The forum of the forums
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Select Content Button

2 posters

Go down

Tutorial Select Content Button

Post by Base Mon 18 Jul 2011, 16:46

Select Content Button

Hello Forumotion members,

In this tutorial, you will discover how to put a 'Select Content' button for every code box as seen on this forum. This tutorial is compatible for all forum versions.

An example of the 'Select Content' button as seen on this forum:
Select Content Button Selectcontentbutton
Clicking it will automatically select the contents of the code box:
Select Content Button Selectcontentbutton2
Step 1:
Navigate to...
Administration Panel → Modules Tab → Javascript codes management → Create a new javascript

Step 2:
Call it whatever you like and set its placement to all pages.

Step 3:
Once you have done that, you will need to add the following code into 'Javascript Code' field :

    function selectCode(e) {
        var doc = document
            , text = $(e).closest("dl").find(".cont_code,code").get(0)
            , range, selection
        if (doc.body.createTextRange) {
            range = document.body.createTextRange();
        } else if (window.getSelection) {
            selection = window.getSelection();        
            range = document.createRange();
    $(function(){$("dl.codebox:not(.spoiler,.hidecode)  > dd.code, dl.codebox:not(.spoiler,.hidecode)  > dd > code").closest("dl").find('dt').append('<span onClick="selectCode(this)" class="selectCode">Select Content</span>')});

Step 4 :
Go to  Administration Panel > Display > Colors > CSS stylesheet

Add the following to your stylesheet to style the select content button and submit :
.selectCode { float:right; text-transform: uppercase; cursor:pointer; }
div.cont_code { clear: right; }

If you have done all the steps correctly then you should have a fully functioning 'Select Content' button appearing for every code box. Wink


Male Posts : 10386
Reputation : 1695
Language : English and French
Location : United Kingdom, England

Back to top Go down

Tutorial Re: Select Content Button

Post by SLGray Tue 25 Apr 2017, 19:48

The JavaScript has been updated since an issue with Chrome and Firefox.  You need to update your JavaScript if you are using it.

Select Content Button Slgray10

When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.

Male Posts : 51481
Reputation : 3519
Language : English
Location : United States

Back to top Go down

Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum