From e713d437a3918b9e417d1a0bc9f11275fc9e6634 Mon Sep 17 00:00:00 2001 From: Jose Antonio Marquez Date: Thu, 17 May 2012 12:16:43 -0700 Subject: Sharing app data in banner and html templates Syncing the files to avoid duplicates and ensure consistency. --- js/document/templates/app/main.js | 61 +++++++++++++++++++++++++ js/document/templates/app/package.json | 10 ++++ js/document/templates/banner/index.html | 2 +- js/document/templates/banner/main.js | 55 ---------------------- js/document/templates/banner/package.json | 10 ---- js/document/templates/html/index.html | 2 +- js/document/templates/html/main.js | 57 ----------------------- js/document/templates/html/package.json | 10 ---- js/document/templates/montage-html/package.json | 9 ---- 9 files changed, 73 insertions(+), 143 deletions(-) create mode 100644 js/document/templates/app/main.js create mode 100755 js/document/templates/app/package.json delete mode 100644 js/document/templates/banner/main.js delete mode 100755 js/document/templates/banner/package.json delete mode 100644 js/document/templates/html/main.js delete mode 100755 js/document/templates/html/package.json delete mode 100755 js/document/templates/montage-html/package.json (limited to 'js/document/templates') diff --git a/js/document/templates/app/main.js b/js/document/templates/app/main.js new file mode 100644 index 00000000..a406abdb --- /dev/null +++ b/js/document/templates/app/main.js @@ -0,0 +1,61 @@ +/* + 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, + Template = require("montage/ui/template").Template, + TemplateCreator = require("tools/template/template-creator").TemplateCreator; + +exports.Main = Montage.create(Component, { + + hasTemplate: { + value: false + }, + + /** + * Adding window hooks to callback into this object from Ninja. + */ + templateDidLoad: { + value: function(){ + 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.needsDraw = true; + componentInstance.ownerComponent = self; + + callback(componentInstance, element); + }) + .end(); + + }; + // + window.mjsTemplateCreator = TemplateCreator; + // + window.mjsTemplate = Template; + // + var templateEvent = document.createEvent("CustomEvent"); + templateEvent.initCustomEvent("mjsTemplateReady", false, true); + document.body.dispatchEvent(templateEvent); + + + // Dispatch event when this template has loaded. + /* + var newEvent = document.createEvent( "CustomEvent" ); + newEvent.initCustomEvent( "userTemplateDidLoad", false, true ); + document.body.dispatchEvent( newEvent ); + */ + + } + } +}); \ No newline at end of file diff --git a/js/document/templates/app/package.json b/js/document/templates/app/package.json new file mode 100755 index 00000000..4f36090a --- /dev/null +++ b/js/document/templates/app/package.json @@ -0,0 +1,10 @@ +{ + "directories": { + "lib": "" + }, + "mappings": { + "montage": "../../../../node_modules/montage/", + "tools": "../../../../node_modules/tools/", + "montage-google": "../../../../node_modules/montage-google/" + } +} \ No newline at end of file diff --git a/js/document/templates/banner/index.html b/js/document/templates/banner/index.html index 91ef06de..f1ee3d98 100755 --- a/js/document/templates/banner/index.html +++ b/js/document/templates/banner/index.html @@ -81,7 +81,7 @@ - + - +