aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Materials/materials-library-panel.reel/materials-library-panel.js')
-rwxr-xr-xjs/panels/Materials/materials-library-panel.reel/materials-library-panel.js87
1 files changed, 26 insertions, 61 deletions
diff --git a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
index b16c4376..2176c6d5 100755
--- a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
+++ b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
@@ -4,76 +4,35 @@ No rights, expressed or implied, whatsoever to this software are provided by Mot
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. 4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */ 5</copyright> */
6 6
7var Tree = require("js/components/tree.reel").Tree, 7var Montage = require("montage/core/core").Montage,
8 Button = require("js/components/button.reel").Button, 8 Component = require("montage/ui/component").Component,
9 MaterialsPopup = require("js/panels/Materials/materials-popup.reel").MaterialsPopup, 9 MaterialsData = require("js/panels/Materials/materials-data.json"),
10 PopupMananger = require("js/components/popup-manager.reel").PopupMananger,
11 Popup = require("montage/ui/popup/popup.reel").Popup; 10 Popup = require("montage/ui/popup/popup.reel").Popup;
12 11
13exports.MaterialsLibraryPanel = (require("montage/core/core").Montage).create(require("montage/ui/component").Component, { 12exports.MaterialsLibraryPanel = Montage.create(Component, {
14 13
15 _hasFocus: { 14 materialsData: {
16 enumerable: false, 15 value: null
17 value: false
18 }, 16 },
19
20 prepareForDraw: {
21 enumerable: false,
22 value: function() {
23 var treeHolderDiv = document.getElementById("materials_library_tree");
24 var materialsTree = Tree.create();
25 materialsTree.element = treeHolderDiv;
26 materialsTree.dataProvider = this._loadXMLDoc("js/panels/Materials/Materials.xml");
27 materialsTree.needsDraw = true;
28
29 materialsTree.addEventListener("change", this, true);
30 17
31 var addButton = Button.create(); 18 _hasFocus: {
32 addButton.element = document.getElementById("ml_add_btn");
33 addButton.label = "Add";
34 addButton.needsDraw = true;
35 addButton.addEventListener("action", this, true);
36
37 var copyButton = Button.create();
38 copyButton.element = document.getElementById("ml_copy_btn");
39 copyButton.label = "Copy";
40 copyButton.needsDraw = true;
41 copyButton.addEventListener("action", this, true);
42
43 var deleteButton = Button.create();
44 deleteButton.element = document.getElementById("ml_delete_btn");
45 deleteButton.label = "Delete";
46 deleteButton.needsDraw = true;
47 deleteButton.addEventListener("action", this, true);
48 }
49 },
50
51 willDraw: {
52 enumerable: false, 19 enumerable: false,
53 value: function() { 20 value: false
54
55 }
56 }, 21 },
57
58 draw: {
59 enumerable: false,
60 value: function() {
61 22
62 } 23 didCreate: {
24 value: function() {
25 this.materialsData = MaterialsData;
26 }
63 }, 27 },
64 28
65 _loadXMLDoc: { 29 prepareForDraw: {
66 value:function(dname) { 30 value : function() {
67 if (window.XMLHttpRequest) { 31 this.eventManager.addEventListener("showMaterialPopup", this, false);
68 xhttp = new XMLHttpRequest();
69 }
70 xhttp.open("GET", dname, false);
71 xhttp.send();
72 return xhttp.responseXML;
73 } 32 }
74 }, 33 },
75 34
76 captureAction: { 35 handleAction: {
77 value:function(event) { 36 value:function(event) {
78 switch(event._currentTarget.label) 37 switch(event._currentTarget.label)
79 { 38 {
@@ -90,10 +49,16 @@ exports.MaterialsLibraryPanel = (require("montage/core/core").Montage).create(re
90 } 49 }
91 }, 50 },
92 51
93 captureChange: { 52 handleNodeActivation: {
94 value:function(e) { 53 value:function(obj) {
95 var tNode = e._event.treeNode; 54 this._showMaterialPopup(obj.id);
96 this._showMaterialPopup(tNode.id); 55 }
56 },
57
58 handleShowMaterialPopup: {
59 enumerable: false,
60 value: function (event) {
61 this._showMaterialPopup(event.detail.materialId);
97 } 62 }
98 }, 63 },
99 64