aboutsummaryrefslogtreecommitdiff
path: root/js/components/layout/document-bar.reel/document-bar.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/components/layout/document-bar.reel/document-bar.js')
-rwxr-xr-xjs/components/layout/document-bar.reel/document-bar.js289
1 files changed, 175 insertions, 114 deletions
diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js
index fa0c8788..098e9e68 100755
--- a/js/components/layout/document-bar.reel/document-bar.js
+++ b/js/components/layout/document-bar.reel/document-bar.js
@@ -29,140 +29,157 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29POSSIBILITY OF SUCH DAMAGE. 29POSSIBILITY OF SUCH DAMAGE.
30</copyright> */ 30</copyright> */
31 31
32var Montage = require("montage/core/core").Montage; 32////////////////////////////////////////////////////////////////////////
33var Component = require("montage/ui/component").Component; 33//
34 34var Montage = require("montage/core/core").Montage,
35 Component = require("montage/ui/component").Component;
36////////////////////////////////////////////////////////////////////////
37//
35exports.DocumentBar = Montage.create(Component, { 38exports.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;
54 //
55 if(this._currentDocument && this._currentDocument.model && this._currentDocument.model.currentView === this._currentDocument.model.views.design) {
56 this.btnCode.setAttribute('class', 'inactive');
57 this.btnDesign.removeAttribute('class');
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');
61 }
62 //
63 this.visible = true;
55 64
56 if(this._currentDocument && this._currentDocument.currentView === "design") { 65 //TODO: check if the code's options bar can be unified
57 this.visible = true; 66 if(this._currentDocument && this._currentDocument.model && (this._currentDocument.model.views.design === null) && (this._currentDocument.model.views.code !== null)){
58 } else if(this._currentDocument && this._currentDocument.currentView === "code") {
59 this.visible = false; 67 this.visible = false;
60 } 68 }
61 } 69 }
62 }, 70 },
63 71 ////////////////////////////////////////////////////////////////////
64 _visible: { 72 //
65 value: false 73 _codeEditorWrapper:{
74 value: null
66 }, 75 },
67 76 ////////////////////////////////////////////////////////////////////
68 visible: { 77 //
69 get: function() { 78 codeEditorWrapper:{
70 return this._visible; 79 get: function() {return this._codeEditorWrapper;},
71 },
72 set: function(value) { 80 set: function(value) {
73 if(this._visible !== value) { 81 //
74 this._visible = value; 82 if(this._codeEditorWrapper !== value){
75 this.needsDraw = true; 83 this._codeEditorWrapper = value;
76 } 84 }
77 } 85 }
78 }, 86 },
79 87 ////////////////////////////////////////////////////////////////////
80 designView: { 88 //
89 btnCode: {
81 value: null 90 value: null
82 }, 91 },
83 92 ////////////////////////////////////////////////////////////////////
84 codeView: { 93 //
94 btnDesign: {
85 value: null 95 value: null
86 }, 96 },
87 97 ////////////////////////////////////////////////////////////////////
88 zoomControl: { 98 //
89 value: null, 99 btnPreview: {
90 serializable: true
91 },
92
93 _type: {
94 value: null 100 value: null
95 }, 101 },
96 102 ////////////////////////////////////////////////////////////////////
97 type: { 103 //
98 enumerable: false, 104 _visible: {
99 get: function() { return this._type; }, 105 value: false
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 }, 106 },
114 107 ////////////////////////////////////////////////////////////////////
115 currentView: { 108 //
116 get: function() { return this._currentView}, 109 visible: {
110 get: function() {return this._visible;},
117 set: function(value) { 111 set: function(value) {
118 if (this._currentView === value) { 112 //
119 return; 113 if(this._visible !== value) {
114 this._visible = value;
115 this.needsDraw = true;
120 } 116 }
121
122 this._currentView = value;
123 this.needsDraw = true;
124 } 117 }
125 }, 118 },
126 119 ////////////////////////////////////////////////////////////////////
120 //
121 zoomControl: {
122 value: null,
123 serializable: true
124 },
125 ////////////////////////////////////////////////////////////////////
126 //
127 _zoomFactor: { 127 _zoomFactor: {
128 value: 100 128 value: 100
129 }, 129 },
130 130 ////////////////////////////////////////////////////////////////////
131 //
131 zoomFactor: { 132 zoomFactor: {
132 get: function() { return this._zoomFactor; }, 133 get: function() {return this._zoomFactor;},
133 134 set: function(value) {
134 set: function(value) 135 if(value !== this._zoomFactor) {
135 { 136 //
136 if(value !== this._zoomFactor)
137 {
138 this._zoomFactor = value; 137 this._zoomFactor = value;
139 if (!this._firstDraw) 138 //
140 { 139 if (!this._firstDraw) {
141 this.application.ninja.stage.setZoom(value); 140 if(this._currentDocument && this._currentDocument.model && this._currentDocument.model.currentView === this._currentDocument.model.views.design){
141 this.application.ninja.stage.setZoom(value);
142 }else if(this._currentDocument && this._currentDocument.model && this._currentDocument.model.currentView === this._currentDocument.model.views.code){
143 this._zoomFactor = value;
144 if(this.codeEditorWrapper){this.codeEditorWrapper.handleZoom(value)};
145 }
142 } 146 }
143 } 147 }
144 } 148 }
145 }, 149 },
146 150 ////////////////////////////////////////////////////////////////////
147 draw: { 151 //
152 prepareForDraw: {
148 value: function() { 153 value: function() {
149 /* 154 //
150 if(this.type === "htm" || this.type === "html") { 155 this.btnCode.addEventListener('click', this.showViewCode.bind(this), false);
151 this.designView.classList.add("active"); 156 this.btnDesign.addEventListener('click', this.showViewDesign.bind(this), false);
152 this.codeView.classList.add("active"); 157 this.btnPreview.addEventListener('click', this, false);
153 158 }