aboutsummaryrefslogtreecommitdiff
path: root/js/document/views
diff options
context:
space:
mode:
Diffstat (limited to 'js/document/views')
-rw-r--r--js/document/views/design-code.js130
1 files changed, 130 insertions, 0 deletions
diff --git a/js/document/views/design-code.js b/js/document/views/design-code.js
new file mode 100644
index 00000000..25073833
--- /dev/null
+++ b/js/document/views/design-code.js
@@ -0,0 +1,130 @@
1/* <copyright>
2Copyright (c) 2012, Motorola Mobility LLC.
3All Rights Reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7
8* Redistributions of source code must retain the above copyright notice,
9 this list of conditions and the following disclaimer.
10
11* Redistributions in binary form must reproduce the above copyright notice,
12 this list of conditions and the following disclaimer in the documentation
13 and/or other materials provided with the distribution.
14
15* Neither the name of Motorola Mobility LLC nor the names of its
16 contributors may be used to endorse or promote products derived from this
17 software without specific prior written permission.
18
19THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29POSSIBILITY OF SUCH DAMAGE.
30</copyright> */
31
32////////////////////////////////////////////////////////////////////////
33//
34var Montage = require("montage/core/core").Montage,
35 Component = require("montage/ui/component").Component,
36 CodeDocumentView = require("js/document/views/code").CodeDocumentView;
37////////////////////////////////////////////////////////////////////////
38//Code View for the HTML file
39//
40exports.DesignCodeView = Montage.create(CodeDocumentView, {
41 ////////////////////////////////////////////////////////////////////
42 //
43 hasTemplate: {
44 value: false
45 },
46 ////////////////////////////////////////////////////////////////////
47 //
48 init:{
49 value: function (content) {
50
51 }
52 },
53 ////////////////////////////////////////////////////////////////////
54 //
55 load:{
56 value:function(content){
57 //initialize the editor if not yet created
58 if(this.editor === null){
59 //todo: get the proper content
60 this.textArea.value = content;
61 this.initializeTextView(this.application.ninja.currentDocument.model.file, this.application.ninja.currentDocument);
62 return true;
63 }else{//reload the editor
64 this.editor.setValue(content);
65 this.editor.focus();
66 }
67 }
68 },
69 ////////////////////////////////////////////////////////////////////
70 //
71 show: {
72 value: function (callback) {
73
74 this.textViewContainer.style.display = "block";
75 this.textViewContainer.style.background = "white";
76 this.textViewContainer.style.height = "100%";
77
78
79 ///todo-remove after the switch view logic is added in all the components
80 this.application.ninja.stage.collapseAllPanels();
81 this.application.ninja.stage.hideCanvas(true);
82 this.application.ninja.stage.hideRulers();
83
84 document.getElementsByClassName("bindingView")[0].style.display = "none";
85
86 //bindingView div needs to be display noned
87 //timeline error on switching back to design view
88
89 ///-end todo-remove
90
91
92
93
94 //todo : update options bar
95
96 //
97 if (callback) callback();
98 }
99 },
100 ////////////////////////////////////////////////////////////////////
101 //
102 hide: {
103 value: function (callback) {
104 if(this.editor){
105 this.editor.save();//save to textarea
106 }
107 this.textViewContainer.style.display = "none";
108
109 ///todo-remove after the switch view logic is added in all the components
110 this.application.ninja.stage.restoreAllPanels(false);
111 this.application.ninja.stage.hideCanvas(false);
112 this.application.ninja.stage.showRulers();
113 ///-end todo-remove
114
115
116 //todo : update options bar
117
118 //
119 if (callback) callback();
120 }
121 },
122 ////////////////////////////////////////////////////////////////////
123 //
124 applyTheme:{
125 value:function(themeClass){
126 //Todo: change for bucket structure of documents
127 this.textViewContainer.className = "codeViewContainer "+themeClass;
128 }
129 }
130}); \ No newline at end of file