aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers')
-rw-r--r--js/controllers/color-controller.js442
-rw-r--r--js/controllers/elements/block-controller.js35
-rw-r--r--js/controllers/elements/canvas-controller.js37
-rw-r--r--js/controllers/elements/component-controller.js12
-rw-r--r--js/controllers/elements/controller-factory.js49
-rw-r--r--js/controllers/elements/element-controller.js263
-rw-r--r--js/controllers/elements/image-controller.js41
-rw-r--r--js/controllers/elements/shapes-controller.js238
-rw-r--r--js/controllers/elements/stage-controller.js125
-rw-r--r--js/controllers/elements/video-controller.js56
-rw-r--r--js/controllers/local-storage-controller.js50
-rw-r--r--js/controllers/selection-controller.js299
-rw-r--r--js/controllers/styles-controller.js1302
-rw-r--r--js/controllers/undo-controller.js206
14 files changed, 3155 insertions, 0 deletions
diff --git a/js/controllers/color-controller.js b/js/controllers/color-controller.js
new file mode 100644
index 00000000..87180873
--- /dev/null
+++ b/js/controllers/color-controller.js
@@ -0,0 +1,442 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No 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//
9var Montage = require("montage/core/core").Montage,
10 Component = require("montage/ui/component").Component,
11 ColorModel = require("js/models/color-model").ColorModel,
12 ColorToolbar = require("js/panels/Color/colortoolbar.reel").ColorToolbar,
13 ColorPanelBase = require("js/panels/Color/colorpanelbase.reel").ColorPanelBase,
14 ElementsMediator = require("js/mediators/element-mediator").ElementMediator,
15 ColorPopupManager = require("js/panels/Color/colorpopup-manager").ColorPopupManager,
16 ColorButtonManager = require("js/panels/Color/colorbutton-manager").ColorButtonManager;
17////////////////////////////////////////////////////////////////////////
18//Exporting as ColorController
19exports.ColorController = Montage.create(Component, {
20 ////////////////////////////////////////////////////////////////////
21 //
22 hasTemplate: {
23 enumerable: true,
24 value: false
25 },
26 ////////////////////////////////////////////////////////////////////
27 //
28 deserializedFromTemplate: {
29 enumerable: true,
30 value: function () {
31 //Setting up colorManager in other classes
32 this.colorPanelBase.colorManager = this.colorModel;
33 this.colorPopupManager.colorManager = this.colorModel;
34 this.colorButtonManager.colorManager = this.colorModel;
35 //Listening for color changes
36 this.colorModel.addEventListener('change', this, false);
37 }
38 },
39 ////////////////////////////////////////////////////////////////////
40 //
41 colorModel: {
42 enumerable: true,
43 value: ColorModel
44 },
45 ////////////////////////////////////////////////////////////////////
46 //
47 colorPanelBase: {
48 enumerable: true,
49 value: ColorPanelBase
50 },
51 ////////////////////////////////////////////////////////////////////
52 //
53 colorPopupManager: {
54 enumerable: true,
55 value: ColorPopupManager
56 },
57 ////////////////////////////////////////////////////////////////////
58 //
59 colorButtonManager: {
60 enumerable: true,
61 value: ColorPopupManager
62 },
63 ////////////////////////////////////////////////////////////////////
64 //
65 colorView: {
66 enumerable: true,
67 value: null
68 },
69 ////////////////////////////////////////////////////////////////////
70 //
71 colorToolbar: {
72 enumerable: true,
73 value: null
74 },
75 ////////////////////////////////////////////////////////////////////
76 //
77 _popupTab: {
78 enumerable: false,
79 value: 'wheel'
80 },
81 ////////////////////////////////////////////////////////////////////
82 //
83 popupTab: {
84 enumerable: true,
85 get: function() {
86 return this._popupTab;
87 },
88 set: function(value) {
89 this._popupTab = value.toLowerCase();
90 }
91 },
92 ////////////////////////////////////////////////////////////////////
93 //
94 addButton: {
95 enumerable: true,
96 value: function (type, button) {
97 if (this.colorView) {
98 this.colorView.addButton(type, button);
99 return true;
100 } else if (this.ColorPanelBase) {
101 this.ColorPanelBase.addButton(type, button);
102 return true;
103 } else {
104 return false;
105 }
106 }
107 },
108 ////////////////////////////////////////////////////////////////////
109 //
110 removeButton: {
111 enumerable: true,
112 value: function (type, button) {
113 if (this.colorView) {
114 this.colorView.removeButton(type, button);
115 return true;
116 } else if (this.ColorPanelBase) {
117 this.ColorPanelBase.removeButton(type, button);
118 return true;
119 } else {
120 return false;
121 }
122 }
123 },
124 ////////////////////////////////////////////////////////////////////
125 //
126 _fill: {
127 enumerable: false,
128 value: null
129 },
130 ////////////////////////////////////////////////////////////////////
131 //
132 fill: {
133 enumerable: true,
134 get: function() {
135 return this._fill;
136 },
137 set: function(value) {
138 this._fill = value;
139 }
140 },
141 ////////////////////////////////////////////////////////////////////
142 //
143 _stroke: {
144 enumerable: false,
145 value: null
146 },
147 ////////////////////////////////////////////////////////////////////
148 //
149 stroke: {
150 enumerable: true,
151 get: function() {
152 return this._stroke;
153 },
154 set: function(value) {
155 this._stroke = value;
156 }
157 },
158 ////////////////////////////////////////////////////////////////////
159 //
160 getBackground: {
161 enumerable: true,
162 value: function (element) {
163 //TODO: Return object with all background properties
164 console.log(ElementsMediator.getProperty(element, 'background-color'));
165 console.log(ElementsMediator.getProperty(element, 'background-image'));
166 }
167 },
168 ////////////////////////////////////////////////////////////////////
169 //
170 getBorder: {
171 enumerable: true,
172 value: function (element) {
173
174 }
175 },
176 ////////////////////////////////////////////////////////////////////
177 //
178 setBackground: {
179 enumerable: true,
180 value: function (type, background, selection) {
181 //TODO: Remove hack
182 var elements, i, hack = [], hackNone = [];
183 //The selection is optional, if none, it asks for the currently selected elements
184 if (selection) {
185 elements = selection;
186 } else {
187 elements = this.application.ninja.selectedElements;
188 }
189 //
190 for (i=0; elements[i]; i++) {
191 hack[i] = background;
192 hackNone[i] = 'none';
193 }
194 //
195 if (elements && elements.length > 0) {
196 switch (type) {
197 case 'image':
198 ElementsMediator.setProperty(elements, "background-image", hack, {"background-image": background}, "Change", "color-controller");
199 ElementsMediator.setProperty(elements, "background-color", hackNone, {"background-color": 'none'}, "Change", "color-controller");
200 break;
201 case 'color':
202 //TODO: Add logic to handle setting color when image (like gradients) is applied
203 //TODO: Handle applying to multiple items, currently, we need to create a dummy array of the same value
204 ElementsMediator.setProperty(elements, "background-image", hackNone, {"background-image": 'none'}, "Change", "color-controller");
205 ElementsMediator.setProperty(elements, "background-color", hack, {"background-color": background}, "Change", "color-controller");
206 break;
207 case 'background':
208