Index: branches/unlabeled/unlabeled-1.27.2/kernel/admin_templates/incs/catalog.js =================================================================== diff -u -N -r5609 -r5613 --- branches/unlabeled/unlabeled-1.27.2/kernel/admin_templates/incs/catalog.js (.../catalog.js) (revision 5609) +++ branches/unlabeled/unlabeled-1.27.2/kernel/admin_templates/incs/catalog.js (.../catalog.js) (revision 5613) @@ -6,6 +6,8 @@ this.URLMask = $url_mask; this.Separator = '#separator#'; this.ParentCategoryID = 0; + this.OnResponceMethod = null; + this.TabShift = 1; // start from 2nd tab (index starting from 0) this.TabRegistry = new Array(); this.ActivePrefix = getCookie(this.CookiePrefix + 'active_prefix'); @@ -15,20 +17,20 @@ Catalog.prototype.Init = function () { var $prefix = this.queryTabRegistry('prefix', this.ActivePrefix, 'prefix'); - if ($prefix !== this.ActivePrefix && this.TabRegistry.length > 1) { + if ($prefix !== this.ActivePrefix && this.TabRegistry.length > this.TabShift) { // ActivePrefix not set or has non-existing prefix value - this.ActivePrefix = this.TabRegistry[1]['prefix']; + this.ActivePrefix = this.TabRegistry[this.TabShift]['prefix']; } this.SetAlternativeTabs(); this.go_to_cat(); } Catalog.prototype.SetAlternativeTabs = function () { // set alternative grids between all items (catalog is set when tab is loaded via AJAX first time) - var $i = 1; + var $i = this.TabShift; while ($i < this.TabRegistry.length) { // run through all prefixes - var $j = 1; + var $j = this.TabShift; while ($j < this.TabRegistry.length) { if (this.TabRegistry[$i]['prefix'] == this.TabRegistry[$j]['prefix']) { $j++; @@ -92,6 +94,10 @@ document.getElementById($params[0]).innerHTML = $text; } + if (typeof($object.OnResponceMethod) == 'function') { + $object.OnResponceMethod($object); + $object.OnResponceMethod = null; + } if (typeof($Debugger) != 'undefined') { $Debugger.Clear(); @@ -102,7 +108,11 @@ alert('AJAX ERROR: ' + Request.getErrorHtml($request)); } -Catalog.prototype.submit_event = function($prefix_special, $event, $t) { +Catalog.prototype.submit_event = function($prefix_special, $event, $t, $OnResponceMethod) { + if (typeof($OnResponceMethod) == 'function') { + this.OnResponceMethod = $OnResponceMethod; + } + var $prev_template = get_hidden_field('t'); if (!isset($prefix_special)) $prefix_special = this.getCurrentPrefix(); var $tab_id = this.queryTabRegistry('prefix', $prefix_special, 'tab_id'); @@ -133,12 +143,7 @@ set_hidden_field('m_cat_id', $cat_id); } - // set all item tabs counters to "?" before quering catagories - var $i = 1; - while ($i < this.TabRegistry.length) { - this.setItemCount(this.TabRegistry[$i]['prefix'], '?'); - $i++; - } + this.resetTabs(false); // query sub categories of $cat_id var $url = this.URLMask.replace('#TEMPLATE_NAME#', 'xml/categories_list').replace('#CATEGORY_ID#', $cat_id); @@ -150,8 +155,25 @@ this.switchTab(); // refresh current item tab } +// set all item tabs counters to "?" before quering catagories +Catalog.prototype.resetTabs = function($reset_content) { + var $i = this.TabShift; + while ($i < this.TabRegistry.length) { + this.setItemCount(this.TabRegistry[$i]['prefix'], '?'); + $i++; + } + + if ($reset_content) { + // set category for all tabs to -1 (forces reload next time) + $i = this.TabShift; + while ($i < this.TabRegistry.length) { + document.getElementById(this.TabRegistry[$i]['tab_id'] + '_div').setAttribute('category_id', -1); + $i++; + } + } +} -Catalog.prototype.switchTab = function($prefix) { +Catalog.prototype.switchTab = function($prefix, $force) { if (this.queryTabRegistry('prefix', this.ActivePrefix, 'prefix') != this.ActivePrefix) { // active prefix is not registred -> cookie left, but not modules installed/enabled at the moment return false; @@ -180,13 +202,13 @@ this.setViewMenu(this.ActivePrefix); setCookie(this.CookiePrefix + 'active_prefix', this.ActivePrefix); - this.refreshTab($prefix, $div_id); + this.refreshTab($prefix, $div_id, $force); } -Catalog.prototype.refreshTab = function($prefix, $div_id) { +Catalog.prototype.refreshTab = function($prefix, $div_id, $force) { 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) { + if ($cat_id != $tab_cat_id || $force) { // 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);