Getting things ready... for dat import

This commit is contained in:
Amadeus Demarzi 2014-07-23 19:50:28 -07:00
parent d6d4cf4b39
commit 3adfc52092
12 changed files with 331 additions and 372 deletions

View File

@ -1,20 +0,0 @@
//
// app.js
//
var APP = (function() {
function initialize (){
APP.Utils.runIfClassNamePresent('page-home', initHome);
}
function initHome() {
APP.Homepage.init();
}
//api
return {
initialize: initialize
}
})();

View File

@ -1,101 +0,0 @@
//
// app.js
//
var APP = (function() {
function initialize (){
APP.Utils.runIfClassNamePresent('page-home', initHome);
}
function initHome() {
APP.Homepage.init();
}
//api
return {
initialize: initialize
}
})();
;//
// util.js
//
var APP = APP || {};
APP.Utils = (function () {
return {
//check for mobile user agents
isMobile : (function(){
if( navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
//|| navigator.userAgent.match(/iPad/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)
){
return true;
}
else {
return false;
}
})(),
runIfClassNamePresent: function(selector, initFunction) {
var elms = document.getElementsByClassName(selector);
if (elms.length > 0) {
initFunction();
}
}
}
}());;//homepage.js
var APP = APP || {};
(function () {
APP.Homepage = (function () {
return {
ui : null,
init: function () {
var _this = this;
//cache elements
this.ui = {
$doc: $(window),
$hero: $('#jumbotron'),
$collapse: $('.navbar-collapse')
}
this.addEventListeners();
},
addEventListeners: function(){
var _this = this;
if(APP.Utils.isMobile)
return;
_this.ui.$doc.scroll(function() {
//if collapseable menu is open dont do parrallax. It looks wonky. Bootstrap conflict
if( _this.ui.$collapse.hasClass('in'))
return;
var top = _this.ui.$doc.scrollTop(),
speedAdj = (top*0.8),
speedAdjOffset = speedAdj - top;
_this.ui.$hero.css('webkitTransform', 'translate(0, '+ speedAdj +'px)');
_this.ui.$hero.find('.container').css('webkitTransform', 'translate(0, '+ speedAdjOffset +'px)');
})
}
}
}());
}(jQuery, this));

View File

@ -1 +0,0 @@
var APP=function(){function a(){APP.Utils.runIfClassNamePresent("page-home",b)}function b(){APP.Homepage.init()}return{initialize:a}}(),APP=APP||{};APP.Utils=function(){return{isMobile:function(){return navigator.userAgent.match(/Android/i)||navigator.userAgent.match(/webOS/i)||navigator.userAgent.match(/iPhone/i)||navigator.userAgent.match(/iPod/i)||navigator.userAgent.match(/BlackBerry/i)||navigator.userAgent.match(/Windows Phone/i)?!0:!1}(),runIfClassNamePresent:function(a,b){var c=document.getElementsByClassName(a);c.length>0&&b()}}}();var APP=APP||{};!function(){APP.Homepage=function(){return{ui:null,init:function(){this.ui={$doc:$(window),$hero:$("#jumbotron"),$collapse:$(".navbar-collapse")},this.addEventListeners()},addEventListeners:function(){var a=this;APP.Utils.isMobile||a.ui.$doc.scroll(function(){if(!a.ui.$collapse.hasClass("in")){var b=a.ui.$doc.scrollTop(),c=.8*b,d=c-b;a.ui.$hero.css("webkitTransform","translate(0, "+c+"px)"),a.ui.$hero.find(".container").css("webkitTransform","translate(0, "+d+"px)")}})}}}()}(jQuery,this);

View File

@ -1,49 +0,0 @@
//homepage.js
var APP = APP || {};
(function () {
APP.Homepage = (function () {
return {
ui : null,
init: function () {
var _this = this;
//cache elements
this.ui = {
$doc: $(window),
$hero: $('#jumbotron'),
$collapse: $('.navbar-collapse')
}
this.addEventListeners();
},
addEventListeners: function(){
var _this = this;
if(APP.Utils.isMobile)
return;
_this.ui.$doc.scroll(function() {
//if collapseable menu is open dont do parrallax. It looks wonky. Bootstrap conflict
if( _this.ui.$collapse.hasClass('in'))
return;
var top = _this.ui.$doc.scrollTop(),
speedAdj = (top*0.8),
speedAdjOffset = speedAdj - top;
_this.ui.$hero.css('webkitTransform', 'translate(0, '+ speedAdj +'px)');
_this.ui.$hero.find('.container').css('webkitTransform', 'translate(0, '+ speedAdjOffset +'px)');
})
}
}
}());
}(jQuery, this));

