Sidebar close at default

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • valendono
    New Member
    • Feb 2008
    • 25
    • 3.6.x

    [Forum] Sidebar close at default

    Hi all,

    My forum so wide on monitor 1024x768 causing by banner, I just want to keep close the sidebar to the right as default. But I want to keep it exist. How I do that ?

    Thanks.
  • Dody
    Senior Member
    • Aug 2004
    • 1896
    • 3.8.x

    #2
    There is no option to do it. You need to modify the JavaScript in order to close the sidebar as the default behavior.
    while(true){
    if(
    $someone->needsHelp() && $i->canHelp()) $post->help();
    if(
    $i->findBug()) $post->bug();
    }

    Comment

    • valendono
      New Member
      • Feb 2008
      • 25
      • 3.6.x

      #3
      any clue ?

      Comment

      • Removed-836727
        Banned by User Request
        • Apr 2006
        • 1274

        #4
        Originally posted by Dody
        There is no option to do it. You need to modify the JavaScript in order to close the sidebar as the default behavior.
        Instead of modify the original file, i would add the code to the forumhome template at the bottom.

        Something like: if sidebar collapse == true, toggle_colapse()

        Comment

        • Removed-836727
          Banned by User Request
          • Apr 2006
          • 1274

          #5
          Sorry, i thought
          Code:
          vB_XHTML_Ready.subscribe((function(){
              vBSidebar.toggle_collapse();
          }));
          would work, but it isn't

          Comment

          • Removed-836727
            Banned by User Request
            • Apr 2006
            • 1274

            #6
            Maybe there is a other way, but i've got it this way working:
            1. in vbulletin_sidebar.js change the function sidebar to:
            Code:
            vB_XHTML_Ready.subscribe((
            function(){
                if (fetch_cookie("vbulletin_sidebar_collapse") != 1)
                    {
                        sidebar.expand();
                    }
            }));
            
            var sidebar;
            
            function init_sidebar() {
              sidebar =  new vBSidebar();
              sidebar.init();
            }
            function vBSidebar() {
               
            }
            Maybe there's a nicer way^^

            Comment

            • Luciano
              Member
              • Apr 2001
              • 87
              • 3.8.x

              #7
              I think its open by default... it checks the cookie.. and then closes..
              you would have to add a javascript at top of page...
              like
              HTML Code:
              <script type="text/javascript">
              	var getCollapsed = fetch_cookie('vbulletin_sidebar_closed');
              	if (getCollapsed != '1')
              	{
              		var expires = new Date();
              		expires.setTime(expires.getTime() + (1000 * 86400 * 365));
              		set_cookie('vbulletin_sidebar_closed', 1, expires);
              		set_cookie('vbulletin_sidebar_collapse', 1, expires);
              	}
              </script>
              or just paste it at top of vbulletin-sidebar.js...
              Just make sure its before the rest of vbulletin-sidebar.js gets called...
              it checks if cookie is there.. if not it sets the sidebar collapsed cookie and sets another cookie to say it doesnt have to check anymore...
              (I hope i got the 1 and 0 right..)

              This will only work once... if the user sets the sidebar open.. and leaves the page, it will remain open..
              if you want it closed every time he loads the page.. do this:
              HTML Code:
              <script type="text/javascript">
              		var expires = new Date();
              		expires.setTime(expires.getTime() + (1000 * 86400 * 365));
              		set_cookie('vbulletin_sidebar_collapse', 1, expires);
              
              </script>
              Luc
              Last edited by Luciano; Wed 23 Dec '09, 10:26am.

              Comment

              • valendono
                New Member
                • Feb 2008
                • 25
                • 3.6.x

                #8
                thanks I will try..

                Comment

                • valendono
                  New Member
                  • Feb 2008
                  • 25
                  • 3.6.x

                  #9
                  work!

                  I create new .js and put on clientscript/vbulletin-sidebar-closed.js
                  HTML Code:
                      var getCollapsed = fetch_cookie('vbulletin_sidebar_closed');
                      if (getCollapsed != '1')
                      {
                          var expires = new Date();
                          expires.setTime(expires.getTime() + (1000 * 86400 * 365));
                          set_cookie('vbulletin_sidebar_closed', 1, expires);
                          set_cookie('vbulletin_sidebar_collapse', 1, expires);
                      }
                  After that going to the skin forum, FORUMHOME and put

                  HTML Code:
                  <script type="text/javascript" src="{vb:raw vboptions.bburl}/clientscript/vbulletin-sidebar-closed.js?v={vb:raw vboptions.simpleversion}"></script>
                  above vbulletin-sidebar.js position.. voila and its work.. nice.. and thank you very much..

                  Comment

                  • Removed-836727
                    Banned by User Request
                    • Apr 2006
                    • 1274

                    #10
                    Originally posted by Luciano
                    I think its open by default... it checks the cookie.. and then closes..
                    you would have to add a javascript at top of page...
                    like
                    HTML Code:
                    <script type="text/javascript">
                    	var getCollapsed = fetch_cookie('vbulletin_sidebar_closed');
                    	if (getCollapsed != '1')
                    	{
                    		var expires = new Date();
                    		expires.setTime(expires.getTime() + (1000 * 86400 * 365));
                    		set_cookie('vbulletin_sidebar_closed', 1, expires);
                    		set_cookie('vbulletin_sidebar_collapse', 1, expires);
                    	}
                    </script>
                    or just paste it at top of vbulletin-sidebar.js...
                    Just make sure its before the rest of vbulletin-sidebar.js gets called...
                    it checks if cookie is there.. if not it sets the sidebar collapsed cookie and sets another cookie to say it doesnt have to check anymore...
                    (I hope i got the 1 and 0 right..)

                    This will only work once... if the user sets the sidebar open.. and leaves the page, it will remain open..
                    if you want it closed every time he loads the page.. do this:
                    HTML Code:
                    <script type="text/javascript">
                    		var expires = new Date();
                    		expires.setTime(expires.getTime() + (1000 * 86400 * 365));
                    		set_cookie('vbulletin_sidebar_collapse', 1, expires);
                    
                    </script>
                    Luc
                    thx

                    Comment

                    • Luciano
                      Member
                      • Apr 2001
                      • 87
                      • 3.8.x

                      #11
                      glad to help...
                      Luc

                      Comment

                      • Sworm1
                        Senior Member
                        • Feb 2008
                        • 488
                        • 4.0.0

                        #12
                        Originally posted by Luciano
                        I think its open by default... it checks the cookie.. and then closes..
                        you would have to add a javascript at top of page...
                        like
                        HTML Code:
                        <script type="text/javascript">
                            var getCollapsed = fetch_cookie('vbulletin_sidebar_closed');
                            if (getCollapsed != '1')
                            {
                                var expires = new Date();
                                expires.setTime(expires.getTime() + (1000 * 86400 * 365));
                                set_cookie('vbulletin_sidebar_closed', 1, expires);
                                set_cookie('vbulletin_sidebar_collapse', 1, expires);
                            }
                        </script>
                        I have added this one but don't work

                        Here my vbulletin-sidebar.js (hope that is correct):
                        Code:
                        /*======================================================================*\
                        || #################################################################### ||
                        || # vBulletin 4.0.3
                        || # ---------------------------------------------------------------- # ||
                        || # Copyright ©2000-2010 vBulletin Solutions Inc. All Rights Reserved. ||
                        || # This file may not be redistributed in whole or significant part. # ||
                        || # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
                        || # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
                        || #################################################################### ||
                        \*======================================================================*/
                        <script type="text/javascript">
                            var getCollapsed = fetch_cookie('vbulletin_sidebar_closed');
                            if (getCollapsed != '1')
                            {
                                var expires = new Date();
                                expires.setTime(expires.getTime() + (1000 * 86400 * 365));
                                set_cookie('vbulletin_sidebar_closed', 1, expires);
                                set_cookie('vbulletin_sidebar_collapse', 1, expires);
                            }
                        </script>
                        vB_XHTML_Ready.subscribe(init_sidebar);function init_sidebar(){new vBSidebar()}function vBSidebar(){this.init()}vBSidebar.prototype.init=function(){this.sidebar_button=YAHOO.util.Dom.get("sidebar_button");this.sidebar_container=YAHOO.util.Dom.get("sidebar_container");this.sidebar=YAHOO.util.Dom.get("sidebar");this.content_container=YAHOO.util.Dom.get("content_container");this.content=YAHOO.util.Dom.get("content");YAHOO.util.Event.on(this.sidebar_button,"click",this.toggle_collapse,this,true);var A=fetch_cookie("vbulletin_sidebar_collapse");if(A=="1"){this.collapse(false)}};vBSidebar.prototype.toggle_collapse=function(A){YAHOO.util.Event.stopEvent(A);if(YAHOO.util.Dom.getStyle(this.sidebar,"display")=="none"){this.expand()}else{this.collapse(true)}return false};vBSidebar.prototype.collapse=function(A){var B=this.sidebar_button;if(A){var C=new YAHOO.util.Anim(this.sidebar,{opacity:{from:1,to:0}},0.3);C.onComplete.subscribe(function(G,D,E){YAHOO.util.Dom.setStyle(E.sidebar,"display","none");YAHOO.util.Dom.setStyle(E.sidebar_container,"width","0");var F;if(sidebar_align=="right"){F=new YAHOO.util.Anim(E.content_container,{marginRight:{to:0}},0.3);F.animate();F=new YAHOO.util.Anim(E.content,{marginRight:{to:0}},0.3);F.onComplete.subscribe(function(){YAHOO.util.Dom.setAttribute(B,"src",IMGDIR_MISC+"/tab-expanded.png")});F.animate()}else{F=new YAHOO.util.Anim(E.content_container,{marginLeft:{to:0}},0.3);F.animate();F=new YAHOO.util.Anim(E.content,{marginLeft:{to:0}},0.3);F.onComplete.subscribe(function(){YAHOO.util.Dom.setAttribute(B,"src",IMGDIR_MISC+"/tab-expanded-left.png")});F.animate()}},this);C.animate()}else{YAHOO.util.Dom.setStyle(this.sidebar,"display","none");YAHOO.util.Dom.setStyle(this.sidebar_container,"width","0");if(sidebar_align=="right"){YAHOO.util.Dom.setAttribute(B,"src",IMGDIR_MISC+"/tab-expanded.png");YAHOO.util.Dom.setStyle(this.content_container,"marginRight","0");YAHOO.util.Dom.setStyle(this.content,"marginRight","0")}else{YAHOO.util.Dom.setAttribute(B,"src",IMGDIR_MISC+"/tab-expanded-left.png");YAHOO.util.Dom.setStyle(this.content_container,"marginLeft","0");YAHOO.util.Dom.setStyle(this.content,"marginLeft","0")}}this.save_collapsed("1")};vBSidebar.prototype.expand=function(){var B;var A=this.sidebar_button;if(sidebar_align=="right"){B=new YAHOO.util.Anim(this.content_container,{marginRight:{to:(0-content_container_margin)}},0.3);B.animate();B=new YAHOO.util.Anim(this.content,{marginRight:{to:content_container_margin}},0.3);B.onComplete.subscribe(function(F,C,D){YAHOO.util.Dom.setStyle(D.sidebar,"display","");YAHOO.util.Dom.setStyle(D.sidebar_container,"width",sidebar_width+"px");var E=new YAHOO.util.Anim(D.sidebar,{opacity:{from:0,to:1}},0.3);E.onComplete.subscribe(function(){YAHOO.util.Dom.setAttribute(A,"src",IMGDIR_MISC+"/tab-collapsed.png")});E.animate()},this);B.animate()}else{B=new YAHOO.util.Anim(this.content_container,{marginLeft:{to:(0-content_container_margin)}},0.3);B.animate();B=new YAHOO.util.Anim(this.content,{marginLeft:{to:content_container_margin}},0.3);B.onComplete.subscribe(function(F,C,D){YAHOO.util.Dom.setStyle(D.sidebar,"display","");YAHOO.util.Dom.setStyle(D.sidebar_container,"width",sidebar_width+"px");var E=new YAHOO.util.Anim(D.sidebar,{opacity:{from:0,to:1}},0.3);E.onComplete.subscribe(function(){YAHOO.util.Dom.setAttribute(A,"src",IMGDIR_MISC+"/tab-collapsed-left.png")});E.animate()},this);B.animate()}this.save_collapsed("0")};vBSidebar.prototype.save_collapsed=function(A){expires=new Date();expires.setTime(expires.getTime()+(1000*86400*365));set_cookie("vbulletin_sidebar_collapse",A,expires)};
                        Can anybody help me to start the sidebar closed as default?

                        Comment

                        • Luciano
                          Member
                          • Apr 2001
                          • 87
                          • 3.8.x

                          #13
                          do NOT add the script tags in the javascript.. this cannot work...

                          if you add it in the script then remove:
                          <script type="text/javascript"> and
                          </script>

                          only

                          Code:
                              var getCollapsed = fetch_cookie('vbulletin_sidebar_closed');
                              if (getCollapsed != '1')
                              {
                                  var expires = new Date();
                                  expires.setTime(expires.getTime() + (1000 * 86400 * 365));
                                  set_cookie('vbulletin_sidebar_closed', 1, expires);
                                  set_cookie('vbulletin_sidebar_collapse', 1, expires);
                              }

                          Comment

                          • Sworm1
                            Senior Member
                            • Feb 2008
                            • 488
                            • 4.0.0

                            #14
                            Thanks Luciano you know i'm not expert, at the top of vbulletin-sidebar.js right?

                            like this:
                            Code:
                            var getCollapsed = fetch_cookie('vbulletin_sidebar_closed');if (getCollapsed != '1'){var expires = new Date(); expires.setTime(expires.getTime() + (1000 * 86400 * 365)); set_cookie('vbulletin_sidebar_closed', 1, expires);set_cookie('vbulletin_sidebar_collapse', 1, expires);}vB_XHTML_Ready.subscribe(init_sidebar);function init_sidebar(){new vBSidebar()}function vBSidebar(){this.init()}vBSidebar.prototype.init=function(){this.sidebar_button=YAHOO.util.Dom.get("sidebar_button");this.sidebar_container=YAHOO.util.Dom.get("sidebar_container");this.sidebar=YAHOO.util.Dom.get("sidebar");this.content_container=YAHOO.util.Dom.get("content_container");this.content=YAHOO.util.Dom.get("content");YAHOO.util.Event.on(this.sidebar_button,"click",this.toggle_collapse,this,true);var A=fetch_cookie("vbulletin_sidebar_collapse");if(A=="1"){this.collapse(false)}};vBSidebar.prototype.toggle_collapse=function(A){YAHOO.util.Event.stopEvent(A);if(YAHOO.util.Dom.getStyle(this.sidebar,"display")=="none"){this.expand()}else{this.collapse(true)}return false};vBSidebar.prototype.collapse=function(A){var B=this.sidebar_button;if(A){var C=new YAHOO.util.Anim(this.sidebar,{opacity:{from:1,to:0}},0.3);C.onComplete.subscribe(function(G,D,E){YAHOO.util.Dom.setStyle(E.sidebar,"display","none");YAHOO.util.Dom.setStyle(E.sidebar_container,"width","0");var F;if(sidebar_align=="right"){F=new YAHOO.util.Anim(E.content_container,{marginRight:{to:0}},0.3);F.animate();F=new YAHOO.util.Anim(E.content,{marginRight:{to:0}},0.3);F.onComplete.subscribe(function(){YAHOO.util.Dom.setAttribute(B,"src",IMGDIR_MISC+"/tab-expanded.png")});F.animate()}else{F=new YAHOO.util.Anim(E.content_container,{marginLeft:{to:0}},0.3);F.animate();F=new YAHOO.util.Anim(E.content,{marginLeft:{to:0}},0.3);F.onComplete.subscribe(function(){YAHOO.util.Dom.setAttribute(B,"src",IMGDIR_MISC+"/tab-expanded-left.png")});F.animate()}},this);C.animate()}else{YAHOO.util.Dom.setStyle(this.sidebar,"display","none");YAHOO.util.Dom.setStyle(this.sidebar_container,"width","0");if(sidebar_align=="right"){YAHOO.util.Dom.setAttribute(B,"src",IMGDIR_MISC+"/tab-expanded.png");YAHOO.util.Dom.setStyle(this.content_container,"marginRight","0");YAHOO.util.Dom.setStyle(this.content,"marginRight","0")}else{YAHOO.util.Dom.setAttribute(B,"src",IMGDIR_MISC+"/tab-expanded-left.png");YAHOO.util.Dom.setStyle(this.content_container,"marginLeft","0");YAHOO.util.Dom.setStyle(this.content,"marginLeft","0")}}this.save_collapsed("1")};vBSidebar.prototype.expand=function(){var B;var A=this.sidebar_button;if(sidebar_align=="right"){B=new YAHOO.util.Anim(this.content_container,{marginRight:{to:(0-content_container_margin)}},0.3);B.animate();B=new YAHOO.util.Anim(this.content,{marginRight:{to:content_container_margin}},0.3);B.onComplete.subscribe(function(F,C,D){YAHOO.util.Dom.setStyle(D.sidebar,"display","");YAHOO.util.Dom.setStyle(D.sidebar_container,"width",sidebar_width+"px");var E=new YAHOO.util.Anim(D.sidebar,{opacity:{from:0,to:1}},0.3);E.onComplete.subscribe(function(){YAHOO.util.Dom.setAttribute(A,"src",IMGDIR_MISC+"/tab-collapsed.png")});E.animate()},this);B.animate()}else{B=new YAHOO.util.Anim(this.content_container,{marginLeft:{to:(0-content_container_margin)}},0.3);B.animate();B=new YAHOO.util.Anim(this.content,{marginLeft:{to:content_container_margin}},0.3);B.onComplete.subscribe(function(F,C,D){YAHOO.util.Dom.setStyle(D.sidebar,"display","");YAHOO.util.Dom.setStyle(D.sidebar_container,"width",sidebar_width+"px");var E=new YAHOO.util.Anim(D.sidebar,{opacity:{from:0,to:1}},0.3);E.onComplete.subscribe(function(){YAHOO.util.Dom.setAttribute(A,"src",IMGDIR_MISC+"/tab-collapsed-left.png")});E.animate()},this);B.animate()}this.save_collapsed("0")};vBSidebar.prototype.save_collapsed=function(A){expires=new Date();expires.setTime(expires.getTime()+(1000*86400*365));set_cookie("vbulletin_sidebar_collapse",A,expires)};
                            Is it correct?

                            Comment

                            • Luciano
                              Member
                              • Apr 2001
                              • 87
                              • 3.8.x

                              #15
                              Like this
                              Code:
                              /*======================================================================*\
                              || #################################################################### ||
                              || # vBulletin 4.0.3
                              || # ---------------------------------------------------------------- # ||
                              || # Copyright ©2000-2010 vBulletin Solutions Inc. All Rights Reserved. ||
                              || # This file may not be redistributed in whole or significant part. # ||
                              || # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
                              || # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
                              || #################################################################### ||
                              \*======================================================================*/
                              
                                  var getCollapsed = fetch_cookie('vbulletin_sidebar_closed');
                                  if (getCollapsed != '1')
                                  {
                                      var expires = new Date();
                                      expires.setTime(expires.getTime() + (1000 * 86400 * 365));
                                      set_cookie('vbulletin_sidebar_closed', 1, expires);
                                      set_cookie('vbulletin_sidebar_collapse', 1, expires);
                                  }
                              
                              vB_XHTML_Ready.subscribe(init_sidebar);function init_sidebar(){new vBSidebar()}function vBSidebar(){this.init()}vBSidebar.prototype.init=function(){this.sidebar_button=YAHOO.util.Dom.get("sidebar_button");this.sidebar_container=YAHOO.util.Dom.get("sidebar_container");this.sidebar=YAHOO.util.Dom.get("sidebar");this.content_container=YAHOO.util.Dom.get("content_container");this.content=YAHOO.util.Dom.get("content");YAHOO.util.Event.on(this.sidebar_button,"click",this.toggle_collapse,this,true);var A=fetch_cookie("vbulletin_sidebar_collapse");if(A=="1"){this.collapse(false)}};vBSidebar.prototype.toggle_collapse=function(A){YAHOO.util.Event.stopEvent(A);if(YAHOO.util.Dom.getStyle(this.sidebar,"display")=="none"){this.expand()}else{this.collapse(true)}return false};vBSidebar.prototype.collapse=function(A){var B=this.sidebar_button;if(A){var C=new YAHOO.util.Anim(this.sidebar,{opacity:{from:1,to:0}},0.3);C.onComplete.subscribe(function(G,D,E){YAHOO.util.Dom.setStyle(E.sidebar,"display","none");YAHOO.util.Dom.setStyle(E.sidebar_container,"width","0");var F;if(sidebar_align=="right"){F=new YAHOO.util.Anim(E.content_container,{marginRight:{to:0}},0.3);F.animate();F=new YAHOO.util.Anim(E.content,{marginRight:{to:0}},0.3);F.onComplete.subscribe(function(){YAHOO.util.Dom.setAttribute(B,"src",IMGDIR_MISC+"/tab-expanded.png")});F.animate()}else{F=new YAHOO.util.Anim(E.content_container,{marginLeft:{to:0}},0.3);F.animate();F=new YAHOO.util.Anim(E.content,{marginLeft:{to:0}},0.3);F.onComplete.subscribe(function(){YAHOO.util.Dom.setAttribute(B,"src",IMGDIR_MISC+"/tab-expanded-left.png")});F.animate()}},this);C.animate()}else{YAHOO.util.Dom.setStyle(this.sidebar,"display","none");YAHOO.util.Dom.setStyle(this.sidebar_container,"width","0");if(sidebar_align=="right"){YAHOO.util.Dom.setAttribute(B,"src",IMGDIR_MISC+"/tab-expanded.png");YAHOO.util.Dom.setStyle(this.content_container,"marginRight","0");YAHOO.util.Dom.setStyle(this.content,"marginRight","0")}else{YAHOO.util.Dom.setAttribute(B,"src",IMGDIR_MISC+"/tab-expanded-left.png");YAHOO.util.Dom.setStyle(this.content_container,"marginLeft","0");YAHOO.util.Dom.setStyle(this.content,"marginLeft","0")}}this.save_collapsed("1")};vBSidebar.prototype.expand=function(){var B;var A=this.sidebar_button;if(sidebar_align=="right"){B=new YAHOO.util.Anim(this.content_container,{marginRight:{to:(0-content_container_margin)}},0.3);B.animate();B=new YAHOO.util.Anim(this.content,{marginRight:{to:content_container_margin}},0.3);B.onComplete.subscribe(function(F,C,D){YAHOO.util.Dom.setStyle(D.sidebar,"display","");YAHOO.util.Dom.setStyle(D.sidebar_container,"width",sidebar_width+"px");var E=new YAHOO.util.Anim(D.sidebar,{opacity:{from:0,to:1}},0.3);E.onComplete.subscribe(function(){YAHOO.util.Dom.setAttribute(A,"src",IMGDIR_MISC+"/tab-collapsed.png")});E.animate()},this);B.animate()}else{B=new YAHOO.util.Anim(this.content_container,{marginLeft:{to:(0-content_container_margin)}},0.3);B.animate();B=new YAHOO.util.Anim(this.content,{marginLeft:{to:content_container_margin}},0.3);B.onComplete.subscribe(function(F,C,D){YAHOO.util.Dom.setStyle(D.sidebar,"display","");YAHOO.util.Dom.setStyle(D.sidebar_container,"width",sidebar_width+"px");var E=new YAHOO.util.Anim(D.sidebar,{opacity:{from:0,to:1}},0.3);E.onComplete.subscribe(function(){YAHOO.util.Dom.setAttribute(A,"src",IMGDIR_MISC+"/tab-collapsed-left.png")});E.animate()},this);B.animate()}this.save_collapsed("0")};vBSidebar.prototype.save_collapsed=function(A){expires=new Date();expires.setTime(expires.getTime()+(1000*86400*365));set_cookie("vbulletin_sidebar_collapse",A,expires)};

                              Comment

                              widgetinstance 262 (Related Topics) skipped due to lack of content & hide_module_if_empty option.
                              Working...