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 --- .../ComponentsPanelBase.css | 11 ++ .../ComponentsPanelBase.html | 34 +++++ .../ComponentsPanelBase.js | 145 +++++++++++++++++++++ 3 files changed, 190 insertions(+) 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/ComponentsPanelBase.reel') 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