diff options
author | Kris Kowal | 2012-07-06 11:52:06 -0700 |
---|---|---|
committer | Kris Kowal | 2012-07-06 15:01:48 -0700 |
commit | 648ee61ae84216d0236e0dbc211addc13b2cfa3a (patch) | |
tree | 8f0f55557bd0c47a84e49c1977c950645d284607 /js/document/document-html.js | |
parent | aedd14b18695d031f695d27dfbd94df5614495bb (diff) | |
download | ninja-648ee61ae84216d0236e0dbc211addc13b2cfa3a.tar.gz |
Expand tabs
Diffstat (limited to 'js/document/document-html.js')
-rwxr-xr-x | js/document/document-html.js | 136 |
1 files changed, 68 insertions, 68 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js index 566e5078..a7a0f03a 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -30,40 +30,40 @@ POSSIBILITY OF SUCH DAMAGE. | |||
30 | 30 | ||
31 | //////////////////////////////////////////////////////////////////////// | 31 | //////////////////////////////////////////////////////////////////////// |
32 | // | 32 | // |
33 | var Montage = require("montage/core/core").Montage, | 33 | var Montage = require("montage/core/core").Montage, |
34 | Component = require("montage/ui/component").Component, | 34 | Component = require("montage/ui/component").Component, |
35 | HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel, | 35 | HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel, |
36 | DesignDocumentView = require("js/document/views/design").DesignDocumentView; | 36 | DesignDocumentView = require("js/document/views/design").DesignDocumentView; |
37 | //////////////////////////////////////////////////////////////////////// | 37 | //////////////////////////////////////////////////////////////////////// |
38 | // | 38 | // |
39 | exports.HtmlDocument = Montage.create(Component, { | 39 | exports.HtmlDocument = Montage.create(Component, { |
40 | //////////////////////////////////////////////////////////////////// | 40 | //////////////////////////////////////////////////////////////////// |
41 | // | 41 | // |
42 | hasTemplate: { | 42 | hasTemplate: { |
43 | value: false | 43 | value: false |
44 | }, | 44 | }, |
45 | //////////////////////////////////////////////////////////////////// | 45 | //////////////////////////////////////////////////////////////////// |
46 | // | 46 | // |
47 | model: { | 47 | model: { |
48 | value: null | 48 | value: null |
49 | }, | 49 | }, |
50 | //////////////////////////////////////////////////////////////////// | 50 | //////////////////////////////////////////////////////////////////// |
51 | // | 51 | // |
52 | loaded: { | 52 | loaded: { |
53 | value: {callback: null, context: null} | 53 | value: {callback: null, context: null} |
54 | }, | 54 | }, |
55 | //////////////////////////////////////////////////////////////////// | 55 | //////////////////////////////////////////////////////////////////// |
56 | // | 56 | // |
57 | _observer: { | 57 | _observer: { |
58 | value: null | 58 | value: null |
59 | }, | 59 | }, |
60 | //////////////////////////////////////////////////////////////////// | 60 | //////////////////////////////////////////////////////////////////// |
61 | // | 61 | // |
62 | exclusionList: { | 62 | exclusionList: { |
63 | value: ["HTML", "BODY", "NINJA-CONTENT", "NINJA-VIEWPORT"] | 63 | value: ["HTML", "BODY", "NINJA-CONTENT", "NINJA-VIEWPORT"] |
64 | }, | 64 | }, |
65 | //////////////////////////////////////////////////////////////////// | 65 | //////////////////////////////////////////////////////////////////// |
66 | // | 66 | // |
67 | inExclusion: { | 67 | inExclusion: { |
68 | value: function(element) { | 68 | value: function(element) { |
69 | if(this.exclusionList.indexOf(element.nodeName) === -1) { | 69 | if(this.exclusionList.indexOf(element.nodeName) === -1) { |
@@ -72,62 +72,62 @@ exports.HtmlDocument = Montage.create(Component, { | |||
72 | return 1; | 72 | return 1; |
73 | } | 73 | } |
74 | }, | 74 | }, |
75 | //////////////////////////////////////////////////////////////////// | 75 | //////////////////////////////////////////////////////////////////// |
76 | // | 76 | // |
77 | init: { | 77 | init: { |
78 | value:function(file, context, callback, view, template) { | 78 | value:function(file, context, callback, view, template) { |
79 | //Storing callback data for loaded dispatch | 79 | //Storing callback data for loaded dispatch |
80 | this.loaded.callback = callback; | 80 | this.loaded.callback = callback; |
81 | this.loaded.context = context; | 81 | this.loaded.context = context; |
82 | //Creating instance of HTML Document Model | 82 | //Creating instance of HTML Document Model |
83 | this.model = Montage.create(HtmlDocumentModel,{ | 83 | this.model = Montage.create(HtmlDocumentModel,{ |
84 | file: {value: file}, | 84 | file: {value: file}, |
85 | fileTemplate: {value: template}, | 85 | fileTemplate: {value: template}, |
86 | parentContainer: {value: document.getElementById("iframeContainer")}, //Saving reference to parent container of all views (should be changed to buckets approach | 86 | parentContainer: {value: document.getElementById("iframeContainer")}, //Saving reference to parent container of all views (should be changed to buckets approach |
87 | views: {value: {'design': DesignDocumentView.create(), 'code': null}} //TODO: Add code view logic | 87 | views: {value: {'design': DesignDocumentView.create(), 'code': null}} //TODO: Add code view logic |
88 | }); | 88 | }); |
89 | //Calling the any init routines in the model | 89 | //Calling the any init routines in the model |
90 | this.model.init(); | 90 | this.model.init(); |
91 | //Initiliazing views and hiding | 91 | //Initiliazing views and hiding |
92 | if (this.model.views.design.initialize(this.model.parentContainer)) { | 92 | if (this.model.views.design.initialize(this.model.parentContainer)) { |
93 | //Hiding iFrame, just initiliazing | 93 | //Hiding iFrame, just initiliazing |
94 | this.model.views.design.hide(); | 94 | this.model.views.design.hide(); |
95 | //Setting the iFrame property for reference in helper class | 95 | //Setting the iFrame property for reference in helper class |
96 | this.model.webGlHelper.iframe = this.model.views.design.iframe; | 96 | this.model.webGlHelper.iframe = this.model.views.design.iframe; |
97 | } else { | 97 | } else { |
98 | //ERROR: Design View not initialized | 98 | //ERROR: Design View not initialized |
99 | } | 99 | } |
100 | // | 100 | // |
101 | if (view === 'design') { | 101 | if (view === 'design') { |
102 | //TODO: Remove reference and use as part of model | 102 | //TODO: Remove reference and use as part of model |
103 | this.currentView = 'design'; | 103 | this.currentView = 'design'; |
104 | //Setting current view object to design | 104 | //Setting current view object to design |
105 | this.model.currentView = this.model.views.design; | 105 | this.model.currentView = this.model.views.design; |
106 | //Showing design iFrame | 106 | //Showing design iFrame |
107 | this.model.views.design.show(); | 107 | this.model.views.design.show(); |
108 | this.model.views.design.iframe.style.opacity = 0; | 108 | this.model.views.design.iframe.style.opacity = 0; |
109 | this.model.views.design.content = this.model.file.content; | 109 | this.model.views.design.content = this.model.file.content; |
110 | //TODO: Improve reference (probably through binding values) | 110 | //TODO: Improve reference (probably through binding values) |
111 | this.model.views.design._webGlHelper = this.model.webGlHelper; | 111 | this.model.views.design._webGlHelper = this.model.webGlHelper; |
112 | //Rendering design view, using observers to know when template is ready | 112 | //Rendering design view, using observers to know when template is ready |
113 | this.model.views.design.render(function () { | 113 | this.model.views.design.render(function () { |
114 | //Adding observer to know when template is ready | 114 | //Adding observer to know when template is ready |
115 | this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); | 115 | this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); |
116 | this._observer.observe(this.model.views.design.document.head, {childList: true}); | 116 | this._observer.observe(this.model.views.design.document.head, {childList: true}); |
117 | }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); | 117 | }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); |
118 | } else { | 118 | } else { |
119 | //TODO: Identify default view (probably code) | 119 | //TODO: Identify default view (probably code) |
120 | } | 120 | } |
121 | } | 121 | } |
122 | }, | 122 | }, |
123 | //////////////////////////////////////////////////////////////////// | 123 | //////////////////////////////////////////////////////////////////// |
124 | // | 124 | // |
125 | handleTemplateReady: { | 125 | handleTemplateReady: { |
126 | value: function (e) { | 126 | value: function (e) { |
127 | //Removing observer, only needed on initial load | 127 | //Removing observer, only needed on initial load |
128 | this._observer.disconnect(); | 128 | this._observer.disconnect(); |
129 | this._observer = null; | 129 | this._observer = null; |
130 | } | 130 | } |
131 | }, | 131 | }, |
132 | handleViewReady: { | 132 | handleViewReady: { |
133 | value: function(mObjects) { | 133 | value: function(mObjects) { |
@@ -143,17 +143,17 @@ exports.HtmlDocument = Montage.create(Component, { | |||
143 | } | 143 | } |
144 | }, | 144 | }, |
145 | //////////////////////////////////////////////////////////////////// | 145 | //////////////////////////////////////////////////////////////////// |
146 | // | 146 | // |
147 | closeDocument: { | 147 | closeDocument: { |
148 | value: function (context, callback) { | 148 | value: function (context, callback) { |
149 | //Closing document (sending null to close all views) | 149 | //Closing document (sending null to close all views) |
150 | this.model.close(null, function () {if (callback) callback.call(context, this);}.bind(this)); | 150 | this.model.close(null, function () {if (callback) callback.call(context, this);}.bind(this)); |
151 | } | 151 | } |
152 | }, | 152 | }, |
153 | //////////////////////////////////////////////////////////////////// | 153 | //////////////////////////////////////////////////////////////////// |
154 | // | 154 | // |
155 | serializeDocument: { | 155 | serializeDocument: { |
156 | value: function () { | 156 | value: function () { |
157 | // Serialize the current scroll position | 157 | // Serialize the current scroll position |
158 | //TODO: Move these properties to the design view class | 158 | //TODO: Move these properties to the design view class |
159 | this.model.scrollLeft = this.application.ninja.stage._scrollLeft; | 159 | this.model.scrollLeft = this.application.ninja.stage._scrollLeft; |
@@ -169,12 +169,12 @@ exports.HtmlDocument = Montage.create(Component, { | |||
169 | // Pause the videos | 169 | // Pause the videos |
170 | //TODO: Move these to be handled on the show/hide methods in the view | 170 | //TODO: Move these to be handled on the show/hide methods in the view |
171 | this.model.views.design.pauseVideos(); | 171 | this.model.views.design.pauseVideos(); |
172 | } | 172 | } |
173 | }, | 173 | }, |
174 | //////////////////////////////////////////////////////////////////// | 174 | //////////////////////////////////////////////////////////////////// |
175 | // | 175 | // |
176 | deserializeDocument: { | 176 | deserializeDocument: { |
177 | value: function () { | 177 | value: function () { |
178 | // Deserialize the current scroll position | 178 | // Deserialize the current scroll position |
179 | //TODO: Move these properties to the design view class | 179 | //TODO: Move these properties to the design view class |
180 | this.application.ninja.stage._scrollLeft = this.model.scrollLeft; | 180 | this.application.ninja.stage._scrollLeft = this.model.scrollLeft; |
@@ -184,7 +184,7 @@ exports.HtmlDocument = Montage.create(Component, { | |||
184 | 184 | ||
185 | // Serialize the undo | 185 | // Serialize the undo |
186 | // TODO: Save the montage undo queue | 186 | // TODO: Save the montage undo queue |
187 | } | 187 | } |
188 | } | 188 | } |
189 | //////////////////////////////////////////////////////////////////// | 189 | //////////////////////////////////////////////////////////////////// |
190 | //////////////////////////////////////////////////////////////////// | 190 | //////////////////////////////////////////////////////////////////// |