diff options
author | Valerio Virgillito | 2012-07-09 14:35:44 -0700 |
---|---|---|
committer | Valerio Virgillito | 2012-07-09 14:35:44 -0700 |
commit | 84b3327bd92faafab7954b5eb64c7abe24a3fe13 (patch) | |
tree | 3f56cbed2f08c5a81ea79eaf0bcb9bd031d8a627 /js/document/mediators | |
parent | c0a42c56f768a873ba637f5b86d5f6a84d4a3312 (diff) | |
parent | 40c6eb2c06b34f65a74d59ef9687251952858bab (diff) | |
download | ninja-84b3327bd92faafab7954b5eb64c7abe24a3fe13.tar.gz |
Merge branch 'normalize' of https://github.com/kriskowal/ninja-internal
Conflicts:
js/components/gradientpicker.reel/gradientpicker.js
js/components/tools-properties/text-properties.reel/text-properties.js
js/document/views/base.js
js/document/views/design.js
js/helper-classes/3D/StageLine.js
js/helper-classes/3D/draw-utils.js
js/lib/drawing/world.js
js/lib/geom/circle.js
js/lib/geom/line.js
js/lib/geom/rectangle.js
js/lib/geom/shape-primitive.js
js/lib/rdge/materials/bump-metal-material.js
js/lib/rdge/materials/flag-material.js
js/lib/rdge/materials/fly-material.js
js/lib/rdge/materials/julia-material.js
js/lib/rdge/materials/keleidoscope-material.js
js/lib/rdge/materials/mandel-material.js
js/lib/rdge/materials/material.js
js/lib/rdge/materials/plasma-material.js
js/lib/rdge/materials/pulse-material.js
js/lib/rdge/materials/radial-gradient-material.js
js/lib/rdge/materials/taper-material.js
js/lib/rdge/materials/twist-vert-material.js
js/lib/rdge/materials/water-material.js
js/panels/Materials/materials-library-panel.reel/materials-library-panel.html
js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
js/panels/Materials/materials-popup.reel/materials-popup.html
js/panels/Materials/materials-popup.reel/materials-popup.js
js/tools/LineTool.js
Signed-off-by: Valerio Virgillito <valerio@motorola.com>
Diffstat (limited to 'js/document/mediators')
-rwxr-xr-x | js/document/mediators/io.js | 18 | ||||
-rwxr-xr-x | js/document/mediators/template.js | 620 |
2 files changed, 319 insertions, 319 deletions
diff --git a/js/document/mediators/io.js b/js/document/mediators/io.js index 85d805ad..9f56a9ea 100755 --- a/js/document/mediators/io.js +++ b/js/document/mediators/io.js | |||
@@ -30,19 +30,19 @@ 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 | //////////////////////////////////////////////////////////////////////// | 35 | //////////////////////////////////////////////////////////////////////// |
36 | // | 36 | // |
37 | exports.IoDocumentMediator = Montage.create(Component, { | 37 | exports.IoDocumentMediator = Montage.create(Component, { |
38 | //////////////////////////////////////////////////////////////////// | 38 | //////////////////////////////////////////////////////////////////// |
39 | // | 39 | // |
40 | hasTemplate: { | 40 | hasTemplate: { |
41 | enumerable: false, | 41 | enumerable: false, |
42 | value: false | 42 | value: false |
43 | } | 43 | } |
44 | //////////////////////////////////////////////////////////////////// | 44 | //////////////////////////////////////////////////////////////////// |
45 | //////////////////////////////////////////////////////////////////// | 45 | //////////////////////////////////////////////////////////////////// |
46 | }); | 46 | }); |
47 | //////////////////////////////////////////////////////////////////////// | 47 | //////////////////////////////////////////////////////////////////////// |
48 | //////////////////////////////////////////////////////////////////////// | 48 | //////////////////////////////////////////////////////////////////////// |
diff --git a/js/document/mediators/template.js b/js/document/mediators/template.js index 982b410f..7451ffa2 100755 --- a/js/document/mediators/template.js +++ b/js/document/mediators/template.js | |||
@@ -30,16 +30,16 @@ 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 | TemplateCreator = require("node_modules/tools/template/template-creator").TemplateCreator, | 35 | TemplateCreator = require("node_modules/tools/template/template-creator").TemplateCreator, |
36 | ClassUuid = require("js/components/core/class-uuid").ClassUuid; | 36 | ClassUuid = require("js/components/core/class-uuid").ClassUuid; |
37 | //////////////////////////////////////////////////////////////////////// | 37 | //////////////////////////////////////////////////////////////////////// |
38 | // | 38 | // |
39 | exports.TemplateDocumentMediator = Montage.create(Component, { | 39 | exports.TemplateDocumentMediator = Montage.create(Component, { |
40 | //////////////////////////////////////////////////////////////////// | 40 | //////////////////////////////////////////////////////////////////// |
41 | // | 41 | // |
42 | hasTemplate: { | 42 | hasTemplate: { |
43 | value: false | 43 | value: false |
44 | }, | 44 | }, |
45 | //////////////////////////////////////////////////////////////////// | 45 | //////////////////////////////////////////////////////////////////// |
@@ -53,55 +53,55 @@ exports.TemplateDocumentMediator = Montage.create(Component, { | |||
53 | //////////////////////////////////////////////////////////////////// | 53 | //////////////////////////////////////////////////////////////////// |
54 | // | 54 | // |
55 | getDataDirectory: { | 55 | getDataDirectory: { |
56 | value: function (path) { | 56 | value: function (path) { |
57 | //TODO: Implement user overwrite | 57 | //TODO: Implement user overwrite |
58 | return this._getUserDirectory(path+'data/'); | 58 | return this._getUserDirectory(path+'data/'); |
59 | } | 59 | } |
60 | }, | 60 | }, |
61 | //////////////////////////////////////////////////////////////////// | 61 | //////////////////////////////////////////////////////////////////// |
62 | // | 62 | // |
63 | getNinjaDirectory: { | 63 | getNinjaDirectory: { |
64 | value: function (path) { | 64 | value: function (path) { |
65 | //TODO: Implement user overwrite | 65 | //TODO: Implement user overwrite |
66 | return this._getUserDirectory(this.getDataDirectory(path)+'ninja/'); | 66 | return this._getUserDirectory(this.getDataDirectory(path)+'ninja/'); |
67 | } | 67 | } |
68 | }, | 68 | }, |
69 | //////////////////////////////////////////////////////////////////// | 69 | //////////////////////////////////////////////////////////////////// |
70 | // | 70 | // |
71 | getCanvasDirectory: { | 71 | getCanvasDirectory: { |
72 | value: function (path) { | 72 | value: function (path) { |
73 | //TODO: Implement user overwrite | 73 | //TODO: Implement user overwrite |
74 | return this._getUserDirectory(this.getNinjaDirectory(path)+'canvas/'); | 74 | return this._getUserDirectory(this.getNinjaDirectory(path)+'canvas/'); |
75 | } | 75 | } |
76 | }, | 76 | }, |
77 | //////////////////////////////////////////////////////////////////// | 77 | //////////////////////////////////////////////////////////////////// |
78 | // | 78 | // |
79 | _getUserDirectory: { | 79 | _getUserDirectory: { |
80 | value: function (path) { | 80 | value: function (path) { |
81 | //Checking for data directory | 81 | //Checking for data directory |
82 | var check = this.application.ninja.coreIoApi.fileExists({uri: path}), directory; | 82 | var check = this.application.ninja.coreIoApi.fileExists({uri: path}), directory; |
83 | //Creating directory if doesn't exists | 83 | //Creating directory if doesn't exists |
84 | switch (check.status) { | 84 | switch (check.status) { |
85 | case 204: //Exists | 85 | case 204: //Exists |
86 | directory = path; | 86 | directory = path; |
87 | break; | 87 | break; |
88 | case 404: //Doesn't exists | 88 | case 404: //Doesn't exists |
89 | directory = this.application.ninja.coreIoApi.createDirectory({uri: path}); | 89 | directory = this.application.ninja.coreIoApi.createDirectory({uri: path}); |
90 | //Checking for success | 90 | //Checking for success |
91 | if (directory.status === 201) { | 91 | if (directory.status === 201) { |
92 | directory = path; | 92 | directory = path; |
93 | } else { | 93 | } else { |
94 | //Error | 94 | //Error |
95 | directory = null; | 95 | directory = null; |
96 | } | 96 | } |
97 | break; | 97 | break; |
98 | default: //Error | 98 | default: //Error |
99 | directory = null; | 99 | directory = null; |
100 | break; | 100 | break; |
101 | } | 101 | } |
102 | //Returning the path to the directory on disk (null for any error) | 102 | //Returning the path to the directory on disk (null for any error) |
103 | return directory; | 103 | return directory; |
104 | } | 104 | } |
105 | }, | 105 | }, |
106 | //////////////////////////////////////////////////////////////////// | 106 | //////////////////////////////////////////////////////////////////// |
107 | // | 107 | // |
@@ -109,7 +109,7 @@ exports.TemplateDocumentMediator = Montage.create(Component, { | |||
109 | value: function (html) { | 109 | value: function (html) { |
110 | //Creating temp object to mimic HTML | 110 | //Creating temp object to mimic HTML |
111 | var doc = window.document.implementation.createHTMLDocument(), template, docHtmlTag, | 111 | var doc = window.document.implementation.createHTMLDocument(), template, docHtmlTag, |
112 | hackHtml = document.createElement('html'), hackTag; | 112 | hackHtml = document.createElement('html'), hackTag; |
113 | //Setting content to temp | 113 | //Setting content to temp |
114 | doc.getElementsByTagName('html')[0].innerHTML = html; | 114 | doc.getElementsByTagName('html')[0].innerHTML = html; |
115 | //TODO: Improve this, very bad way of copying attributes (in a pinch to get it working) | 115 | //TODO: Improve this, very bad way of copying attributes (in a pinch to get it working) |
@@ -118,13 +118,13 @@ exports.TemplateDocumentMediator = Montage.create(Component, { | |||
118 | docHtmlTag = doc.getElementsByTagName('html')[0]; | 118 | docHtmlTag = doc.getElementsByTagName('html')[0]; |
119 | //Looping through the attributes to copy them | 119 | //Looping through the attributes to copy them |
120 | if (hackTag) { | 120 | if (hackTag) { |
121 | for (var m in hackTag.attributes) { | 121 | for (var m in hackTag.attributes) { |
122 | if (hackTag.attributes[m].value) { | 122 | if (hackTag.attributes[m].value) { |
123 | docHtmlTag.setAttribute(hackTag.attributes[m].name.replace(/ninjahtmlhack/gi, 'html'), hackTag.attributes[m].value.replace(/ninjahtmlhack/gi, 'html')); | 123 | docHtmlTag.setAttribute(hackTag.attributes[m].name.replace(/ninjahtmlhack/gi, 'html'), hackTag.attributes[m].value.replace(/ninjahtmlhack/gi, 'html')); |
124 | } | 124 | } |
125 | } | 125 | } |
126 | } | 126 | } |
127 | //Garbage collection | 127 | //Garbage collection |
128 | hackHtml = hackTag = null; | 128 | hackHtml = hackTag = null; |
129 | //Creating return object | 129 | //Creating return object |
130 | return {head: doc.head.innerHTML, body: doc.body.innerHTML, document: doc}; | 130 | return {head: doc.head.innerHTML, body: doc.body.innerHTML, document: doc}; |
@@ -134,42 +134,42 @@ exports.TemplateDocumentMediator = Montage.create(Component, { | |||
134 | //TODO: Expand to allow more templates, clean up variables | 134 | //TODO: Expand to allow more templates, clean up variables |
135 | parseNinjaTemplateToHtml: { | 135 | parseNinjaTemplateToHtml: { |
136 | value: function (saveExternalData, template, ninjaWrapper, libCopyCallback) { | 136 | value: function (saveExternalData, template, ninjaWrapper, libCopyCallback) { |
137 | //TODO: Improve reference for rootUrl | 137 | //TODO: Improve reference for rootUrl |
138 | var regexRootUrl, | 138 | var regexRootUrl, |
139 | rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])), | 139 | rootUrl = this.application.ninja.coreIoApi.rootUrl + escape((this.application.ninja.documentController.documentHackReference.root.split(this.application.ninja.coreIoApi.cloudData.root)[1])), |
140 | mjsCreator = template.mjsTemplateCreator.create(), | 140 | mjsCreator = template.mjsTemplateCreator.create(), |
141 | mJsSerialization, | 141 | mJsSerialization, |
142 | toremovetags = [], | 142 | toremovetags = [], |
143 | presentNodes, | 143 | presentNodes, |
144 | montageTemplate; | 144 | montageTemplate; |
145 | //Creating instance of template creator | 145 | //Creating instance of template creator |
146 | montageTemplate = mjsCreator.initWithDocument(template.document); | 146 | montageTemplate = mjsCreator.initWithDocument(template.document); |
147 | //Setting up expression for parsing URLs | 147 | //Setting up expression for parsing URLs |
148 | regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); | 148 | regexRootUrl = new RegExp(rootUrl.replace(/\//gi, '\\\/'), 'gi'); |
149 | //Injecting head and body into old document | 149 | //Injecting head and body into old document |
150 | if (montageTemplate._ownerSerialization.length > 0) { | 150 | if (montageTemplate._ownerSerialization.length > 0) { |
151 | template.file.content.document.head.innerHTML = montageTemplate._document.head.innerHTML.replace(regexRootUrl, ''); | 151 | template.file.content.document.head.innerHTML = montageTemplate._document.head.innerHTML.replace(regexRootUrl, ''); |
152 | template.file.content.document.body.innerHTML = montageTemplate._document.body.innerHTML.replace(regexRootUrl, ''); |