mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-23 10:07:19 +00:00
Improve ability to disable drag and drop
Now we disable the draggable list macros too.
This commit is contained in:
parent
561662782e
commit
cb52d709c2
@ -43,12 +43,14 @@ DroppableWidget.prototype.render = function(parent,nextSibling) {
|
|||||||
classes.push("tc-droppable");
|
classes.push("tc-droppable");
|
||||||
domNode.className = classes.join(" ");
|
domNode.className = classes.join(" ");
|
||||||
// Add event handlers
|
// Add event handlers
|
||||||
$tw.utils.addEventListeners(domNode,[
|
if(this.droppableEnable) {
|
||||||
{name: "dragenter", handlerObject: this, handlerMethod: "handleDragEnterEvent"},
|
$tw.utils.addEventListeners(domNode,[
|
||||||
{name: "dragover", handlerObject: this, handlerMethod: "handleDragOverEvent"},
|
{name: "dragenter", handlerObject: this, handlerMethod: "handleDragEnterEvent"},
|
||||||
{name: "dragleave", handlerObject: this, handlerMethod: "handleDragLeaveEvent"},
|
{name: "dragover", handlerObject: this, handlerMethod: "handleDragOverEvent"},
|
||||||
{name: "drop", handlerObject: this, handlerMethod: "handleDropEvent"}
|
{name: "dragleave", handlerObject: this, handlerMethod: "handleDragLeaveEvent"},
|
||||||
]);
|
{name: "drop", handlerObject: this, handlerMethod: "handleDropEvent"}
|
||||||
|
]);
|
||||||
|
}
|
||||||
// Insert element
|
// Insert element
|
||||||
parent.insertBefore(domNode,nextSibling);
|
parent.insertBefore(domNode,nextSibling);
|
||||||
this.renderChildren(domNode,null);
|
this.renderChildren(domNode,null);
|
||||||
@ -142,6 +144,7 @@ DroppableWidget.prototype.execute = function() {
|
|||||||
this.droppableEffect = this.getAttribute("effect","copy");
|
this.droppableEffect = this.getAttribute("effect","copy");
|
||||||
this.droppableTag = this.getAttribute("tag");
|
this.droppableTag = this.getAttribute("tag");
|
||||||
this.droppableClass = this.getAttribute("class");
|
this.droppableClass = this.getAttribute("class");
|
||||||
|
this.droppableEnable = (this.getAttribute("enable") || "yes") === "yes";
|
||||||
// Make child widgets
|
// Make child widgets
|
||||||
this.makeChildWidgets();
|
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) {
|
DroppableWidget.prototype.refresh = function(changedTiddlers) {
|
||||||
var changedAttributes = this.computeAttributes();
|
var changedAttributes = this.computeAttributes();
|
||||||
if(changedAttributes["class"] || changedAttributes.tag) {
|
if(changedAttributes["class"] || changedAttributes.tag || changedAttributes.enable) {
|
||||||
this.refreshSelf();
|
this.refreshSelf();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -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-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="tv-show-missing-links" value={{$:/config/MissingLinks}}>
|
||||||
|
|
||||||
<$set name="storyviewTitle" value={{$:/view}}>
|
<$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}}>
|
<$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">
|
<$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>
|
</$set>
|
||||||
|
|
||||||
|
</$set>
|
||||||
|
@ -15,7 +15,7 @@ caption: {{$:/language/SideBar/Open/Caption}}
|
|||||||
|
|
||||||
\define droppable-item(button)
|
\define droppable-item(button)
|
||||||
\whitespace trim
|
\whitespace trim
|
||||||
<$droppable actions=<<drop-actions>>>
|
<$droppable actions=<<drop-actions>> enable=<<tv-allow-drag-and-drop>>>
|
||||||
<<placeholder>>
|
<<placeholder>>
|
||||||
<div>
|
<div>
|
||||||
$button$
|
$button$
|
||||||
|
@ -26,7 +26,7 @@ tags: $:/tags/Macro
|
|||||||
<$vars targetTiddler="""$tiddler$""" targetField="""$field$""">
|
<$vars targetTiddler="""$tiddler$""" targetField="""$field$""">
|
||||||
<$type$ class="$class$">
|
<$type$ class="$class$">
|
||||||
<$list filter="[list[$tiddler$!!$field$]]">
|
<$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 class="tc-droppable-placeholder"/>
|
||||||
<div>
|
<div>
|
||||||
<$transclude tiddler="""$itemTemplate$""">
|
<$transclude tiddler="""$itemTemplate$""">
|
||||||
@ -41,7 +41,7 @@ tags: $:/tags/Macro
|
|||||||
</$list>
|
</$list>
|
||||||
</$type$>
|
</$type$>
|
||||||
<$tiddler tiddler="">
|
<$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">
|
<div class="tc-droppable-placeholder">
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
@ -80,7 +80,7 @@ tags: $:/tags/Macro
|
|||||||
<$set name="tag" value=<<__tag__>>>
|
<$set name="tag" value=<<__tag__>>>
|
||||||
<$list filter="[<__tag__>tagging[]$subFilter$]" emptyMessage=<<__emptyMessage__>> storyview=<<__storyview__>>>
|
<$list filter="[<__tag__>tagging[]$subFilter$]" emptyMessage=<<__emptyMessage__>> storyview=<<__storyview__>>>
|
||||||
<$elementTag$ class="tc-menu-list-item">
|
<$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$ class="tc-droppable-placeholder"/>
|
||||||
<$elementTag$>
|
<$elementTag$>
|
||||||
<$transclude tiddler="""$itemTemplate$""">
|
<$transclude tiddler="""$itemTemplate$""">
|
||||||
@ -93,7 +93,7 @@ tags: $:/tags/Macro
|
|||||||
</$elementTag$>
|
</$elementTag$>
|
||||||
</$list>
|
</$list>
|
||||||
<$tiddler tiddler="">
|
<$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$ class="tc-droppable-placeholder"/>
|
||||||
<$elementTag$ style="height:0.5em;">
|
<$elementTag$ style="height:0.5em;">
|
||||||
</$elementTag$>
|
</$elementTag$>
|
||||||
|
@ -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.
|
@ -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
|
|
@ -1,6 +1,6 @@
|
|||||||
caption: droppable
|
caption: droppable
|
||||||
created: 20170406082820317
|
created: 20170406082820317
|
||||||
modified: 20190118084621046
|
modified: 20200317142604572
|
||||||
tags: Widgets
|
tags: Widgets
|
||||||
title: DroppableWidget
|
title: DroppableWidget
|
||||||
type: text/vnd.tiddlywiki
|
type: text/vnd.tiddlywiki
|
||||||
@ -30,6 +30,7 @@ See DragAndDropMechanism for an overview.
|
|||||||
|actions |Actions to be performed when items are dropped |
|
|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 |
|
|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 |
|
|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:
|
Within the action string, there are two Variables generated by the DroppableWidget:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user