aboutsummaryrefslogtreecommitdiff
path: root/js/panels/Materials/materials-library-panel.reel
diff options
context:
space:
mode:
Diffstat (limited to 'js/panels/Materials/materials-library-panel.reel')
-rw-r--r--js/panels/Materials/materials-library-panel.reel/materials-library-panel.css47
-rw-r--r--js/panels/Materials/materials-library-panel.reel/materials-library-panel.html40
-rw-r--r--js/panels/Materials/materials-library-panel.reel/materials-library-panel.js205
3 files changed, 292 insertions, 0 deletions
diff --git a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.css b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.css
new file mode 100644
index 00000000..07488da1
--- /dev/null
+++ b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.css
@@ -0,0 +1,47 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6
7.materials_library_panel hr {
8 float: left;
9 clear: both;
10 width: 100%;
11 display: block;
12 background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.5, #1d1d1d), color-stop(0.75, #424242));
13 border: none;
14 height: 2px;
15 margin: 4px 0px 4px 0px;
16}
17
18
19#ml_buttons {
20 clear:both;
21 float: left;
22 margin: 0px -4px 0px 4px;
23 width: 97%;
24}
25
26#ml_buttons button {
27 height: 22px;
28 overflow: hidden;
29 display: block;
30 cursor: pointer;
31 margin: 0px 1px;
32}
33
34#materialsLibraryPanel-ml_add_btn {
35 float: left;
36 width: 60px;
37}
38
39#materialsLibraryPanel-ml_copy_btn {
40 float: left;
41 width: 60px;
42}
43
44#materialsLibraryPanel-ml_delete_btn {
45 float: right;
46 width: 60px;
47} \ No newline at end of file
diff --git a/js/panels/Materials/materials-library-panel.reel/materials-library-panel.html b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.html
new file mode 100644
index 00000000..eede02bd
--- /dev/null
+++ b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.html
@@ -0,0 +1,40 @@
1<!DOCTYPE html>
2<!-- <copyright>
3 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
4 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
5 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
6 </copyright> -->
7<html lang="en">
8 <head>
9 <meta http-equiv="content-type" content="text/html; charset=utf-8" />
10 <link rel="stylesheet" type="text/css" href="materials-library-panel.css">
11 <script type="text/montage-serialization">
12 {
13 "owner": {
14 "module": "js/panels/Materials/materials-library-panel.reel",
15 "name": "MaterialsLibraryPanels",
16 "properties": {
17 "element": {"#": "materials_library_panel"}
18 }
19 }
20
21 }
22 </script>
23
24 </head>
25 <body>
26
27 <div id="materials_library_panel" class="materials_library_panel">
28 <div id="ml_tree_holder">
29 <ul id="materials_library_tree"></ul>
30 </div>
31 <hr />
32 <div id="ml_buttons">
33 <button id="ml_add_btn">Add</button>
34 <button id="ml_copy_btn">Copy</button>
35 <button id="ml_delete_btn">Delete</button>
36 </div>
37 </div>
38
39 </body>
40</html> \ No newline at end of file
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
new file mode 100644
index 00000000..f97e1a27
--- /dev/null
+++ b/js/panels/Materials/materials-library-panel.reel/materials-library-panel.js
@@ -0,0 +1,205 @@
1/* <copyright>
2This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4(c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5</copyright> */
6
7var Tree = require("js/components/tree.reel").Tree,
8 Button = require("js/components/button.reel").Button,
9 MaterialsPopup = require("js/panels/Materials/materials-popup.reel").MaterialsPopup,
10 PopupMananger = require("js/components/popup-manager.reel").PopupMananger;
11
12exports.MaterialsLibraryPanel = (require("montage/core/core").Montage).create(require("montage/ui/component").Component, {
13
14 _hasFocus: {
15 enumerable: false,
16 value: false
17 },
18
19 prepareForDraw: {
20 enumerable: false,
21 value: function() {
22 var treeHolderDiv = document.getElementById("materials_library_tree");
23 var materialsTree = Tree.create();
24 materialsTree.element = treeHolderDiv;
25 materialsTree.dataProvider = this._loadXMLDoc("js/panels/Materials/Materials.xml");
26 materialsTree.needsDraw = true;
27
28 materialsTree.addEventListener("change", this, true);
29
30 var addButton = Button.create();
31 addButton.element = document.getElementById("ml_add_btn");
32 addButton.label = "Add";
33 addButton.needsDraw = true;
34 addButton.addEventListener("action", this, true);
35
36 var copyButton = Button.create();
37 copyButton.element = document.getElementById("ml_copy_btn");
38 copyButton.label = "Copy";
39 copyButton.needsDraw = true;
40 copyButton.addEventListener("action", this, true);
41
42 var deleteButton = Button.create();
43 deleteButton.element = document.getElementById("ml_delete_btn");
44 deleteButton.label = "Delete";
45 deleteButton.needsDraw = true;
46 deleteButton.addEventListener("action", this, true);
47 }
48 },
49
50 willDraw: {
51 enumerable: false,
52 value: function() {
53
54 }
55 },
56
57 draw: {
58 enumerable: false,
59 value: function() {
60
61 }
62 },
63
64 _loadXMLDoc: {
65 value:function(dname) {
66 if (window.XMLHttpRequest) {
67 xhttp = new XMLHttpRequest();
68 }
69 xhttp.open("GET", dname, false);
70 xhttp.send();
71 return xhttp.responseXML;
72 }
73 },
74
75 captureAction: {
76 value:function(event) {
77 switch(event._currentTarget.label)
78 {
79 case "Add":
80 console.log("Add new material");
81 break;
82 case "Copy":
83 console.log("Copy selected material");
84 break;
85 case "Delete":
86 console.log("Delete selected material");
87 break;
88 }
89 }
90 },
91
92 captureChange: {
93 value:function(e) {
94 var tNode = e._event.treeNode;
95 var left, top;
96 //TODO: Figure out if this is the best way to detect where user clicked
97 var mouseEvent = e._event.mouseEvent;
98 if (mouseEvent.clientX && mouseEvent.clientY) {
99 if (mouseEvent.clientX > (parseInt(document.width)/2)) {
100 left = mouseEvent.clientX - mouseEvent.offsetX-2;
101 top = mouseEvent.currentTarget.clientHeight/2+mouseEvent.clientY - mouseEvent.offsetY;
102 } else {
103 left = mouseEvent.clientX - mouseEvent.offsetX+parseInt(mouseEvent.currentTarget.clientWidth);
104 top = mouseEvent.clientY - mouseEvent.offsetY;
105 }