tennpipes-init 3.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +163 -0
- data/Rakefile +1 -0
- data/bin/tennpipes-init +16 -0
- data/lib/tennpipes-init.rb +73 -0
- data/lib/tennpipes-init/command.rb +18 -0
- data/lib/tennpipes-init/generators/actions.rb +630 -0
- data/lib/tennpipes-init/generators/app.rb +75 -0
- data/lib/tennpipes-init/generators/app/app.rb.tt +72 -0
- data/lib/tennpipes-init/generators/app/app.rb.tt~ +72 -0
- data/lib/tennpipes-init/generators/cli.rb +57 -0
- data/lib/tennpipes-init/generators/component.rb +73 -0
- data/lib/tennpipes-init/generators/components/actions.rb +208 -0
- data/lib/tennpipes-init/generators/components/mocks/mocha.rb +10 -0
- data/lib/tennpipes-init/generators/components/mocks/rr.rb +13 -0
- data/lib/tennpipes-init/generators/components/orms/activerecord.rb +201 -0
- data/lib/tennpipes-init/generators/components/orms/couchrest.rb +55 -0
- data/lib/tennpipes-init/generators/components/orms/datamapper.rb +140 -0
- data/lib/tennpipes-init/generators/components/orms/dynamoid.rb +67 -0
- data/lib/tennpipes-init/generators/components/orms/minirecord.rb +165 -0
- data/lib/tennpipes-init/generators/components/orms/mongoid.rb +113 -0
- data/lib/tennpipes-init/generators/components/orms/mongomapper.rb +43 -0
- data/lib/tennpipes-init/generators/components/orms/mongomatic.rb +84 -0
- data/lib/tennpipes-init/generators/components/orms/ohm.rb +65 -0
- data/lib/tennpipes-init/generators/components/orms/ripple.rb +75 -0
- data/lib/tennpipes-init/generators/components/orms/sequel.rb +99 -0
- data/lib/tennpipes-init/generators/components/renderers/erb.rb +3 -0
- data/lib/tennpipes-init/generators/components/renderers/haml.rb +3 -0
- data/lib/tennpipes-init/generators/components/renderers/liquid.rb +4 -0
- data/lib/tennpipes-init/generators/components/renderers/slim.rb +3 -0
- data/lib/tennpipes-init/generators/components/scripts/dojo.rb +10 -0
- data/lib/tennpipes-init/generators/components/scripts/extcore.rb +10 -0
- data/lib/tennpipes-init/generators/components/scripts/jquery.rb +10 -0
- data/lib/tennpipes-init/generators/components/scripts/mootools.rb +10 -0
- data/lib/tennpipes-init/generators/components/scripts/prototype.rb +12 -0
- data/lib/tennpipes-init/generators/components/scripts/rightjs.rb +10 -0
- data/lib/tennpipes-init/generators/components/stylesheets/compass.rb +39 -0
- data/lib/tennpipes-init/generators/components/stylesheets/compass/application.scss +43 -0
- data/lib/tennpipes-init/generators/components/stylesheets/compass/partials/_base.scss +12 -0
- data/lib/tennpipes-init/generators/components/stylesheets/less.rb +25 -0
- data/lib/tennpipes-init/generators/components/stylesheets/sass.rb +15 -0
- data/lib/tennpipes-init/generators/components/stylesheets/scss.rb +16 -0
- data/lib/tennpipes-init/generators/components/tests/bacon.rb +103 -0
- data/lib/tennpipes-init/generators/components/tests/cucumber.rb +86 -0
- data/lib/tennpipes-init/generators/components/tests/minitest.rb +110 -0
- data/lib/tennpipes-init/generators/components/tests/riot.rb +117 -0
- data/lib/tennpipes-init/generators/components/tests/rspec.rb +111 -0
- data/lib/tennpipes-init/generators/components/tests/shoulda.rb +114 -0
- data/lib/tennpipes-init/generators/components/tests/steak.rb +114 -0
- data/lib/tennpipes-init/generators/controller.rb +77 -0
- data/lib/tennpipes-init/generators/helper.rb +50 -0
- data/lib/tennpipes-init/generators/mailer.rb +52 -0
- data/lib/tennpipes-init/generators/migration.rb +43 -0
- data/lib/tennpipes-init/generators/model.rb +113 -0
- data/lib/tennpipes-init/generators/plugin.rb +67 -0
- data/lib/tennpipes-init/generators/project.rb +160 -0
- data/lib/tennpipes-init/generators/project/config.ru +9 -0
- data/lib/tennpipes-init/generators/project/config/apps.rb.tt +35 -0
- data/lib/tennpipes-init/generators/project/config/boot.rb +49 -0
- data/lib/tennpipes-init/generators/project/public/favicon.ico +0 -0
- data/lib/tennpipes-init/generators/project/public/images/booking.com.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/causes.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bg.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bluelogo.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_bluelogo.svg +68 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_whitelogo.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/ennkeypee_whitelogo.svg +65 -0
- data/lib/tennpipes-init/generators/project/public/images/forever21.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.eot +0 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.svg +970 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.ttf +0 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/foundation-icons.woff +0 -0
- data/lib/tennpipes-init/generators/project/public/images/icons/tennpipes-icons.css +598 -0
- data/lib/tennpipes-init/generators/project/public/images/image1.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/image11.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/image2.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/image3.jpg +0 -0
- data/lib/tennpipes-init/generators/project/public/images/intuit.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/krispykreme.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/README.md +302 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/bower.json +4 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/composer.json +34 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/gulpfile.js +92 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/holder.js +1920 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/holder.min.js +12 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/package.json +46 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/holder.js +1411 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/augment.js +27 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/ondomready.js +155 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/lib/polyfills.js +177 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/scenegraph.js +101 -0
- data/lib/tennpipes-init/generators/project/public/images/placeholders/src/utils.js +129 -0
- data/lib/tennpipes-init/generators/project/public/images/priceline.com.png +0 -0
- data/lib/tennpipes-init/generators/project/public/images/stripe.png +0 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes.min.js +6081 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.abide.js +340 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.accordion.js +67 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.alert.js +43 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.clearing.js +556 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.dropdown.js +448 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.equalizer.js +77 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.interchange.js +354 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.joyride.js +932 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.js +703 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.magellan.js +203 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.offcanvas.js +152 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.orbit.js +476 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.reveal.js +471 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.slider.js +263 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.tab.js +237 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.tooltip.js +307 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/tennpipes/tennpipes.topbar.js +452 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/fastclick.js +8 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/jquery.cookie.js +8 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/jquery.js +26 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/modernizr.js +8 -0
- data/lib/tennpipes-init/generators/project/public/javascripts/vendor/placeholder.js +2 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/app.css~ +178 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/app1.css~ +177 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/ennkeypee.css +214 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/ennkeypee.css~ +214 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/normalize.css +427 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.css +6201 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.css~ +6201 -0
- data/lib/tennpipes-init/generators/project/public/stylesheets/tennpipes.min.css +1 -0
- data/lib/tennpipes-init/generators/runner.rb +139 -0
- data/lib/tennpipes-init/generators/task.rb +45 -0
- data/lib/tennpipes-init/generators/templates/Gemfile.tt +32 -0
- data/lib/tennpipes-init/generators/templates/Rakefile.tt +8 -0
- data/lib/tennpipes-init/generators/templates/controller.rb.tt +22 -0
- data/lib/tennpipes-init/generators/templates/gem/README.md.tt +29 -0
- data/lib/tennpipes-init/generators/templates/gem/gemspec.tt +19 -0
- data/lib/tennpipes-init/generators/templates/gem/lib/libname.tt +6 -0
- data/lib/tennpipes-init/generators/templates/gem/lib/libname/version.tt +3 -0
- data/lib/tennpipes-init/generators/templates/helper.rb.tt +13 -0
- data/lib/tennpipes-init/generators/templates/initializer.rb.tt +5 -0
- data/lib/tennpipes-init/generators/templates/mailer.rb.tt +54 -0
- data/lib/tennpipes-init/generators/templates/project_bin.tt +14 -0
- data/lib/tennpipes-init/generators/templates/task.rb.tt +7 -0
- data/lib/tennpipes-init/tennpipes-tasks/activerecord.rb +377 -0
- data/lib/tennpipes-init/tennpipes-tasks/database.rb +12 -0
- data/lib/tennpipes-init/tennpipes-tasks/datamapper.rb +94 -0
- data/lib/tennpipes-init/tennpipes-tasks/minirecord.rb +19 -0
- data/lib/tennpipes-init/tennpipes-tasks/mongoid.rb +215 -0
- data/lib/tennpipes-init/tennpipes-tasks/mongomapper.rb +55 -0
- data/lib/tennpipes-init/tennpipes-tasks/sequel.rb +85 -0
- data/lib/tennpipes-init/tennpipes-tasks/sql-helpers.rb +72 -0
- data/test/fixtures/admin_template.rb +7 -0
- data/test/fixtures/example_template.rb +15 -0
- data/test/fixtures/git_template.rb +4 -0
- data/test/fixtures/plugin_template.rb +13 -0
- data/test/fixtures/rake_template.rb +9 -0
- data/test/helper.rb +103 -0
- data/test/test_app_generator.rb +142 -0
- data/test/test_cli.rb +27 -0
- data/test/test_component_generator.rb +98 -0
- data/test/test_controller_generator.rb +272 -0
- data/test/test_generator.rb +13 -0
- data/test/test_helper_generator.rb +133 -0
- data/test/test_mailer_generator.rb +69 -0
- data/test/test_migration_generator.rb +222 -0
- data/test/test_model_generator.rb +553 -0
- data/test/test_plugin_generator.rb +152 -0
- data/test/test_project_generator.rb +757 -0
- data/test/test_task_generator.rb +53 -0
- metadata +285 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
var Factory = function () {};
|
2
|
+
var slice = Array.prototype.slice;
|
3
|
+
|
4
|
+
var augment = function (base, body) {
|
5
|
+
var uber = Factory.prototype = typeof base === "function" ? base.prototype : base;
|
6
|
+
var prototype = new Factory(), properties = body.apply(prototype, slice.call(arguments, 2).concat(uber));
|
7
|
+
if (typeof properties === "object") for (var key in properties) prototype[key] = properties[key];
|
8
|
+
if (!prototype.hasOwnProperty("constructor")) return prototype;
|
9
|
+
var constructor = prototype.constructor;
|
10
|
+
constructor.prototype = prototype;
|
11
|
+
return constructor;
|
12
|
+
};
|
13
|
+
|
14
|
+
augment.defclass = function (prototype) {
|
15
|
+
var constructor = prototype.constructor;
|
16
|
+
constructor.prototype = prototype;
|
17
|
+
return constructor;
|
18
|
+
};
|
19
|
+
|
20
|
+
augment.extend = function (base, body) {
|
21
|
+
return augment(base, function (uber) {
|
22
|
+
this.uber = uber;
|
23
|
+
return body;
|
24
|
+
});
|
25
|
+
};
|
26
|
+
|
27
|
+
module.exports = augment;
|
@@ -0,0 +1,155 @@
|
|
1
|
+
/*!
|
2
|
+
* onDomReady.js 1.4.0 (c) 2013 Tubal Martin - MIT license
|
3
|
+
*
|
4
|
+
* Specially modified to work with Holder.js
|
5
|
+
*/
|
6
|
+
|
7
|
+
function _onDomReady(win) {
|
8
|
+
//Lazy loading fix for Firefox < 3.6
|
9
|
+
//http://webreflection.blogspot.com/2009/11/195-chars-to-help-lazy-loading.html
|
10
|
+
if (document.readyState == null && document.addEventListener) {
|
11
|
+
document.addEventListener("DOMContentLoaded", function DOMContentLoaded() {
|
12
|
+
document.removeEventListener("DOMContentLoaded", DOMContentLoaded, false);
|
13
|
+
document.readyState = "complete";
|
14
|
+
}, false);
|
15
|
+
document.readyState = "loading";
|
16
|
+
}
|
17
|
+
|
18
|
+
var doc = win.document,
|
19
|
+
docElem = doc.documentElement,
|
20
|
+
|
21
|
+
LOAD = "load",
|
22
|
+
FALSE = false,
|
23
|
+
ONLOAD = "on"+LOAD,
|
24
|
+
COMPLETE = "complete",
|
25
|
+
READYSTATE = "readyState",
|
26
|
+
ATTACHEVENT = "attachEvent",
|
27
|
+
DETACHEVENT = "detachEvent",
|
28
|
+
ADDEVENTLISTENER = "addEventListener",
|
29
|
+
DOMCONTENTLOADED = "DOMContentLoaded",
|
30
|
+
ONREADYSTATECHANGE = "onreadystatechange",
|
31
|
+
REMOVEEVENTLISTENER = "removeEventListener",
|
32
|
+
|
33
|
+
// W3C Event model
|
34
|
+
w3c = ADDEVENTLISTENER in doc,
|
35
|
+
_top = FALSE,
|
36
|
+
|
37
|
+
// isReady: Is the DOM ready to be used? Set to true once it occurs.
|
38
|
+
isReady = FALSE,
|
39
|
+
|
40
|
+
// Callbacks pending execution until DOM is ready
|
41
|
+
callbacks = [];
|
42
|
+
|
43
|
+
// Handle when the DOM is ready
|
44
|
+
function ready( fn ) {
|
45
|
+
if ( !isReady ) {
|
46
|
+
|
47
|
+
// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
|
48
|
+
if ( !doc.body ) {
|
49
|
+
return defer( ready );
|
50
|
+
}
|
51
|
+
|
52
|
+
// Remember that the DOM is ready
|
53
|
+
isReady = true;
|
54
|
+
|
55
|
+
// Execute all callbacks
|
56
|
+
while ( fn = callbacks.shift() ) {
|
57
|
+
defer( fn );
|
58
|
+
}
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
// The ready event handler
|
63
|
+
function completed( event ) {
|
64
|
+
// readyState === "complete" is good enough for us to call the dom ready in oldIE
|
65
|
+
if ( w3c || event.type === LOAD || doc[READYSTATE] === COMPLETE ) {
|
66
|
+
detach();
|
67
|
+
ready();
|
68
|
+
}
|
69
|
+
}
|
70
|
+
|
71
|
+
// Clean-up method for dom ready events
|
72
|
+
function detach() {
|
73
|
+
if ( w3c ) {
|
74
|
+
doc[REMOVEEVENTLISTENER]( DOMCONTENTLOADED, completed, FALSE );
|
75
|
+
win[REMOVEEVENTLISTENER]( LOAD, completed, FALSE );
|
76
|
+
} else {
|
77
|
+
doc[DETACHEVENT]( ONREADYSTATECHANGE, completed );
|
78
|
+
win[DETACHEVENT]( ONLOAD, completed );
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
// Defers a function, scheduling it to run after the current call stack has cleared.
|
83
|
+
function defer( fn, wait ) {
|
84
|
+
// Allow 0 to be passed
|
85
|
+
setTimeout( fn, +wait >= 0 ? wait : 1 );
|
86
|
+
}
|
87
|
+
|
88
|
+
// Attach the listeners:
|
89
|
+
|
90
|
+
// Catch cases where onDomReady is called after the browser event has already occurred.
|
91
|
+
// we once tried to use readyState "interactive" here, but it caused issues like the one
|
92
|
+
// discovered by ChrisS here: http://bugs.jquery.com/ticket/12282#comment:15
|
93
|
+
if ( doc[READYSTATE] === COMPLETE ) {
|
94
|
+
// Handle it asynchronously to allow scripts the opportunity to delay ready
|
95
|
+
defer( ready );
|
96
|
+
|
97
|
+
// Standards-based browsers support DOMContentLoaded
|
98
|
+
} else if ( w3c ) {
|
99
|
+
// Use the handy event callback
|
100
|
+
doc[ADDEVENTLISTENER]( DOMCONTENTLOADED, completed, FALSE );
|
101
|
+
|
102
|
+
// A fallback to window.onload, that will always work
|
103
|
+
win[ADDEVENTLISTENER]( LOAD, completed, FALSE );
|
104
|
+
|
105
|
+
// If IE event model is used
|
106
|
+
} else {
|
107
|
+
// Ensure firing before onload, maybe late but safe also for iframes
|
108
|
+
doc[ATTACHEVENT]( ONREADYSTATECHANGE, completed );
|
109
|
+
|
110
|
+
// A fallback to window.onload, that will always work
|
111
|
+
win[ATTACHEVENT]( ONLOAD, completed );
|
112
|
+
|
113
|
+
// If IE and not a frame
|
114
|
+
// continually check to see if the document is ready
|
115
|
+
try {
|
116
|
+
_top = win.frameElement == null && docElem;
|
117
|
+
} catch(e) {}
|
118
|
+
|
119
|
+
if ( _top && _top.doScroll ) {
|
120
|
+
(function doScrollCheck() {
|
121
|
+
if ( !isReady ) {
|
122
|
+
try {
|
123
|
+
// Use the trick by Diego Perini
|
124
|
+
// http://javascript.nwbox.com/IEContentLoaded/
|
125
|
+
_top.doScroll("left");
|
126
|
+
} catch(e) {
|
127
|
+
return defer( doScrollCheck, 50 );
|
128
|
+
}
|
129
|
+
|
130
|
+
// detach all dom ready events
|
131
|
+
detach();
|
132
|
+
|
133
|
+
// and execute any waiting functions
|
134
|
+
ready();
|
135
|
+
}
|
136
|
+
})();
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
function onDomReady( fn ) {
|
141
|
+
// If DOM is ready, execute the function (async), otherwise wait
|
142
|
+
isReady ? defer( fn ) : callbacks.push( fn );
|
143
|
+
}
|
144
|
+
|
145
|
+
// Add version
|
146
|
+
onDomReady.version = "1.4.0";
|
147
|
+
// Add method to check if DOM is ready
|
148
|
+
onDomReady.isReady = function(){
|
149
|
+
return isReady;
|
150
|
+
};
|
151
|
+
|
152
|
+
return onDomReady;
|
153
|
+
}
|
154
|
+
|
155
|
+
module.exports = typeof window !== "undefined" && _onDomReady(window);
|
@@ -0,0 +1,177 @@
|
|
1
|
+
//https://github.com/inexorabletash/polyfill/blob/master/web.js
|
2
|
+
if (!document.querySelectorAll) {
|
3
|
+
document.querySelectorAll = function (selectors) {
|
4
|
+
var style = document.createElement('style'), elements = [], element;
|
5
|
+
document.documentElement.firstChild.appendChild(style);
|
6
|
+
document._qsa = [];
|
7
|
+
|
8
|
+
style.styleSheet.cssText = selectors + '{x-qsa:expression(document._qsa && document._qsa.push(this))}';
|
9
|
+
window.scrollBy(0, 0);
|
10
|
+
style.parentNode.removeChild(style);
|
11
|
+
|
12
|
+
while (document._qsa.length) {
|
13
|
+
element = document._qsa.shift();
|
14
|
+
element.style.removeAttribute('x-qsa');
|
15
|
+
elements.push(element);
|
16
|
+
}
|
17
|
+
document._qsa = null;
|
18
|
+
return elements;
|
19
|
+
};
|
20
|
+
}
|
21
|
+
|
22
|
+
if (!document.querySelector) {
|
23
|
+
document.querySelector = function (selectors) {
|
24
|
+
var elements = document.querySelectorAll(selectors);
|
25
|
+
return (elements.length) ? elements[0] : null;
|
26
|
+
};
|
27
|
+
}
|
28
|
+
|
29
|
+
if (!document.getElementsByClassName) {
|
30
|
+
document.getElementsByClassName = function (classNames) {
|
31
|
+
classNames = String(classNames).replace(/^|\s+/g, '.');
|
32
|
+
return document.querySelectorAll(classNames);
|
33
|
+
};
|
34
|
+
}
|
35
|
+
|
36
|
+
//https://github.com/inexorabletash/polyfill
|
37
|
+
// ES5 15.2.3.14 Object.keys ( O )
|
38
|
+
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Object/keys
|
39
|
+
if (!Object.keys) {
|
40
|
+
Object.keys = function (o) {
|
41
|
+
if (o !== Object(o)) { throw TypeError('Object.keys called on non-object'); }
|
42
|
+
var ret = [], p;
|
43
|
+
for (p in o) {
|
44
|
+
if (Object.prototype.hasOwnProperty.call(o, p)) {
|
45
|
+
ret.push(p);
|
46
|
+
}
|
47
|
+
}
|
48
|
+
return ret;
|
49
|
+
};
|
50
|
+
}
|
51
|
+
|
52
|
+
//https://github.com/inexorabletash/polyfill/blob/master/web.js
|
53
|
+
(function (global) {
|
54
|
+
var B64_ALPHABET = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
|
55
|
+
global.atob = global.atob || function (input) {
|
56
|
+
input = String(input);
|
57
|
+
var position = 0,
|
58
|
+
output = [],
|
59
|
+
buffer = 0, bits = 0, n;
|
60
|
+
|
61
|
+
input = input.replace(/\s/g, '');
|
62
|
+
if ((input.length % 4) === 0) { input = input.replace(/=+$/, ''); }
|
63
|
+
if ((input.length % 4) === 1) { throw Error('InvalidCharacterError'); }
|
64
|
+
if (/[^+/0-9A-Za-z]/.test(input)) { throw Error('InvalidCharacterError'); }
|
65
|
+
|
66
|
+
while (position < input.length) {
|
67
|
+
n = B64_ALPHABET.indexOf(input.charAt(position));
|
68
|
+
buffer = (buffer << 6) | n;
|
69
|
+
bits += 6;
|
70
|
+
|
71
|
+
if (bits === 24) {
|
72
|
+
output.push(String.fromCharCode((buffer >> 16) & 0xFF));
|
73
|
+
output.push(String.fromCharCode((buffer >> 8) & 0xFF));
|
74
|
+
output.push(String.fromCharCode(buffer & 0xFF));
|
75
|
+
bits = 0;
|
76
|
+
buffer = 0;
|
77
|
+
}
|
78
|
+
position += 1;
|
79
|
+
}
|
80
|
+
|
81
|
+
if (bits === 12) {
|
82
|
+
buffer = buffer >> 4;
|
83
|
+
output.push(String.fromCharCode(buffer & 0xFF));
|
84
|
+
} else if (bits === 18) {
|
85
|
+
buffer = buffer >> 2;
|
86
|
+
output.push(String.fromCharCode((buffer >> 8) & 0xFF));
|
87
|
+
output.push(String.fromCharCode(buffer & 0xFF));
|
88
|
+
}
|
89
|
+
|
90
|
+
return output.join('');
|
91
|
+
};
|
92
|
+
|
93
|
+
global.btoa = global.btoa || function (input) {
|
94
|
+
input = String(input);
|
95
|
+
var position = 0,
|
96
|
+
out = [],
|
97
|
+
o1, o2, o3,
|
98
|
+
e1, e2, e3, e4;
|
99
|
+
|
100
|
+
if (/[^\x00-\xFF]/.test(input)) { throw Error('InvalidCharacterError'); }
|
101
|
+
|
102
|
+
while (position < input.length) {
|
103
|
+
o1 = input.charCodeAt(position++);
|
104
|
+
o2 = input.charCodeAt(position++);
|
105
|
+
o3 = input.charCodeAt(position++);
|
106
|
+
|
107
|
+
// 111111 112222 222233 333333
|
108
|
+
e1 = o1 >> 2;
|
109
|
+
e2 = ((o1 & 0x3) << 4) | (o2 >> 4);
|
110
|
+
e3 = ((o2 & 0xf) << 2) | (o3 >> 6);
|
111
|
+
e4 = o3 & 0x3f;
|
112
|
+
|
113
|
+
if (position === input.length + 2) {
|
114
|
+
e3 = 64; e4 = 64;
|
115
|
+
}
|
116
|
+
else if (position === input.length + 1) {
|
117
|
+
e4 = 64;
|
118
|
+
}
|
119
|
+
|
120
|
+
out.push(B64_ALPHABET.charAt(e1),
|
121
|
+
B64_ALPHABET.charAt(e2),
|
122
|
+
B64_ALPHABET.charAt(e3),
|
123
|
+
B64_ALPHABET.charAt(e4));
|
124
|
+
}
|
125
|
+
|
126
|
+
return out.join('');
|
127
|
+
};
|
128
|
+
}(this));
|
129
|
+
|
130
|
+
//https://gist.github.com/jimeh/332357
|
131
|
+
if (!Object.prototype.hasOwnProperty){
|
132
|
+
/*jshint -W001, -W103 */
|
133
|
+
Object.prototype.hasOwnProperty = function(prop) {
|
134
|
+
var proto = this.__proto__ || this.constructor.prototype;
|
135
|
+
return (prop in this) && (!(prop in proto) || proto[prop] !== this[prop]);
|
136
|
+
};
|
137
|
+
/*jshint +W001, +W103 */
|
138
|
+
}
|
139
|
+
|
140
|
+
//requestAnimationFrame polyfill for older Firefox/Chrome versions
|
141
|
+
if (!window.requestAnimationFrame) {
|
142
|
+
if (window.webkitRequestAnimationFrame) {
|
143
|
+
//https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/requestAnimationFrame/polyfill-webkit.js
|
144
|
+
(function (global) {
|
145
|
+
// window.requestAnimationFrame
|
146
|
+
global.requestAnimationFrame = function (callback) {
|
147
|
+
return webkitRequestAnimationFrame(function () {
|
148
|
+
callback(global.performance.now());
|
149
|
+
});
|
150
|
+
};
|
151
|
+
|
152
|
+
// window.cancelAnimationFrame
|
153
|
+
global.cancelAnimationFrame = webkitCancelAnimationFrame;
|
154
|
+
}(this));
|
155
|
+
} else if (window.mozRequestAnimationFrame) {
|
156
|
+
//https://github.com/Financial-Times/polyfill-service/blob/master/polyfills/requestAnimationFrame/polyfill-moz.js
|
157
|
+
(function (global) {
|
158
|
+
// window.requestAnimationFrame
|
159
|
+
global.requestAnimationFrame = function (callback) {
|
160
|
+
return mozRequestAnimationFrame(function () {
|
161
|
+
callback(global.performance.now());
|
162
|
+
});
|
163
|
+
};
|
164
|
+
|
165
|
+
// window.cancelAnimationFrame
|
166
|
+
global.cancelAnimationFrame = mozCancelAnimationFrame;
|
167
|
+
}(this));
|
168
|
+
} else {
|
169
|
+
(function (global) {
|
170
|
+
global.requestAnimationFrame = function (callback) {
|
171
|
+
return global.setTimeout(callback, 1000 / 60);
|
172
|
+
};
|
173
|
+
|
174
|
+
global.cancelAnimationFrame = global.clearTimeout;
|
175
|
+
})(this);
|
176
|
+
}
|
177
|
+
}
|
@@ -0,0 +1,101 @@
|
|
1
|
+
var augment = require('./lib/augment');
|
2
|
+
|
3
|
+
var SceneGraph = function(sceneProperties) {
|
4
|
+
var nodeCount = 1;
|
5
|
+
|
6
|
+
//todo: move merge to helpers section
|
7
|
+
function merge(parent, child) {
|
8
|
+
for (var prop in child) {
|
9
|
+
parent[prop] = child[prop];
|
10
|
+
}
|
11
|
+
return parent;
|
12
|
+
}
|
13
|
+
|
14
|
+
var SceneNode = augment.defclass({
|
15
|
+
constructor: function(name) {
|
16
|
+
nodeCount++;
|
17
|
+
this.parent = null;
|
18
|
+
this.children = {};
|
19
|
+
this.id = nodeCount;
|
20
|
+
this.name = 'n' + nodeCount;
|
21
|
+
if (name != null) {
|
22
|
+
this.name = name;
|
23
|
+
}
|
24
|
+
this.x = 0;
|
25
|
+
this.y = 0;
|
26
|
+
this.z = 0;
|
27
|
+
this.width = 0;
|
28
|
+
this.height = 0;
|
29
|
+
},
|
30
|
+
resize: function(width, height) {
|
31
|
+
if (width != null) {
|
32
|
+
this.width = width;
|
33
|
+
}
|
34
|
+
if (height != null) {
|
35
|
+
this.height = height;
|
36
|
+
}
|
37
|
+
},
|
38
|
+
moveTo: function(x, y, z) {
|
39
|
+
this.x = x != null ? x : this.x;
|
40
|
+
this.y = y != null ? y : this.y;
|
41
|
+
this.z = z != null ? z : this.z;
|
42
|
+
},
|
43
|
+
add: function(child) {
|
44
|
+
var name = child.name;
|
45
|
+
if (this.children[name] == null) {
|
46
|
+
this.children[name] = child;
|
47
|
+
child.parent = this;
|
48
|
+
} else {
|
49
|
+
throw 'SceneGraph: child with that name already exists: ' + name;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
});
|
53
|
+
|
54
|
+
var RootNode = augment(SceneNode, function(uber) {
|
55
|
+
this.constructor = function() {
|
56
|
+
uber.constructor.call(this, 'root');
|
57
|
+
this.properties = sceneProperties;
|
58
|
+
};
|
59
|
+
});
|
60
|
+
|
61
|
+
var Shape = augment(SceneNode, function(uber) {
|
62
|
+
function constructor(name, props) {
|
63
|
+
uber.constructor.call(this, name);
|
64
|
+
this.properties = {
|
65
|
+
fill: '#000'
|
66
|
+
};
|
67
|
+
if (props != null) {
|
68
|
+
merge(this.properties, props);
|
69
|
+
} else if (name != null && typeof name !== 'string') {
|
70
|
+
throw 'SceneGraph: invalid node name';
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
this.Group = augment.extend(this, {
|
75
|
+
constructor: constructor,
|
76
|
+
type: 'group'
|
77
|
+
});
|
78
|
+
|
79
|
+
this.Rect = augment.extend(this, {
|
80
|
+
constructor: constructor,
|
81
|
+
type: 'rect'
|
82
|
+
});
|
83
|
+
|
84
|
+
this.Text = augment.extend(this, {
|
85
|
+
constructor: function(text) {
|
86
|
+
constructor.call(this);
|
87
|
+
this.properties.text = text;
|
88
|
+
},
|
89
|
+
type: 'text'
|
90
|
+
});
|
91
|
+
});
|
92
|
+
|
93
|
+
var root = new RootNode();
|
94
|
+
|
95
|
+
this.Shape = Shape;
|
96
|
+
this.root = root;
|
97
|
+
|
98
|
+
return this;
|
99
|
+
};
|
100
|
+
|
101
|
+
module.exports = SceneGraph;
|