1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-12-25 01:20:30 +00:00

Add a hidden setting for disabling the page dropzone

This commit is contained in:
Jeremy Ruston 2020-03-15 14:46:33 +00:00
parent a6f6db40d9
commit bc687e5783
4 changed files with 28 additions and 10 deletions

View File

@ -37,6 +37,7 @@ DropZoneWidget.prototype.render = function(parent,nextSibling) {
var domNode = this.document.createElement("div"); var domNode = this.document.createElement("div");
domNode.className = "tc-dropzone"; domNode.className = "tc-dropzone";
// Add event handlers // Add event handlers
if(this.dropzoneEnable) {
$tw.utils.addEventListeners(domNode,[ $tw.utils.addEventListeners(domNode,[
{name: "dragenter", handlerObject: this, handlerMethod: "handleDragEnterEvent"}, {name: "dragenter", handlerObject: this, handlerMethod: "handleDragEnterEvent"},
{name: "dragover", handlerObject: this, handlerMethod: "handleDragOverEvent"}, {name: "dragover", handlerObject: this, handlerMethod: "handleDragOverEvent"},
@ -45,6 +46,7 @@ DropZoneWidget.prototype.render = function(parent,nextSibling) {
{name: "paste", handlerObject: this, handlerMethod: "handlePasteEvent"}, {name: "paste", handlerObject: this, handlerMethod: "handlePasteEvent"},
{name: "dragend", handlerObject: this, handlerMethod: "handleDragEndEvent"} {name: "dragend", handlerObject: this, handlerMethod: "handleDragEndEvent"}
]); ]);
}
domNode.addEventListener("click",function (event) { domNode.addEventListener("click",function (event) {
},false); },false);
// Insert element // Insert element
@ -189,6 +191,7 @@ Compute the internal state of the widget
*/ */
DropZoneWidget.prototype.execute = function() { DropZoneWidget.prototype.execute = function() {
this.dropzoneDeserializer = this.getAttribute("deserializer"); this.dropzoneDeserializer = this.getAttribute("deserializer");
this.dropzoneEnable = (this.getAttribute("enable") || "yes") === "yes";
// Make child widgets // Make child widgets
this.makeChildWidgets(); this.makeChildWidgets();
}; };
@ -197,6 +200,11 @@ DropZoneWidget.prototype.execute = function() {
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
*/ */
DropZoneWidget.prototype.refresh = function(changedTiddlers) { DropZoneWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes.enable) {
this.refreshSelf();
return true;
}
return this.refreshChildren(changedTiddlers); return this.refreshChildren(changedTiddlers);
}; };

View File

@ -22,7 +22,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> <$dropzone enable={{$:/config/PageDropzone/Enable}}>
<$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">

View File

@ -0,0 +1,9 @@
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: dropzone caption: dropzone
created: 20131024141900000 created: 20131024141900000
modified: 20170712153850528 modified: 20200315144454996
tags: Widgets tags: Widgets
title: DropzoneWidget title: DropzoneWidget
type: text/vnd.tiddlywiki type: text/vnd.tiddlywiki
@ -15,6 +15,7 @@ It sends a [[WidgetMessage: tm-import-tiddlers]] carrying a JSON representation
|!Attribute |!Description | |!Attribute |!Description |
|deserializer |<<.from-version "5.1.15">> Optional name of deserializer to be used (by default the deserializer is derived from the file extension) | |deserializer |<<.from-version "5.1.15">> Optional name of deserializer to be used (by default the deserializer is derived from the file extension) |
|enable |<<.from-version "5.1.22">> Optional value "no" to disable the dropzone functionality (defaults to "yes") |
The list of available deserializers can be inspected by executing `Object.keys($tw.Wiki.tiddlerDeserializerModules).sort().join("\n")` in the browser JavaScript console. The list of available deserializers can be inspected by executing `Object.keys($tw.Wiki.tiddlerDeserializerModules).sort().join("\n")` in the browser JavaScript console.