aboutsummaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
Diffstat (limited to 'js/lib')
-rwxr-xr-xjs/lib/NJUtils.js32
1 files changed, 23 insertions, 9 deletions
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js
index dae128e4..301af3f1 100755
--- a/js/lib/NJUtils.js
+++ b/js/lib/NJUtils.js
@@ -54,13 +54,25 @@ exports.NJUtils = Object.create(Object.prototype, {
54 return document.createTextNode(text); 54 return document.createTextNode(text);
55 } 55 }
56 }, 56 },
57 57
58 ///// Quick "createElement" function "attr" can be classname or object 58 ///// Quick "createElement" function "attr" can be classname or object
59 ///// with attribute key/values 59 ///// with attribute key/values
60 ///// Suppor for data attributes 60 ///// Support for data attributes
61 make : { 61 ///// Support user/ninja document
62 value: function(tag, attr) { 62 make: {
63 var el = document.createElement(tag); 63 value: function(tag, attr, doc) {
64 var _doc, el;
65
66 _doc = doc ? doc._document : document;
67 el = _doc.createElement(tag);
68 this.decor(el, attr);
69
70 return el;
71 }
72 },
73
74 decor: {
75 value: function(el, attr) {
64 if (typeof attr === 'object') { 76 if (typeof attr === 'object') {
65 for (var a in attr) { 77 for (var a in attr) {
66 if (attr.hasOwnProperty(a)) { 78 if (attr.hasOwnProperty(a)) {
@@ -74,8 +86,12 @@ exports.NJUtils = Object.create(Object.prototype, {
74 } else if (typeof attr === 'string') { 86 } else if (typeof attr === 'string') {
75 el.className = (el.className + ' ' + attr).trim(); 87 el.className = (el.className + ' ' + attr).trim();
76 } 88 }
77 89 }
78 return el; 90 },
91
92 createModel: {
93 value: function(el) {
94 el.elementModel = Montage.create(ElementModel).initialize(el);
79 } 95 }
80 }, 96 },
81 97
@@ -94,8 +110,6 @@ exports.NJUtils = Object.create(Object.prototype, {
94 ///// TODO: find a different place for this function 110 ///// TODO: find a different place for this function
95 makeElementModel: { 111 makeElementModel: {
96 value: function(el, selection, controller, isShape) { 112 value: function(el, selection, controller, isShape) {
97 //el.elementModel = Montage.create(ElementModel).initialize(el.nodeName, selection, controller, isShape);
98
99 var p3d = Montage.create(Properties3D); 113 var p3d = Montage.create(Properties3D);
100 114
101 var shapeProps = null; 115 var shapeProps = null;