diff options
author | Ananya Sen | 2012-02-29 14:53:13 -0800 |
---|---|---|
committer | Ananya Sen | 2012-02-29 14:53:13 -0800 |
commit | 5d4f1aad01737695238582c704e6d4f2c3a2f317 (patch) | |
tree | bf202a3432e3cfa928a57ee80d54af91b9e2509a /js | |
parent | ccedeef38d6eb2e55d1782b82401828f3c99dd9c (diff) | |
parent | 551e1f2be11e9e6ab7af17816396b88aafd57dff (diff) | |
download | ninja-5d4f1aad01737695238582c704e6d4f2c3a2f317.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into FileIO
Diffstat (limited to 'js')
30 files changed, 741 insertions, 368 deletions
diff --git a/js/controllers/local-storage-controller.js b/js/controllers/local-storage-controller.js index 6963b245..1388f3e5 100755 --- a/js/controllers/local-storage-controller.js +++ b/js/controllers/local-storage-controller.js | |||
@@ -7,44 +7,51 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
7 | var Montage = require("montage/core/core").Montage, | 7 | var Montage = require("montage/core/core").Montage, |
8 | Component = require("montage/ui/component").Component; | 8 | Component = require("montage/ui/component").Component; |
9 | 9 | ||
10 | exports.LocalStorage = Montage.create( Montage, { | 10 | exports.LocalStorage = Montage.create( Component, { |
11 | 11 | ||
12 | getItem: { | 12 | canStore: { |
13 | value: function(item) { | 13 | value: null |
14 | var item; | 14 | }, |
15 | |||
16 | if (window.localStorage) { | ||
17 | item = window.localStorage.getItem(item); | ||
18 | if(item !== null) return JSON.parse(item) | ||
19 | return null; | ||
20 | } else { | ||
21 | alert("Local Storage is not supported on your browser"); | ||
22 | return null; | ||
23 | } | ||
24 | 15 | ||
25 | /* | 16 | deserializedFromTemplate: { |
26 | if (window.localStorage) { | 17 | value: function() { |
27 | this.getItem = function(item) { | 18 | this.canStore = window.localStorage; |
28 | return window.localStorage.getItem(item); | 19 | this.application.localStorage = this; |
29 | }(item); | 20 | |
30 | } else { | 21 | // Redefine setItem and getItem if local storage is not available. |
31 | alert("Local Storage is not supported on your browser"); | 22 | if(!this.canStore) { |
23 | this.getItem = function() { | ||
24 | console.log("Local Storage is not supported on your browser"); | ||
25 | return ""; | ||
26 | }; | ||
27 | |||
28 | this.setItem = function() { | ||
29 | console.log("Local Storage is not supported on your browser"); | ||
30 | return false; | ||
31 | } | ||
32 | } | ||
32 | 33 | ||
34 | // Temporary clear the local storage if we find the version key | ||
35 | if(window.localStorage.version) { | ||
36 | window.localStorage.clear(); | ||
33 | } | 37 | } |
34 | */ | 38 | } |
39 | }, | ||
40 | |||
41 | getItem: { | ||
42 | value: function(key) { | ||
43 | var value = window.localStorage.getItem("ninja-" + key); | ||
44 | if(value !== null) value = JSON.parse(value); | ||
45 | |||
46 | return value; | ||
35 | } | 47 | } |
36 | }, | 48 | }, |
37 | 49 | ||
38 | setItem: { | 50 | setItem: { |
39 | value: function(item, value) { | 51 | value: function(key, value) { |
40 | if (window.localStorage) { | 52 | window.localStorage.setItem("ninja-" + key, JSON.stringify(value)); |
41 | window.localStorage.setItem(item, JSON.stringify(value)); | 53 | |
42 | return true; | 54 | return value; |
43 | } else { | ||
44 | alert("Local Storage is not supported on your browser"); | ||
45 | return false; | ||
46 | } | ||
47 | } | 55 | } |
48 | } | 56 | } |
49 | |||
50 | }); \ No newline at end of file | 57 | }); \ No newline at end of file |
diff --git a/js/data/settings.js b/js/data/settings.js deleted file mode 100755 index ffea2075..00000000 --- a/js/data/settings.js +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | |||
7 | var Montage = require("montage/core/core").Montage, | ||
8 | Component = require("montage/ui/component").Component, | ||
9 | LocalStorage = require("js/controllers/local-storage-controller").LocalStorage; | ||
10 | |||
11 | exports.Settings = Montage.create( Component, { | ||
12 | |||
13 | version: { | ||
14 | value: "11.1213" | ||
15 | }, | ||
16 | |||
17 | _settings: { | ||
18 | value: null | ||
19 | }, | ||
20 | |||
21 | settings: { | ||
22 | get: function() { return this._settings; }, | ||
23 | set: function(value) { this._settings = value; } | ||
24 | }, | ||
25 | |||
26 | getSetting: { | ||
27 | value: function(objName, fieldName, namespace) { | ||
28 | try { | ||
29 | objName = objName.replace(/-/gi, "_").replace(/\//gi, "zzSlash"); | ||
30 | return this.settings[objName][fieldName]; | ||
31 | } catch(e) { | ||
32 | return null; | ||
33 | } | ||
34 | } | ||
35 | }, | ||
36 | |||
37 | setSetting: { | ||
38 | value: function(objName, fieldName, value, namespace) { | ||
39 | try { | ||
40 | objName = objName.replace(/-/gi, "_").replace(/\//gi, "zzSlash"); | ||
41 | |||
42 | if(this.settings === null) { | ||
43 | this.settings = {}; | ||
44 | } | ||
45 | |||
46 | if (this.settings[objName] == null) { | ||
47 | this.settings[objName] = {}; | ||
48 | } | ||
49 | |||
50 | this.settings[objName][fieldName] = value; | ||
51 | |||
52 | LocalStorage.setItem("settings", this.settings); | ||
53 | } catch(e) { | ||
54 | return null; | ||
55 | } | ||
56 | } | ||
57 | }, | ||
58 | |||
59 | deserializedFromSerialization: { | ||
60 | value: function() { | ||
61 | |||
62 | if (LocalStorage.getItem("version") != this.version) { | ||
63 | this.settings = {} | ||
64 | LocalStorage.setItem("version",this.version); | ||
65 | } else { | ||
66 | this.settings = LocalStorage.getItem("settings"); | ||
67 | } | ||
68 | |||
69 | } | ||
70 | } | ||
71 | }); \ No newline at end of file | ||
diff --git a/js/helper-classes/3D/snap-manager.js b/js/helper-classes/3D/snap-manager.js index 94202dc5..372be345 100755 --- a/js/helper-classes/3D/snap-manager.js +++ b/js/helper-classes/3D/snap-manager.js | |||
@@ -597,7 +597,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
597 | } | 597 | } |
598 | 598 | ||
599 | // TODO - Don't traverse components' children | 599 | // TODO - Don't traverse components' children |
600 | if(elt.elementModel && elt.elementModel.isComponent) | 600 | // if(elt.elementModel && elt.elementModel.isComponent) |
601 | if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG")))) | ||
601 | { | 602 | { |
602 | return; | 603 | return; |
603 | } | 604 | } |
@@ -1007,7 +1008,8 @@ var SnapManager = exports.SnapManager = Montage.create(Component, { | |||
1007 | } | 1008 | } |
1008 | 1009 | ||
1009 | // TODO - Don't traverse components' children | 1010 | // TODO - Don't traverse components' children |
1010 | if(elt.elementModel && elt.elementModel.isComponent) | 1011 | // if(elt.elementModel && elt.elementModel.isComponent) |
1012 | if(elt.nodeName.toLowerCase() === "svg" || (elt.elementModel && (elt.elementModel.isComponent || (elt.elementModel.selection === "SVG")))) | ||
1011 | { | 1013 | { |
1012 | return; | 1014 | return; |
1013 | } | 1015 | } |
diff --git a/js/helper-classes/3D/view-utils.js b/js/helper-classes/3D/view-utils.js index bedda8bf..c1f59397 100755 --- a/js/helper-classes/3D/view-utils.js +++ b/js/helper-classes/3D/view-utils.js | |||
@@ -580,7 +580,8 @@ exports.ViewUtils = Montage.create(Component, { | |||
580 | i |