View File

@ -1,33 +0,0 @@
//
// util.js
//
var APP = APP || {};
APP.Utils = (function () {
return {
//check for mobile user agents
isMobile : (function(){
if( navigator.userAgent.match(/Android/i)
|| navigator.userAgent.match(/webOS/i)
|| navigator.userAgent.match(/iPhone/i)
//|| navigator.userAgent.match(/iPad/i)
|| navigator.userAgent.match(/iPod/i)
|| navigator.userAgent.match(/BlackBerry/i)
|| navigator.userAgent.match(/Windows Phone/i)
){
return true;
}
else {
return false;
}
})(),
runIfClassNamePresent: function(selector, initFunction) {
var elms = document.getElementsByClassName(selector);
if (elms.length > 0) {
initFunction();
}
}
}
}());

View File

@ -1,158 +0,0 @@
/**
* Classy - classy classes for JavaScript
*
* :copyright: (c) 2011 by Armin Ronacher.
* :license: BSD.
*/
;(function(undefined) {
var
CLASSY_VERSION = '1.4',
root = this,
old_class = root.Class,
disable_constructor = false;
/* we check if $super is in use by a class if we can. But first we have to
check if the JavaScript interpreter supports that. This also matches
to false positives later, but that does not do any harm besides slightly
slowing calls down. */
var probe_super = (function(){$super();}).toString().indexOf('$super') > 0;
function usesSuper(obj) {
return !probe_super || /\B\$super\b/.test(obj.toString());
}
/* helper function to set the attribute of something to a value or
removes it if the value is undefined. */
function setOrUnset(obj, key, value) {
if (value === undefined)
delete obj[key];
else
obj[key] = value;
}
/* gets the own property of an object */
function getOwnProperty(obj, name) {
return Object.prototype.hasOwnProperty.call(obj, name)
? obj[name] : undefined;
}
/* instanciate a class without calling the constructor */
function cheapNew(cls) {
disable_constructor = true;
var rv = new cls;
disable_constructor = false;
return rv;
}
/* the base class we export */
var Class = function() {};
/* restore the global Class name and pass it to a function. This allows
different versions of the classy library to be used side by side and
in combination with other libraries. */
Class.$noConflict = function() {
try {
setOrUnset(root, 'Class', old_class);
}
catch (e) {
// fix for IE that does not support delete on window
root.Class = old_class;
}
return Class;
};
/* what version of classy are we using? */
Class.$classyVersion = CLASSY_VERSION;
/* extend functionality */
Class.$extend = function(properties) {
var super_prototype = this.prototype;
/* disable constructors and instanciate prototype. Because the
prototype can't raise an exception when created, we are safe
without a try/finally here. */
var prototype = cheapNew(this);
/* copy all properties of the includes over if there are any */
if (properties.__include__)
for (var i = 0, n = properties.__include__.length; i != n; ++i) {
var mixin = properties.__include__[i];
for (var name in mixin) {
var value = getOwnProperty(mixin, name);
if (value !== undefined)
prototype[name] = mixin[name];
}
}
/* copy class vars from the superclass */
properties.__classvars__ = properties.__classvars__ || {};
if (prototype.__classvars__)
for (var key in prototype.__classvars__)
if (!properties.__classvars__[key]) {
var value = getOwnProperty(prototype.__classvars__, key);
properties.__classvars__[key] = value;
}
/* copy all properties over to the new prototype */
for (var name in properties) {
var value = getOwnProperty(properties, name);
if (name === '__include__' ||
value === undefined)
continue;
prototype[name] = typeof value === 'function' && usesSuper(value) ?
(function(meth, name) {
return function() {
var old_super = getOwnProperty(this, '$super');
this.$super = super_prototype[name];
try {
return meth.apply(this, arguments);
}
finally {
setOrUnset(this, '$super', old_super);
}
};
})(value, name) : value
}
/* dummy constructor */
var rv = function() {
if (disable_constructor)
return;
var proper_this = root === this ? cheapNew(arguments.callee) : this;
if (proper_this.__init__)
proper_this.__init__.apply(proper_this, arguments);
proper_this.$class = rv;
return proper_this;
}
/* copy all class vars over of any */
for (var key in properties.__classvars__) {
var value = getOwnProperty(properties.__classvars__, key);
if (value !== undefined)
rv[key] = value;
}
/* copy prototype and constructor over, reattach $extend and
return the class */
rv.prototype = prototype;
rv.constructor = rv;
rv.$extend = Class.$extend;
rv.$withData = Class.$withData;
return rv;
};
/* instanciate with data functionality */
Class.$withData = function(data) {
var rv = cheapNew(this);
for (var key in data) {
var value = getOwnProperty(data, key);
if (value !== undefined)
rv[key] = value;
}
return rv;
};
/* export the class */
root.Class = Class;
})();

