From 72efb92273d20757097b18326fb31d070a6d693d Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Tue, 19 Jun 2012 15:55:17 -0700 Subject: Objects Tray - Show only "off stage" objects --- js/controllers/objects-controller.js | 5 ++--- js/stage/objects-tray.reel/objects-tray.html | 3 ++- js/stage/objects-tray.reel/objects-tray.js | 32 +++++++++++++++++++++++++++- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/js/controllers/objects-controller.js b/js/controllers/objects-controller.js index 877f7f9f..3a6f6e97 100644 --- a/js/controllers/objects-controller.js +++ b/js/controllers/objects-controller.js @@ -4,14 +4,13 @@ (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. */ -var Montage = require("montage/core/core").Montage, - Component = require("montage/ui/component").Component; +var Montage = require("montage/core/core").Montage; var CATEGORIES = { }; -var objectsController = exports.ObjectsController = Montage.create(Component, { +var objectsController = exports.ObjectsController = Montage.create(Montage, { _currentDocument : { value : null, diff --git a/js/stage/objects-tray.reel/objects-tray.html b/js/stage/objects-tray.reel/objects-tray.html index 0fece3fe..710e3edf 100644 --- a/js/stage/objects-tray.reel/objects-tray.html +++ b/js/stage/objects-tray.reel/objects-tray.html @@ -14,7 +14,8 @@ "owner": { "prototype": "js/stage/objects-tray.reel", "properties": { - "element": {"#": "objects-tray"} + "element": {"#": "objects-tray"}, + "offStageObjectsController": {"@": "arrayController"} } }, "repetition" : { diff --git a/js/stage/objects-tray.reel/objects-tray.js b/js/stage/objects-tray.reel/objects-tray.js index 190abf57..3872c8b6 100644 --- a/js/stage/objects-tray.reel/objects-tray.js +++ b/js/stage/objects-tray.reel/objects-tray.js @@ -15,6 +15,23 @@ exports.ObjectsTray = Montage.create(Component, { hideClass : { value: 'hide-objects-tray'}, _empty : { value: null }, _workspaceMode : { value: null }, + + offStageObjectsController : { + value: null + }, + + _showAllObjects : { value: null }, + showAllObjects : { + get : function() { return this._showAllObjects; }, + set : function(value) { + if(value === this._showAllObjects) { return; } + + this._showAllObjects = value; + + this.needsDraw = true; + } + }, + workspaceMode : { get : function() { return this._workspaceMode; }, set : function(value) { @@ -43,6 +60,19 @@ exports.ObjectsTray = Montage.create(Component, { } }, + offStageObjectFilter : { + value: function(obj) { + if(this.showAllObjects) { + return true; + } + + var isComponent = this.application.ninja.objectsController._hasPrototype(obj, "Component"), + hasValidElement = obj.element && obj.element.parentNode; + + return !isComponent || !hasValidElement; + } + }, + _hide : { value: null }, hide : { get : function() { return this._hide; }, @@ -58,7 +88,7 @@ exports.ObjectsTray = Montage.create(Component, { templateDidLoad: { value: function() { - console.log('objects panel loaded'); + this.offStageObjectsController.filterFunction = this.offStageObjectFilter.bind(this); } }, -- cgit v1.2.3