Set Cookie on jQuery WOAHbar (Hello Bar alternative) to Remember Previous State

Hello everyone,

I’ve installed the WOAHbar on a new site which is an awesome free alternative
to the Hello Bar, found here:

http://blog.jobdeals.com/2011/12/free-hellobar-com-alternative-source-code/

The only thing I want to change is for it to remember the previous state the visitor
chooses when they navigate to a different page or post. I’m trying to use the
jQuery Cookie plugin. I’m new to jQuery, so I’m having trouble figuring it out.

Here’s the jQuery for WOAHbar:

<script type="text/javascript">
    var stub_showing = false;

    function woahbar_show() {
        if(stub_showing) {
          $('.woahbar-stub').slideUp('fast', function() {
            $('.woahbar').show('bounce', { times:3, distance:15 }, 100);
            $('body').animate({"marginTop": "2.4em"}, 250);
          });
        }
        else {
          $('.woahbar').show('bounce', { times:3, distance:15 }, 100);
          $('body').animate({"marginTop": "2.4em"}, 250);
        }
    }


    function woahbar_hide() {
        $('.woahbar').slideUp('fast', function() {
          $('.woahbar-stub').show('bounce', { times:3, distance:15 }, 100);
          stub_showing = true;
        });

        if( $(window).width() > 1024 ) {
          $('body').animate({"marginTop": "0px"}, 250); // if width greater than 1024 pull up the body
        }
    }

    $().ready(function() {
        window.setTimeout(function() {
        woahbar_show();
     }, 5000);


    });
	</script>

Any help would be appreciated!

That would involve doing two things.

  1. When a tab is opened, set a cookie that records information about which tab has been opened.
  2. When the page loads, use that cookie information (if it exists) to set the current tab.

I read your question the other day and did not find the response very helpful. I was able to figure it out and I wrote about it on my blog: Adding Cookies to a WOAHBar.

Hope it helps.

Mark