2013-03-10 19:24:22 +00:00
|
|
|
/*\
|
2013-05-31 12:23:25 +00:00
|
|
|
title: $:/core/modules/widgets/info.js
|
2013-03-10 19:24:22 +00:00
|
|
|
type: application/javascript
|
|
|
|
module-type: widget
|
|
|
|
|
|
|
|
Implements the info widget that displays various information about a specified tiddler.
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var InfoWidget = function(renderer) {
|
|
|
|
// Save state
|
|
|
|
this.renderer = renderer;
|
|
|
|
// Generate child nodes
|
|
|
|
this.generate();
|
|
|
|
};
|
|
|
|
|
|
|
|
InfoWidget.types = {
|
2013-06-02 22:20:24 +00:00
|
|
|
changecount: function(options) {return options.wiki.getChangeCount(options.widget.renderer.tiddlerTitle);},
|
|
|
|
currentField: function(options) {return options.widget.renderer.renderTree.getContextVariable(options.widget.renderer,"field","text");}
|
2013-03-10 19:24:22 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
InfoWidget.prototype.generate = function() {
|
|
|
|
// Get attributes
|
|
|
|
this.type = this.renderer.getAttribute("type","changecount");
|
|
|
|
// Get the appropriate value for the current tiddler
|
|
|
|
var value = "",
|
|
|
|
fn = InfoWidget.types[this.type];
|
|
|
|
if(fn) {
|
|
|
|
value = fn({
|
|
|
|
wiki: this.renderer.renderTree.wiki,
|
2013-06-02 22:20:24 +00:00
|
|
|
widget: this
|
2013-03-10 19:24:22 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
// Set the element
|
|
|
|
this.tag = "span";
|
|
|
|
this.attributes = {};
|
2013-05-15 16:32:17 +00:00
|
|
|
this.children = this.renderer.renderTree.createRenderers(this.renderer,[{
|
2013-03-10 19:24:22 +00:00
|
|
|
type: "text",
|
|
|
|
text: value
|
|
|
|
}]);
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.info = InfoWidget;
|
|
|
|
|
|
|
|
})();
|