diff options
author | Pierre Frisch | 2011-12-22 07:25:50 -0800 |
---|---|---|
committer | Valerio Virgillito | 2012-01-27 11:18:17 -0800 |
commit | b89a7ee8b956c96a1dcee995ea840feddc5d4b27 (patch) | |
tree | 0f3136ab0ecdbbbed6a83576581af0a53124d6f1 /js/panels/PanelBase.js | |
parent | 2401f05d1f4b94d45e4568b81fc73e67b969d980 (diff) | |
download | ninja-b89a7ee8b956c96a1dcee995ea840feddc5d4b27.tar.gz |
First commit of Ninja to ninja-internal
Signed-off-by: Valerio Virgillito <rmwh84@motorola.com>
Diffstat (limited to 'js/panels/PanelBase.js')
-rw-r--r-- | js/panels/PanelBase.js | 105 |
1 files changed, 105 insertions, 0 deletions
diff --git a/js/panels/PanelBase.js b/js/panels/PanelBase.js new file mode 100644 index 00000000..b7b6945c --- /dev/null +++ b/js/panels/PanelBase.js | |||
@@ -0,0 +1,105 @@ | |||
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 | // Needed to change scope of 'this' inside | ||
8 | // event handler function to the actual class | ||
9 | // instead of the object that dispatched the event | ||
10 | |||
11 | var Montage = require("montage/core/core").Montage; | ||
12 | var Component = require("montage/ui/component").Component; | ||
13 | |||
14 | exports.PanelBase = Montage.create(Component, { | ||
15 | |||
16 | //Properties | ||
17 | panelName : {value : 'Generic Panel', writable:true, enumerable:true, configurable:true}, // Initial Panel Name will be used to remember status please be unique with this name | ||
18 | collapsedHeight: { value:26 }, // When Collapsed = true contentHeight will return this value | ||
19 | minHeight: { value: 200 }, // Minimum shrink ability for a panel | ||
20 | maxHeight: { value: null }, // Maximum potential growth for a panel | ||
21 | isStatic: { value: false }, // Static Value is used when you would like to create a panel that has no grow or shrink capabilities | ||
22 | isLocked: { value: false }, // Locked Value is used when a panel is temporary disabled to grow and shrink | ||
23 | defaultHeight: { value: 200 }, // The height set when there is no height saved in the users storage | ||
24 | content : { value: null }, // Component goes here. This will be connected with the slot in the center of a panel | ||
25 | _contentHeight: { value: 200 }, // Drawn Height | ||
26 | _forcedCollapse: { value: false }, // Calculated Collapse when no room exists able to expand when height allows it to | ||
27 | _collapsed : { value: null }, // collapsed value will set Panels State to collapsed or uncollapsed by its value (boolean) | ||
28 | _visible: { value:null }, // Visible variable when visible is set to false Panel will hide | ||
29 | scrollable: { value: true }, | ||
30 | |||
31 | // Getter and Setters | ||
32 | contentHeight: { | ||
33 | get: function() { | ||
34 | if(this._contentHeight == null) { | ||
35 | if(this.application.ninja.settings.getSetting(this.panelName, "contentHeight")) { | ||
36 | this._contentHeight = this.application.ninja.settings.getSetting(this.panelName, "contentHeight"); | ||
37 | } else { | ||
38 | this._contentHeight = this.defaultHeight; | ||
39 | } | ||
40 | } | ||
41 | return this._contentHeight; | ||
42 | }, | ||
43 | set: function(value) { | ||
44 | if (this.minHeight > value) value = this._minHeight; | ||
45 | if (this.maxHeight != null) if(this.maxHeight < value) value = this.maxHeight; | ||
46 | this._contentHeight = value; | ||
47 | this.application.ninja.settings.setSetting(this.panelName, "contentHeight", value); | ||
48 | } | ||
49 | }, | ||
50 | forcedCollapse: { | ||
51 | get: function() { | ||
52 | if(this._forcedCollapse == null) { | ||
53 | if(this.application.Ninja.SettingsManager.getSetting(this.panelName, "isPanelForceCollapsed")) { | ||
54 | this._forcedCollapse = this.application.Ninja.SettingsManager.getSetting(this.panelName, "isPanelForceCollapsed"); | ||
55 | } else { | ||
56 | this._forcedCollapse = false; | ||
57 | } | ||
58 | } | ||
59 | return this._forcedCollapse; | ||
60 | }, | ||
61 | set: function(value) { | ||
62 | this._forcedCollapse = value; | ||
63 | this.application.Ninja.SettingsManager.setSetting(this.panelName, "isPanelForceCollapsed", value); | ||
64 | } | ||
65 | }, | ||
66 | collapsed: { | ||
67 | get: function() { | ||
68 | if(this._collapsed == null) { | ||
69 | if(this.application.ninja.settings.getSetting(this.panelName, "isPanelCollapsed")) { | ||
70 | this._collapsed = this.application.ninja.settings.getSetting(this.panelName, "isPanelCollapsed"); | ||
71 | } else { | ||
72 | this._collapsed = false; | ||
73 | } | ||
74 | } | ||
75 | return this._collapsed; | ||
76 | }, | ||
77 | set: function(value) { | ||
78 | this._collapsed = value; | ||
79 | this.application.ninja.settings.setSetting(this.panelName, "isPanelCollapsed", value); | ||
80 | } | ||
81 | }, | ||
82 | visible: { | ||
83 | get: function() { | ||
84 | |||
85 | if(this._visible === null) { | ||
86 | if(typeof(this.application.ninja.settings.getSetting(this.panelName, "visible")) !== "undefined") { | ||
87 | this._visible = this.application.ninja.settings.getSetting(this.panelName, "visible"); | ||
88 | } else { | ||
89 | this._visible = true; | ||
90 | } | ||
91 | } | ||
92 | |||
93 | return this._visible; | ||
94 | }, | ||
95 | set: function(value) { | ||
96 | this._visible = value; | ||
97 | |||
98 | this.application.ninja.settings.setSetting(this.panelName, "visible", value); | ||
99 | |||
100 | } | ||
101 | } | ||
102 | |||
103 | // Methods exist in panel.js | ||
104 | |||
105 | }); | ||