js/foundation/foundation.js in zurb-foundation-4.0.7 vs js/foundation/foundation.js in zurb-foundation-4.0.8

- old
+ new

@@ -96,21 +96,21 @@ 'use strict'; window.Foundation = { name : 'Foundation', - version : '4.0.0', + version : '4.0.8', // global Foundation cache object cache : {}, 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; // set foundation global scope @@ -187,20 +187,35 @@ this.libs[scope.name][methods_arr[i]] = this.lib_methods[methods_arr[i]]; } } }, + random_str : function (length) { + var chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz'.split(''); + + if (!length) { + length = Math.floor(Math.random() * chars.length); + } + + var str = ''; + for (var i = 0; i < length; i++) { + str += chars[Math.floor(Math.random() * chars.length)]; + } + return str; + }, + libs : {}, // methods that can be inherited in libraries lib_methods : { set_data : function (node, data) { // this.name references the name of the library calling this method - var id = this.name + (+new Date()); + var id = [this.name,+new Date(),Foundation.random_str(5)].join('-'); Foundation.cache[id] = data; node.attr('data-' + this.name + '-id', id); + return data; }, get_data : function (node) { return Foundation.cache[node.attr('data-' + this.name + '-id')]; }, @@ -226,19 +241,19 @@ fun.apply(context, args); }, delay); }; }, - // parses data-options attribute on page nodes and turns + // parses data-options attribute on nodes and turns // them into an object data_options : function (el) { var opts = {}, ii, p, opts_arr = (el.attr('data-options') || ':').split(';'), opts_len = opts_arr.length; function isNumber (o) { - return ! isNaN (o-0) && o !== null && o !== "" && o !== false; + return ! isNaN (o-0) && o !== null && o !== "" && o !== false && o !== true; } function trim(str) { if (typeof str === 'string') return $.trim(str); return str; @@ -250,10 +265,10 @@ if (/true/i.test(p[1])) p[1] = true; if (/false/i.test(p[1])) p[1] = false; if (isNumber(p[1])) p[1] = parseInt(p[1], 10); - if (p.length === 2) { + if (p.length === 2 && p[0].length > 0) { opts[trim(p[0])] = trim(p[1]); } } return opts;