vendor/assets/javascripts/foundation/jquery.foundation.tooltips.js in zurb-foundation-3.0.9 vs vendor/assets/javascripts/foundation/jquery.foundation.tooltips.js in zurb-foundation-3.1.0.rc1
- old
+ new
@@ -1,27 +1,30 @@
/*
- * jQuery Foundation Tooltip Plugin 2.0.1
+ * jQuery Foundation Tooltips 2.0.1
* http://foundation.zurb.com
* Copyright 2012, ZURB
* Free to use under the MIT license.
* http://www.opensource.org/licenses/mit-license.php
*/
/*jslint unparam: true, browser: true, indent: 2 */
-;(function ($) {
+;(function ($, window, undefined) {
'use strict';
+
var settings = {
bodyHeight : 0,
targetClass : '.has-tip',
tooltipClass : '.tooltip',
tipTemplate : function (selector, content) {
return '<span data-selector="' + selector + '" class="' + settings.tooltipClass.substring(1) + '">' + content + '<span class="nub"></span></span>';
}
},
methods = {
init : function (options) {
+ settings = $.extend(settings, options);
+
return this.each(function () {
var $body = $('body');
if (Modernizr.touch) {
$body.on('click.tooltip touchstart.tooltip touchend.tooltip', settings.targetClass, function (e) {
@@ -42,10 +45,13 @@
} else if (e.type === 'mouseleave') {
methods.hide($this);
}
});
}
+
+ $(this).data('tooltips', true);
+
});
},
showOrCreateTip : function ($target) {
var $tip = methods.getTip($target);
@@ -134,11 +140,11 @@
}
tip.css('visibility', 'visible').hide();
},
inheritable_classes : function (target) {
var inheritables = ['tip-top', 'tip-left', 'tip-bottom', 'tip-right', 'noradius'],
- filtered = target.attr('class').split(' ').map(function (el, i) {
+ filtered = $.map(target.attr('class').split(' '), function (el, i) {
if ($.inArray(el, inheritables) !== -1) {
return el;
}
}).join(' ');
@@ -156,11 +162,11 @@
$tip.fadeOut(150);
},
reload : function () {
var $self = $(this);
- return ($self.data('tooltips')) ? $self.tooltips('destroy').tooltips('init') : $self.tooltips('init');
+ return ($self.data('tooltips')) ? $self.foundationTooltips('destroy').foundationTooltips('init') : $self.foundationTooltips('init');
},
destroy : function () {
return this.each(function () {
$(window).off('.tooltip');
$(settings.targetClass).off('.tooltip');
@@ -169,15 +175,15 @@
}).remove();
});
}
};
- $.fn.tooltips = function (method) {
+ $.fn.foundationTooltips = function (method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
- $.error('Method ' + method + ' does not exist on jQuery.tooltips');
+ $.error('Method ' + method + ' does not exist on jQuery.foundationTooltips');
}
};
-}(jQuery));
\ No newline at end of file
+}(jQuery, this));