Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update jquery.colobox.js touch support #828

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions jquery.colorbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@
var slideshow = (function(){
var active,
className = prefix + "Slideshow_",
click = "click." + prefix,
click = "click." + prefix + " touchstart." + prefix,
timeOut;

function clear () {
Expand Down Expand Up @@ -533,16 +533,16 @@
init = true;

// Anonymous functions here keep the public method from being cached, thereby allowing them to be redefined on the fly.
$next.click(function () {
$next.on("click touchstart",function () {
publicMethod.next();
});
$prev.click(function () {
$prev.on("click touchstart",function () {
publicMethod.prev();
});
$close.click(function () {
$close.on("click touchstart",function () {
publicMethod.close();
});
$overlay.click(function () {
$overlay.on("click touchstart",function () {
if (settings.get('overlayClose')) {
publicMethod.close();
}
Expand All @@ -568,12 +568,12 @@

if ($.isFunction($.fn.on)) {
// For jQuery 1.7+
$(document).on('click.'+prefix, '.'+boxElement, clickHandler);
$(document).on('click.'+prefix + ' touchstart.'+prefix, '.'+boxElement, clickHandler);
} else {
// For jQuery 1.3.x -> 1.6.x
// This code is never reached in jQuery 1.9, so do not contact me about 'live' being removed.
// This is not here for jQuery 1.9, it's here for legacy users.
$('.'+boxElement).live('click.'+prefix, clickHandler);
$('.'+boxElement).live('click.'+prefix + ' touchstart.'+prefix, clickHandler);
}
}
return true;
Expand Down Expand Up @@ -1014,7 +1014,7 @@
if ($related[1] && (settings.get('loop') || $related[index + 1])) {
photo.style.cursor = 'pointer';

$(photo).bind('click.'+prefix, function () {
$(photo).bind('click.'+prefix+ ' touchstart.'+prefix, function () {
publicMethod.next();
});
}
Expand Down Expand Up @@ -1091,7 +1091,7 @@
.removeData(colorbox)
.removeClass(boxElement);

$(document).unbind('click.'+prefix).unbind('keydown.'+prefix);
$(document).unbind('click.'+prefix+ ' touchstart.'+prefix).unbind('keydown.'+prefix);
};

// A method for fetching the current element Colorbox is referencing.
Expand Down