Update jQuery to 3.7 and fix admintests (#5868)

* jQuery: Migrate to `.on()`, `.off()`, `.trigger()`

This avoids methods that are deprecated in newer versions of jQuery.

* jQuery: avoid `.removeAttr`, prefer `.prop`

* helper.edit: wait up to 10 seconds for ACCEPT_COMMIT

* Chat: disabled attribute is boolean

* Chat: avoid inline onclick handler to support jQuery 3.4+

* jQuery: update to version 3.6.0

* Update to 3.7

* Removed deprecated event.

* Revert change to focus on padeditor.ace

---------

Co-authored-by: webzwo0i <webzwo0i@c3d2.de>
pull/5869/head
SamTV12345 2023-08-08 18:26:25 +02:00 committed by GitHub
parent 2f5b6b80e1
commit a096f1ae33
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
52 changed files with 9457 additions and 8785 deletions

View File

@ -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' &&

View File

@ -164,7 +164,7 @@
$(window).resize(adjust);
// Allow for manual triggering if needed.
$ta.bind('autosize', adjust);
$ta.on('autosize', adjust);
// Call adjust in case the textarea already contains text.
adjust();

View File

@ -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;
@ -164,7 +164,7 @@ $(document).ready(() => {
if (data.query.offset === 0) search.results = [];
search.messages.hide('nothing-found');
search.messages.hide('fetching');
$('#search-query').removeAttr('disabled');
$('#search-query').prop('disabled', false);
console.log('got search results', data);

View File

@ -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');
@ -40,7 +40,7 @@ $(document).ready(() => {
socket.emit('saveSettings', $('.settings').val());
} else {
alert('Invalid JSON');
$('.settings').focus();
$('.settings').trigger('focus');
}
});
@ -62,7 +62,7 @@ const isJSONClean = (data) => {
// this is a bit naive. In theory some key/value might contain the sequences ',]' or ',}'
cleanSettings = cleanSettings.replace(',]', ']').replace(',}', '}');
try {
return typeof jQuery.parseJSON(cleanSettings) === 'object';
return typeof JSON.parseJSON(cleanSettings) === 'object';
} catch (e) {
return false; // the JSON failed to be parsed
}

View File

@ -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);

View File

@ -42,11 +42,14 @@ exports.chat = (() => {
},
focus: () => {
setTimeout(() => {
$('#chatinput').focus();
$('#chatinput').trigger('focus');
}, 100);
},
// Make chat stick to right hand side of screen
stickToScreen(fromInitialCall) {
if ($('#options-stickychat').prop('checked')) {
$('#options-stickychat').prop('checked', false);
}
if (pad.settings.hideChat) {
return;
}
@ -68,7 +71,7 @@ exports.chat = (() => {
this.stickToScreen(true);
$('#options-stickychat').prop('checked', true);
$('#options-chatandusers').prop('checked', true);
$('#options-stickychat').prop('disabled', 'disabled');
$('#options-stickychat').prop('disabled', true);
userAndChat = true;
} else {
$('#options-stickychat').prop('disabled', false);
@ -223,14 +226,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 +242,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 +260,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;

View File

@ -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();
}

View File

@ -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()}`;
});

View File

@ -412,10 +412,12 @@ const pad = {
setTimeout(() => {
padeditor.ace.focus();
}, 0);
const optionsStickyChat = $('#options-stickychat');
optionsStickyChat.on('click', () => { chat.stickToScreen(); });
// if we have a cookie for always showing chat then show it
if (padcookie.getPref('chatAlwaysVisible')) {
chat.stickToScreen(true); // stick it to the screen
$('#options-stickychat').prop('checked', true); // set the checkbox to on
optionsStickyChat.prop('checked', true); // set the checkbox to on
}
// if we have a cookie for always showing chat then show it
if (padcookie.getPref('chatAndUsers')) {
@ -437,8 +439,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 +713,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);

View File

@ -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) => {

View File

@ -31,7 +31,7 @@ const padconnectionstatus = (() => {
const self = {
init: () => {
$('button#forcereconnect').click(() => {
$('button#forcereconnect').on('click', () => {
window.location.reload();
});
},

View File

@ -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', () => {

View File

@ -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) {

View File

@ -38,7 +38,7 @@ const padimpexp = (() => {
const fileInputUpdated = () => {
$('#importsubmitinput').addClass('throbbold');
$('#importformfilediv').addClass('importformenabled');
$('#importsubmitinput').removeAttr('disabled');
$('#importsubmitinput').prop('disabled', false);
$('#importmessagefail').fadeOut('fast');
};
@ -69,8 +69,8 @@ const padimpexp = (() => {
$('#import_export').removeClass('popup-show');
if (directDatabaseAccess) window.location.reload();
}
$('#importsubmitinput').removeAttr('disabled').val(html10n.get('pad.impexp.importbutton'));
window.setTimeout(() => $('#importfileinput').removeAttr('disabled'), 0);
$('#importsubmitinput').prop('disabled', false).val(html10n.get('pad.impexp.importbutton'));
window.setTimeout(() => $('#importfileinput').prop('disabled', false), 0);
$('#importstatusball').hide();
addImportFrames();
})();
@ -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();

View File

@ -325,23 +325,23 @@ 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');
jqueryNode.prop('disabled', false).addClass('editable');
};
let pad = undefined;
@ -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');

View File

@ -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();
}
@ -313,11 +313,11 @@ const padutils = {
if (value) {
$(node).attr('checked', 'checked');
} else {
$(node).removeAttr('checked');
$(node).prop('checked', false);
}
},
bindCheckboxChange: (node, func) => {
$(node).change(func);
$(node).on('change', func);
},
encodeUserId: (userId) => userId.replace(/[^a-y0-9]/g, (c) => {
if (c === '.') return '-';

View File

@ -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();
});

View File

@ -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() || '');
});
};

View File

@ -33,7 +33,7 @@ $._farbtastic = function (container, options) {
fb.linkTo = function (callback) {
// Unbind previous nodes
if (typeof fb.callback == 'object') {
$(fb.callback).unbind('keyup', fb.updateValue);
$(fb.callback).off('keyup').on('keyup').on('keyup', fb.updateValue);
}
// Reset color
@ -45,7 +45,7 @@ $._farbtastic = function (container, options) {
}
else if (typeof callback == 'object' || typeof callback == 'string') {
fb.callback = $(callback);
fb.callback.bind('keyup', fb.updateValue);
fb.callback.on('keyup', fb.updateValue);
if (fb.callback[0].value) {
fb.setColor(fb.callback[0].value);
}
@ -388,7 +388,7 @@ $._farbtastic = function (container, options) {
fb.mousedown = function (event) {
// Capture mouse
if (!$._farbtastic.dragging) {
$(document).bind('mousemove', fb.mousemove).bind('mouseup', fb.mouseup);
$(document).on('mousemove', fb.mousemove).on('mouseup', fb.mouseup);
$._farbtastic.dragging = true;
}
@ -429,8 +429,8 @@ $._farbtastic = function (container, options) {
*/
fb.mouseup = function () {
// Uncapture mouse
$(document).unbind('mousemove', fb.mousemove);
$(document).unbind('mouseup', fb.mouseup);
$(document).off('mousemove').on('mousemove',fb.mousemove);
$(document).off('mouseup').on('mouseup', fb.mouseup);
$._farbtastic.dragging = false;
}
@ -519,7 +519,7 @@ $._farbtastic = function (container, options) {
fb.initWidget();
// Install mousedown handler (the others are set on the document on-demand)
$('canvas.farbtastic-overlay', container).mousedown(fb.mousedown);
$('canvas.farbtastic-overlay', container).on('mousedown',fb.mousedown);
// Set linked elements/callback
if (options.callback) {

File diff suppressed because it is too large Load Diff

View File

@ -123,7 +123,7 @@
$dropdown.find('.list').css('max-height', $maxListHeight + 'px');
} else {
$dropdown.focus();
$dropdown.trigger('focus');
}
});

View File

@ -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'); });
};

View File

@ -122,7 +122,7 @@
<% e.begin_block("mySettings"); %>
<h2 data-l10n-id="pad.settings.myView"></h2>
<p class="hide-for-mobile">
<input type="checkbox" id="options-stickychat" onClick="chat.stickToScreen();">
<input type="checkbox" id="options-stickychat">
<label for="options-stickychat" data-l10n-id="pad.settings.stickychat"></label>
</p>
<p class="hide-for-mobile">

View File

@ -37,7 +37,7 @@ helper.edit = async (message, line) => {
await helper.withFastCommit(async (incorp) => {
helper.linesDiv()[line].sendkeys(message);
incorp();
await helper.waitForPromise(() => editsNum + 1 === helper.commits.length);
await helper.waitForPromise(() => editsNum + 1 === helper.commits.length, 10000);
});
};
@ -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);
};

View File

@ -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'));
};

View File

@ -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;
};
@ -80,8 +80,8 @@ describe('Admin > Settings', function () {
await helper.waitForPromise(async () => {
oldStartTime = await getStartTime();
return oldStartTime != null && oldStartTime > 0;
}, 1000, 500);
helper.admin$('#restartEtherpad').click();
}, 2100, 500);
helper.admin$('#restartEtherpad').trigger('click');
await helper.waitForPromise(async () => {
const startTime = await getStartTime();
return startTime != null && startTime > oldStartTime;

View File

@ -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(

View File

@ -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 &&

View File

@ -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();

View File

@ -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}');

View File

@ -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);

View File

@ -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);

View File

@ -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);
});

View File

@ -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');

View File

@ -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();

View File

@ -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');

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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');

View File

@ -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;

View File

@ -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);
});

View File

@ -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';

View File

@ -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();

View File

@ -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);
};

View File

@ -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();

View File

@ -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;

View File

@ -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));
});
});

View File

@ -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));

View File

@ -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);
});

View File

@ -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);
});

View File

@ -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);
});