diff options
Diffstat (limited to 'js/document/helpers')
-rwxr-xr-x | js/document/helpers/url-parser.js | 118 | ||||
-rwxr-xr-x | js/document/helpers/webgl-helper.js | 318 |
2 files changed, 218 insertions, 218 deletions
diff --git a/js/document/helpers/url-parser.js b/js/document/helpers/url-parser.js index 9c663e8a..c0c71511 100755 --- a/js/document/helpers/url-parser.js +++ b/js/document/helpers/url-parser.js | |||
@@ -30,81 +30,81 @@ 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.UrlParser = Montage.create(Component, { | 37 | exports.UrlParser = Montage.create(Component, { |
38 | //////////////////////////////////////////////////////////////////// | 38 | //////////////////////////////////////////////////////////////////// |
39 | // | 39 | // |
40 | hasTemplate: { | 40 | hasTemplate: { |
41 | value: false | 41 | value: false |
42 | }, | 42 | }, |
43 | //////////////////////////////////////////////////////////////////// | 43 | //////////////////////////////////////////////////////////////////// |
44 | // | 44 | // |
45 | parseStyleUrls: { | 45 | parseStyleUrls: { |
46 | value: function (css, href, local) { | 46 | value: function (css, href, local) { |
47 | // | 47 | // |
48 | if (local) { | 48 | if (local) { |
49 | var fileCouldDirUrl = href.split(href.split('/')[href.split('/').length-1])[0]; | 49 | var fileCouldDirUrl = href.split(href.split('/')[href.split('/').length-1])[0]; |
50 | } else { | 50 | } else { |
51 | //TODO: Add logic for external URLs | 51 | //TODO: Add logic for external URLs |
52 | } | 52 | } |
53 | //TODO: Clean up functions | 53 | //TODO: Clean up functions |
54 | css = css.replace(/url\(()(.+?)\1\)/g, parseToNinjaUrl.bind(this)); | 54 | css = css.replace(/url\(()(.+?)\1\)/g, parseToNinjaUrl.bind(this)); |
55 | // | 55 | // |
56 | function parseToNinjaUrl (prop) { | 56 | function parseToNinjaUrl (prop) { |
57 | // | 57 | // |
58 | return prop.replace(/[^()\\""\\'']+/g, prefixWithNinjaUrl.bind(this)); | 58 | return prop.replace(/[^()\\""\\'']+/g, prefixWithNinjaUrl.bind(this)); |
59 | } | 59 | } |
60 | // | 60 | // |
61 | function prefixWithNinjaUrl (url) { | 61 | function prefixWithNinjaUrl (url) { |
62 | // | 62 | // |
63 | if (url !== 'url' && !url.match(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi)) { | 63 | if (url !== 'url' && !url.match(/(\b(?:(?:https?|ftp|file|[A-Za-z]+):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$]))/gi)) { |
64 | url = fileCouldDirUrl+url; | 64 | url = fileCouldDirUrl+url; |
65 | } | 65 | } |
66 | // | 66 | // |
67 | return url; | 67 | return url; |
68 | } | 68 | } |
69 | // | 69 | // |
70 | return css; | 70 | return css; |
71 | } | 71 | } |
72 | }, | 72 | }, |
73 | //////////////////////////////////////////////////////////////////// | 73 | //////////////////////////////////////////////////////////////////// |
74 | // | 74 | // |
75 | loadLocalStyleSheet: { | 75 | loadLocalStyleSheet: { |
76 | value: function (href) { | 76 | value: function (href) { |
77 | //Getting file URI (not URL since we must load through I/O API) | 77 | //Getting file URI (not URL since we must load through I/O API) |
78 | var css = {}, file; | 78 | var css = {}, file; |
79 | css.cssUrl = href.split(this.application.ninja.coreIoApi.rootUrl)[1]; | 79 | css.cssUrl = href.split(this.application.ninja.coreIoApi.rootUrl)[1]; |
80 | css.fileUri = this.application.ninja.coreIoApi.cloudData.root + unescape(css.cssUrl); | 80 | css.fileUri = this.application.ninja.coreIoApi.cloudData.root + unescape(css.cssUrl); |
81 | //Loading data from CSS file | 81 | //Loading data from CSS file |
82 | file = this.application.ninja.coreIoApi.readFile({uri: css.fileUri}); | 82 | file = this.application.ninja.coreIoApi.readFile({uri: css.fileUri}); |
83 | //Checking for file to be writable on disk | 83 | //Checking for file to be writable on disk |
84 | css.writable = JSON.parse(this.application.ninja.coreIoApi.isFileWritable({uri: css.fileUri}).content).readOnly; | 84 | css.writable = JSON.parse(this.application.ninja.coreIoApi.isFileWritable({uri: css.fileUri}).content).readOnly; |
85 | //Returning loaded file | 85 | //Returning loaded file |
86 | if (file && file.content) { | 86 | if (file && file.content) { |
87 | //Getting file contents | 87 | //Getting file contents |
88 | css.content = this.parseStyleUrls(file.content, href, true); | 88 | css.content = this.parseStyleUrls(file.content, href, true); |
89 | //Returning CSS object | 89 | //Returning CSS object |
90 | return css; | 90 | return css; |
91 | } else { | 91 | } else { |
92 | return false; | 92 | return false; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | }, | 95 | }, |
96 | //////////////////////////////////////////////////////////////////// | 96 | //////////////////////////////////////////////////////////////////// |
97 | // | 97 | // |
98 | loadExternalStyleSheet: { | 98 | loadExternalStyleSheet: { |
99 | value: function (href) { | 99 | value: function (href) { |
100 | //Loading external file | 100 | //Loading external file |
101 | var file = this.application.ninja.coreIoApi.readExternalFile({url: href, binary: false}); | 101 | var file = this.application.ninja.coreIoApi.readExternalFile({url: href, binary: false}); |
102 | //Returning file | 102 | //Returning file |
103 | return file; | 103 | return file; |
104 | } | 104 | } |
105 | } | 105 | } |
106 | //////////////////////////////////////////////////////////////////// | 106 | //////////////////////////////////////////////////////////////////// |
107 | //////////////////////////////////////////////////////////////////// | 107 | //////////////////////////////////////////////////////////////////// |
108 | }); | 108 | }); |
109 | //////////////////////////////////////////////////////////////////////// | 109 | //////////////////////////////////////////////////////////////////////// |
110 | //////////////////////////////////////////////////////////////////////// | 110 | //////////////////////////////////////////////////////////////////////// |
diff --git a/js/document/helpers/webgl-helper.js b/js/document/helpers/webgl-helper.js index 4d73758b..86e2cdc1 100755 --- a/js/document/helpers/webgl-helper.js +++ b/js/document/helpers/webgl-helper.js | |||
@@ -30,72 +30,72 @@ 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 | MaterialsModel = require("js/models/materials-model").MaterialsModel, | 35 | MaterialsModel = require("js/models/materials-model").MaterialsModel, |
36 | NJUtils = require("js/lib/NJUtils").NJUtils, | 36 | NJUtils = require("js/lib/NJUtils").NJUtils, |
37 | GLWorld = require("js/lib/drawing/world").World; | 37 | GLWorld = require("js/lib/drawing/world").World; |
38 | //////////////////////////////////////////////////////////////////////// | 38 | //////////////////////////////////////////////////////////////////////// |
39 | // | 39 | // |
40 | exports.webGlDocumentHelper = Montage.create(Component, { | 40 | exports.webGlDocumentHelper = Montage.create(Component, { |
41 | //////////////////////////////////////////////////////////////////// | 41 | //////////////////////////////////////////////////////////////////// |
42 | // | 42 | // |
43 | hasTemplate: { | 43 | hasTemplate: { |
44 | value: false | 44 | value: false |
45 | }, | 45 | }, |
46 | //////////////////////////////////////////////////////////////////// | 46 | //////////////////////////////////////////////////////////////////// |
47 | //This is set when the design view is ready, for local reference | 47 | //This is set when the design view is ready, for local reference |
48 | iframe: { | 48 | iframe: { |
49 | value: null | 49 | value: null |
50 | }, | 50 | }, |
51 | //////////////////////////////////////////////////////////////////// | 51 | //////////////////////////////////////////////////////////////////// |
52 | // | 52 | // |
53 | _glData: { | 53 | _glData: { |
54 | value: null | 54 | value: null |
55 | }, | 55 | }, |
56 | //////////////////////////////////////////////////////////////////// | 56 | //////////////////////////////////////////////////////////////////// |
57 | // | 57 | // |
58 | glData: { | 58 | glData: { |
59 | // | 59 | // |
60 | get: function() { | 60 | get: function() { |
61 | // | 61 | // |
62 | var elt = this.iframe.contentWindow.document.body; | 62 | var elt = this.iframe.contentWindow.document.body; |
63 | // | 63 | // |
64 | if (elt) { | 64 | if (elt) { |
65 | var matLib = MaterialsModel.exportMaterials(); | 65 | var matLib = MaterialsModel.exportMaterials(); |
66 | this._glData = [matLib]; | 66 | this._glData = [matLib]; |
67 | this.collectGLData(this.iframe.contentWindow.document, this._glData ); | 67 | this.collectGLData(this.iframe.contentWindow.document, this._glData ); |
68 | } else { | 68 | } else { |
69 | this._glData = null | 69 | this._glData = null |
70 | } | 70 | } |
71 | // | 71 | // |
72 | return this._glData; | 72 | return this._glData; |
73 | }, | 73 | }, |
74 | // | 74 | // |
75 | set: function(value) { | 75 | set: function(value) { |
76 | // | 76 | // |
77 | var elt = this.iframe.contentWindow.document.body; | 77 | var elt = this.iframe.contentWindow.document.body; |
78 | // | 78 | // |
79 | if (elt) { | 79 | if (elt) { |
80 | /* | 80 | /* |
81 | // Use this code to test the runtime version of WebGL | 81 | // Use this code to test the runtime version of WebGL |
82 | var cdm = new NinjaCvsRt.CanvasDataManager(); | 82 | var cdm = new NinjaCvsRt.CanvasDataManager(); |
83 | cdm.loadGLData(elt, value, null ); | 83 | cdm.loadGLData(elt, value, null ); |
84 | */ | 84 |