SocialAcademy • Forum

Social Academy Community Support Forum & Free Tutorial's & Skins



SocialAcademy • Forum » Support Section » Ask Question 's & Problems  →   Problem with advanced code box

Problem with advanced code box


    • Please log in to Reply

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

    avatar
     
    Member
    Member

    Posted on Mon Aug 17, 2015 12:36 am

     
    Details: I have this js code to made the code box collapsible, and it's morking fine but the issue is that when I toogle one the rest of the code boxes open too at the same time. How can I prevent this? I know there's something I'm missing in this code but I can't find what it is, hope someone could help me.

    This is the code I'm ussing:

    Code:
    var expand_qc = "<img src='http://i18.servimg.com/u/f18/19/22/43/68/expand10.gif' />";
    var collapse_qc = "<img src='http://i18.servimg.com/u/f18/19/22/43/68/collap10.gif' />";

    var collapsible_codes = true;
    var code_auto_hide = true;

    $(document).ready(function(){

    var check_post = $(".postbody");

    $(check_post).each(function(){
    var check_number = $(this).children(".postbody .content").length;
    for(var i=0;i <= check_number; i++){
    if($(this).has("dl.codebox:not(.spoiler,.hidecode)")){
    $("dl.codebox:not(.spoiler,.hidecode)").addClass("code-wrapper");
    $("dl.codebox:not(.spoiler,.hidecode) dt").addClass("code-header");
    $("dl.codebox:not(.spoiler,.hidecode) dd code").addClass("my-code");
    }
    }
    });

    $(".code-header").append("<span class='code-grab'>(Selecciónalo todo)</span>");

    $(".code-grab").click(function(x){
    var code_text = $(this).parents("dt:first").next("dd").children("code");

    code_text.each(function() {
    if(document.body.createTextRange){
    var code_range = document.body.createTextRange();
    code_range.moveToElementText(this);
    code_range.select();
    } else if (window.getSelection) {
    selection = window.getSelection();        
    code_range = document.createRange();
    code_range.selectNodeContents(this);
    selection.removeAllRanges();
    selection.addRange(code_range);
    }
    });

    x.stopPropagation();
    });

    if(collapsible_codes == true){
    $(".code-header").append("<span class='selectCode'>&nbsp;<span class='code-toggle' style='display:none'>"+expand_qc+"</span><span class='code-toggle'>"+collapse_qc+"</span></span>");
    if(code_auto_hide == true) {
    $("code.my-code").hide();
    $(".code-header").children(".selectCode").children("span.code-toggle").toggle();
    $(".code-header").children(".code-grab").toggle();
    }
    }

    $(".selectCode").click(function(){
    $("code.my-code").toggle();
    $("span.quote-toggle").toggle();
    $(".code-grab").toggle();
    });

    });

    Screenshot:
    Forum Address: http://loseyourmindskin1.forosinvision.com/
    Forum Version: Phpbb3

    View user profile
    avatar
     
    Administrator
     Administrator

    Posted on Mon Oct 19, 2015 7:52 am

     
    up for this ?





    Community Forum
     •  Social Academy
    Hello Guest Please be detailed for Asking Questions
    View user profile http://www.socialacademy.biz
    avatar
     
    Member
    Member

    Posted on Fri Jan 22, 2016 9:02 pm

     
    Yes, sorry for the delay, I was out of city, but yes, I up this. Many thanks.

    View user profile
    #4

    OfflineSponsored content


     

    Posted

     

    Message (Page 1 of 1)



      Share Topics Url

      Url
      BBcode
      HTML

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

       
      • Forum create on Forumotion | © PunBB | Free forum support | Contact | Report an abuse | Free forum


      Social Academy Forum

         The Summer looks out from her brazen tower,
      Through the flashing bars of July.  

      © Social Academy 2013-2017