rayantony / jixedbar

Automatically exported from code.google.com/p/jixedbar
GNU General Public License v2.0
0 stars 0 forks source link

minimized all the time #61

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. minimize it
2. go to another page
3. it´s not minimized more

What version of the product are you using? On what operating system?
Windows 7, firefox 4.0, jixedbar 0.0.5

Please provide any additional information below.

Original issue reported on code.google.com by kimlip...@gmail.com on 15 May 2011 at 5:31

GoogleCodeExporter commented 9 years ago
I doubt this is a problem with the jixedbar.   It uses cookies to "write" the 
minimized state.  
var hideBar = false; // default bar hide/show status

if ($(this).checkCookie("JXID")) { // check if cookie already exists
    if ($(this).readCookie("JXHID") == "true") {
    this.hideBar = true; // hide bar
    }           
} else { // else drop cookie
    $(this).createCookie("JXID", $(this).genRandID()); // set random ID and create cookie
    $(this).createCookie("JXHID", false); // set bar hide to false then create cookie
}

Then it shows it based on the cookie state:
// check if we need to hide the bar (based on cookie)
if (this.hideBar) {
    $(this).css({"display": "none" // do not display the main bar});    
}

This works across page loads just fine.  Although it won't be as compatible 
with older browsers, I personally would prefer the use of http session storage 
over cookies.

Make sure you have cookies enabled in your browser else you can expect to see 
the behavior your seeing.

Original comment by Gary.Tes...@gmail.com on 10 Jun 2011 at 1:57

GoogleCodeExporter commented 9 years ago
i have cookies enable, and not work on all browsers.
So i dig a little and found that we need to negate the comparison of cookie_end.

if (cookie_end == -1) its wrong
if (cookie_end != -1) its ok

Full working function bellow.

jQuery.fn.checkCookie = function(cookie_name) {
    if (document.cookie.length > 0) {
        cookie_start = document.cookie.indexOf(cookie_name + "=");
            if (cookie_start != -1) {
                cookie_start = cookie_start + cookie_name.length + 1;
                cookie_end = document.cookie.indexOf(";", cookie_start);
                if (cookie_end != -1) { // bug correction: must be not equal
                    cookie_end = document.cookie.length;
                    return true;
                }
            }
    }
    return false;
};

Original comment by inaci...@gmail.com on 24 Mar 2012 at 1:41