changeset 727:fc61c6b02c78 jquery

first steps to storing embedded state in cookie
author robcast
date Tue, 01 Feb 2011 11:18:32 +0100
parents 6224f64cbd58
children 84ad95fd3202
files client/digitallibrary/jquery/jquery.digilib.js
diffstat 1 files changed, 20 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/client/digitallibrary/jquery/jquery.digilib.js	Tue Feb 01 00:12:02 2011 +0100
+++ b/client/digitallibrary/jquery/jquery.digilib.js	Tue Feb 01 11:18:32 2011 +0100
@@ -288,6 +288,19 @@
                         params = queryParams;
                     } else {
                         params = parseImgParams($elem);
+                        if (jQuery.cookie) {
+                            // retrieve params from cookie
+                            var ck = "digilib-embed:fn:" + escape(params.fn) + ":pn:" + (params.pn || '1');
+                            var cs = jQuery.cookie(ck);
+                            console.debug("get cookie=", ck, " value=", cs);
+                            if (cs) {
+                                var cp = parseQueryString(cs);
+                                // ignore fn and pn from cookie
+                                cp.fn = params.fn;
+                                cp.pn = params.pn;
+                                params = cp;
+                            }
+                        }
                     }
                     // store $(this) element in the settings
                     elemSettings = $.extend({}, settings, params);
@@ -735,6 +748,13 @@
                 jQuery.cookie(ck, clop);
                 }
         }
+        if (settings.interactionMode !== 'fullscreen' && jQuery.cookie) {
+            // store normal parameters in cookie for embedded mode
+            var qs = getParamString(settings, settings.digilibParamNames, defaults);
+            var ck = "digilib-embed:fn:" + escape(settings.fn) + ":pn:" + settings.pn;
+            console.debug("set cookie=", ck, " value=", qs);
+            jQuery.cookie(ck, qs);
+        }
     };
 
     var retrieveOptions = function (data) {