aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/code-editor/code-editor-wrapper.js6
-rw-r--r--js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js2
-rwxr-xr-xjs/components/layout/document-bar.reel/document-bar.html19
-rwxr-xr-xjs/components/layout/document-bar.reel/document-bar.js289
-rwxr-xr-xjs/controllers/document-controller.js8
-rwxr-xr-xjs/document/document-html.js71
-rwxr-xr-xjs/document/document-text.js4
-rwxr-xr-xjs/document/mediators/template.js12
-rwxr-xr-xjs/document/models/base.js22
-rw-r--r--js/document/views/design-code.js130
10 files changed, 419 insertions, 144 deletions
diff --git a/js/code-editor/code-editor-wrapper.js b/js/code-editor/code-editor-wrapper.js
index 57fe4d3a..65f42db2 100644
--- a/js/code-editor/code-editor-wrapper.js
+++ b/js/code-editor/code-editor-wrapper.js
@@ -131,6 +131,12 @@ exports.CodeEditorWrapper = Montage.create(Component, {
131 this.application.ninja.editorViewOptions.codeEditorWrapper = this; 131 this.application.ninja.editorViewOptions.codeEditorWrapper = this;
132 } 132 }
133 133
134 //TODO:add codeEditorWrapper
135 if(!this.application.ninja.documentBar.codeEditorWrapper){
136 this.application.ninja.documentBar.codeEditorWrapper = this;
137 }
138
139
134 editorOptions = { 140 editorOptions = {
135 lineNumbers: true, 141 lineNumbers: true,
136 matchBrackets:true, 142 matchBrackets:true,
diff --git a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js
index 9344d34c..e2632d35 100644
--- a/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js
+++ b/js/code-editor/ui/code-editor-view-options.reel/code-editor-view-options.js
@@ -51,7 +51,7 @@ exports.CodeEditorViewOptions = Montage.create(Component, {
51 51
52 this._currentDocument = value; 52 this._currentDocument = value;
53 53
54 if(!value || this._currentDocument.currentView === "design") { 54 if(!value || (this._currentDocument.currentView === "design") || ((this._currentDocument.model.views.design !== null))) {
55 this.visible = false; 55 this.visible = false;
56 } else { 56 } else {
57 this.visible = true; 57 this.visible = true;
diff --git a/js/components/layout/document-bar.reel/document-bar.html b/js/components/layout/document-bar.reel/document-bar.html
index 9e5e4eb2..3e3ac936 100755
--- a/js/components/layout/document-bar.reel/document-bar.html
+++ b/js/components/layout/document-bar.reel/document-bar.html
@@ -75,20 +75,17 @@ POSSIBILITY OF SUCH DAMAGE.
75 "element": {"#": "previewButton"}, 75 "element": {"#": "previewButton"},
76 "identifier": "preview", 76 "identifier": "preview",
77 "label": "Preview" 77 "label": "Preview"
78 }, 78 }
79 "listeners": [
80 {
81 "type": "action",
82 "listener": {"@": "owner"}
83 }
84 ]
85 }, 79 },
86 80
87 "owner": { 81 "owner": {
88 "prototype": "js/components/layout/document-bar.reel", 82 "prototype": "js/components/layout/document-bar.reel",
89 "properties": { 83 "properties": {
90 "element": {"#": "documentBar"}, 84 "element": {"#": "documentBar"},
91 "zoomControl": {"@": "hottext1"} 85 "zoomControl": {"@": "hottext1"},
86 "btnDesign": {"#": "buttonDesign"},
87 "btnCode": {"#": "buttonCode"},
88 "btnPreview": {"#": "buttonPreview"}
92 } 89 }
93 } 90 }
94 } 91 }
@@ -108,7 +105,7 @@ POSSIBILITY OF SUCH DAMAGE.
108 105
109 </section> 106 </section>
110 107
111 <section> 108 <section data-montage-id="buttonDesign">
112 109
113 <div class="viewicon viewdesign"></div> 110 <div class="viewicon viewdesign"></div>
114 111
@@ -116,7 +113,7 @@ POSSIBILITY OF SUCH DAMAGE.
116 113
117 </section> 114 </section>
118 115
119 <section class="inactive"> 116 <section data-montage-id="buttonCode">
120 117
121 <div class="viewicon viewcode"></div> 118 <div class="viewicon viewcode"></div>
122 119
@@ -124,7 +121,7 @@ POSSIBILITY OF SUCH DAMAGE.
124 121
125 </section> 122 </section>
126 123
127 <section class="inactive"> 124 <section data-montage-id="buttonPreview" class="inactive">
128 125
129 <div class="viewicon viewPreview"></div> 126 <div class="viewicon viewPreview"></div>
130 127
diff --git a/js/components/layout/document-bar.reel/document-bar.js b/js/components/layout/document-bar.reel/document-bar.js
index fa0c8788..bf84c652 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 },