From 700611c9aaee6093bbf4e86503c1decb5ac65c83 Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 27 Feb 2012 17:41:09 -0800 Subject: Fix for double clicking in the resizer Signed-off-by: Valerio Virgillito --- js/panels/Resizer.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/js/panels/Resizer.js b/js/panels/Resizer.js index 60fdde4f..ca6ed062 100755 --- a/js/panels/Resizer.js +++ b/js/panels/Resizer.js @@ -135,10 +135,13 @@ exports.Resizer = Montage.create(Component, { handleWebkitTransitionEnd: { value: function() { + if(this.redrawStage) { this.application.ninja.stage.resizeCanvases = true; } - this.panel.removeEventListener("webkitTransitionEnd"); + + this.panel.removeEventListener("webkitTransitionEnd", this, false); + } }, -- cgit v1.2.3 From 6054d13cf1254447d2396889eafc6a953f0b8d4a Mon Sep 17 00:00:00 2001 From: Valerio Virgillito Date: Mon, 27 Feb 2012 21:09:44 -0800 Subject: adding the template-creator class Signed-off-by: Valerio Virgillito --- node_modules/tools/template-creator.js | 113 +++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 node_modules/tools/template-creator.js diff --git a/node_modules/tools/template-creator.js b/node_modules/tools/template-creator.js new file mode 100644 index 00000000..6b50cc1e --- /dev/null +++ b/node_modules/tools/template-creator.js @@ -0,0 +1,113 @@ +/* + 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. +
*/ +/** + @module montage/tools/template/template-creator + @requires montage/ui/template +*/ + +exports = typeof exports !== "undefined" ? exports : {}; + +var Montage = require("montage/core/core").Montage; +var Template = require("montage/ui/template").Template; + +/** + @class module:montage/tools/template/template-creator.TemplateCreator + @extends module:montage/ui/template.Template +*/ +var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @lends module:montage/tools/template/template-creator.TemplateCreator# */ { + initWithDocument: { + value: function(doc, montageJsPath) { + return this.initWithHeadAndBodyElements(doc.head, doc.body, montageJsPath); + } + }, + + initWithBodyElement: { + value: function(body, montageJsPath) { + return this.initWithHeadAndBodyElements(null, body, montageJsPath); + } + }, + + initWithHeadAndBodyElements: { + value: function(head, body, montageJsPath) { + var serializer = this.serializer, + objects = {}, + components = {}, + doc, + script, + self = this; + + this._objectNamesIndex = {}; + doc = this._document = document.implementation.createHTMLDocument(""); + + function copyNode(sourceNode, targetNode, isRootNode) { + var childNodes = sourceNode.childNodes, + childNode, + targetChildNode, + label, + script, + component = isRootNode ? null : sourceNode.controller; + + if (component) { + label = self._generateLabelForComponent(component); + targetNode.setAttribute("id", label); + component._element = targetNode; + components[label] = component; + } else { + for (var i = 0; (childNode = childNodes[i]); i++) { + targetChildNode = targetNode.appendChild(childNode.cloneNode(false)); + copyNode(childNode, targetChildNode); + } + } + } + + if (head) { + doc.head.innerHTML = head.innerHTML; + } + if (montageJsPath) { + script = doc.createElement("script"); + script.setAttribute("src", montageJsPath); + doc.head.appendChild(script); + doc.head.insertBefore(doc.createTextNode("\n "), script); + } + + // try to make things look nice... + var html = doc.documentElement; + html.insertBefore(doc.createTextNode("\n"), doc.head); + html.insertBefore(doc.createTextNode("\n"), doc.body); + html.appendChild(doc.createTextNode("\n")); + if (!head) { + // the first child is the title + doc.head.insertBefore(doc.createTextNode("\n "), doc.head.firstChild); + } + + copyNode(body, this._document.body, true); + this._ownerSerialization = serializer.serialize(components); + this._externalObjects = serializer.getExternalObjects(); + + return this; + } + }, + + _componentNamesIndex: { + value: null + }, + + _generateLabelForComponent: {value: function(component) { + var componentInfo = Montage.getInfoForObject(component), + componentLabel = componentInfo.label, + componentName, + index; + + if (componentLabel) { + return componentLabel; + } else { + componentName = componentInfo.objectName.toLowerCase(); + index = this._componentNamesIndex[componentName] || 1; + this._componentNamesIndex[componentName] = index + 1; + return componentName + index; + } + }}, +}); \ No newline at end of file -- cgit v1.2.3