Skip to content

Commit

Permalink
Merge branch '5.2-wip' of github.com:zurb/foundation into 5.2-wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Hayes committed Mar 5, 2014
2 parents 0df83f4 + f792e3f commit 4bba60c
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions js/foundation/foundation.tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,21 @@

$(this.scope)
.off('.tooltip')
.on('mouseenter.fndtn.tooltip mouseleave.fndtn.tooltip touchstart.fndtn.tooltip',
.on('mouseenter.fndtn.tooltip mouseleave.fndtn.tooltip touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip',
'[' + this.attr_name() + ']:not(a)', function (e) {
var $this = S(this),
settings = $.extend({}, self.settings, self.data_options($this)),
is_touch = false;

if (/mouse/i.test(e.type) && self.ie_touch(e)) return false;

if ($this.hasClass('open')) {
if (Modernizr.touch && /touchstart/i.test(e.type)) e.preventDefault();
if (Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) e.preventDefault();
self.hide($this);
} else {
if (settings.disable_for_touch && Modernizr.touch && /touchstart/i.test(e.type)) {
if (settings.disable_for_touch && Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) {
return;
} else if(!settings.disable_for_touch && Modernizr.touch && /touchstart/i.test(e.type)) {
} else if(!settings.disable_for_touch && Modernizr.touch && /touchstart|MSPointerDown/i.test(e.type)) {
e.preventDefault();
S(settings.tooltip_class + '.open').hide();
is_touch = true;
Expand All @@ -65,11 +67,13 @@
}
}
})
.on('mouseleave.fndtn.tooltip touchstart.fndtn.tooltip', '.open[' + this.attr_name() + ']', function (e) {
.on('mouseleave.fndtn.tooltip touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip', '[' + this.attr_name() + '].open', function (e) {
if (/mouse/i.test(e.type) && self.ie_touch(e)) return false;

if($(this).data('tooltip-open-event-type') == 'touch' && e.type == 'mouseleave') {
return;
}
else if($(this).data('tooltip-open-event-type') == 'mouse' && e.type == 'touchstart') {
else if($(this).data('tooltip-open-event-type') == 'mouse' && /MSPointerDown|touchstart/i.test(e.type)) {
self.convert_to_touch($(this));
} else {
self.hide($(this));
Expand All @@ -80,6 +84,11 @@
});
},

ie_touch : function (e) {
// How do I distinguish between IE11 and Windows Phone 8?????
return false;
},

showTip : function ($target) {
var $tip = this.getTip($target);

Expand Down Expand Up @@ -126,7 +135,7 @@

if (Modernizr.touch) {
$tip.append('<span class="tap-to-close">'+settings.touch_close_text+'</span>');
$tip.on('touchstart.fndtn.tooltip', function(e) {
$tip.on('touchstart.fndtn.tooltip MSPointerDown.fndtn.tooltip', function(e) {
self.hide($target);
});
}
Expand Down Expand Up @@ -215,7 +224,7 @@

if ($tip.find('.tap-to-close').length === 0) {
$tip.append('<span class="tap-to-close">'+settings.touch_close_text+'</span>');
$tip.on('click.fndtn.tooltip.tapclose touchstart.fndtn.tooltip.tapclose', function(e) {
$tip.on('click.fndtn.tooltip.tapclose touchstart.fndtn.tooltip.tapclose MSPointerDown.fndtn.tooltip.tapclose', function(e) {
self.hide($target);
});
}
Expand All @@ -240,7 +249,7 @@

$tip.fadeOut(150, function() {
$tip.find('.tap-to-close').remove();
$tip.off('click.fndtn.tooltip.tapclose touchstart.fndtn.tooltip.tapclose');
$tip.off('click.fndtn.tooltip.tapclose touchstart.fndtn.tooltip.tapclose MSPointerDown.fndtn.tapclose');
$target.removeClass('open');
});
},
Expand Down

0 comments on commit 4bba60c

Please sign in to comment.