From 7e94d5786df400b599df3233b3086bfe9eff2bde Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Wed, 16 May 2012 22:58:24 -0700 Subject: Objects Panel - Add Objects controller and montage/application hack to expose template --- js/controllers/objects-controller.js | 59 ++++++++++++++++++++++++++++++++++ js/ninja.reel/ninja.html | 5 +++ node_modules/montage/ui/application.js | 3 ++ 3 files changed, 67 insertions(+) create mode 100644 js/controllers/objects-controller.js diff --git a/js/controllers/objects-controller.js b/js/controllers/objects-controller.js new file mode 100644 index 00000000..70a3974c --- /dev/null +++ b/js/controllers/objects-controller.js @@ -0,0 +1,59 @@ +/* + 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; + +var objectsController = exports.ObjectsController = Montage.create(Component, { + objects : { + value: [] + }, + + handleAppLoaded : { + value: function() { + ///// Bind app's activeDocument property to + ///// objects controller's _activeDocument property + + Object.defineBinding(this, "activeDocument", { + boundObject: this.application.ninja, + boundObjectPropertyPath: "currentDocument", + oneway: true + }); + } + }, + + deserializedFromTemplate : { + value: function() { + this.eventManager.addEventListener( "appLoaded", this, false); + }, + enumerable : false + }, + + _activeDocument : { + value : null, + enumerable : false + }, + + activeDocument : { + get : function() { + return this._activeDocument; + }, + set : function(document) { + ///// If the document is null set default stylesheets to null + if(!document) { return false; } + + setTimeout(function() { + this.objects = document._document.application._template._deserializer.getObjectsFromLastDeserialization(); + }.bind(this), 1000); + + + ///// setting document via binding + this._activeDocument = document; + }, + enumerable : false + } + +}); \ No newline at end of file diff --git a/js/ninja.reel/ninja.html b/js/ninja.reel/ninja.html index 52a6daa2..7c3bc2c4 100755 --- a/js/ninja.reel/ninja.html +++ b/js/ninja.reel/ninja.html @@ -321,6 +321,10 @@ "prototype": "js/controllers/code-editor-controller" }, + "objectsController" : { + "prototype": "js/controllers/objects-controller" + }, + "owner": { "prototype": "js/ninja.reel", "properties": { @@ -350,6 +354,7 @@ "timeline": {"@": "timeline"}, "mainMenuController": {"@": "mainMenuController"}, "codeEditorController": {"@": "codeEditorController"}, + "objectsController": {"@": "objectsController"}, "rightPanelContainer": {"#": "rightPanelContainer" }, "panelSplitter": {"@": "splitter3"}, "timelineSplitter": {"@": "splitter4"}, diff --git a/node_modules/montage/ui/application.js b/node_modules/montage/ui/application.js index bbce6835..43443ecc 100755 --- a/node_modules/montage/ui/application.js +++ b/node_modules/montage/ui/application.js @@ -153,6 +153,9 @@ var Application = exports.Application = Montage.create(Montage, /** @lends monta // assign to the exports so that it is available in the deserialization of the template exports.application = self; + ///// TODO: Remove this hack when montage exposes this + this._template = template; + template.instantiateWithOwnerAndDocument(null, window.document, function() { require("ui/component").__root__.needsDraw = true; if (callback) { -- cgit v1.2.3