assets/js/edge.js in edge_framework-0.9.12 vs assets/js/edge.js in edge_framework-0.10.0
- old
+ new
@@ -1,233 +1,233 @@
/*
- EDGE LIBRARY
- Based on Foundation 4 by ZURB
+ EDGE LIBRARY
+ Based on Foundation 4 by ZURB
*/
var Edge = {};
var Foundation = {};
(function () {
- // Browser Compatibility
- if (!Array.prototype.filter) {
- Array.prototype.filter = function(fun /*, thisp */) {
- "use strict";
-
- if (this == null) {
- throw new TypeError();
- }
-
- var t = Object(this),
- len = t.length >>> 0;
- if (typeof fun != "function") {
- try {
- throw new TypeError();
- } catch (e) {
- return;
- }
- }
-
- var res = [],
- thisp = arguments[1];
- for (var i = 0; i < len; i++) {
- if (i in t) {
- var val = t[i]; // in case `fun` mutates this
- if (fun && fun.call(thisp, val, i, t)) {
- res.push(val);
- }
- }
- }
-
- return res;
- };
+ // Browser Compatibility
+ if (!Array.prototype.filter) {
+ Array.prototype.filter = function(fun /*, thisp */) {
+ "use strict";
+
+ if (this == null) {
+ throw new TypeError();
+ }
+
+ var t = Object(this),
+ len = t.length >>> 0;
+ if (typeof fun != "function") {
+ try {
+ throw new TypeError();
+ } catch (e) {
+ return;
+ }
+ }
+
+ var res = [],
+ thisp = arguments[1];
+ for (var i = 0; i < len; i++) {
+ if (i in t) {
+ var val = t[i]; // in case `fun` mutates this
+ if (fun && fun.call(thisp, val, i, t)) {
+ res.push(val);
+ }
+ }
+ }
+
+ return res;
+ };
- if (!Function.prototype.bind) {
- Function.prototype.bind = function (oThis) {
- if (typeof this !== "function") {
- // closest thing possible to the ECMAScript 5 internal IsCallable 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;
- };
- }
- }
+ if (!Function.prototype.bind) {
+ Function.prototype.bind = function (oThis) {
+ if (typeof this !== "function") {
+ // closest thing possible to the ECMAScript 5 internal IsCallable 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;
+ };
+ }
+ }
}() );
;(function (window, document, undefined) {
- "use strict";
+ "use strict";
- Edge = {
- name : "Edge",
- version : "1.0",
- libs : {},
+ Edge = {
+ name : "Edge",
+ version : "1.0",
+ libs : {},
- init: function( scope, libraries, method, options, response, /* internal */ nc ) {
- var library_arr,
- args = [scope, method, options, response],
- responses = [],
- nc = nc || false;
+ init: function( scope, libraries, method, options, response, /* internal */ nc ) {
+ var library_arr,
+ args = [scope, method, options, response],
+ responses = [],
+ nc = nc || false;
- // Disable library error catching,
- // used for development only
- if (nc) this.nc = nc;
+ // Disable library error catching,
+ // used for development only
+ if (nc) this.nc = nc;
- // Set edge global scope
- this.scope = scope || this.scope;
+ // Set edge global scope
+ this.scope = scope || this.scope;
- // If calling specific library
- if (libraries && typeof libraries === "string") {
- // If calling `off`
- if (/off/i.test(libraries) ) {
- return this.off();
- }
+ // If calling specific library
+ if (libraries && typeof libraries === "string") {
+ // If calling `off`
+ if (/off/i.test(libraries) ) {
+ return this.off();
+ }
- library_arr = libraries.split(' ');
+ library_arr = libraries.split(' ');
- // If more than 0
- if (library_arr.length) {
- for (var i = 0, len = library_arr.length; i < len; i++) {
- responses.push(this.init_lib(library_arr[i], args) );
- }
- }
- } else {
- for (var lib in this.libs) {
- responses.push(this.init_lib(lib, args) );
- }
- }
- // If first argument is callback, add to args
- if (typeof libraries === "function") {
- args.unshift(libraries);
- }
+ // If more than 0
+ if (library_arr.length) {
+ for (var i = 0, len = library_arr.length; i < len; i++) {
+ responses.push(this.init_lib(library_arr[i], args) );
+ }
+ }
+ } else {
+ for (var lib in this.libs) {
+ responses.push(this.init_lib(lib, args) );
+ }
+ }
+ // If first argument is callback, add to args
+ if (typeof libraries === "function") {
+ args.unshift(libraries);
+ }
- return this.response_obj(responses, args);
- },
-
- response_obj: function( response_arr, args ) {
- for (var callback in args) {
- if (typeof args[callback] === "function") {
- return args[callback]({
- errors: response_arr.filter(function (s) {
- if (typeof s === "string") return s;
- })
- });
- }
- }
- console.log(response_arr);
- return response_arr;
- },
+ return this.response_obj(responses, args);
+ },
+
+ response_obj: function( response_arr, args ) {
+ for (var callback in args) {
+ if (typeof args[callback] === "function") {
+ return args[callback]({
+ errors: response_arr.filter(function (s) {
+ if (typeof s === "string") return s;
+ })
+ });
+ }
+ }
+ console.log(response_arr);
+ return response_arr;
+ },
- init_lib: function( lib, args ) {
- return this.trap(function() {
- if (this.libs.hasOwnProperty(lib) ) {
- this.patch(this.libs[lib] );
- return this.libs[lib].init.apply(this.libs[lib], args);
- }
- }.bind(this), lib);
- },
+ init_lib: function( lib, args ) {
+ return this.trap(function() {
+ if (this.libs.hasOwnProperty(lib) ) {
+ this.patch(this.libs[lib] );
+ return this.libs[lib].init.apply(this.libs[lib], args);
+ }
+ }.bind(this), lib);
+ },
- // Error Checking
- trap: function( fun, lib ) {
- if (!this.nc) {
- try {
- return fun();
- } catch (e) {
- return this.error({
- name : lib,
- message : "could not be initialized",
- more : e.name + ' ' + e.message,
- });
- }
- }
- return fun();
- },
+ // Error Checking
+ trap: function( fun, lib ) {
+ if (!this.nc) {
+ try {
+ return fun();
+ } catch (e) {
+ return this.error({
+ name : lib,
+ message : "could not be initialized",
+ more : e.name + ' ' + e.message,
+ });
+ }
+ }
+ return fun();
+ },
- patch: function( lib ) {
- lib.outerHeight = function (el, bool) {
- if (typeof bool !== "undefined") {
- return el.outerHeight(bool);
- }
- return el.outerHeight();
- };
+ patch: function( lib ) {
+ lib.outerHeight = function (el, bool) {
+ if (typeof bool !== "undefined") {
+ return el.outerHeight(bool);
+ }
+ return el.outerHeight();
+ };
- lib.outerWidth = function (el) {
- if (typeof bool !== "undefined") {
- return el.outerWidth(bool);
- }
- return el.outerWidth();
- };
- },
+ lib.outerWidth = function (el) {
+ if (typeof bool !== "undefined") {
+ return el.outerWidth(bool);
+ }
+ return el.outerWidth();
+ };
+ },
- inherit: function( scope, methods ) {
- console.log("inherit");
- var methods_arr = methods.split(" ");
+ inherit: function( scope, methods ) {
+ console.log("inherit");
+ var methods_arr = methods.split(" ");
- for (var i = methods_arr.length - 1; i >= 0; i--) {
- if (this.lib_methods.hasOwnProperty(methods_arr[i]) ) {
- this.libs[scope.name][methods_arr[i] ] = this.lib_methods[methods_arr[i] ];
- }
- }
- },
+ for (var i = methods_arr.length - 1; i >= 0; i--) {
+ if (this.lib_methods.hasOwnProperty(methods_arr[i]) ) {
+ this.libs[scope.name][methods_arr[i] ] = this.lib_methods[methods_arr[i] ];
+ }
+ }
+ },
- // Inherited methods in library
- lib_methods: {
- delay: function ( fun, delay ) {
- return setTimeout(fun, delay);
- },
- scrollTo: function ( el, to, duration ) {
- if (duration < 0) return;
- var difference = to - $(window).scrollTop();
- var perTick = difference / duration * 10;
+ // Inherited methods in library
+ lib_methods: {
+ delay: function ( fun, delay ) {
+ return setTimeout(fun, delay);
+ },
+ scrollTo: function ( el, to, duration ) {
+ if (duration < 0) return;
+ var difference = to - $(window).scrollTop();
+ var perTick = difference / duration * 10;
- this.scrollToTimerCache = setTimeout(function() {
- if (!isNaN(parseInt(perTick, 10) ) ) {
- window.scrollTo(0, $(window).scrollTop() + perTick);
- this.scrollTo(el, to, duration - 10);
- }
- }.bind(this), 10);
- },
+ this.scrollToTimerCache = setTimeout(function() {
+ if (!isNaN(parseInt(perTick, 10) ) ) {
+ window.scrollTo(0, $(window).scrollTop() + perTick);
+ this.scrollTo(el, to, duration - 10);
+ }
+ }.bind(this), 10);
+ },
- // Test for empty object or array
- empty : function (obj) {
- if (obj.length && obj.length > 0) { return false; }
- if (obj.length && obj.length === 0) { return true; }
- for (var key in obj) {
- if (hasOwnProperty.call(obj, key) ) { return false; }
- }
- return true;
- },
- },
+ // Test for empty object or array
+ empty : function (obj) {
+ if (obj.length && obj.length > 0) { return false; }
+ if (obj.length && obj.length === 0) { return true; }
+ for (var key in obj) {
+ if (hasOwnProperty.call(obj, key) ) { return false; }
+ }
+ return true;
+ },
+ },
- error: function( error ) {
- return error.name + " " + error.message + "; " + error.more;
- },
+ error: function( error ) {
+ return error.name + " " + error.message + "; " + error.more;
+ },
- off: function() {
- $(this.scope).off(".edge");
- $(window).off(".edge");
- return true;
- },
- };
+ off: function() {
+ $(this.scope).off(".edge");
+ $(window).off(".edge");
+ return true;
+ },
+ };
- Foundation = Edge;
+ Foundation = Edge;
- // JQuery prototype, allow `$().edge()` call
- $.fn.edge = function () {
- var args = Array.prototype.slice.call(arguments, 0);
- return this.each(function () {
- Edge.init.apply(Edge, [this].concat(args) );
- return this;
- });
- };
+ // JQuery prototype, allow `$().edge()` call
+ $.fn.edge = function () {
+ var args = Array.prototype.slice.call(arguments, 0);
+ return this.each(function () {
+ Edge.init.apply(Edge, [this].concat(args) );
+ return this;
+ });
+ };
}(this, this.document) );
\ No newline at end of file