From b89a7ee8b956c96a1dcee995ea840feddc5d4b27 Mon Sep 17 00:00:00 2001 From: Pierre Frisch Date: Thu, 22 Dec 2011 07:25:50 -0800 Subject: First commit of Ninja to ninja-internal Signed-off-by: Valerio Virgillito --- js/panels/Components/Components.xml | 28 ++++ js/panels/Components/ComponentsPanel.js | 47 +++++++ .../ComponentsPanelBase.css | 11 ++ .../ComponentsPanelBase.html | 34 +++++ .../ComponentsPanelBase.js | 145 +++++++++++++++++++++ 5 files changed, 265 insertions(+) create mode 100644 js/panels/Components/Components.xml create mode 100644 js/panels/Components/ComponentsPanel.js create mode 100644 js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.css create mode 100644 js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html create mode 100644 js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js (limited to 'js/panels/Components') diff --git a/js/panels/Components/Components.xml b/js/panels/Components/Components.xml new file mode 100644 index 00000000..b3056330 --- /dev/null +++ b/js/panels/Components/Components.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/js/panels/Components/ComponentsPanel.js b/js/panels/Components/ComponentsPanel.js new file mode 100644 index 00000000..df1d74bb --- /dev/null +++ b/js/panels/Components/ComponentsPanel.js @@ -0,0 +1,47 @@ +/* +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 new file mode 100644 index 00000000..ac250c83 --- /dev/null +++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.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/ComponentsPanelBase.reel/ComponentsPanelBase.html b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html new file mode 100644 index 00000000..df104ecc --- /dev/null +++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.html @@ -0,0 +1,34 @@ + + + + + + + + + + + + +
+
+
    +
    +
    + + + \ No newline at end of file diff --git a/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js new file mode 100644 index 00000000..41afefa5 --- /dev/null +++ b/js/panels/Components/ComponentsPanelBase.reel/ComponentsPanelBase.js @@ -0,0 +1,145 @@ +/* +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 ComponentsPanelBase = exports.ComponentsPanelBase = Montage.create(Component, { + _hasFocus: { + enumerable: false, + value: false + }, + prepareForDraw: { + enumerable: false, + value: function() { + var treeHolderDiv = document.getElementById("comp_tree"); + var componentsTree = treeControlModule.Tree.create(); + componentsTree.element = treeHolderDiv; + componentsTree.dataProvider = this._loadXMLDoc("js/panels/Components/Components.xml"); + componentsTree.needsDraw = true; + + this.eventManager.addEventListener( "executeAddComponent", this, false); + } + }, + willDraw: { + enumerable: false, + value: function() { + + } + }, + draw: { + enumerable: false, + value: function() { + + } + }, + + _loadXMLDoc: { + value:function(dname) { + if (window.XMLHttpRequest) { + xhttp = new XMLHttpRequest(); + } + xhttp.open("GET", dname, false); + xhttp.send(); + return xhttp.responseXML; + } + }, + + handleExecuteAddComponent: { + value: function(evt) { + this.addComponentToStage(evt.detail.component, evt.detail.dropX, evt.detail.dropY) + } + }, + + addComponentToStage:{ + value:function(componentType, dropX, dropY){ + var compW = 100, + compH = 100, + elementType = "div", + componentContainer, + componentElement; + + if(componentType == "Button"){ + compW = 118; + compH = 52; + }else if(componentType == "Checkbox"){ + compW = 53; + compH = 53; +// elementType = "input"; + }else if(componentType == "DynamicText"){ + compW = 100; + compH = 20; + }else if(componentType == "FlowController"){ + compW = 800; + compH = 320; + }else if(componentType == "HotText"){ + compW = 50; + compH = 18; +// elementType = "input"; + }else if(componentType == "HotTextUnit"){ + compW = 45; + compH = 18; + }else if(componentType == "ImageContainer"){ + compW = 285; + compH = 232; + }else if(componentType == "Progress"){ + compW = 300; + compH = 9; + }else if(componentType == "Scrollview"){ + compW = 200; + compH = 200; + }else if(componentType == "Slider"){ + compW = 200; + compH = 55; + }else if(componentType == "TextArea"){ + compW = 312; + compH = 112; + elementType = "textarea"; + }else if(componentType == "Textfield"){ + compW = 312; + compH = 34; + elementType = "input"; + }else if(componentType == "Toggle"){ + compW = 60; + compH = 22; + elementType = "span"; + }else if(componentType == "ToggleButton"){ + compW = 118; + compH = 52; + }else{ + compW = 100; + compH = 25; + } + + componentContainer = NJUtils.makeNJElement("div", componentType, "component"); + componentContainer.elementModel.isComponent = true; + + var styles = { + 'position': 'absolute', + 'top' : dropY + 'px', + 'left' : dropX + 'px', + 'width' : compW + 'px', + 'height' : compH + '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)' + }; + + + componentElement = NJUtils.makeNJElement(elementType, "ComponentDiv", "block"); + + componentContainer.appendChild(componentElement); + + NJevent("elementAdding", {"el": componentContainer, "data":styles}); + + var componentRef = this.application.ninja.currentDocument._window.addComponent(componentElement, componentType); + this.application.ninja.currentDocument._userComponentSet[componentContainer.uuid] = componentRef; + + } + } +}); \ No newline at end of file -- cgit v1.2.3