Skip to content

Commit

Permalink
Update jQuery to v3.7
Browse files Browse the repository at this point in the history
Update to latest version of jQuery and removed all possible jQuery deprecations.
Some jQuery plugins still have deprecations, but they are going to work with v3.7.
  • Loading branch information
sascha-karnatz authored and tvdeyen committed Dec 28, 2023
1 parent 07c2095 commit 047b10b
Show file tree
Hide file tree
Showing 16 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/alchemy/admin.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Alchemy CMS Sprockets Manifest
// ------------------------------
//= require jquery2
//= require jquery3
//= require tinymce/tinymce.min
//= require_tree ../../../../vendor/assets/javascripts/jquery_plugins/
//= require clipboard.min
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class window.Alchemy.ConfirmDialog extends Alchemy.Dialog

bind_buttons: ->
@cancel_button.focus()
@cancel_button.click =>
@cancel_button.on "click", =>
@close()
false
@ok_button.click =>
@ok_button.on "click", =>
@close()
@options.on_ok()
false
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/alchemy/alchemy.dialog.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ class window.Alchemy.Dialog
# - Overlay (if the Dialog is a modal)
# - ESC Key
bind_close_events: ->
@close_button.click =>
@close_button.on "click", =>
@close()
false
@dialog_container.addClass('closable').click (e) =>
@dialog_container.addClass('closable').on "click", (e) =>
return true if e.target != @dialog_container.get(0)
@close()
false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Alchemy.ToolbarButton = (options) ->
$lnk = $("<a class='icon_button' href='#' />")
if options.hotkey
$lnk.attr('data-alchemy-hotkey', options.hotkey)
$lnk.click (e) ->
$lnk.on "click", (e) ->
e.preventDefault()
options.onClick(e)
return
Expand All @@ -31,7 +31,7 @@ Alchemy.ElementsWindow =
@element_window.append @createToolbar(options.toolbarButtons)
@element_window.append @element_area
@button = $('#element_window_button')
@button.click =>
@button.on "click", =>
@hide()
false

Expand Down Expand Up @@ -95,13 +95,13 @@ Alchemy.ElementsWindow =
@button.find('label').text(@options.texts.showElements)
@button.find('.icon').removeClass("ri-menu-unfold-line").addClass("ri-menu-fold-line")
@button.off('click')
@button.click =>
@button.on "click", =>
@show()
false
else
@button.find('label').text(@options.texts.hideElements)
@button.find('.icon').removeClass("ri-menu-fold-line").addClass("ri-menu-unfold-line")
@button.off('click')
@button.click =>
@button.on "click", =>
@hide()
false
2 changes: 1 addition & 1 deletion app/assets/javascripts/alchemy/alchemy.growler.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Alchemy.Growler =

fade: ->
$(".flash:not(.error)", "#flash_notices").delay(5000).queue(-> Alchemy.Growler.dismiss(this))
$(".flash", "#flash_notices").click((e) => @dismiss(e.currentTarget))
$(".flash", "#flash_notices").on("click", (e) => @dismiss(e.currentTarget))
return

dismiss: (element) ->
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/alchemy/alchemy.image_overlay.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class window.Alchemy.ImageOverlay extends Alchemy.Dialog

init: ->
Alchemy.ImageLoader(@dialog_body[0])
$('.zoomed-picture-background').click (e) =>
$('.zoomed-picture-background').on "click", (e) =>
e.stopPropagation()
return if e.target.nodeName == 'IMG'
@close()
false
$('.picture-overlay-handle').click (e) =>
$('.picture-overlay-handle').on "click", (e) =>
@dialog.toggleClass('hide-form')
false
@$previous = $('.previous-picture')
Expand Down
4 changes: 2 additions & 2 deletions app/assets/javascripts/alchemy/alchemy.list_filter.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ class Alchemy.ListFilterHandler
@filter_field.on 'keyup', (e) =>
@clear.show()
@_filter @filter_field.val()
@clear.click (e) =>
@clear.on "click", (e) =>
e.preventDefault()
@_clear()
@filter_field.focus ->
@filter_field.on "focus", ->
key.setScope('list_filter')
key 'esc', 'list_filter', =>
@_clear()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Alchemy.PreviewWindow =
$iframe = $("<iframe name=\"alchemy_preview_window\" src=\"#{@previewUrl}\" id=\"alchemy_preview_window\" frameborder=\"0\"/>")
$reload = $('#reload_preview_button')
@_showSpinner()
$iframe.load =>
$iframe.on "load", =>
@_hideSpinner()
$('body').append($iframe)
@currentWindow = $iframe
Expand All @@ -31,7 +31,7 @@ Alchemy.PreviewWindow =
@_showSpinner()
# We need to be sure that no load event is binded on the preview frame.
$iframe.off('load')
$iframe.load (e) =>
$iframe.on "load", (e) =>
@_hideSpinner()
if callback
callback.call(e, $iframe)
Expand All @@ -55,7 +55,7 @@ Alchemy.PreviewWindow =
$reload = $('#reload_preview_button')
key 'alt+r', =>
@refresh()
$reload.click (e) =>
$reload.on "click", (e) =>
e.preventDefault()
@refresh()

