From 984d65c818969ea3bef57ade9cbf5fc50d9a2316 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 --- js/components/treeview/tree-node.js | 103 ++++++++++++++++++++++++++++++++++++ 1 file changed, 103 insertions(+) create mode 100644 js/components/treeview/tree-node.js (limited to 'js/components/treeview/tree-node.js') diff --git a/js/components/treeview/tree-node.js b/js/components/treeview/tree-node.js new file mode 100644 index 00000000..689fc233 --- /dev/null +++ b/js/components/treeview/tree-node.js @@ -0,0 +1,103 @@ +/* +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; + +exports.TreeNode = Montage.create(Component, { + _labelText: { + value: "Default" + }, + labelText : { + get: function() { return this._labelText; }, + set: function(text) { + this._labelText = text; + } + }, + treeView : { + value: null, + serializable: true + }, + leafComponent: { + value: null, + serializable: true + }, + branchKey : { + serializable: true, + value: null + }, + labelKey : { + serializable: true, + value: null + }, + _sourceObject : { + value : null + }, + sourceObject : { + get : function() { + return this._sourceObject; + }, + set : function(object) { + if(!object) { + return; + } + if(object[this.branchKey]) { + object[this.branchKey].forEach(function(node) { + this.childNodes.push(node); + }, this); + } + this._sourceObject = object; + } + }, + childNodes : { + distinct: true, + value: [] + }, + isExpanded : { + distinct: true, + value: true + }, + _needsToggle : { + value: null + }, + activationEvent : { + value: null + }, + toggleExpand : { + value: function() { + if(this.isExpanded) { + this.collapse(); + this.isExpanded = false; + } else { + this.expand(); + this.isExpanded = true; + } + } + }, + expand : { + value: function() { + if(this.collapseClass) { + this.branchList.classList.remove(this.collapseClass); + } else { + this.branchList.style.display = "block"; + } + + } + }, + collapse : { + value: function() { + if(this.collapseClass) { + this.branchList.classList.add(this.collapseClass); + } else { + this.branchList.style.display = "none"; + } + + } + } + + + +}); -- cgit v1.2.3