Changeset 11940


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

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

File:
1 edited

Legend:

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

    r10485 r11940  
    2222{html_head}{literal}
    2323<script type="text/javascript">
     24/**
     25* jQuery Cookie plugin
     26*
     27* Copyright (c) 2010 Klaus Hartl (stilbuero.de)
     28* Dual licensed under the MIT and GPL licenses:
     29* http://www.opensource.org/licenses/mit-license.php
     30* http://www.gnu.org/licenses/gpl.html
     31*
     32*/
     33jQuery.cookie = function (key, value, options) {
     34
     35    // key and at least value given, set cookie...
     36    if (arguments.length > 1 && String(value) !== "[object Object]") {
     37        options = jQuery.extend({}, options);
     38
     39        if (value === null || value === undefined) {
     40            options.expires = -1;
     41        }
     42
     43        if (typeof options.expires === 'number') {
     44            var days = options.expires, t = options.expires = new Date();
     45            t.setDate(t.getDate() + days);
     46        }
     47
     48        value = String(value);
     49
     50        return (document.cookie = [
     51            encodeURIComponent(key), '=',
     52            options.raw ? value : encodeURIComponent(value),
     53            options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
     54            options.path ? '; path=' + options.path : '',
     55            options.domain ? '; domain=' + options.domain : '',
     56            options.secure ? '; secure' : ''
     57        ].join(''));
     58    }
     59
     60    // key and possibly options given, get cookie...
     61    options = value || {};
     62    var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent;
     63    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null;
     64};
     65
     66
     67
    2468jQuery(document).ready(function(){
    25         $(".titre_acordeon").click(function() {
     69        $(".titre_acordeon, .titre_acordeon_0").each(function () {
     70                var id = $(this).parent().attr("id");
     71                if (!jQuery.cookie(id))
     72                {
     73                        if ( $(this).attr("class")=="titre_acordeon")
     74                        {
     75                                jQuery.cookie($(this).parent().attr("id"),false, {path: "/"});
     76                                $(this).next().hide();
     77                        }
     78                        else
     79                        {
     80                                $(this).next().show();
     81                                jQuery.cookie($(this).parent().attr("id"),true, {path: "/"});
     82                        }
     83                }
     84                else if (jQuery.cookie(id) == "true")
     85                {
     86                        $(this).next().show();
     87                }
     88                else
     89                {
     90                        $(this).next().hide();
     91                }
     92        });
     93       
     94        $(".titre_acordeon, .titre_acordeon_0").click(function() {
    2695                $(this).next().toggle("medium");
    27         }).next().hide();
    28 });
    29 jQuery(document).ready(function(){
    30         $(".titre_acordeon_0").click(function() {
    31                 $(this).next().toggle("medium");
    32         }).next().show();
     96                var id = $(this).parent().attr("id");
     97                if ( jQuery.cookie(id) == "true")
     98                {
     99                        jQuery.cookie(id, false, {path: "/"});
     100                }
     101                else
     102                {
     103                        jQuery.cookie(id, true, {path: "/"});
     104                }
     105        });
    33106});
    34107$(function(){
Note: See TracChangeset for help on using the changeset viewer.