Skip to content

Commit

Permalink
[related #6080] Fix startOffset issue when useCookie is true (#6902)
Browse files Browse the repository at this point in the history
* [related #6080] Fix startOffset issue when useCookie is true

* [cs] Improved condition by optimizing code - set useCookie as default
  • Loading branch information
gunjanpatel authored and Kubik-Rubik committed May 7, 2016
1 parent a7081c4 commit c3569e0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion libraries/cms/html/tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ 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";

// When use storage is set and value is false - By default we allow to use storage
$opt['useStorage'] = (isset($params['useCookie']) && !$params['useCookie']) ? false : 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 c3569e0

Please sign in to comment.