Index: trunk/kernel/admin_templates/incs/catalog.js =================================================================== diff -u -r5002 -r5005 --- trunk/kernel/admin_templates/incs/catalog.js (.../catalog.js) (revision 5002) +++ trunk/kernel/admin_templates/incs/catalog.js (.../catalog.js) (revision 5005) @@ -75,31 +75,30 @@ Catalog.prototype.switchTab = function($prefix) { - alert('switch tab called ['+$prefix+'/'+this.ActivePrefix+']'); if (!isset($prefix)) $prefix = this.ActivePrefix; - - var $cat_id = get_hidden_field('m_cat_id'); - var $div_id = this.queryTabRegistry('prefix', $prefix, 'tab_id') + '_div'; - var $tab_cat_id = document.getElementById($div_id).getAttribute('category_id'); - if ((this.ActivePrefix == $prefix && $cat_id == $tab_cat_id) || (this.TabRegistry.length == 1)) { - // clicked on current tab + same category || no item tabs = do nothing - alert('problems in switchtab, prefix: '+$prefix+'; cat_id: '+$cat_id+'; tab_cat_id:'+$tab_cat_id); - return true; - } - - // switch tab - if (this.ActivePrefix) { + if (this.ActivePrefix != $prefix) { + // hide source tab document.getElementById(this.ActivePrefix + '_tab').className = 'catalog-tab-unselected'; + document.getElementById(this.queryTabRegistry('prefix', this.ActivePrefix, 'tab_id') + '_div').style.display = 'none'; } + + // show destination tab this.ActivePrefix = $prefix; document.getElementById(this.ActivePrefix + '_tab').className = 'catalog-tab-selected'; - - // query tab content - var $url = this.URLMask.replace('#TEMPLATE_NAME#', this.queryTabRegistry('prefix', $prefix, 'module_path') + '/catalog_tab'); - $url = $url.replace('#CATEGORY_ID#', $cat_id); - - Request.makeRequest($url, this.BusyRequest, $div_id, this.successCallback, this.errorCallback, $div_id); + var $div_id = this.queryTabRegistry('prefix', $prefix, 'tab_id') + '_div'; // destination tab + document.getElementById($div_id).style.display = 'block'; + + // this.TabRegistry.length == 1 + var $cat_id = get_hidden_field('m_cat_id'); + var $tab_cat_id = document.getElementById($div_id).getAttribute('category_id'); + if ($cat_id != $tab_cat_id) { + // query tab content only in case if not queried or category don't match + var $url = this.URLMask.replace('#TEMPLATE_NAME#', this.queryTabRegistry('prefix', $prefix, 'module_path') + '/catalog_tab'); + $url = $url.replace('#CATEGORY_ID#', $cat_id); + + Request.makeRequest($url, this.BusyRequest, $div_id, this.successCallback, this.errorCallback, $div_id); + } } // adds information about tab to tab_registry @@ -111,6 +110,7 @@ this.TabRegistry[$index]['prefix'] = $tab.getAttribute('prefix'); this.TabRegistry[$index]['module_path'] = $tab.getAttribute('edit_template').substring(0, $tab.getAttribute('edit_template').indexOf('/')); this.TabRegistry[$index]['edit_template'] = $tab.getAttribute('edit_template'); + this.TabRegistry[$index]['index'] = $index; } // allows to get any information about tab @@ -124,4 +124,24 @@ $i++; } return false; +} + +Catalog.prototype.HideTab = function($prefix) { + + var $tab = document.getElementById($prefix + '_tab_container'); + if ($tab) { + $tab.style.display = 'none'; + var $index = this.queryTabRegistry('prefix', $prefix, 'index'); // index of hidden tab + if ($index + 1 < this.TabRegistry.length) { + // some tabs exists after hidden tab + this.ShowTab(this.queryTabRegistry('index', $index + 1, 'prefix')); + } + } +} + +Catalog.prototype.ShowTab = function($prefix) { + var $tab = document.getElementById($prefix + '_tab_container'); + if ($tab) { + $tab.style.display = 'block'; + } } \ No newline at end of file