diff options
Diffstat (limited to 'js/panels/Splitter.js')
-rw-r--r-- | js/panels/Splitter.js | 127 |
1 files changed, 127 insertions, 0 deletions
diff --git a/js/panels/Splitter.js b/js/panels/Splitter.js new file mode 100644 index 00000000..9f5b4de7 --- /dev/null +++ b/js/panels/Splitter.js | |||
@@ -0,0 +1,127 @@ | |||
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 | var Component = require("montage/ui/component").Component; | ||
9 | |||
10 | exports.Splitter = Montage.create(Component, { | ||
11 | |||
12 | hasTemplate: { | ||
13 | value: false | ||
14 | }, | ||
15 | |||
16 | _panel: { | ||
17 | value: null, | ||
18 | enumerable:true | ||
19 | }, | ||
20 | |||
21 | panel: { | ||
22 | get: function() { | ||
23 | return this._panel; | ||
24 | }, | ||
25 | set: function(value) { | ||
26 | this._panel = value; | ||
27 | } | ||
28 | }, | ||
29 | |||
30 | _resizeBar: { | ||
31 | value: null | ||
32 | }, | ||
33 | |||
34 | resizeBar: { | ||
35 | get: function() { | ||
36 | return this._resizeBar; | ||
37 | }, | ||
38 | set: function(val) { | ||
39 | this._resizeBar = val; | ||
40 | } | ||
41 | }, | ||
42 | |||
43 | _collapsed : { | ||
44 | value: false, | ||
45 | enumerable:true | ||
46 | }, | ||
47 | |||
48 | collapsed: { | ||
49 | get: function() { | ||
50 | return this._collapsed; | ||
51 | }, | ||
52 | set: function(value) | ||
53 | { | ||
54 | this._collapsed = value; | ||
55 | this.application.ninja.settings.setSetting(this.element.id, "collapsed", this.collapsed); | ||
56 | } | ||
57 | }, | ||
58 | |||
59 | prepareForDraw: { | ||
60 | value: function() { | ||
61 | //Get Setting from SettingManager | ||
62 | this.application.ninja.settings.getSetting(this.element.id, "collapsed"); | ||
63 | lapsed = false; | ||
64 | if (lapsed != null) this._collapsed = lapsed; | ||
65 | this.element.addEventListener("click", this, false); | ||
66 | } | ||
67 | }, | ||
68 | |||
69 | draw: { | ||
70 | value: function() { | ||
71 | if(this.collapsed) { | ||
72 | |||
73 | if(this.panel.element) this.panel.element.classList.add("collapsed"); | ||
74 | else this.panel.classList.add("collapsed"); | ||
75 | this.element.classList.add("collapsed"); | ||
76 | if(this._resizeBar != null) this.resizeBar.classList.add("collapsed"); | ||
77 | } | ||
78 | else { | ||
79 | if(this.panel.element) this.panel.element.classList.remove("collapsed"); | ||
80 | else this.panel.classList.remove("collapsed"); | ||
81 | this.element.classList.remove("collapsed"); | ||
82 | if(this._resizeBar != null) this.resizeBar.classList.remove("collapsed"); | ||
83 | } | ||
84 | } | ||
85 | }, | ||
86 | |||
87 | handleClick : { | ||
88 | value: function() { | ||
89 | if (!this.disabled) { | ||
90 | this.panel.addEventListener("webkitTransitionEnd", this, false); | ||
91 | this.collapsed = !this.collapsed; | ||
92 | this.needsDraw = true; | ||
93 | } | ||
94 | } | ||
95 | }, | ||
96 | |||
97 | handleWebkitTransitionEnd: { | ||
98 | value: function() { | ||
99 | this.panel.removeEventListener("webkitTransitionEnd", this, false); | ||
100 | this.application.ninja.stage.resizeCanvases = true; | ||
101 | } | ||
102 | }, | ||
103 | |||
104 | _disabled: { | ||
105 | value: null | ||
106 | }, | ||
107 | |||
108 | disabled: { | ||
109 | get: function() { | ||
110 | return this._disabled; | ||
111 | }, | ||
112 | set: function(val) { | ||
113 | if (val && !this.element.classList.contains("disabled")) { | ||
114 | this.element.classList.add("disabled"); | ||
115 | } else { | ||
116 | this.element.classList.remove("disabled"); | ||
117 | } | ||
118 | this._disabled = val; | ||
119 | } | ||
120 | }, | ||
121 | |||
122 | toggle: { | ||
123 | value: function() { | ||
124 | this.handleClick(); | ||
125 | } | ||
126 | } | ||
127 | }); | ||