diff options
Diffstat (limited to 'js/panels/Materials/materials-library-panel.reel/materials-library-panel.js')
-rwxr-xr-x | js/panels/Materials/materials-library-panel.reel/materials-library-panel.js | 154 |
1 files changed, 123 insertions, 31 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 b5d6bb96..aef48230 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 | |||
@@ -1,24 +1,25 @@ | |||
1 | /* <copyright> | 1 | /* <copyright> |
2 | Copyright (c) 2012, Motorola Mobility, Inc | 2 | Copyright (c) 2012, Motorola Mobility LLC. |
3 | All Rights Reserved. | 3 | All Rights Reserved. |
4 | BSD License. | ||
5 | 4 | ||
6 | Redistribution and use in source and binary forms, with or without | 5 | Redistribution and use in source and binary forms, with or without |
7 | modification, are permitted provided that the following conditions are met: | 6 | modification, are permitted provided that the following conditions are met: |
8 | 7 | ||
9 | - Redistributions of source code must retain the above copyright notice, | 8 | * Redistributions of source code must retain the above copyright notice, |
10 | this list of conditions and the following disclaimer. | 9 | this list of conditions and the following disclaimer. |
11 | - Redistributions in binary form must reproduce the above copyright | 10 | |
12 | notice, this list of conditions and the following disclaimer in the | 11 | * Redistributions in binary form must reproduce the above copyright notice, |
13 | documentation and/or other materials provided with the distribution. | 12 | this list of conditions and the following disclaimer in the documentation |
14 | - Neither the name of Motorola Mobility nor the names of its contributors | 13 | and/or other materials provided with the distribution. |
15 | may be used to endorse or promote products derived from this software | 14 | |
16 | without specific prior written permission. | 15 | * Neither the name of Motorola Mobility LLC nor the names of its |
16 | contributors may be used to endorse or promote products derived from this | ||
17 | software without specific prior written permission. | ||
17 | 18 | ||
18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | 20 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | 21 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
21 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE | 22 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
22 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | 23 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
23 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | 24 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
24 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | 25 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
@@ -31,17 +32,39 @@ POSSIBILITY OF SUCH DAMAGE. | |||
31 | var Montage = require("montage/core/core").Montage, | 32 | var Montage = require("montage/core/core").Montage, |
32 | Component = require("montage/ui/component").Component, | 33 | Component = require("montage/ui/component").Component, |
33 | MaterialsData = require("js/panels/Materials/materials-data.json"), | 34 | MaterialsData = require("js/panels/Materials/materials-data.json"), |
34 | Popup = require("montage/ui/popup/popup.reel").Popup; | 35 | Popup = require("montage/ui/popup/popup.reel").Popup, |
36 | MaterialsModel = require("js/models/materials-model").MaterialsModel, | ||
37 | LeafNode = require("js/components/treeview/ninja-leaf.reel").Leaf; | ||
35 | 38 | ||
36 | exports.MaterialsLibraryPanel = Montage.create(Component, { | 39 | exports.MaterialsLibraryPanel = Montage.create(Component, { |
37 | 40 | ||
41 | deleteButton: { | ||
42 | value: null | ||
43 | }, | ||
44 | |||
38 | materialsData: { | 45 | materialsData: { |
39 | value: null | 46 | value: null |
40 | }, | 47 | }, |
41 | 48 | ||
49 | materialId: { | ||
50 | value: null | ||
51 | }, | ||
52 | |||
53 | selectedMaterialNode: { | ||
54 | value: null | ||
55 | }, | ||
56 | |||
57 | customMaterialsBranch: { | ||
58 | value: null | ||
59 | }, | ||
60 | |||
61 | customMaterialsCounter: { | ||
62 | value: 2 | ||
63 | }, | ||
64 | |||
42 | _hasFocus: { | 65 | _hasFocus: { |
43 | enumerable: false, | 66 | enumerable: false, |
44 | value: false | 67 | value: false |
45 | }, | 68 | }, |
46 | 69 | ||
47 | didCreate: { | 70 | didCreate: { |
@@ -60,21 +83,32 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { | |||
60 | value:function(event) { | 83 | value:function(event) { |
61 | switch(event._currentTarget.label) | 84 | switch(event._currentTarget.label) |
62 | { | 85 | { |
63 | case "Add": | 86 | case "Duplicate": |
64 | console.log("Add new material"); | 87 | this.duplicateMaterial(); |
65 | break; | 88 | break; |
66 | case "Copy": | 89 | case "Edit": |
67 | console.log("Copy selected material"); | 90 | // console.log("Edit selected material"); |
91 | this._showMaterialPopup({ materialId: this.materialId }); | ||
68 | break; | 92 | break; |
69 | case "Delete": | 93 | case "Delete": |
70 | console.log("Delete selected material"); | 94 | this.deleteMaterial(); |
71 | break; | 95 | break; |
72 | } | 96 | } |
73 | } | 97 | } |
74 | }, | 98 | }, |
75 | 99 | ||
76 | handleNodeActivation: { | 100 | handleNodeActivation: { |
77 | value:function(obj) { | 101 | value: function(obj, event) { |
102 | this.selectedMaterialNode = event.currentTarget; | ||
103 | this.materialId = obj.id; | ||
104 | this.deleteButton.enabled = !!obj.canDelete; | ||
105 | } | ||
106 | }, | ||
107 | |||
108 | handleDblclick: { | ||
109 | value:function(obj, event) { | ||
110 | this.selectedMaterialNode = event.currentTarget; | ||
111 | this.materialId = obj.id; | ||
78 | this._showMaterialPopup({ materialId: obj.id }); | 112 | this._showMaterialPopup({ materialId: obj.id }); |
79 | } | 113 | } |
80 | }, | 114 | }, |
@@ -82,7 +116,6 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { | |||
82 | handleShowMaterialPopup: { | 116 | handleShowMaterialPopup: { |
83 | enumerable: false, | 117 | enumerable: false, |
84 | value: function (event) { | 118 | value: function (event) { |
85 | //this._showMaterialPopup(event.detail.materialId); | ||
86 | this._showMaterialPopup(event.detail); | 119 | this._showMaterialPopup(event.detail); |
87 | } | 120 | } |
88 | }, | 121 | }, |
@@ -96,32 +129,91 @@ exports.MaterialsLibraryPanel = Montage.create(Component, { | |||
96 | enumerable:true, | 129 | enumerable:true, |
97 | serializable: true | 130 | serializable: true |
98 | }, | 131 | }, |
99 | 132 | ||
100 | _showMaterialPopup: { | 133 | _showMaterialPopup: { |
101 | enumerable: false, | 134 | enumerable: false, |
102 | value: function (materialObj) { | 135 | value: function (materialObj) { |
103 | 136 | ||
104 | if(!this._materialPopup) | 137 | if(!this._materialPopup) |
105 | { | 138 | { |
106 | this._materialPopup = Popup.create(); | 139 | this._materialPopup = Popup.create(); |
140 | this._materialInfo.materialsLibraryRef = this; | ||
107 | this._materialPopup.content = this._materialInfo; | 141 | this._materialPopup.content = this._materialInfo; |
142 | this._materialPopup.delegate = this; | ||
108 | this._materialPopup.modal = false; | 143 | this._materialPopup.modal = false; |
109 | this.eventManager.addEventListener("hideMaterialPopup", this, false); | 144 | this.eventManager.addEventListener("hideMaterialPopup", this, false); |
110 | this._materialPopup.addEventListener("show", this, false); | 145 | this._materialPopup.addEventListener("show", this, false); |
111 | } | 146 | } |
112 | this._materialPopup.show(); | 147 | this._materialPopup.show(); |
113 | 148 | ||
114 | materialID = materialObj.materialId; | 149 | this._materialInfo.loadMaterials(materialObj.materialId, materialObj.useSelection, materialObj.whichMaterial); |
115 | this._materialInfo.loadMaterials(materialID, materialObj.useSelection, materialObj.whichMaterial); | 150 | } |
116 | } | ||
117 | }, | 151 | }, |
118 | 152 | ||
119 | handleHideMaterialPopup: { | 153 | handleHideMaterialPopup: { |
120 | enumerable: false, | 154 | enumerable: false, |
121 | value: function (event) { | 155 | value: function (event) { |
122 | if(this._materialPopup){ | 156 | if(this._materialPopup){ |
157 | // console.log("hiding material popup"); | ||
158 | this._materialInfo.destroy(); | ||
123 | this._materialPopup.hide(); | 159 | this._materialPopup.hide(); |
124 | } | 160 | <