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 ++++++------- js/document/helpers/webgl-helper.js | 318 ++++++++++++++++++------------------ 2 files changed, 218 insertions(+), 218 deletions(-) (limited to 'js/document/helpers') 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; } } - //////////////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////// }); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// 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. //////////////////////////////////////////////////////////////////////// // -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component, - MaterialsModel = require("js/models/materials-model").MaterialsModel, - NJUtils = require("js/lib/NJUtils").NJUtils, - GLWorld = require("js/lib/drawing/world").World; +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, + MaterialsModel = require("js/models/materials-model").MaterialsModel, + NJUtils = require("js/lib/NJUtils").NJUtils, + GLWorld = require("js/lib/drawing/world").World; //////////////////////////////////////////////////////////////////////// -// +// exports.webGlDocumentHelper = Montage.create(Component, { - //////////////////////////////////////////////////////////////////// - // - hasTemplate: { + //////////////////////////////////////////////////////////////////// + // + hasTemplate: { value: false }, //////////////////////////////////////////////////////////////////// - //This is set when the design view is ready, for local reference - iframe: { + //This is set when the design view is ready, for local reference + iframe: { value: null }, //////////////////////////////////////////////////////////////////// - // + // _glData: { - value: null + value: null }, //////////////////////////////////////////////////////////////////// - // + // glData: { - // - get: function() { - // - var elt = this.iframe.contentWindow.document.body; - // - if (elt) { - var matLib = MaterialsModel.exportMaterials(); - this._glData = [matLib]; - this.collectGLData(this.iframe.contentWindow.document, this._glData ); - } else { - this._glData = null - } - // - return this._glData; - }, - // + // + get: function() { + // + var elt = this.iframe.contentWindow.document.body; + // + if (elt) { + var matLib = MaterialsModel.exportMaterials(); + this._glData = [matLib]; + this.collectGLData(this.iframe.contentWindow.document, this._glData ); + } else { + this._glData = null + } + // + return this._glData; + }, + // set: function(value) { - // - var elt = this.iframe.contentWindow.document.body; - // - if (elt) { - /* - // Use this code to test the runtime version of WebGL - var cdm = new NinjaCvsRt.CanvasDataManager(); - cdm.loadGLData(elt, value, null ); - */ + // + var elt = this.iframe.contentWindow.document.body; + // + if (elt) { + /* + // Use this code to test the runtime version of WebGL + var cdm = new NinjaCvsRt.CanvasDataManager(); + cdm.loadGLData(elt, value, null ); + */ - // - var i, nWorlds= value.length; - // - for (i = 0; i < nWorlds; i++) { - // get the data for the next canvas - var importStr = value[i], id, jObj, index = importStr.indexOf(';'), matLibStr, matLibObj, startIndex, endIndex, canvas, useWebGL, world; - // determine if it is the new (JSON) or old style format - if ((importStr[0] === 'v') && (index < 24)) { - // JSON format. pull off the - importStr = importStr.substr(index+1); - jObj = JSON.parse(importStr); - id = jObj.id; - } else { + // + var i, nWorlds= value.length; + // + for (i = 0; i < nWorlds; i++) { + // get the data for the next canvas + var importStr = value[i], id, jObj, index = importStr.indexOf(';'), matLibStr, matLibObj, startIndex, endIndex, canvas, useWebGL, world; + // determine if it is the new (JSON) or old style format + if ((importStr[0] === 'v') && (index < 24)) { + // JSON format. pull off the + importStr = importStr.substr(index+1); + jObj = JSON.parse(importStr); + id = jObj.id; + } else { // at this point the data could be either the materials library or // an old style world. We can determine which by converting the string // to an object via JSON.parse. That operation will fail if the string @@ -107,113 +107,113 @@ exports.webGlDocumentHelper = Montage.create(Component, { matLibObj = JSON.parse(importStr); MaterialsModel.importMaterials(matLibObj); } else { - startIndex = importStr.indexOf("id: "); - if (startIndex >= 0) { - endIndex = importStr.indexOf("\n", startIndex); - if (endIndex > 0) id = importStr.substring(startIndex+4, endIndex); - } + startIndex = importStr.indexOf("id: "); + if (startIndex >= 0) { + endIndex = importStr.indexOf("\n", startIndex); + if (endIndex > 0) id = importStr.substring(startIndex+4, endIndex); + } } - } - // - if (id != null) { - // - canvas = this.findCanvasWithID(id, elt); - // - if (canvas) { - // - if (canvas.elementModel) { - if (canvas.elementModel.shapeModel.GLWorld) { - canvas.elementModel.shapeModel.GLWorld.clearTree(); - } - // - if (jObj) { - useWebGL = jObj.webGL; - world = new GLWorld(canvas, useWebGL); - world.importJSON(jObj); - } - // - this.buildShapeModel(canvas.elementModel, world); - } - } - } - } - } - } + } + // + if (id != null) { + // + canvas = this.findCanvasWithID(id, elt); + // + if (canvas) { + // + if (canvas.elementModel) { + if (canvas.elementModel.shapeModel.GLWorld) { + canvas.elementModel.shapeModel.GLWorld.clearTree(); + } + // + if (jObj) { + useWebGL = jObj.webGL; + world = new GLWorld(canvas, useWebGL); + world.importJSON(jObj); + } + // + this.buildShapeModel(canvas.elementModel, world); + } + } + } + } + } + } }, //////////////////////////////////////////////////////////////////// - // + // findCanvasWithID: { - value: function(id, elt) { - // - var i, child, nKids, foundElt, cid = elt.getAttribute("data-RDGE-id"); - // - if (cid == id) return elt; - // - if (elt.children) { - nKids = elt.children.length; - for (i=0; i -Copyright (c) 2012, Motorola Mobility, Inc +Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved. -BSD License. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of Motorola Mobility nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of Motorola Mobility LLC nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS diff --git a/js/document/helpers/webgl-helper.js b/js/document/helpers/webgl-helper.js index 93bc1e93..9bdf33e6 100755 --- a/js/document/helpers/webgl-helper.js +++ b/js/document/helpers/webgl-helper.js @@ -1,24 +1,25 @@ /* -Copyright (c) 2012, Motorola Mobility, Inc +Copyright (c) 2012, Motorola Mobility LLC. All Rights Reserved. -BSD License. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: - - Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. - - Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - Neither the name of Motorola Mobility nor the names of its contributors - may be used to endorse or promote products derived from this software - without specific prior written permission. +* Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + +* Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +* Neither the name of Motorola Mobility LLC nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- cgit v1.2.3