aboutsummaryrefslogtreecommitdiff
path: root/js/panels/css-panel/styles-view-container.reel/styles-view-container.js
diff options
context:
space:
mode:
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.js133
1 files changed, 133 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..6ce64b8f
--- /dev/null
+++ b/js/panels/css-panel/styles-view-container.reel/styles-view-container.js
@@ -0,0 +1,133 @@
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
7var Montage = require("montage/core/core").Montage,
8 Component = require("montage/ui/component").Component;
9
10exports.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
30 _getElementLabel : {
31 value: function(el) {
32 var id = '#'+el.id,
33 className = '.'+Array.prototype.slice.call(el.classList).join('.'),
34 nodeName = el.nodeName;
35
36 if(id.length > 1) {
37 return nodeName + id;
38 } else if(className.length > 1) {
39 return nodeName + className;
40 }
41
42 return nodeName;
43 }
44 },
45
46 templateDidLoad : {
47 value: function() {
48 this.eventManager.addEventListener('styleSheetsReady', this, false);
49 //this.eventManager.addEventListener('elementChanging', this, false);
50 this.eventManager.addEventListener('elementChange', this, false);
51 }
52 },
53 handleStyleSheetsReady: {
54 value: function(e) {
55 this.eventManager.addEventListener( "selectionChange", this, false);
56 }
57 },
58 handleSelectionChange: {
59 value: function() {
60 var elements = this.application.ninja.selectedElements;
61
62 if(elements.length === 0) {
63 this.hasStyles = false;
64 return false;
65 } else if(elements.length === 1) {
66
67 ///// update the selection status label with the label of the element
68 this.selectionNameLabel.innerHTML = this._getElementLabel(elements[0]);
69
70 if(this.contentPanel === "rules") {
71 this.ruleListContainer.displayListForSelection(elements);
72 } else {
73 this.computedStyleView.declaration = elements[0];
74 }
75 } else {
76
77 }
78
79 this.hasStyles = true;
80 }
81 },
82 handleElementChange : {
83 value: function(e) {
84 var elements = this.application.ninja.selectedElements;
85
86 if(elements.length === 0) {
87 return false;
88 } else if(elements.length === 1) {
89 if(this.contentPanel === "rules") {
90 if(e._event.detail.type !== 'cssChange') {
91 this.ruleListContainer.update();
92 }
93 } else {
94 this.computedStyleView.declaration = elements[0];
95 }
96 } else {
97 return false;
98 }
99
100 }
101 },
102
103 handleElementChanging : {
104 value: function(e) {
105 var elements = this.application.ninja.selectedElements;
106
107 if(elements.length === 1) {
108 if(this.contentPanel === "rules") {
109// if(e._event.detail.type !== 'cssChange') {
110// this.ruleListContainer.displayedList.component.update();
111// }
112 } else {
113 this.computedStyleView.declaration = elements[0];
114 }
115 }
116
117 return false;
118
119 }
120 },
121
122 draw : {
123 value: function() {
124 if(this.hasStyles) {
125 this.element.classList.remove('no-styles');
126 this.selectionNameLabel.classList.remove('no-styles');
127 } else {
128 this.element.classList.add('no-styles');
129 this.selectionNameLabel.classList.add('no-styles');
130 }
131 }
132 }
133}); \ No newline at end of file