From 0f1e635b275879ed785b062a950c875d3e17d7e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Sun, 3 Mar 2013 08:10:30 +0100 Subject: [PATCH] Use a cookie for the toolbar. re #41 --- index.php | 8 +++++++- js/jquery.cookies.js | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 js/jquery.cookies.js diff --git a/index.php b/index.php index 5eb5e08..ef19697 100644 --- a/index.php +++ b/index.php @@ -21,6 +21,9 @@ exit (); } + $withToolbar = false; + if (!isset($_COOKIE['toolbar'])) $withToolbar = true; + header ("Content-Type:application/xhtml+xml"); $page = getURLParam ("page", Base::PAGE_INDEX); $query = getURLParam ("query"); @@ -53,6 +56,7 @@ + @@ -97,8 +101,10 @@ $("#settingsImage").click(function(){ if ($("#tool").is(":hidden")) { $("#tool").slideDown("slow"); + $.cookie('toolbar', '1'); } else { $("#tool").slideUp(); + $.removeCookie('toolbar'); } }); @@ -159,7 +165,7 @@
-
+
>
diff --git a/js/jquery.cookies.js b/js/jquery.cookies.js new file mode 100644 index 0000000..0321fce --- /dev/null +++ b/js/jquery.cookies.js @@ -0,0 +1,10 @@ +/*! + * jQuery Cookie Plugin + * https://github.com/carhartl/jquery-cookie + * Copyright 2011, Klaus Hartl + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://www.opensource.org/licenses/mit-license.php + * http://www.opensource.org/licenses/GPL-2.0 + * Last update: Sun, 03 Mar 2013 06:56:32 +0000 + */ +(function(factory){if(typeof define==='function'&&define.amd){define(['jquery'],factory)}else{factory(jQuery)}}(function($){var pluses=/\+/g;function raw(s){return s}function decoded(s){return decodeURIComponent(s.replace(pluses,' '))}function converted(s){if(s.indexOf('"')===0){s=s.slice(1,-1).replace(/\\"/g, '"').replace(/\\\\/g,'\\');}try{return config.json?JSON.parse(s):s}catch(er){}}var config=$.cookie=function(key,value,options){if(value!==undefined){options=$.extend({},config.defaults,options);if(typeof options.expires==='number'){var days=options.expires,t=options.expires=new Date();t.setDate(t.getDate()+days)}value=config.json?JSON.stringify(value):String(value);return(document.cookie=[config.raw?key:encodeURIComponent(key),'=',config.raw?value:encodeURIComponent(value),options.expires?'; expires='+options.expires.toUTCString():'',options.path?'; path='+options.path:'',options.domain?'; domain='+options.domain:'',options.secure?'; secure':''].join(''))}var decode=config.raw?raw:decoded;var cookies=document.cookie.split('; ');var result=key?undefined:{};for(var i=0,l=cookies.length;i