From 648ee61ae84216d0236e0dbc211addc13b2cfa3a Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:52:06 -0700 Subject: Expand tabs --- js/document/helpers/url-parser.js | 118 +++++++++++++++++++------------------- 1 file changed, 59 insertions(+), 59 deletions(-) (limited to 'js/document/helpers/url-parser.js') 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. //////////////////////////////////////////////////////////////////////// // -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component; //////////////////////////////////////////////////////////////////////// -// +// exports.UrlParser = Montage.create(Component, { - //////////////////////////////////////////////////////////////////// - // - hasTemplate: { + //////////////////////////////////////////////////////////////////// + // + hasTemplate: { value: false }, //////////////////////////////////////////////////////////////////// - // - parseStyleUrls: { + // + parseStyleUrls: { value: function (css, href, local) { - // - if (local) { - var fileCouldDirUrl = href.split(href.split('/')[href.split('/').length-1])[0]; - } else { - //TODO: Add logic for external URLs - } - //TODO: Clean up functions - css = css.replace(/url\(()(.+?)\1\)/g, parseToNinjaUrl.bind(this)); - // - function parseToNinjaUrl (prop) { - // - return prop.replace(/[^()\\""\\'']+/g, prefixWithNinjaUrl.bind(this)); - } - // - function prefixWithNinjaUrl (url) { - // - 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)) { - url = fileCouldDirUrl+url; - } - // - return url; - } - // - return css; + // + if (local) { + var fileCouldDirUrl = href.split(href.split('/')[href.split('/').length-1])[0]; + } else { + //TODO: Add logic for external URLs + } + //TODO: Clean up functions + css = css.replace(/url\(()(.+?)\1\)/g, parseToNinjaUrl.bind(this)); + // + function parseToNinjaUrl (prop) { + // + return prop.replace(/[^()\\""\\'']+/g, prefixWithNinjaUrl.bind(this)); + } + // + function prefixWithNinjaUrl (url) { + // + 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)) { + url = fileCouldDirUrl+url; + } + // + return url; + } + // + return css; } }, //////////////////////////////////////////////////////////////////// - // - loadLocalStyleSheet: { + // + loadLocalStyleSheet: { value: function (href) { - //Getting file URI (not URL since we must load through I/O API) - var css = {}, file; - css.cssUrl = href.split(this.application.ninja.coreIoApi.rootUrl)[1]; - css.fileUri = this.application.ninja.coreIoApi.cloudData.root + unescape(css.cssUrl); - //Loading data from CSS file - file = this.application.ninja.coreIoApi.readFile({uri: css.fileUri}); - //Checking for file to be writable on disk - css.writable = JSON.parse(this.application.ninja.coreIoApi.isFileWritable({uri: css.fileUri}).content).readOnly; - //Returning loaded file - if (file && file.content) { - //Getting file contents - css.content = this.parseStyleUrls(file.content, href, true); - //Returning CSS object - return css; - } else { - return false; - } + //Getting file URI (not URL since we must load through I/O API) + var css = {}, file; + css.cssUrl = href.split(this.application.ninja.coreIoApi.rootUrl)[1]; + css.fileUri = this.application.ninja.coreIoApi.cloudData.root + unescape(css.cssUrl); + //Loading data from CSS file + file = this.application.ninja.coreIoApi.readFile({uri: css.fileUri}); + //Checking for file to be writable on disk + css.writable = JSON.parse(this.application.ninja.coreIoApi.isFileWritable({uri: css.fileUri}).content).readOnly; + //Returning loaded file + if (file && file.content) { + //Getting file contents + css.content = this.parseStyleUrls(file.content, href, true); + //Returning CSS object + return css; + } else { + return false; + } } }, //////////////////////////////////////////////////////////////////// - // - loadExternalStyleSheet: { + // + loadExternalStyleSheet: { value: function (href) { - //Loading external file - var file = this.application.ninja.coreIoApi.readExternalFile({url: href, binary: false}); - //Returning file - return file; + //Loading external file + var file = this.application.ninja.coreIoApi.readExternalFile({url: href, binary: false}); + //Returning file + return file; } } - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// }); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// -- cgit v1.2.3 From 04343eda8c2f870b0da55cfdc8003c99fe1cc4de Mon Sep 17 00:00:00 2001 From: Kris Kowal Date: Fri, 6 Jul 2012 11:53:10 -0700 Subject: Remove trailing spaces --- js/document/helpers/url-parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/document/helpers/url-parser.js') diff --git a/js/document/helpers/url-parser.js b/js/document/helpers/url-parser.js index c0c71511..353593eb 100755 --- a/js/document/helpers/url-parser.js +++ b/js/document/helpers/url-parser.js @@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE. var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component; //////////////////////////////////////////////////////////////////////// -// +// exports.UrlParser = Montage.create(Component, { //////////////////////////////////////////////////////////////////// // -- cgit v1.2.3