diff options
author | Jose Antonio Marquez | 2012-05-01 10:12:40 -0700 |
---|---|---|
committer | Jose Antonio Marquez | 2012-05-01 10:12:40 -0700 |
commit | 7bdcab084d1991361ba8d37a7435efd229648630 (patch) | |
tree | 0670dadce6bf37cc8ad1672f0e4baf21dc4f5ed8 /js/document/document-html.js | |
parent | 7fdeb9feac4d2da9f86646cda4548ea60e5effa9 (diff) | |
download | ninja-7bdcab084d1991361ba8d37a7435efd229648630.tar.gz |
Setting up new architecture for I/O
Diffstat (limited to 'js/document/document-html.js')
-rwxr-xr-x | js/document/document-html.js | 102 |
1 files changed, 45 insertions, 57 deletions
diff --git a/js/document/document-html.js b/js/document/document-html.js index 89717dd6..28406ee8 100755 --- a/js/document/document-html.js +++ b/js/document/document-html.js | |||
@@ -18,25 +18,33 @@ exports.HtmlDocument = Montage.create(Component, { | |||
18 | enumerable: false, | 18 | enumerable: false, |
19 | value: false | 19 | value: false |
20 | }, | 20 | }, |
21 | 21 | //////////////////////////////////////////////////////////////////// | |
22 | // | ||
22 | model: { | 23 | model: { |
24 | enumerable: false, | ||
23 | value: null | 25 | value: null |
24 | }, | 26 | }, |
25 | 27 | //////////////////////////////////////////////////////////////////// | |
28 | // | ||
26 | loadDelegate: { | 29 | loadDelegate: { |
30 | enumerable: false, | ||
27 | value: null | 31 | value: null |
28 | }, | 32 | }, |
29 | 33 | //////////////////////////////////////////////////////////////////// | |
34 | // | ||
30 | delegateContext: { | 35 | delegateContext: { |
36 | enumerable: false, | ||
31 | value: null | 37 | value: null |
32 | }, | 38 | }, |
33 | 39 | //////////////////////////////////////////////////////////////////// | |
40 | // | ||
34 | exclusionList: { | 41 | exclusionList: { |
42 | enumerable: false, | ||
35 | value: ["HTML", "BODY"] | 43 | value: ["HTML", "BODY"] |
36 | }, | 44 | }, |
37 | 45 | //////////////////////////////////////////////////////////////////// | |
38 | // Getters for the model. | 46 | //////////////////////////////////////////////////////////////////// |
39 | // TODO: Change how these properties are accessed through Ninja | 47 | //TODO: Remove these setters/getters, should call model directly |
40 | name: { | 48 | name: { |
41 | get: function() { | 49 | get: function() { |
42 | return this.model._name; | 50 | return this.model._name; |
@@ -45,7 +53,7 @@ exports.HtmlDocument = Montage.create(Component, { | |||
45 | this.model._name = value; | 53 | this.model._name = value; |
46 | } | 54 | } |
47 | }, | 55 | }, |
48 | 56 | // | |
49 | isActive: { | 57 | isActive: { |
50 | get: function() { | 58 | get: function() { |
51 | return this.model._isActive; | 59 | return this.model._isActive; |
@@ -54,7 +62,7 @@ exports.HtmlDocument = Montage.create(Component, { | |||
54 | this.model._isActive = value; | 62 | this.model._isActive = value; |
55 | } | 63 | } |
56 | }, | 64 | }, |
57 | 65 | // | |
58 | needsSave: { | 66 | needsSave: { |
59 | get: function() { | 67 | get: function() { |
60 | return this.model._needsSave; | 68 | return this.model._needsSave; |
@@ -63,82 +71,62 @@ exports.HtmlDocument = Montage.create(Component, { | |||
63 | this.model._needsSave = value; | 71 | this.model._needsSave = value; |
64 | } | 72 | } |
65 | }, | 73 | }, |
66 | 74 | // | |
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: { | 75 | uuid: { |
74 | get: function() { | 76 | get: function() { |
75 | return this._uuid; | 77 | return this._uuid; |
76 | } | 78 | } |
77 | }, | 79 | }, |
78 | 80 | // | |
79 | currentView: { | 81 | currentView: { |
80 | value: "design" | 82 | value: "design" |
81 | }, | 83 | }, |
82 | //////////////////////////////////////////////////////////////////// | 84 | //////////////////////////////////////////////////////////////////// |
83 | //////////////////////////////////////////////////////////////////// | 85 | //////////////////////////////////////////////////////////////////// |
84 | init: { | 86 | // |
85 | value:function(file, context, callback) { | 87 | iframe: { //MOVE TO: base.js in views |
86 | this.model = Montage.create(HtmlDocumentModel, { | 88 | value: null |
87 | file: { | ||
88 | value: file | ||
89 | } | ||
90 | }); | ||
91 | |||
92 | this.name = file.name; | ||
93 | |||
94 | // this.init(file.name, file.uri, file.extension, iframe, uuid, callback); | ||
95 | |||
96 | |||
97 | this.iframe = this.createView(); | ||
98 | |||
99 | //this.selectionExclude = ["HTML", "BODY", "Viewport", "UserContent", "stageBG"]; | ||
100 | //this.currentView = "design"; | ||
101 | // | ||
102 | |||
103 | this.delegateContext = context; | ||
104 | this.loadDelegate = callback; | ||
105 | } | ||
106 | }, | 89 | }, |
107 | 90 | // | |
108 | // Create View | 91 | createView: { //MOVE TO: design.js in views |
109 | // Move this into a base view object | ||
110 | createView: { | ||
111 | value: function() { | 92 | value: function() { |
112 | var ifr = document.createElement("iframe"); | 93 | var ifr = document.createElement("iframe"); |
94 | // | ||
113 | ifr.id = "document_" + this._uuid; | 95 | ifr.id = "document_" + this._uuid; |
114 | |||
115 | |||
116 | ifr.style.border = "none"; | 96 | ifr.style.border = "none"; |
117 | ifr.style.background = "#FFF"; | 97 | ifr.style.background = "#FFF"; |
118 | ifr.style.height = "100%"; | 98 | ifr.style.height = "100%"; |
119 | ifr.style.width = "100%"; | 99 | ifr.style.width = "100%"; |
120 | 100 | // | |
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"; | 101 | ifr.src = "js/document/templates/montage-web/index.html"; |
125 | ifr.addEventListener("load", this.handleWebTemplateLoad.bind(this), true); | 102 | ifr.addEventListener("load", this.handleWebTemplateLoad.bind(this), true); |
126 | 103 | // | |
127 | return document.getElementById("iframeContainer").appendChild(ifr); | 104 | return document.getElementById("iframeContainer").appendChild(ifr); |
128 | } | 105 | } |
129 | }, | 106 | }, |
130 | 107 | //////////////////////////////////////////////////////////////////// | |
108 | //////////////////////////////////////////////////////////////////// | ||
109 | // | ||
110 | init: { | ||
111 | value:function(file, context, callback) { | ||
112 | this.model = Montage.create(HtmlDocumentModel, { | ||
113 | file: { | ||
114 | value: file | ||
115 | } | ||
116 | }); | ||
117 | this.name = file.name; | ||
118 | this.iframe = this.createView(); | ||
119 | this.delegateContext = context; | ||
120 | this.loadDelegate = callback; | ||
121 | } | ||
122 | }, | ||
123 | //////////////////////////////////////////////////////////////////// | ||
124 | // | ||
131 | handleWebTemplateLoad: { | 125 | handleWebTemplateLoad: { |
132 | value: function(event) { | 126 | value: function(event) { |
133 | //TODO: Remove, also for prototyping | 127 | //TODO: Remove, also for prototyping |
134 | this.application.ninja.documentController._hackRootFlag = true; | 128 | this.application.ninja.documentController._hackRootFlag = true; |
135 | 129 | ||
136 | |||
137 | //TODO: Clean up, using for prototyping save | ||
138 | // this._templateDocument = {}; | ||
139 | // this._templateDocument.html = this.iframe.contentWindow.document; | ||
140 | // this._templateDocument.body = | ||
141 | |||
142 | this._window = this.iframe.contentWindow; | 130 | this._window = this.iframe.contentWindow; |
143 | this._document = this.iframe.contentWindow.document; | 131 | this._document = this.iframe.contentWindow.document; |
144 | this.documentRoot = this.iframe.contentWindow.document.body; | 132 | this.documentRoot = this.iframe.contentWindow.document.body; |