Skip to content
This repository has been archived by the owner on Aug 15, 2024. It is now read-only.

Add support for jQuery 3 #31

Merged
merged 1 commit into from
Aug 15, 2024
Merged
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
14 changes: 12 additions & 2 deletions app/assets/javascripts/openseadragon/rails.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
$('picture[data-openseadragon]').openseadragon();
}

var handler = 'ready';
const jquery3 = parseInt($.fn.jquery.split('.')[0]) >= 3;
let handler = 'ready';
if (typeof Turbolinks !== 'undefined' && Turbolinks.supported) {
// Turbolinks 5
if (Turbolinks.BrowserAdapter) {
Expand All @@ -15,5 +16,14 @@
handler = 'page:load ready';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this branch also need some handling?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thanks. I saw "Turbolinks", and my eyes moved right over it...

}
}
$(document).on(handler, initOpenSeadragon);

// Support for $(document).on( "ready", handler ) was removed in jQuery 3
if (jquery3 && handler.includes('ready')) {
handler = handler.replace('ready', '').trim();
$(initOpenSeadragon);
}

if (handler) {
$(document).on(handler, initOpenSeadragon);
}
})(jQuery);
Loading