Closed (won't fix)
Project:
BUEditor
Version:
6.x-2.2
Component:
User interface
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
10 Mar 2011 at 19:58 UTC
Updated:
2 Mar 2012 at 12:41 UTC
Suggesting to add a button to the standatd editor to quote selected text (selected anywhere, not only in the editor field)
Here is the code
js:
textObj=document.getElementById("edit-comment");
txt = '';
if (window.getSelection && !window.opera) txt = window.getSelection();
else if (document.getSelection) txt = document.getSelection();
else if (document.selection) txt = document.selection.createRange().text;
txt='[quote]\n' + txt + '\n[/quote]\n';
textV=txt;
textV=textV.replace(/\s\[\?\]/g,'')
if (textV==''||!textObj) return
var ver=8;
if(document.all && !window.opera){
if (textObj.createTextRange&&textObj.caretPos) {
var caretPos=textObj.caretPos
caretPos.text=textV
}else textObj.value+= textV
}else
{var brows=navigator.userAgent.toString()
var scrollTop, scrollLeft
if (textObj.type=='textarea'&&textObj.scrollTop)
{scrollTop=textObj.scrollTop;scrollLeft=textObj.scrollLeft}
if(brows.search(/opera\/?(\d*.\d*)/i)!=-1) ver=RegExp.$1
if(textObj.selectionStart>=0&&ver>=8){
if(textObj.textLength != undefined)
{var selLength=textObj.textLength
var selStart=textObj.selectionStart
var selEnd=textObj.selectionEnd
if (selEnd==1||selEnd==2)selEnd=selLength
var s1=(textObj.value).substring(0,selStart)
var s2=(textObj.value).substring(selEnd,selLength)
textObj.value=s1+textV+s2
textObj.setSelectionRange(selStart+textV.length,selStart+textV.length)
}
if (typeof scrollTop != 'undefined')
{textObj.scrollTop=scrollTop;textObj.scrollLeft=scrollLeft}
}else textObj.value+=textV
}
Comments
Comment #1
superfedya commentedDoesn't work with 6.x-2.5.
Any fix?
Thanks!
Comment #2
__Sander__ commentedI am afraid, not now...
I really do not want to update my site untill it is a security reason or some significant improvement I need.
So I have nowhere to test it on...
Comment #3
ufku commentedCore would include only very simple buttons.