From 480c3c43f15162980390cf762411b93f7d02db19 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 9 May 2012 15:40:50 -0700 Subject: fixing the components for the new dom Signed-off-by: Valerio Virgillito --- js/document/models/html.js | 29 +++++++++++++++++++++- .../components-panel.reel/components-panel.js | 4 +-- 2 files changed, 30 insertions(+), 3 deletions(-) (limited to 'js') diff --git a/js/document/models/html.js b/js/document/models/html.js index 1639a8e2..2764a6d6 100755 --- a/js/document/models/html.js +++ b/js/document/models/html.js @@ -26,9 +26,36 @@ exports.HtmlDocumentModel = Montage.create(BaseDocumentModel, { // webGlHelper: { value: webGlDocumentHelper - } + }, //////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////// + userComponents: { + value: {} + }, + + /** + * Add a reference to a component instance to the userComponents hash using the + * element UUID + */ + setComponentInstance: { + value: function(instance, el) { + this.userComponents[el.uuid] = instance; + } + }, + + /** + * Returns the component instance obj from the element + */ + getComponentFromElement: { + value: function(el) { + if(el) { + if(el.uuid) return this.userComponents[el.uuid]; + } else { + return null; + } + } + } + }); //////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////// \ No newline at end of file diff --git a/js/panels/components-panel.reel/components-panel.js b/js/panels/components-panel.reel/components-panel.js index 4169423b..9b237229 100755 --- a/js/panels/components-panel.reel/components-panel.js +++ b/js/panels/components-panel.reel/components-panel.js @@ -278,7 +278,7 @@ exports.ComponentsPanel = Montage.create(Component, { that = this; element = this.makeComponent(component.component); - this.application.ninja.currentDocument._window.addComponent(element, {name: component.name, path: component.module}, function(instance, element) { + this.application.ninja.currentDocument.model.views.design.iframe.contentWindow.addComponent(element, {name: component.name, path: component.module}, function(instance, element) { //var pos = that.getStageCenter(); @@ -297,7 +297,7 @@ exports.ComponentsPanel = Montage.create(Component, { instance.addEventListener('firstDraw', that, false); - that.application.ninja.currentDocument.setComponentInstance(instance, element); + that.application.ninja.currentDocument.model.setComponentInstance(instance, element); that.application.ninja.elementMediator.addElements(element, styles); }); -- cgit v1.2.3