Version: 1.00, by BCP Hung
Developer Last Online: Jan 2019
Category: BB Code Enhancements -
Version: 4.x.x
Rating:
Released: 06-09-2011
Last Update: Never
Installs: 26
Template Edits
Code Changes Translations
No support by the author.
About this modification :
This mods template allows you added to the BB Code CODE / HTML / PHP function selects all the content in it with a simple button.
Install :
Insert javascript code into headinclude template
AdminCP -> Styles & Templates -> Style Manager -> Edit Templates -> headinclude
Copy and paste following js code to bottom of headinclude template :
HTML Code:
<script type="text/javascript">
function selectAll(a)
{
var e = a.parentNode.parentNode.getElementsByTagName('code')[0];
if (window.getSelection)
{
var s = window.getSelection();
if (s.setBaseAndExtent)
{
s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
}
else
{
var r = document.createRange();
r.selectNodeContents(e);
s.removeAllRanges();
s.addRange(r);
}
}
else if (document.getSelection)
{
var s = document.getSelection();
var r = document.createRange();
r.selectNodeContents(e);
s.removeAllRanges();
s.addRange(r);
}
else if (document.selection)
{
var r = document.body.createTextRange();
r.moveToElementText(e);
r.select();
}
}
</script>
Insert new code to bbcode template
... -> Edit Templates -> BB Code Layout Templates -> bbcode_code
Find :
(Optional) Add new phrase : If you don't want to do this step, please look at "Notes" !
AdminCP -> Languages & Phrases -> Phrase Manager -> [Add New Phrase]
Phrase Type : GLOBAL
Product : vBulletin
Varname : select_code
Text : select all
Notes :
If you don't want to create new phrase (step 5), you can search for : {vb:rawphrase select_code} and replace with select all
Next version : add new feature "copy to clipboard".
Show Your Support
This modification may not be copied, reproduced or published elsewhere without author's permission.
This mod doesn`t work with my site. Error is "Parameter is not an object [Break On This Error] r.selectNodeContents(e); " Can you tell me how to fix it ?
I'm not versed enough in Javascript enough to fix this properly. What does make this work is by removing the following:
PHP Code:
if (s.setBaseAndExtent) { s.setBaseAndExtent(e, 0, e, e.innerText.length - 1); } else {
and the } after the else
So the new Javascript in the headinclude is
PHP Code:
<script type="text/javascript"> function selectAll(a) { var e = a.parentNode.parentNode.getElementsByTagName('code')[0]; if (window.getSelection) { var s = window.getSelection();
var r = document.createRange(); r.selectNodeContents(e); s.removeAllRanges(); s.addRange(r);
} else if (document.getSelection) { var s = document.getSelection(); var r = document.createRange(); r.selectNodeContents(e); s.removeAllRanges(); s.addRange(r); } else if (document.selection) { var r = document.body.createTextRange(); r.moveToElementText(e); r.select(); } } </script>
Hope this helps someone.
If there's anyone who can post the correct java solution without removing any code that would be great.