From a9a6d479e4f00134b32f7c3e657de3ce5cfb0c48 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Mon, 11 Jun 2012 10:27:49 -0700 Subject: Objects Panel - Add component icon and icons by type --- js/panels/objects/object.reel/object.js | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) (limited to 'js/panels/objects/object.reel/object.js') diff --git a/js/panels/objects/object.reel/object.js b/js/panels/objects/object.reel/object.js index 43abafad..1e33b7f7 100644 --- a/js/panels/objects/object.reel/object.js +++ b/js/panels/objects/object.reel/object.js @@ -13,6 +13,16 @@ var Montage = require("montage/core/core").Montage, exports.Object = Montage.create(Component, { _needsPropertyInspection : { value: null }, + type: { value: null }, + getType : { + value: function() { + if(this._hasPrototype(this.sourceObject, 'Component')) { + return 'Component'; + } + + return null; + } + }, _sourceObject : { value: null }, sourceObject : { @@ -22,8 +32,11 @@ exports.Object = Montage.create(Component, { set: function(object) { if(this._sourceObject === object) { return false; } + this._sourceObject = object; + if(object._montage_metadata) { this.montageMetaData = object._montage_metadata; + this.type = this.getType(); } this._needsPropertyInspection = this.needsDraw = true; @@ -70,8 +83,25 @@ exports.Object = Montage.create(Component, { }, + _hasPrototype : { + value: function(object, prototypeName) { + var prototypes = this.application.ninja.objectsController.getPrototypes(object).map(function(proto) { + var metadata = proto._montage_metadata; + return (metadata) ? metadata.objectName : "Object"; + }); + + return prototypes.indexOf(prototypeName) !== -1; + } + }, + draw : { value: function() { + if(this.type) { + this.element.classList.add('object-icon-'+this.type.toLowerCase()); + } else{ + this.element.classList.add('object-icon-default'); + } + } } -- cgit v1.2.3