Changeset 11941


Ignore:
Timestamp:
Aug 12, 2011, 6:52:50 PM (13 years ago)
Author:
flop25
Message:

jquery.cookie for managing tabs : now the theme remembers the status hidden/shown of each tabs

Location:
extensions/floOS
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • extensions/floOS/OS_glass_clear/local_head.tpl

    r10290 r11941  
    22{html_head}{literal}
    33<script type="text/javascript">
     4/**
     5* jQuery Cookie plugin
     6*
     7* Copyright (c) 2010 Klaus Hartl (stilbuero.de)
     8* Dual licensed under the MIT and GPL licenses:
     9* http://www.opensource.org/licenses/mit-license.php
     10* http://www.gnu.org/licenses/gpl.html
     11*
     12*/
     13jQuery.cookie = function (key, value, options) {
     14
     15    // key and at least value given, set cookie...
     16    if (arguments.length > 1 && String(value) !== "[object Object]") {
     17        options = jQuery.extend({}, options);
     18
     19        if (value === null || value === undefined) {
     20            options.expires = -1;
     21        }
     22
     23        if (typeof options.expires === 'number') {
     24            var days = options.expires, t = options.expires = new Date();
     25            t.setDate(t.getDate() + days);
     26        }
     27
     28        value = String(value);
     29
     30        return (document.cookie = [
     31            encodeURIComponent(key), '=',
     32            options.raw ? value : encodeURIComponent(value),
     33            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
     34            options.path ? '; path=' + options.path : '',
     35            options.domain ? '; domain=' + options.domain : '',
     36            options.secure ? '; secure' : ''
     37        ].join(''));
     38    }
     39
     40    // key and possibly options given, get cookie...
     41    options = value || {};
     42    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
     43    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
     44};
     45
     46
     47
    448jQuery(document).ready(function(){
    5         $(".titre_acordeon").click(function() {
     49        $(".titre_acordeon, .titre_acordeon_0").each(function () {
     50                var id = $(this).parent().attr("id");
     51                if (!jQuery.cookie(id))
     52                {
     53                        if ( $(this).attr("class")=="titre_acordeon")
     54                        {
     55                                jQuery.cookie($(this).parent().attr("id"),false, {path: "/"});
     56                                $(this).next().hide();
     57                        }
     58                        else
     59                        {
     60                                $(this).next().show();
     61                                jQuery.cookie($(this).parent().attr("id"),true, {path: "/"});
     62                        }
     63                }
     64                else if (jQuery.cookie(id) == "true")
     65                {
     66                        $(this).next().show();
     67                }
     68                else
     69                {
     70                        $(this).next().hide();
     71                }
     72        });
     73       
     74        $(".titre_acordeon, .titre_acordeon_0").click(function() {
    675                $(this).next().toggle("medium");
    7         }).next().hide();
    8 });
    9 jQuery(document).ready(function(){
    10         $(".titre_acordeon_0").click(function() {
    11                 $(this).next().toggle("medium");
    12         }).next().show();
     76                var id = $(this).parent().attr("id");
     77                if ( jQuery.cookie(id) == "true")
     78                {
     79                        jQuery.cookie(id, false, {path: "/"});
     80                }
     81                else
     82                {
     83                        jQuery.cookie(id, true, {path: "/"});
     84                }
     85        });
    1386});
    1487$(function(){
  • extensions/floOS/OS_glass_dark/local_head.tpl

    r10289 r11941  
    22{html_head}{literal}
    33<script type="text/javascript">
     4/**
     5* jQuery Cookie plugin
     6*
     7* Copyright (c) 2010 Klaus Hartl (stilbuero.de)
     8* Dual licensed under the MIT and GPL licenses:
     9* http://www.opensource.org/licenses/mit-license.php
     10* http://www.gnu.org/licenses/gpl.html
     11*
     12*/
     13jQuery.cookie = function (key, value, options) {
     14
     15    // key and at least value given, set cookie...
     16    if (arguments.length > 1 && String(value) !== "[object Object]") {
     17        options = jQuery.extend({}, options);
     18
     19        if (value === null || value === undefined) {
     20            options.expires = -1;
     21        }
     22
     23        if (typeof options.expires === 'number') {
     24            var days = options.expires, t = options.expires = new Date();
     25            t.setDate(t.getDate() + days);
     26        }
     27
     28        value = String(value);
     29
     30        return (document.cookie = [
     31            encodeURIComponent(key), '=',
     32            options.raw ? value : encodeURIComponent(value),
     33            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
     34            options.path ? '; path=' + options.path : '',
     35            options.domain ? '; domain=' + options.domain : '',
     36            options.secure ? '; secure' : ''
     37        ].join(''));
     38    }
     39
     40    // key and possibly options given, get cookie...
     41    options = value || {};
     42    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
     43    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
     44};
     45
     46
     47
    448jQuery(document).ready(function(){
    5         $(".titre_acordeon").click(function() {
     49        $(".titre_acordeon, .titre_acordeon_0").each(function () {
     50                var id = $(this).parent().attr("id");
     51                if (!jQuery.cookie(id))
     52                {
     53                        if ( $(this).attr("class")=="titre_acordeon")
     54                        {
     55                                jQuery.cookie($(this).parent().attr("id"),false, {path: "/"});
     56                                $(this).next().hide();
     57                        }
     58                        else
     59                        {
     60                                $(this).next().show();
     61                                jQuery.cookie($(this).parent().attr("id"),true, {path: "/"});
     62                        }
     63                }
     64                else if (jQuery.cookie(id) == "true")
     65                {
     66                        $(this).next().show();
     67                }
     68                else
     69                {
     70                        $(this).next().hide();
     71                }
     72        });
     73       
     74        $(".titre_acordeon, .titre_acordeon_0").click(function() {
    675                $(this).next().toggle("medium");
    7         }).next().hide();
    8 });
    9 jQuery(document).ready(function(){
    10         $(".titre_acordeon_0").click(function() {
    11                 $(this).next().toggle("medium");
    12         }).next().show();
     76                var id = $(this).parent().attr("id");
     77                if ( jQuery.cookie(id) == "true")
     78                {
     79                        jQuery.cookie(id, false, {path: "/"});
     80                }
     81                else
     82                {
     83                        jQuery.cookie(id, true, {path: "/"});
     84                }
     85        });
    1386});
    1487$(function(){
  • extensions/floOS/OS_glass_dark_2/local_head.tpl

    r10288 r11941  
    22{html_head}{literal}
    33<script type="text/javascript">
     4/**
     5* jQuery Cookie plugin
     6*
     7* Copyright (c) 2010 Klaus Hartl (stilbuero.de)
     8* Dual licensed under the MIT and GPL licenses:
     9* http://www.opensource.org/licenses/mit-license.php
     10* http://www.gnu.org/licenses/gpl.html
     11*
     12*/
     13jQuery.cookie = function (key, value, options) {
     14
     15    // key and at least value given, set cookie...
     16    if (arguments.length > 1 && String(value) !== "[object Object]") {
     17        options = jQuery.extend({}, options);
     18
     19        if (value === null || value === undefined) {
     20            options.expires = -1;
     21        }
     22
     23        if (typeof options.expires === 'number') {
     24            var days = options.expires, t = options.expires = new Date();
     25            t.setDate(t.getDate() + days);
     26        }
     27
     28        value = String(value);
     29
     30        return (document.cookie = [
     31            encodeURIComponent(key), '=',
     32            options.raw ? value : encodeURIComponent(value),
     33            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
     34            options.path ? '; path=' + options.path : '',
     35            options.domain ? '; domain=' + options.domain : '',
     36            options.secure ? '; secure' : ''
     37        ].join(''));
     38    }
     39
     40    // key and possibly options given, get cookie...
     41    options = value || {};
     42    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
     43    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
     44};
     45
     46
     47
    448jQuery(document).ready(function(){
    5         $(".titre_acordeon").click(function() {
     49        $(".titre_acordeon, .titre_acordeon_0").each(function () {
     50                var id = $(this).parent().attr("id");
     51                if (!jQuery.cookie(id))
     52                {
     53                        if ( $(this).attr("class")=="titre_acordeon")
     54                        {
     55                                jQuery.cookie($(this).parent().attr("id"),false, {path: "/"});
     56                                $(this).next().hide();
     57                        }
     58                        else
     59                        {
     60                                $(this).next().show();
     61                                jQuery.cookie($(this).parent().attr("id"),true, {path: "/"});
     62                        }
     63                }
     64                else if (jQuery.cookie(id) == "true")
     65                {
     66                        $(this).next().show();
     67                }
     68                else
     69                {
     70                        $(this).next().hide();
     71                }
     72        });
     73       
     74        $(".titre_acordeon, .titre_acordeon_0").click(function() {
    675                $(this).next().toggle("medium");
    7         }).next().hide();
    8 });
    9 jQuery(document).ready(function(){
    10         $(".titre_acordeon_0").click(function() {
    11                 $(this).next().toggle("medium");
    12         }).next().show();
     76                var id = $(this).parent().attr("id");
     77                if ( jQuery.cookie(id) == "true")
     78                {
     79                        jQuery.cookie(id, false, {path: "/"});
     80                }
     81                else
     82                {
     83                        jQuery.cookie(id, true, {path: "/"});
     84                }
     85        });
    1386});
    1487$(function(){
Note: See TracChangeset for help on using the changeset viewer.