From 673cf363ccc0a0e82237c8a1867d250b6769d9f6 Mon Sep 17 00:00:00 2001
From: Eric Guzman
Date: Mon, 6 Feb 2012 11:43:01 -0800
Subject: Tree Components - Adding the tree components

---
 .../treeview/ninja-leaf.reel/ninja-leaf.css        | 22 ++++++++++++
 .../treeview/ninja-leaf.reel/ninja-leaf.html       | 38 ++++++++++++++++++++
 .../treeview/ninja-leaf.reel/ninja-leaf.js         | 41 ++++++++++++++++++++++
 3 files changed, 101 insertions(+)
 create mode 100644 js/components/treeview/ninja-leaf.reel/ninja-leaf.css
 create mode 100644 js/components/treeview/ninja-leaf.reel/ninja-leaf.html
 create mode 100644 js/components/treeview/ninja-leaf.reel/ninja-leaf.js

(limited to 'js/components/treeview/ninja-leaf.reel')

diff --git a/js/components/treeview/ninja-leaf.reel/ninja-leaf.css b/js/components/treeview/ninja-leaf.reel/ninja-leaf.css
new file mode 100644
index 00000000..0ad10c4c
--- /dev/null
+++ b/js/components/treeview/ninja-leaf.reel/ninja-leaf.css
@@ -0,0 +1,22 @@
+.treeRoot .leaf-label {
+    background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAANCAIAAAD9iXMrAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyRpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw%2FeHBhY2tldCBiZWdpbj0i77u%2FIiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8%2BIDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYxIDY0LjE0MDk0OSwgMjAxMC8xMi8wNy0xMDo1NzowMSAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YW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: 3px center;
+    background-repeat: no-repeat;
+    border-bottom: 1px solid #505050;
+    cursor: pointer;
+    padding: 3px 0 4px;
+}
+/* First level */
+.branch .leaf-label {
+    padding-left: 25px;
+}
+/* Second level */
+.branch .branch .leaf-label {
+    background-position: 25px center;
+    padding-left: 45px;
+}
+/* Third level */
+.branch .branch .branch .leaf-label {
+    background-position: 45px center;
+    padding-left: 65px;
+}
\ No newline at end of file
diff --git a/js/components/treeview/ninja-leaf.reel/ninja-leaf.html b/js/components/treeview/ninja-leaf.reel/ninja-leaf.html
new file mode 100644
index 00000000..0a8fdac0
--- /dev/null
+++ b/js/components/treeview/ninja-leaf.reel/ninja-leaf.html
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    	<meta http-equiv="content-type" content="text/html; charset=utf-8" />
+        <link href="ninja-leaf.css" rel="stylesheet" type="text/css" />
+        <script type="text/montage-serialization">
+        {
+            "owner": {
+                "module" : "js/components/treeview/ninja-leaf.reel",
+                "name" : "Leaf",
+                "properties" : {
+                    "element" : {"#" : "leaf"},
+                    "label" : { "@" : "textComponent" }
+                }
+            },
+            "textComponent" : {
+                "module" : "montage/ui/dynamic-text.reel",
+                "name" : "DynamicText",
+                "properties" : {
+                    "element" : { "#" : "label" }
+                },
+                "bindings" : {
+                    "value" : {
+                        "boundObject" : {"@": "owner"},
+                        "boundObjectPropertyPath": "_labelText",
+                        "oneway": true
+                    }
+                }
+            }
+    	}
+		</script>
+</head>
+<body>
+    <div id="leaf" class="leaf">
+        <div id="label" class="leaf-label"></div>
+    </div>
+</body>
+</html>
\ No newline at end of file
diff --git a/js/components/treeview/ninja-leaf.reel/ninja-leaf.js b/js/components/treeview/ninja-leaf.reel/ninja-leaf.js
new file mode 100644
index 00000000..bd566b26
--- /dev/null
+++ b/js/components/treeview/ninja-leaf.reel/ninja-leaf.js
@@ -0,0 +1,41 @@
+/* <copyright>
+This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
+No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
+(c) Copyright 2011 Motorola Mobility, Inc.  All Rights Reserved.
+</copyright> */
+
+var Montage   = require("montage/core/core").Montage,
+    Component = require("montage/ui/component").Component;
+    TreeNode = require("js/components/treeview/tree-node").TreeNode;
+
+exports.Leaf = Montage.create(TreeNode, {
+    hasTemplate: {
+        value: true
+    },
+    templateDidLoad : {
+        value: function() {
+            this.needsDraw = true;
+        }
+    },
+    prepareForDraw: {
+        value : function() {
+            this.activationEvent = this.activationEvent || 'click';
+            this.label._element.addEventListener(this.activationEvent, this.handleNodeActivation.bind(this), false);
+        }
+    },
+    handleNodeActivation: {
+        value: function(e) {
+            console.log(this.sourceObject);
+            this.treeView.contentController.delegate.applyPresetSelection(this.sourceObject);
+        }
+    },
+    draw : {
+        value : function() {
+            if(this.sourceObject[this.labelKey]) {
+                this._labelText = this.sourceObject[this.labelKey];
+            }
+        }
+    }
+
+
+});
-- 
cgit v1.2.3