diff options
Diffstat (limited to 'js/components/layout/document-bar.reel')
-rwxr-xr-x | js/components/layout/document-bar.reel/document-bar.html | 6 | ||||
-rwxr-xr-x | js/components/layout/document-bar.reel/document-bar.js | 112 |
2 files changed, 85 insertions, 33 deletions
diff --git a/js/components/layout/document-bar.reel/document-bar.html b/js/components/layout/document-bar.reel/document-bar.html index 760186ba..a35b5590 100755 --- a/js/components/layout/document-bar.reel/document-bar.html +++ b/js/components/layout/document-bar.reel/document-bar.html | |||
@@ -37,11 +37,7 @@ | |||
37 | "element": {"#": "disabledCondition"} | 37 | "element": {"#": "disabledCondition"} |
38 | }, | 38 | }, |
39 | "bindings": { | 39 | "bindings": { |
40 | "condition": { | 40 | "condition": {"<-": "@owner.disabled"} |
41 | "boundObject": {"@": "owner"}, | ||
42 | "boundObjectPropertyPath": "disabled", | ||
43 | "oneway": true | ||
44 | } | ||
45 | } | 41 | } |
46 | }, | 42 | }, |
47 | 43 | ||
diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js index 56b61f1d..1cb0bd90 100755 --- a/js/components/layout/document-bar.reel/document-bar.js +++ b/js/components/layout/document-bar.reel/document-bar.js | |||
@@ -9,13 +9,64 @@ var Component = require("montage/ui/component").Component; | |||
9 | 9 | ||
10 | exports.DocumentBar = Montage.create(Component, { | 10 | exports.DocumentBar = Montage.create(Component, { |
11 | 11 | ||
12 | designView: { value: null, enumerable: false}, | 12 | _currentDocument: { |
13 | codeView: { value: null, enumerable: false}, | 13 | enumerable: false, |
14 | zoomControl: { value: null, enumerable: false }, | 14 | value: null |
15 | _type: { enumerable: false, value: null }, | 15 | }, |
16 | disabled: { value: true }, | 16 | |
17 | currentDocument: { | ||
18 | enumerable: false, | ||
19 | get: function() { | ||
20 | return this._currentDocument; | ||
21 | }, | ||
22 | set: function(value) { | ||
23 | if (value === this._currentDocument) { | ||
24 | return; | ||
25 | } | ||
26 | |||
27 | this._currentDocument = value; | ||
28 | |||
29 | this.disabled = !this._currentDocument; | ||
30 | |||
31 | if(this._currentDocument && this._currentDocument.currentView === "design") { | ||
32 | this.visible = true; | ||
33 | } else if(this._currentDocument && this._currentDocument.currentView === "code") { | ||
34 | this.visible = false; | ||
35 | } | ||
36 | } | ||
37 | }, | ||
38 | |||
39 | _visible: { | ||
40 | value: false | ||
41 | }, | ||
42 | |||
43 | visible: { | ||
44 | get: function() { | ||
45 | return this._visible; | ||
46 | }, | ||
47 | set: function(value) { | ||
48 | if(this._visible !== value) { | ||
49 | this._visible = value; | ||
50 | this.needsDraw = true; | ||
51 | } | ||
52 | } | ||
53 | }, | ||
54 | |||
55 | designView: { | ||
56 | value: null | ||
57 | }, | ||
58 | |||
59 | codeView: { | ||
60 | value: null | ||
61 | }, | ||
17 | 62 | ||
63 | zoomControl: { | ||
64 | value: null | ||
65 | }, | ||
18 | 66 | ||
67 | _type: { | ||
68 | value: null | ||
69 | }, | ||
19 | 70 | ||
20 | type: { | 71 | type: { |
21 | enumerable: false, | 72 | enumerable: false, |
@@ -31,7 +82,9 @@ exports.DocumentBar = Montage.create(Component, { | |||
31 | } | 82 | } |
32 | }, | 83 | }, |
33 | 84 | ||
34 | _currentView: { value: null, enumerable: false }, | 85 | _currentView: { |
86 | value: null | ||
87 | }, | ||
35 | 88 | ||
36 | currentView: { | 89 | currentView: { |
37 | get: function() { return this._currentView}, | 90 | get: function() { return this._currentView}, |
@@ -45,7 +98,9 @@ exports.DocumentBar = Montage.create(Component, { | |||
45 | } | 98 | } |
46 | }, | 99 | }, |
47 | 100 | ||
48 | _zoomFactor: { value: 100, enumerable: false }, | 101 | _zoomFactor: { |
102 | value: 100 | ||
103 | }, | ||
49 | 104 | ||
50 | zoomFactor: { | 105 | zoomFactor: { |
51 | get: function() { return this._zoomFactor; }, | 106 | get: function() { return this._zoomFactor; }, |
@@ -65,6 +120,7 @@ exports.DocumentBar = Montage.create(Component, { | |||
65 | 120 | ||
66 | draw: { | 121 | draw: { |
67 | value: function() { | 122 | value: function() { |
123 | /* | ||
68 | if(this.type === "htm" || this.type === "html") { | 124 | if(this.type === "htm" || this.type === "html") { |
69 | this.designView.classList.add("active"); | 125 | this.designView.classList.add("active"); |
70 | this.codeView.classList.add("active"); | 126 | this.codeView.classList.add("active"); |
@@ -80,46 +136,46 @@ exports.DocumentBar = Montage.create(Component, { | |||
80 | } else if(this.type) { | 136 | } else if(this.type) { |
81 | this.designView.classList.remove("active"); | 137 | this.designView.classList.remove("active"); |
82 | } | 138 | } |
139 | */ | ||
140 | if(this.visible) { | ||
141 | this.element.style.display = "block"; | ||
142 | } else { | ||
143 | this.element.style.display = "none"; | ||
144 | } | ||
83 | 145 | ||
84 | } | 146 | } |
85 | }, | 147 | }, |
86 | 148 | ||
87 | prepareForDraw: { | 149 | prepareForDraw: { |
88 | value: function() { | 150 | value: function() { |
89 | this.eventManager.addEventListener( "openDocument", this, false); | ||
90 | this.eventManager.addEventListener( "closeDocument", this, false); | ||
91 | this.designView.addEventListener("click", this, false); | 151 | this.designView.addEventListener("click", this, false); |
92 | this.codeView.addEventListener("click", this, false); | 152 | this.codeView.addEventListener("click", this, false); |
93 | 153 | ||
94 | } | 154 | } |
95 | }, | 155 | }, |
96 | 156 | ||
97 | handleClick: { | 157 | _disabled: { |
98 | value: function(event) { | 158 | value: true |
99 | if(event._event.target.id === this.currentView) return; | ||
100 | |||
101 | this.currentView = event._event.target.id; | ||
102 | this.application.ninja.documentController.stage.stageView.switchDesignDocViews(event._event.target.id);//switch between design view | ||
103 | } | ||
104 | }, | ||
105 | |||
106 | handleOpenDocument: { | ||
107 | value: function() { | ||
108 | this.disabled = false; | ||
109 | } | ||
110 | }, | 159 | }, |
111 | 160 | ||
112 | handleCloseDocument: { | 161 | disabled: { |
113 | value: function() { | 162 | get: function() { |
114 | if(!this.application.ninja.documentController.activeDocument) { | 163 | return this._disabled; |
115 | this.disabled = true; | 164 | }, |
165 | set: function(value) { | ||
166 | if(value !== this._disabled) { | ||
167 | this._disabled = value; | ||
116 | } | 168 | } |
117 | } | 169 | } |
118 | }, | 170 | }, |
119 | 171 | ||
120 | handleOnDocumentChanged:{ | ||
121 | value:function(event){ | ||
122 | 172 | ||
173 | handleClick: { | ||
174 | value: function(event) { | ||
175 | if(event._event.target.id === this.currentView) return; | ||
176 | |||
177 | this.currentView = event._event.target.id; | ||
178 | this.application.ninja.documentController.stage.stageView.switchDesignDocViews(event._event.target.id);//switch between design view | ||
123 | } | 179 | } |
124 | } | 180 | } |
125 | }); | 181 | }); |