aboutsummaryrefslogtreecommitdiff
path: root/js/panels/resize-composer.js
diff options
context:
space:
mode:
authorNivesh Rajbhandari2012-03-01 21:49:44 -0800
committerNivesh Rajbhandari2012-03-01 21:49:44 -0800
commit50058746779f714ed9b0287f49e56c9f0d35593e (patch)
tree8bfcb041824bfb492765ff814bf8576847a11436 /js/panels/resize-composer.js
parent500426dea0ca95a6b45be8ea8d132cfdb4d2c940 (diff)
parentff0a956f33df034e9a009cfcb8999e469456a4b5 (diff)
downloadninja-50058746779f714ed9b0287f49e56c9f0d35593e.tar.gz
Merge branch 'refs/heads/ninja-internal' into WebGLFixes
Diffstat (limited to 'js/panels/resize-composer.js')
-rw-r--r--js/panels/resize-composer.js121
1 files changed, 121 insertions, 0 deletions
diff --git a/js/panels/resize-composer.js b/js/panels/resize-composer.js
new file mode 100644
index 00000000..6e5e89f8
--- /dev/null
+++ b/js/panels/resize-composer.js
@@ -0,0 +1,121 @@
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
7var Montage = require("montage/core/core").Montage;
8var Composer = require("montage/ui/composer/composer").Composer;
9
10exports.ResizeComposer = Montage.create(Composer, {
11
12 enabled : {
13 enumerable: false,
14 value: true
15 },
16
17 inversed : {
18 enumarable: false,
19 value: false
20 },
21
22 _startX: {
23 enumerable: false,
24 value: 0
25 },
26
27 _startY: {
28 enumerable: false,
29 value: 0
30 },
31
32 _deltaX: {
33 enumerable: false,
34 value: 0
35 },
36
37 _deltaY: {
38 enumerable: false,
39 value: 0
40 },
41
42 _startTimestamp: {
43 enumerable: false,
44 value: 0
45 },
46
47 _reset: {
48 enumerable: false,
49 value: function() {
50 this._startX = 0;
51 this._startY = 0;
52 this._deltaX = 0;
53 this._deltaY = 0;
54 }
55 },
56
57 _executeEvent: {
58 value: function(eventName) {
59 resizeEvent = document.createEvent("CustomEvent");
60 resizeEvent.initCustomEvent(eventName, true, false, null);
61 resizeEvent.startX = this._startX;
62 resizeEvent.startY = this._startY;
63 resizeEvent.dX = this._deltaX;
64 resizeEvent.dY = this._deltaY;
65 this.dispatchEvent(resizeEvent);
66 }
67 },
68
69 load: {
70 value: function() {
71 this.element.addEventListener("mousedown", this, true);
72 }
73 },
74
75 unload: {
76 value: function() {
77 this.element.removeEventListener("mousedown", this, true);
78 }
79 },
80
81 captureMousedown: {
82 value: function(e) {
83 e.preventDefault();
84 if (this.enabled) {
85 this._reset();
86 this._startX = e.clientX;
87 this._startY = e.clientY;
88 this._startTimestamp = e.timeStamp;
89 window.addEventListener("mousemove", this, true);
90 window.addEventListener("mouseup", this, true);
91 this._executeEvent("resizeStart");
92 }
93 }
94 },
95
96 captureMouseup: {
97 value: function(e) {
98 e.preventDefault();
99 window.removeEventListener("mousemove", this, true);
100 window.removeEventListener("mouseup", this, true);
101 this._executeEvent("resizeEnd");
102 }
103 },
104
105 captureMousemove: {
106 value: function(e) {
107 this._deltaX = e.clientX - this._startX;
108 this._deltaY = e.clientY - this._startY;
109 this._executeEvent("resizeMove");
110 }
111 },
112
113 deserializedFromTemplate: {
114 value: function() {
115 if (this.component) {
116 this.component.addComposer(this);
117 }
118 }
119 }
120
121}); \ No newline at end of file