From 0429532ad10b0708e085c4830bb930d8457d62f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Scott=20Gonz=C3=A1lez?= Date: Thu, 25 Oct 2012 05:36:24 -0400 Subject: [PATCH] Tabs: Removed cookie option. Fixes #7162 - Tabs: Remove cookie option. --- external/jquery.cookie.js | 89 ----------------------- tests/unit/tabs/tabs_common_deprecated.js | 1 - tests/unit/tabs/tabs_deprecated.html | 1 - tests/unit/tabs/tabs_deprecated.js | 35 --------- ui/jquery.ui.tabs.js | 52 ------------- 5 files changed, 178 deletions(-) delete mode 100644 external/jquery.cookie.js diff --git a/external/jquery.cookie.js b/external/jquery.cookie.js deleted file mode 100644 index 7b3e70125..000000000 --- a/external/jquery.cookie.js +++ /dev/null @@ -1,89 +0,0 @@ -/*jslint browser: true */ /*global jQuery: true */ - -/** - * jQuery Cookie plugin - * - * Copyright (c) 2010 Klaus Hartl (stilbuero.de) - * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - * - */ - -// TODO JsDoc - -/** - * Create a cookie with the given key and value and other optional parameters. - * - * @example $.cookie('the_cookie', 'the_value'); - * @desc Set the value of a cookie. - * @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true }); - * @desc Create a cookie with all available options. - * @example $.cookie('the_cookie', 'the_value'); - * @desc Create a session cookie. - * @example $.cookie('the_cookie', null); - * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain - * used when the cookie was set. - * - * @param String key The key of the cookie. - * @param String value The value of the cookie. - * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. - * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. - * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. - * If set to null or omitted, the cookie will be a session cookie and will not be retained - * when the the browser exits. - * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). - * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). - * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will - * require a secure protocol (like HTTPS). - * @type undefined - * - * @name $.cookie - * @cat Plugins/Cookie - * @author Klaus Hartl/klaus.hartl@stilbuero.de - */ - -/** - * Get the value of a cookie with the given key. - * - * @example $.cookie('the_cookie'); - * @desc Get the value of a cookie. - * - * @param String key The key of the cookie. - * @return The value of the cookie. - * @type String - * - * @name $.cookie - * @cat Plugins/Cookie - * @author Klaus Hartl/klaus.hartl@stilbuero.de - */ -jQuery.cookie = function (key, value, options) { - - // key and value given, set cookie... - if (arguments.length > 1 && (value === null || typeof value !== "object")) { - options = jQuery.extend({}, options); - - if (value === null) { - options.expires = -1; - } - - if (typeof options.expires === 'number') { - var days = options.expires, t = options.expires = new Date(); - t.setDate(t.getDate() + days); - } - - return (document.cookie = [ - encodeURIComponent(key), '=', - options.raw ? String(value) : encodeURIComponent(String(value)), - options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE - options.path ? '; path=' + options.path : '', - options.domain ? '; domain=' + options.domain : '', - options.secure ? '; secure' : '' - ].join('')); - } - - // key and possibly options given, get cookie... - options = value || {}; - var result, decode = options.raw ? function (s) { return s; } : decodeURIComponent; - return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? decode(result[1]) : null; -}; diff --git a/tests/unit/tabs/tabs_common_deprecated.js b/tests/unit/tabs/tabs_common_deprecated.js index 8caff1ac5..72fecfbdd 100644 --- a/tests/unit/tabs/tabs_common_deprecated.js +++ b/tests/unit/tabs/tabs_common_deprecated.js @@ -2,7 +2,6 @@ TestHelpers.commonWidgetTests( "tabs", { defaults: { active: null, collapsible: false, - cookie: null, disabled: false, event: "click", heightStyle: "content", diff --git a/tests/unit/tabs/tabs_deprecated.html b/tests/unit/tabs/tabs_deprecated.html index 9d3ecef3a..3c476d0b4 100644 --- a/tests/unit/tabs/tabs_deprecated.html +++ b/tests/unit/tabs/tabs_deprecated.html @@ -5,7 +5,6 @@ jQuery UI Tabs Test Suite - diff --git a/tests/unit/tabs/tabs_deprecated.js b/tests/unit/tabs/tabs_deprecated.js index 49ad5c13e..b93417375 100644 --- a/tests/unit/tabs/tabs_deprecated.js +++ b/tests/unit/tabs/tabs_deprecated.js @@ -66,41 +66,6 @@ test( "tabTemplate + panelTemplate", function() { ok( element.find( "#new" ).hasClass( "customPanel" ), "panel custom class" ); }); -test( "cookie", function() { - expect( 6 ); - - var element = $( "#tabs1" ), - cookieName = "tabs_test", - cookieObj = { name: cookieName }; - $.cookie( cookieName, null ); - function cookie() { - return parseInt( $.cookie( cookieName ), 10 ); - } - - element.tabs({ cookie: cookieObj }); - equal( cookie(), 0, "initial cookie value" ); - - element.tabs( "destroy" ); - element.tabs({ active: 1, cookie: cookieObj }); - equal( cookie(), 1, "initial cookie value, from active property" ); - - element.tabs( "option", "active", 2 ); - equal( cookie(), 2, "cookie value updated after activating" ); - - element.tabs( "destroy" ); - $.cookie( cookieName, 1 ); - element.tabs({ cookie: cookieObj }); - equal( cookie(), 1, "initial cookie value, from existing cookie" ); - - element.tabs( "destroy" ); - element.tabs({ cookie: cookieObj, collapsible: true }); - element.tabs( "option", "active", false ); - equal( cookie(), -1, "cookie value for all tabs unselected" ); - - element.tabs( "destroy" ); - ok( $.cookie( cookieName ) === null, "erase cookie after destroy" ); -}); - asyncTest( "spinner", function() { expect( 2 ); diff --git a/ui/jquery.ui.tabs.js b/ui/jquery.ui.tabs.js index 28786e5ce..76216bfc9 100644 --- a/ui/jquery.ui.tabs.js +++ b/ui/jquery.ui.tabs.js @@ -1144,58 +1144,6 @@ if ( $.uiBackCompat !== false ) { } }); - // cookie option - (function() { - - var listId = 0; - - $.widget( "ui.tabs", $.ui.tabs, { - options: { - cookie: null // e.g. { expires: 7, path: '/', domain: 'jquery.com', secure: true } - }, - _create: function() { - var options = this.options, - active; - if ( options.active == null && options.cookie ) { - active = parseInt( this._cookie(), 10 ); - if ( active === -1 ) { - active = false; - } - options.active = active; - } - this._super(); - }, - _cookie: function( active ) { - var cookie = [ this.cookie || - ( this.cookie = this.options.cookie.name || "ui-tabs-" + (++listId) ) ]; - if ( arguments.length ) { - cookie.push( active === false ? -1 : active ); - cookie.push( this.options.cookie ); - } - return $.cookie.apply( null, cookie ); - }, - _refresh: function() { - this._super(); - if ( this.options.cookie ) { - this._cookie( this.options.active, this.options.cookie ); - } - }, - _eventHandler: function() { - this._superApply( arguments ); - if ( this.options.cookie ) { - this._cookie( this.options.active, this.options.cookie ); - } - }, - _destroy: function() { - this._super(); - if ( this.options.cookie ) { - this._cookie( null, this.options.cookie ); - } - } - }); - - })(); - // load event $.widget( "ui.tabs", $.ui.tabs, { _trigger: function( type, event, data ) {