diff options
author | Jose Antonio Marquez | 2012-02-16 23:12:11 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-02-16 23:12:11 -0800 |
commit | e404c691b84ca8fd1ab17fc6187bccb3f94258fb (patch) | |
tree | 7547d267a629ac717553e98e34a4d02543d529b7 /js | |
parent | cfc2a432323d4620b1f4ca2061bbe57f46e7eaf7 (diff) | |
parent | e67d1f472dab28b4ff6afc9d9cc06b34756e26b5 (diff) | |
download | ninja-e404c691b84ca8fd1ab17fc6187bccb3f94258fb.tar.gz |
Merge branch 'refs/heads/NinjaInternal' into FileIO
Diffstat (limited to 'js')
-rwxr-xr-x | js/controllers/elements/component-controller.js | 53 | ||||
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 1 | ||||
-rw-r--r-- | js/document/templates/montage-html/main.reel/main.js | 5 | ||||
-rwxr-xr-x | js/lib/NJUtils.js | 22 | ||||
-rwxr-xr-x | js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js | 99 | ||||
-rwxr-xr-x | js/tools/BrushTool.js | 2 | ||||
-rwxr-xr-x | js/tools/LineTool.js | 2 | ||||
-rwxr-xr-x | js/tools/PenTool.js | 2 | ||||
-rwxr-xr-x | js/tools/ShapeTool.js | 2 |
9 files changed, 153 insertions, 35 deletions
diff --git a/js/controllers/elements/component-controller.js b/js/controllers/elements/component-controller.js index 33b9b79a..83450d0f 100755 --- a/js/controllers/elements/component-controller.js +++ b/js/controllers/elements/component-controller.js | |||
@@ -12,20 +12,19 @@ exports.ComponentController = Montage.create(ElementController, { | |||
12 | getProperty: { | 12 | getProperty: { |
13 | value: function(el, prop) { | 13 | value: function(el, prop) { |
14 | switch(prop) { | 14 | switch(prop) { |
15 | case "label": | 15 | case "id": |
16 | return this.application.ninja.currentDocument.getComponentFromElement(el).label; | 16 | case "class": |
17 | break; | 17 | case "left": |
18 | case "enabled": | 18 | case "top": |
19 | return this.application.ninja.currentDocument.getComponentFromElement(el).enabled; | 19 | case "width": |
20 | break; | 20 | case "height": |
21 | case "disabled": | 21 | if(el.nodeName === "IMG" && (prop === "width" || prop === "height")) { |
22 | return this.application.ninja.currentDocument.getComponentFromElement(el).disabled; | 22 | return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; |
23 | break; | 23 | } else { |
24 | case "value": | 24 | return ElementController.getProperty(el, prop, true); |
25 | return this.application.ninja.currentDocument.getComponentFromElement(el).value; | 25 | } |
26 | break; | ||
27 | default: | 26 | default: |
28 | return ElementController.getProperty(el, prop, true); | 27 | return this.application.ninja.currentDocument.getComponentFromElement(el)[prop]; |
29 | } | 28 | } |
30 | } | 29 | } |
31 | }, | 30 | }, |
@@ -33,20 +32,24 @@ exports.ComponentController = Montage.create(ElementController, { | |||
33 | setProperty: { | 32 | setProperty: { |
34 | value: function(el, p, value) { | 33 | value: function(el, p, value) { |
35 | switch(p) { | 34 | switch(p) { |
36 | case "label": | 35 | case "id": |
37 | this.application.ninja.currentDocument.getComponentFromElement(el).label = value; | 36 | case "class": |
38 | break; | 37 | case "left": |
39 | case "enabled": | 38 | case "top": |
40 | this.application.ninja.currentDocument.getComponentFromElement(el).enabled = value; | 39 | case "width": |
41 | break; | 40 | case "height": |
42 | case "disabled": | 41 | if(el.nodeName === "IMG" && (p === "width" || p === "height")) { |
43 | this.application.ninja.currentDocument.getComponentFromElement(el).disabled = value; | 42 | this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value; |
44 | break; | 43 | } else { |
45 | case "value": | 44 | ElementController.setProperty(el, p, value); |
46 | this.application.ninja.currentDocument.getComponentFromElement(el).value = value; | 45 | } |
47 | break; | 46 | break; |
48 | default: | 47 | default: |
49 | ElementController.setProperty(el, p, value); | 48 | if(p === "min" || p === "max") value = parseFloat(value); |
49 | |||
50 | this.application.ninja.currentDocument.getComponentFromElement(el)[p] = value; | ||
51 | break; | ||
52 | |||
50 | } | 53 | } |
51 | } | 54 | } |
52 | } | 55 | } |
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 640119c4..15a18a51 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js | |||
@@ -59,6 +59,7 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
59 | break; | 59 | break; |
60 | case "useWebGl": | 60 | case "useWebGl": |
61 | var canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true); | 61 | var canvas = njModule.NJUtils.makeNJElement("canvas", "Canvas", "shape", el.className, true); |
62 | canvas.setAttribute("data-RDGE-id", njModule.NJUtils.generateRandom()); | ||
62 | canvas.width = el.width; | 63 | canvas.width = el.width; |
63 | canvas.height = el.height; | 64 | canvas.height = el.height; |
64 | this.application.ninja.elementMediator.replaceElement(el, canvas); | 65 | this.application.ninja.elementMediator.replaceElement(el, canvas); |
diff --git a/js/document/templates/montage-html/main.reel/main.js b/js/document/templates/montage-html/main.reel/main.js index 86871fd3..567f481c 100644 --- a/js/document/templates/montage-html/main.reel/main.js +++ b/js/document/templates/montage-html/main.reel/main.js | |||
@@ -6,8 +6,6 @@ | |||
6 | var Montage = require("montage/core/core").Montage, | 6 | var Montage = require("montage/core/core").Montage, |
7 | Component = require("montage/ui/component").Component; | 7 | Component = require("montage/ui/component").Component; |
8 | 8 | ||
9 | //var Button = ("montage/ui/button.reel").Button; | ||
10 | |||
11 | exports.Main = Montage.create(Component, { | 9 | exports.Main = Montage.create(Component, { |
12 | 10 | ||
13 | hasTemplate: { | 11 | hasTemplate: { |
@@ -31,6 +29,7 @@ exports.Main = Montage.create(Component, { | |||
31 | } | 29 | } |
32 | }, | 30 | }, |
33 | 31 | ||
32 | // Adding components to the user document by using a async require. | ||
34 | addComponentToUserDocument:{ | 33 | addComponentToUserDocument:{ |
35 | value:function(element, data, callback){ | 34 | value:function(element, data, callback){ |
36 | 35 | ||
@@ -42,7 +41,7 @@ exports.Main = Montage.create(Component, { | |||
42 | var componentInstance = componentRequire.create(); | 41 | var componentInstance = componentRequire.create(); |
43 | 42 | ||
44 | componentInstance.element = element; | 43 | componentInstance.element = element; |
45 | componentInstance.deserializedFromTemplate(); | 44 | //componentInstance.deserializedFromTemplate(); |
46 | componentInstance.needsDraw = true; | 45 | componentInstance.needsDraw = true; |
47 | 46 | ||
48 | callback(componentInstance, element); | 47 | callback(componentInstance, element); |
diff --git a/js/lib/NJUtils.js b/js/lib/NJUtils.js index 8daafa42..887743c5 100755 --- a/js/lib/NJUtils.js +++ b/js/lib/NJUtils.js | |||
@@ -5,6 +5,7 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
5 | </copyright> */ | 5 | </copyright> */ |
6 | 6 | ||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | Uuid = require("montage/core/uuid").Uuid, | ||
8 | ElementModel = require("js/models/element-model").ElementModel, | 9 | ElementModel = require("js/models/element-model").ElementModel, |
9 | Properties3D = require("js/models/properties-3d").Properties3D, | 10 | Properties3D = require("js/models/properties-3d").Properties3D, |
10 | ShapeModel = require("js/models/shape-model").ShapeModel, | 11 | ShapeModel = require("js/models/shape-model").ShapeModel, |
@@ -56,13 +57,18 @@ exports.NJUtils = Object.create(Object.prototype, { | |||
56 | 57 | ||
57 | ///// Quick "createElement" function "attr" can be classname or object | 58 | ///// Quick "createElement" function "attr" can be classname or object |
58 | ///// with attribute key/values | 59 | ///// with attribute key/values |
60 | ///// Suppor for data attributes | ||
59 | make : { | 61 | make : { |
60 | value: function(tag, attr) { | 62 | value: function(tag, attr) { |
61 | var el = document.createElement(tag); | 63 | var el = document.createElement(tag); |
62 | if (typeof attr === 'object') { | 64 | if (typeof attr === 'object') { |
63 | for (var a in attr) { | 65 | for (var a in attr) { |
64 | if (attr.hasOwnProperty(a)) { | 66 | if (attr.hasOwnProperty(a)) { |
65 | el[a] = attr[a]; | 67 | if(a.indexOf("data-") > -1) { |
68 | el.setAttribute(a, attr[a]); | ||
69 | } else { | ||
70 | el[a] = attr[a]; | ||
71 | } | ||
66 | } | 72 | } |
67 | } | 73 | } |
68 | } else if (typeof attr === 'string') { | 74 | } else if (typeof attr === 'string') { |
@@ -247,6 +253,20 @@ exports.NJUtils = Object.create(Object.prototype, { | |||
247 | } | 253 | } |
248 | return status; | 254 | return status; |
249 | } | 255 | } |
256 | }, | ||
257 | |||
258 | /* ================= misc methods ================= */ | ||
259 | |||
260 | // Generates an alpha-numeric random number | ||
261 | // len: number of chars | ||
262 | // default length is '8' | ||
263 | generateRandom: { | ||
264 | value: function(len) { | ||
265 | var length; | ||
266 | len ? length = len : length = 8; | ||
267 | |||
268 | return Uuid.generate().substring(0,length); | ||
269 | } | ||
250 | } | 270 | } |
251 | 271 | ||
252 | }); | 272 | }); |
diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js index 7e5a76ee..b4eec771 100755 --- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js +++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js | |||
@@ -26,14 +26,59 @@ var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component | |||
26 | "text": "Montage Components", | 26 | "text": "Montage Components", |
27 | "children": [ | 27 | "children": [ |
28 | { | 28 | { |
29 | "text": "Anchor", | ||
30 | "dataFile" : "node_modules/components-data/anchor.json", | ||
31 | "component": "anchor" | ||
32 | }, | ||
33 | { | ||
29 | "text": "Button", | 34 | "text": "Button", |
30 | "dataFile" : "node_modules/components-data/button.json", | 35 | "dataFile" : "node_modules/components-data/button.json", |
31 | "component": "button" | 36 | "component": "button" |
32 | }, | 37 | }, |
33 | { |