From d66b53e79e78f52eda8a582f5e9d07e778ef1cda Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Mon, 20 Mar 2017 01:25:42 -0400 Subject: [PATCH] Remove unused javascript It looks like these came over from Nomad(?), but we do not use them anywhere. This saves about 4kb on the compressed javascript, so it's a big savings. Also, it causes namespace conflicts. --- .../assets/javascripts/app/DotLockup.js | 130 ---- website/source/assets/javascripts/app/Init.js | 66 -- .../source/assets/javascripts/application.js | 9 - .../assets/javascripts/jquery.waypoints.js | 647 ------------------ website/source/assets/javascripts/lib/Base.js | 145 ---- .../assets/javascripts/lib/Chainable.js | 92 --- .../lib/Function.prototype.bind.js | 21 - .../javascripts/lib/String.substitute.js | 14 - website/source/assets/javascripts/lib/dbg.js | 60 -- 9 files changed, 1184 deletions(-) delete mode 100644 website/source/assets/javascripts/app/DotLockup.js delete mode 100644 website/source/assets/javascripts/app/Init.js delete mode 100755 website/source/assets/javascripts/jquery.waypoints.js delete mode 100644 website/source/assets/javascripts/lib/Base.js delete mode 100644 website/source/assets/javascripts/lib/Chainable.js delete mode 100644 website/source/assets/javascripts/lib/Function.prototype.bind.js delete mode 100644 website/source/assets/javascripts/lib/String.substitute.js delete mode 100644 website/source/assets/javascripts/lib/dbg.js diff --git a/website/source/assets/javascripts/app/DotLockup.js b/website/source/assets/javascripts/app/DotLockup.js deleted file mode 100644 index 8eae2ca580..0000000000 --- a/website/source/assets/javascripts/app/DotLockup.js +++ /dev/null @@ -1,130 +0,0 @@ -(function(){ - -DotLockup = Base.extend({ - - $keyWrap: null, - $keys: null, - - constructor: function(){ - var _this = this; - - _this.$keyWrap = $('.keys'); - _this.$keys = $('.keys span'); - - //(3000) - - _this.addEventListeners(); - _this.animateFull() - .then(_this.animateOff.bind(this)) - .then(_this.animateFull.bind(this)) - .then(_this.animatePress.bind(this)) - .then(_this.resetKeys.bind(this)); - }, - - addEventListeners: function(){ - var _this = this; - }, - - animateFull: function(uberDelay){ - var _this = this, - uberDelay = uberDelay || 0, - deferred = $.Deferred(); - - setTimeout( function(){ - _this.updateEachKeyClass('full', 'off', 1000, 150, deferred.resolve); - }, uberDelay) - - return deferred; - }, - - animateOff: function(){ - var deferred = $.Deferred(); - - this.updateEachKeyClass('full off', '', 1000, 150, deferred.resolve, true); - - return deferred; - }, - - animatePress: function(){ - var _this = this, - deferred = $.Deferred(), - len = _this.$keys.length, - presses = _this.randomNumbersIn(len), - delay = 250, - interval = 600; - - for(var i=0; i < len; i++){ - (function(index){ - setTimeout(function(){ - _this.$keys.eq(presses[index]).addClass('press'); - if(index == len -1 ){ - deferred.resolve(); - } - }, delay) - - delay += interval; - }(i)) - } - - return deferred; - }, - - resetKeys: function(){ - var _this = this, - len = _this.$keys.length, - delay = 2500, - interval = 250; - - setTimeout(function(){ - _this.$keys.removeClass('full press'); - }, delay) - /*for(var i=0; i < len; i++){ - (function(index){ - setTimeout(function(){ - _this.$keys.eq(index).removeClass('full press'); - }, delay) - - delay += interval; - }(i)) - }*/ - }, - - updateEachKeyClass: function(clsAdd, clsRemove, delay, interval, resolve, reverse){ - var delay = delay; - this.$keys.each(function(index){ - var span = this; - var finishIndex = (reverse) ? 0 : 9; // final timeout at 0 or 9 depending on if class removal is reversed on the span list - setTimeout( function(){ - $(span).removeClass(clsRemove).addClass(clsAdd); - if(index == finishIndex ){ - resolve(); - } - }, delay); - - if(reverse){ - delay -= interval; - }else{ - delay += interval; - } - }) - - }, - - randomNumbersIn: function(len){ - var arr = []; - while(arr.length < len){ - var randomnumber=Math.floor(Math.random()*len) - var found=false; - for(var i=0;i axis.oldScroll - var direction = isForward ? axis.forward : axis.backward - - for (var waypointKey in this.waypoints[axisKey]) { - var waypoint = this.waypoints[axisKey][waypointKey] - var wasBeforeTriggerPoint = axis.oldScroll < waypoint.triggerPoint - var nowAfterTriggerPoint = axis.newScroll >= waypoint.triggerPoint - var crossedForward = wasBeforeTriggerPoint && nowAfterTriggerPoint - var crossedBackward = !wasBeforeTriggerPoint && !nowAfterTriggerPoint - if (crossedForward || crossedBackward) { - waypoint.queueTrigger(direction) - triggeredGroups[waypoint.group.id] = waypoint.group - } - } - } - - for (var groupKey in triggeredGroups) { - triggeredGroups[groupKey].flushTriggers() - } - - this.oldScroll = { - x: axes.horizontal.newScroll, - y: axes.vertical.newScroll - } - } - - /* Private */ - Context.prototype.innerHeight = function() { - /*eslint-disable eqeqeq */ - if (this.element == this.element.window) { - return Waypoint.viewportHeight() - } - /*eslint-enable eqeqeq */ - return this.adapter.innerHeight() - } - - /* Private */ - Context.prototype.remove = function(waypoint) { - delete this.waypoints[waypoint.axis][waypoint.key] - this.checkEmpty() - } - - /* Private */ - Context.prototype.innerWidth = function() { - /*eslint-disable eqeqeq */ - if (this.element == this.element.window) { - return Waypoint.viewportWidth() - } - /*eslint-enable eqeqeq */ - return this.adapter.innerWidth() - } - - /* Public */ - /* http://imakewebthings.com/waypoints/api/context-destroy */ - Context.prototype.destroy = function() { - var allWaypoints = [] - for (var axis in this.waypoints) { - for (var waypointKey in this.waypoints[axis]) { - allWaypoints.push(this.waypoints[axis][waypointKey]) - } - } - for (var i = 0, end = allWaypoints.length; i < end; i++) { - allWaypoints[i].destroy() - } - } - - /* Public */ - /* http://imakewebthings.com/waypoints/api/context-refresh */ - Context.prototype.refresh = function() { - /*eslint-disable eqeqeq */ - var isWindow = this.element == this.element.window - /*eslint-enable eqeqeq */ - var contextOffset = this.adapter.offset() - var triggeredGroups = {} - var axes - - this.handleScroll() - axes = { - horizontal: { - contextOffset: isWindow ? 0 : contextOffset.left, - contextScroll: isWindow ? 0 : this.oldScroll.x, - contextDimension: this.innerWidth(), - oldScroll: this.oldScroll.x, - forward: 'right', - backward: 'left', - offsetProp: 'left' - }, - vertical: { - contextOffset: isWindow ? 0 : contextOffset.top, - contextScroll: isWindow ? 0 : this.oldScroll.y, - contextDimension: this.innerHeight(), - oldScroll: this.oldScroll.y, - forward: 'down', - backward: 'up', - offsetProp: 'top' - } - } - - for (var axisKey in axes) { - var axis = axes[axisKey] - for (var waypointKey in this.waypoints[axisKey]) { - var waypoint = this.waypoints[axisKey][waypointKey] - var adjustment = waypoint.options.offset - var oldTriggerPoint = waypoint.triggerPoint - var elementOffset = 0 - var freshWaypoint = oldTriggerPoint == null - var contextModifier, wasBeforeScroll, nowAfterScroll - var triggeredBackward, triggeredForward - - if (waypoint.element !== waypoint.element.window) { - elementOffset = waypoint.adapter.offset()[axis.offsetProp] - } - - if (typeof adjustment === 'function') { - adjustment = adjustment.apply(waypoint) - } - else if (typeof adjustment === 'string') { - adjustment = parseFloat(adjustment) - if (waypoint.options.offset.indexOf('%') > - 1) { - adjustment = Math.ceil(axis.contextDimension * adjustment / 100) - } - } - - contextModifier = axis.contextScroll - axis.contextOffset - waypoint.triggerPoint = elementOffset + contextModifier - adjustment - wasBeforeScroll = oldTriggerPoint < axis.oldScroll - nowAfterScroll = waypoint.triggerPoint >= axis.oldScroll - triggeredBackward = wasBeforeScroll && nowAfterScroll - triggeredForward = !wasBeforeScroll && !nowAfterScroll - - if (!freshWaypoint && triggeredBackward) { - waypoint.queueTrigger(axis.backward) - triggeredGroups[waypoint.group.id] = waypoint.group - } - else if (!freshWaypoint && triggeredForward) { - waypoint.queueTrigger(axis.forward) - triggeredGroups[waypoint.group.id] = waypoint.group - } - else if (freshWaypoint && axis.oldScroll >= waypoint.triggerPoint) { - waypoint.queueTrigger(axis.forward) - triggeredGroups[waypoint.group.id] = waypoint.group - } - } - } - - for (var groupKey in triggeredGroups) { - triggeredGroups[groupKey].flushTriggers() - } - - return this - } - - /* Private */ - Context.findOrCreateByElement = function(element) { - return Context.findByElement(element) || new Context(element) - } - - /* Private */ - Context.refreshAll = function() { - for (var contextId in contexts) { - contexts[contextId].refresh() - } - } - - /* Public */ - /* http://imakewebthings.com/waypoints/api/context-find-by-element */ - Context.findByElement = function(element) { - return contexts[element.waypointContextKey] - } - - window.onload = function() { - if (oldWindowLoad) { - oldWindowLoad() - } - Context.refreshAll() - } - - Waypoint.requestAnimationFrame = function(callback) { - var requestFn = window.requestAnimationFrame || - window.mozRequestAnimationFrame || - window.webkitRequestAnimationFrame || - requestAnimationFrameShim - requestFn.call(window, callback) - } - Waypoint.Context = Context -}()) -;(function() { - 'use strict' - - function byTriggerPoint(a, b) { - return a.triggerPoint - b.triggerPoint - } - - function byReverseTriggerPoint(a, b) { - return b.triggerPoint - a.triggerPoint - } - - var groups = { - vertical: {}, - horizontal: {} - } - var Waypoint = window.Waypoint - - /* http://imakewebthings.com/waypoints/api/group */ - function Group(options) { - this.name = options.name - this.axis = options.axis - this.id = this.name + '-' + this.axis - this.waypoints = [] - this.clearTriggerQueues() - groups[this.axis][this.name] = this - } - - /* Private */ - Group.prototype.add = function(waypoint) { - this.waypoints.push(waypoint) - } - - /* Private */ - Group.prototype.clearTriggerQueues = function() { - this.triggerQueues = { - up: [], - down: [], - left: [], - right: [] - } - } - - /* Private */ - Group.prototype.flushTriggers = function() { - for (var direction in this.triggerQueues) { - var waypoints = this.triggerQueues[direction] - var reverse = direction === 'up' || direction === 'left' - waypoints.sort(reverse ? byReverseTriggerPoint : byTriggerPoint) - for (var i = 0, end = waypoints.length; i < end; i += 1) { - var waypoint = waypoints[i] - if (waypoint.options.continuous || i === waypoints.length - 1) { - waypoint.trigger([direction]) - } - } - } - this.clearTriggerQueues() - } - - /* Private */ - Group.prototype.next = function(waypoint) { - this.waypoints.sort(byTriggerPoint) - var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) - var isLast = index === this.waypoints.length - 1 - return isLast ? null : this.waypoints[index + 1] - } - - /* Private */ - Group.prototype.previous = function(waypoint) { - this.waypoints.sort(byTriggerPoint) - var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) - return index ? this.waypoints[index - 1] : null - } - - /* Private */ - Group.prototype.queueTrigger = function(waypoint, direction) { - this.triggerQueues[direction].push(waypoint) - } - - /* Private */ - Group.prototype.remove = function(waypoint) { - var index = Waypoint.Adapter.inArray(waypoint, this.waypoints) - if (index > -1) { - this.waypoints.splice(index, 1) - } - } - - /* Public */ - /* http://imakewebthings.com/waypoints/api/first */ - Group.prototype.first = function() { - return this.waypoints[0] - } - - /* Public */ - /* http://imakewebthings.com/waypoints/api/last */ - Group.prototype.last = function() { - return this.waypoints[this.waypoints.length - 1] - } - - /* Private */ - Group.findOrCreate = function(options) { - return groups[options.axis][options.name] || new Group(options) - } - - Waypoint.Group = Group -}()) -;(function() { - 'use strict' - - var $ = window.jQuery - var Waypoint = window.Waypoint - - function JQueryAdapter(element) { - this.$element = $(element) - } - - $.each([ - 'innerHeight', - 'innerWidth', - 'off', - 'offset', - 'on', - 'outerHeight', - 'outerWidth', - 'scrollLeft', - 'scrollTop' - ], function(i, method) { - JQueryAdapter.prototype[method] = function() { - var args = Array.prototype.slice.call(arguments) - return this.$element[method].apply(this.$element, args) - } - }) - - $.each([ - 'extend', - 'inArray', - 'isEmptyObject' - ], function(i, method) { - JQueryAdapter[method] = $[method] - }) - - Waypoint.adapters.push({ - name: 'jquery', - Adapter: JQueryAdapter - }) - Waypoint.Adapter = JQueryAdapter -}()) -;(function() { - 'use strict' - - var Waypoint = window.Waypoint - - function createExtension(framework) { - return function() { - var waypoints = [] - var overrides = arguments[0] - - if (framework.isFunction(arguments[0])) { - overrides = framework.extend({}, arguments[1]) - overrides.handler = arguments[0] - } - - this.each(function() { - var options = framework.extend({}, overrides, { - element: this - }) - if (typeof options.context === 'string') { - options.context = framework(this).closest(options.context)[0] - } - waypoints.push(new Waypoint(options)) - }) - - return waypoints - } - } - - if (window.jQuery) { - window.jQuery.fn.waypoint = createExtension(window.jQuery) - } - if (window.Zepto) { - window.Zepto.fn.waypoint = createExtension(window.Zepto) - } -}()) -; diff --git a/website/source/assets/javascripts/lib/Base.js b/website/source/assets/javascripts/lib/Base.js deleted file mode 100644 index 504e2beea1..0000000000 --- a/website/source/assets/javascripts/lib/Base.js +++ /dev/null @@ -1,145 +0,0 @@ -/* - 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; -}); diff --git a/website/source/assets/javascripts/lib/Chainable.js b/website/source/assets/javascripts/lib/Chainable.js deleted file mode 100644 index dbe51dd1d9..0000000000 --- a/website/source/assets/javascripts/lib/Chainable.js +++ /dev/null @@ -1,92 +0,0 @@ -(function(){ - -var Chainable = function(engine){ - this.engine = engine; - this._chain = []; - this._updateTimer = this._updateTimer.bind(this); - this._cycle = this._cycle.bind(this); -}; - -Chainable.prototype._running = false; - -Chainable.prototype._updateTimer = function(tick){ - this._timer += tick; - if (this._timer >= this._timerMax) { - this.resetTimer(); - this._cycle(); - } -}; - -Chainable.prototype.resetTimer = function(){ - this.engine.updateChainTimer = undefined; - this._timer = 0; - this._timerMax = 0; - return this; -}; - -Chainable.prototype.start = function(){ - if (this._running || !this._chain.length) { - return this; - } - this._running = true; - return this._cycle(); -}; - -Chainable.prototype.reset = function(){ - if (!this._running) { - return this; - } - this.resetTimer(); - this._timer = 0; - this._running = false; - return this; -}; - -Chainable.prototype._cycle = function(){ - var current; - if (!this._chain.length) { - return this.reset(); - } - - current = this._chain.shift(); - - if (current.type === 'function') { - current.func.apply(current.scope, current.args); - current = null; - return this._cycle(); - } - if (current.type === 'wait') { - this.resetTimer(); - // Convert timer to seconds - this._timerMax = current.time / 1000; - this.engine.updateChainTimer = this._updateTimer; - current = null; - } - - return this; -}; - -Chainable.prototype.then = Chainable.prototype.exec = function(func, scope, args){ - this._chain.push({ - type : 'function', - - func : func, - scope : scope || window, - args : args || [] - }); - - return this.start(); -}; - -Chainable.prototype.wait = function(time){ - this._chain.push({ - type : 'wait', - time : time - }); - - return this.start(); -}; - -window.Chainable = Chainable; - -})(); diff --git a/website/source/assets/javascripts/lib/Function.prototype.bind.js b/website/source/assets/javascripts/lib/Function.prototype.bind.js deleted file mode 100644 index 82c3cb6c68..0000000000 --- a/website/source/assets/javascripts/lib/Function.prototype.bind.js +++ /dev/null @@ -1,21 +0,0 @@ -if (!Function.prototype.bind) { - Function.prototype.bind = function (oThis) { - if (typeof this !== "function") { - throw new TypeError("Function.prototype.bind - what is trying to be bound is not callable"); - } - - var aArgs = Array.prototype.slice.call(arguments, 1), - fToBind = this, - fNOP = function () {}, - fBound = function () { - return fToBind.apply(this instanceof fNOP && oThis ? - this : oThis, - aArgs.concat(Array.prototype.slice.call(arguments))); - }; - - fNOP.prototype = this.prototype; - fBound.prototype = new fNOP(); - - return fBound; - }; -} diff --git a/website/source/assets/javascripts/lib/String.substitute.js b/website/source/assets/javascripts/lib/String.substitute.js deleted file mode 100644 index da2b52a387..0000000000 --- a/website/source/assets/javascripts/lib/String.substitute.js +++ /dev/null @@ -1,14 +0,0 @@ -(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); diff --git a/website/source/assets/javascripts/lib/dbg.js b/website/source/assets/javascripts/lib/dbg.js deleted file mode 100644 index 6df4f37625..0000000000 --- a/website/source/assets/javascripts/lib/dbg.js +++ /dev/null @@ -1,60 +0,0 @@ -/* - * - * 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);