diff options
Diffstat (limited to 'js/components/layout/document-bar.reel/document-bar.js')
-rwxr-xr-x | js/components/layout/document-bar.reel/document-bar.js | 232 |
1 files changed, 119 insertions, 113 deletions
diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js index 248bc8c4..dbb4fcad 100755 --- a/js/components/layout/document-bar.reel/document-bar.js +++ b/js/components/layout/document-bar.reel/document-bar.js | |||
@@ -29,140 +29,115 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | |||
29 | POSSIBILITY OF SUCH DAMAGE. | 29 | POSSIBILITY OF SUCH DAMAGE. |
30 | </copyright> */ | 30 | </copyright> */ |
31 | 31 | ||
32 | var Montage = require("montage/core/core").Montage; | 32 | //////////////////////////////////////////////////////////////////////// |
33 | var Component = require("montage/ui/component").Component; | 33 | // |
34 | 34 | var Montage = require("montage/core/core").Montage, | |
35 | Component = require("montage/ui/component").Component; | ||
36 | //////////////////////////////////////////////////////////////////////// | ||
37 | // | ||
35 | exports.DocumentBar = Montage.create(Component, { | 38 | exports.DocumentBar = Montage.create(Component, { |
36 | 39 | //////////////////////////////////////////////////////////////////// | |
37 | _currentDocument: { | 40 | // |
38 | enumerable: false, | 41 | _currentDocument: {value: null}, |
39 | value: null | 42 | //////////////////////////////////////////////////////////////////// |
40 | }, | 43 | // |
41 | |||
42 | currentDocument: { | 44 | currentDocument: { |
43 | enumerable: false, | 45 | get: function() {return this._currentDocument;}, |
44 | get: function() { | ||
45 | return this._currentDocument; | ||
46 | }, | ||
47 | set: function(value) { | 46 | set: function(value) { |
47 | // | ||
48 | if (value === this._currentDocument) { | 48 | if (value === this._currentDocument) { |
49 | return; | 49 | return; |
50 | } | 50 | } |
51 | 51 | // | |
52 | this._currentDocument = value; | 52 | this._currentDocument = value; |
53 | |||
54 | this.disabled = !this._currentDocument; | 53 | this.disabled = !this._currentDocument; |
55 | 54 | // | |
56 | if(this._currentDocument && this._currentDocument.currentView === "design") { | 55 | if(this._currentDocument && this._currentDocument.model && this._currentDocument.model.currentView === this._currentDocument.model.views.design) { |
57 | this.visible = true; | 56 | this.btnCode.setAttribute('class', 'inactive'); |
58 | } else if(this._currentDocument && this._currentDocument.currentView === "code") { | 57 | this.btnDesign.removeAttribute('class'); |
59 | this.visible = false; | 58 | } else if(this._currentDocument && this._currentDocument.model && this._currentDocument.model.currentView === this._currentDocument.model.views.code) { |
59 | this.btnDesign.setAttribute('class', 'inactive'); | ||
60 | this.btnCode.removeAttribute('class'); | ||
60 | } | 61 | } |
62 | // | ||
63 | this.visible = true; | ||
61 | } | 64 | } |
62 | }, | 65 | }, |
63 | 66 | //////////////////////////////////////////////////////////////////// | |
67 | // | ||
64 | _visible: { | 68 | _visible: { |
65 | value: false | 69 | value: false |
66 | }, | 70 | }, |
67 | 71 | //////////////////////////////////////////////////////////////////// | |
72 | // | ||
68 | visible: { | 73 | visible: { |
69 | get: function() { | 74 | get: function() {return this._visible;}, |
70 | return this._visible; | ||
71 | }, | ||
72 | set: function(value) { | 75 | set: function(value) { |
76 | // | ||
73 | if(this._visible !== value) { | 77 | if(this._visible !== value) { |
74 | this._visible = value; | 78 | this._visible = value; |
75 | this.needsDraw = true; | 79 | this.needsDraw = true; |
76 | } | 80 | } |
77 | } | 81 | } |
78 | }, | 82 | }, |
79 | 83 | //////////////////////////////////////////////////////////////////// | |
80 | designView: { | 84 | // |
81 | value: null | ||
82 | }, | ||
83 | |||
84 | codeView: { | ||
85 | value: null | ||
86 | }, | ||
87 | |||
88 | zoomControl: { | 85 | zoomControl: { |
89 | value: null, | 86 | value: null, |
90 | serializable: true | 87 | serializable: true |
91 | }, | 88 | }, |
92 | 89 | //////////////////////////////////////////////////////////////////// | |
93 | _type: { | 90 | // |
94 | value: null | ||
95 | }, | ||
96 | |||
97 | type: { | ||
98 | enumerable: false, | ||
99 | get: function() { return this._type; }, | ||
100 | set: function(value) { | ||
101 | if (this._type === value) { | ||
102 | return; | ||
103 | } | ||
104 | |||
105 | this._type = value; | ||
106 | this.needsDraw = true; | ||
107 | |||
108 | } | ||
109 | }, | ||
110 | |||
111 | _currentView: { | ||
112 | value: null | ||
113 | }, | ||
114 | |||
115 | currentView: { | ||
116 | get: function() { return this._currentView}, | ||
117 | set: function(value) { | ||
118 | if (this._currentView === value) { | ||
119 | return; | ||
120 | } | ||
121 | |||
122 | this._currentView = value; | ||
123 | this.needsDraw = true; | ||
124 | } | ||
125 | }, | ||
126 | |||
127 | _zoomFactor: { | 91 | _zoomFactor: { |
128 | value: 100 | 92 | value: 100 |
129 | }, | 93 | }, |
130 | 94 | //////////////////////////////////////////////////////////////////// | |
95 | // | ||
131 | zoomFactor: { | 96 | zoomFactor: { |
132 | get: function() { return this._zoomFactor; }, | 97 | get: function() {return this._zoomFactor;}, |
133 | 98 | set: function(value) { | |
134 | set: function(value) | 99 | if(value !== this._zoomFactor) { |
135 | { | 100 | // |
136 | if(value !== this._zoomFactor) | ||
137 | { | ||
138 | this._zoomFactor = value; | 101 | this._zoomFactor = value; |
139 | if (!this._firstDraw) | 102 | // |
140 | { | 103 | if (!this._firstDraw) { |
141 | this.application.ninja.stage.setZoom(value); | 104 | this.application.ninja.stage.setZoom(value); |
142 | } | 105 | } |
143 | } | 106 | } |
144 | } | 107 | } |
145 | }, | 108 | }, |
146 | 109 | //////////////////////////////////////////////////////////////////// | |
147 | draw: { | 110 | // |
111 | prepareForDraw: { | ||
148 | value: function() { | 112 | value: function() { |
149 | /* | 113 | // |
150 | if(this.type === "htm" || this.type === "html") { | 114 | this.btnCode.addEventListener('click', this.showViewCode.bind(this), false); |
151 | this.designView.classList.add("active"); | 115 | this.btnDesign.addEventListener('click', this.showViewDesign.bind(this), false); |
152 | this.codeView.classList.add("active"); | 116 | } |
153 | 117 | }, | |
154 | if(this.currentView === "design") { | 118 | //////////////////////////////////////////////////////////////////// |
155 | this.designView.classList.add("selected"); | 119 | // |
156 | if(this.codeView.classList.contains("selected")) this.codeView.classList.toggle("selected"); | 120 | willDraw: { |
157 | } else { | 121 | value: function() { |
158 | this.codeView.classList.add("selected"); | 122 | // |
159 | if(this.designView.classList.contains("selected")) this.designView.classList.toggle("selected"); | 123 | this.btnCode.setAttribute('class', 'inactive'); |
124 | this.btnDesign.setAttribute('class', 'inactive'); | ||
125 | // | ||
126 | if (this._currentDocument && this._currentDocument.model && this._currentDocument.model.currentView) { | ||
127 | // | ||
128 | if (this._currentDocument.model.currentView === this._currentDocument.model.views.design) { | ||
129 | this.btnDesign.removeAttribute('class'); | ||
130 | } else if (this._currentDocument.model.currentView === this._currentDocument.model.views.code) { | ||
131 | this.btnCode.removeAttribute('class'); | ||
160 | } | 132 | } |
161 | |||
162 | } else if(this.type) { | ||
163 | this.designView.classList.remove("active"); | ||
164 | } | 133 | } |
165 | */ | 134 | } |
135 | }, | ||
136 | //////////////////////////////////////////////////////////////////// | ||
137 | // | ||
138 | draw: { | ||
139 | value: function() { | ||
140 | // | ||
166 | if(this.visible) { |