View File

@ -0,0 +1,145 @@
/*
Based on Base.js 1.1a (c) 2006-2010, Dean Edwards
Updated to pass JSHint and converted into a module by Kenneth Powers
License: http://www.opensource.org/licenses/mit-license.php
*/
/*global define:true module:true*/
/*jshint eqeqeq:true*/
(function (name, global, definition) {
if (typeof module !== 'undefined') {
module.exports = definition();
} else if (typeof define !== 'undefined' && typeof define.amd === 'object') {
define(definition);
} else {
global[name] = definition();
}
})('Base', this, function () {
// Base Object
var Base = function () {};
// Implementation
Base.extend = function (_instance, _static) { // subclass
var extend = Base.prototype.extend;
// build the prototype
Base._prototyping = true;
var proto = new this();
extend.call(proto, _instance);
proto.base = function () {
// call this method from any other method to invoke that method's ancestor
};
delete Base._prototyping;
// create the wrapper for the constructor function
//var constructor = proto.constructor.valueOf(); //-dean
var constructor = proto.constructor;
var klass = proto.constructor = function () {
if (!Base._prototyping) {
if (this._constructing || this.constructor === klass) { // instantiation
this._constructing = true;
constructor.apply(this, arguments);
delete this._constructing;
} else if (arguments[0] !== null) { // casting
return (arguments[0].extend || extend).call(arguments[0], proto);
}
}
};
// build the class interface
klass.ancestor = this;
klass.extend = this.extend;
klass.forEach = this.forEach;
klass.implement = this.implement;
klass.prototype = proto;
klass.toString = this.toString;
klass.valueOf = function (type) {
return (type === 'object') ? klass : constructor.valueOf();
};
extend.call(klass, _static);
// class initialization
if (typeof klass.init === 'function') klass.init();
return klass;
};
Base.prototype = {
extend: function (source, value) {
if (arguments.length > 1) { // extending with a name/value pair
var ancestor = this[source];
if (ancestor && (typeof value === 'function') && // overriding a method?
// the valueOf() comparison is to avoid circular references
(!ancestor.valueOf || ancestor.valueOf() !== value.valueOf()) && /\bbase\b/.test(value)) {
// get the underlying method
var method = value.valueOf();
// override
value = function () {
var previous = this.base || Base.prototype.base;
this.base = ancestor;
var returnValue = method.apply(this, arguments);
this.base = previous;
return returnValue;
};
// point to the underlying method
value.valueOf = function (type) {
return (type === 'object') ? value : method;
};
value.toString = Base.toString;
}
this[source] = value;
} else if (source) { // extending with an object literal
var extend = Base.prototype.extend;
// if this object has a customized extend method then use it
if (!Base._prototyping && typeof this !== 'function') {
extend = this.extend || extend;
}
var proto = {
toSource: null
};
// do the "toString" and other methods manually
var hidden = ['constructor', 'toString', 'valueOf'];
// if we are prototyping then include the constructor
for (var i = Base._prototyping ? 0 : 1; i < hidden.length; i++) {
var h = hidden[i];
if (source[h] !== proto[h])
extend.call(this, h, source[h]);
}
// copy each of the source object's properties to this object
for (var key in source) {
if (!proto[key]) extend.call(this, key, source[key]);
}
}
return this;
}
};
// initialize
Base = Base.extend({
constructor: function () {
this.extend(arguments[0]);
}
}, {
ancestor: Object,
version: '1.1',
forEach: function (object, block, context) {
for (var key in object) {
if (this.prototype[key] === undefined) {
block.call(context, object[key], key, object);
}
}
},
implement: function () {
for (var i = 0; i < arguments.length; i++) {
if (typeof arguments[i] === 'function') {
// if it's a function, call it
arguments[i](this.prototype);
} else {
// add the interface using the extend method
this.prototype.extend(arguments[i]);
}
}
return this;
},
toString: function () {
return String(this.valueOf());
}
});
// Return Base implementation
return Base;
});

