-
-
Save saqimtiaz/4733d7a81784103d66610275a2160c93 to your computer and use it in GitHub Desktop.
Example action-widget for TW5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*\ | |
title: $:/core/modules/widgets/action-alert.js | |
type: application/javascript | |
module-type: widget | |
Action widget to log debug messages | |
\*/ | |
(function(){ | |
/*jslint node: true, browser: true */ | |
/*global $tw: false */ | |
"use strict"; | |
var Widget = require("$:/core/modules/widgets/widget.js").widget; | |
var AlertWidget = function(parseTreeNode,options) { | |
this.initialise(parseTreeNode,options); | |
}; | |
/* | |
Inherit from the base widget class | |
*/ | |
AlertWidget.prototype = new Widget(); | |
/* | |
Render this widget into the DOM | |
*/ | |
AlertWidget.prototype.render = function(parent,nextSibling) { | |
this.computeAttributes(); | |
this.execute(); | |
}; | |
AlertWidget.prototype.execute = function(){ | |
this.message = this.getAttribute("message",""); | |
} | |
/* | |
Refresh the widget by ensuring our attributes are up to date | |
*/ | |
AlertWidget.prototype.refresh = function(changedTiddlers) { | |
this.refreshSelf(); | |
return true; | |
}; | |
/* | |
Invoke the action associated with this widget | |
*/ | |
AlertWidget.prototype.invokeAction = function(triggeringWidget,event) { | |
alert(this.message); | |
return true; // Action was invoked | |
}; | |
exports["action-alert"] = AlertWidget; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment