1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-27 03:57:21 +00:00

Improve ability to disable drag and drop

Now we disable the draggable list macros too.
This commit is contained in:
Jeremy Ruston 2020-03-20 10:46:17 +00:00
parent 561662782e
commit cb52d709c2
7 changed files with 41 additions and 23 deletions

View File

@ -43,12 +43,14 @@ DroppableWidget.prototype.render = function(parent,nextSibling) {
classes.push("tc-droppable");
domNode.className = classes.join(" ");
// Add event handlers
if(this.droppableEnable) {
$tw.utils.addEventListeners(domNode,[
{name: "dragenter", handlerObject: this, handlerMethod: "handleDragEnterEvent"},
{name: "dragover", handlerObject: this, handlerMethod: "handleDragOverEvent"},
{name: "dragleave", handlerObject: this, handlerMethod: "handleDragLeaveEvent"},
{name: "drop", handlerObject: this, handlerMethod: "handleDropEvent"}
]);
}
// Insert element
parent.insertBefore(domNode,nextSibling);
this.renderChildren(domNode,null);
@ -142,6 +144,7 @@ DroppableWidget.prototype.execute = function() {
this.droppableEffect = this.getAttribute("effect","copy");
this.droppableTag = this.getAttribute("tag");
this.droppableClass = this.getAttribute("class");
this.droppableEnable = (this.getAttribute("enable") || "yes") === "yes";
// Make child widgets
this.makeChildWidgets();
};
@ -151,7 +154,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/
DroppableWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes["class"] || changedAttributes.tag) {
if(changedAttributes["class"] || changedAttributes.tag || changedAttributes.enable) {
this.refreshSelf();
return true;
}

View File

@ -12,6 +12,8 @@ tc-page-container tc-page-view-$(storyviewTitle)$ tc-language-$(languageTitle)$
<$set name="tv-config-toolbar-class" value={{$:/config/Toolbar/ButtonClass}}>
<$set name="tv-enable-drag-and-drop" value={{$:/config/DragAndDrop/Enable}}>
<$set name="tv-show-missing-links" value={{$:/config/MissingLinks}}>
<$set name="storyviewTitle" value={{$:/view}}>
@ -22,7 +24,7 @@ tc-page-container tc-page-view-$(storyviewTitle)$ tc-language-$(languageTitle)$
<$navigator story="$:/StoryList" history="$:/HistoryList" openLinkFromInsideRiver={{$:/config/Navigation/openLinkFromInsideRiver}} openLinkFromOutsideRiver={{$:/config/Navigation/openLinkFromOutsideRiver}} relinkOnRename={{$:/config/RelinkOnRename}}>
<$dropzone enable={{$:/config/PageDropzone/Enable}}>
<$dropzone enable=<<tv-enable-drag-and-drop>>>
<$list filter="[all[shadows+tiddlers]tag[$:/tags/PageTemplate]!has[draft.of]]" variable="listItem">
@ -47,3 +49,5 @@ tc-page-container tc-page-view-$(storyviewTitle)$ tc-language-$(languageTitle)$
</$set>
</$set>
</$set>

View File

@ -15,7 +15,7 @@ caption: {{$:/language/SideBar/Open/Caption}}
\define droppable-item(button)
\whitespace trim
<$droppable actions=<<drop-actions>>>
<$droppable actions=<<drop-actions>> enable=<<tv-allow-drag-and-drop>>>
<<placeholder>>
<div>
$button$

View File

@ -26,7 +26,7 @@ tags: $:/tags/Macro
<$vars targetTiddler="""$tiddler$""" targetField="""$field$""">
<$type$ class="$class$">
<$list filter="[list[$tiddler$!!$field$]]">
<$droppable actions=<<list-links-draggable-drop-actions>> tag="""$subtype$""">
<$droppable actions=<<list-links-draggable-drop-actions>> tag="""$subtype$""" enable=<<tv-enable-drag-and-drop>>>
<div class="tc-droppable-placeholder"/>
<div>
<$transclude tiddler="""$itemTemplate$""">
@ -41,7 +41,7 @@ tags: $:/tags/Macro
</$list>
</$type$>
<$tiddler tiddler="">
<$droppable actions=<<list-links-draggable-drop-actions>> tag="div">
<$droppable actions=<<list-links-draggable-drop-actions>> tag="div" enable=<<tv-enable-drag-and-drop>>>
<div class="tc-droppable-placeholder">
&nbsp;
</div>
@ -80,7 +80,7 @@ tags: $:/tags/Macro
<$set name="tag" value=<<__tag__>>>
<$list filter="[<__tag__>tagging[]$subFilter$]" emptyMessage=<<__emptyMessage__>> storyview=<<__storyview__>>>
<$elementTag$ class="tc-menu-list-item">
<$droppable actions="""<$macrocall $name="list-tagged-draggable-drop-actions" tag=<<__tag__>>/>""">
<$droppable actions="""<$macrocall $name="list-tagged-draggable-drop-actions" tag=<<__tag__>>/>""" enable=<<tv-enable-drag-and-drop>>>
<$elementTag$ class="tc-droppable-placeholder"/>
<$elementTag$>
<$transclude tiddler="""$itemTemplate$""">
@ -93,7 +93,7 @@ tags: $:/tags/Macro
</$elementTag$>
</$list>
<$tiddler tiddler="">
<$droppable actions="""<$macrocall $name="list-tagged-draggable-drop-actions" tag=<<__tag__>>/>""">
<$droppable actions="""<$macrocall $name="list-tagged-draggable-drop-actions" tag=<<__tag__>>/>""" enable=<<tv-enable-drag-and-drop>>>
<$elementTag$ class="tc-droppable-placeholder"/>
<$elementTag$ style="height:0.5em;">
</$elementTag$>

View File

@ -0,0 +1,19 @@
created: 20200315143638556
modified: 20200315143638556
tags: [[Hidden Settings]]
title: Hidden Setting: Disable Drag and Drop
type: text/vnd.tiddlywiki
To disable all the drag and drop operations that are built into the core, set the following tiddler to "no":
$:/config/DragAndDrop/Enable
To selectively re-enable drag and drop for an instance of the [[list-tagged-draggable Macro]] or [[list-links-draggable Macro]] you must ensure that the variable `tv-enable-drag-and-drop` is set to `yes` for the scope of the macro invocation. For example:
<$macrocall $name="wikitext-example-without-html" src="""<$set name="tv-enable-drag-and-drop" value="yes">
<<list-tagged-draggable tag:"Features">>
</$set>"""/>
Note that when using the DropzoneWidget and the DroppableWidget directly the ''enable'' attribute works independently of the global setting.

View File

@ -1,9 +0,0 @@
created: 20200315143638556
modified: 20200315143638556
tags: [[Hidden Settings]]
title: Hidden Setting: Disable Page Dropzone
type: text/vnd.tiddlywiki
To disable the main DropzoneWidget, set the following tiddler to "no":
$:/config/PageDropzone/Enable

View File

@ -1,6 +1,6 @@
caption: droppable
created: 20170406082820317
modified: 20190118084621046
modified: 20200317142604572
tags: Widgets
title: DroppableWidget
type: text/vnd.tiddlywiki
@ -30,6 +30,7 @@ See DragAndDropMechanism for an overview.
|actions |Actions to be performed when items are dropped |
|class |Optional CSS classes to assign to the draggable element. The class `tc-droppable` is added automatically, and the class `tc-dragover` is applied while an item is being dragged over the droppable element |
|tag |Optional tag to override the default of a "div" element when the widget is rendered in block mode, or a "span" element when it is rendered in inline mode |
|enable |<<.from-version "5.1.22">> Optional value "no" to disable the droppable functionality (defaults to "yes") |
Within the action string, there are two Variables generated by the DroppableWidget: