From 9b8a24a7360416d5750828c9580e33dd336ff882 Mon Sep 17 00:00:00 2001 From: François Frisch Date: Fri, 16 Mar 2012 17:57:18 -0700 Subject: Getting ownerComponent bindings --- .../templates/montage-html/main.reel/main.js | 43 +++++++++++----------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'js/document/templates/montage-html') diff --git a/js/document/templates/montage-html/main.reel/main.js b/js/document/templates/montage-html/main.reel/main.js index 567f481c..ee23e844 100644 --- a/js/document/templates/montage-html/main.reel/main.js +++ b/js/document/templates/montage-html/main.reel/main.js @@ -17,7 +17,25 @@ exports.Main = Montage.create(Component, { */ templateDidLoad: { value: function(){ - window.addComponent = this.addComponentToUserDocument; + var self = this; + window.addComponent = function(element, data, callback) { + var component; + + component = require.async(data.path) + .then(function(component) { + var componentRequire = component[data.name]; + var componentInstance = componentRequire.create(); + + componentInstance.element = element; + //componentInstance.deserializedFromTemplate(); + componentInstance.needsDraw = true; + componentInstance.ownerComponent = self; + + callback(componentInstance, element); + }) + .end(); + + }; // window.addBinding = this.addBindingToUserDocument; // Dispatch event when this template has loaded. @@ -29,26 +47,9 @@ exports.Main = Montage.create(Component, { } }, - // Adding components to the user document by using a async require. - addComponentToUserDocument:{ - value:function(element, data, callback){ - - var component; - - component = require.async(data.path) - .then(function(component) { - var componentRequire = component[data.name]; - var componentInstance = componentRequire.create(); - - componentInstance.element = element; - //componentInstance.deserializedFromTemplate(); - componentInstance.needsDraw = true; - - callback(componentInstance, element); - }) - .end(); - - } + location: { + value:null, + enumerable:false } }); \ No newline at end of file -- cgit v1.2.3 From 9b53d2dac464cb9217b217e6707dbb97c1d65490 Mon Sep 17 00:00:00 2001 From: François Frisch Date: Sat, 17 Mar 2012 11:25:52 -0700 Subject: Deleting unecessary property --- js/document/templates/montage-html/main.reel/main.js | 6 ------ 1 file changed, 6 deletions(-) (limited to 'js/document/templates/montage-html') diff --git a/js/document/templates/montage-html/main.reel/main.js b/js/document/templates/montage-html/main.reel/main.js index ee23e844..6c141108 100644 --- a/js/document/templates/montage-html/main.reel/main.js +++ b/js/document/templates/montage-html/main.reel/main.js @@ -45,11 +45,5 @@ exports.Main = Montage.create(Component, { document.body.dispatchEvent( newEvent ); } - }, - - location: { - value:null, - enumerable:false } - }); \ No newline at end of file -- cgit v1.2.3 From 19aca6ec6f3c10922646f0ca760a375acdffaf56 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Wed, 21 Mar 2012 16:35:20 -0700 Subject: Adding 'addComponentFirstDraw' event from the user document main component. Signed-off-by: Valerio Virgillito --- js/document/templates/montage-html/main.reel/main.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'js/document/templates/montage-html') diff --git a/js/document/templates/montage-html/main.reel/main.js b/js/document/templates/montage-html/main.reel/main.js index 6c141108..2970f37a 100644 --- a/js/document/templates/montage-html/main.reel/main.js +++ b/js/document/templates/montage-html/main.reel/main.js @@ -27,16 +27,17 @@ exports.Main = Montage.create(Component, { var componentInstance = componentRequire.create(); componentInstance.element = element; - //componentInstance.deserializedFromTemplate(); + componentInstance.needsDraw = true; componentInstance.ownerComponent = self; + componentInstance.addEventListener("firstDraw", self, false); + callback(componentInstance, element); }) .end(); }; -// window.addBinding = this.addBindingToUserDocument; // Dispatch event when this template has loaded. var newEvent = document.createEvent( "CustomEvent" ); @@ -45,5 +46,14 @@ exports.Main = Montage.create(Component, { document.body.dispatchEvent( newEvent ); } + }, + + handleFirstDraw: { + value: function() { + var newEvent = document.createEvent( "CustomEvent" ); + newEvent.initCustomEvent( "addComponentFirstDraw", false, true ); + + document.body.dispatchEvent( newEvent ); + } } }); \ No newline at end of file -- cgit v1.2.3 From efcec76362a652033254fc6465dd127e8bebc04c Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 22 Mar 2012 09:57:32 -0700 Subject: Adding firstDraw event to components added This will allow us to re-parse the document for styles added dynamically. --- js/document/templates/montage-html/main.reel/main.js | 11 ----------- 1 file changed, 11 deletions(-) (limited to 'js/document/templates/montage-html') diff --git a/js/document/templates/montage-html/main.reel/main.js b/js/document/templates/montage-html/main.reel/main.js index 2970f37a..019c675e 100644 --- a/js/document/templates/montage-html/main.reel/main.js +++ b/js/document/templates/montage-html/main.reel/main.js @@ -31,8 +31,6 @@ exports.Main = Montage.create(Component, { componentInstance.needsDraw = true; componentInstance.ownerComponent = self; - componentInstance.addEventListener("firstDraw", self, false); - callback(componentInstance, element); }) .end(); @@ -46,14 +44,5 @@ exports.Main = Montage.create(Component, { document.body.dispatchEvent( newEvent ); } - }, - - handleFirstDraw: { - value: function() { - var newEvent = document.createEvent( "CustomEvent" ); - newEvent.initCustomEvent( "addComponentFirstDraw", false, true ); - - document.body.dispatchEvent( newEvent ); - } } }); \ No newline at end of file -- cgit v1.2.3