mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-08-28 12:02:40 +00:00
![Jeremy Ruston](/assets/img/avatar_default.png)
Get rid of the separate renderContext stack and instead have a parent pointer on renderer nodes. This lets us walk back up the render tree to resolve context references
42 lines
949 B
JavaScript
42 lines
949 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,[{
|
|
type: "text",
|
|
text: value
|
|
}]);
|
|
};
|
|
|
|
exports.date = DateViewer;
|
|
|
|
})();
|