mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/8996] Revert initial fix to keep old behaviour on empty selection
Revert "[ticket/8996] Also fix the BBCode bug in subsilver2 and acp"
This reverts commit eb1f15bc8b
.
PHPBB3-8996
This commit is contained in:
parent
e596d2ca7e
commit
730d2d5d19
3 changed files with 108 additions and 117 deletions
|
@ -84,10 +84,14 @@ function bbfontstyle(bbopen, bbclose)
|
||||||
if ((clientVer >= 4) && is_ie && is_win)
|
if ((clientVer >= 4) && is_ie && is_win)
|
||||||
{
|
{
|
||||||
// Get text selection
|
// Get text selection
|
||||||
if (textarea.createTextRange && textarea.caretPos)
|
theSelection = document.selection.createRange().text;
|
||||||
|
|
||||||
|
if (theSelection)
|
||||||
{
|
{
|
||||||
textarea.caretPos.text = bbopen + textarea.caretPos.text + bbclose;
|
// Add tags around selection
|
||||||
textarea.focus();
|
document.selection.createRange().text = bbopen + theSelection + bbclose;
|
||||||
|
document.forms[form_name].elements[text_name].focus();
|
||||||
|
theSelection = '';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -117,7 +121,7 @@ function bbfontstyle(bbopen, bbclose)
|
||||||
else if (document.selection)
|
else if (document.selection)
|
||||||
{
|
{
|
||||||
var range = textarea.createTextRange();
|
var range = textarea.createTextRange();
|
||||||
range.move("character", bbopen.length);
|
range.move("character", new_pos);
|
||||||
range.select();
|
range.select();
|
||||||
storeCaret(textarea);
|
storeCaret(textarea);
|
||||||
}
|
}
|
||||||
|
@ -288,17 +292,7 @@ function mozWrap(txtarea, open, close)
|
||||||
*/
|
*/
|
||||||
function storeCaret(textEl)
|
function storeCaret(textEl)
|
||||||
{
|
{
|
||||||
var keyCode = false;
|
if (textEl.createTextRange)
|
||||||
if (is_ie)
|
|
||||||
{
|
|
||||||
keyCode = (event.keyCode) ? event.keyCode : event.charCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Did the user press Shift (16), Ctrl (17) or Alt (18)?
|
|
||||||
// If so, we do not update the caretPos, so BBCodes can still be applied correctly.
|
|
||||||
var is_control_key = (keyCode == 16 || keyCode == 17 || keyCode == 18);
|
|
||||||
|
|
||||||
if ((!is_ie || !is_control_key) && (textEl.createTextRange))
|
|
||||||
{
|
{
|
||||||
textEl.caretPos = document.selection.createRange().duplicate();
|
textEl.caretPos = document.selection.createRange().duplicate();
|
||||||
}
|
}
|
||||||
|
@ -376,7 +370,7 @@ function getCaretPosition(txtarea)
|
||||||
var caretPos = new caretPosition();
|
var caretPos = new caretPosition();
|
||||||
|
|
||||||
// simple Gecko/Opera way
|
// simple Gecko/Opera way
|
||||||
if (!is_ie && (txtarea.selectionStart || txtarea.selectionStart == 0))
|
if (txtarea.selectionStart || txtarea.selectionStart == 0)
|
||||||
{
|
{
|
||||||
caretPos.start = txtarea.selectionStart;
|
caretPos.start = txtarea.selectionStart;
|
||||||
caretPos.end = txtarea.selectionEnd;
|
caretPos.end = txtarea.selectionEnd;
|
||||||
|
|
|
@ -86,10 +86,10 @@ function bbfontstyle(bbopen, bbclose)
|
||||||
if ((clientVer >= 4) && is_ie && is_win)
|
if ((clientVer >= 4) && is_ie && is_win)
|
||||||
{
|
{
|
||||||
// Get text selection
|
// Get text selection
|
||||||
|
textarea = document.forms[form_name].elements[text_name];
|
||||||
if (textarea.createTextRange && textarea.caretPos)
|
if (textarea.createTextRange && textarea.caretPos)
|
||||||
{
|
{
|
||||||
textarea.caretPos.text = bbopen + textarea.caretPos.text + bbclose;
|
textarea.caretPos.text = bbopen + textarea.caretPos.text + bbclose;
|
||||||
textarea.focus();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -351,9 +351,7 @@ function storeCaret(textEl)
|
||||||
|
|
||||||
// Did the user press Shift (16), Ctrl (17) or Alt (18)?
|
// Did the user press Shift (16), Ctrl (17) or Alt (18)?
|
||||||
// If so, we do not update the caretPos, so BBCodes can still be applied correctly.
|
// If so, we do not update the caretPos, so BBCodes can still be applied correctly.
|
||||||
var is_control_key = (keyCode == 16 || keyCode == 17 || keyCode == 18);
|
if ((!is_ie || (keyCode != 16 && keyCode != 17 && keyCode != 18)) && (textEl.createTextRange))
|
||||||
|
|
||||||
if ((!is_ie || !is_control_key) && (textEl.createTextRange))
|
|
||||||
{
|
{
|
||||||
textEl.caretPos = document.selection.createRange().duplicate();
|
textEl.caretPos = document.selection.createRange().duplicate();
|
||||||
}
|
}
|
||||||
|
@ -439,6 +437,7 @@ function getCaretPosition(txtarea)
|
||||||
// dirty and slow IE way
|
// dirty and slow IE way
|
||||||
else if(document.selection)
|
else if(document.selection)
|
||||||
{
|
{
|
||||||
|
|
||||||
// get current selection
|
// get current selection
|
||||||
var range = document.selection.createRange();
|
var range = document.selection.createRange();
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
// Startup variables
|
// Startup variables
|
||||||
var imageTag = false;
|
var imageTag = false;
|
||||||
var theSelection = false;
|
var theSelection = false;
|
||||||
|
|
||||||
var bbcodeEnabled = true;
|
var bbcodeEnabled = true;
|
||||||
|
|
||||||
// Check for Browser & Platform for PC & IE specific bits
|
// Check for Browser & Platform for PC & IE specific bits
|
||||||
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
|
// More details from: http://www.mozilla.org/docs/web-developer/sniffer/browser_type.html
|
||||||
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
|
var clientPC = navigator.userAgent.toLowerCase(); // Get client info
|
||||||
|
@ -15,6 +15,7 @@ var clientVer = parseInt(navigator.appVersion); // Get browser version
|
||||||
|
|
||||||
var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1));
|
var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1));
|
||||||
var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1));
|
var is_win = ((clientPC.indexOf('win') != -1) || (clientPC.indexOf('16bit') != -1));
|
||||||
|
|
||||||
var baseHeight;
|
var baseHeight;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -43,7 +44,6 @@ function initInsertions()
|
||||||
}
|
}
|
||||||
|
|
||||||
var textarea = doc.forms[form_name].elements[text_name];
|
var textarea = doc.forms[form_name].elements[text_name];
|
||||||
|
|
||||||
if (is_ie && typeof(baseHeight) != 'number')
|
if (is_ie && typeof(baseHeight) != 'number')
|
||||||
{
|
{
|
||||||
textarea.focus();
|
textarea.focus();
|
||||||
|
@ -86,10 +86,14 @@ function bbfontstyle(bbopen, bbclose)
|
||||||
if ((clientVer >= 4) && is_ie && is_win)
|
if ((clientVer >= 4) && is_ie && is_win)
|
||||||
{
|
{
|
||||||
// Get text selection
|
// Get text selection
|
||||||
if (textarea.createTextRange && textarea.caretPos)
|
theSelection = document.selection.createRange().text;
|
||||||
|
|
||||||
|
if (theSelection)
|
||||||
{
|
{
|
||||||
textarea.caretPos.text = bbopen + textarea.caretPos.text + bbclose;
|
// Add tags around selection
|
||||||
textarea.focus();
|
document.selection.createRange().text = bbopen + theSelection + bbclose;
|
||||||
|
document.forms[form_name].elements[text_name].focus();
|
||||||
|
theSelection = '';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,6 +163,7 @@ function insert_text(text, spaces, popup)
|
||||||
textarea.selectionStart = sel_start + text.length;
|
textarea.selectionStart = sel_start + text.length;
|
||||||
textarea.selectionEnd = sel_end + text.length;
|
textarea.selectionEnd = sel_end + text.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (textarea.createTextRange && textarea.caretPos)
|
else if (textarea.createTextRange && textarea.caretPos)
|
||||||
{
|
{
|
||||||
if (baseHeight != textarea.caretPos.boundingHeight)
|
if (baseHeight != textarea.caretPos.boundingHeight)
|
||||||
|
@ -166,9 +171,9 @@ function insert_text(text, spaces, popup)
|
||||||
textarea.focus();
|
textarea.focus();
|
||||||
storeCaret(textarea);
|
storeCaret(textarea);
|
||||||
}
|
}
|
||||||
|
|
||||||
var caret_pos = textarea.caretPos;
|
var caret_pos = textarea.caretPos;
|
||||||
caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) == ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
|
caret_pos.text = caret_pos.text.charAt(caret_pos.text.length - 1) == ' ' ? caret_pos.text + text + ' ' : caret_pos.text + text;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -178,6 +183,7 @@ function insert_text(text, spaces, popup)
|
||||||
{
|
{
|
||||||
textarea.focus();
|
textarea.focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -273,6 +279,7 @@ function addquote(post_id, username, l_wrote)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function split_lines(text)
|
function split_lines(text)
|
||||||
{
|
{
|
||||||
var lines = text.split('\n');
|
var lines = text.split('\n');
|
||||||
|
@ -309,6 +316,7 @@ function split_lines(text)
|
||||||
}
|
}
|
||||||
return splitLines;
|
return splitLines;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* From http://www.massless.org/mozedit/
|
* From http://www.massless.org/mozedit/
|
||||||
*/
|
*/
|
||||||
|
@ -343,17 +351,7 @@ function mozWrap(txtarea, open, close)
|
||||||
*/
|
*/
|
||||||
function storeCaret(textEl)
|
function storeCaret(textEl)
|
||||||
{
|
{
|
||||||
var keyCode = false;
|
if (textEl.createTextRange)
|
||||||
if (is_ie)
|
|
||||||
{
|
|
||||||
keyCode = (event.keyCode) ? event.keyCode : event.charCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Did the user press Shift (16), Ctrl (17) or Alt (18)?
|
|
||||||
// If so, we do not update the caretPos, so BBCodes can still be applied correctly.
|
|
||||||
var is_control_key = (keyCode == 16 || keyCode == 17 || keyCode == 18);
|
|
||||||
|
|
||||||
if ((!is_ie || !is_control_key) && (textEl.createTextRange))
|
|
||||||
{
|
{
|
||||||
textEl.caretPos = document.selection.createRange().duplicate();
|
textEl.caretPos = document.selection.createRange().duplicate();
|
||||||
}
|
}
|
||||||
|
@ -431,7 +429,7 @@ function getCaretPosition(txtarea)
|
||||||
var caretPos = new caretPosition();
|
var caretPos = new caretPosition();
|
||||||
|
|
||||||
// simple Gecko/Opera way
|
// simple Gecko/Opera way
|
||||||
if (!is_ie && (txtarea.selectionStart || txtarea.selectionStart == 0))
|
if(txtarea.selectionStart || txtarea.selectionStart == 0)
|
||||||
{
|
{
|
||||||
caretPos.start = txtarea.selectionStart;
|
caretPos.start = txtarea.selectionStart;
|
||||||
caretPos.end = txtarea.selectionEnd;
|
caretPos.end = txtarea.selectionEnd;
|
||||||
|
|
Loading…
Add table
Reference in a new issue