Login Register
MoHH2 Legendz

Legends of Medal of honor:Heores 2.. Never forgotten RiP in piece


    You are not connected. Please login or register

    View previous topic View next topic Go down  Message [Page 1 of 1]

    Post: #1Mon Aug 13, 2012 12:40 am

    Nietzsche

    Nietzsche

    Gold Member
    Gold Member


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

    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 (your forum version ONLY):

    phpBB 2
    Code:
    function selectCode(a)
        {
        // Get ID of code block
        var e = jQuery(a).closest('tr').next().find('.cont_code')[0];

        // Not IE
        if (window.getSelection)
        {
        var s = window.getSelection();
        // Safari
        if (s.setBaseAndExtent)
        {
        s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
        }
        // Firefox and Opera
        else
        {
        // workaround for bug # 42885
        if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>')
        {
        e.innerHTML = e.innerHTML + ' ';
        }

        var r = document.createRange();
        r.selectNodeContents(e);
        s.removeAllRanges();
        s.addRange(r);
        }
        }
        // Some older browsers
        else if (document.getSelection)
        {
        var s = document.getSelection();
        var r = document.createRange();
        r.selectNodeContents(e);
        s.removeAllRanges();
        s.addRange(r);
        }
        // IE
        else if (document.selection)
        {
        var r = document.body.createTextRange();
        r.moveToElementText(e);
        r.select();
        }
        }
        jQuery(function(){

        jQuery('div.postbody td.code').parent().prev().find('b').html('Code:
        <a href="javascript:void()" onClick="selectCode(this)"><font
        face="verdana" color="red"></font> Select Content </a>');
        });


    phpBB 3, punBB and Invision

    Code:
    function selectCode(a)
        {
          // Get ID of code block
          var e = a.parentNode.parentNode.getElementsByTagName('CODE')[0];
       
          // Not IE
          if (window.getSelection)
          {
              var s = window.getSelection();
              // Safari
              if (s.setBaseAndExtent)
              {
                s.setBaseAndExtent(e, 0, e, e.innerText.length - 1);
              }
              // Firefox and Opera
              else
              {
                // workaround for bug # 42885
                if (window.opera && e.innerHTML.substring(e.innerHTML.length - 4) == '<BR>')
                {
                    e.innerHTML = e.innerHTML + ' ';
                }
       
                var r = document.createRange();
                r.selectNodeContents(e);
                s.removeAllRanges();
                s.addRange(r);
              }
          }
          // Some older browsers
          else if (document.getSelection)
          {
              var s = document.getSelection();
              var r = document.createRange();
              r.selectNodeContents(e);
              s.removeAllRanges();
              s.addRange(r);
          }
          // IE
          else if (document.selection)
          {
              var r = document.body.createTextRange();
              r.moveToElementText(e);
              r.select();
          }
        }
        if(text){}else{ var text = 'Selecionar todos';}
        jQuery(document).ready(function(){
          jQuery("dl.codebox dt").not("dl.spoiler > dt").html('Code: <a href="#" onclick="selectCode(this); return false;" title="Select all the content" class="code-a"> Select Content </a>');
        });


    Tutorial written by Base, with the help of k.201017 and Gangstar15


    http://elitegamers4life.forumotion.com/

    Post: #2Mon Aug 13, 2012 2:26 am

    avatar

    Vader

    Master Vader


    I like the idea awesomeness


    Post: #3Mon Aug 13, 2012 2:28 am

    Nietzsche

    Nietzsche

    Gold Member
    Gold Member


    They should add this code to this forum hint hint Wink


    http://elitegamers4life.forumotion.com/

    Post: #4Mon Aug 13, 2012 5:55 pm

    StriickeN

    StriickeN

    Admins
    Admins


    we never use the code box though Confused and can't you select one letter and hit ctrl + A what? but i guess i'll add it anyway... Razz


    http://www.psvmods.net

    Post: #5Thu Aug 16, 2012 7:16 am

    Nietzsche

    Nietzsche

    Gold Member
    Gold Member


    thx


    http://elitegamers4life.forumotion.com/

    Post: #6Sat Aug 18, 2012 8:06 am

    Dead1077

    Dead1077

    Senior Member


    it a cool idea give ya credit man


    Post: #7Sat Aug 18, 2012 8:16 am

    Nietzsche

    Nietzsche

    Gold Member
    Gold Member


    THX Wink


    http://elitegamers4life.forumotion.com/

    Post: #8

    Sponsored content





    View previous topic View next topic Back to top  Message [Page 1 of 1]

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