Skip to content

Commit

Permalink
[related #6080] Fix startOffset issue when useCookie is true
Browse files Browse the repository at this point in the history
  • Loading branch information
Gunjan Patel committed Sep 4, 2015
1 parent 8c5855b commit e8cccbc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion libraries/cms/html/tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,19 @@ protected static function loadBehavior($group, $params = array())
$opt['onActive'] = (isset($params['onActive'])) ? '\\' . $params['onActive'] : null;
$opt['onBackground'] = (isset($params['onBackground'])) ? '\\' . $params['onBackground'] : null;
$opt['display'] = (isset($params['startOffset'])) ? (int) $params['startOffset'] : null;
$opt['useStorage'] = (isset($params['useCookie']) && $params['useCookie']) ? true : false;
$opt['titleSelector'] = "dt.tabs";
$opt['descriptionSelector'] = "dd.tabs";

// Initialize value
$opt['useStorage'] = false;

// By default useCookie(this.options.display) is true
if (!isset($params['useCookie'])
|| (isset($params['useCookie']) && $params['useCookie']))
{
$opt['useStorage'] = true;
}

$options = JHtml::getJSObject($opt);

$js = ' window.addEvent(\'domready\', function(){
Expand Down
4 changes: 2 additions & 2 deletions media/system/js/tabs.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ var JTabs = new Class({

if (this.options.useStorage) {
if (Browser.Features.localstorage) {
this.options.display = localStorage[this.storageName];
this.options.display = this.options.display || localStorage[this.storageName];
} else {
this.options.display = Cookie.read(this.storageName);
this.options.display = this.options.display || Cookie.read(this.storageName);
}
}
if (this.options.display === null || this.options.display === undefined) {
Expand Down

0 comments on commit e8cccbc

Please sign in to comment.