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/treeview.reel/treeview.css | 3 + js/components/treeview/treeview.reel/treeview.html | 50 ++++++++ js/components/treeview/treeview.reel/treeview.js | 129 +++++++++++++++++++++ 3 files changed, 182 insertions(+) create mode 100644 js/components/treeview/treeview.reel/treeview.css create mode 100644 js/components/treeview/treeview.reel/treeview.html create mode 100644 js/components/treeview/treeview.reel/treeview.js (limited to 'js/components/treeview/treeview.reel') diff --git a/js/components/treeview/treeview.reel/treeview.css b/js/components/treeview/treeview.reel/treeview.css new file mode 100644 index 00000000..1e3965ef --- /dev/null +++ b/js/components/treeview/treeview.reel/treeview.css @@ -0,0 +1,3 @@ + + +{} diff --git a/js/components/treeview/treeview.reel/treeview.html b/js/components/treeview/treeview.reel/treeview.html new file mode 100644 index 00000000..3d5d75c4 --- /dev/null +++ b/js/components/treeview/treeview.reel/treeview.html @@ -0,0 +1,50 @@ + + + + + + + + +
+
+
+ + \ No newline at end of file diff --git a/js/components/treeview/treeview.reel/treeview.js b/js/components/treeview/treeview.reel/treeview.js new file mode 100644 index 00000000..ebbfe685 --- /dev/null +++ b/js/components/treeview/treeview.reel/treeview.js @@ -0,0 +1,129 @@ +/* + 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.Treeview = Montage.create(Component, { + + substitution : { value : null }, + data : { value : null }, + + _hasBeenDeserialized: { + value: false, + enumerable: false + }, + + branchComponent : { + value: null, + serializable: true + }, + leafComponent : { + value: null, + serializable: true + }, + + hasTemplate: { + value: true + }, + templateDidLoad : { + value : function() { + this._initializeRootBranch(); + } + }, + _initializeRootBranch : { + value: function() { + var rootBranch; + + ///// Get user-defined branch/leaf components or use defaults + this.branchComponent = this.branchComponent || this.defaultBranchComponent; + + ///// Tell branch component what the label key is (defined in tree controller) + this.branchComponent.labelKey = this.contentController.labelKey; + + ///// Tell branch component what the branch key is (so it can recursively generate branches) + this.branchComponent.branchKey = this.contentController.branchKey; + + rootBranch = Montage.create(this.branchComponent); + rootBranch.hideLabel = !this.showRoot; + rootBranch.treeView = this; + + this.slot.content = rootBranch; + rootBranch.sourceObject = this.contentController.root; + rootBranch.needsDraw = true; + this.needsDraw = true; + + } + }, + showRoot : { + value: null + }, + + _contentController: { + enumerable: false, + value: null + }, + + contentController: { + enumerable: false, + get: function() { + return this._contentController; + }, + set: function(value) { + if (this._contentController === value) { + return; + } + + if (this._contentController) { + Object.deleteBinding(this, "selectedIndexes"); + } + + this._contentController = value; + + if (this._contentController) { + + // And bind what we need from the new contentController + var selectedIndexesBindingDescriptor; + + selectedIndexesBindingDescriptor = { + boundObject: this._contentController, + boundObjectPropertyPath: "selectedIndexes" + }; + + if (this._hasBeenDeserialized) { + Object.defineBinding(this, "selectedIndexes", selectedIndexesBindingDescriptor); + } else { + // otherwise we need to defer it until later; we haven't been deserialized yet + if (!this._controllerBindingsToInstall) { + this._controllerBindingsToInstall = {}; + } + this._controllerBindingsToInstall.selectedIndexes = selectedIndexesBindingDescriptor; + } + } + + } + }, + + deserializedFromTemplate: { + value: function() { + var controllerBindingDescriptorsToInstall = this._controllerBindingsToInstall; + + if (controllerBindingDescriptorsToInstall) { + for (var key in controllerBindingDescriptorsToInstall) { + Object.defineBinding(this, key, controllerBindingDescriptorsToInstall[key]); + } + delete this._controllerBindingsToInstall; + } + + this._hasBeenDeserialized = true; + } + }, + + selectedIndexes: { + enumerable: false, + value: null + } +}); \ No newline at end of file -- cgit v1.2.3 From c066fb41ebee85bacf9b2155366b16831af41d76 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 7 Feb 2012 13:46:05 -0800 Subject: Tree Components - Added copyright comments --- js/components/treeview/treeview.reel/treeview.css | 8 +++++--- js/components/treeview/treeview.reel/treeview.html | 5 +++++ 2 files changed, 10 insertions(+), 3 deletions(-) (limited to 'js/components/treeview/treeview.reel') diff --git a/js/components/treeview/treeview.reel/treeview.css b/js/components/treeview/treeview.reel/treeview.css index 1e3965ef..018448f1 100644 --- a/js/components/treeview/treeview.reel/treeview.css +++ b/js/components/treeview/treeview.reel/treeview.css @@ -1,3 +1,5 @@ - - -{} +/* + 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. +
*/ diff --git a/js/components/treeview/treeview.reel/treeview.html b/js/components/treeview/treeview.reel/treeview.html index 3d5d75c4..d70b016c 100644 --- a/js/components/treeview/treeview.reel/treeview.html +++ b/js/components/treeview/treeview.reel/treeview.html @@ -1,4 +1,9 @@ + -- cgit v1.2.3