View File

@ -0,0 +1,14 @@
(function(String){
if (String.prototype.substitute) {
return;
}
String.prototype.substitute = function(object, regexp){
return String(this).replace(regexp || (/\\?\{([^{}]+)\}/g), function(match, name){
if (match.charAt(0) == '\\') return match.slice(1);
return (object[name] !== null) ? object[name] : '';
});
};
})(String);

View File

@ -0,0 +1,111 @@
(function(global){ 'use strict';
var Vector = function(x, y){
this.x = x || 0;
this.y = y || 0;
};
Vector.prototype = {
clone: function(){
return new Vector(this.x, this.y);
},
add: function(vec){
this.x += vec.x;
this.y += vec.y;
return this;
},
sub: function(vec){
this.x -= vec.x;
this.y -= vec.y;
return this;
},
subVal: function(val){
this.x -= val;
this.y -= val;
return this;
},
mult: function(mul){
this.x *= mul;
this.y *= mul;
return this;
},
div: function(div){
if (div === 0) {
return this;
}
this.x /= div;
this.y /= div;
return this;
},
mag: function(){
return Math.sqrt(
this.x * this.x +
this.y * this.y
);
},
limit: function(max){
if (this.mag() > max) {
this.normalize();
this.mult(max);
}
return this;
},
normalize: function(){
var mag = this.mag();
if (mag === 0) {
return this;
}
this.div(mag);
return this;
},
heading: function(){
return Math.atan2(this.y, this.x);
},
set: function(vec){
this.x = vec.x;
this.y = vec.y;
return this;
}
};
Vector.add = function(vec1, vec2){
return vec1.clone().add(vec2.clone());
};
Vector.sub = function(vec1, vec2){
return vec1.clone().sub(vec2.clone());
};
Vector.mult = function(vec, mult){
return vec.clone().mult(mult);
};
Vector.div = function(vec, div){
return vec.clone().div(div);
};
// Ripped from processing
Vector.random2D = function(){
var angle = Math.random(0, 1) * Math.PI * 2;
return new Vector(Math.cos(angle), Math.sin(angle));
};
Vector.coerce = function(obj){
return new Vector(obj.x, obj.y);
};
global.Vector = Vector;
})(this);

View File

@ -0,0 +1,60 @@
/*
*
* name: dbg
*
* description: A bad ass little console utility, check the README for deets
*
* license: MIT-style license
*
* author: Amadeus Demarzi
*
* provides: window.dbg
*
*/
(function(){
var global = this,
// Get the real console or set to null for easy boolean checks
realConsole = global.console || null,
// Backup / Disabled Lambda
fn = function(){},
// Supported console methods
methodNames = ['log', 'error', 'warn', 'info', 'count', 'debug', 'profileEnd', 'trace', 'dir', 'dirxml', 'assert', 'time', 'profile', 'timeEnd', 'group', 'groupEnd'],
// Disabled Console
disabledConsole = {
// Enables dbg, if it exists, otherwise it just provides disabled
enable: function(quiet){
global.dbg = realConsole ? realConsole : disabledConsole;
},
// Disable dbg
disable: function(){
global.dbg = disabledConsole;
}
}, name, i;
// Setup disabled console and provide fallbacks on the real console
for (i = 0; i < methodNames.length;i++){
name = methodNames[i];
disabledConsole[name] = fn;
if (realConsole && !realConsole[name])
realConsole[name] = fn;
}
// Add enable/disable methods
if (realConsole) {
realConsole.disable = disabledConsole.disable;
realConsole.enable = disabledConsole.enable;
}
// Enable dbg
disabledConsole.enable();
}).call(this);

View File

@ -19,14 +19,5 @@
</div> </div>
</div> </div>
</div> </div>
<script src="/javascripts/lib/jquery-2.0.3.min.js"></script>
<script src="/javascripts/lib/bootstrap.min.js"></script>
<script src="/javascripts/app/deploy/site.js"></script>
<script>
APP.initialize();
</script>
</body> </body>
</html> </html>

View File

@ -8,7 +8,7 @@
@jumbotron-height: 804px; @jumbotron-height: 804px;
@header-height: 90px; @header-height: 90px;
@jumbotron-total-height: 804px; //jumbo+header @jumbotron-total-height: 700px; //jumbo+header
@jumbotron-color: #fff; @jumbotron-color: #fff;
@btn-border-radius: 4px; @btn-border-radius: 4px;
@el-border-radius: 6px; @el-border-radius: 6px;