/* 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.
*/ /** @requires montage/core/core @requires montage/ui/component */ var Montage = require("montage/core/core").Montage, Component = require("montage/ui/component").Component; 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) { if(value === this._workspaceMode) { return; } var toHide = (value !== 'binding'); setTimeout(function() { this.hide = toHide; }.bind(this), 200); this._workspaceMode = value; this.needsDraw = true; } }, _objects: { value: null }, objects: { get: function() { return this._objects; }, set: function(value) { this._objects = value; this.needsDraw = true; } }, 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; }, set : function(value) { if(value === this._hide) { return; } this._hide = value; this.needsDraw = true; } }, templateDidLoad: { value: function() { this.offStageObjectsController.filterFunction = this.offStageObjectFilter.bind(this); } }, prepareForDraw : { value: function() { Object.defineBinding(this, 'workspaceMode', { "boundObject": this.application.ninja, "boundObjectPropertyPath": "workspaceMode", "oneway": true }); Object.defineBinding(this, 'objects', { "boundObject": this.application.ninja.objectsController, "boundObjectPropertyPath": "objects", "oneway": true }); if(this.objects) { this.empty = !this.objects.length; } else { this.empty = true; } } }, draw : { value: function() { if(this.hide || this._empty) { this.element.classList.add(this.hideClass); } else { this.element.classList.remove(this.hideClass); } } } });