vendor/assets/stylesheets/bower_components/foundation/js/foundation/foundation.js in paint-rails-0.6.7 vs vendor/assets/stylesheets/bower_components/foundation/js/foundation/foundation.js in paint-rails-0.7.24
- old
+ new
@@ -12,27 +12,31 @@
var header_helpers = function (class_array) {
var i = class_array.length;
var head = $('head');
while (i--) {
- if(head.has('.' + class_array[i]).length === 0) {
+ if (head.has('.' + class_array[i]).length === 0) {
head.append('<meta class="' + class_array[i] + '" />');
}
}
};
header_helpers([
'foundation-mq-small',
+ 'foundation-mq-small-only',
'foundation-mq-medium',
+ 'foundation-mq-medium-only',
'foundation-mq-large',
+ 'foundation-mq-large-only',
'foundation-mq-xlarge',
+ 'foundation-mq-xlarge-only',
'foundation-mq-xxlarge',
'foundation-data-attribute-namespace']);
// Enable FastClick if present
- $(function() {
+ $(function () {
if (typeof FastClick !== 'undefined') {
// Don't attach to body if undefined
if (typeof document.body !== 'undefined') {
FastClick.attach(document.body);
}
@@ -46,11 +50,13 @@
if (typeof selector === 'string') {
if (context) {
var cont;
if (context.jquery) {
cont = context[0];
- if (!cont) return context;
+ if (!cont) {
+ return context;
+ }
} else {
cont = context;
}
return $(cont.querySelectorAll(selector));
}
@@ -63,12 +69,16 @@
// Namespace functions.
var attr_name = function (init) {
var arr = [];
- if (!init) arr.push('data');
- if (this.namespace.length > 0) arr.push(this.namespace);
+ if (!init) {
+ arr.push('data');
+ }
+ if (this.namespace.length > 0) {
+ arr.push(this.namespace);
+ }
arr.push(this.name);
return arr.join('-');
};
@@ -94,29 +104,24 @@
// Event binding and data-options updating.
var bindings = function (method, options) {
var self = this,
- should_bind_events = !S(this).data(this.attr_name(true));
+ bind = function(){
+ var $this = S(this),
+ should_bind_events = !$this.data(self.attr_name(true) + '-init');
+ $this.data(self.attr_name(true) + '-init', $.extend({}, self.settings, (options || method), self.data_options($this)));
+ if (should_bind_events) {
+ self.events(this);
+ }
+ };
if (S(this.scope).is('[' + this.attr_name() +']')) {
- S(this.scope).data(this.attr_name(true) + '-init', $.extend({}, this.settings, (options || method), this.data_options(S(this.scope))));
-
- if (should_bind_events) {
- this.events(this.scope);
- }
-
+ bind.call(this.scope);
} else {
- S('[' + this.attr_name() +']', this.scope).each(function () {
- var should_bind_events = !S(this).data(self.attr_name(true) + '-init');
- S(this).data(self.attr_name(true) + '-init', $.extend({}, self.settings, (options || method), self.data_options(S(this))));
-
- if (should_bind_events) {
- self.events(this);
- }
- });
+ S('[' + this.attr_name() +']', this.scope).each(bind);
}
// # Patch to fix #5043 to move this *after* the if/else clause in order for Backbone and similar frameworks to have improved control over event binding and data-options updating.
if (typeof method === 'string') {
return this[method].call(this, options);
}
@@ -150,58 +155,69 @@
} else {
bindLoad.call(image);
}
};
- /*
- https://github.com/paulirish/matchMedia.js
- */
+ /*! matchMedia() polyfill - Test a CSS media type/query in JS. Authors & copyright (c) 2012: Scott Jehl, Paul Irish, Nicholas Zakas, David Knight. Dual MIT/BSD license */
- window.matchMedia = window.matchMedia || (function( doc ) {
+ window.matchMedia || (window.matchMedia = function() {
+ "use strict";
- "use strict";
+ // For browsers that support matchMedium api such as IE 9 and webkit
+ var styleMedia = (window.styleMedia || window.media);
- var bool,
- docElem = doc.documentElement,
- refNode = docElem.firstElementChild || docElem.firstChild,
- // fakeBody required for <FF4 when executed in <head>
- fakeBody = doc.createElement( "body" ),
- div = doc.createElement( "div" );
+ // For those that don't support matchMedium
+ if (!styleMedia) {
+ var style = document.createElement('style'),
+ script = document.getElementsByTagName('script')[0],
+ info = null;
- div.id = "mq-test-1";
- div.style.cssText = "position:absolute;top:-100em";
- fakeBody.style.background = "none";
- fakeBody.appendChild(div);
+ style.type = 'text/css';
+ style.id = 'matchmediajs-test';
- return function (q) {
+ script.parentNode.insertBefore(style, script);
- div.innerHTML = "­<style media=\"" + q + "\"> #mq-test-1 { width: 42px; }</style>";
+ // 'style.currentStyle' is used by IE <= 8 and 'window.getComputedStyle' for all other browsers
+ info = ('getComputedStyle' in window) && window.getComputedStyle(style, null) || style.currentStyle;
- docElem.insertBefore( fakeBody, refNode );
- bool = div.offsetWidth === 42;
- docElem.removeChild( fakeBody );
+ styleMedia = {
+ matchMedium: function(media) {
+ var text = '@media ' + media + '{ #matchmediajs-test { width: 1px; } }';
- return {
- matches: bool,
- media: q
- };
+ // 'style.styleSheet' is used by IE <= 8 and 'style.textContent' for all other browsers
+ if (style.styleSheet) {
+ style.styleSheet.cssText = text;
+ } else {
+ style.textContent = text;
+ }
- };
+ // Test if media query is true or false
+ return info.width === '1px';
+ }
+ };
+ }
- }( document ));
+ return function(media) {
+ return {
+ matches: styleMedia.matchMedium(media || 'all'),
+ media: media || 'all'
+ };
+ };
+ }());
/*
* jquery.requestAnimationFrame
* https://github.com/gnarf37/jquery-requestAnimationFrame
* Requires jQuery 1.8+
*
* Copyright (c) 2012 Corey Frang
* Licensed under the MIT license.
*/
- (function($) {
+ (function(jQuery) {
+
// requestAnimationFrame polyfill adapted from Erik Möller
// fixes from Paul Irish and Tino Zijdel
// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
@@ -211,14 +227,14 @@
requestAnimationFrame = window.requestAnimationFrame,
cancelAnimationFrame = window.cancelAnimationFrame,
jqueryFxAvailable = 'undefined' !== typeof jQuery.fx;
for (; lastTime < vendors.length && !requestAnimationFrame; lastTime++) {
- requestAnimationFrame = window[ vendors[lastTime] + "RequestAnimationFrame" ];
+ requestAnimationFrame = window[ vendors[lastTime] + 'RequestAnimationFrame' ];
cancelAnimationFrame = cancelAnimationFrame ||
- window[ vendors[lastTime] + "CancelAnimationFrame" ] ||
- window[ vendors[lastTime] + "CancelRequestAnimationFrame" ];
+ window[ vendors[lastTime] + 'CancelAnimationFrame' ] ||
+ window[ vendors[lastTime] + 'CancelRequestAnimationFrame' ];
}
function raf() {
if (animating) {
requestAnimationFrame(raf);
@@ -262,13 +278,12 @@
clearTimeout(id);
};
}
- }( jQuery ));
+ }( $ ));
-
function removeQuotes (string) {
if (typeof string === 'string' || string instanceof String) {
string = string.replace(/^['\\/"]+|(;\s?})+|['\\/"]+$/g, '');
}
@@ -276,24 +291,28 @@
}
window.Foundation = {
name : 'Foundation',
- version : '5.4.7',
+ version : '5.5.2',
media_queries : {
- small : S('.foundation-mq-small').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
- medium : S('.foundation-mq-medium').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
- large : S('.foundation-mq-large').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
- xlarge: S('.foundation-mq-xlarge').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
- xxlarge: S('.foundation-mq-xxlarge').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, '')
+ 'small' : S('.foundation-mq-small').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
+ 'small-only' : S('.foundation-mq-small-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
+ 'medium' : S('.foundation-mq-medium').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
+ 'medium-only' : S('.foundation-mq-medium-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
+ 'large' : S('.foundation-mq-large').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
+ 'large-only' : S('.foundation-mq-large-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
+ 'xlarge' : S('.foundation-mq-xlarge').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
+ 'xlarge-only' : S('.foundation-mq-xlarge-only').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, ''),
+ 'xxlarge' : S('.foundation-mq-xxlarge').css('font-family').replace(/^[\/\\'"]+|(;\s?})+|[\/\\'"]+$/g, '')
},
stylesheet : $('<style></style>').appendTo('head')[0].sheet,
- global: {
- namespace: undefined
+ global : {
+ namespace : undefined
},
init : function (scope, libraries, method, options, response) {
var args = [scope, method, options, response],
responses = [];
@@ -314,11 +333,11 @@
for (var lib in this.libs) {
responses.push(this.init_lib(lib, libraries));
}
}
- S(window).load(function(){
+ S(window).load(function () {
S(window)
.trigger('resize.fndtn.clearing')
.trigger('resize.fndtn.dropdown')
.trigger('resize.fndtn.equalizer')
.trigger('resize.fndtn.interchange')
@@ -335,19 +354,18 @@
if (this.libs.hasOwnProperty(lib)) {
this.patch(this.libs[lib]);
if (args && args.hasOwnProperty(lib)) {
if (typeof this.libs[lib].settings !== 'undefined') {
- $.extend(true, this.libs[lib].settings, args[lib]);
+ $.extend(true, this.libs[lib].settings, args[lib]);
+ } else if (typeof this.libs[lib].defaults !== 'undefined') {
+ $.extend(true, this.libs[lib].defaults, args[lib]);
}
- else if (typeof this.libs[lib].defaults !== 'undefined') {
- $.extend(true, this.libs[lib].defaults, args[lib]);
- }
return this.libs[lib].init.apply(this.libs[lib], [this.scope, args[lib]]);
}
- args = args instanceof Array ? args : new Array(args); // PATCH: added this line
+ args = args instanceof Array ? args : new Array(args);
return this.libs[lib].init.apply(this.libs[lib], args);
}
return function () {};
},
@@ -372,11 +390,11 @@
scope[methods_arr[i]] = this.utils[methods_arr[i]];
}
}
},
- set_namespace: function () {
+ set_namespace : function () {
// Description:
// Don't bother reading the namespace out of the meta tag
// if the namespace has been set globally in javascript
//
@@ -460,16 +478,20 @@
var timeout, result;
return function () {
var context = this, args = arguments;
var later = function () {
timeout = null;
- if (!immediate) result = func.apply(context, args);
+ if (!immediate) {
+ result = func.apply(context, args);
+ }
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, delay);
- if (callNow) result = func.apply(context, args);
+ if (callNow) {
+ result = func.apply(context, args);
+ }
return result;
};
},
// Description:
@@ -502,24 +524,30 @@
opts_arr = (cached_options || ':').split(';');
ii = opts_arr.length;
function isNumber (o) {
- return ! isNaN (o-0) && o !== null && o !== "" && o !== false && o !== true;
+ return !isNaN (o - 0) && o !== null && o !== '' && o !== false && o !== true;
}
function trim (str) {
- if (typeof str === 'string') return $.trim(str);
+ if (typeof str === 'string') {
+ return $.trim(str);
+ }
return str;
}
while (ii--) {
p = opts_arr[ii].split(':');
p = [p[0], p.slice(1).join(':')];
- if (/true/i.test(p[1])) p[1] = true;
- if (/false/i.test(p[1])) p[1] = false;
+ if (/true/i.test(p[1])) {
+ p[1] = true;
+ }
+ if (/false/i.test(p[1])) {
+ p[1] = false;
+ }
if (isNumber(p[1])) {
if (p[1].indexOf('.') === -1) {
p[1] = parseInt(p[1], 10);
} else {
p[1] = parseFloat(p[1]);
@@ -541,11 +569,11 @@
// Media (String): Key string for the media query to be stored as in
// Foundation.media_queries
//
// Class (String): Class name for the generated <meta> tag
register_media : function (media, media_class) {
- if(Foundation.media_queries[media] === undefined) {
+ if (Foundation.media_queries[media] === undefined) {
$('head').append('<meta class="' + media_class + '"/>');
Foundation.media_queries[media] = removeQuotes($('.' + media_class).css('font-family'));
}
},
@@ -563,11 +591,11 @@
} else {
var query = Foundation.media_queries[media];
if (query !== undefined) {
Foundation.stylesheet.insertRule('@media ' +
- Foundation.media_queries[media] + '{ ' + rule + ' }');
+ Foundation.media_queries[media] + '{ ' + rule + ' }', Foundation.stylesheet.cssRules.length);
}
}
},
// Description:
@@ -579,11 +607,23 @@
// Callback (Function): Function to execute when image is fully loaded.
image_loaded : function (images, callback) {
var self = this,
unloaded = images.length;
- if (unloaded === 0) {
+ function pictures_has_height(images) {
+ var pictures_number = images.length;
+
+ for (var i = pictures_number - 1; i >= 0; i--) {
+ if(images.attr('height') === undefined) {
+ return false;
+ };
+ };
+
+ return true;
+ }
+
+ if (unloaded === 0 || pictures_has_height(images)) {
callback(images);
}
images.each(function () {
single_image_loaded(self.S(this), function () {
@@ -603,13 +643,73 @@
// integer.
//
// Returns:
// Rand (String): Pseudo-random, alphanumeric string.
random_str : function () {
- if (!this.fidx) this.fidx = 0;
+ if (!this.fidx) {
+ this.fidx = 0;
+ }
this.prefix = this.prefix || [(this.name || 'F'), (+new Date).toString(36)].join('-');
return this.prefix + (this.fidx++).toString(36);
+ },
+
+ // Description:
+ // Helper for window.matchMedia
+ //
+ // Arguments:
+ // mq (String): Media query
+ //
+ // Returns:
+ // (Boolean): Whether the media query passes or not
+ match : function (mq) {
+ return window.matchMedia(mq).matches;
+ },
+
+ // Description:
+ // Helpers for checking Foundation default media queries with JS
+ //
+ // Returns:
+ // (Boolean): Whether the media query passes or not
+
+ is_small_up : function () {
+ return this.match(Foundation.media_queries.small);
+ },
+
+ is_medium_up : function () {
+ return this.match(Foundation.media_queries.medium);
+ },
+
+ is_large_up : function () {
+ return this.match(Foundation.media_queries.large);
+ },
+
+ is_xlarge_up : function () {
+ return this.match(Foundation.media_queries.xlarge);
+ },
+
+ is_xxlarge_up : function () {
+ return this.match(Foundation.media_queries.xxlarge);
+ },
+
+ is_small_only : function () {
+ return !this.is_medium_up() && !this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up();
+ },
+
+ is_medium_only : function () {
+ return this.is_medium_up() && !this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up();
+ },
+
+ is_large_only : function () {
+ return this.is_medium_up() && this.is_large_up() && !this.is_xlarge_up() && !this.is_xxlarge_up();
+ },
+
+ is_xlarge_only : function () {
+ return this.is_medium_up() && this.is_large_up() && this.is_xlarge_up() && !this.is_xxlarge_up();
+ },
+
+ is_xxlarge_only : function () {
+ return this.is_medium_up() && this.is_large_up() && this.is_xlarge_up() && this.is_xxlarge_up();
}
}
};
$.fn.foundation = function () {