diff options
author | Ananya Sen | 2012-07-09 16:52:49 -0700 |
---|---|---|
committer | Ananya Sen | 2012-07-09 16:52:49 -0700 |
commit | 2eb84584f44b8c774479d1af2ee1d810597474cf (patch) | |
tree | 64cb3e09a8daeb340261dd7f3869c73f7b90b643 /js/document/document-html.js | |
parent | bf9dba001ec84243e2f12cd13b0c0ae020fba4a2 (diff) | |
parent | cee0deca695359ab468bd06d0e05ed3b2010b338 (diff) | |
download | ninja-2eb84584f44b8c774479d1af2ee1d810597474cf.tar.gz |
Merge branch 'refs/heads/ninja-internal-master' into codemirror-custom-theme-removal
Conflicts:
js/code-editor/codemirror-ninja/theme/lesser-dark-ninja.css
js/code-editor/codemirror-ninja/theme/xq-dark-ninja.css
Signed-off-by: Ananya Sen <Ananya.Sen@motorola.com>
Diffstat (limited to 'js/document/document-html.js')
-rwxr-xr-x | js/document/document-html.js | 159 |
1 files changed, 80 insertions, 79 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js index 566e5078..142ffe4a 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -1,24 +1,25 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | ||
5 | 4 | ||
6 | Redistribution and use in source and binary forms, with or without | 5 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 6 | modification, are permitted provided that the following conditions are met: |
8 | 7 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 8 | * Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 9 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 10 | |
12 | notice, this list of conditions and the following disclaimer in the | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
13 | documentation and/or other materials provided with the distribution. | 12 | this list of conditions and the following disclaimer in the documentation |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 13 | and/or other materials provided with the distribution. |
15 | may be used to endorse or promote products derived from this software | 14 | |
16 | without specific prior written permission. | 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. | ||
17 | 18 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
@@ -30,40 +31,40 @@ POSSIBILITY OF SUCH DAMAGE. | |||
30 | 31 | ||
31 | //////////////////////////////////////////////////////////////////////// | 32 | //////////////////////////////////////////////////////////////////////// |
32 | // | 33 | // |
33 | var Montage = require("montage/core/core").Montage, | 34 | var Montage = require("montage/core/core").Montage, |
34 | Component = require("montage/ui/component").Component, | 35 | Component = require("montage/ui/component").Component, |
35 | HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel, | 36 | HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel, |
36 | DesignDocumentView = require("js/document/views/design").DesignDocumentView; | 37 | DesignDocumentView = require("js/document/views/design").DesignDocumentView; |
37 | //////////////////////////////////////////////////////////////////////// | 38 | //////////////////////////////////////////////////////////////////////// |
38 | // | 39 | // |
39 | exports.HtmlDocument = Montage.create(Component, { | 40 | exports.HtmlDocument = Montage.create(Component, { |
40 | //////////////////////////////////////////////////////////////////// | 41 | //////////////////////////////////////////////////////////////////// |
41 | // | 42 | // |
42 | hasTemplate: { | 43 | hasTemplate: { |
43 | value: false | 44 | value: false |
44 | }, | 45 | }, |
45 | //////////////////////////////////////////////////////////////////// | 46 | //////////////////////////////////////////////////////////////////// |
46 | // | 47 | // |
47 | model: { | 48 | model: { |
48 | value: null | 49 | value: null |
49 | }, | 50 | }, |
50 | //////////////////////////////////////////////////////////////////// | 51 | //////////////////////////////////////////////////////////////////// |
51 | // | 52 | // |
52 | loaded: { | 53 | loaded: { |
53 | value: {callback: null, context: null} | 54 | value: {callback: null, context: null} |
54 | }, | 55 | }, |
55 | //////////////////////////////////////////////////////////////////// | 56 | //////////////////////////////////////////////////////////////////// |
56 | // | 57 | // |
57 | _observer: { | 58 | _observer: { |
58 | value: null | 59 | value: null |
59 | }, | 60 | }, |
60 | //////////////////////////////////////////////////////////////////// | 61 | //////////////////////////////////////////////////////////////////// |
61 | // | 62 | // |
62 | exclusionList: { | 63 | exclusionList: { |
63 | value: ["HTML", "BODY", "NINJA-CONTENT", "NINJA-VIEWPORT"] | 64 | value: ["HTML", "BODY", "NINJA-CONTENT", "NINJA-VIEWPORT"] |
64 | }, | 65 | }, |
65 | //////////////////////////////////////////////////////////////////// | 66 | //////////////////////////////////////////////////////////////////// |
66 | // | 67 | // |
67 | inExclusion: { | 68 | inExclusion: { |
68 | value: function(element) { | 69 | value: function(element) { |
69 | if(this.exclusionList.indexOf(element.nodeName) === -1) { | 70 | if(this.exclusionList.indexOf(element.nodeName) === -1) { |
@@ -72,62 +73,62 @@ exports.HtmlDocument = Montage.create(Component, { | |||
72 | return 1; | 73 | return 1; |
73 | } | 74 | } |
74 | }, | 75 | }, |
75 | //////////////////////////////////////////////////////////////////// | 76 | //////////////////////////////////////////////////////////////////// |
76 | // | 77 | // |
77 | init: { | 78 | init: { |
78 | value:function(file, context, callback, view, template) { | 79 | value:function(file, context, callback, view, template) { |
79 | //Storing callback data for loaded dispatch | 80 | //Storing callback data for loaded dispatch |
80 | this.loaded.callback = callback; | 81 | this.loaded.callback = callback; |
81 | this.loaded.context = context; | 82 | this.loaded.context = context; |
82 | //Creating instance of HTML Document Model | 83 | //Creating instance of HTML Document Model |
83 | this.model = Montage.create(HtmlDocumentModel,{ | 84 | this.model = Montage.create(HtmlDocumentModel,{ |
84 | file: {value: file}, | 85 | file: {value: file}, |
85 | fileTemplate: {value: template}, | 86 | fileTemplate: {value: template}, |
86 | parentContainer: {value: document.getElementById("iframeContainer")}, //Saving reference to parent container of all views (should be changed to buckets approach | 87 | 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 | 88 | views: {value: {'design': DesignDocumentView.create(), 'code': null}} //TODO: Add code view logic |
88 | }); | 89 | }); |
89 | //Calling the any init routines in the model | 90 | //Calling the any init routines in the model |
90 | this.model.init(); | 91 | this.model.init(); |
91 | //Initiliazing views and hiding | 92 | //Initiliazing views and hiding |
92 | if (this.model.views.design.initialize(this.model.parentContainer)) { | 93 | if (this.model.views.design.initialize(this.model.parentContainer)) { |
93 | //Hiding iFrame, just initiliazing | 94 | //Hiding iFrame, just initiliazing |
94 | this.model.views.design.hide(); | 95 | this.model.views.design.hide(); |
95 | //Setting the iFrame property for reference in helper class | 96 | //Setting the iFrame property for reference in helper class |
96 | this.model.webGlHelper.iframe = this.model.views.design.iframe; | 97 | this.model.webGlHelper.iframe = this.model.views.design.iframe; |
97 | } else { | 98 | } else { |
98 | //ERROR: Design View not initialized | 99 | //ERROR: Design View not initialized |
99 | } | 100 | } |
100 | // | 101 | // |
101 | if (view === 'design') { | 102 | if (view === 'design') { |
102 | //TODO: Remove reference and use as part of model | 103 | //TODO: Remove reference and use as part of model |
103 | this.currentView = 'design'; | 104 | this.currentView = 'design'; |
104 | //Setting current view object to design | 105 | //Setting current view object to design |
105 | this.model.currentView = this.model.views.design; | 106 | this.model.currentView = this.model.views.design; |
106 | //Showing design iFrame | 107 | //Showing design iFrame |
107 | this.model.views.design.show(); | 108 | this.model.views.design.show(); |
108 | this.model.views.design.iframe.style.opacity = 0; | 109 | this.model.views.design.iframe.style.opacity = 0; |
109 | this.model.views.design.content = this.model.file.content; | 110 | this.model.views.design.content = this.model.file.content; |
110 | //TODO: Improve reference (probably through binding values) | 111 | //TODO: Improve reference (probably through binding values) |
111 | this.model.views.design._webGlHelper = this.model.webGlHelper; | 112 | this.model.views.design._webGlHelper = this.model.webGlHelper; |
112 | //Rendering design view, using observers to know when template is ready | 113 | //Rendering design view, using observers to know when template is ready |
113 | this.model.views.design.render(function () { | 114 | this.model.views.design.render(function () { |
114 | //Adding observer to know when template is ready | 115 | //Adding observer to know when template is ready |
115 | this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); | 116 | this._observer = new WebKitMutationObserver(this.handleTemplateReady.bind(this)); |
116 | this._observer.observe(this.model.views.design.document.head, {childList: true}); | 117 | this._observer.observe(this.model.views.design.document.head, {childList: true}); |
117 | }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); | 118 | }.bind(this), template, {viewCallback: this.handleViewReady, context: this}); |
118 | } else { | 119 | } else { |
119 | //TODO: Identify default view (probably code) | 120 | //TODO: Identify default view (probably code) |
120 | } | 121 | } |
121 | } | 122 | } |
122 | }, | 123 | }, |
123 | //////////////////////////////////////////////////////////////////// | 124 | //////////////////////////////////////////////////////////////////// |
124 | // | 125 | // |
125 | handleTemplateReady: { | 126 | handleTemplateReady: { |
126 | value: function (e) { | 127 | value: function (e) { |
127 | //Removing observer, only needed on initial load | 128 | //Removing observer, only needed on initial load |
128 | this._observer.disconnect(); | 129 | this._observer.disconnect(); |
129 | this._observer = null; | 130 | this._observer = null; |
130 | } | 131 | } |
131 | }, | 132 | }, |
132 | handleViewReady: { | 133 | handleViewReady: { |
133 | value: function(mObjects) { | 134 | value: function(mObjects) { |
@@ -143,17 +144,17 @@ exports.HtmlDocument = Montage.create(Component, { | |||
143 | } | 144 | } |
144 | }, | 145 | }, |
145 | //////////////////////////////////////////////////////////////////// | 146 | //////////////////////////////////////////////////////////////////// |
146 | // | 147 | // |
147 | closeDocument: { | 148 | closeDocument: { |
148 | value: function (context, callback) { | 149 | value: function (context, callback) { |
149 | //Closing document (sending null to close all views) | 150 | //Closing document (sending null to close all views) |
150 | this.model.close(null, function () {if (callback) callback.call(context, this);}.bind(this)); | 151 | this.model.close(null, function () {if (callback) callback.call(context, this);}.bind(this)); |
151 | } | 152 | } |
152 | }, | 153 | }, |
153 | //////////////////////////////////////////////////////////////////// | 154 | //////////////////////////////////////////// |