2012-04-30 11:23:03 +00:00
|
|
|
/*\
|
2012-05-03 20:47:16 +00:00
|
|
|
title: $:/core/modules/tree.utils.js
|
2012-04-30 11:23:03 +00:00
|
|
|
type: application/javascript
|
|
|
|
module-type: treeutils
|
|
|
|
|
|
|
|
Static utility methods for the $tw.Tree class
|
|
|
|
|
|
|
|
\*/
|
|
|
|
(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";
|
|
|
|
|
|
|
|
/*
|
|
|
|
Construct an error message
|
|
|
|
*/
|
|
|
|
exports.errorNode = function(text) {
|
|
|
|
return $tw.Tree.Element("span",{
|
|
|
|
"class": ["label","label-important"]
|
|
|
|
},[
|
2012-05-04 17:49:04 +00:00
|
|
|
new $tw.Tree.Text(text)
|
2012-04-30 11:23:03 +00:00
|
|
|
]);
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Construct a label
|
|
|
|
*/
|
|
|
|
exports.labelNode = function(type,value,classes) {
|
|
|
|
classes = (classes || []).slice(0);
|
|
|
|
classes.push("label");
|
|
|
|
return $tw.Tree.Element("span",{
|
|
|
|
"class": classes,
|
|
|
|
"data-tw-label-type": type
|
|
|
|
},value);
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
Construct a split label
|
|
|
|
*/
|
|
|
|
exports.splitLabelNode = function(type,left,right,classes) {
|
|
|
|
classes = (classes || []).slice(0);
|
|
|
|
classes.push("splitLabel");
|
|
|
|
return $tw.Tree.Element("span",{
|
|
|
|
"class": classes
|
|
|
|
},[
|
|
|
|
$tw.Tree.Element("span",{
|
|
|
|
"class": ["splitLabelLeft"],
|
|
|
|
"data-tw-label-type": type
|
|
|
|
},left),
|
|
|
|
$tw.Tree.Element("span",{
|
|
|
|
"class": ["splitLabelRight"]
|
|
|
|
},right)
|
|
|
|
]);
|
|
|
|
};
|
|
|
|
|
|
|
|
})();
|