Expand All @@ -71,7 +71,7 @@ Alchemy.PreviewWindow =
null

_bindSelect: ->
$(@select).change (e) =>
$(@select).on "change", (e) =>
@previewUrl = e.target.value
option = e.target.querySelector("option[value='#{@previewUrl}']")
window.localStorage.setItem("alchemyPreview", option.text)
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/alchemy_admin/dirty.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ function checkPageDirtyness(element) {
}

function PageLeaveObserver() {
$("#main_navi a").click(function (event) {
$("#main_navi a").on("click", function (event) {
if (!checkPageDirtyness(event.currentTarget)) {
event.preventDefault()
}
Expand Down
4 changes: 2 additions & 2 deletions app/javascript/alchemy_admin/image_cropper.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,15 +90,15 @@ export default class ImageCropper {
}

bind() {
this.dialog.dialog_body.find('button[type="submit"]').click(() => {
this.dialog.dialog_body.find('button[type="submit"]').on("click", () => {
const elementEditor = document.querySelector(
`[data-element-id='${this.elementId}']`
)
elementEditor.setDirty()
this.dialog.close()
return false
})
this.dialog.dialog_body.find('button[type="reset"]').click(() => {
this.dialog.dialog_body.find('button[type="reset"]').on("click", () => {
this.reset()
return false
})
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/alchemy_admin/initializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function Initialize() {
// Add observer for please wait overlay.
$(".please_wait")
.not("*[data-alchemy-confirm]")
.click(Alchemy.pleaseWaitOverlay)
.on("click", Alchemy.pleaseWaitOverlay)

// Hack for enabling tab focus for <a>'s styled as button.
$("a.button").attr({ tabindex: 0 })
Expand Down
2 changes: 1 addition & 1 deletion app/javascript/alchemy_admin/tags_autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function initSelection(element, callback) {
const data = []
$(element.val().split(",")).each(function () {
data.push({
id: $.trim(this),
id: this.trim(),
text: this
})
})
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/crop.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<% if @settings %>
<script type="text/javascript">
Alchemy.ImageLoader('#jscropper .thumbnail_background');
$('#imageToCrop').load(function() {
$('#imageToCrop').on("load", function() {
new Alchemy.ImageCropper(
<%= @settings[:min_size].to_json %>,
<%= @settings[:default_box].to_json %>,
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/admin/pictures/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@
$(".selected_item_tools").toggleClass("hidden")
return false;
});
$('.thumbnail_background').click(function(event) {
$('.thumbnail_background').on("click", function(event) {
var url = $(this).attr('href');
var overlay = new Alchemy.ImageOverlay(url);
overlay.open();
Expand Down
2 changes: 1 addition & 1 deletion app/views/alchemy/base/500.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

<script>
$(function(){
$('.error_details--toggle').click(function(){
$('.error_details--toggle').on("click", function(){
$('.error.message p').toggleClass('hidden');
return false;
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
"flatpickr": "^4.6.9",
"jest": "^29.6.4",
"jest-environment-jsdom": "^29.6.4",
"jquery": "^2.2.4",
"jquery": "^3.7.1",
"jsdom-testing-mocks": "^1.11.0",
"lodash-es": "^4.17.21",
"prettier": "^3.0.0",
Expand Down

0 comments on commit 047b10b

Please sign in to comment.