Bug 8283 - Replace usage of YUI Cookie utility with jQuery Cookie plugin
authorOwen Leonard <oleonard@myacpl.org>
Fri, 22 Jun 2012 18:12:49 +0000 (14:12 -0400)
committerPaul Poulain <paul.poulain@biblibre.com>
Fri, 13 Jul 2012 09:27:33 +0000 (11:27 +0200)
Switching from YUI Cookie utility to jQuery Cookie plugin. The
jQuery Cookie plugin is already used elsewhere in Koha, so no new
dependencies are added. The YUI Cookie files are removed.

To test, go to batch item deletion and/or batch item modification
and submit a set of barcodes. On the confirmation screen select
or deselect columns to show. Start over and submit your barcodes
again. The confirmation screen should remember which columns you
previously selected.

Signed-off-by: Chris Cormack <chris@bigballofwax.co.nz>
Signed-off-by: Paul Poulain <paul.poulain@biblibre.com>
koha-tmpl/intranet-tmpl/prog/en/js/pages/batchMod.js
koha-tmpl/intranet-tmpl/prog/en/lib/yui/cookie/cookie-debug.js [deleted file]
koha-tmpl/intranet-tmpl/prog/en/lib/yui/cookie/cookie-min.js [deleted file]
koha-tmpl/intranet-tmpl/prog/en/lib/yui/cookie/cookie.js [deleted file]
koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt

