From d5b981719f26900660b821df2dc8b0a69bf8dbb1 Mon Sep 17 00:00:00 2001 From: webzwo0i Date: Mon, 5 Jul 2021 17:12:47 +0200 Subject: [PATCH] jQuery: Migrate to `.on()`, `.off()`, `.trigger()` This avoids methods that are deprecated in newer versions of jQuery. --- src/static/js/ace2_inner.js | 8 ++--- src/static/js/admin/plugins.js | 12 +++---- src/static/js/admin/settings.js | 2 +- src/static/js/broadcast_slider.js | 30 ++++++++-------- src/static/js/chat.js | 14 ++++---- src/static/js/collab_client.js | 2 +- src/static/js/index.js | 4 +-- src/static/js/pad.js | 6 ++-- src/static/js/pad_automatic_reconnect.js | 2 +- src/static/js/pad_connectionstatus.js | 2 +- src/static/js/pad_editbar.js | 36 +++++++++---------- src/static/js/pad_editor.js | 4 +-- src/static/js/pad_impexp.js | 6 ++-- src/static/js/pad_userlist.js | 18 +++++----- src/static/js/pad_utils.js | 8 ++--- src/static/js/skin_variants.js | 2 +- src/static/js/timeslider.js | 4 +-- src/static/skins/colibris/pad.js | 4 +-- src/tests/frontend/helper/methods.js | 12 +++---- src/tests/frontend/helper/ui.js | 10 +++--- src/tests/frontend/specs/adminsettings.js | 4 +-- .../frontend/specs/adminupdateplugins.js | 6 ++-- .../frontend/specs/authorship_of_editions.js | 4 +-- src/tests/frontend/specs/bold.js | 2 +- src/tests/frontend/specs/change_user_color.js | 20 +++++------ .../frontend/specs/chat_load_messages.js | 12 +++---- .../frontend/specs/clear_authorship_colors.js | 10 +++--- src/tests/frontend/specs/drag_and_drop.js | 4 +-- src/tests/frontend/specs/embed_value.js | 12 +++---- src/tests/frontend/specs/font_type.js | 4 +-- src/tests/frontend/specs/helper.js | 8 ++--- src/tests/frontend/specs/importexport.js | 4 +-- src/tests/frontend/specs/indentation.js | 22 ++++++------ src/tests/frontend/specs/italic.js | 2 +- src/tests/frontend/specs/language.js | 16 ++++----- ...ultiple_authors_clear_authorship_colors.js | 2 +- src/tests/frontend/specs/ordered_list.js | 16 ++++----- src/tests/frontend/specs/pad_modal.js | 6 ++-- src/tests/frontend/specs/redo.js | 4 +-- .../specs/select_formatting_buttons.js | 4 +-- src/tests/frontend/specs/strikethrough.js | 2 +- src/tests/frontend/specs/timeslider.js | 2 +- src/tests/frontend/specs/timeslider_follow.js | 14 ++++---- .../frontend/specs/timeslider_revisions.js | 2 +- src/tests/frontend/specs/undo.js | 2 +- src/tests/frontend/specs/unordered_list.js | 18 +++++----- src/tests/frontend/specs/xxauto_reconnect.js | 2 +- 47 files changed, 195 insertions(+), 195 deletions(-) diff --git a/src/static/js/ace2_inner.js b/src/static/js/ace2_inner.js index a8b98ac16..e64c8695d 100644 --- a/src/static/js/ace2_inner.js +++ b/src/static/js/ace2_inner.js @@ -2585,17 +2585,17 @@ function Ace2Inner(editorInfo, cssManagers) { const firstEditbarElement = parent.parent.$('#editbar') .children('ul').first().children().first() .children().first().children().first(); - $(this).blur(); - firstEditbarElement.focus(); + $(this).trigger('blur'); + firstEditbarElement.trigger('focus'); evt.preventDefault(); } if (!specialHandled && type === 'keydown' && altKey && keyCode === 67 && padShortcutEnabled.altC) { // Alt c focuses on the Chat window - $(this).blur(); + $(this).trigger('blur'); parent.parent.chat.show(); - parent.parent.$('#chatinput').focus(); + parent.parent.$('#chatinput').trigger('focus'); evt.preventDefault(); } if (!specialHandled && type === 'keydown' && diff --git a/src/static/js/admin/plugins.js b/src/static/js/admin/plugins.js index d3636dfd8..a3bcbc2c3 100644 --- a/src/static/js/admin/plugins.js +++ b/src/static/js/admin/plugins.js @@ -112,15 +112,15 @@ $(document).ready(() => { const updateHandlers = () => { // Search - $('#search-query').unbind('keyup').keyup(() => { + $('#search-query').off('keyup').on('keyup', () => { search($('#search-query').val()); }); // Prevent form submit - $('#search-query').parent().bind('submit', () => false); + $('#search-query').parent().on('submit', () => false); // update & install - $('.do-install, .do-update').unbind('click').click(function (e) { + $('.do-install, .do-update').off('click').on('click', function (e) { const $row = $(e.target).closest('tr'); const plugin = $row.data('plugin'); if ($(this).hasClass('do-install')) { @@ -134,7 +134,7 @@ $(document).ready(() => { }); // uninstall - $('.do-uninstall').unbind('click').click((e) => { + $('.do-uninstall').off('click').on('click', (e) => { const $row = $(e.target).closest('tr'); const pluginName = $row.data('plugin'); socket.emit('uninstall', pluginName); @@ -143,14 +143,14 @@ $(document).ready(() => { }); // Sort - $('.sort.up').unbind('click').click(function () { + $('.sort.up').off('click').on('click', function () { search.sortBy = $(this).attr('data-label').toLowerCase(); search.sortDir = false; search.offset = 0; search(search.searchTerm, search.results.length); search.results = []; }); - $('.sort.down, .sort.none').unbind('click').click(function () { + $('.sort.down, .sort.none').off('click').on('click', function () { search.sortBy = $(this).attr('data-label').toLowerCase(); search.sortDir = true; search.offset = 0; diff --git a/src/static/js/admin/settings.js b/src/static/js/admin/settings.js index a53937471..33bb12689 100644 --- a/src/static/js/admin/settings.js +++ b/src/static/js/admin/settings.js @@ -25,7 +25,7 @@ $(document).ready(() => { /* Check to make sure the JSON is clean before proceeding */ if (isJSONClean(settings.results)) { $('.settings').append(settings.results); - $('.settings').focus(); + $('.settings').trigger('focus'); $('.settings').autosize(); } else { alert('Invalid JSON'); diff --git a/src/static/js/broadcast_slider.js b/src/static/js/broadcast_slider.js index f03a22836..80afffe28 100644 --- a/src/static/js/broadcast_slider.js +++ b/src/static/js/broadcast_slider.js @@ -67,7 +67,7 @@ const loadBroadcastSliderJS = (fireWhenAllScriptsAreLoaded) => { newSavedRevision.css( 'left', (position * ($('#ui-slider-bar').width() - 2) / (sliderLength * 1.0)) - 1); $('#ui-slider-bar').append(newSavedRevision); - newSavedRevision.mouseup((evt) => { + newSavedRevision.on('mouseup', (evt) => { BroadcastSlider.setSliderPosition(position); }); savedRevisions.push(newSavedRevision); @@ -209,21 +209,21 @@ const loadBroadcastSliderJS = (fireWhenAllScriptsAreLoaded) => { // assign event handlers to html UI elements after page load fireWhenAllScriptsAreLoaded.push(() => { - $(document).keyup((e) => { + $(document).on('keyup', (e) => { if (!e) e = window.event; const code = e.keyCode || e.which; if (code === 37) { // left if (e.shiftKey) { - $('#leftstar').click(); + $('#leftstar').trigger('click'); } else { - $('#leftstep').click(); + $('#leftstep').trigger('click'); } } else if (code === 39) { // right if (e.shiftKey) { - $('#rightstar').click(); + $('#rightstar').trigger('click'); } else { - $('#rightstep').click(); + $('#rightstep').trigger('click'); } } else if (code === 32) { // spacebar $('#playpause_button_icon').trigger('click'); @@ -231,22 +231,22 @@ const loadBroadcastSliderJS = (fireWhenAllScriptsAreLoaded) => { }); // Resize - $(window).resize(() => { + $(window).on('resize', () => { updateSliderElements(); }); // Slider click - $('#ui-slider-bar').mousedown((evt) => { + $('#ui-slider-bar').on('mousedown', (evt) => { $('#ui-slider-handle').css('left', (evt.clientX - $('#ui-slider-bar').offset().left)); $('#ui-slider-handle').trigger(evt); }); // Slider dragging - $('#ui-slider-handle').mousedown(function (evt) { + $('#ui-slider-handle').on('mousedown', function (evt) { this.startLoc = evt.clientX; this.currentLoc = parseInt($(this).css('left')); sliderActive = true; - $(document).mousemove((evt2) => { + $(document).on('mousemove', (evt2) => { $(this).css('pointer', 'move'); let newloc = this.currentLoc + (evt2.clientX - this.startLoc); if (newloc < 0) newloc = 0; @@ -257,9 +257,9 @@ const loadBroadcastSliderJS = (fireWhenAllScriptsAreLoaded) => { $(this).css('left', newloc); if (getSliderPosition() !== version) _callSliderCallbacks(version); }); - $(document).mouseup((evt2) => { - $(document).unbind('mousemove'); - $(document).unbind('mouseup'); + $(document).on('mouseup', (evt2) => { + $(document).off('mousemove'); + $(document).off('mouseup'); sliderActive = false; let newloc = this.currentLoc + (evt2.clientX - this.startLoc); if (newloc < 0) newloc = 0; @@ -276,12 +276,12 @@ const loadBroadcastSliderJS = (fireWhenAllScriptsAreLoaded) => { }); // play/pause toggling - $('#playpause_button_icon').click((evt) => { + $('#playpause_button_icon').on('click', (evt) => { BroadcastSlider.playpause(); }); // next/prev saved revision and changeset - $('.stepper').click(function (evt) { + $('.stepper').on('click', function (evt) { switch ($(this).attr('id')) { case 'leftstep': setSliderPosition(getSliderPosition() - 1); diff --git a/src/static/js/chat.js b/src/static/js/chat.js index 63c17c153..48cc562b0 100755 --- a/src/static/js/chat.js +++ b/src/static/js/chat.js @@ -42,7 +42,7 @@ exports.chat = (() => { }, focus: () => { setTimeout(() => { - $('#chatinput').focus(); + $('#chatinput').trigger('focus'); }, 100); }, // Make chat stick to right hand side of screen @@ -223,14 +223,14 @@ exports.chat = (() => { // Send the users focus back to the pad if ((evt.altKey === true && evt.which === 67) || evt.which === 27) { // If we're in chat already.. - $(':focus').blur(); // required to do not try to remove! + $(':focus').trigger('blur'); // required to do not try to remove! padeditor.ace.focus(); // Sends focus back to pad evt.preventDefault(); return false; } }); // Clear the chat mentions when the user clicks on the chat input box - $('#chatinput').click(() => { + $('#chatinput').on('click', () => { chatMentions = 0; Tinycon.setBubble(0); }); @@ -239,14 +239,14 @@ exports.chat = (() => { $('body:not(#chatinput)').on('keypress', function (evt) { if (evt.altKey && evt.which === 67) { // Alt c focuses on the Chat window - $(this).blur(); + $(this).trigger('blur'); self.show(); - $('#chatinput').focus(); + $('#chatinput').trigger('focus'); evt.preventDefault(); } }); - $('#chatinput').keypress((evt) => { + $('#chatinput').on('keypress', (evt) => { // if the user typed enter, fire the send if (evt.key === 'Enter' && !evt.shiftKey) { evt.preventDefault(); @@ -257,7 +257,7 @@ exports.chat = (() => { // initial messages are loaded in pad.js' _afterHandshake $('#chatcounter').text(0); - $('#chatloadmessagesbutton').click(() => { + $('#chatloadmessagesbutton').on('click', () => { const start = Math.max(this.historyPointer - 20, 0); const end = this.historyPointer; diff --git a/src/static/js/collab_client.js b/src/static/js/collab_client.js index 74bc66f9f..11a3a3dc6 100644 --- a/src/static/js/collab_client.js +++ b/src/static/js/collab_client.js @@ -66,7 +66,7 @@ const getCollabClient = (ace2editor, serverVars, initialUserInfo, options, _pad) if (browser.firefox) { // Prevent "escape" from taking effect and canceling a comet connection; // doesn't work if focus is on an iframe. - $(window).bind('keydown', (evt) => { + $(window).on('keydown', (evt) => { if (evt.which === 27) { evt.preventDefault(); } diff --git a/src/static/js/index.js b/src/static/js/index.js index b0b3a1ebb..d50c14e7d 100644 --- a/src/static/js/index.js +++ b/src/static/js/index.js @@ -41,7 +41,7 @@ const randomPadName = () => { }; $(() => { - $('#go2Name').submit(() => { + $('#go2Name').on('submit', () => { const padname = $('#padname').val(); if (padname.length > 0) { window.location = `p/${encodeURIComponent(padname.trim())}`; @@ -51,7 +51,7 @@ $(() => { return false; }); - $('#button').click(() => { + $('#button').on('click', () => { window.location = `p/${randomPadName()}`; }); diff --git a/src/static/js/pad.js b/src/static/js/pad.js index c37920ead..18c33c5c5 100644 --- a/src/static/js/pad.js +++ b/src/static/js/pad.js @@ -437,8 +437,8 @@ const pad = { // Prevent sticky chat or chat and users to be checked for mobiles const checkChatAndUsersVisibility = (x) => { if (x.matches) { // If media query matches - $('#options-chatandusers:checked').click(); - $('#options-stickychat:checked').click(); + $('#options-chatandusers:checked').trigger('click'); + $('#options-stickychat:checked').trigger('click'); } }; const mobileMatch = window.matchMedia('(max-width: 800px)'); @@ -711,7 +711,7 @@ const pad = { $('form#reconnectform input.diagnosticInfo').val(JSON.stringify(pad.diagnosticInfo)); $('form#reconnectform input.missedChanges') .val(JSON.stringify(pad.collabClient.getMissedChanges())); - $('form#reconnectform').submit(); + $('form#reconnectform').trigger('submit'); }, callWhenNotCommitting: (f) => { pad.collabClient.callWhenNotCommitting(f); diff --git a/src/static/js/pad_automatic_reconnect.js b/src/static/js/pad_automatic_reconnect.js index 9d9ee953a..576e0d350 100644 --- a/src/static/js/pad_automatic_reconnect.js +++ b/src/static/js/pad_automatic_reconnect.js @@ -96,7 +96,7 @@ const whenConnectionIsRestablishedWithServer = (callback, pad) => { }; const forceReconnection = ($modal) => { - $modal.find('#forcereconnect').click(); + $modal.find('#forcereconnect').trigger('click'); }; const updateCountDownTimerMessage = ($modal, minutes, seconds) => { diff --git a/src/static/js/pad_connectionstatus.js b/src/static/js/pad_connectionstatus.js index 1282d488c..7b0497d96 100644 --- a/src/static/js/pad_connectionstatus.js +++ b/src/static/js/pad_connectionstatus.js @@ -31,7 +31,7 @@ const padconnectionstatus = (() => { const self = { init: () => { - $('button#forcereconnect').click(() => { + $('button#forcereconnect').on('click', () => { window.location.reload(); }); }, diff --git a/src/static/js/pad_editbar.js b/src/static/js/pad_editbar.js index 9d006d2c7..d7f12465d 100644 --- a/src/static/js/pad_editbar.js +++ b/src/static/js/pad_editbar.js @@ -65,13 +65,13 @@ class ToolbarItem { bind(callback) { if (this.isButton()) { - this.$el.click((event) => { - $(':focus').blur(); + this.$el.on('click', (event) => { + $(':focus').trigger('blur'); callback(this.getCommand(), this); event.preventDefault(); }); } else if (this.isSelect()) { - this.$el.find('select').change(() => { + this.$el.find('select').on('change', () => { callback(this.getCommand(), this); }); } @@ -134,7 +134,7 @@ exports.padeditbar = new class { $('#editbar .editbarbutton').attr('unselectable', 'on'); // for IE this.enable(); $('#editbar [data-key]').each((i, elt) => { - $(elt).unbind('click'); + $(elt).off('click'); new ToolbarItem($(elt)).bind((command, item) => { this.triggerCommand(command, item); }); @@ -144,11 +144,11 @@ exports.padeditbar = new class { this._bodyKeyEvent(evt); }); - $('.show-more-icon-btn').click(() => { + $('.show-more-icon-btn').on('click', () => { $('.toolbar').toggleClass('full-icons'); }); this.checkAllIconsAreDisplayedInToolbar(); - $(window).resize(_.debounce(() => this.checkAllIconsAreDisplayedInToolbar(), 100)); + $(window).on('resize', _.debounce(() => this.checkAllIconsAreDisplayedInToolbar(), 100)); this._registerDefaultCommands(); @@ -168,7 +168,7 @@ exports.padeditbar = new class { } // When editor is scrolled, we add a class to style the editbar differently - $('iframe[name="ace_outer"]').contents().scroll((ev) => { + $('iframe[name="ace_outer"]').contents().on('scroll', (ev) => { $('#editbar').toggleClass('editor-scrolled', $(ev.currentTarget).scrollTop() > 2); }); } @@ -305,12 +305,12 @@ exports.padeditbar = new class { // Close any dropdowns we have open.. this.toggleDropDown('none'); // Shift focus away from any drop downs - $(':focus').blur(); // required to do not try to remove! + $(':focus').trigger('blur'); // required to do not try to remove! // Check we're on a pad and not on the timeslider // Or some other window I haven't thought about! if (typeof pad === 'undefined') { // Timeslider probably.. - $('#editorcontainerbox').focus(); // Focus back onto the pad + $('#editorcontainerbox').trigger('focus'); // Focus back onto the pad } else { padeditor.ace.focus(); // Sends focus back to pad // The above focus doesn't always work in FF, you have to hit enter afterwards @@ -320,8 +320,8 @@ exports.padeditbar = new class { // Focus on the editbar :) const firstEditbarElement = parent.parent.$('#editbar button').first(); - $(evt.currentTarget).blur(); - firstEditbarElement.focus(); + $(evt.currentTarget).trigger('blur'); + firstEditbarElement.trigger('focus'); evt.preventDefault(); } } @@ -341,7 +341,7 @@ exports.padeditbar = new class { this._editbarPosition--; // Allow focus to shift back to end of row and start of row if (this._editbarPosition === -1) this._editbarPosition = focusItems.length - 1; - $(focusItems[this._editbarPosition]).focus(); + $(focusItems[this._editbarPosition]).trigger('focus'); } // On right arrow move to next button in editbar @@ -352,7 +352,7 @@ exports.padeditbar = new class { this._editbarPosition++; // Allow focus to shift back to end of row and start of row if (this._editbarPosition >= focusItems.length) this._editbarPosition = 0; - $(focusItems[this._editbarPosition]).focus(); + $(focusItems[this._editbarPosition]).trigger('focus'); } } } @@ -366,7 +366,7 @@ exports.padeditbar = new class { this.registerCommand('settings', () => { this.toggleDropDown('settings'); - $('#options-stickychat').focus(); + $('#options-stickychat').trigger('focus'); }); this.registerCommand('import_export', () => { @@ -374,22 +374,22 @@ exports.padeditbar = new class { // If Import file input exists then focus on it.. if ($('#importfileinput').length !== 0) { setTimeout(() => { - $('#importfileinput').focus(); + $('#importfileinput').trigger('focus'); }, 100); } else { - $('.exportlink').first().focus(); + $('.exportlink').first().trigger('focus'); } }); this.registerCommand('showusers', () => { this.toggleDropDown('users'); - $('#myusernameedit').focus(); + $('#myusernameedit').trigger('focus'); }); this.registerCommand('embed', () => { this.setEmbedLinks(); this.toggleDropDown('embed'); - $('#linkinput').focus().select(); + $('#linkinput').trigger('focus').trigger('select'); }); this.registerCommand('savedRevision', () => { diff --git a/src/static/js/pad_editor.js b/src/static/js/pad_editor.js index e39f73fee..585cccbb5 100644 --- a/src/static/js/pad_editor.js +++ b/src/static/js/pad_editor.js @@ -76,7 +76,7 @@ const padeditor = (() => { }); // font family change - $('#viewfontmenu').change(() => { + $('#viewfontmenu').on('change', () => { pad.changeViewOption('padFontFamily', $('#viewfontmenu').val()); }); @@ -97,7 +97,7 @@ const padeditor = (() => { }); }); $('#languagemenu').val(html10n.getLanguage()); - $('#languagemenu').change(() => { + $('#languagemenu').on('change', () => { Cookies.set('language', $('#languagemenu').val()); window.html10n.localize([$('#languagemenu').val(), 'en']); if ($('select').niceSelect) { diff --git a/src/static/js/pad_impexp.js b/src/static/js/pad_impexp.js index c85a791eb..80df3502b 100644 --- a/src/static/js/pad_impexp.js +++ b/src/static/js/pad_impexp.js @@ -162,9 +162,9 @@ const padimpexp = (() => { } addImportFrames(); - $('#importfileinput').change(fileInputUpdated); - $('#importform').unbind('submit').submit(fileInputSubmit); - $('.disabledexport').click(cantExport); + $('#importfileinput').on('change', fileInputUpdated); + $('#importform').off('submit').on('submit', fileInputSubmit); + $('.disabledexport').on('click', cantExport); }, disable: () => { $('#impexp-disabled-clickcatcher').show(); diff --git a/src/static/js/pad_userlist.js b/src/static/js/pad_userlist.js index 07c223341..6b18c1a96 100644 --- a/src/static/js/pad_userlist.js +++ b/src/static/js/pad_userlist.js @@ -325,21 +325,21 @@ const paduserlist = (() => { }; const setUpEditable = (jqueryNode, valueGetter, valueSetter) => { - jqueryNode.bind('focus', (evt) => { + jqueryNode.on('focus', (evt) => { const oldValue = valueGetter(); if (jqueryNode.val() !== oldValue) { jqueryNode.val(oldValue); } jqueryNode.addClass('editactive').removeClass('editempty'); }); - jqueryNode.bind('blur', (evt) => { + jqueryNode.on('blur', (evt) => { const newValue = jqueryNode.removeClass('editactive').val(); valueSetter(newValue); }); padutils.bindEnterAndEscape(jqueryNode, () => { - jqueryNode.blur(); + jqueryNode.trigger('blur'); }, () => { - jqueryNode.val(valueGetter()).blur(); + jqueryNode.val(valueGetter()).trigger('blur'); }); jqueryNode.removeAttr('disabled').addClass('editable'); }; @@ -369,15 +369,15 @@ const paduserlist = (() => { }); // color picker - $('#myswatchbox').click(showColorPicker); - $('#mycolorpicker .pickerswatchouter').click(function () { + $('#myswatchbox').on('click', showColorPicker); + $('#mycolorpicker .pickerswatchouter').on('click', function () { $('#mycolorpicker .pickerswatchouter').removeClass('picked'); $(this).addClass('picked'); }); - $('#mycolorpickersave').click(() => { + $('#mycolorpickersave').on('click', () => { closeColorPicker(true); }); - $('#mycolorpickercancel').click(() => { + $('#mycolorpickercancel').on('click', () => { closeColorPicker(false); }); // @@ -587,7 +587,7 @@ const showColorPicker = () => { li.appendTo(colorsList); - li.bind('click', (event) => { + li.on('click', (event) => { $('#colorpickerswatches li').removeClass('picked'); $(event.target).addClass('picked'); diff --git a/src/static/js/pad_utils.js b/src/static/js/pad_utils.js index e10841f50..99c5bbede 100644 --- a/src/static/js/pad_utils.js +++ b/src/static/js/pad_utils.js @@ -224,7 +224,7 @@ const padutils = { // It is work on Windows (IE8, Chrome 6.0.472), CentOs (Firefox 3.0) and Mac OSX (Firefox // 3.6.10, Chrome 6.0.472, Safari 5.0). if (onEnter) { - node.keypress((evt) => { + node.on('keypress', (evt) => { if (evt.which === 13) { onEnter(evt); } @@ -232,7 +232,7 @@ const padutils = { } if (onEscape) { - node.keydown((evt) => { + node.on('keydown', (evt) => { if (evt.which === 27) { onEscape(evt); } @@ -299,7 +299,7 @@ const padutils = { } field.removeClass('editempty'); }); - field.blur(() => { + field.on('blur', () => { if (!field.val()) { clear(); } @@ -317,7 +317,7 @@ const padutils = { } }, bindCheckboxChange: (node, func) => { - $(node).change(func); + $(node).on('change', func); }, encodeUserId: (userId) => userId.replace(/[^a-y0-9]/g, (c) => { if (c === '.') return '-'; diff --git a/src/static/js/skin_variants.js b/src/static/js/skin_variants.js index a7902545e..9a0427ac9 100644 --- a/src/static/js/skin_variants.js +++ b/src/static/js/skin_variants.js @@ -46,7 +46,7 @@ if (window.location.hash.toLowerCase() === '#skinvariantsbuilder') { $('#skin-variant-full-width').prop('checked', $('html').hasClass('full-width-editor')); }; - $('.skin-variant').change(() => { + $('.skin-variant').on('change', () => { updateSkinVariantsClasses(); }); diff --git a/src/static/js/timeslider.js b/src/static/js/timeslider.js index 246872061..8c5993145 100644 --- a/src/static/js/timeslider.js +++ b/src/static/js/timeslider.js @@ -82,7 +82,7 @@ const init = () => { // get all the export links exportLinks = $('#export > .exportlink'); - $('button#forcereconnect').click(() => { + $('button#forcereconnect').on('click', () => { window.location.reload(); }); @@ -159,7 +159,7 @@ const handleClientVars = (message) => { $('#rightstep').attr('title', html10n.get('timeslider.forwardRevision')); // font family change - $('#viewfontmenu').change(function () { + $('#viewfontmenu').on('change', function () { $('#innerdocbody').css('font-family', $(this).val() || ''); }); }; diff --git a/src/static/skins/colibris/pad.js b/src/static/skins/colibris/pad.js index 1987f3204..3a2af8508 100644 --- a/src/static/skins/colibris/pad.js +++ b/src/static/skins/colibris/pad.js @@ -2,6 +2,6 @@ window.customStart = () => { $('#pad_title').show(); - $('.buttonicon').mousedown(function () { $(this).parent().addClass('pressed'); }); - $('.buttonicon').mouseup(function () { $(this).parent().removeClass('pressed'); }); + $('.buttonicon').on('mousedown', function () { $(this).parent().addClass('pressed'); }); + $('.buttonicon').on('mouseup', function () { $(this).parent().removeClass('pressed'); }); }; diff --git a/src/tests/frontend/helper/methods.js b/src/tests/frontend/helper/methods.js index 4c3c0db3d..3df29eb73 100644 --- a/src/tests/frontend/helper/methods.js +++ b/src/tests/frontend/helper/methods.js @@ -94,7 +94,7 @@ helper.sendChatMessage = async (message) => { */ helper.showSettings = async () => { if (helper.isSettingsShown()) return; - helper.settingsButton().click(); + helper.settingsButton().trigger('click'); await helper.waitForPromise(() => helper.isSettingsShown(), 2000); }; @@ -106,7 +106,7 @@ helper.showSettings = async () => { */ helper.hideSettings = async () => { if (!helper.isSettingsShown()) return; - helper.settingsButton().click(); + helper.settingsButton().trigger('click'); await helper.waitForPromise(() => !helper.isSettingsShown(), 2000); }; @@ -119,7 +119,7 @@ helper.hideSettings = async () => { helper.enableStickyChatviaSettings = async () => { const stickyChat = helper.padChrome$('#options-stickychat'); if (!helper.isSettingsShown() || stickyChat.is(':checked')) return; - stickyChat.click(); + stickyChat.trigger('click'); await helper.waitForPromise(() => helper.isChatboxSticky(), 2000); }; @@ -132,7 +132,7 @@ helper.enableStickyChatviaSettings = async () => { helper.disableStickyChatviaSettings = async () => { const stickyChat = helper.padChrome$('#options-stickychat'); if (!helper.isSettingsShown() || !stickyChat.is(':checked')) return; - stickyChat.click(); + stickyChat.trigger('click'); await helper.waitForPromise(() => !helper.isChatboxSticky(), 2000); }; @@ -145,7 +145,7 @@ helper.disableStickyChatviaSettings = async () => { helper.enableStickyChatviaIcon = async () => { const stickyChat = helper.padChrome$('#titlesticky'); if (!helper.isChatboxShown() || helper.isChatboxSticky()) return; - stickyChat.click(); + stickyChat.trigger('click'); await helper.waitForPromise(() => helper.isChatboxSticky(), 2000); }; @@ -157,7 +157,7 @@ helper.enableStickyChatviaIcon = async () => { */ helper.disableStickyChatviaIcon = async () => { if (!helper.isChatboxShown() || !helper.isChatboxSticky()) return; - helper.titlecross().click(); + helper.titlecross().trigger('click'); await helper.waitForPromise(() => !helper.isChatboxSticky(), 2000); }; diff --git a/src/tests/frontend/helper/ui.js b/src/tests/frontend/helper/ui.js index 0524a95c2..60911e08d 100644 --- a/src/tests/frontend/helper/ui.js +++ b/src/tests/frontend/helper/ui.js @@ -16,7 +16,7 @@ helper.contentWindow = () => $('#iframe-container iframe')[0].contentWindow; helper.showChat = async () => { const chaticon = helper.chatIcon(); if (!chaticon.hasClass('visible')) return; - chaticon.click(); + chaticon.trigger('click'); await helper.waitForPromise(() => !chaticon.hasClass('visible'), 2000); }; @@ -27,7 +27,7 @@ helper.showChat = async () => { */ helper.hideChat = async () => { if (!helper.isChatboxShown() || helper.isChatboxSticky()) return; - helper.titlecross().click(); + helper.titlecross().trigger('click'); await helper.waitForPromise(() => !helper.isChatboxShown(), 2000); }; @@ -80,7 +80,7 @@ helper.settingsButton = helper.toggleUserList = async () => { const isVisible = helper.userListShown(); const button = helper.padChrome$("button[data-l10n-id='pad.toolbar.showusers.title']"); - button.click(); + button.trigger('click'); await helper.waitForPromise(() => !isVisible); }; @@ -104,9 +104,9 @@ helper.userListShown = () => helper.padChrome$('div#users').hasClass('popup-show */ helper.setUserName = async (name) => { const userElement = helper.usernameField(); - userElement.click(); + userElement.trigger('click'); userElement.val(name); - userElement.blur(); + userElement.trigger('blur'); await helper.waitForPromise(() => !helper.usernameField().hasClass('editactive')); }; diff --git a/src/tests/frontend/specs/adminsettings.js b/src/tests/frontend/specs/adminsettings.js index a2ee02046..a64487557 100644 --- a/src/tests/frontend/specs/adminsettings.js +++ b/src/tests/frontend/specs/adminsettings.js @@ -27,7 +27,7 @@ describe('Admin > Settings', function () { observer.observe( helper.admin$('#response')[0], {attributes: true, childList: false, subtree: false}); }); - helper.admin$('#saveSettings').click(); + helper.admin$('#saveSettings').trigger('click'); await p; }; @@ -81,7 +81,7 @@ describe('Admin > Settings', function () { oldStartTime = await getStartTime(); return oldStartTime != null && oldStartTime > 0; }, 1000, 500); - helper.admin$('#restartEtherpad').click(); + helper.admin$('#restartEtherpad').trigger('click'); await helper.waitForPromise(async () => { const startTime = await getStartTime(); return startTime != null && startTime > oldStartTime; diff --git a/src/tests/frontend/specs/adminupdateplugins.js b/src/tests/frontend/specs/adminupdateplugins.js index 65e498ff4..1f6e21fc8 100755 --- a/src/tests/frontend/specs/adminupdateplugins.js +++ b/src/tests/frontend/specs/adminupdateplugins.js @@ -56,7 +56,7 @@ describe('Plugins page', function () { await timeout(500); // HACK! Please submit better fix.. const $doUpdateButton = helper.admin$('.ep_align .do-update'); - $doUpdateButton.click(); + $doUpdateButton.trigger('click'); // ensure its showing as Updating await helper.waitForPromise( @@ -79,7 +79,7 @@ describe('Plugins page', function () { // skip if we already have ep_headings2 installed.. if (helper.admin$('.ep_headings2 .do-install').is(':visible') === false) this.skip(); - helper.admin$('.ep_headings2 .do-install').click(); + helper.admin$('.ep_headings2 .do-install').trigger('click'); // ensure install has attempted to be started await helper.waitForPromise( () => helper.admin$('.ep_headings2 .do-install').length !== 0, 120000); @@ -96,7 +96,7 @@ describe('Plugins page', function () { await helper.waitForPromise( () => helper.admin$('.ep_headings2 .do-uninstall').length !== 0, 120000); - helper.admin$('.ep_headings2 .do-uninstall').click(); + helper.admin$('.ep_headings2 .do-uninstall').trigger('click'); // ensure its showing uninstalling await helper.waitForPromise( diff --git a/src/tests/frontend/specs/authorship_of_editions.js b/src/tests/frontend/specs/authorship_of_editions.js index 9fd90ffb7..066c8d86b 100644 --- a/src/tests/frontend/specs/authorship_of_editions.js +++ b/src/tests/frontend/specs/authorship_of_editions.js @@ -25,7 +25,7 @@ describe('author of pad edition', function () { $lineWithUnorderedList.sendkeys('{selectall}'); const $insertUnorderedListButton = helper.padChrome$('.buttonicon-insertunorderedlist'); - $insertUnorderedListButton.click(); + $insertUnorderedListButton.trigger('click'); await helper.waitForPromise(() => ( getLine(LINE_WITH_UNORDERED_LIST).find('ul li').length === 1 && @@ -36,7 +36,7 @@ describe('author of pad edition', function () { $lineWithOrderedList.sendkeys('{selectall}'); const $insertOrderedListButton = helper.padChrome$('.buttonicon-insertorderedlist'); - $insertOrderedListButton.click(); + $insertOrderedListButton.trigger('click'); await helper.waitForPromise(() => ( getLine(LINE_WITH_ORDERED_LIST).find('ol li').length === 1 && diff --git a/src/tests/frontend/specs/bold.js b/src/tests/frontend/specs/bold.js index 51655588d..cadfb7a54 100644 --- a/src/tests/frontend/specs/bold.js +++ b/src/tests/frontend/specs/bold.js @@ -18,7 +18,7 @@ describe('bold button', function () { // get the bold button and click it const $boldButton = chrome$('.buttonicon-bold'); - $boldButton.click(); + $boldButton.trigger('click'); const $newFirstTextElement = inner$('div').first(); diff --git a/src/tests/frontend/specs/change_user_color.js b/src/tests/frontend/specs/change_user_color.js index 6d73fb805..9025b1a54 100644 --- a/src/tests/frontend/specs/change_user_color.js +++ b/src/tests/frontend/specs/change_user_color.js @@ -13,10 +13,10 @@ describe('change user color', function () { // click on the settings button to make settings visible let $userButton = chrome$('.buttonicon-showusers'); - $userButton.click(); + $userButton.trigger('click'); let $userSwatch = chrome$('#myswatch'); - $userSwatch.click(); + $userSwatch.trigger('click'); const fb = chrome$.farbtastic('#colorpicker'); const $colorPickerSave = chrome$('#mycolorpickersave'); @@ -34,7 +34,7 @@ describe('change user color', function () { // The swatch updates as the test color is picked. fb.setColor(testColorHash); expect($colorPickerPreview.css('background-color')).to.be(testColorRGB); - $colorPickerSave.click(); + $colorPickerSave.trigger('click'); expect($userSwatch.css('background-color')).to.be(testColorRGB); // give it a second to save the color on the server side @@ -47,10 +47,10 @@ describe('change user color', function () { // click on the settings button to make settings visible $userButton = chrome$('.buttonicon-showusers'); - $userButton.click(); + $userButton.trigger('click'); $userSwatch = chrome$('#myswatch'); - $userSwatch.click(); + $userSwatch.trigger('click'); $colorPickerPreview = chrome$('#mycolorpickerpreview'); @@ -64,15 +64,15 @@ describe('change user color', function () { const $colorOption = helper.padChrome$('#options-colorscheck'); if (!$colorOption.is(':checked')) { - $colorOption.click(); + $colorOption.trigger('click'); } // click on the settings button to make settings visible const $userButton = chrome$('.buttonicon-showusers'); - $userButton.click(); + $userButton.trigger('click'); const $userSwatch = chrome$('#myswatch'); - $userSwatch.click(); + $userSwatch.trigger('click'); const fb = chrome$.farbtastic('#colorpicker'); const $colorPickerSave = chrome$('#mycolorpickersave'); @@ -82,11 +82,11 @@ describe('change user color', function () { const testColorRGB = 'rgb(171, 205, 239)'; fb.setColor(testColorHash); - $colorPickerSave.click(); + $colorPickerSave.trigger('click'); // click on the chat button to make chat visible const $chatButton = chrome$('#chaticon'); - $chatButton.click(); + $chatButton.trigger('click'); const $chatInput = chrome$('#chatinput'); $chatInput.sendkeys('O hi'); // simulate a keypress of typing user $chatInput.sendkeys('{enter}'); diff --git a/src/tests/frontend/specs/chat_load_messages.js b/src/tests/frontend/specs/chat_load_messages.js index d720fbba1..86bd2b3c7 100644 --- a/src/tests/frontend/specs/chat_load_messages.js +++ b/src/tests/frontend/specs/chat_load_messages.js @@ -10,7 +10,7 @@ describe('chat-load-messages', function () { it('adds a lot of messages', async function () { const chrome$ = helper.padChrome$; const chatButton = chrome$('#chaticon'); - chatButton.click(); + chatButton.trigger('click'); const chatInput = chrome$('#chatinput'); const chatText = chrome$('#chattext'); @@ -33,7 +33,7 @@ describe('chat-load-messages', function () { const chrome$ = helper.padChrome$; helper.waitFor(() => { const chatButton = chrome$('#chaticon'); - chatButton.click(); + chatButton.trigger('click'); chatText = chrome$('#chattext'); return chatText.children('p').length === expectedCount; }).always(() => { @@ -47,11 +47,11 @@ describe('chat-load-messages', function () { const expectedCount = 122; const chrome$ = helper.padChrome$; const chatButton = chrome$('#chaticon'); - chatButton.click(); + chatButton.trigger('click'); const chatText = chrome$('#chattext'); const loadMsgBtn = chrome$('#chatloadmessagesbutton'); - loadMsgBtn.click(); + loadMsgBtn.trigger('click'); helper.waitFor(() => chatText.children('p').length === expectedCount).always(() => { expect(chatText.children('p').length).to.be(expectedCount); done(); @@ -63,11 +63,11 @@ describe('chat-load-messages', function () { const expectedDisplay = 'none'; const chrome$ = helper.padChrome$; const chatButton = chrome$('#chaticon'); - chatButton.click(); + chatButton.trigger('click'); const loadMsgBtn = chrome$('#chatloadmessagesbutton'); const loadMsgBall = chrome$('#chatloadmessagesball'); - loadMsgBtn.click(); + loadMsgBtn.trigger('click'); helper.waitFor(() => loadMsgBtn.css('display') === expectedDisplay && loadMsgBall.css('display') === expectedDisplay).always(() => { expect(loadMsgBtn.css('display')).to.be(expectedDisplay); diff --git a/src/tests/frontend/specs/clear_authorship_colors.js b/src/tests/frontend/specs/clear_authorship_colors.js index 20c358b49..0dc9c7f2a 100644 --- a/src/tests/frontend/specs/clear_authorship_colors.js +++ b/src/tests/frontend/specs/clear_authorship_colors.js @@ -32,11 +32,11 @@ describe('clear authorship colors button', function () { () => inner$('div span').first().attr('class').indexOf('author') !== -1); // IE hates you if you don't give focus to the inner frame bevore you do a clearAuthorship - inner$('div').first().focus(); + inner$('div').first().trigger('focus'); // get the clear authorship colors button and click it const $clearauthorshipcolorsButton = chrome$('.buttonicon-clearauthorship'); - $clearauthorshipcolorsButton.click(); + $clearauthorshipcolorsButton.trigger('click'); // does the first div include an author class? const hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1; @@ -70,11 +70,11 @@ describe('clear authorship colors button', function () { () => inner$('div span').first().attr('class').indexOf('author') !== -1); // IE hates you if you don't give focus to the inner frame bevore you do a clearAuthorship - inner$('div').first().focus(); + inner$('div').first().trigger('focus'); // get the clear authorship colors button and click it const $clearauthorshipcolorsButton = chrome$('.buttonicon-clearauthorship'); - $clearauthorshipcolorsButton.click(); + $clearauthorshipcolorsButton.trigger('click'); // does the first div include an author class? let hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1; @@ -93,7 +93,7 @@ describe('clear authorship colors button', function () { const $undoButton = chrome$('.buttonicon-undo'); // click the button - $undoButton.click(); // shouldn't do anything + $undoButton.trigger('click'); // shouldn't do anything hasAuthorClass = inner$('div').first().attr('class').indexOf('author') !== -1; expect(hasAuthorClass).to.be(false); diff --git a/src/tests/frontend/specs/drag_and_drop.js b/src/tests/frontend/specs/drag_and_drop.js index 6d3f5a363..2aeb22f24 100644 --- a/src/tests/frontend/specs/drag_and_drop.js +++ b/src/tests/frontend/specs/drag_and_drop.js @@ -24,7 +24,7 @@ describe('drag and drop', function () { before(async function () { const originalHTML = helper.padInner$('body').html(); const $undoButton = helper.padChrome$('.buttonicon-undo'); - $undoButton.click(); + $undoButton.trigger('click'); await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML); }); @@ -59,7 +59,7 @@ describe('drag and drop', function () { before(async function () { const originalHTML = helper.padInner$('body').html(); const $undoButton = helper.padChrome$('.buttonicon-undo'); - $undoButton.click(); + $undoButton.trigger('click'); await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML); }); diff --git a/src/tests/frontend/specs/embed_value.js b/src/tests/frontend/specs/embed_value.js index e92d070a7..1594fd891 100644 --- a/src/tests/frontend/specs/embed_value.js +++ b/src/tests/frontend/specs/embed_value.js @@ -59,7 +59,7 @@ describe('embed links', function () { const chrome$ = helper.padChrome$; // open share dropdown - chrome$('.buttonicon-embed').click(); + chrome$('.buttonicon-embed').trigger('click'); // get the link of the share field + the actual pad url and compare them const shareLink = chrome$('#linkinput').val(); @@ -73,7 +73,7 @@ describe('embed links', function () { const chrome$ = helper.padChrome$; // open share dropdown - chrome$('.buttonicon-embed').click(); + chrome$('.buttonicon-embed').trigger('click'); // get the link of the share field + the actual pad url and compare them const embedCode = chrome$('#embedinput').val(); @@ -93,8 +93,8 @@ describe('embed links', function () { const chrome$ = helper.padChrome$; // open share dropdown - chrome$('.buttonicon-embed').click(); - chrome$('#readonlyinput').click(); + chrome$('.buttonicon-embed').trigger('click'); + chrome$('#readonlyinput').trigger('click'); chrome$('#readonlyinput:checkbox:not(:checked)').attr('checked', 'checked'); // get the link of the share field + the actual pad url and compare them @@ -109,9 +109,9 @@ describe('embed links', function () { const chrome$ = helper.padChrome$; // open share dropdown - chrome$('.buttonicon-embed').click(); + chrome$('.buttonicon-embed').trigger('click'); // check read only checkbox, a bit hacky - chrome$('#readonlyinput').click(); + chrome$('#readonlyinput').trigger('click'); chrome$('#readonlyinput:checkbox:not(:checked)').attr('checked', 'checked'); diff --git a/src/tests/frontend/specs/font_type.js b/src/tests/frontend/specs/font_type.js index fbebcdfd7..9b2012b91 100644 --- a/src/tests/frontend/specs/font_type.js +++ b/src/tests/frontend/specs/font_type.js @@ -12,7 +12,7 @@ describe('font select', function () { // click on the settings button to make settings visible const $settingsButton = chrome$('.buttonicon-settings'); - $settingsButton.click(); + $settingsButton.trigger('click'); // get the font menu and RobotoMono option const $viewfontmenu = chrome$('#viewfontmenu'); @@ -21,7 +21,7 @@ describe('font select', function () { // $RobotoMonooption.attr('selected','selected'); // commenting out above will break safari test $viewfontmenu.val('RobotoMono'); - $viewfontmenu.change(); + $viewfontmenu.trigger('change'); // check if font changed to RobotoMono const fontFamily = inner$('body').css('font-family').toLowerCase(); diff --git a/src/tests/frontend/specs/helper.js b/src/tests/frontend/specs/helper.js index 0d876b336..9be34c662 100644 --- a/src/tests/frontend/specs/helper.js +++ b/src/tests/frontend/specs/helper.js @@ -47,13 +47,13 @@ describe('the test helper', function () { // click on the settings button to make settings visible let $userButton = chrome$('.buttonicon-showusers'); - $userButton.click(); + $userButton.trigger('click'); let $usernameInput = chrome$('#myusernameedit'); - $usernameInput.click(); + $usernameInput.trigger('click'); $usernameInput.val('John McLear'); - $usernameInput.blur(); + $usernameInput.trigger('blur'); // Before refreshing, make sure the name is there expect($usernameInput.val()).to.be('John McLear'); @@ -85,7 +85,7 @@ describe('the test helper', function () { // click on the settings button to make settings visible $userButton = chrome$('.buttonicon-showusers'); - $userButton.click(); + $userButton.trigger('click'); // confirm that the session was actually cleared $usernameInput = chrome$('#myusernameedit'); diff --git a/src/tests/frontend/specs/importexport.js b/src/tests/frontend/specs/importexport.js index 46254bedd..e04f5db56 100644 --- a/src/tests/frontend/specs/importexport.js +++ b/src/tests/frontend/specs/importexport.js @@ -527,7 +527,7 @@ describe('importexport.js', function () { const isVisible = () => popup.hasClass('popup-show'); if (isVisible()) return; const button = helper.padChrome$('button[data-l10n-id="pad.toolbar.import_export.title"]'); - button.click(); + button.trigger('click'); await helper.waitForPromise(isVisible); }); @@ -558,7 +558,7 @@ describe('importexport.js', function () { dt.items.add(new File([contents], `file.${ext}`, {type: 'text/plain'})); const form = helper.padChrome$('#importform'); form.find('input[type=file]')[0].files = dt.files; - form.find('#importsubmitinput').submit(); + form.find('#importsubmitinput').trigger('submit'); try { await helper.waitForPromise(() => { const got = helper.linesDiv(); diff --git a/src/tests/frontend/specs/indentation.js b/src/tests/frontend/specs/indentation.js index 80a0f9140..939745353 100644 --- a/src/tests/frontend/specs/indentation.js +++ b/src/tests/frontend/specs/indentation.js @@ -27,7 +27,7 @@ describe('indentation button', function () { const chrome$ = helper.padChrome$; const $indentButton = chrome$('.buttonicon-indent'); - $indentButton.click(); + $indentButton.trigger('click'); await helper.waitForPromise(() => inner$('div').first().find('ul li').length === 1); }); @@ -38,7 +38,7 @@ describe('indentation button', function () { const chrome$ = helper.padChrome$; const $indentButton = chrome$('.buttonicon-indent'); - $indentButton.click(); + $indentButton.trigger('click'); // type a bit, make a line break and type again const $firstTextElement = inner$('div span').first(); @@ -147,19 +147,19 @@ describe('indentation button', function () { helper.selectLines($firstLine, $secondLine); const $indentButton = chrome$('.buttonicon-indent'); - $indentButton.click(); + $indentButton.trigger('click'); await helper.waitForPromise(() => inner$('div').first().find('ul li').length === 1); // apply bold const $boldButton = chrome$('.buttonicon-bold'); - $boldButton.click(); + $boldButton.trigger('click'); await helper.waitForPromise(() => inner$('div').first().find('b').length === 1); // outdent first 2 lines const $outdentButton = chrome$('.buttonicon-outdent'); - $outdentButton.click(); + $outdentButton.trigger('click'); await helper.waitForPromise(() => inner$('div').first().find('ul li').length === 0); // check if '*' is displayed @@ -179,7 +179,7 @@ describe('indentation button', function () { // get the indentation button and click it const $indentButton = helper.$getPadChrome().find('.buttonicon-indent'); - $indentButton.click(); + $indentButton.trigger('click'); let newFirstTextElement = $inner.find('div').first(); @@ -196,7 +196,7 @@ describe('indentation button', function () { expect(isLI).to.be(true); // indent again - $indentButton.click(); + $indentButton.trigger('click'); newFirstTextElement = $inner.find('div').first(); @@ -215,8 +215,8 @@ describe('indentation button', function () { // get the unindentation button and click it twice const $outdentButton = helper.$getPadChrome().find('.buttonicon-outdent'); - $outdentButton.click(); - $outdentButton.click(); + $outdentButton.trigger('click'); + $outdentButton.trigger('click'); newFirstTextElement = $inner.find('div').first(); @@ -242,8 +242,8 @@ describe('indentation button', function () { helper.selectText(firstTextElement[0], $inner); // indent twice - $indentButton.click(); - $indentButton.click(); + $indentButton.trigger('click'); + $indentButton.trigger('click'); // get the first text element out of the inner iframe firstTextElement = $inner.find('div').first(); diff --git a/src/tests/frontend/specs/italic.js b/src/tests/frontend/specs/italic.js index 9b7b00b9f..3297d9399 100644 --- a/src/tests/frontend/specs/italic.js +++ b/src/tests/frontend/specs/italic.js @@ -18,7 +18,7 @@ describe('italic some text', function () { // get the bold button and click it const $boldButton = chrome$('.buttonicon-italic'); - $boldButton.click(); + $boldButton.trigger('click'); // ace creates a new dom element when you press a button, just get the first text element again const $newFirstTextElement = inner$('div').first(); diff --git a/src/tests/frontend/specs/language.js b/src/tests/frontend/specs/language.js index 2373874f5..de3b483ec 100644 --- a/src/tests/frontend/specs/language.js +++ b/src/tests/frontend/specs/language.js @@ -16,7 +16,7 @@ describe('Language select and change', function () { // click on the settings button to make settings visible const $settingsButton = chrome$('.buttonicon-settings'); - $settingsButton.click(); + $settingsButton.trigger('click'); // click the language button const $language = chrome$('#languagemenu'); @@ -24,7 +24,7 @@ describe('Language select and change', function () { // select german $languageoption.attr('selected', 'selected'); - $language.change(); + $language.trigger('change'); await helper.waitForPromise( () => chrome$('.buttonicon-bold').parent()[0].title === 'Fett (Strg-B)'); @@ -45,13 +45,13 @@ describe('Language select and change', function () { // click on the settings button to make settings visible const $settingsButton = chrome$('.buttonicon-settings'); - $settingsButton.click(); + $settingsButton.trigger('click'); // click the language button const $language = chrome$('#languagemenu'); // select english $language.val('en'); - $language.change(); + $language.trigger('change'); // get the value of the bold button let $boldButton = chrome$('.buttonicon-bold').parent(); @@ -79,7 +79,7 @@ describe('Language select and change', function () { // click on the settings button to make settings visible const $settingsButton = chrome$('.buttonicon-settings'); - $settingsButton.click(); + $settingsButton.trigger('click'); // click the language button const $language = chrome$('#languagemenu'); @@ -88,7 +88,7 @@ describe('Language select and change', function () { // select arabic // $languageoption.attr('selected','selected'); // Breaks the test.. $language.val('ar'); - $languageoption.change(); + $languageoption.trigger('change'); await helper.waitForPromise(() => chrome$('html')[0].dir !== 'ltr'); @@ -101,7 +101,7 @@ describe('Language select and change', function () { // click on the settings button to make settings visible const $settingsButton = chrome$('.buttonicon-settings'); - $settingsButton.click(); + $settingsButton.trigger('click'); // click the language button const $language = chrome$('#languagemenu'); @@ -111,7 +111,7 @@ describe('Language select and change', function () { // select arabic $languageoption.attr('selected', 'selected'); $language.val('en'); - $languageoption.change(); + $languageoption.trigger('change'); await helper.waitForPromise(() => chrome$('html')[0].dir !== 'rtl'); diff --git a/src/tests/frontend/specs/multiple_authors_clear_authorship_colors.js b/src/tests/frontend/specs/multiple_authors_clear_authorship_colors.js index e0c86fa43..1276f839c 100755 --- a/src/tests/frontend/specs/multiple_authors_clear_authorship_colors.js +++ b/src/tests/frontend/specs/multiple_authors_clear_authorship_colors.js @@ -33,7 +33,7 @@ describe('author of pad edition', function () { // get the clear authorship colors button and click it const $clearauthorshipcolorsButton = chrome$('.buttonicon-clearauthorship'); - $clearauthorshipcolorsButton.click(); + $clearauthorshipcolorsButton.trigger('click'); // does the first divs span include an author class? const hasAuthorClass = inner$('div span').first().attr('class').indexOf('author') !== -1; diff --git a/src/tests/frontend/specs/ordered_list.js b/src/tests/frontend/specs/ordered_list.js index 21331596f..33e7f5c90 100644 --- a/src/tests/frontend/specs/ordered_list.js +++ b/src/tests/frontend/specs/ordered_list.js @@ -12,7 +12,7 @@ describe('ordered_list.js', function () { const chrome$ = helper.padChrome$; const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist'); - $insertorderedlistButton.click(); + $insertorderedlistButton.trigger('click'); await helper.waitForPromise(() => inner$('div').first().find('ol li').length === 1); }); @@ -115,10 +115,10 @@ describe('ordered_list.js', function () { const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist'); const $firstLine = inner$('div').first(); $firstLine.sendkeys('{selectall}'); - $insertorderedlistButton.click(); + $insertorderedlistButton.trigger('click'); const $secondLine = inner$('div').first().next(); $secondLine.sendkeys('{selectall}'); - $insertorderedlistButton.click(); + $insertorderedlistButton.trigger('click'); expect($secondLine.find('ol').attr('start') === 2); }); @@ -128,7 +128,7 @@ describe('ordered_list.js', function () { const chrome$ = helper.padChrome$; const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist'); - $insertorderedlistButton.click(); + $insertorderedlistButton.trigger('click'); // type a bit, make a line break and type again const $firstTextElement = inner$('div span').first(); @@ -182,7 +182,7 @@ describe('ordered_list.js', function () { $firstTextElement.sendkeys('{selectall}'); const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist'); - $insertorderedlistButton.click(); + $insertorderedlistButton.trigger('click'); const e = new inner$.Event(helper.evtType); e.keyCode = 9; // tab @@ -217,15 +217,15 @@ describe('ordered_list.js', function () { $firstTextElement.sendkeys('{selectall}'); const $insertorderedlistButton = chrome$('.buttonicon-insertorderedlist'); - $insertorderedlistButton.click(); + $insertorderedlistButton.trigger('click'); const $indentButton = chrome$('.buttonicon-indent'); - $indentButton.click(); // make it indented twice + $indentButton.trigger('click'); // make it indented twice expect(inner$('div').first().find('.list-number2').length === 1).to.be(true); const $outdentButton = chrome$('.buttonicon-outdent'); - $outdentButton.click(); // make it deindented to 1 + $outdentButton.trigger('click'); // make it deindented to 1 await helper.waitForPromise(() => inner$('div').first().find('.list-number1').length === 1); }); diff --git a/src/tests/frontend/specs/pad_modal.js b/src/tests/frontend/specs/pad_modal.js index 735abe8c0..d2a53b7bc 100644 --- a/src/tests/frontend/specs/pad_modal.js +++ b/src/tests/frontend/specs/pad_modal.js @@ -71,16 +71,16 @@ describe('Pad modal', function () { const clickOnPadInner = () => { const $editor = helper.padInner$('#innerdocbody'); - $editor.click(); + $editor.trigger('click'); }; const clickOnPadOuter = () => { const $lineNumbersColumn = helper.padOuter$('#sidedivinner'); - $lineNumbersColumn.click(); + $lineNumbersColumn.trigger('click'); }; const openSettingsAndWaitForModalToBeVisible = async () => { - helper.padChrome$('.buttonicon-settings').click(); + helper.padChrome$('.buttonicon-settings').trigger('click'); // wait for modal to be displayed const modalSelector = '#settings'; diff --git a/src/tests/frontend/specs/redo.js b/src/tests/frontend/specs/redo.js index bbe85a7ea..6a29482e2 100644 --- a/src/tests/frontend/specs/redo.js +++ b/src/tests/frontend/specs/redo.js @@ -22,8 +22,8 @@ describe('undo button then redo button', function () { const $undoButton = chrome$('.buttonicon-undo'); const $redoButton = chrome$('.buttonicon-redo'); // click the buttons - $undoButton.click(); // removes foo - $redoButton.click(); // resends foo + $undoButton.trigger('click'); // removes foo + $redoButton.trigger('click'); // resends foo await helper.waitForPromise(() => inner$('div span').first().text() === newString); const finalValue = inner$('div').first().text(); diff --git a/src/tests/frontend/specs/select_formatting_buttons.js b/src/tests/frontend/specs/select_formatting_buttons.js index 28921357d..67c93d636 100644 --- a/src/tests/frontend/specs/select_formatting_buttons.js +++ b/src/tests/frontend/specs/select_formatting_buttons.js @@ -13,7 +13,7 @@ describe('select formatting buttons when selection has style applied', function const chrome$ = helper.padChrome$; selectLine(line); const $formattingButton = chrome$(`.buttonicon-${style}`); - $formattingButton.click(); + $formattingButton.trigger('click'); }; const isButtonSelected = function (style) { @@ -37,7 +37,7 @@ describe('select formatting buttons when selection has style applied', function const undo = async function () { const originalHTML = helper.padInner$('body').html(); const $undoButton = helper.padChrome$('.buttonicon-undo'); - $undoButton.click(); + $undoButton.trigger('click'); await helper.waitForPromise(() => helper.padInner$('body').html() !== originalHTML); }; diff --git a/src/tests/frontend/specs/strikethrough.js b/src/tests/frontend/specs/strikethrough.js index 4c33244cd..8385d676e 100644 --- a/src/tests/frontend/specs/strikethrough.js +++ b/src/tests/frontend/specs/strikethrough.js @@ -18,7 +18,7 @@ describe('strikethrough button', function () { // get the strikethrough button and click it const $strikethroughButton = chrome$('.buttonicon-strikethrough'); - $strikethroughButton.click(); + $strikethroughButton.trigger('click'); // ace creates a new dom element when you press a button, just get the first text element again const $newFirstTextElement = inner$('div').first(); diff --git a/src/tests/frontend/specs/timeslider.js b/src/tests/frontend/specs/timeslider.js index 350965720..6ee00f108 100644 --- a/src/tests/frontend/specs/timeslider.js +++ b/src/tests/frontend/specs/timeslider.js @@ -22,7 +22,7 @@ xdescribe('timeslider button takes you to the timeslider of a pad', function () await helper.waitForPromise(() => modifiedValue !== originalValue); const $timesliderButton = chrome$('#timesliderlink'); - $timesliderButton.click(); // So click the timeslider link + $timesliderButton.trigger('click'); // So click the timeslider link await helper.waitForPromise(() => { const iFrameURL = chrome$.window.location.href; diff --git a/src/tests/frontend/specs/timeslider_follow.js b/src/tests/frontend/specs/timeslider_follow.js index ffda2d286..e3d9b8067 100644 --- a/src/tests/frontend/specs/timeslider_follow.js +++ b/src/tests/frontend/specs/timeslider_follow.js @@ -25,7 +25,7 @@ describe('timeslider follow', function () { // set to follow contents as it arrives helper.contentWindow().$('#options-followContents').prop('checked', true); - helper.contentWindow().$('#playpause_button_icon').click(); + helper.contentWindow().$('#playpause_button_icon').trigger('click'); let newTop; await helper.waitForPromise(() => { @@ -64,27 +64,27 @@ describe('timeslider follow', function () { */ // line 40 changed - helper.contentWindow().$('#leftstep').click(); + helper.contentWindow().$('#leftstep').trigger('click'); await helper.waitForPromise(() => hasFollowedToLine(40)); // line 1 is the first line that changed - helper.contentWindow().$('#leftstep').click(); + helper.contentWindow().$('#leftstep').trigger('click'); await helper.waitForPromise(() => hasFollowedToLine(1)); // line 1 changed - helper.contentWindow().$('#leftstep').click(); + helper.contentWindow().$('#leftstep').trigger('click'); await helper.waitForPromise(() => hasFollowedToLine(1)); // line 1 changed - helper.contentWindow().$('#rightstep').click(); + helper.contentWindow().$('#rightstep').trigger('click'); await helper.waitForPromise(() => hasFollowedToLine(1)); // line 1 is the first line that changed - helper.contentWindow().$('#rightstep').click(); + helper.contentWindow().$('#rightstep').trigger('click'); await helper.waitForPromise(() => hasFollowedToLine(1)); // line 40 changed - helper.contentWindow().$('#rightstep').click(); + helper.contentWindow().$('#rightstep').trigger('click'); helper.waitForPromise(() => hasFollowedToLine(40)); }); }); diff --git a/src/tests/frontend/specs/timeslider_revisions.js b/src/tests/frontend/specs/timeslider_revisions.js index 8c4f07458..c2de15c42 100644 --- a/src/tests/frontend/specs/timeslider_revisions.js +++ b/src/tests/frontend/specs/timeslider_revisions.js @@ -12,7 +12,7 @@ describe('timeslider', function () { // Create a bunch of revisions. for (let i = 0; i < 99; i++) await helper.edit('a'); - chrome$('.buttonicon-savedRevision').click(); + chrome$('.buttonicon-savedRevision').trigger('click'); await helper.waitForPromise(() => helper.padChrome$('.saved-revision').length > 0); // Give some time to send the SAVE_REVISION message to the server before navigating away. await new Promise((resolve) => setTimeout(resolve, 100)); diff --git a/src/tests/frontend/specs/undo.js b/src/tests/frontend/specs/undo.js index d853eaf7b..4d9b4f18a 100644 --- a/src/tests/frontend/specs/undo.js +++ b/src/tests/frontend/specs/undo.js @@ -20,7 +20,7 @@ describe('undo button', function () { // get clear authorship button as a variable const $undoButton = chrome$('.buttonicon-undo'); // click the button - $undoButton.click(); + $undoButton.trigger('click'); await helper.waitForPromise(() => inner$('div span').first().text() === originalValue); }); diff --git a/src/tests/frontend/specs/unordered_list.js b/src/tests/frontend/specs/unordered_list.js index 9e5439a77..f181bb17b 100644 --- a/src/tests/frontend/specs/unordered_list.js +++ b/src/tests/frontend/specs/unordered_list.js @@ -13,7 +13,7 @@ describe('unordered_list.js', function () { const originalText = inner$('div').first().text(); const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist'); - $insertunorderedlistButton.click(); + $insertunorderedlistButton.trigger('click'); await helper.waitForPromise(() => { const newText = inner$('div').first().text(); @@ -21,7 +21,7 @@ describe('unordered_list.js', function () { }); // remove indentation by bullet and ensure text string remains the same - chrome$('.buttonicon-outdent').click(); + chrome$('.buttonicon-outdent').trigger('click'); await helper.waitForPromise(() => inner$('div').first().text() === originalText); }); }); @@ -38,7 +38,7 @@ describe('unordered_list.js', function () { const originalText = inner$('div').first().text(); const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist'); - $insertunorderedlistButton.click(); + $insertunorderedlistButton.trigger('click'); await helper.waitForPromise(() => { const newText = inner$('div').first().text(); @@ -46,7 +46,7 @@ describe('unordered_list.js', function () { }); // remove indentation by bullet and ensure text string remains the same - $insertunorderedlistButton.click(); + $insertunorderedlistButton.trigger('click'); await helper.waitForPromise(() => inner$('div').find('ul').length !== 1); }); }); @@ -63,7 +63,7 @@ describe('unordered_list.js', function () { const chrome$ = helper.padChrome$; const $insertorderedlistButton = chrome$('.buttonicon-insertunorderedlist'); - $insertorderedlistButton.click(); + $insertorderedlistButton.trigger('click'); // type a bit, make a line break and type again const $firstTextElement = inner$('div span').first(); @@ -98,7 +98,7 @@ describe('unordered_list.js', function () { $firstTextElement.sendkeys('{selectall}'); const $insertorderedlistButton = chrome$('.buttonicon-insertunorderedlist'); - $insertorderedlistButton.click(); + $insertorderedlistButton.trigger('click'); const e = new inner$.Event(helper.evtType); e.keyCode = 9; // tab @@ -131,14 +131,14 @@ describe('unordered_list.js', function () { $firstTextElement.sendkeys('{selectall}'); const $insertunorderedlistButton = chrome$('.buttonicon-insertunorderedlist'); - $insertunorderedlistButton.click(); + $insertunorderedlistButton.trigger('click'); const $indentButton = chrome$('.buttonicon-indent'); - $indentButton.click(); // make it indented twice + $indentButton.trigger('click'); // make it indented twice expect(inner$('div').first().find('.list-bullet2').length === 1).to.be(true); const $outdentButton = chrome$('.buttonicon-outdent'); - $outdentButton.click(); // make it deindented to 1 + $outdentButton.trigger('click'); // make it deindented to 1 await helper.waitForPromise(() => inner$('div').first().find('.list-bullet1').length === 1); }); diff --git a/src/tests/frontend/specs/xxauto_reconnect.js b/src/tests/frontend/specs/xxauto_reconnect.js index c04ca9d29..b8b3e73f7 100644 --- a/src/tests/frontend/specs/xxauto_reconnect.js +++ b/src/tests/frontend/specs/xxauto_reconnect.js @@ -32,7 +32,7 @@ describe('Automatic pad reload on Force Reconnect message', function () { context('and user clicks on Cancel', function () { beforeEach(async function () { const $errorMessageModal = helper.padChrome$('#connectivity .userdup'); - $errorMessageModal.find('#cancelreconnect').click(); + $errorMessageModal.find('#cancelreconnect').trigger('click'); await helper.waitForPromise( () => helper.padChrome$('#connectivity .userdup').is(':visible') === true); });