mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-11-04 09:06:18 +00:00
64 lines
1.3 KiB
JavaScript
64 lines
1.3 KiB
JavaScript
|
/*\
|
||
|
title: $:/core/modules/new_widgets/text.js
|
||
|
type: application/javascript
|
||
|
module-type: new_widget
|
||
|
|
||
|
Text node widget
|
||
|
|
||
|
\*/
|
||
|
(function(){
|
||
|
|
||
|
/*jslint node: true, browser: true */
|
||
|
/*global $tw: false */
|
||
|
"use strict";
|
||
|
|
||
|
var Widget = require("$:/core/modules/new_widgets/widget.js").widget;
|
||
|
|
||
|
var TextNodeWidget = function(parseTreeNode,options) {
|
||
|
this.initialise(parseTreeNode,options);
|
||
|
};
|
||
|
|
||
|
/*
|
||
|
Inherit from the base widget class
|
||
|
*/
|
||
|
TextNodeWidget.prototype = new Widget();
|
||
|
|
||
|
/*
|
||
|
Render this widget into the DOM
|
||
|
*/
|
||
|
TextNodeWidget.prototype.render = function(parent,nextSibling) {
|
||
|
this.parentDomNode = parent;
|
||
|
this.execute();
|
||
|
var textNode = this.document.createTextNode(this.parseTreeNode.text);
|
||
|
parent.insertBefore(textNode,nextSibling);
|
||
|
this.domNodes.push(textNode);
|
||
|
};
|
||
|
|
||
|
/*
|
||
|
Compute the internal state of the widget
|
||
|
*/
|
||
|
TextNodeWidget.prototype.execute = function() {
|
||
|
// Nothing to do for a text node
|
||
|
};
|
||
|
|
||
|
/*
|
||
|
Selectively refreshes the widget if needed. Returns true if the widget or any of its children needed re-rendering
|
||
|
*/
|
||
|
TextNodeWidget.prototype.refresh = function(changedTiddlers) {
|
||
|
return false;
|
||
|
};
|
||
|
|
||
|
/*
|
||
|
Remove any DOM nodes created by this widget
|
||
|
*/
|
||
|
TextNodeWidget.prototype.removeChildDomNodes = function() {
|
||
|
$tw.utils.each(this.domNodes,function(domNode) {
|
||
|
domNode.parentNode.removeChild(domNode);
|
||
|
});
|
||
|
this.domNodes = [];
|
||
|
};
|
||
|
|
||
|
exports.text = TextNodeWidget;
|
||
|
|
||
|
})();
|