diff options
Diffstat (limited to 'js/controllers')
-rwxr-xr-x | js/controllers/color-controller.js | 4 | ||||
-rwxr-xr-x | js/controllers/document-controller.js | 26 | ||||
-rwxr-xr-x | js/controllers/elements/shapes-controller.js | 4 | ||||
-rw-r--r-- | js/controllers/presets-controller.js | 108 |
4 files changed, 137 insertions, 5 deletions
diff --git a/js/controllers/color-controller.js b/js/controllers/color-controller.js index 8e000b19..c6d664cf 100755 --- a/js/controllers/color-controller.js +++ b/js/controllers/color-controller.js | |||
@@ -227,14 +227,14 @@ exports.ColorController = Montage.create(Component, { | |||
227 | // | 227 | // |
228 | this.fill = color; | 228 | this.fill = color; |
229 | // | 229 | // |
230 | if(e._event.wasSetByCode && mode !== 'nocolor') return; | 230 | if(e._event.wasSetByCode) return; |
231 | // | 231 | // |
232 | this.setColor(mode, color, true); | 232 | this.setColor(mode, color, true); |
233 | } else if (input === 'stroke') { | 233 | } else if (input === 'stroke') { |
234 | // | 234 | // |
235 | this.stroke = color; | 235 | this.stroke = color; |
236 | // | 236 | // |
237 | if(e._event.wasSetByCode && mode !== 'nocolor') return; | 237 | if(e._event.wasSetByCode) return; |
238 | 238 | ||
239 | this.setColor(mode, color, false); | 239 | this.setColor(mode, color, false); |
240 | } | 240 | } |
diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index b6d9dc67..97ea834b 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js | |||
@@ -32,22 +32,30 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
32 | _iframeHolder: { value: null, enumerable: false }, | 32 | _iframeHolder: { value: null, enumerable: false }, |
33 | _textHolder: { value: null, enumerable: false }, | 33 | _textHolder: { value: null, enumerable: false }, |
34 | _codeMirrorCounter: {value: 1, enumerable: false}, | 34 | _codeMirrorCounter: {value: 1, enumerable: false}, |
35 | |||
36 | canSave:{value: false},//for Save menu state update | ||
37 | canSaveAll:{value: false},//for Save All menu state update | ||
35 | 38 | ||
36 | activeDocument: { | 39 | activeDocument: { |
37 | get: function() { | 40 | get: function() { |
38 | return this._activeDocument; | 41 | return this._activeDocument; |
39 | }, | 42 | }, |
40 | set: function(doc) { | 43 | set: function(doc) { |
41 | if(!!this._activeDocument) this._activeDocument.isActive = false; | 44 | if(!!this._activeDocument){ this._activeDocument.isActive = false;} |
42 | |||
43 | this._activeDocument = doc; | 45 | this._activeDocument = doc; |
44 | if(!!this._activeDocument){ | 46 | if(!!this._activeDocument){ |
45 | |||
46 | if(this._documents.indexOf(doc) === -1) this._documents.push(doc); | 47 | if(this._documents.indexOf(doc) === -1) this._documents.push(doc); |
47 | this._activeDocument.isActive = true; | 48 | this._activeDocument.isActive = true; |
49 | |||
48 | if(!!this._activeDocument.editor){ | 50 | if(!!this._activeDocument.editor){ |
49 | this._activeDocument.editor.focus(); | 51 | this._activeDocument.editor.focus(); |
50 | } | 52 | } |
53 | |||
54 | this.canSave = doc.needsSave; | ||
55 | this.canSaveAll = doc.needsSave; | ||
56 | }else{ | ||
57 | this.canSave = false; | ||
58 | this.canSaveAll = false; | ||
51 | } | 59 | } |
52 | } | 60 | } |
53 | }, | 61 | }, |
@@ -61,6 +69,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
61 | this.eventManager.addEventListener("executeSaveAs", this, false); | 69 | this.eventManager.addEventListener("executeSaveAs", this, false); |
62 | this.eventManager.addEventListener("executeSaveAll", this, false); | 70 | this.eventManager.addEventListener("executeSaveAll", this, false); |
63 | this.eventManager.addEventListener("executeFileClose", this, false); | 71 | this.eventManager.addEventListener("executeFileClose", this, false); |
72 | this.eventManager.addEventListener("executeFileCloseAll", this, false); | ||
64 | 73 | ||
65 | this.eventManager.addEventListener("styleSheetDirty", this, false); | 74 | this.eventManager.addEventListener("styleSheetDirty", this, false); |
66 | 75 | ||
@@ -180,6 +189,17 @@ var DocumentController = exports.DocumentController = Montage.create(Component, | |||
180 | } | 189 | } |
181 | }, | 190 | }, |
182 | //////////////////////////////////////////////////////////////////// | 191 | //////////////////////////////////////////////////////////////////// |
192 | handleExecuteFileCloseAll:{ | ||
193 | value: function(event) { | ||
194 | var i=0; | ||
195 | if(this.activeDocument && this.application.ninja.coreIoApi.cloudAvailable()){ | ||
196 | while(this._documents.length > 0){ | ||
197 | this.closeDocument(this._documents[this._documents.length -1].uuid); | ||
198 | } | ||
199 | } | ||
200 | } | ||
201 | }, | ||
202 | //////////////////////////////////////////////////////////////////// | ||
183 | // | 203 | // |
184 | fileSaveResult: { | 204 | fileSaveResult: { |
185 | value: function (result) { | 205 | value: function (result) { |
diff --git a/js/controllers/elements/shapes-controller.js b/js/controllers/elements/shapes-controller.js index 5b9e4672..f0e9458b 100755 --- a/js/controllers/elements/shapes-controller.js +++ b/js/controllers/elements/shapes-controller.js | |||
@@ -274,6 +274,10 @@ exports.ShapesController = Montage.create(CanvasController, { | |||
274 | color = this.getShapeProperty(el, "stroke"); | 274 | color = this.getShapeProperty(el, "stroke"); |
275 | } | 275 | } |
276 | 276 | ||
277 | if(!css) { | ||
278 | return null; | ||
279 | } | ||
280 | |||
277 | css = this.application.ninja.colorController.colorModel.webGlToCss(color); | 281 | css = this.application.ninja.colorController.colorModel.webGlToCss(color); |
278 | return this.application.ninja.colorController.getColorObjFromCss(css); | 282 | return this.application.ninja.colorController.getColorObjFromCss(css); |
279 | } | 283 | } |
diff --git a/js/controllers/presets-controller.js b/js/controllers/presets-controller.js new file mode 100644 index 00000000..7152ba93 --- /dev/null +++ b/js/controllers/presets-controller.js | |||
@@ -0,0 +1,108 @@ | |||
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 | |||
8 | var Montage = require("montage/core/core").Montage, | ||
9 | Component = require("montage/ui/component").Component; | ||
10 | |||
11 | exports.PresetsController = Montage.create(Component, { | ||
12 | |||
13 | hasTemplate : { | ||
14 | value: false | ||
15 | }, | ||
16 | |||
17 | transitionClass : { | ||
18 | value : "nj-preset-transition" | ||
19 | }, | ||
20 | |||
21 | addTransition: { | ||
22 | value: function(element) { | ||
23 | element.classList.add(this.transitionClass); | ||
24 | element.addEventListener("webkitTransitionEnd", this, true); | ||
25 | } | ||
26 | }, | ||
27 | |||
28 | captureWebkitTransitionEnd : { | ||
29 | value : function(e) { | ||
30 | var el = e.target; | ||
31 | el.classList.remove(this.transitionClass); | ||
32 | el.removeEventListener("webkitTransitionEnd", this, true); | ||
33 | } | ||
34 | }, | ||
35 | |||
36 | applyPreset : { | ||
37 | value: function(presetData, useTransition) { | ||
38 | var selection = this.application.ninja.selectedElements; | ||
39 | |||
40 | if(!selection || !selection.length || selection.length === 0) { return false; } | ||
41 | |||
42 | var stylesController = this.application.ninja.stylesController, | ||
43 | selectorBase = presetData.selectorBase, | ||
44 | rules = []; | ||
45 | |||
46 | selectorBase = stylesController.generateClassName(selectorBase); | ||
47 | |||
48 | presetData.rules.forEach(function(rule, i) { | ||
49 | ///// Treat keyframed rules differently | ||
50 | if(rule.isKeyFrameRule) { | ||
51 | this.application.ninja.stylesController.addRule( | ||
52 | '@-webkit-keyframes ' + presetData.selectorBase, | ||
53 | this.stringifyKeys(rule.keys) | ||
54 | ); | ||
55 | } else { | ||
56 | var suffix = rule.selectorSuffix || ''; | ||
57 | rules.push(stylesController.addRule('.'+selectorBase + suffix, rule.styles)); | ||
58 | } | ||
59 | }, this); | ||
60 | |||
61 | selection.forEach(function(element) { | ||
62 | var el = element._element; | ||
63 | |||
64 | if(useTransition) { | ||
65 | this.addTransition(el); | ||
66 | } | ||
67 | |||
68 | el.classList.add(selectorBase); | ||
69 | |||
70 | //// Keep track of elements with presets and don't add duplicates | ||
71 | this.setCachedPreset(el, presetData.id, rules); | ||
72 | |||
73 | }, this); | ||
74 | |||
75 | } | ||
76 | }, | ||
77 | |||
78 | setCachedPreset : { | ||
79 | value: function(el, presetId, rules) { | ||
80 | |||
81 | } | ||
82 | }, | ||
83 | |||
84 | getPresets : { | ||
85 | value: function(element) { | ||
86 | |||
87 | } | ||
88 | |||
89 | }, | ||
90 | |||
91 | stringifyKeys : { | ||
92 | value: function(keysArray) { | ||
93 | var keysString = ''; | ||
94 | |||
95 | keysArray.forEach(function(key) { | ||
96 | var styles = '', style; | ||
97 | |||
98 | for(style in key.styles) { | ||
99 | styles += style + ':' + key.styles[style] + '; '; | ||
100 | } | ||
101 | |||
102 | keysString += key.keyText + ' {' + styles + ' }'; | ||
103 | }); | ||
104 | |||
105 | return keysString; | ||
106 | } | ||
107 | } | ||
108 | }); \ No newline at end of file | ||