diff options
Diffstat (limited to 'js/panels/css-panel/styles-view-container.reel/styles-view-container.js')
-rw-r--r-- | js/panels/css-panel/styles-view-container.reel/styles-view-container.js | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/js/panels/css-panel/styles-view-container.reel/styles-view-container.js b/js/panels/css-panel/styles-view-container.reel/styles-view-container.js new file mode 100644 index 00000000..7df39d39 --- /dev/null +++ b/js/panels/css-panel/styles-view-container.reel/styles-view-container.js | |||
@@ -0,0 +1,101 @@ | |||
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 | Component = require("montage/ui/component").Component; | ||
9 | |||
10 | exports.StylesViewContainer = Montage.create(Component, { | ||
11 | contentController : { | ||
12 | value: null | ||
13 | }, | ||
14 | contentPanel : { | ||
15 | value: 'rules' | ||
16 | }, | ||
17 | _hasStyles : { | ||
18 | value: false | ||
19 | }, | ||
20 | hasStyles : { | ||
21 | get: function() { | ||
22 | return this._hasStyles; | ||
23 | }, | ||
24 | set: function(hasThem) { | ||
25 | this._hasStyles = hasThem; | ||
26 | this.needsDraw = true; | ||
27 | } | ||
28 | }, | ||
29 | templateDidLoad : { | ||
30 | value: function() { | ||
31 | console.log("styles view container - deserialized"); | ||
32 | this.eventManager.addEventListener('styleSheetsReady', this, false); | ||
33 | } | ||
34 | }, | ||
35 | handleStyleSheetsReady: { | ||
36 | value: function(e) { | ||
37 | this.eventManager.addEventListener( "selectionChange", this, false); | ||
38 | } | ||
39 | }, | ||
40 | handleSelectionChange: { | ||
41 | value: function() { | ||
42 | var elements = this.application.ninja.selectedElements, | ||
43 | type, selection, ruleList; | ||
44 | |||
45 | if(elements.length === 0) { | ||
46 | return false; | ||
47 | } else if(elements.length > 1) { | ||
48 | type = 'ELEMENTS'; | ||
49 | selection = elements; | ||
50 | } else { | ||
51 | type = 'ELEMENT'; | ||
52 | selection = elements[0]; | ||
53 | } | ||
54 | |||
55 | ruleList = this.ruleListContainer._getRuleList({ | ||
56 | selectionType : type, | ||
57 | selection : selection | ||
58 | }); | ||
59 | |||
60 | if(ruleList) { | ||
61 | this.ruleListContainer.displayedList = ruleList; | ||
62 | } else { | ||
63 | this.ruleListContainer.add(type, selection); | ||
64 | } | ||
65 | |||
66 | this.hasStyles = true; | ||
67 | } | ||
68 | }, | ||
69 | |||
70 | _ruleList : { | ||
71 | value: [] | ||
72 | }, | ||
73 | ruleList : { | ||
74 | get: function() { | ||
75 | return this._ruleList; | ||
76 | }, | ||
77 | set: function(list) { | ||
78 | if(!list) { | ||
79 | this._ruleList.length = 0; | ||
80 | return; | ||
81 | } | ||
82 | |||
83 | this._ruleList = list; | ||
84 | this.needsDraw = true; | ||
85 | } | ||
86 | }, | ||
87 | prepareForDraw : { | ||
88 | value: function() { | ||
89 | console.log("styles view container - prepare for draw"); | ||
90 | } | ||
91 | }, | ||
92 | draw : { | ||
93 | value: function() { | ||
94 | if(this.hasStyles) { | ||
95 | this.element.classList.remove('no-styles'); | ||
96 | } else { | ||
97 | this.element.classList.add('no-styles'); | ||
98 | } | ||
99 | } | ||
100 | } | ||
101 | }); \ No newline at end of file | ||