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

Replacing deprecated shorthands due… #894

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion example1/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$('.retina').colorbox({rel:'group5', transition:'none', retinaImage:true, retinaUrl:true});

//Example of preserving a JavaScript event for inline calls.
$("#click").click(function(){
$("#click").on("click", function(){
$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
return false;
});
Expand Down
2 changes: 1 addition & 1 deletion example2/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$('.retina').colorbox({rel:'group5', transition:'none', retinaImage:true, retinaUrl:true});

//Example of preserving a JavaScript event for inline calls.
$("#click").click(function(){
$("#click").on("click", function(){
$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
return false;
});
Expand Down
2 changes: 1 addition & 1 deletion example3/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$('.retina').colorbox({rel:'group5', transition:'none', retinaImage:true, retinaUrl:true});

//Example of preserving a JavaScript event for inline calls.
$("#click").click(function(){
$("#click").on("click", function(){
$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
return false;
});
Expand Down
2 changes: 1 addition & 1 deletion example4/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$('.retina').colorbox({rel:'group5', transition:'none', retinaImage:true, retinaUrl:true});

//Example of preserving a JavaScript event for inline calls.
$("#click").click(function(){
$("#click").on("click", function(){
$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
return false;
});
Expand Down
2 changes: 1 addition & 1 deletion example5/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
$('.retina').colorbox({rel:'group5', transition:'none', retinaImage:true, retinaUrl:true});

//Example of preserving a JavaScript event for inline calls.
$("#click").click(function(){
$("#click").on("click", function(){
$('#click').css({"background-color":"#f00", "color":"#fff", "cursor":"inherit"}).text("Open this window again and this message will still be here.");
return false;
});
Expand Down
2 changes: 1 addition & 1 deletion jquery.colorbox-min.js

Large diffs are not rendered by default.

54 changes: 28 additions & 26 deletions jquery.colorbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@

this.get = function(key) {
var value = this.value(key);
return $.isFunction(value) ? value.call(this.el, this) : value;
return typeof value === "function" ? value.call(this.el, this) : value;
};
}

Expand Down Expand Up @@ -318,12 +318,12 @@
function start() {
$slideshow
.html(settings.get('slideshowStop'))
.unbind(click)
.off(click)
.one(click, stop);

$events
.bind(event_complete, set)
.bind(event_load, clear);
.on(event_complete, set)
.on(event_load, clear);

$box.removeClass(className + "off").addClass(className + "on");
}
Expand All @@ -332,12 +332,12 @@
clear();

$events
.unbind(event_complete, set)
.unbind(event_load, clear);
.off(event_complete, set)
.off(event_load, clear);

$slideshow
.html(settings.get('slideshowStart'))
.unbind(click)
.off(click)
.one(click, function () {
publicMethod.next();
start();
Expand All @@ -351,15 +351,15 @@
$slideshow.hide();
clear();
$events
.unbind(event_complete, set)
.unbind(event_load, clear);
.off(event_complete, set)
.off(event_load, clear);
$box.removeClass(className + "off " + className + "on");
}

return function(){
if (active) {
if (!settings.get('slideshow')) {
$events.unbind(event_cleanup, reset);
$events.off(event_cleanup, reset);
reset();
}
} else {
Expand Down Expand Up @@ -533,23 +533,23 @@
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", function () {
publicMethod.next();
});
$prev.click(function () {
$prev.on("click", function () {
publicMethod.prev();
});
$close.click(function () {
$close.on("click", function () {
publicMethod.close();
});
$overlay.click(function () {
$overlay.on("click", function () {
if (settings.get('overlayClose')) {
publicMethod.close();
}
});

// Key Bindings
$(document).bind('keydown.' + prefix, function (e) {
$(document).on('keydown.' + prefix, function (e) {
var key = e.keyCode;
if (open && settings.get('escKey') && key === 27) {
e.preventDefault();
Expand All @@ -558,15 +558,16 @@
if (open && settings.get('arrowKey') && $related[1] && !e.altKey) {
if (key === 37) {
e.preventDefault();
$prev.click();
$prev.trigger("click");
} else if (key === 39) {
e.preventDefault();
$next.click();
$next.trigger("click");
}
}
});

if ($.isFunction($.fn.on)) {
if (typeof $.fn.on === "function") {

// For jQuery 1.7+
$(document).on('click.'+prefix, '.'+boxElement, clickHandler);
} else {
Expand Down Expand Up @@ -602,7 +603,7 @@

options = options || {};

if ($.isFunction($obj)) { // assume a call to $.colorbox
if (typeof $obj === "function") { // assume a call to $.colorbox
$obj = $('<a/>');
options.open = true;
}
Expand Down Expand Up @@ -643,7 +644,7 @@
scrollTop,
scrollLeft;

$window.unbind('resize.' + prefix);
$window.off('resize.' + prefix);

// remove the modal so that it doesn't influence the document width/height
$box.css({top: -9e4, left: -9e4});
Expand Down Expand Up @@ -723,11 +724,12 @@

if (settings.get('reposition')) {
setTimeout(function () { // small delay before binding onresize due to an IE8 bug.
$window.bind('resize.' + prefix, publicMethod.position);
$window.on('resize.' + prefix, publicMethod.position);
}, 1);
}

if ($.isFunction(loadedCallback)) {
if (typeof loadedCallback === "function") {

loadedCallback();
}
},
Expand Down Expand Up @@ -974,7 +976,7 @@

$(photo)
.addClass(prefix + 'Photo')
.bind('error.'+prefix,function () {
.on('error.'+prefix,function () {
prep($tag(div, 'Error').html(settings.get('imgError')));
})
.one('load', function () {
Expand Down Expand Up @@ -1014,7 +1016,7 @@
if ($related[1] && (settings.get('loop') || $related[index + 1])) {
photo.style.cursor = 'pointer';

$(photo).bind('click.'+prefix, function () {
$(photo).on('click.'+prefix, function () {
publicMethod.next();
});
}
Expand Down Expand Up @@ -1059,7 +1061,7 @@
open = false;
trigger(event_cleanup);
settings.get('onCleanup');
$window.unbind('.' + prefix);
$window.off('.' + prefix);
$overlay.fadeTo(settings.get('fadeOut') || 0, 0);

$box.stop().fadeTo(settings.get('fadeOut') || 0, 0, function () {
Expand Down Expand Up @@ -1091,7 +1093,7 @@
.removeData(colorbox)
.removeClass(boxElement);

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

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