From 1f7c17d688c3340b31d2e1c2b7205b10bd806968 Mon Sep 17 00:00:00 2001 From: Eric Guzman Date: Fri, 25 May 2012 16:37:24 -0700 Subject: Objects Controller - Now keeps track of document's object instances, including added components --- js/document/models/html.js | 5 +++++ js/document/templates/app/main.js | 1 + js/document/views/design.js | 6 +++++- 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'js/document') diff --git a/js/document/models/html.js b/js/document/models/html.js index 9cc8ce92..10112565 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -69,6 +69,7 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { setComponentInstance: { value: function(instance, el) { this.userComponents[el.uuid] = instance; + this.objects.push(instance); } }, //////////////////////////////////////////////////////////////////// @@ -81,6 +82,10 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { return null; } } + }, + //////////////////////////////////////////////////////////////////// + objects : { + value: null } //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// diff --git a/js/document/templates/app/main.js b/js/document/templates/app/main.js index a406abdb..91c46fda 100644 --- a/js/document/templates/app/main.js +++ b/js/document/templates/app/main.js @@ -29,6 +29,7 @@ exports.Main = Montage.create(Component, { var componentRequire = component[data.name]; var componentInstance = componentRequire.create(); + componentInstance._montage_metadata.label = data.name; componentInstance.element = element; componentInstance.needsDraw = true; diff --git a/js/document/views/design.js b/js/document/views/design.js index b3887fdf..75eb3695 100755 --- a/js/document/views/design.js +++ b/js/document/views/design.js @@ -363,11 +363,15 @@ exports.DesignDocumentView = Montage.create(BaseDocumentView, { initMontage: { value: function (scripttags) { // + //debugger; this.iframe.contentWindow.document.body.addEventListener('mjsTemplateReady', function () { //Initializing template with user's seriliazation var template = this.iframe.contentWindow.mjsTemplate.create(); + template.initWithDocument(this.iframe.contentWindow.document); - template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (e){/*Nothing just a required extra parameter*/}); + template.instantiateWithOwnerAndDocument(null, this.iframe.contentWindow.document, function (e){ + this.model.objects = template.deserializer.getObjectsFromLastDeserialization(); + }.bind(this)); }.bind(this), false); } }, -- cgit v1.2.3