mirror of
https://github.com/TiddlyWiki/TiddlyWiki5.git
synced 2026-05-02 10:27:41 +00:00
Add support for action widgets
This is part of the groundwork for fixing #336
This commit is contained in:
@@ -59,6 +59,9 @@ ButtonWidget.prototype.render = function(parent,nextSibling) {
|
||||
// Add a click event handler
|
||||
domNode.addEventListener("click",function (event) {
|
||||
var handled = false;
|
||||
if(self.invokeActions(event)) {
|
||||
handled = true;
|
||||
}
|
||||
if(self.to) {
|
||||
self.navigateTo(event);
|
||||
handled = true;
|
||||
@@ -87,6 +90,10 @@ ButtonWidget.prototype.render = function(parent,nextSibling) {
|
||||
this.domNodes.push(domNode);
|
||||
};
|
||||
|
||||
ButtonWidget.prototype.getBoundingClientRect = function() {
|
||||
return this.domNodes[0].getBoundingClientRect();
|
||||
}
|
||||
|
||||
ButtonWidget.prototype.isSelected = function() {
|
||||
var tiddler = this.wiki.getTiddler(this.set);
|
||||
return tiddler ? tiddler.fields.text === this.setTo : this.defaultSetValue === this.setTo;
|
||||
@@ -99,7 +106,7 @@ ButtonWidget.prototype.isPoppedUp = function() {
|
||||
};
|
||||
|
||||
ButtonWidget.prototype.navigateTo = function(event) {
|
||||
var bounds = this.domNodes[0].getBoundingClientRect();
|
||||
var bounds = this.getBoundingClientRect();
|
||||
this.dispatchEvent({
|
||||
type: "tm-navigate",
|
||||
navigateTo: this.to,
|
||||
|
||||
Reference in New Issue
Block a user