mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-29 12:32:40 +00:00
![Jeremy Ruston](/assets/img/avatar_default.png)
This arrangement takes better advantage of the similarities between the now deleted widget renderer and the element renderer. It also obviates the need for wrapper elements around every widget.
42 lines
963 B
JavaScript
42 lines
963 B
JavaScript
/*\
|
|
title: $:/core/modules/widgets/view/viewers/date.js
|
|
type: application/javascript
|
|
module-type: fieldviewer
|
|
|
|
A viewer for viewing tiddler fields as a date
|
|
|
|
\*/
|
|
(function(){
|
|
|
|
/*jslint node: true, browser: true */
|
|
/*global $tw: false */
|
|
"use strict";
|
|
|
|
var DateViewer = function(viewWidget,tiddler,field,value) {
|
|
this.viewWidget = viewWidget;
|
|
this.tiddler = tiddler;
|
|
this.field = field;
|
|
this.value = value;
|
|
};
|
|
|
|
DateViewer.prototype.render = function() {
|
|
var template = this.viewWidget.renderer.getAttribute("template","DD MMM YYYY"),
|
|
value = "";
|
|
if(this.value !== undefined) {
|
|
value = $tw.utils.formatDateString(this.value,template);
|
|
}
|
|
// Set the element details
|
|
this.viewWidget.tag = "span";
|
|
this.viewWidget.attributes = {
|
|
"class": "tw-view-date"
|
|
};
|
|
this.viewWidget.children = this.viewWidget.renderer.renderTree.createRenderers(this.viewWidget.renderer.renderContext,[{
|
|
type: "text",
|
|
text: value
|
|
}]);
|
|
};
|
|
|
|
exports.date = DateViewer;
|
|
|
|
})();
|