mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/13713] Move function to get textarea element to core.js
PHPBB3-13713
This commit is contained in:
parent
1b5c521d8f
commit
a0d9c7fe85
3 changed files with 29 additions and 25 deletions
|
@ -1745,6 +1745,31 @@ phpbb.lazyLoadAvatars = function loadAvatars() {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get editor text area element
|
||||||
|
*
|
||||||
|
* @param {string} formName Name of form
|
||||||
|
* @param {string} textareaName Textarea name
|
||||||
|
*
|
||||||
|
* @return {HTMLElement|null} Text area element or null if textarea couldn't be found
|
||||||
|
*/
|
||||||
|
phpbb.getEditorTextArea = function(formName, textareaName) {
|
||||||
|
let doc;
|
||||||
|
|
||||||
|
// find textarea, make sure browser supports necessary functions
|
||||||
|
if (document.forms[formName]) {
|
||||||
|
doc = document;
|
||||||
|
} else {
|
||||||
|
doc = opener.document;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!doc.forms[formName]) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return doc.forms[formName].elements[textareaName];
|
||||||
|
}
|
||||||
|
|
||||||
phpbb.recaptcha = {
|
phpbb.recaptcha = {
|
||||||
button: null,
|
button: null,
|
||||||
ready: false,
|
ready: false,
|
||||||
|
|
|
@ -384,33 +384,11 @@ function getCaretPosition(txtarea) {
|
||||||
return caretPos;
|
return caretPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get editor text area element
|
|
||||||
*
|
|
||||||
* @return {HTMLElement|null} Text area element or null if textarea couldn't be found
|
|
||||||
*/
|
|
||||||
function getEditorTextArea() {
|
|
||||||
let doc;
|
|
||||||
|
|
||||||
// find textarea, make sure browser supports necessary functions
|
|
||||||
if (document.forms[form_name]) {
|
|
||||||
doc = document;
|
|
||||||
} else {
|
|
||||||
doc = opener.document;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!doc.forms[form_name]) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
return doc.forms[form_name].elements[text_name];
|
|
||||||
}
|
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(() => {
|
||||||
const textarea = getEditorTextArea();
|
const textarea = phpbb.getEditorTextArea(form_name, text_name);
|
||||||
|
|
||||||
if (typeof textarea === 'undefined') {
|
if (typeof textarea === 'undefined') {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -311,7 +311,8 @@
|
||||||
phpbb.mentions = new Mentions();
|
phpbb.mentions = new Mentions();
|
||||||
|
|
||||||
$(document).ready(() => {
|
$(document).ready(() => {
|
||||||
const textarea = getEditorTextArea();
|
/* global form_name, text_name */
|
||||||
|
const textarea = phpbb.getEditorTextArea(form_name, text_name);
|
||||||
|
|
||||||
if (typeof textarea === 'undefined') {
|
if (typeof textarea === 'undefined') {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Add table
Reference in a new issue