From 6b9bfb63f6bc22ef1095dc11816826bb83a2c408 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 26 Mar 2012 15:55:38 -0700 Subject: Cleanup of the components panel Renamed to naming convention. Deleted un-used file. Signed-off-by: Valerio Virgillito --- js/data/panels-data.js | 4 +- js/panels/Components/ComponentsPanel.js | 47 --- .../ComponentsPanelBase.css | 11 - .../ComponentsPanelBase.html | 65 ---- .../ComponentsPanelBase.js | 423 --------------------- .../components-panel.reel/components-panel.css | 11 + .../components-panel.reel/components-panel.html | 65 ++++ .../components-panel.reel/components-panel.js | 423 +++++++++++++++++++++ 8 files changed, 501 insertions(+), 548 deletions(-) delete mode 100755 js/panels/Components/ComponentsPanel.js delete mode 100755 js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.css delete mode 100755 js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html delete mode 100755 js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js create mode 100755 js/panels/components-panel.reel/components-panel.css create mode 100755 js/panels/components-panel.reel/components-panel.html create mode 100755 js/panels/components-panel.reel/components-panel.js (limited to 'js') diff --git a/js/data/panels-data.js b/js/data/panels-data.js index 2422f5e7..7a2d817a 100644 --- a/js/data/panels-data.js +++ b/js/data/panels-data.js @@ -55,8 +55,8 @@ exports.PanelsData = Montage.create(Montage, { scrollable: true, collapsed: true, open: true, - modulePath: "js/panels/Components/ComponentsPanelBase.reel", - moduleName: "ComponentsPanelBase" + modulePath: "js/panels/components-panel.reel", + moduleName: "ComponentsPanel" }, // { // name: "Project/Assets", diff --git a/js/panels/Components/ComponentsPanel.js b/js/panels/Components/ComponentsPanel.js deleted file mode 100755 index df1d74bb..00000000 --- a/js/panels/Components/ComponentsPanel.js +++ /dev/null @@ -1,47 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -var Montage = require("montage/core/core").Montage; - -var PanelBase = require("js/panels/PanelBase").PanelBase; -var ComponentsPanelBase = require("js/panels/Components/ComponentsPanelBase.reel").ComponentsPanelBase; - -exports.ComponentsPanel = Montage.create(PanelBase, { - id : {value : "componentsPanel", writable:true, enumerable:true, configurable:true}, - panelName : {value : "Components", writable:true, enumerable:true, configurable:true}, - panelHeaderID : {value : "componentsPanelHeader", writable:true, enumerable:true, configurable:true}, - disclosureIconID : {value : "componentsPanelDisclosureIcon", writable:true, enumerable:true, configurable:true}, - closeButtonID : {value : "componentsPanelCloseButton", writable:true, enumerable:true, configurable:true}, - panelContentID : {value : "componentsPanelContent", writable:true, enumerable:true, configurable:true}, - - init : { - value : function() - { - this.contentHeight = 200; - this.minHeight = 100; - this.defaultHeight = 200; - - /* OLD WAY -- Removing the temporary div - // TODO: Remove this comment once this is tested. - var panelContainer = document.createElement("div"); - this._componentsPanelBase = ComponentsPanelBase.create(); - this._componentsPanelBase.element = panelContainer; - - this.content = this._componentsPanelBase; - this._componentsPanelBase.needsDraw = true; - */ - - this.content = ComponentsPanelBase.create(); - } - }, - - _componentsPanelBase:{ - enumerable: true, - value: null, - writable:true - } - -}); \ No newline at end of file diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.css b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.css deleted file mode 100755 index ac250c83..00000000 --- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.css +++ /dev/null @@ -1,11 +0,0 @@ -/* - This file contains proprietary software owned by Motorola Mobility, Inc.
- No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
- (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -.treeHolder{ - width: 227px; - background: red; - padding-left: 13px; -} diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html deleted file mode 100755 index 6d7c8a2c..00000000 --- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - -
-
-
- - - \ No newline at end of file diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js deleted file mode 100755 index 3505393c..00000000 --- a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js +++ /dev/null @@ -1,423 +0,0 @@ -/* -This file contains proprietary software owned by Motorola Mobility, Inc.
-No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
-(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. -
*/ - -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component, - NJUtils = require("js/lib/NJUtils").NJUtils; - -var treeControlModule = require("js/components/tree.reel"); -var PIData = require("js/data/pi/pi-data").PiData; - -String.prototype.capitalizeFirstChar = function() { - return this.charAt(0).toUpperCase() + this.slice(1); -}; - - -var ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component, { - - components: { - value: { - "text": "styles", - "children": [ - { - "text": "Widgets", - "children": [ - { - "text": "Feed Reader", - "dataFile" : "node_modules/components-data/feed-reader.json", - "component": "feedreader" - }, - { - "text": "Map", - "dataFile" : "node_modules/components-data/map.json", - "component": "map" - }, - { - "text": "Picasa Carousel", - "dataFile" : "node_modules/components-data/picasa-carousel.json", - "component": "picasa-carousel" - }, - { - "text": "Search Bar", - "dataFile" : "node_modules/components-data/searchfield.json", - "component": "searchfield" - }, - { - "text": "Youtube Channel", - "dataFile" : "node_modules/components-data/youtube-channel.json", - "component": "youtube-channel" - } - ] - }, - { - "text": "Montage Components", - "children": [ - { - "text": "Anchor", - "dataFile" : "node_modules/components-data/anchor.json", - "component": "anchor" - }, - { - "text": "Button", - "dataFile" : "node_modules/components-data/button.json", - "component": "button" - }, - { - "text": "Checkbox", - "dataFile" : "node_modules/components-data/checkbox.json", - "component": "checkbox" - }, - { - "text": "Image Component", - "dataFile" : "node_modules/components-data/image.json", - "component": "imageComponent" - }, - { - "text": "NumberInput", - "dataFile" : "node_modules/components-data/number-input.json", - "component": "numberInput" - }, - { - "text": "Select Input", - "dataFile" : "node_modules/components-data/select.json", - "component": "select" - }, - { - "text": "Radio Button", - "dataFile" : "node_modules/components-data/radio-button.json", - "component": "radioButton" - }, - { - "text": "Range Input", - "dataFile" : "node_modules/components-data/range-input.json", - "component": "rangeInput" - }, - { - "text": "TextArea", - "dataFile" : "node_modules/components-data/textarea.json", - "component": "textarea" - }, - { - "text": "Textfield", - "dataFile" : "node_modules/components-data/textfield.json", - "component": "textfield" - }, - { - "text": "Toogle Button", - "dataFile" : "node_modules/components-data/toggle-button.json", - "component": "toggleButton" - } - ] - } - ] - } - }, - - componentsData: { - value: {} - }, - - componentsToLoad: { - value: null - }, - - componentsLoaded: { - value: 0 - }, - - dragComponent: { - value: null - }, - - dragPosition: { - value: null - }, - - centerStage: { - value: null - }, - - - /********************************************************************* - * Components Tree and Model Creation - *********************************************************************/ - - didCreate: { - value: function() { - // Setup the drop delegate - this.application.ninja.dragDropMediator.dropDelegate = this; - // Loop through the component and load the JSON data for them - this._loadComponents(); - } - }, - - // Load all the data files for each component - // TODO: Implement the error case - _loadComponents: { - value: function() { - - for(var cat in this.components.children) { - - this.componentsToLoad += this.components.children[cat].children.length; - - for(var i = 0, component; component = this.components.children[cat].children[i]; i++) { - var req = new XMLHttpRequest(); - //req.identifier = "searchRequest"; - req.open("GET", component.dataFile); - req.addEventListener("load", this, false); - req.addEventListener("error", this, false); - req.send(); - } - - } - } - }, - - handleLoad: { - value: function(evt) { - var componentData, component, piID, piObj, section; - - componentData = JSON.parse(evt.target.responseText); - - component = componentData.name; - - // Build the PI data and create a new object for Ninja PI - piID = component + "Pi"; - piObj = []; - section = {}; - section.label = component + " Properties"; - section.Section = []; - - for(var j = 0, props; props = componentData.properties[j]; j++) { - var row = {}; - row.type = this.getControlType(props.type); - row.id = props.name; - row.prop = props.name; - row.defaultValue = props["default"]; - row.label = props.name; - row.items = props.possibleValues; - - section.Section.push([row]); - } - - PIData[piID] = []; - PIData[piID].push(section); - - // Setup the component hash object to store references to each component data - this.componentsData[componentData.component] = componentData; - - this.componentsLoaded++; - - if(this.componentsLoaded === this.componentsToLoad) { - // console.log("all loaded"); - // Here we need to stop some sort of loading animation - } - - } - }, - - // PI conversion method. This will convert the property type into a Ninja component - getControlType: { - value: function(type) { - switch(type) { - case "string": - return "textbox"; - case "boolean": - return "checkbox"; - case "select": - return "dropdown"; - case "number": - return "hottext"; - default: - alert("Conversion not implemented for ", type); - } - } - }, - - /********************************************************************* - * Handle Tree / Drag-Drop events - *********************************************************************/ - - handleDblclick: { - value: function(obj) { - this.addComponentToStage(this.componentsData[obj.component]); - } - }, - - handleDragStart: { - value: function(obj, event) { - this.dragComponent = obj; - event.dataTransfer.effectAllowed = 'move'; - event.dataTransfer.setData('text/plain', 'componentDrop'); - } - }, - - handleComponentDrop: { - value: function(left, top) { - this.addComponentToStage(this.componentsData[this.dragComponent.component], [left, top]); - } - }, - - - /** - * Send a request to add a component to the user document and waits for a callback to continue - */ - addComponentToStage: { - value: function(component, position) { - var that, element; - - // Check for position. If none then center on the stage - if(position) { - this.dragPosition = position; - } else { - this.dragPosition = this.getStageCenter(); - - } - that = this; - element = this.makeComponent(component.component); - - this.application.ninja.currentDocument._window.addComponent(element, {name: component.name, path: component.module}, function(instance, element) { - - //var pos = that.getStageCenter(); - - var styles = { - 'position': 'absolute', - 'left' : that.dragPosition[0] + 'px', - 'top' : that.dragPosition[1] + 'px', - '-webkit-transform-style' : 'preserve-3d', - '-webkit-transform' : 'perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)' - }; - - var defaultStyles = component.defaultStyles; - if(defaultStyles) { - for(var n in defaultStyles) { - styles[n] = defaultStyles[n]; - } - } - - instance.addEventListener('firstDraw', that, false); - - that.application.ninja.currentDocument.setComponentInstance(instance, element); - - NJevent("elementAdding", {"el": element, "data":styles}); - }); - - } - }, - - handleFirstDraw: { - value: function (e) { - NJevent("addComponentFirstDraw"); - } - }, - - makeComponent: { - value: function(name) { - var el; - - switch(name) { - case "anchor": - el = NJUtils.makeNJElement("a", "Anchor", "component"); - el.elementModel.pi = "AnchorPi"; - el.setAttribute("href", "http://www.motorola.com"); - el.innerHTML = "link"; - break; - case "button": - el = NJUtils.makeNJElement(name, "Button", "component"); - el.elementModel.pi = "ButtonPi"; - el.setAttribute("type", "button"); - el.innerHTML = "Button"; - break; - case "checkbox": - el = NJUtils.makeNJElement("input", "Checkbox", "component"); - el.elementModel.pi = "CheckboxPi"; - el.setAttribute("type", "checkbox"); - break; - case "imageComponent": - el = NJUtils.makeNJElement("image", "Image", "component"); - el.elementModel.pi = "ImagePi"; - el.setAttribute("width", 200); - el.setAttribute("height", 200); - break; - case "numberInput": - el = NJUtils.makeNJElement("input", "Number Input", "component"); - el.elementModel.pi = "NumberInputPi"; - el.setAttribute("type", "number"); - break; - case "select": - el = NJUtils.makeNJElement("select", "Select", "component"); - el.elementModel.pi = "SelectInputPi"; - break; - case "radioButton": - el = NJUtils.makeNJElement("input", "Radio Button", "component"); - el.elementModel.pi = "RadioButtonPi"; - el.setAttribute("type", "radio"); - break; - case "rangeInput": - el = NJUtils.makeNJElement("input", "Range Input", "component"); - el.elementModel.pi = "RangeInputPi"; - el.setAttribute("type", "range"); - break; - case "textfield": - case "searchfield": - el = NJUtils.makeNJElement("input", "Textfield", "component"); - el.elementModel.pi = "TextfieldPi"; - el.setAttribute("type", "text"); - break; - case "textarea": - el = NJUtils.makeNJElement("textarea", "TextArea", "component"); - el.elementModel.pi = "TextAreaPi"; - break; - case "toggleButton": - el = NJUtils.makeNJElement("button", "Toggle Button", "component"); - el.elementModel.pi = "ToggleButtonPi"; - el.innerHTML = "Off"; - break; - case "map": - el = NJUtils.makeNJElement("div", "Map", "component"); - el.elementModel.pi = "MapPi"; - el.elementModel.isComponent = true; - break; - case "feedreader": - el = NJUtils.makeNJElement("div", "Feed Reader", "component"); - el.elementModel.pi = "FeedReaderPi"; - el.elementModel.isComponent = true; - break; - case "picasa-carousel": - el = NJUtils.makeNJElement("div", "Picasa Carousel", "component"); - el.elementModel.pi = "PicasaCarouselPi"; - el.elementModel.isComponent = true; - break; - case "youtube-channel": - el = NJUtils.makeNJElement("div", "Youtube Channel", "component"); - el.elementModel.pi = "YoutubeChannelPi"; - el.elementModel.isComponent = true; - break; - - } - - return el; - } - }, - - /** - * - */ - getStageCenter: { - value: function() { - //if(!this.centerStage) { - var top, left; - - top = ~~((parseFloat(this.application.ninja.elementMediator.getProperty(this.application.ninja.currentDocument.documentRoot, "height"))) / 2); - left = ~~((parseFloat(this.application.ninja.elementMediator.getProperty(this.application.ninja.currentDocument.documentRoot, "width"))) / 2); - //this.centerStage = [top, left]; - return [left, top]; - //} - - //return this.centerStage; - } - } -}); \ No newline at end of file diff --git a/js/panels/components-panel.reel/components-panel.css b/js/panels/components-panel.reel/components-panel.css new file mode 100755 index 00000000..ac250c83 --- /dev/null +++ b/js/panels/components-panel.reel/components-panel.css @@ -0,0 +1,11 @@ +/* + This file contains proprietary software owned by Motorola Mobility, Inc.
+ No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +.treeHolder{ + width: 227px; + background: red; + padding-left: 13px; +} diff --git a/js/panels/components-panel.reel/components-panel.html b/js/panels/components-panel.reel/components-panel.html new file mode 100755 index 00000000..f598a1ee --- /dev/null +++ b/js/panels/components-panel.reel/components-panel.html @@ -0,0 +1,65 @@ + + + + + + + + + + + + +
+
+
+ + + \ No newline at end of file diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js new file mode 100755 index 00000000..9252b7b8 --- /dev/null +++ b/js/panels/components-panel.reel/components-panel.js @@ -0,0 +1,423 @@ +/* +This file contains proprietary software owned by Motorola Mobility, Inc.
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.
+(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. +
*/ + +var Montage = require("montage/core/core").Montage, + Component = require("montage/ui/component").Component, + NJUtils = require("js/lib/NJUtils").NJUtils; + +var treeControlModule = require("js/components/tree.reel"); +var PIData = require("js/data/pi/pi-data").PiData; + +String.prototype.capitalizeFirstChar = function() { + return this.charAt(0).toUpperCase() + this.slice(1); +}; + + +exports.ComponentsPanel = Montage.create(Component, { + + components: { + value: { + "text": "styles", + "children": [ + { + "text": "Widgets", + "children": [ + { + "text": "Feed Reader", + "dataFile" : "node_modules/components-data/feed-reader.json", + "component": "feedreader" + }, + { + "text": "Map", + "dataFile" : "node_modules/components-data/map.json", + "component": "map" + }, + { + "text": "Picasa Carousel", + "dataFile" : "node_modules/components-data/picasa-carousel.json", + "component": "picasa-carousel" + }, + { + "text": "Search Bar", + "dataFile" : "node_modules/components-data/searchfield.json", + "component": "searchfield" + }, + { + "text": "Youtube Channel", + "dataFile" : "node_modules/components-data/youtube-channel.json", + "component": "youtube-channel" + } + ] + }, + { + "text": "Montage Components", + "children": [ + { + "text": "Anchor", + "dataFile" : "node_modules/components-data/anchor.json", + "component": "anchor" + }, + { + "text": "Button", + "dataFile" : "node_modules/components-data/button.json", + "component": "button" + }, + { + "text": "Checkbox", + "dataFile" : "node_modules/components-data/checkbox.json", + "component": "checkbox" + }, + { + "text": "Image Component", + "dataFile" : "node_modules/components-data/image.json", + "component": "imageComponent" + }, + { + "text": "NumberInput", + "dataFile" : "node_modules/components-data/number-input.json", + "component": "numberInput" + }, + { + "text": "Select Input", + "dataFile" : "node_modules/components-data/select.json", + "component": "select" + }, + { + "text": "Radio Button", + "dataFile" : "node_modules/components-data/radio-button.json", + "component": "radioButton" + }, + { + "text": "Range Input", + "dataFile" : "node_modules/components-data/range-input.json", + "component": "rangeInput" + }, + { + "text": "TextArea", + "dataFile" : "node_modules/components-data/textarea.json", + "component": "textarea" + }, + { + "text": "Textfield", + "dataFile" : "node_modules/components-data/textfield.json", + "component": "textfield" + }, + { + "text": "Toogle Button", + "dataFile" : "node_modules/components-data/toggle-button.json", + "component": "toggleButton" + } + ] + } + ] + } + }, + + componentsData: { + value: {} + }, + + componentsToLoad: { + value: null + }, + + componentsLoaded: { + value: 0 + }, + + dragComponent: { + value: null + }, + + dragPosition: { + value: null + }, + + centerStage: { + value: null + }, + + + /********************************************************************* + * Components Tree and Model Creation + *********************************************************************/ + + didCreate: { + value: function() { + // Setup the drop delegate + this.application.ninja.dragDropMediator.dropDelegate = this; + // Loop through the component and load the JSON data for them + this._loadComponents(); + } + }, + + // Load all the data files for each component + // TODO: Implement the error case + _loadComponents: { + value: function() { + + for(var cat in this.components.children) { + + this.componentsToLoad += this.components.children[cat].children.length; + + for(var i = 0, component; component = this.components.children[cat].children[i]; i++) { + var req = new XMLHttpRequest(); + //req.identifier = "searchRequest"; + req.open("GET", component.dataFile); + req.addEventListener("load", this, false); + req.addEventListener("error", this, false); + req.send(); + } + + } + } + }, + + handleLoad: { + value: function(evt) { + var componentData, component, piID, piObj, section; + + componentData = JSON.parse(evt.target.responseText); + + component = componentData.name; + + // Build the PI data and create a new object for Ninja PI + piID = component + "Pi"; + piObj = []; + section = {}; + section.label = component + " Properties"; + section.Section = []; + + for(var j = 0, props; props = componentData.properties[j]; j++) { + var row = {}; + row.type = this.getControlType(props.type); + row.id = props.name; + row.prop = props.name; + row.defaultValue = props["default"]; + row.label = props.name; + row.items = props.possibleValues; + + section.Section.push([row]); + } + + PIData[piID] = []; + PIData[piID].push(section); + + // Setup the component hash object to store references to each component data + this.componentsData[componentData.component] = componentData; + + this.componentsLoaded++; + + if(this.componentsLoaded === this.componentsToLoad) { + // console.log("all loaded"); + // Here we need to stop some sort of loading animation + } + + } + }, + + // PI conversion method. This will convert the property type into a Ninja component + getControlType: { + value: function(type) { + switch(type) { + case "string": + return "textbox"; + case "boolean": + return "checkbox"; + case "select": + return "dropdown"; + case "number": + return "hottext"; + default: + alert("Conversion not implemented for ", type); + } + } + }, + + /********************************************************************* + * Handle Tree / Drag-Drop events + *********************************************************************/ + + handleDblclick: { + value: function(obj) { + this.addComponentToStage(this.componentsData[obj.component]); + } + }, + + handleDragStart: { + value: function(obj, event) { + this.dragComponent = obj; + event.dataTransfer.effectAllowed = 'move'; + event.dataTransfer.setData('text/plain', 'componentDrop'); + } + }, + + handleComponentDrop: { + value: function(left, top) { + this.addComponentToStage(this.componentsData[this.dragComponent.component], [left, top]); + } + }, + + + /** + * Send a request to add a component to the user document and waits for a callback to continue + */ + addComponentToStage: { + value: function(component, position) { + var that, element; + + // Check for position. If none then center on the stage + if(position) { + this.dragPosition = position; + } else { + this.dragPosition = this.getStageCenter(); + + } + that = this; + element = this.makeComponent(component.component); + + this.application.ninja.currentDocument._window.addComponent(element, {name: component.name, path: component.module}, function(instance, element) { + + //var pos = that.getStageCenter(); + + var styles = { + 'position': 'absolute', + 'left' : that.dragPosition[0] + 'px', + 'top' : that.dragPosition[1] + 'px', + '-webkit-transform-style' : 'preserve-3d', + '-webkit-transform' : 'perspective(1400) matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1)' + }; + + var defaultStyles = component.defaultStyles; + if(defaultStyles) { + for(var n in defaultStyles) { + styles[n] = defaultStyles[n]; + } + } + + instance.addEventListener('firstDraw', that, false); + + that.application.ninja.currentDocument.setComponentInstance(instance, element); + + NJevent("elementAdding", {"el": element, "data":styles}); + }); + + } + }, + + handleFirstDraw: { + value: function (e) { + NJevent("addComponentFirstDraw"); + } + }, + + makeComponent: { + value: function(name) { + var el; + + switch(name) { + case "anchor": + el = NJUtils.makeNJElement("a", "Anchor", "component"); + el.elementModel.pi = "AnchorPi"; + el.setAttribute("href", "http://www.motorola.com"); + el.innerHTML = "link"; + break; + case "button": + el = NJUtils.makeNJElement(name, "Button", "component"); + el.elementModel.pi = "ButtonPi"; + el.setAttribute("type", "button"); + el.innerHTML = "Button"; + break; + case "checkbox": + el = NJUtils.makeNJElement("input", "Checkbox", "component"); + el.elementModel.pi = "CheckboxPi"; + el.setAttribute("type", "checkbox"); + break; + case "imageComponent": + el = NJUtils.makeNJElement("image", "Image", "component"); + el.elementModel.pi = "ImagePi"; + el.setAttribute("width", 200); + el.setAttribute("height", 200); + break; + case "numberInput": + el = NJUtils.makeNJElement("input", "Number Input", "component"); + el.elementModel.pi = "NumberInputPi"; + el.setAttribute("type", "number"); + break; + case "select": + el = NJUtils.makeNJElement("select", "Select", "component"); + el.elementModel.pi = "SelectInputPi"; + break; + case "radioButton": + el = NJUtils.makeNJElement("input", "Radio Button", "component"); + el.elementModel.pi = "RadioButtonPi"; + el.setAttribute("type", "radio"); + break; + case "rangeInput": + el = NJUtils.makeNJElement("input", "Range Input", "component"); + el.elementModel.pi = "RangeInputPi"; + el.setAttribute("type", "range"); + break; + case "textfield": + case "searchfield": + el = NJUtils.makeNJElement("input", "Textfield", "component"); + el.elementModel.pi = "TextfieldPi"; + el.setAttribute("type", "text"); + break; + case "textarea": + el = NJUtils.makeNJElement("textarea", "TextArea", "component"); + el.elementModel.pi = "TextAreaPi"; + break; + case "toggleButton": + el = NJUtils.makeNJElement("button", "Toggle Button", "component"); + el.elementModel.pi = "ToggleButtonPi"; + el.innerHTML = "Off"; + break; + case "map": + el = NJUtils.makeNJElement("div", "Map", "component"); + el.elementModel.pi = "MapPi"; + el.elementModel.isComponent = true; + break; + case "feedreader": + el = NJUtils.makeNJElement("div", "Feed Reader", "component"); + el.elementModel.pi = "FeedReaderPi"; + el.elementModel.isComponent = true; + break; + case "picasa-carousel": + el = NJUtils.makeNJElement("div", "Picasa Carousel", "component"); + el.elementModel.pi = "PicasaCarouselPi"; + el.elementModel.isComponent = true; + break; + case "youtube-channel": + el = NJUtils.makeNJElement("div", "Youtube Channel", "component"); + el.elementModel.pi = "YoutubeChannelPi"; + el.elementModel.isComponent = true; + break; + + } + + return el; + } + }, + + /** + * + */ + getStageCenter: { + value: function() { + //if(!this.centerStage) { + var top, left; + + top = ~~((parseFloat(this.application.ninja.elementMediator.getProperty(this.application.ninja.currentDocument.documentRoot, "height"))) / 2); + left = ~~((parseFloat(this.application.ninja.elementMediator.getProperty(this.application.ninja.currentDocument.documentRoot, "width"))) / 2); + //this.centerStage = [top, left]; + return [left, top]; + //} + + //return this.centerStage; + } + } +}); \ No newline at end of file -- cgit v1.2.3 From db6c0d20eba328408b37b65e67215d1866100c18 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Tue, 27 Mar 2012 11:34:06 -0700 Subject: removed trace statement Signed-off-by: Valerio Virgillito --- js/controllers/document-controller.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/controllers/document-controller.js b/js/controllers/document-controller.js index d5556fa8..b6d9dc67 100755 --- a/js/controllers/document-controller.js +++ b/js/controllers/document-controller.js @@ -71,7 +71,7 @@ var DocumentController = exports.DocumentController = Montage.create(Component, handleAddComponentFirstDraw: { value: function (e) { //TODO: Add logic to reparse the document for dynamically added styles - console.log(e); + //console.log(e); } }, -- cgit v1.2.3 From dd3cf0df2b03d1b5e124d99118c667eab55877e7 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 30 Mar 2012 14:34:03 -0700 Subject: IKNINJA-1191 - Fixed the order of the components Components now appear in alphabetical order. Signed-off-by: Valerio Virgillito --- js/panels/components-panel.reel/components-panel.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'js') diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js index 9252b7b8..461abe84 100755 --- a/js/panels/components-panel.reel/components-panel.js +++ b/js/panels/components-panel.reel/components-panel.js @@ -80,11 +80,6 @@ exports.ComponentsPanel = Montage.create(Component, { "dataFile" : "node_modules/components-data/number-input.json", "component": "numberInput" }, - { - "text": "Select Input", - "dataFile" : "node_modules/components-data/select.json", - "component": "select" - }, { "text": "Radio Button", "dataFile" : "node_modules/components-data/radio-button.json", @@ -95,6 +90,11 @@ exports.ComponentsPanel = Montage.create(Component, { "dataFile" : "node_modules/components-data/range-input.json", "component": "rangeInput" }, + { + "text": "Select Input", + "dataFile" : "node_modules/components-data/select.json", + "component": "select" + }, { "text": "TextArea", "dataFile" : "node_modules/components-data/textarea.json", -- cgit v1.2.3 From e6cfd371849b92fccd5e7ee74e428914a2dc23eb Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Fri, 30 Mar 2012 15:15:26 -0700 Subject: completing the component simple pi Signed-off-by: Valerio Virgillito --- js/panels/components-panel.reel/components-panel.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js') diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js index 461abe84..6972b9b4 100755 --- a/js/panels/components-panel.reel/components-panel.js +++ b/js/panels/components-panel.reel/components-panel.js @@ -106,7 +106,7 @@ exports.ComponentsPanel = Montage.create(Component, { "component": "textfield" }, { - "text": "Toogle Button", + "text": "Toggle Button", "dataFile" : "node_modules/components-data/toggle-button.json", "component": "toggleButton" } -- cgit v1.2.3 From fb0a659c9ca3479fd6799325498b11f074689936 Mon Sep 17 00:00:00 2001 From: John Mayhew Date: Mon, 2 Apr 2012 14:57:31 -0700 Subject: -Namespaced all RDGE javascript. -Removed the following unused files from the build script /core/script/fx/blur.js /core/script/fx/ssao.js /core/script/animation.js - Fully removed the following from the build and from source control as they are unused or no longer needed /core/script/util/dbgpanel.js /core/script/util/fpsTracker.js /core/script/util/statTracker.js /core/script/input.js /core/script/TextureManager.js /core/script/ubershader.js --- js/helper-classes/RDGE/runtime/GLRuntime.js | 26 +- .../RDGE/src/core/script/MeshManager.js | 255 +-- .../RDGE/src/core/script/RenderInitProcs.js | 476 ++-- .../RDGE/src/core/script/RenderProcs.js | 787 ++++--- .../RDGE/src/core/script/ScreenQuad.js | 32 +- .../RDGE/src/core/script/ShaderManager.js | 124 +- .../RDGE/src/core/script/TextureManager.js | 6 - .../RDGE/src/core/script/animation.js | 191 +- js/helper-classes/RDGE/src/core/script/box.js | 181 +- js/helper-classes/RDGE/src/core/script/camera.js | 468 ++-- js/helper-classes/RDGE/src/core/script/engine.js | 513 ++--- js/helper-classes/RDGE/src/core/script/fx/blur.js | 283 ++- js/helper-classes/RDGE/src/core/script/fx/ssao.js | 211 +- .../RDGE/src/core/script/init_state.js | 553 +++-- js/helper-classes/RDGE/src/core/script/input.js | 117 - js/helper-classes/RDGE/src/core/script/jpass.js | 771 +++---- js/helper-classes/RDGE/src/core/script/jshader.js | 260 ++- .../RDGE/src/core/script/lightmanager.js | 148 +- .../RDGE/src/core/script/math/mat4.js | 1055 +++++---- .../RDGE/src/core/script/math/quat.js | 237 +- .../RDGE/src/core/script/math/vec2.js | 229 +- .../RDGE/src/core/script/math/vec3.js | 423 ++-- .../RDGE/src/core/script/math/vec4.js | 315 +-- .../RDGE/src/core/script/objectManager.js | 8 +- js/helper-classes/RDGE/src/core/script/particle.js | 1591 +++++++------- .../RDGE/src/core/script/precompiled.js | 123 +- .../RDGE/src/core/script/renderUtils.js | 644 +++--- .../RDGE/src/core/script/rendercontext.js | 454 ++-- js/helper-classes/RDGE/src/core/script/renderer.js | 2299 ++++++++++---------- .../RDGE/src/core/script/run_state.js | 711 +++--- js/helper-classes/RDGE/src/core/script/runtime.js | 280 +-- .../RDGE/src/core/script/scenegraph.js | 1754 +++++++-------- .../RDGE/src/core/script/scenegraphNodes.js | 1016 ++++----- .../RDGE/src/core/script/shadowLight.js | 90 +- js/helper-classes/RDGE/src/core/script/sockets.js | 243 +-- .../RDGE/src/core/script/ubershader.js | 159 -- .../RDGE/src/core/script/util/dbgpanel.js | 237 -- .../RDGE/src/core/script/util/fpsTracker.js | 51 - .../RDGE/src/core/script/util/statTracker.js | 338 --- .../RDGE/src/core/script/utilities.js | 282 ++- .../RDGE/src/tools/compile-rdge-core.bat | 2 +- .../RDGE/src/tools/compile-rdge-core.sh | 2 +- js/lib/drawing/world.js | 58 +- js/lib/geom/circle.js | 6 +- js/lib/geom/line.js | 4 +- js/lib/geom/rectangle.js | 8 +- js/lib/geom/shape-primitive.js | 4 +- js/lib/rdge/materials/bump-metal-material.js | 6 +- js/lib/rdge/materials/deform-material.js | 4 +- js/lib/rdge/materials/flat-material.js | 4 +- js/lib/rdge/materials/fly-material.js | 4 +- js/lib/rdge/materials/julia-material.js | 6 +- js/lib/rdge/materials/keleidoscope-material.js | 6 +- js/lib/rdge/materials/linear-gradient-material.js | 4 +- js/lib/rdge/materials/mandel-material.js | 6 +- js/lib/rdge/materials/plasma-material.js | 4 +- js/lib/rdge/materials/pulse-material.js | 10 +- js/lib/rdge/materials/radial-blur-material.js | 10 +- js/lib/rdge/materials/radial-gradient-material.js | 4 +- js/lib/rdge/materials/relief-tunnel-material.js | 4 +- js/lib/rdge/materials/square-tunnel-material.js | 4 +- js/lib/rdge/materials/star-material.js | 4 +- js/lib/rdge/materials/taper-material.js | 4 +- js/lib/rdge/materials/tunnel-material.js | 4 +- js/lib/rdge/materials/twist-material.js | 6 +- js/lib/rdge/materials/twist-vert-material.js | 6 +- js/lib/rdge/materials/uber-material.js | 16 +- js/lib/rdge/materials/water-material.js | 4 +- js/lib/rdge/materials/z-invert-material.js | 6 +- js/preloader/Preloader.js | 8 - 70 files changed, 8193 insertions(+), 9966 deletions(-) delete mode 100755 js/helper-classes/RDGE/src/core/script/TextureManager.js delete mode 100755 js/helper-classes/RDGE/src/core/script/input.js delete mode 100755 js/helper-classes/RDGE/src/core/script/ubershader.js delete mode 100755 js/helper-classes/RDGE/src/core/script/util/dbgpanel.js delete mode 100755 js/helper-classes/RDGE/src/core/script/util/fpsTracker.js delete mode 100755 js/helper-classes/RDGE/src/core/script/util/statTracker.js (limited to 'js') diff --git a/js/helper-classes/RDGE/runtime/GLRuntime.js b/js/helper-classes/RDGE/runtime/GLRuntime.js index 5c99be02..80162f91 100644 --- a/js/helper-classes/RDGE/runtime/GLRuntime.js +++ b/js/helper-classes/RDGE/runtime/GLRuntime.js @@ -31,8 +31,8 @@ function GLRuntime( canvas, importStr ) /////////////////////////////////////////////////////////////////////// var id = canvas.getAttribute( "data-RDGE-id" ); canvas.rdgeid = id; - g_Engine.registerCanvas(canvas, this); - RDGEStart( canvas ); + RDGE.globals.engine.registerCanvas(canvas, this); + RDGE.RDGEStart( canvas ); this.loadScene = function() { @@ -53,16 +53,16 @@ function GLRuntime( canvas, importStr ) this.init = function() { - var ctx1 = g_Engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle), - ctx2 = g_Engine.getContext(); + var ctx1 = RDGE.globals.engine.ctxMan.handleToObject(this._canvas.rdgeCtxHandle), + ctx2 = RDGE.globals.engine.getContext(); if (ctx1 != ctx2) console.log( "***** different contexts *****" ); this.renderer = ctx1.renderer; // create a camera, set its perspective, and then point it at the origin - var cam = new camera(); + var cam = new RDGE.camera(); this._camera = cam; cam.setPerspective(this.getFOV(), this.getAspect(), this.getZNear(), this.getZFar()); - cam.setLookAt([0, 0, this.getViewDistance()], [0, 0, 0], vec3.up()); + cam.setLookAt([0, 0, this.getViewDistance()], [0, 0, 0], RDGE.vec3.up()); // make this camera the active camera this.renderer.cameraManager().setActiveCamera(cam); @@ -77,17 +77,17 @@ function GLRuntime( canvas, importStr ) /* // create some lights // light 1 - this.light = createLightNode("myLight"); + this.light = RDGE.createLightNode("myLight"); this.light.setPosition([0,0,1.2]); this.light.setDiffuseColor([0.75,0.9,1.0,1.0]); // light 2 - this.light2 = createLightNode("myLight2"); + this.light2 = RDGE.createLightNode("myLight2"); this.light2.setPosition([-0.5,0,1.2]); this.light2.setDiffuseColor([1.0,0.9,0.75,1.0]); // create a light transform - var lightTr = createTransformNode("lightTr"); + var lightTr = RDGE.createTransformNode("lightTr"); // create and attach a material - materials hold the light data lightTr.attachMaterial(createMaterialNode("lights")); @@ -107,7 +107,7 @@ function GLRuntime( canvas, importStr ) // Add the scene to the engine - necessary if you want the engine to draw for you var name = "myScene" + this._canvas.getAttribute( "data-RDGE-id" ); - g_Engine.AddScene(name, this.myScene); + RDGE.globals.engine.AddScene(name, this.myScene); } // main code for handling user interaction and updating the scene @@ -119,7 +119,7 @@ function GLRuntime( canvas, importStr ) this.elapsed += dt; // changed the global position uniform of light 0, another way to change behavior of a light - rdgeGlobalParameters.u_light0Pos.set( [5*Math.cos(this.elapsed), 5*Math.sin(this.elapsed), 20]); + RDGE.rdgeGlobalParameters.u_light0Pos.set([5 * Math.cos(this.elapsed), 5 * Math.sin(this.elapsed), 20]); // orbit the light nodes around the boxes this.light.setPosition([1.2*Math.cos(this.elapsed*2.0), 1.2*Math.sin(this.elapsed*2.0), 1.2*Math.cos(this.elapsed*2.0)]); @@ -132,9 +132,9 @@ function GLRuntime( canvas, importStr ) // defining the draw function to control how the scene is rendered this.draw = function() { - g_Engine.setContext( this._canvas.rdgeid ); + RDGE.globals.engine.setContext( this._canvas.rdgeid ); - var ctx = g_Engine.getContext(); + var ctx = RDGE.globals.engine.getContext(); var renderer = ctx.renderer; if (renderer.unloadedTextureCount <= 0) { diff --git a/js/helper-classes/RDGE/src/core/script/MeshManager.js b/js/helper-classes/RDGE/src/core/script/MeshManager.js index 43813078..2c31781e 100755 --- a/js/helper-classes/RDGE/src/core/script/MeshManager.js +++ b/js/helper-classes/RDGE/src/core/script/MeshManager.js @@ -4,86 +4,80 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -function Model(name, mesh) -{ +// RDGE namespaces +var RDGE = RDGE || {}; + +RDGE.Model = function (name, mesh) { this.name = name; this.mesh = mesh; this.camera = null; -} +}; /* - * Maintains a list of meshes to allow instancing of data - */ -function MeshManager() { - this.contentUrl = "assets_web/mesh/"; - this.modelMap = {}; - this.readyList = []; // meshes that have data ready - this.meshesLoading = true; // indicates that no meshes have loaded or that they are still loading - this.postMeshLoadCallbackList = []; - this.tempSphere = null; - this.requestCounter = 0; -} +* Maintains a list of meshes to allow instancing of data +*/ +RDGE.MeshManager = function () { + this.contentUrl = "assets_web/mesh/"; + this.modelMap = {}; + this.readyList = []; // meshes that have data ready + this.meshesLoading = true; // indicates that no meshes have loaded or that they are still loading + this.postMeshLoadCallbackList = []; + this.tempSphere = null; + this.requestCounter = 0; +}; /* - * Pass the scene meshNode stump, loads temp object while real mesh is downloading - */ -MeshManager.prototype.loadMesh = function (meshStump, tempMesh) -{ +* Pass the scene meshNode stump, loads temp object while real mesh is downloading +*/ +RDGE.MeshManager.prototype.loadMesh = function (meshStump, tempMesh) { // if it exists already, return the mesh requested - if ( this.modelMap[meshStump.name] !== undefined ) + if (this.modelMap[meshStump.name] !== undefined) return this.modelMap[meshStump.name]; meshStump.ready = false; meshStump.addr = this.contentUrl + meshStump.name + "_mesh.json"; - meshStump.ctxID = g_Engine.getContext().renderer.id; - - // sets a temp mesh up in place of the final mesh to load - if (!tempMesh) - { - if (this.tempSphere == null) - { - this.tempSphere = makeSphere(g_Engine.getContext().renderer.ctx, 25, 5, 5); + meshStump.ctxID = RDGE.globals.engine.getContext().renderer.id; + + // sets a temp mesh up in place of the final mesh to load + if (!tempMesh) { + if (this.tempSphere == null) { + this.tempSphere = RDGE.renderUtils.makeSphere(RDGE.globals.engine.getContext().renderer.ctx, 25, 5, 5); } tempMesh = this.tempSphere; } - // add the temp mesh to the map of loaded meshes + // add the temp mesh to the map of loaded meshes this.modelMap[meshStump.name] = tempMesh; - + // update the request counter - we now have one more mesh to load this.requestCounter++; - requestMesh(meshStump); + RDGE.requestMesh(meshStump); return null; }; /* - * Deletes the passed mesh from the manager as well as all renderers - */ -MeshManager.prototype.deleteMesh = function (name) -{ - var model = this.modelMap[name]; - - if (model) - { - g_Engine.ctxMan.forEach(function(context) - { - context.renderer.deletePrimitive(model.primitive); - }); - - delete this.modelMap[name]; - } +* Deletes the passed mesh from the manager as well as all renderers +*/ +RDGE.MeshManager.prototype.deleteMesh = function (name) { + var model = this.modelMap[name]; + + if (model) { + RDGE.globals.engine.ctxMan.forEach(function (context) { + context.renderer.deletePrimitive(model.primitive); + }); + + delete this.modelMap[name]; + } }; -MeshManager.prototype.getModelByName = function (name) -{ +RDGE.MeshManager.prototype.getModelByName = function (name) { return this.modelMap[name]; }; -MeshManager.prototype.getModelNames = function () -{ +RDGE.MeshManager.prototype.getModelNames = function () { var names = []; for (var index in this.modelMap) { names.push(this.modelList[index].name); @@ -93,134 +87,121 @@ MeshManager.prototype.getModelNames = function () }; -MeshManager.prototype.processMeshData = function () { - var renderer = g_Engine.getContext().renderer; - +RDGE.MeshManager.prototype.processMeshData = function () { + var renderer = RDGE.globals.engine.getContext().renderer; + // loop through meshes and load ready data for (var index in this.readyList) { // if item is ready load it if (this.readyList[index] && this.readyList[index].ready && renderer.id === this.readyList[index].ctxID) { - + // pop the item var model = this.readyList[index]; this.readyList.splice(index, 1); - - var primset = new rdgePrimitiveDefinition(); - - primset.vertexDefinition = + + var primset = new RDGE.rdgePrimitiveDefinition(); + + primset.vertexDefinition = { - // this shows two ways to map this data to an attribute - "vert":{'type':rdgeConstants.VS_ELEMENT_POS, 'bufferIndex':0, 'bufferUsage': rdgeConstants.BUFFER_STATIC}, - "a_pos":{'type':rdgeConstants.VS_ELEMENT_POS, 'bufferIndex':0, 'bufferUsage': rdgeConstants.BUFFER_STATIC}, - "normal":{'type':rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex':1, 'bufferUsage': rdgeConstants.BUFFER_STATIC}, - "a_norm":{'type':rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex':1, 'bufferUsage': rdgeConstants.BUFFER_STATIC}, - "a_normal":{'type':rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex':1, 'bufferUsage': rdgeConstants.BUFFER_STATIC}, - "texcoord":{'type':rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex':2, 'bufferUsage': rdgeConstants.BUFFER_STATIC}, - "a_texcoord":{'type':rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex':2, 'bufferUsage': rdgeConstants.BUFFER_STATIC}, - "a_texcoords":{'type':rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex':2, 'bufferUsage': rdgeConstants.BUFFER_STATIC}, - "a_uv":{'type':rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex':2, 'bufferUsage': rdgeConstants.BUFFER_STATIC} + // this shows two ways to map this data to an attribute + "vert": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, + "a_pos": { 'type': RDGE.rdgeConstants.VS_ELEMENT_POS, 'bufferIndex': 0, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, + "normal": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, + "a_norm": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, + "a_normal": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT3, 'bufferIndex': 1, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, + "texcoord": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, + "a_texcoord": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, + "a_texcoords": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE.rdgeConstants.BUFFER_STATIC }, + "a_uv": { 'type': RDGE.rdgeConstants.VS_ELEMENT_FLOAT2, 'bufferIndex': 2, 'bufferUsage': RDGE