vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vBulletin 4.x Template Modifications (https://vborg.vbsupport.ru/forumdisplay.php?f=246)
-   -   BB Code Enhancements - "select all" feature for BB Code : CODE/HTML/PHP (https://vborg.vbsupport.ru/showthread.php?t=264981)

BCP Hung 06-09-2011 10:00 PM

"select all" feature for BB Code : CODE/HTML/PHP
 
1 Attachment(s)
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 :
  1. 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>

  2. Insert new code to bbcode template
    ... -> Edit Templates -> BB Code Layout Templates -> bbcode_code
    Find :
    Code:

    {vb:rawphrase code}:

    ...and...

    {vb:raw code}

    Change :
    Code:

    {vb:rawphrase code}:&nbsp;<input type="button" value="{vb:rawphrase select_code}" onclick="selectAll(this); return false;">

    ...and...

    <code>{vb:raw code}</code>

  3. Insert new code to bbcode_html template (same bbcode_code)
    ... -> Edit Templates -> BB Code Layout Templates -> bbcode_html
    Find :
    Code:

    {vb:rawphrase html_code}:

    ...and...

    {vb:raw code}

    Change :
    Code:

    {vb:rawphrase html_code}:&nbsp;<input type="button" value="{vb:rawphrase select_code}" onclick="selectAll(this); return false;">

    ...and...

    <code>{vb:raw code}</code>

  4. Insert new code to bbcode_php template (same bbcode_code)
    ... -> Edit Templates -> BB Code Layout Templates -> bbcode_php
    Find :
    Code:

    {vb:rawphrase php_code}:
    Change :
    Code:

    {vb:rawphrase php_code}:&nbsp;<input type="button" value="{vb:rawphrase select_code}" onclick="selectAll(this); return false;">
  5. (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".

nitra1000 06-10-2011 11:07 AM

Good job, tagged for later

BCP Hung 06-10-2011 03:26 PM

New update : fix bug : same phrase with CKEditor phrase in vBulletin 4.1.4.

Thank you,
Getamped 1404.

nacaruncr 06-11-2011 02:34 AM

working fine in 4.1.3 :D

Thanks men :D

tagged + installed + MOTM + 5 stars :D

BCP Hung 06-11-2011 03:04 AM

Quote:

Originally Posted by nacaruncr (Post 2206068)
working fine in 4.1.3 :D

Thanks men :D

tagged + installed + MOTM + 5 stars :D

Thanks for feedback !

You will be like next version with "copy to clipboard" feature. But, some bugs with flash file must be fix ! :confused:

nacaruncr 06-12-2011 12:13 AM

Ok, I'll wait it .. thanks so much.

Twikitero 06-13-2011 05:29 AM

Thank you very much, works perfectly 100%.
A major modification, pending the copy to clipboard very necessary for my forum

Thanks again

Marked as installed

BCP Hung 06-13-2011 06:40 AM

Quote:

Originally Posted by Twikitero (Post 2206952)
A major modification, pending the copy to clipboard very necessary for my forum

Yes, I know that. I'm having a lot of project, I will way back with this modification soon !

Thanks for used,
Getamped 1404.

Twikitero 07-03-2011 04:42 PM

Thank you.

Just please do not forget the copy to clipboard.

I love your modifications.

regards

BCP Hung 07-03-2011 05:46 PM

Quote:

Originally Posted by Twikitero (Post 2216284)
Thank you.

Just please do not forget the copy to clipboard.

I love your modifications.

regards

Sorry, I really busy now, my free time very poor.

I need more time to update.

Thanks,
Getamped 1404.

nacaruncr 07-10-2011 07:08 AM

Thanks men :D I wait for the upgrade :D

f4vn 11-21-2011 01:01 PM

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 ?

Thank you,

bigs15 01-27-2013 05:36 AM

is this work with 3.8.7 thankx in advance...

bulwinkl 01-31-2014 09:25 PM

Great job, I really appreciated this.

This really should be part of the default Vbulletin.

Worked perfectly in 4.2.2:up:

ahobilam 02-03-2014 03:18 PM

I am using VB 4.2.2
The code found in my (custom template) bbcode_code and bbcode_html are different
than what you are instructed for find as below:
Code:

<div class="bbcode_container">
        <div class="bbcode_description">{vb:rawphrase html_code}:</div>
        <pre class="bbcode_code"<vb:if condition="$vboptions['codemaxlines']"> style="height:<vb:if condition="$blockheight<=$vboptions['codemaxlines']">{vb:math {vb:math {vb:raw blockheight}+2}}*{vb:stylevar mid_fontSize}}<vb:else />{vb:math {vb:math {vb:raw blockheight}+1}*{vb:stylevar mid_fontSize}}</vb:if>;"</vb:if>>{vb:raw code}</pre>
</div>

Can I replace it, I want to conform before making any changes.

What is the meaning for
....and.....
between the code.
Thanks in advance.

ramesh_umk3 02-05-2014 01:14 PM

it will work as i am running vbulletin 4.2.2

leave ....and.....

replace only starting and ending code which he mentioned

Regards,

RedHacker 06-06-2016 06:17 AM

Thanks it is work with 4.1.7

john7911 06-15-2016 09:09 AM

Hi,
It does not work on my forum 4.2.3 :(
Can somme one tell me where is the problem?
Thank you :)
https://vborg.vbsupport.ru/external/2016/06/5.jpg


-----------------------------------
It's ok I found the problem :cool: I forgot a < in the beginning of the code :erm:

Raptor 05-05-2017 06:19 AM

This stopped working in Chrome just recently

Works fine in Edge and cellphone browser

Uncaught DOMException: Failed to execute 'setBaseAndExtent' on 'Selection': There is no child at offset 18125.
at selectAll (

Raptor 05-07-2017 12:51 PM

Update:

Select All works in Chrome Version 57.0.2987.133 (64-bit)

Stopped working after update to Chrome Version 58.0.3029.96 (64-bit)

Problem: the last parameter to the "setBaseAndExtent" shouldn't be the text length, it should be the child node count.

https://developer.mozilla.org/en-US/...tBaseAndExtent

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(e0ee.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 
window.getSelection();
 
                var 
document.createRange();
                
r.selectNodeContents(e);
                
s.removeAllRanges();
                
s.addRange(r);
 
        }
        else if (
document.getSelection)
        {
            var 
document.getSelection();
            var 
document.createRange();
            
r.selectNodeContents(e);
            
s.removeAllRanges();
            
s.addRange(r);
        }
        else if  (
document.selection)
        {
            var 
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.

My vB is 4.2.4 btw

RedHacker 05-31-2020 04:34 AM

Hello can be fix this to work ?

PinkMilk 05-31-2020 09:55 AM

CSS4 solution:
Code:

.selectable{
    -webkit-touch-callout: all; /* iOS Safari */
    -webkit-user-select: all; /* Safari */
    -khtml-user-select: all; /* Konqueror HTML */
    -moz-user-select: all; /* Firefox */
    -ms-user-select: all; /* Internet Explorer/Edge */
    user-select: all; /* Chrome and Opera */
}

user-select is a CSS Module Level 4 specification, that is currently a draft and non-standard CSS property, but browsers support it well ? see #search=user-select.

Read more on user-select here on MDN and play with it here in w3scools

Source

RedHacker 08-31-2021 06:43 AM

No work at 4.2.5


All times are GMT. The time now is 06:37 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.01239 seconds
  • Memory Usage 1,810KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (8)bbcode_code_printable
  • (1)bbcode_html_printable
  • (2)bbcode_php_printable
  • (3)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (23)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete