diff options
Diffstat (limited to 'js/document')
-rwxr-xr-x | js/document/document-html.js | 267 | ||||
-rwxr-xr-x | js/document/helpers/url-parser.js | 45 | ||||
-rwxr-xr-x | js/document/models/base.js | 77 | ||||
-rwxr-xr-x | js/document/models/html.js | 1 | ||||
-rwxr-xr-x | js/document/templates/montage-web/default_html.css | 28 | ||||
-rwxr-xr-x | js/document/templates/montage-web/index.html | 31 | ||||
-rw-r--r-- | js/document/templates/montage-web/main.js (renamed from js/document/templates/montage-web/main.reel/main.js) | 0 | ||||
-rwxr-xr-x | js/document/views/base.js | 46 | ||||
-rwxr-xr-x | js/document/views/design.js | 273 |
9 files changed, 566 insertions, 202 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js index 89717dd6..ec59c3e2 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -7,138 +7,151 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot | |||
7 | //////////////////////////////////////////////////////////////////////// | 7 | //////////////////////////////////////////////////////////////////////// |
8 | // | 8 | // |
9 | var Montage = require("montage/core/core").Montage, | 9 | var Montage = require("montage/core/core").Montage, |
10 | Component = require("montage/ui/component").Component; | 10 | Component = require("montage/ui/component").Component, |
11 | HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel; | 11 | HtmlDocumentModel = require("js/document/models/html").HtmlDocumentModel, |
12 | DesignDocumentView = require("js/document/views/design").DesignDocumentView; | ||
12 | //////////////////////////////////////////////////////////////////////// | 13 | //////////////////////////////////////////////////////////////////////// |
13 | // | 14 | // |
14 | exports.HtmlDocument = Montage.create(Component, { | 15 | exports.HtmlDocument = Montage.create(Component, { |
15 | //////////////////////////////////////////////////////////////////// | 16 | //////////////////////////////////////////////////////////////////// |
16 | // | 17 | // |
17 | hasTemplate: { | 18 | hasTemplate: { |
18 | enumerable: false, | ||
19 | value: false | 19 | value: false |
20 | }, | 20 | }, |
21 | 21 | //////////////////////////////////////////////////////////////////// | |
22 | // | ||
22 | model: { | 23 | model: { |
23 | value: null | 24 | value: null |
24 | }, | 25 | }, |
25 | 26 | //////////////////////////////////////////////////////////////////// | |
26 | loadDelegate: { | 27 | // |
27 | value: null | 28 | loaded: { |
29 | value: {callback: null, context: null} | ||
28 | }, | 30 | }, |
29 | 31 | //////////////////////////////////////////////////////////////////// | |
30 | delegateContext: { | 32 | // |
31 | value: null | 33 | _document: { |
34 | value: null //TODO: Figure out if this will be needed, probably not | ||
32 | }, | 35 | }, |
33 | 36 | //////////////////////////////////////////////////////////////////// | |
37 | // | ||
34 | exclusionList: { | 38 | exclusionList: { |
35 | value: ["HTML", "BODY"] | 39 | value: [] //TODO: Update to correct list |
36 | }, | ||
37 | |||
38 | // Getters for the model. | ||
39 | // TODO: Change how these properties are accessed through Ninja | ||
40 | name: { | ||
41 | get: function() { | ||
42 | return this.model._name; | ||
43 | }, | ||
44 | set: function(value) { | ||
45 | this.model._name = value; | ||
46 | } | ||
47 | }, | 40 | }, |
48 | 41 | //////////////////////////////////////////////////////////////////// | |
49 | isActive: { | 42 | // |
50 | get: function() { | ||
51 | return this.model._isActive; | ||
52 | }, | ||
53 | set: function(value) { | ||
54 | this.model._isActive = value; | ||
55 | } | ||
56 | }, | ||
57 | |||
58 | needsSave: { | ||
59 | get: function() { | ||
60 | return this.model._needsSave; | ||
61 | }, | ||
62 | set: function(value) { | ||
63 | this.model._needsSave = value; | ||
64 | } | ||
65 | }, | ||
66 | |||
67 | // View Properties | ||
68 | // TODO: Move those into a view object - for now dump it here | ||
69 | iframe: { | ||
70 | value: null | ||
71 | }, | ||
72 | |||
73 | uuid: { | 43 | uuid: { |
74 | get: function() { | 44 | get: function() { |
75 | return this._uuid; | 45 | return this._uuid; |
76 | } | 46 | } |
77 | }, | 47 | }, |
78 | 48 | //////////////////////////////////////////////////////////////////// | |
79 | currentView: { | 49 | // |
80 | value: "design" | 50 | inExclusion: { |
51 | value: function(element) { | ||
52 | if(this.exclusionList.indexOf(element.nodeName) === -1) { | ||
53 | return -1; | ||
54 | } | ||
55 | return 1; | ||
56 | } | ||
81 | }, | 57 | }, |
82 | //////////////////////////////////////////////////////////////////// | 58 | //////////////////////////////////////////////////////////////////// |
83 | //////////////////////////////////////////////////////////////////// | 59 | // |
84 | init: { | 60 | init: { |
85 | value:function(file, context, callback) { | 61 | value:function(file, context, callback, view) { |
86 | this.model = Montage.create(HtmlDocumentModel, { | 62 | //Storing callback data for loaded dispatch |
87 | file: { | 63 | this.loaded.callback = callback; |
88 | value: file | 64 | this.loaded.context = context; |
89 | } | 65 | //Creating instance of HTML Document Model |
66 | this.model = Montage.create(HtmlDocumentModel,{ | ||
67 | file: {value: file}, | ||
68 | views: {value: {'design': DesignDocumentView.create(), 'code': null}} //TODO: Add code view logic | ||
90 | }); | 69 | }); |
91 | 70 | //Initiliazing views and hiding | |
92 | this.name = file.name; | 71 | if (this.model.views.design.initiliaze(document.getElementById("iframeContainer"))) { |
93 | 72 | //Hiding iFrame, just initiliazing | |
94 | // this.init(file.name, file.uri, file.extension, iframe, uuid, callback); | 73 | this.model.views.design.hide(); |
95 | 74 | } else { | |
96 | 75 | //ERROR: Design View not initilized | |
97 | this.iframe = this.createView(); | 76 | } |
98 | |||
99 | //this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; | ||
100 | //this.currentView = "design"; | ||
101 | // | 77 | // |
102 | 78 | if (view === 'design') { | |
103 | this.delegateContext = context; | 79 | //Showing design iFrame |
104 | this.loadDelegate = callback; | 80 | this.model.views.design.show(); |
81 | this.model.views.design.iframe.style.opacity = 0; | ||
82 | this.model.views.design.content = this.model.file.content; | ||
83 | // | ||
84 | this.model.views.design.render(function () { | ||
85 | //TODO: Identify and remove usage of '_document' | ||
86 | this._document = this.model.views.design.document; | ||
87 | //TODO: Check for needed | ||
88 | this.documentRoot = this.model.views.design.document.body; | ||
89 | //TODO: Why is this needed? | ||
90 | this._liveNodeList = this.documentRoot.getElementsByTagName('*'); | ||
91 | //Initiliazing document model | ||
92 | document.application.njUtils.makeElementModel(this.documentRoot, "Body", "body"); | ||
93 | //Adding event to know when template is ready | ||
94 | this.model.views.design.document.head.addEventListener('DOMSubtreeModified', this.handleTemplateReady.bind(this), false); | ||
95 | }.bind(this)); | ||
96 | } else { | ||
97 | //TODO: Identify default view (probably code) | ||
98 | } | ||
105 | } | 99 | } |
106 | }, | 100 | }, |
107 | 101 | //////////////////////////////////////////////////////////////////// | |
108 | // Create View | 102 | // |
109 | // Move this into a base view object | 103 | handleTemplateReady: { |
110 | createView: { | 104 | value: function (e) { |
111 | value: function() { | 105 | //Removing event listener, a must for this type of event |
112 | var ifr = document.createElement("iframe"); | 106 | this.model.views.design.document.head.removeEventListener('DOMSubtreeModified', this.handleTemplateReady.bind(this), false); |
113 | ifr.id = "document_" + this._uuid; | 107 | //Making callback after view is loaded |
114 | 108 | this.loaded.callback.call(this.loaded.context, this); | |
115 | 109 | //Setting opacity to be viewable after load | |
116 | ifr.style.border = "none"; | 110 | this.model.views.design.iframe.style.opacity = 1; |
117 | ifr.style.background = "#FFF"; | 111 | } |
118 | ifr.style.height = "100%"; | ||
119 | ifr.style.width = "100%"; | ||
120 | |||
121 | // TODO: Reable opacity to display only when done loading | ||
122 | // ifr.style.opacity = 0; | ||
123 | |||
124 | ifr.src = "js/document/templates/montage-web/index.html"; | ||
125 | ifr.addEventListener("load", this.handleWebTemplateLoad.bind(this), true); | ||
126 | |||
127 | return document.getElementById("iframeContainer").appendChild(ifr); | ||
128 | } | ||
129 | }, | 112 | }, |
130 | 113 | //////////////////////////////////////////////////////////////////// | |
114 | //////////////////////////////////////////////////////////////////// | ||
115 | |||
116 | |||
117 | |||
118 | |||
119 | |||
120 | |||
121 | |||
122 | |||
123 | |||
124 | |||
125 | |||
126 | |||
127 | |||
128 | |||
129 | |||
130 | |||
131 | |||
132 | |||
133 | |||
134 | |||
135 | |||
136 | |||
137 | |||
138 | |||
139 | |||
140 |