index b01552c..ed0d92f 100644 (file)
@@ -5,13 +5,12 @@
 
 
 function hideColumns(){
-  valCookie = YAHOO.util.Cookie.get("showColumns", function(stringValue){
-    return stringValue.split("/");
-  });
+  valCookie = $.cookie("showColumns");
   if(valCookie){
+    valCookie = valCookie.split("/");
     $("#showall").removeAttr("checked").parent().removeClass("selected");
     for( i=0; i<valCookie.length; i++ ){
-      if(valCookie[i] != ''){
+      if(valCookie[i] !== ''){
         index = valCookie[i] - 2;
         $("#itemst td:nth-child("+valCookie[i]+"),#itemst th:nth-child("+valCookie[i]+")").toggle();
         $("#checkheader"+index).removeAttr("checked").parent().removeClass("selected");
@@ -22,9 +21,7 @@ function hideColumns(){
 
 function hideColumn(num) {
   $("#hideall,#showall").removeAttr("checked").parent().removeClass("selected");
-  valCookie = YAHOO.util.Cookie.get("showColumns", function(stringValue){
-    return stringValue.split("/");
-  });
+  valCookie = $.cookie("showColumns");
   // set the index of the table column to hide
   $("#"+num).parent().removeClass("selected");
   var hide = Number(num.replace("checkheader","")) + 2;
@@ -32,6 +29,7 @@ function hideColumn(num) {
   $("#itemst td:nth-child("+hide+"),#itemst th:nth-child("+hide+")").toggle();
   // set or modify cookie with the hidden column's index
   if(valCookie){
+    valCookie = valCookie.split("/");
     var found = false;
     for( $i=0; $i<valCookie.length; $i++ ){
         if (hide == valCookie[i]) {
@@ -42,14 +40,10 @@ function hideColumn(num) {
     if( !found ){
         valCookie.push(hide);
         var cookieString = valCookie.join("/");
-        YAHOO.util.Cookie.set("showColumns", cookieString, {
-          expires: date
-        });
+        $.cookie("showColumns", cookieString, { expires : date });
     }
   } else {
-        YAHOO.util.Cookie.set("showColumns", hide, {
-          expires: date
-        });
+        $.cookie("showColumns", hide, { expires : date });
   }
 }
 
@@ -64,15 +58,14 @@ Array.prototype.remove = function(from, to) {
 function showColumn(num){
   $("#hideall").removeAttr("checked").parent().removeClass("selected");
   $("#"+num).parent().addClass("selected");
-  valCookie = YAHOO.util.Cookie.get("showColumns", function(stringValue){
-    return stringValue.split("/");
-  });
+  valCookie = $.cookie("showColumns");
   // set the index of the table column to hide
   show = Number(num.replace("checkheader","")) + 2;
   // hide header and cells matching the index
   $("#itemst td:nth-child("+show+"),#itemst th:nth-child("+show+")").toggle();
   // set or modify cookie with the hidden column's index
   if(valCookie){
+    valCookie = valCookie.split("/");
     var found = false;
     for( i=0; i<valCookie.length; i++ ){
         if (show == valCookie[i]) {
@@ -82,9 +75,7 @@ function showColumn(num){
     }
     if( found ){
         var cookieString = valCookie.join("/");
-        YAHOO.util.Cookie.set("showColumns", cookieString, {
-          expires: date
-        });
+        $.cookie("showColumns", cookieString, { expires : date });
     }
   }
 }
@@ -92,7 +83,7 @@ function showAllColumns(){
     $("#selections").checkCheckboxes();
     $("#selections span").addClass("selected");
     $("#itemst td:nth-child(2),#itemst tr th:nth-child(2)").nextAll().show();
-    YAHOO.util.Cookie.remove("showColumns");
+    $.cookie("showColumns",null);
     $("#hideall").removeAttr("checked").parent().removeClass("selected");
 }
 function hideAllColumns(){
@@ -101,9 +92,7 @@ function hideAllColumns(){
     $("#itemst td:nth-child(2),#itemst th:nth-child(2)").nextAll().hide();
     $("#hideall").attr("checked","checked").parent().addClass("selected");
     var cookieString = allColumns.join("/");
-    YAHOO.util.Cookie.set("showColumns", cookieString, {
-      expires: date
-    });
+    $.cookie("showColumns", cookieString, { expires : date });
 }
 
   $(document).ready(function() {
diff --git a/koha-tmpl/intranet-tmpl/prog/en/lib/yui/cookie/cookie-debug.js b/koha-tmpl/intranet-tmpl/prog/en/lib/yui/cookie/cookie-debug.js
deleted file mode 100644 (file)
index 4ec1093..0000000
+++ /dev/null
@@ -1,482 +0,0 @@
-/*
-Copyright (c) 2009, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.8.0r4
-*/
-/**
- * Utilities for cookie management
- * @namespace YAHOO.util
- * @module cookie
- */
-YAHOO.namespace("util");
-
-/**
- * Cookie utility.
- * @class Cookie
- * @static
- */
-YAHOO.util.Cookie = {
-    
-    //-------------------------------------------------------------------------
-    // Private Methods
-    //-------------------------------------------------------------------------
-    
-    /**
-     * Creates a cookie string that can be assigned into document.cookie.
-     * @param {String} name The name of the cookie.
-     * @param {String} value The value of the cookie.
-     * @param {Boolean} encodeValue True to encode the value, false to leave as-is.
-     * @param {Object} options (Optional) Options for the cookie.
-     * @return {String} The formatted cookie string.
-     * @method _createCookieString
-     * @private
-     * @static
-     */
-    _createCookieString : function (name /*:String*/, value /*:Variant*/, encodeValue /*:Boolean*/, options /*:Object*/) /*:String*/ {
-        
-        //shortcut
-        var lang = YAHOO.lang,
-            text = encodeURIComponent(name) + "=" + (encodeValue ? encodeURIComponent(value) : value);
-        
-        
-        if (lang.isObject(options)){
-            //expiration date
-            if (options.expires instanceof Date){
-                text += "; expires=" + options.expires.toUTCString();
-            }
-            
-            //path
-            if (lang.isString(options.path) && options.path !== ""){
-                text += "; path=" + options.path;
-            }
-            
-            //domain
-            if (lang.isString(options.domain) && options.domain !== ""){
-                text += "; domain=" + options.domain;
-            }
-            
-            //secure
-            if (options.secure === true){
-                text += "; secure";
-            }
-        }
-        
-        return text;
-    },
-    
-    /**
-     * Formats a cookie value for an object containing multiple values.
-     * @param {Object} hash An object of key-value pairs to create a string for.
-     * @return {String} A string suitable for use as a cookie value.
-     * @method _createCookieHashString
-     * @private
-     * @static
-     */
-    _createCookieHashString : function (hash /*:Object*/) /*:String*/ {
-        
-        //shortcuts
-        var lang = YAHOO.lang;
-        
-        if (!lang.isObject(hash)){
-            throw new TypeError("Cookie._createCookieHashString(): Argument must be an object.");
-        }
-        
-        var text /*:Array*/ = [];
-        
-        for (var key in hash){
-            if (lang.hasOwnProperty(hash, key) && !lang.isFunction(hash[key]) && !lang.isUndefined(hash[key])){
-                text.push(encodeURIComponent(key) + "=" + encodeURIComponent(String(hash[key])));
-            }
-        }
-        
-        return text.join("&");
-    },
-    
-    /**
-     * Parses a cookie hash string into an object.
-     * @param {String} text The cookie hash string to parse. The string should already be URL-decoded.
-     * @return {Object} An object containing entries for each cookie value.
-     * @method _parseCookieHash
-     * @private
-     * @static
-     */
-    _parseCookieHash : function (text /*:String*/) /*:Object*/ {
-        
-        var hashParts /*:Array*/ = text.split("&"),
-            hashPart /*:Array*/ = null,
-            hash /*:Object*/ = {};
-        
-        if (text.length > 0){
-            for (var i=0, len=hashParts.length; i < len; i++){
-                hashPart = hashParts[i].split("=");
-                hash[decodeURIComponent(hashPart[0])] = decodeURIComponent(hashPart[1]);
-            }
-        }
-        
-        return hash;
-    },
-    
-    /**
-     * Parses a cookie string into an object representing all accessible cookies.
-     * @param {String} text The cookie string to parse.
-     * @param {Boolean} decode (Optional) Indicates if the cookie values should be decoded or not. Default is true.
-     * @return {Object} An object containing entries for each accessible cookie.
-     * @method _parseCookieString
-     * @private
-     * @static
-     */
-    _parseCookieString : function (text /*:String*/, decode /*:Boolean*/) /*:Object*/ {
-        
-        var cookies /*:Object*/ = {};
-        
-        if (YAHOO.lang.isString(text) && text.length > 0) {
-            
-            var decodeValue = (decode === false ? function(s){return s;} : decodeURIComponent);
-            
-            //if (/[^=]+=[^=;]?(?:; [^=]+=[^=]?)?/.test(text)){
-                var cookieParts /*:Array*/ = text.split(/;\s/g),
-                    cookieName /*:String*/ = null,
-                    cookieValue /*:String*/ = null,
-                    cookieNameValue /*:Array*/ = null;
-                
-                for (var i=0, len=cookieParts.length; i < len; i++){
-                    
-                    //check for normally-formatted cookie (name-value)
-                    cookieNameValue = cookieParts[i].match(/([^=]+)=/i);
-                    if (cookieNameValue instanceof Array){
-                        try {
-                            cookieName = decodeURIComponent(cookieNameValue[1]);
-                            cookieValue = decodeValue(cookieParts[i].substring(cookieNameValue[1].length+1));
-                        } catch (ex){
-                            //ignore the entire cookie - encoding is likely invalid
-                        }
-                    } else {
-                        //means the cookie does not have an "=", so treat it as a boolean flag
-                        cookieName = decodeURIComponent(cookieParts[i]);
-                        cookieValue = "";
-                    }
-                    cookies[cookieName] = cookieValue;
-                }
-            //}
-        }
-        
-        return cookies;
-    },
-    
-    //-------------------------------------------------------------------------
-    // Public Methods
-    //-------------------------------------------------------------------------
-    
-    /**
-     * Determines if the cookie with the given name exists. This is useful for
-     * Boolean cookies (those that do not follow the name=value convention).
-     * @param {String} name The name of the cookie to check.
-     * @return {Boolean} True if the cookie exists, false if not.
-     * @method exists
-     * @static
-     */
-    exists: function(name) {
-
-        if (!YAHOO.lang.isString(name) || name === ""){
-            throw new TypeError("Cookie.exists(): Cookie name must be a non-empty string.");
-        }
-
-        var cookies /*:Object*/ = this._parseCookieString(document.cookie, true);
-        
-        return cookies.hasOwnProperty(name);
-    },
-    
-    /**
-     * Returns the cookie value for the given name.
-     * @param {String} name The name of the cookie to retrieve.
-     * @param {Object|Function} options (Optional) An object containing one or more
-     *      cookie options: raw (true/false) and converter (a function).
-     *      The converter function is run on the value before returning it. The
-     *      function is not used if the cookie doesn't exist. The function can be
-     *      passed instead of the options object for backwards compatibility.
-     * @return {Variant} If no converter is specified, returns a string or null if
-     *      the cookie doesn't exist. If the converter is specified, returns the value
-     *      returned from the converter or null if the cookie doesn't exist.
-     * @method get
-     * @static
-     */
-    get : function (name /*:String*/, options /*:Variant*/) /*:Variant*/{
-        
-        var lang = YAHOO.lang,
-            converter;
-        
-        if (lang.isFunction(options)) {
-            converter = options;
-            options = {};
-        } else if (lang.isObject(options)) {
-            converter = options.converter;
-        } else {
-            options = {};
-        }
-        
-        var cookies /*:Object*/ = this._parseCookieString(document.cookie, !options.raw);
-        
-        if (!lang.isString(name) || name === ""){
-            throw new TypeError("Cookie.get(): Cookie name must be a non-empty string.");
-        }
-        
-        if (lang.isUndefined(cookies[name])) {
-            return null;
-        }
-        
-        if (!lang.isFunction(converter)){
-            return cookies[name];
-        } else {
-            return converter(cookies[name]);
-        }
-    },
-    
-    /**
-     * Returns the value of a subcookie.
-     * @param {String} name The name of the cookie to retrieve.
-     * @param {String} subName The name of the subcookie to retrieve.
-     * @param {Function} converter (Optional) A function to run on the value before returning
-     *      it. The function is not used if the cookie doesn't exist.
-     * @return {Variant} If the cookie doesn't exist, null is returned. If the subcookie
-     *      doesn't exist, null if also returned. If no converter is specified and the
-     *      subcookie exists, a string is returned. If a converter is specified and the
-     *      subcookie exists, the value returned from the converter is returned.
-     * @method getSub
-     * @static
-     */
-    getSub : function (name, subName, converter) {
-        
-        var lang = YAHOO.lang,
-            hash = this.getSubs(name);
-        
-        if (hash !== null) {
-            
-            if (!lang.isString(subName) || subName === ""){
-                throw new TypeError("Cookie.getSub(): Subcookie name must be a non-empty string.");
-            }
-            
-            if (lang.isUndefined(hash[subName])){
-                return null;
-            }
-            
-            if (!lang.isFunction(converter)){
-                return hash[subName];
-            } else {
-                return converter(hash[subName]);
-            }
-        } else {
-            return null;
-        }
-    
-    },
-    
-    /**
-     * Returns an object containing name-value pairs stored in the cookie with the given name.
-     * @param {String} name The name of the cookie to retrieve.
-     * @return {Object} An object of name-value pairs if the cookie with the given name
-     *      exists, null if it does not.
-     * @method getSubs
-     * @static
-     */
-    getSubs : function (name /*:String*/) /*:Object*/ {
-    
-        var isString = YAHOO.lang.isString;
-        
-        //check cookie name
-        if (!isString(name) || name === ""){
-            throw new TypeError("Cookie.getSubs(): Cookie name must be a non-empty string.");
-        }
-        
-        var cookies = this._parseCookieString(document.cookie, false);
-        if (isString(cookies[name])){
-            return this._parseCookieHash(cookies[name]);
-        }
-        return null;
-    },
-    
-    /**
-     * Removes a cookie from the machine by setting its expiration date to
-     * sometime in the past.
-     * @param {String} name The name of the cookie to remove.
-     * @param {Object} options (Optional) An object containing one or more
-     *      cookie options: path (a string), domain (a string),
-     *      and secure (true/false). The expires option will be overwritten
-     *      by the method.
-     * @return {String} The created cookie string.
-     * @method remove
-     * @static
-     */
-    remove : function (name /*:String*/, options /*:Object*/) /*:String*/ {
-        
-        //check cookie name
-        if (!YAHOO.lang.isString(name) || name === ""){
-            throw new TypeError("Cookie.remove(): Cookie name must be a non-empty string.");
-        }
-        
-        //set options - clone options so the original isn't affected
-        options = YAHOO.lang.merge(options || {}, {
-            expires: new Date(0)
-        });
-        
-        //set cookie
-        return this.set(name, "", options);
-    },
-    
-    /**
-     * Removes a subcookie with a given name. Removing the last subcookie
-     *      won't remove the entire cookie unless options.removeIfEmpty is true.
-     * @param {String} name The name of the cookie in which the subcookie exists.
-     * @param {String} subName The name of the subcookie to remove.
-     * @param {Object} options (Optional) An object containing one or more
-     *      cookie options: path (a string), domain (a string), expires (a Date object),
-     *      removeIfEmpty (true/false), and secure (true/false). This must be the same
-     *      settings as the original subcookie.
-     * @return {String} The created cookie string.
-     * @method removeSub
-     * @static
-     */
-    removeSub : function(name /*:String*/, subName /*:String*/, options /*:Object*/) /*:String*/ {
-        
-        var lang = YAHOO.lang;
-        
-        options = options || {};
-        
-        //check cookie name
-        if (!lang.isString(name) || name === ""){
-            throw new TypeError("Cookie.removeSub(): Cookie name must be a non-empty string.");
-        }
-        
-        //check subcookie name
-        if (!lang.isString(subName) || subName === ""){
-            throw new TypeError("Cookie.removeSub(): Subcookie name must be a non-empty string.");
-        }
-        
-        //get all subcookies for this cookie
-        var subs = this.getSubs(name);
-        
-        //delete the indicated subcookie
-        if (lang.isObject(subs) && lang.hasOwnProperty(subs, subName)){
-            delete subs[subName];
-
-            if (!options.removeIfEmpty) {
-                //reset the cookie
-
-                return this.setSubs(name, subs, options);
-            } else {
-                //reset the cookie if there are subcookies left, else remove
-                for (var key in subs){
-                    if (lang.hasOwnProperty(subs, key) && !lang.isFunction(subs[key]) && !lang.isUndefined(subs[key])){
-                        return this.setSubs(name, subs, options);
-                    }
-                }
-                
-                return this.remove(name, options);
-            }
-        } else {
-            return "";
-        }
-        
-    },
-    
-    /**
-     * Sets a cookie with a given name and value.
-     * @param {String} name The name of the cookie to set.
-     * @param {Variant} value The value to set for the cookie.
-     * @param {Object} options (Optional) An object containing one or more
-     *      cookie options: path (a string), domain (a string), expires (a Date object),
-     *      raw (true/false), and secure (true/false).
-     * @return {String} The created cookie string.
-     * @method set
-     * @static
-     */
-    set : function (name /*:String*/, value /*:Variant*/, options /*:Object*/) /*:String*/ {
-        
-        var lang = YAHOO.lang;
-        
-        options = options || {};
-        
-        if (!lang.isString(name)){
-            throw new TypeError("Cookie.set(): Cookie name must be a string.");
-        }
-        
-        if (lang.isUndefined(value)){
-            throw new TypeError("Cookie.set(): Value cannot be undefined.");
-        }
-        
-        var text /*:String*/ = this._createCookieString(name, value, !options.raw, options);
-        document.cookie = text;
-        return text;
-    },
-    
-    /**
-     * Sets a sub cookie with a given name to a particular value.
-     * @param {String} name The name of the cookie to set.
-     * @param {String} subName The name of the subcookie to set.
-     * @param {Variant} value The value to set.
-     * @param {Object} options (Optional) An object containing one or more
-     *      cookie options: path (a string), domain (a string), expires (a Date object),
-     *      and secure (true/false).
-     * @return {String} The created cookie string.
-     * @method setSub
-     * @static
-     */
-    setSub : function (name /*:String*/, subName /*:String*/, value /*:Variant*/, options /*:Object*/) /*:String*/ {
-        
-        var lang = YAHOO.lang;
-        
-        if (!lang.isString(name) || name === ""){
-            throw new TypeError("Cookie.setSub(): Cookie name must be a non-empty string.");
-        }
-        
-        if (!lang.isString(subName) || subName === ""){
-            throw new TypeError("Cookie.setSub(): Subcookie name must be a non-empty string.");
-        }
-        
-        if (lang.isUndefined(value)){
-            throw new TypeError("Cookie.setSub(): Subcookie value cannot be undefined.");
-        }
-        
-        var hash /*:Object*/ = this.getSubs(name);
-        
-        if (!lang.isObject(hash)){
-            hash = {};
-        }
-        
-        hash[subName] = value;
-        
-        return this.setSubs(name, hash, options);
-        
-    },
-    
-    /**
-     * Sets a cookie with a given name to contain a hash of name-value pairs.
-     * @param {String} name The name of the cookie to set.
-     * @param {Object} value An object containing name-value pairs.
-     * @param {Object} options (Optional) An object containing one or more
-     *      cookie options: path (a string), domain (a string), expires (a Date object),
-     *      and secure (true/false).
-     * @return {String} The created cookie string.
-     * @method setSubs
-     * @static
-     */
-    setSubs : function (name /*:String*/, value /*:Object*/, options /*:Object*/) /*:String*/ {
-        
-        var lang = YAHOO.lang;
-        
-        if (!lang.isString(name)){
-            throw new TypeError("Cookie.setSubs(): Cookie name must be a string.");
-        }
-        
-        if (!lang.isObject(value)){
-            throw new TypeError("Cookie.setSubs(): Cookie value must be an object.");
-        }
-        
-        var text /*:String*/ = this._createCookieString(name, this._createCookieHashString(value), false, options);
-        document.cookie = text;
-        return text;
-    }
-
-};
-
-YAHOO.register("cookie", YAHOO.util.Cookie, {version: "2.8.0r4", build: "2449"});
diff --git a/koha-tmpl/intranet-tmpl/prog/en/lib/yui/cookie/cookie-min.js b/koha-tmpl/intranet-tmpl/prog/en/lib/yui/cookie/cookie-min.js
deleted file mode 100644 (file)
index 8846f12..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-/*
-Copyright (c) 2009, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.8.0r4
-*/
-YAHOO.namespace("util");YAHOO.util.Cookie={_createCookieString:function(B,D,C,A){var F=YAHOO.lang,E=encodeURIComponent(B)+"="+(C?encodeURIComponent(D):D);if(F.isObject(A)){if(A.expires instanceof Date){E+="; expires="+A.expires.toUTCString();}if(F.isString(A.path)&&A.path!==""){E+="; path="+A.path;}if(F.isString(A.domain)&&A.domain!==""){E+="; domain="+A.domain;}if(A.secure===true){E+="; secure";}}return E;},_createCookieHashString:function(B){var D=YAHOO.lang;if(!D.isObject(B)){throw new TypeError("Cookie._createCookieHashString(): Argument must be an object.");}var C=[];for(var A in B){if(D.hasOwnProperty(B,A)&&!D.isFunction(B[A])&&!D.isUndefined(B[A])){C.push(encodeURIComponent(A)+"="+encodeURIComponent(String(B[A])));}}return C.join("&");},_parseCookieHash:function(E){var D=E.split("&"),F=null,C={};if(E.length>0){for(var B=0,A=D.length;B<A;B++){F=D[B].split("=");C[decodeURIComponent(F[0])]=decodeURIComponent(F[1]);}}return C;},_parseCookieString:function(J,A){var K={};if(YAHOO.lang.isString(J)&&J.length>0){var B=(A===false?function(L){return L;}:decodeURIComponent);var H=J.split(/;\s/g),I=null,C=null,E=null;for(var D=0,F=H.length;D<F;D++){E=H[D].match(/([^=]+)=/i);if(E instanceof Array){try{I=decodeURIComponent(E[1]);C=B(H[D].substring(E[1].length+1));}catch(G){}}else{I=decodeURIComponent(H[D]);C="";}K[I]=C;}}return K;},exists:function(A){if(!YAHOO.lang.isString(A)||A===""){throw new TypeError("Cookie.exists(): Cookie name must be a non-empty string.");}var B=this._parseCookieString(document.cookie,true);return B.hasOwnProperty(A);},get:function(B,A){var E=YAHOO.lang,C;if(E.isFunction(A)){C=A;A={};}else{if(E.isObject(A)){C=A.converter;}else{A={};}}var D=this._parseCookieString(document.cookie,!A.raw);if(!E.isString(B)||B===""){throw new TypeError("Cookie.get(): Cookie name must be a non-empty string.");}if(E.isUndefined(D[B])){return null;}if(!E.isFunction(C)){return D[B];}else{return C(D[B]);}},getSub:function(A,C,B){var E=YAHOO.lang,D=this.getSubs(A);if(D!==null){if(!E.isString(C)||C===""){throw new TypeError("Cookie.getSub(): Subcookie name must be a non-empty string.");}if(E.isUndefined(D[C])){return null;}if(!E.isFunction(B)){return D[C];}else{return B(D[C]);}}else{return null;}},getSubs:function(B){var A=YAHOO.lang.isString;if(!A(B)||B===""){throw new TypeError("Cookie.getSubs(): Cookie name must be a non-empty string.");}var C=this._parseCookieString(document.cookie,false);if(A(C[B])){return this._parseCookieHash(C[B]);}return null;},remove:function(B,A){if(!YAHOO.lang.isString(B)||B===""){throw new TypeError("Cookie.remove(): Cookie name must be a non-empty string.");}A=YAHOO.lang.merge(A||{},{expires:new Date(0)});return this.set(B,"",A);},removeSub:function(B,E,A){var F=YAHOO.lang;A=A||{};if(!F.isString(B)||B===""){throw new TypeError("Cookie.removeSub(): Cookie name must be a non-empty string.");}if(!F.isString(E)||E===""){throw new TypeError("Cookie.removeSub(): Subcookie name must be a non-empty string.");}var D=this.getSubs(B);if(F.isObject(D)&&F.hasOwnProperty(D,E)){delete D[E];if(!A.removeIfEmpty){return this.setSubs(B,D,A);}else{for(var C in D){if(F.hasOwnProperty(D,C)&&!F.isFunction(D[C])&&!F.isUndefined(D[C])){return this.setSubs(B,D,A);}}return this.remove(B,A);}}else{return"";}},set:function(B,C,A){var E=YAHOO.lang;A=A||{};if(!E.isString(B)){throw new TypeError("Cookie.set(): Cookie name must be a string.");}if(E.isUndefined(C)){throw new TypeError("Cookie.set(): Value cannot be undefined.");}var D=this._createCookieString(B,C,!A.raw,A);document.cookie=D;return D;},setSub:function(B,D,C,A){var F=YAHOO.lang;if(!F.isString(B)||B===""){throw new TypeError("Cookie.setSub(): Cookie name must be a non-empty string.");}if(!F.isString(D)||D===""){throw new TypeError("Cookie.setSub(): Subcookie name must be a non-empty string.");}if(F.isUndefined(C)){throw new TypeError("Cookie.setSub(): Subcookie value cannot be undefined.");}var E=this.getSubs(B);if(!F.isObject(E)){E={};}E[D]=C;return this.setSubs(B,E,A);},setSubs:function(B,C,A){var E=YAHOO.lang;if(!E.isString(B)){throw new TypeError("Cookie.setSubs(): Cookie name must be a string.");}if(!E.isObject(C)){throw new TypeError("Cookie.setSubs(): Cookie value must be an object.");}var D=this._createCookieString(B,this._createCookieHashString(C),false,A);document.cookie=D;return D;}};YAHOO.register("cookie",YAHOO.util.Cookie,{version:"2.8.0r4",build:"2449"});
\ No newline at end of file
diff --git a/koha-tmpl/intranet-tmpl/prog/en/lib/yui/cookie/cookie.js b/koha-tmpl/intranet-tmpl/prog/en/lib/yui/cookie/cookie.js
deleted file mode 100644 (file)
index 4ec1093..0000000
+++ /dev/null
@@ -1,482 +0,0 @@
-/*
-Copyright (c) 2009, Yahoo! Inc. All rights reserved.
-Code licensed under the BSD License:
-http://developer.yahoo.net/yui/license.txt
-version: 2.8.0r4
-*/
-/**
- * Utilities for cookie management
- * @namespace YAHOO.util
- * @module cookie
- */
-YAHOO.namespace("util");
-
-/**
- * Cookie utility.
- * @class Cookie
- * @static
- */
-YAHOO.util.Cookie = {
-    
-    //-------------------------------------------------------------------------
-    // Private Methods
-    //-------------------------------------------------------------------------
-    
-    /**
-     * Creates a cookie string that can be assigned into document.cookie.
-     * @param {String} name The name of the cookie.
-     * @param {String} value The value of the cookie.
-     * @param {Boolean} encodeValue True to encode the value, false to leave as-is.
-     * @param {Object} options (Optional) Options for the cookie.
-     * @return {String} The formatted cookie string.
-     * @method _createCookieString
-     * @private
-     * @static
-     */
-    _createCookieString : function (name /*:String*/, value /*:Variant*/, encodeValue /*:Boolean*/, options /*:Object*/) /*:String*/ {
-        
-        //shortcut
-        var lang = YAHOO.lang,
-            text = encodeURIComponent(name) + "=" + (encodeValue ? encodeURIComponent(value) : value);
-        
-        
-        if (lang.isObject(options)){
-            //expiration date
-            if (options.expires instanceof Date){
-                text += "; expires=" + options.expires.toUTCString();
-            }
-            
-            //path
-            if (lang.isString(options.path) && options.path !== ""){
-                text += "; path=" + options.path;
-            }
-            
-            //domain
-            if (lang.isString(options.domain) && options.domain !== ""){
-                text += "; domain=" + options.domain;
-            }
-            
-            //secure
-            if (options.secure === true){
-                text += "; secure";
-            }
-        }
-        
-        return text;
-    },
-    
-    /**
-     * Formats a cookie value for an object containing multiple values.
-     * @param {Object} hash An object of key-value pairs to create a string for.
-     * @return {String} A string suitable for use as a cookie value.
-     * @method _createCookieHashString
-     * @private
-     * @static
-     */
-    _createCookieHashString : function (hash /*:Object*/) /*:String*/ {
-        
-        //shortcuts
-        var lang = YAHOO.lang;
-        
-        if (!lang.isObject(hash)){
-            throw new TypeError("Cookie._createCookieHashString(): Argument must be an object.");
-        }
-        
-        var text /*:Array*/ = [];
-        
-        for (var key in hash){
-            if (lang.hasOwnProperty(hash, key) && !lang.isFunction(hash[key]) && !lang.isUndefined(hash[key])){
-                text.push(encodeURIComponent(key) + "=" + encodeURIComponent(String(hash[key])));
-            }
-        }
-        
-        return text.join("&");
-    },
-    
-    /**
-     * Parses a cookie hash string into an object.
-     * @param {String} text The cookie hash string to parse. The string should already be URL-decoded.
-     * @return {Object} An object containing entries for each cookie value.
-     * @method _parseCookieHash
-     * @private
-     * @static
-     */
-    _parseCookieHash : function (text /*:String*/) /*:Object*/ {
-        
-        var hashParts /*:Array*/ = text.split("&"),
-            hashPart /*:Array*/ = null,
-            hash /*:Object*/ = {};
-        
-        if (text.length > 0){
-            for (var i=0, len=hashParts.length; i < len; i++){
-                hashPart = hashParts[i].split("=");
-                hash[decodeURIComponent(hashPart[0])] = decodeURIComponent(hashPart[1]);
-            }
-        }
-        
-        return hash;
-    },
-    
-    /**
-     * Parses a cookie string into an object representing all accessible cookies.
-     * @param {String} text The cookie string to parse.
-     * @param {Boolean} decode (Optional) Indicates if the cookie values should be decoded or not. Default is true.
-     * @return {Object} An object containing entries for each accessible cookie.
-     * @method _parseCookieString
-     * @private
-     * @static
-     */
-    _parseCookieString : function (text /*:String*/, decode /*:Boolean*/) /*:Object*/ {
-        
-        var cookies /*:Object*/ = {};
-        
-        if (YAHOO.lang.isString(text) && text.length > 0) {
-            
-            var decodeValue = (decode === false ? function(s){return s;} : decodeURIComponent);
-            
-            //if (/[^=]+=[^=;]?(?:; [^=]+=[^=]?)?/.test(text)){
-                var cookieParts /*:Array*/ = text.split(/;\s/g),
-                    cookieName /*:String*/ = null,
-                    cookieValue /*:String*/ = null,
-                    cookieNameValue /*:Array*/ = null;
-                
-                for (var i=0, len=cookieParts.length; i < len; i++){
-                    
-                    //check for normally-formatted cookie (name-value)
-                    cookieNameValue = cookieParts[i].match(/([^=]+)=/i);
-                    if (cookieNameValue instanceof Array){
-                        try {
-                            cookieName = decodeURIComponent(cookieNameValue[1]);
-                            cookieValue = decodeValue(cookieParts[i].substring(cookieNameValue[1].length+1));
-                        } catch (ex){
-                            //ignore the entire cookie - encoding is likely invalid
-                        }
-                    } else {
-                        //means the cookie does not have an "=", so treat it as a boolean flag
-                        cookieName = decodeURIComponent(cookieParts[i]);
-                        cookieValue = "";
-                    }
-                    cookies[cookieName] = cookieValue;
-                }
-            //}
-        }
-        
-        return cookies;
-    },
-    
-    //-------------------------------------------------------------------------
-    // Public Methods
-    //-------------------------------------------------------------------------
-    
-    /**
-     * Determines if the cookie with the given name exists. This is useful for
-     * Boolean cookies (those that do not follow the name=value convention).
-     * @param {String} name The name of the cookie to check.
-     * @return {Boolean} True if the cookie exists, false if not.
-     * @method exists
-     * @static
-     */
-    exists: function(name) {
-
-        if (!YAHOO.lang.isString(name) || name === ""){
-            throw new TypeError("Cookie.exists(): Cookie name must be a non-empty string.");
-        }
-
-        var cookies /*:Object*/ = this._parseCookieString(document.cookie, true);
-        
-        return cookies.hasOwnProperty(name);
-    },
-    
-    /**
-     * Returns the cookie value for the given name.
-     * @param {String} name The name of the cookie to retrieve.
-     * @param {Object|Function} options (Optional) An object containing one or more
-     *      cookie options: raw (true/false) and converter (a function).
-     *      The converter function is run on the value before returning it. The
-     *      function is not used if the cookie doesn't exist. The function can be
-     *      passed instead of the options object for backwards compatibility.
-     * @return {Variant} If no converter is specified, returns a string or null if
-     *      the cookie doesn't exist. If the converter is specified, returns the value
-     *      returned from the converter or null if the cookie doesn't exist.
-     * @method get
-     * @static
-     */
-    get : function (name /*:String*/, options /*:Variant*/) /*:Variant*/{
-        
-        var lang = YAHOO.lang,
-            converter;
-        
-        if (lang.isFunction(options)) {
-            converter = options;
-            options = {};
-        } else if (lang.isObject(options)) {
-            converter = options.converter;
-        } else {
-            options = {};
-        }
-        
-        var cookies /*:Object*/ = this._parseCookieString(document.cookie, !options.raw);
-        
-        if (!lang.isString(name) || name === ""){
-            throw new TypeError("Cookie.get(): Cookie name must be a non-empty string.");
-        }
-        
-        if (lang.isUndefined(cookies[name])) {
-            return null;
-        }
-        
-        if (!lang.isFunction(converter)){
-            return cookies[name];
-        } else {
-            return converter(cookies[name]);
-        }
-    },
-    
-    /**
-     * Returns the value of a subcookie.
-     * @param {String} name The name of the cookie to retrieve.
-     * @param {String} subName The name of the subcookie to retrieve.
-     * @param {Function} converter (Optional) A function to run on the value before returning
-     *      it. The function is not used if the cookie doesn't exist.
-     * @return {Variant} If the cookie doesn't exist, null is returned. If the subcookie
-     *      doesn't exist, null if also returned. If no converter is specified and the
-     *      subcookie exists, a string is returned. If a converter is specified and the
-     *      subcookie exists, the value returned from the converter is returned.
-     * @method getSub
-     * @static
-     */
-    getSub : function (name, subName, converter) {
-        
-        var lang = YAHOO.lang,
-            hash = this.getSubs(name);
-        
-        if (hash !== null) {
-            
-            if (!lang.isString(subName) || subName === ""){
-                throw new TypeError("Cookie.getSub(): Subcookie name must be a non-empty string.");
-            }
-            
-            if (lang.isUndefined(hash[subName])){
-                return null;
-            }
-            
-            if (!lang.isFunction(converter)){
-                return hash[subName];
-            } else {
-                return converter(hash[subName]);
-            }
-        } else {
-            return null;
-        }
-    
-    },
-    
-    /**
-     * Returns an object containing name-value pairs stored in the cookie with the given name.
-     * @param {String} name The name of the cookie to retrieve.
-     * @return {Object} An object of name-value pairs if the cookie with the given name
-     *      exists, null if it does not.
-     * @method getSubs
-     * @static
-     */
-    getSubs : function (name /*:String*/) /*:Object*/ {
-    
-        var isString = YAHOO.lang.isString;
-        
-        //check cookie name
-        if (!isString(name) || name === ""){
-            throw new TypeError("Cookie.getSubs(): Cookie name must be a non-empty string.");
-        }
-        
-        var cookies = this._parseCookieString(document.cookie, false);
-        if (isString(cookies[name])){
-            return this._parseCookieHash(cookies[name]);
-        }
-        return null;
-    },
-    
-    /**
-     * Removes a cookie from the machine by setting its expiration date to
-     * sometime in the past.
-     * @param {String} name The name of the cookie to remove.
-     * @param {Object} options (Optional) An object containing one or more
-     *      cookie options: path (a string), domain (a string),
-     *      and secure (true/false). The expires option will be overwritten
-     *      by the method.
-     * @return {String} The created cookie string.
-     * @method remove
-     * @static
-     */
-    remove : function (name /*:String*/, options /*:Object*/) /*:String*/ {
-        
-        //check cookie name
-        if (!YAHOO.lang.isString(name) || name === ""){
-            throw new TypeError("Cookie.remove(): Cookie name must be a non-empty string.");
-        }
-        
-        //set options - clone options so the original isn't affected
-        options = YAHOO.lang.merge(options || {}, {
-            expires: new Date(0)
-        });
-        
-        //set cookie
-        return this.set(name, "", options);
-    },
-    
-    /**
-     * Removes a subcookie with a given name. Removing the last subcookie
-     *      won't remove the entire cookie unless options.removeIfEmpty is true.
-     * @param {String} name The name of the cookie in which the subcookie exists.
-     * @param {String} subName The name of the subcookie to remove.
-     * @param {Object} options (Optional) An object containing one or more
-     *      cookie options: path (a string), domain (a string), expires (a Date object),
-     *      removeIfEmpty (true/false), and secure (true/false). This must be the same
-     *      settings as the original subcookie.
-     * @return {String} The created cookie string.
-     * @method removeSub
-     * @static
-     */
-    removeSub : function(name /*:String*/, subName /*:String*/, options /*:Object*/) /*:String*/ {
-        
-        var lang = YAHOO.lang;
-        
-        options = options || {};
-        
-        //check cookie name
-        if (!lang.isString(name) || name === ""){
-            throw new TypeError("Cookie.removeSub(): Cookie name must be a non-empty string.");
-        }
-        
-        //check subcookie name
-        if (!lang.isString(subName) || subName === ""){
-            throw new TypeError("Cookie.removeSub(): Subcookie name must be a non-empty string.");
-        }
-        
-        //get all subcookies for this cookie
-        var subs = this.getSubs(name);
-        
-        //delete the indicated subcookie
-        if (lang.isObject(subs) && lang.hasOwnProperty(subs, subName)){
-            delete subs[subName];
-
-            if (!options.removeIfEmpty) {
-                //reset the cookie
-
-                return this.setSubs(name, subs, options);
-            } else {
-                //reset the cookie if there are subcookies left, else remove
-                for (var key in subs){
-                    if (lang.hasOwnProperty(subs, key) && !lang.isFunction(subs[key]) && !lang.isUndefined(subs[key])){
-                        return this.setSubs(name, subs, options);
-                    }
-                }
-                
-                return this.remove(name, options);
-            }
-        } else {
-            return "";
-        }
-        
-    },
-    
-    /**
-     * Sets a cookie with a given name and value.
-     * @param {String} name The name of the cookie to set.
-     * @param {Variant} value The value to set for the cookie.
-     * @param {Object} options (Optional) An object containing one or more
-     *      cookie options: path (a string), domain (a string), expires (a Date object),
-     *      raw (true/false), and secure (true/false).
-     * @return {String} The created cookie string.
-     * @method set
-     * @static
-     */
-    set : function (name /*:String*/, value /*:Variant*/, options /*:Object*/) /*:String*/ {
-        
-        var lang = YAHOO.lang;
-        
-        options = options || {};
-        
-        if (!lang.isString(name)){
-            throw new TypeError("Cookie.set(): Cookie name must be a string.");
-        }
-        
-        if (lang.isUndefined(value)){
-            throw new TypeError("Cookie.set(): Value cannot be undefined.");
-        }
-        
-        var text /*:String*/ = this._createCookieString(name, value, !options.raw, options);
-        document.cookie = text;
-        return text;
-    },
-    
-    /**
-     * Sets a sub cookie with a given name to a particular value.
-     * @param {String} name The name of the cookie to set.
-     * @param {String} subName The name of the subcookie to set.
-     * @param {Variant} value The value to set.
-     * @param {Object} options (Optional) An object containing one or more
-     *      cookie options: path (a string), domain (a string), expires (a Date object),
-     *      and secure (true/false).
-     * @return {String} The created cookie string.
-     * @method setSub
-     * @static
-     */
-    setSub : function (name /*:String*/, subName /*:String*/, value /*:Variant*/, options /*:Object*/) /*:String*/ {
-        
-        var lang = YAHOO.lang;
-        
-        if (!lang.isString(name) || name === ""){
-            throw new TypeError("Cookie.setSub(): Cookie name must be a non-empty string.");
-        }
-        
-        if (!lang.isString(subName) || subName === ""){
-            throw new TypeError("Cookie.setSub(): Subcookie name must be a non-empty string.");
-        }
-        
-        if (lang.isUndefined(value)){
-            throw new TypeError("Cookie.setSub(): Subcookie value cannot be undefined.");
-        }
-        
-        var hash /*:Object*/ = this.getSubs(name);
-        
-        if (!lang.isObject(hash)){
-            hash = {};
-        }
-        
-        hash[subName] = value;
-        
-        return this.setSubs(name, hash, options);
-        
-    },
-    
-    /**
-     * Sets a cookie with a given name to contain a hash of name-value pairs.
-     * @param {String} name The name of the cookie to set.
-     * @param {Object} value An object containing name-value pairs.
-     * @param {Object} options (Optional) An object containing one or more
-     *      cookie options: path (a string), domain (a string), expires (a Date object),
-     *      and secure (true/false).
-     * @return {String} The created cookie string.
-     * @method setSubs
-     * @static
-     */
-    setSubs : function (name /*:String*/, value /*:Object*/, options /*:Object*/) /*:String*/ {
-        
-        var lang = YAHOO.lang;
-        
-        if (!lang.isString(name)){
-            throw new TypeError("Cookie.setSubs(): Cookie name must be a string.");
-        }
-        
-        if (!lang.isObject(value)){
-            throw new TypeError("Cookie.setSubs(): Cookie value must be an object.");
-        }
-        
-        var text /*:String*/ = this._createCookieString(name, this._createCookieHashString(value), false, options);
-        document.cookie = text;
-        return text;
-    }
-
-};
-
-YAHOO.register("cookie", YAHOO.util.Cookie, {version: "2.8.0r4", build: "2449"});
index b88401c..3d511ea 100644 (file)
@@ -4,7 +4,6 @@
 <script type="text/javascript" src="[% themelang %]/js/background-job-progressbar.js"></script>
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/pages/batchMod.css" />
 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
-<script src="[% themelang %]/lib/yui/cookie/cookie-min.js"></script>
 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
 <script type="text/javascript">
 //<![CDATA[
@@ -12,7 +11,6 @@
 // Prepare array of all column headers, incrementing each index by
 // two to accomodate control and title columns
 var allColumns = new Array([% FOREACH item_header_loo IN item_header_loop %]'[% loop.count %]'[% UNLESS ( loop.last ) %],[% END %][% END %]);
-console.log(allColumns);
 for( x=0; x<allColumns.length; x++ ){
   allColumns[x] = Number(allColumns[x]) + 2;
 }
index e64776a..4c7198e 100644 (file)
@@ -4,7 +4,6 @@
 <script type="text/javascript" src="[% themelang %]/js/background-job-progressbar.js"></script>
 <link rel="stylesheet" type="text/css" href="[% themelang %]/css/pages/batchMod.css" />
 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.tablesorter.min.js"></script>
-<script src="[% themelang %]/lib/yui/cookie/cookie-min.js"></script>
 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
 <script type="text/javascript">
 //<![CDATA[
@@ -12,7 +11,6 @@
 // Prepare array of all column headers, incrementing each index by
 // two to accomodate control and title columns
 var allColumns = new Array([% FOREACH item_header_loo IN item_header_loop %]'[% loop.count %]'[% UNLESS ( loop.last ) %],[% END %][% END %]);
-console.log(allColumns);
 for( x=0; x<allColumns.length; x++ ){
   allColumns[x] = Number(allColumns[x]) + 2;
 }