mirror of
https://github.com/ether/etherpad-lite.git
synced 2025-01-31 19:02:59 +01:00
915849b319
* lint: low hanging specs/alphabet.js * lint: low hanging specs/authorship_of_editions.js * lint: low hanging specs/bold.js * lint: low hanging specs/caret.js * lint: low hanging specs/change_user_color.js * lint: low hanging specs/change_user_name.js * lint: low hanging specs/chat.js * lint: low hanging specs/chat_load_messages.js * lint: low hanging specs/clear_authorship_colors.js * lint: low hanging specs/delete.js * lint: low hanging specs/drag_and_drop.js * lint: low hanging specs/embed_value.js * lint: low hanging specs/enter.js * lint: low hanging specs/font_type.js * lint: low hanging specs/helper.js * lint: low hanging specs/importexport.js * lint: low hanging specs/importindents.js * lint: low hanging specs/indentation.js * lint: low hanging specs/italic.js * lint: low hanging specs/language.js * lint: low hanging specs/multiple_authors_clear_authorship_colors.js * lint: low hanging specs/ordered_list.js * lint: low hanging specs/pad_modal.js * lint: low hanging specs/redo.js * lint: low hanging specs/responsiveness.js * lint: low hanging specs/select_formatting_buttons.js * lint: low hanging specs/strikethrough.js * lint: low hanging specs/timeslider.js * lint: low hanging specs/timeslider_labels.js * lint: low hanging specs/timeslider_numeric_padID.js * lint: low hanging specs/timeslider_revisions.js * lint: low hanging specs/undo.js * lint: low hanging specs/unordered_list.js * lint: low hanging specs/xxauto_reconnect.js * lint: attempt to do remote_runner.js * lint: helper linting * lint: rate limit linting * use constructor for Event to make eslint happier * for squash: lint fix refinements * for squash: lint fix refinements Co-authored-by: Richard Hansen <rhansen@rhansen.org>
191 lines
4.3 KiB
JavaScript
191 lines
4.3 KiB
JavaScript
'use strict';
|
|
|
|
/**
|
|
* the contentWindow is either the normal pad or timeslider
|
|
*
|
|
* @returns {HTMLElement} contentWindow
|
|
*/
|
|
helper.contentWindow = function () {
|
|
return $('#iframe-container iframe')[0].contentWindow;
|
|
};
|
|
|
|
/**
|
|
* Opens the chat unless it is already open via an
|
|
* icon on the bottom right of the page
|
|
*
|
|
* @returns {Promise}
|
|
*/
|
|
helper.showChat = function () {
|
|
const chaticon = helper.chatIcon();
|
|
if (chaticon.hasClass('visible')) {
|
|
chaticon.click();
|
|
return helper.waitForPromise(() => !chaticon.hasClass('visible'), 2000);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Closes the chat window if it is shown and not sticky
|
|
*
|
|
* @returns {Promise}
|
|
*/
|
|
helper.hideChat = function () {
|
|
if (helper.isChatboxShown() && !helper.isChatboxSticky()) {
|
|
helper.titlecross().click();
|
|
return helper.waitForPromise(() => !helper.isChatboxShown(), 2000);
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Gets the chat icon from the bottom right of the page
|
|
*
|
|
* @returns {HTMLElement} the chat icon
|
|
*/
|
|
helper.chatIcon = function () { return helper.padChrome$('#chaticon'); };
|
|
|
|
/**
|
|
* The chat messages from the UI
|
|
*
|
|
* @returns {Array.<HTMLElement>}
|
|
*/
|
|
helper.chatTextParagraphs = function () { return helper.padChrome$('#chattext').children('p'); };
|
|
|
|
/**
|
|
* Returns true if the chat box is sticky
|
|
*
|
|
* @returns {boolean} stickyness of the chat box
|
|
*/
|
|
helper.isChatboxSticky = function () {
|
|
return helper.padChrome$('#chatbox').hasClass('stickyChat');
|
|
};
|
|
|
|
/**
|
|
* Returns true if the chat box is shown
|
|
*
|
|
* @returns {boolean} visibility of the chat box
|
|
*/
|
|
helper.isChatboxShown = function () {
|
|
return helper.padChrome$('#chatbox').hasClass('visible');
|
|
};
|
|
|
|
/**
|
|
* Gets the settings menu
|
|
*
|
|
* @returns {HTMLElement} the settings menu
|
|
*/
|
|
helper.settingsMenu = function () { return helper.padChrome$('#settings'); };
|
|
|
|
/**
|
|
* Gets the settings button
|
|
*
|
|
* @returns {HTMLElement} the settings button
|
|
*/
|
|
helper.settingsButton = function () {
|
|
return helper.padChrome$("button[data-l10n-id='pad.toolbar.settings.title']");
|
|
};
|
|
|
|
/**
|
|
* Toggles user list
|
|
*/
|
|
helper.toggleUserList = async function () {
|
|
const isVisible = helper.userListShown();
|
|
const button = helper.padChrome$("button[data-l10n-id='pad.toolbar.showusers.title']");
|
|
button.click();
|
|
await helper.waitForPromise(() => !isVisible);
|
|
};
|
|
|
|
/**
|
|
* Gets the user name input field
|
|
*
|
|
* @returns {HTMLElement} user name input field
|
|
*/
|
|
helper.usernameField = function () {
|
|
return helper.padChrome$("input[data-l10n-id='pad.userlist.entername']");
|
|
};
|
|
|
|
/**
|
|
* Is the user list popup shown?
|
|
*
|
|
* @returns {boolean}
|
|
*/
|
|
helper.userListShown = function () {
|
|
return helper.padChrome$('div#users').hasClass('popup-show');
|
|
};
|
|
|
|
/**
|
|
* Sets the user name
|
|
*
|
|
*/
|
|
helper.setUserName = async (name) => {
|
|
const userElement = helper.usernameField();
|
|
userElement.click();
|
|
userElement.val(name);
|
|
userElement.blur();
|
|
await helper.waitForPromise(() => !helper.usernameField().hasClass('editactive'));
|
|
};
|
|
|
|
/**
|
|
* Gets the titlecross icon
|
|
*
|
|
* @returns {HTMLElement} the titlecross icon
|
|
*/
|
|
helper.titlecross = function () { return helper.padChrome$('#titlecross'); };
|
|
|
|
/**
|
|
* Returns true if the settings menu is visible
|
|
*
|
|
* @returns {boolean} is the settings menu shown?
|
|
*/
|
|
helper.isSettingsShown = function () {
|
|
return helper.padChrome$('#settings').hasClass('popup-show');
|
|
};
|
|
|
|
/**
|
|
* Gets the timer div of a timeslider that has the datetime of the revision
|
|
*
|
|
* @returns {HTMLElement} timer
|
|
*/
|
|
helper.timesliderTimer = function () {
|
|
if (typeof helper.contentWindow().$ === 'function') {
|
|
return helper.contentWindow().$('#timer');
|
|
}
|
|
};
|
|
|
|
/**
|
|
* Gets the time of the revision on a timeslider
|
|
*
|
|
* @returns {HTMLElement} timer
|
|
*/
|
|
helper.timesliderTimerTime = function () {
|
|
if (helper.timesliderTimer()) {
|
|
return helper.timesliderTimer().text();
|
|
}
|
|
};
|
|
|
|
/**
|
|
* The ui-slidar-bar element in the timeslider
|
|
*
|
|
* @returns {HTMLElement}
|
|
*/
|
|
helper.sliderBar = function () {
|
|
return helper.contentWindow().$('#ui-slider-bar');
|
|
};
|
|
|
|
/**
|
|
* revision_date element
|
|
* like "Saved October 10, 2020"
|
|
*
|
|
* @returns {HTMLElement}
|
|
*/
|
|
helper.revisionDateElem = function () {
|
|
return helper.contentWindow().$('#revision_date').text();
|
|
};
|
|
|
|
/**
|
|
* revision_label element
|
|
* like "Version 1"
|
|
*
|
|
* @returns {HTMLElement}
|
|
*/
|
|
helper.revisionLabelElem = function () {
|
|
return helper.contentWindow().$('#revision_label');
|
|
};
|