aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--credits.html9
-rw-r--r--js/mediators/io-mediator.js19
-rw-r--r--node_modules/tools/template-creator.js113
3 files changed, 137 insertions, 4 deletions
diff --git a/credits.html b/credits.html
index 1cc36c78..082eefd4 100644
--- a/credits.html
+++ b/credits.html
@@ -95,5 +95,14 @@
95 <li>License: <a href="http://www.opensource.org/licenses/mit-license.php" target="_blank">http://www.opensource.org/licenses/mit-license.php</a></li> 95 <li>License: <a href="http://www.opensource.org/licenses/mit-license.php" target="_blank">http://www.opensource.org/licenses/mit-license.php</a></li>
96 </ul> 96 </ul>
97 </div> 97 </div>
98
99 <div>
100 js-beautify
101 <ul>
102 <li>Written by Einar Lielmanis, <a href="mailto:einar@jsbeautifier.org">einar@jsbeautifier.org</a>. Python version flourished by <a href="http://github.com/satufk">Stefano Sanfilippo</a> with help from <a href="http://jason.diamond.name/weblog/">Jason&nbsp;Diamond</a>, Patrick&nbsp;Hof, Nochum&nbsp;Sossonko, Andreas&nbsp;Schneider, Dave&nbsp;Vasilevsky, <a href="http://my.opera.com/Vital/blog/">Vital&nbsp;Batmanov,</a> Ron&nbsp;Baldwin, Gabriel&nbsp;Harrison, <a href="http://shullian.com">Chris&nbsp;J.&nbsp;Shull</a>, <a href="http://mathiasbynens.be/">Mathias Bynens</a> and others.</li>
103 <li>Code from: <a href="https://github.com/einars/js-beautify" target="_blank">https://github.com/einars/js-beautify</a></li>
104 <li>License: <a href="https://github.com/einars/js-beautify/blob/master/license.txt" target="_blank">https://github.com/einars/js-beautify/blob/master/license.txt</a></li>
105 </ul>
106 </div>
98 </body> 107 </body>
99</html> \ No newline at end of file 108</html> \ No newline at end of file
diff --git a/js/mediators/io-mediator.js b/js/mediators/io-mediator.js
index 7efed29b..733e44b2 100644
--- a/js/mediators/io-mediator.js
+++ b/js/mediators/io-mediator.js
@@ -345,10 +345,21 @@ exports.IoMediator = Montage.create(Component, {
345 //////////////////////////////////////////////////////////////////// 345 ////////////////////////////////////////////////////////////////////
346 //Pretty methods (minified) 346 //Pretty methods (minified)
347 /* 347 /*
348 is-beautify javascript code courtesy of Einar Lielmanis: 348 is-beautify javascript code courtesy of Einar Lielmanis:
349 Code from https://github.com/einars/js-beautify 349 Code from https://github.com/einars/js-beautify
350 License https://github.com/einars/js-beautify/blob/master/license.txt 350 License https://github.com/einars/js-beautify/blob/master/license.txt
351 Used with author's permission 351 Used with author's permission, as stated below
352
353 Copyright (c) 2009 - 2011, Einar Lielmanis
354 Permission is hereby granted, free of charge, to any person
355 obtaining a copy of this software and associated documentation
356 files (the "Software"), to deal in the Software without
357 restriction, including without limitation the rights to use,
358 copy, modify, merge, publish, distribute, sublicense, and/or sell
359 copies of the Software, and to permit persons to whom the
360 Software is furnished to do so, subject to the following
361 conditions:The above copyright notice and this permission notice shall be
362 included in all copies or substantial portions of the Software.
352 */ 363 */
353 //For HTML, including any JS or CSS (single string/file) 364 //For HTML, including any JS or CSS (single string/file)
354 getPrettyHtml: { 365 getPrettyHtml: {
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 @@
1/* <copyright>
2 This file contains proprietary software owned by Motorola Mobility, Inc.<br/>
3 No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/>
4 (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved.
5 </copyright> */
6/**
7 @module montage/tools/template/template-creator
8 @requires montage/ui/template
9*/
10
11exports = typeof exports !== "undefined" ? exports : {};
12
13var Montage = require("montage/core/core").Montage;
14var Template = require("montage/ui/template").Template;
15
16/**
17 @class module:montage/tools/template/template-creator.TemplateCreator
18 @extends module:montage/ui/template.Template
19*/
20var TemplateCreator = exports.TemplateCreator = Montage.create(Template, /** @lends module:montage/tools/template/template-creator.TemplateCreator# */ {
21 initWithDocument: {
22 value: function(doc, montageJsPath) {
23 return this.initWithHeadAndBodyElements(doc.head, doc.body, montageJsPath);
24 }
25 },
26
27 initWithBodyElement: {
28 value: function(body, montageJsPath) {
29 return this.initWithHeadAndBodyElements(null, body, montageJsPath);
30 }
31 },
32
33 initWithHeadAndBodyElements: {
34 value: function(head, body, montageJsPath) {
35 var serializer = this.serializer,
36 objects = {},
37 components = {},
38 doc,
39 script,
40 self = this;
41
42 this._objectNamesIndex = {};
43 doc = this._document = document.implementation.createHTMLDocument("");
44
45 function copyNode(sourceNode, targetNode, isRootNode) {
46 var childNodes = sourceNode.childNodes,
47 childNode,
48 targetChildNode,
49 label,
50 script,
51 component = isRootNode ? null : sourceNode.controller;
52
53 if (component) {
54 label = self._generateLabelForComponent(component);
55 targetNode.setAttribute("id", label);
56 component._element = targetNode;
57 components[label] = component;
58 } else {
59 for (var i = 0; (childNode = childNodes[i]); i++) {
60 targetChildNode = targetNode.appendChild(childNode.cloneNode(false));
61 copyNode(childNode, targetChildNode);
62 }
63 }
64 }
65
66 if (head) {
67 doc.head.innerHTML = head.innerHTML;
68 }
69 if (montageJsPath) {
70 script = doc.createElement("script");
71 script.setAttribute("src", montageJsPath);
72 doc.head.appendChild(script);
73 doc.head.insertBefore(doc.createTextNode("\n "), script);
74 }
75
76 // try to make things look nice...
77 var html = doc.documentElement;
78 html.insertBefore(doc.createTextNode("\n"), doc.head);
79 html.insertBefore(doc.createTextNode("\n"), doc.body);
80 html.appendChild(doc.createTextNode("\n"));
81 if (!head) {
82 // the first child is the title
83 doc.head.insertBefore(doc.createTextNode("\n "), doc.head.firstChild);
84 }
85
86 copyNode(body, this._document.body, true);
87 this._ownerSerialization = serializer.serialize(components);
88 this._externalObjects = serializer.getExternalObjects();
89
90 return this;
91 }
92 },
93
94 _componentNamesIndex: {
95 value: null
96 },
97
98 _generateLabelForComponent: {value: function(component) {
99 var componentInfo = Montage.getInfoForObject(component),
100 componentLabel = componentInfo.label,
101 componentName,
102 index;
103
104 if (componentLabel) {
105 return componentLabel;
106 } else {
107 componentName = componentInfo.objectName.toLowerCase();
108 index = this._componentNamesIndex[componentName] || 1;
109 this._componentNamesIndex[componentName] = index + 1;
110 return componentName + index;
111 }
112 }},
113}); \ No newline at end of file