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 Code not working.

5 posters

Go down

In progress Select Content Code not working.

Post by The Life Less One 17/4/2014, 06:19

Hello so I used this tutorial to do the select content feature for my friends forum but it doesn't work for some reason.
https://help.forumotion.com/t93456-select-content-button the tutorial is there and the forum is version phpbb3 so I used the second code for it. When the code was copied and pasted into the javascript code management it seemed to work but whenever I or other members click it, it scrolls us up at the top Confused

Any ideas on how to solve this?
avatar
The Life Less One
New Member

Posts : 5
Reputation : 1
Language : English

http://yugiohzexalduelacade.forumotion.com/

Back to top Go down

In progress Re: Select Content Code not working.

Post by Needhelplease:( 17/4/2014, 07:04

Are you sure you followed everything "Correctly"?
avatar
Needhelplease:(
New Member

Posts : 4
Reputation : 1
Language : English

Back to top Go down

In progress Re: Select Content Code not working.

Post by The Life Less One 17/4/2014, 07:10

Yea javascript is enabled and it is also set to all pages. The indentations are also correct.
avatar
The Life Less One
New Member

Posts : 5
Reputation : 1
Language : English

http://yugiohzexalduelacade.forumotion.com/

Back to top Go down

In progress Re: Select Content Code not working.

Post by Michael_vx 17/4/2014, 10:34

hi try this code it working on my forum
javascript
Code:
function
    
   selectCode(a){a=$(a).closest("dl").find(".cont_code,code")[0];if(window.getSelection){var
    
   c=window.getSelection();if(c.setBaseAndExtent)c.setBaseAndExtent(a,0,a,a.innerText.length-1);else{window.opera&&a.innerHTML.substring(a.innerHTML.length-4)=="<BR>"&&(a.innerHTML+="
     ");var
    b=document.createRange();b.selectNodeContents(a);c.removeAllRanges();c.addRange(b)}}else
    
   document.getSelection?(c=document.getSelection(),b=document.createRange(),b.selectNodeContents(a),
    c.removeAllRanges(),c.addRange(b)):document.selection&&(b=document.body.createTextRange(),b.moveToElementText(a),b.select())}
    
   $(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">code_select</span>');
    });
i guess you will need also to put this css code

Code:
.selectCode {
cursor:pointer;
float:right;
text-transform:uppercase;
}

i hope it works with you
Michael_vx
Michael_vx
Forumember

Male Posts : 664
Reputation : 29
Language : Arabic and some English
Location : Egypt

Back to top Go down

In progress Re: Select Content Code not working.

Post by Pizza Boi 17/4/2014, 10:36

Hi Very Happy

Are you using any other Javascript for the topics? Please post your forum Url so we can check if there are conflicting scripts.

Regards,
Pizza Boi
Pizza Boi
Pizza Boi
Hyperactive

Male Posts : 2016
Reputation : 160
Language : French
Location : Pizza Hut!

Back to top Go down

In progress Re: Select Content Code not working.

Post by Ange Tuteur 17/4/2014, 16:10

Hello The Life Less One,

Since the last update to the editor the select content code on versions like phpbb2 stopped working. Over on FR support there's a code that should work for all versions, regardless.

Replace your script by :
Code:
       function selectCode(a){a=$(a).closest("dl").find(".cont_code,code")[0];if(window.getSelection){var c=window.getSelection();if(c.setBaseAndExtent)c.setBaseAndExtent(a,0,a,a.innerText.length-1);else{window.opera&&a.innerHTML.substring(a.innerHTML.length-4)=="<BR>"&&(a.innerHTML+=" ");var b=document.createRange();b.selectNodeContents(a);c.removeAllRanges();c.addRange(b)}}else document.getSelection?(c=document.getSelection(),b=document.createRange(),b.selectNodeContents(a),
        c.removeAllRanges(),c.addRange(b)):document.selection&&(b=document.body.createTextRange(),b.moveToElementText(a),b.select())}
        
       $(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">Sélectionner le contenu</span>');
        });

Then add the following to your stylesheet :
Display > Colors > CSS stylesheet
Code:
.selectCode { float:right; text-transform: uppercase; cursor:pointer; }
div.cont_code { clear: right; }
Ange Tuteur
Ange Tuteur
Forumaster

Male Posts : 13244
Reputation : 2998
Language : English & 日本語
Location : Pennsylvania

https://fmdesign.forumotion.com

Back to top Go down

Back to top

- Similar topics

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