1
0
mirror of https://github.com/Jermolene/TiddlyWiki5 synced 2024-11-23 18:17:20 +00:00

Add "enabled" attribute to draggable widget (#6581)

* Add "enabled" attribute to draggable widget

* Update draggable.js

* Update draggable.js

* Update draggable.js
This commit is contained in:
Simon Huber 2022-04-15 15:17:06 +02:00 committed by GitHub
parent 58dd47d128
commit 030155ec27
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -48,7 +48,7 @@ DraggableWidget.prototype.render = function(parent,nextSibling) {
if(this.draggableClasses) {
classes.push(this.draggableClasses);
}
if(!this.dragHandleSelector) {
if(!this.dragHandleSelector && this.dragEnable) {
classes.push("tc-draggable");
}
domNode.setAttribute("class",classes.join(" "));
@ -56,6 +56,7 @@ DraggableWidget.prototype.render = function(parent,nextSibling) {
parent.insertBefore(domNode,nextSibling);
this.renderChildren(domNode,null);
// Add event handlers
if(this.dragEnable) {
$tw.utils.makeDraggable({
domNode: domNode,
dragTiddlerFn: function() {return self.getAttribute("tiddler");},
@ -66,6 +67,7 @@ DraggableWidget.prototype.render = function(parent,nextSibling) {
widget: this,
selector: self.dragHandleSelector
});
}
this.domNodes.push(domNode);
};
@ -80,6 +82,7 @@ DraggableWidget.prototype.execute = function() {
this.endActions = this.getAttribute("endactions");
this.dragImageType = this.getAttribute("dragimagetype");
this.dragHandleSelector = this.getAttribute("selector");
this.dragEnable = this.getAttribute("enable","yes") === "yes";
// Make the child widgets
this.makeChildWidgets();
};
@ -89,7 +92,7 @@ Selectively refreshes the widget if needed. Returns true if the widget or any of
*/
DraggableWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes.tag || changedAttributes["class"]) {
if($tw.utils.count(changedAttributes) > 0) {
this.refreshSelf();
return true;
}