diff options
Diffstat (limited to 'js/document/views')
-rwxr-xr-x | js/document/views/base.js | 46 | ||||
-rwxr-xr-x | js/document/views/design.js | 103 |
2 files changed, 142 insertions, 7 deletions
diff --git a/js/document/views/base.js b/js/document/views/base.js index 50c0a78d..d1c65b5e 100755 --- a/js/document/views/base.js +++ b/js/document/views/base.js | |||
@@ -7,15 +7,57 @@ 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 | UrlParser = require("js/document/helpers/url-parser").UrlParser; | ||
11 | //////////////////////////////////////////////////////////////////////// | 12 | //////////////////////////////////////////////////////////////////////// |
12 | // | 13 | // |
13 | exports.BaseDocumentView = Montage.create(Component, { | 14 | exports.BaseDocumentView = Montage.create(Component, { |
14 | //////////////////////////////////////////////////////////////////// | 15 | //////////////////////////////////////////////////////////////////// |
15 | // | 16 | // |
16 | hasTemplate: { | 17 | hasTemplate: { |
17 | enumerable: false, | ||
18 | value: false | 18 | value: false |
19 | }, | ||
20 | //////////////////////////////////////////////////////////////////// | ||
21 | // | ||
22 | urlParser: { | ||
23 | value: UrlParser | ||
24 | }, | ||
25 | //////////////////////////////////////////////////////////////////// | ||
26 | // | ||
27 | _iframe: { | ||
28 | value: null | ||
29 | }, | ||
30 | //////////////////////////////////////////////////////////////////// | ||
31 | // | ||
32 | iframe: { | ||
33 | get: function() {return this._iframe;}, | ||
34 | set: function(value) {this._iframe= value;} | ||
35 | }, | ||
36 | //////////////////////////////////////////////////////////////////// | ||
37 | // | ||
38 | show: { | ||
39 | value: function (callback) { | ||
40 | if (this.iframe) { | ||
41 | this.iframe.style.display = 'block'; | ||
42 | } else { | ||
43 | console.log('Error: View has no iframe to show!'); | ||
44 | } | ||
45 | // | ||
46 | if (callback) callback(); | ||
47 | } | ||
48 | }, | ||
49 | //////////////////////////////////////////////////////////////////// | ||
50 | // | ||
51 | hide: { | ||
52 | value: function (callback) { | ||
53 | if (this.iframe) { | ||
54 | this.iframe.style.display = 'none'; | ||
55 | } else { | ||
56 | console.log('Error: View has no iframe to hide!'); | ||
57 | } | ||
58 | // | ||
59 | if (callback) callback(); | ||
60 | } | ||
19 | } | 61 | } |
20 | //////////////////////////////////////////////////////////////////// | 62 | //////////////////////////////////////////////////////////////////// |
21 | //////////////////////////////////////////////////////////////////// | 63 | //////////////////////////////////////////////////////////////////// |
diff --git a/js/document/views/design.js b/js/document/views/design.js index 84871257..10963cab 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js | |||
@@ -7,17 +7,110 @@ 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 | BaseDocumentView = require("js/document/views/base").BaseDocumentView; |
11 | CodeDocumentView = require("js/document/views/code").CodeDocumentView; | ||
12 | //////////////////////////////////////////////////////////////////////// | 11 | //////////////////////////////////////////////////////////////////////// |
13 | // | 12 | // |
14 | exports.DesignDocumentView = Montage.create(CodeDocumentView, { | 13 | exports.DesignDocumentView = Montage.create(BaseDocumentView, { |
15 | //////////////////////////////////////////////////////////////////// | 14 | //////////////////////////////////////////////////////////////////// |
16 | // | 15 | // |
17 | hasTemplate: { | 16 | hasTemplate: { |
18 | enumerable: false, | ||
19 | value: false | 17 | value: false |
20 | } | 18 | }, |
19 | //////////////////////////////////////////////////////////////////// | ||
20 | // | ||
21 | _callback: { | ||
22 | value: null | ||
23 | }, | ||
24 | //////////////////////////////////////////////////////////////////// | ||
25 | // | ||
26 | _document: { | ||
27 | value: null | ||
28 | }, | ||
29 | //////////////////////////////////////////////////////////////////// | ||
30 | // | ||
31 | content: { | ||
32 | value: null | ||
33 | }, | ||
34 | //////////////////////////////////////////////////////////////////// | ||
35 | // | ||
36 | document: { | ||
37 | get: function() {return this._document;}, | ||
38 | set: function(value) {this._document = value;} | ||
39 | }, | ||
40 | //////////////////////////////////////////////////////////////////// | ||
41 | // | ||
42 | initiliaze: { | ||
43 | value: function (parent) { | ||
44 | // | ||
45 | this.iframe = document.createElement("iframe"); | ||
46 | // | ||
47 | this.iframe.style.border = "none"; | ||
48 | this.iframe.style.background = "#FFF"; | ||
49 | this.iframe.style.height = "100%"; | ||
50 | this.iframe.style.width = "100%"; | ||
51 | // | ||
52 | return parent.appendChild(this.iframe); | ||
53 | } | ||
54 | }, | ||
55 | //////////////////////////////////////////////////////////////////// | ||
56 | // | ||
57 | render: { | ||
58 | value: function (callback) { | ||
59 | // | ||
60 | this._callback = callback; | ||
61 | this.iframe.addEventListener("load", this.onTemplateLoad.bind(this), true); | ||
62 | this.iframe.src = "js/document/templates/montage-web/index.html"; | ||
63 | } | ||
64 | }, | ||
65 | //////////////////////////////////////////////////////////////////// | ||
66 | // | ||
67 | onTemplateLoad: { | ||
68 | value: function (e) { | ||
69 | // | ||
70 | this.document = this.iframe.contentWindow.document; | ||
71 | // | ||
72 | |||
73 | |||
74 | |||
75 | |||
76 | //this.document.head.innerHTML += this.content.head; | ||
77 | this.document.body.innerHTML = this.content.head + this.content.body; | ||
78 | |||
79 | |||
80 | |||
81 | |||
82 | // | ||
83 | if (this._callback) this._callback(); | ||
84 | } | ||
85 | }, | ||
86 | //////////////////////////////////////////////////////////////////// | ||
87 | // | ||
88 | initCss: { | ||
89 | value: function () { | ||
90 | // | ||
91 | } | ||
92 | }, | ||
93 | //////////////////////////////////////////////////////////////////// | ||
94 | // | ||
95 | initWebGl: { | ||
96 | value: function () { | ||
97 | // | ||
98 | } | ||
99 | }, | ||
100 | //////////////////////////////////////////////////////////////////// | ||
101 | // | ||
102 | initMontage: { | ||
103 | value: function () { | ||
104 | // | ||
105 | } | ||
106 | }, | ||
107 | //////////////////////////////////////////////////////////////////// | ||
108 | // | ||
109 | getElementFromPoint: { | ||
110 | value: function(x, y) { | ||
111 | return this.iframe.contentWindow.getElement(x,y); | ||
112 | } | ||
113 | }, | ||
21 | //////////////////////////////////////////////////////////////////// | 114 | //////////////////////////////////////////////////////////////////// |
22 | //////////////////////////////////////////////////////////////////// | 115 | //////////////////////////////////////////////////////////////////// |
23 | }); | 116 | }); |