2012-04-30 11:23:03 +00:00
|
|
|
/*\
|
2012-05-03 20:47:16 +00:00
|
|
|
title: $:/core/modules/treenodes/entity.js
|
2012-04-30 11:23:03 +00:00
|
|
|
type: application/javascript
|
|
|
|
module-type: treenode
|
|
|
|
|
|
|
|
Entity nodes
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(function(){
|
|
|
|
|
2012-05-04 17:49:04 +00:00
|
|
|
/*jslint node: true, browser: true */
|
|
|
|
/*global $tw: false */
|
2012-04-30 11:23:03 +00:00
|
|
|
"use strict";
|
|
|
|
|
|
|
|
var Node = require("./node.js").Node;
|
|
|
|
|
|
|
|
var Entity = function(entity) {
|
|
|
|
if(this instanceof Entity) {
|
|
|
|
this.entity = entity;
|
|
|
|
} else {
|
|
|
|
return new Entity(entity);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
Entity.prototype = new Node();
|
|
|
|
Entity.prototype.constructor = Entity;
|
|
|
|
|
|
|
|
Entity.prototype.render = function(type) {
|
|
|
|
return type === "text/html" ? this.entity : $tw.utils.entityDecode(this.entity);
|
|
|
|
};
|
|
|
|
|
|
|
|
Entity.prototype.renderInDom = function(domNode) {
|
|
|
|
this.domNode = document.createTextNode($tw.utils.entityDecode(this.entity));
|
|
|
|
domNode.appendChild(this.domNode);
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.Entity = Entity;
|
|
|
|
|
|
|
|
})();
|