2020-10-21 17:43:17 +00:00
|
|
|
/**
|
|
|
|
* the contentWindow is either the normal pad or timeslider
|
|
|
|
*
|
|
|
|
* @returns {HTMLElement} contentWindow
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.contentWindow = function () {
|
2020-10-21 17:43:17 +00:00
|
|
|
return $('#iframe-container iframe')[0].contentWindow;
|
2020-11-23 18:21:51 +00:00
|
|
|
};
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Opens the chat unless it is already open via an
|
|
|
|
* icon on the bottom right of the page
|
|
|
|
*
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.showChat = function () {
|
|
|
|
const chaticon = helper.chatIcon();
|
|
|
|
if (chaticon.hasClass('visible')) {
|
|
|
|
chaticon.click();
|
|
|
|
return helper.waitForPromise(() => !chaticon.hasClass('visible'), 2000);
|
2020-10-21 17:43:17 +00:00
|
|
|
}
|
2020-11-23 18:21:51 +00:00
|
|
|
};
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Closes the chat window if it is shown and not sticky
|
|
|
|
*
|
|
|
|
* @returns {Promise}
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.hideChat = function () {
|
|
|
|
if (helper.isChatboxShown() && !helper.isChatboxSticky()) {
|
|
|
|
helper.titlecross().click();
|
|
|
|
return helper.waitForPromise(() => !helper.isChatboxShown(), 2000);
|
2020-10-21 17:43:17 +00:00
|
|
|
}
|
2020-11-23 18:21:51 +00:00
|
|
|
};
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the chat icon from the bottom right of the page
|
|
|
|
*
|
|
|
|
* @returns {HTMLElement} the chat icon
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.chatIcon = function () { return helper.padChrome$('#chaticon'); };
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The chat messages from the UI
|
|
|
|
*
|
|
|
|
* @returns {Array.<HTMLElement>}
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.chatTextParagraphs = function () { return helper.padChrome$('#chattext').children('p'); };
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the chat box is sticky
|
|
|
|
*
|
|
|
|
* @returns {boolean} stickyness of the chat box
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.isChatboxSticky = function () {
|
2020-10-21 17:43:17 +00:00
|
|
|
return helper.padChrome$('#chatbox').hasClass('stickyChat');
|
2020-11-23 18:21:51 +00:00
|
|
|
};
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the chat box is shown
|
|
|
|
*
|
|
|
|
* @returns {boolean} visibility of the chat box
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.isChatboxShown = function () {
|
2020-10-21 17:43:17 +00:00
|
|
|
return helper.padChrome$('#chatbox').hasClass('visible');
|
2020-11-23 18:21:51 +00:00
|
|
|
};
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the settings menu
|
|
|
|
*
|
|
|
|
* @returns {HTMLElement} the settings menu
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.settingsMenu = function () { return helper.padChrome$('#settings'); };
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the settings button
|
|
|
|
*
|
|
|
|
* @returns {HTMLElement} the settings button
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.settingsButton = function () { return helper.padChrome$("button[data-l10n-id='pad.toolbar.settings.title']"); };
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the titlecross icon
|
|
|
|
*
|
|
|
|
* @returns {HTMLElement} the titlecross icon
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.titlecross = function () { return helper.padChrome$('#titlecross'); };
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the settings menu is visible
|
|
|
|
*
|
|
|
|
* @returns {boolean} is the settings menu shown?
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.isSettingsShown = function () {
|
2020-10-21 17:43:17 +00:00
|
|
|
return helper.padChrome$('#settings').hasClass('popup-show');
|
2020-11-23 18:21:51 +00:00
|
|
|
};
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the timer div of a timeslider that has the datetime of the revision
|
|
|
|
*
|
|
|
|
* @returns {HTMLElement} timer
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.timesliderTimer = function () {
|
|
|
|
if (typeof helper.contentWindow().$ === 'function') {
|
|
|
|
return helper.contentWindow().$('#timer');
|
2020-10-21 17:43:17 +00:00
|
|
|
}
|
2020-11-23 18:21:51 +00:00
|
|
|
};
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the time of the revision on a timeslider
|
|
|
|
*
|
|
|
|
* @returns {HTMLElement} timer
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.timesliderTimerTime = function () {
|
|
|
|
if (helper.timesliderTimer()) {
|
|
|
|
return helper.timesliderTimer().text();
|
2020-10-21 17:43:17 +00:00
|
|
|
}
|
2020-11-23 18:21:51 +00:00
|
|
|
};
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The ui-slidar-bar element in the timeslider
|
|
|
|
*
|
|
|
|
* @returns {HTMLElement}
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.sliderBar = function () {
|
|
|
|
return helper.contentWindow().$('#ui-slider-bar');
|
|
|
|
};
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* revision_date element
|
|
|
|
* like "Saved October 10, 2020"
|
|
|
|
*
|
|
|
|
* @returns {HTMLElement}
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.revisionDateElem = function () {
|
2020-10-21 17:43:17 +00:00
|
|
|
return helper.contentWindow().$('#revision_date').text();
|
2020-11-23 18:21:51 +00:00
|
|
|
};
|
2020-10-21 17:43:17 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* revision_label element
|
|
|
|
* like "Version 1"
|
|
|
|
*
|
|
|
|
* @returns {HTMLElement}
|
|
|
|
*/
|
2020-11-23 18:21:51 +00:00
|
|
|
helper.revisionLabelElem = function () {
|
|
|
|
return helper.contentWindow().$('#revision_label');
|
|
|
|
};
|