There is the <$action-confirm>
widget which does a fine job to display a simple dialog box for OK/Cancel dialog.
What about pure information box ? This would be a simple OK dialog box.
So I tried creating my own, adapting the js code for <$action-confirm>
as shown below:
/*\
title: $:/user/common/widgets/action-ack.js
type: application/javascript
module-type: widget
\*/
(function(){
/*jslint node: true, browser: true */
/*global $tw: false */
"use strict";
var Widget = require("$:/core/modules/widgets/widget.js").widget;
var AckWidget = function(parseTreeNode, options) {
this.initialise(parseTreeNode, options);
};
/*
Inherit from the base widget class
*/
AckWidget.prototype = new Widget();
/*
Render this widget into the DOM
*/
AckWidget.prototype.render = function(parent, nextSibling) {
this.computeAttributes();
this.execute();
this.parentDomNode = parent;
this.renderChildren(parent, nextSibling);
};
/*
Compute the internal state of the widget
*/
AckWidget.prototype.execute = function() {
this.message = this.getAttribute("$message", "By Jove!");
this.prompt = this.getAttribute("$prompt", "OK");
this.makeChildWidgets();
};
/*
Refresh the widget by ensuring our attributes are up to date
*/
AckWidget.prototype.refresh = function(changedTiddlers) {
var changedAttributes = this.computeAttributes();
if(changedAttributes["$message"] || changedAttributes["$prompt"]) {
this.refreshSelf();
return true;
}
return this.refreshChildren(changedTiddlers);
};
/*
Invoke the action associated with this widget
*/
AckWidget.prototype.invokeAction = function(triggeringWidget, event) {
var invokeActions = true,
handled = true,
win = event && event.event && event.event.view ? event.event.view : window;
if(this.prompt) {
invokeActions = win.confirm(this.message);
}
if(invokeActions) {
handled = this.invokeActions(triggeringWidget, event);
}
return handled;
};
AckWidget.prototype.allowActionPropagation = function() {
return false;
};
exports["action-ack"] = AckWidget;
})();
There is just a problem: I still have both OK and Cancel buttons in the dialog box. This means I still needs to have a proper template or customize the parameters for the template currently in use. But where is that template?
TIA for all you clever folks!