diff options
Diffstat (limited to 'js/components/tools-properties/rect-properties.reel/rect-properties.js')
-rw-r--r-- | js/components/tools-properties/rect-properties.reel/rect-properties.js | 128 |
1 files changed, 128 insertions, 0 deletions
diff --git a/js/components/tools-properties/rect-properties.reel/rect-properties.js b/js/components/tools-properties/rect-properties.reel/rect-properties.js new file mode 100644 index 00000000..8d0cd21f --- /dev/null +++ b/js/components/tools-properties/rect-properties.reel/rect-properties.js | |||
@@ -0,0 +1,128 @@ | |||
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 | ToolProperties = require("js/components/tools-properties/tool-properties").ToolProperties; | ||
9 | |||
10 | exports.RectProperties = Montage.create(ToolProperties, { | ||
11 | base: { value: null }, | ||
12 | lockButton: { value: null, enumerable: false}, | ||
13 | TLRadiusControl: { value: null, enumerable: false }, | ||
14 | TRRadiusControl: { value: null, enumerable: false }, | ||
15 | BLRadiusControl: { value: null, enumerable: false }, | ||
16 | BRRadiusControl: { value: null, enumerable: false }, | ||
17 | |||
18 | _unlocked: { value: false, enumerable: false}, | ||
19 | |||
20 | _subPrepare: { | ||
21 | value: function() { | ||
22 | this.lockButton.addEventListener("click", this, false); | ||
23 | |||
24 | this._setBindings([this.TRRadiusControl, this.BLRadiusControl, this.BRRadiusControl]); | ||
25 | this._setCap([this.TLRadiusControl,this.TRRadiusControl, this.BLRadiusControl, this.BRRadiusControl]); | ||
26 | |||
27 | } | ||
28 | }, | ||
29 | |||
30 | handleClick: { | ||
31 | value: function(event) { | ||
32 | this._unlocked = !this._unlocked; | ||
33 | |||
34 | this.TRRadiusControl.enabled = this.BLRadiusControl.enabled = this.BRRadiusControl.enabled = this._unlocked; | ||
35 | |||
36 | if(this._unlocked) { | ||
37 | this.lockButton.classList.remove("LockToolUp"); | ||
38 | this.lockButton.classList.add("UnLockToolUp"); | ||
39 | this._removeBindings([this.TRRadiusControl, this.BLRadiusControl, this.BRRadiusControl]); | ||
40 | } else { | ||
41 | this.lockButton.classList.remove("UnLockToolUp"); | ||
42 | this.lockButton.classList.add("LockToolUp"); | ||
43 | this._setBindings([this.TRRadiusControl, this.BLRadiusControl, this.BRRadiusControl]); | ||
44 | } | ||
45 | } | ||
46 | }, | ||
47 | |||
48 | // Public API | ||
49 | use3D: { | ||
50 | get: function() { return this.base._use3D; } | ||
51 | }, | ||
52 | |||
53 | strokeSize: { | ||
54 | get: function() { return this.base._strokeSize; } | ||
55 | }, | ||
56 | |||
57 | strokeStyle : { | ||
58 | get: function() { return this.base._strokeStyle.options[this.base._strokeStyle.value].text; } | ||
59 | }, | ||
60 | |||
61 | strokeStyleIndex : { | ||
62 | get: function() { return this.base._strokeStyle.options[this.base._strokeStyle.value].value; } | ||
63 | }, | ||
64 | |||
65 | strokeMaterial: { | ||
66 | get: function() { return this.base._strokeMaterial.options[this.base._strokeMaterial.value].value; } | ||
67 | }, | ||
68 | |||
69 | fillMaterial: { | ||
70 | get: function() { return this.base._fillMaterial.options[this.base._fillMaterial.value].value; } | ||
71 | }, | ||
72 | |||
73 | _setBindings: { | ||
74 | value: function(els) { | ||
75 | var that = this; | ||
76 | els.forEach(function(el) { | ||
77 | Object.defineBinding(el, "value", { | ||
78 | boundObject: that.TLRadiusControl, | ||
79 | boundObjectPropertyPath: "value", | ||
80 | boundValueMutator: function(value) { | ||
81 | if (typeof value === "string") { | ||
82 | return parseFloat(value); | ||
83 | } | ||
84 | |||
85 | return value; | ||
86 | } | ||
87 | }); | ||
88 | |||
89 | Object.defineBinding(el, "units", { | ||
90 | boundObject: that.TLRadiusControl, | ||
91 | boundObjectPropertyPath: "units" | ||
92 | }); | ||
93 | }); | ||
94 | } | ||
95 | }, | ||
96 | |||
97 | _removeBindings: { | ||
98 | value: function(els) { | ||
99 | els.forEach(function(el) { | ||
100 | Object.deleteBindings(el); | ||
101 | }); | ||
102 | } | ||
103 | }, | ||
104 | |||
105 | _setCap: { | ||
106 | value: function(els) { | ||
107 | var that = this; | ||
108 | els.forEach(function(el) { | ||
109 | el.addEventListener("change", that, false); | ||
110 | }); | ||
111 | } | ||
112 | }, | ||
113 | |||
114 | handleChange: { | ||
115 | value: function(event) { | ||
116 | var hotTxt = event.currentTarget | ||
117 | if(hotTxt.units === "%") { | ||
118 | if(hotTxt.value > 50) { | ||
119 | hotTxt.maxValue = 50; | ||
120 | } | ||
121 | return hotTxt.value; | ||
122 | } | ||
123 | |||
124 | } | ||
125 | } | ||
126 | |||
127 | |||
128 | }); \ No newline at end of file | ||