// Product tabs position and ajax loading order are now independent
This commit is contained in:
@@ -227,22 +227,18 @@
|
|||||||
var tabs_preloaded = new Array();
|
var tabs_preloaded = new Array();
|
||||||
|
|
||||||
$(window).bind("load", function() {
|
$(window).bind("load", function() {
|
||||||
{foreach $tabs_preloaded as $k => $tab}
|
{* Fill an array with tabs that need to be preloaded *}
|
||||||
tabs_preloaded['{$k}'] = '{$tab}';
|
var tabs_to_preload = new Array();
|
||||||
|
{foreach $tabs_preloaded as $tab_name => $value}
|
||||||
|
{* If the tab was not given a loading priority number it will not be preloaded *}
|
||||||
|
{if (is_numeric($value))}
|
||||||
|
if ($("#product-tab-content-"+'{$tab_name}').hasClass('not-loaded'))
|
||||||
|
tabs_to_preload.push('{$tab_name}');
|
||||||
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
var stack = new Array();
|
|
||||||
|
|
||||||
$('.product-tab-content').each(function(){
|
// Recursively load tabs starting with the first element of stack
|
||||||
var id = $(this).attr('id').substr(20);
|
displayTabProductById(tabs_to_preload[0], false, 0, tabs_to_preload);
|
||||||
var split_position = id.indexOf('-') + 1;
|
|
||||||
var btn_name = id.substr(split_position);
|
|
||||||
|
|
||||||
if (tabs_preloaded[btn_name])
|
|
||||||
if ($("#product-tab-content-"+id).hasClass('not-loaded'))
|
|
||||||
stack.push(id);
|
|
||||||
});
|
|
||||||
// Recursively get tabs starting with the first element of stack
|
|
||||||
displayTabProductById(stack[0], false, 0, stack);
|
|
||||||
|
|
||||||
$('.productTabs').show();
|
$('.productTabs').show();
|
||||||
$('#product_form').show();
|
$('#product_form').show();
|
||||||
|
|||||||
@@ -39,46 +39,32 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
*/
|
*/
|
||||||
protected $tab_display;
|
protected $tab_display;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The order in the array decides the order in the list of tab. If an element's value is a number, it will be preloaded.
|
||||||
|
* The tabs are preloaded from the smallest to the highest number.
|
||||||
|
* @var array Product tabs.
|
||||||
|
*/
|
||||||
protected $available_tabs = array(
|
protected $available_tabs = array(
|
||||||
'Informations',
|
'Informations' => 0,
|
||||||
'Prices',
|
'Pack' => 7,
|
||||||
'Seo',
|
'VirtualProduct' => 8,
|
||||||
'Associations',
|
'Prices' => 1,
|
||||||
'Images',
|
'Seo' => 2,
|
||||||
'Shipping',
|
'Associations' => 3,
|
||||||
'Combinations',
|
|
||||||
'Features',
|
|
||||||
'Customization',
|
|
||||||
'Attachments',
|
|
||||||
'Quantities',
|
|
||||||
'Suppliers',
|
|
||||||
'Warehouses',
|
|
||||||
'Accounting',
|
|
||||||
'Pack',
|
|
||||||
'VirtualProduct'
|
|
||||||
);
|
|
||||||
|
|
||||||
protected $available_tabs_lang = array ();
|
|
||||||
|
|
||||||
protected $tabs_preloaded = array(
|
|
||||||
'Informations' => true,
|
|
||||||
'Prices' => true,
|
|
||||||
'Seo' => true,
|
|
||||||
'Associations' => true,
|
|
||||||
'Images' => false,
|
'Images' => false,
|
||||||
'Shipping' => true,
|
'Shipping' => 4,
|
||||||
'Combinations' => true,
|
'Combinations' => 5,
|
||||||
'Features' => false,
|
'Features' => false,
|
||||||
'Customization' => false,
|
'Customization' => false,
|
||||||
'Attachments' => false,
|
'Attachments' => false,
|
||||||
'Quantities' => true,
|
'Quantities' => 6,
|
||||||
'Suppliers' => false,
|
'Suppliers' => false,
|
||||||
'Warehouses' => false,
|
'Warehouses' => false,
|
||||||
'Accounting' => false,
|
'Accounting' => false,
|
||||||
'Pack' => true,
|
|
||||||
'VirtualProduct' => true,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
protected $available_tabs_lang = array ();
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->table = 'product';
|
$this->table = 'product';
|
||||||
@@ -998,7 +984,7 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
// Set tab to display
|
// Set tab to display
|
||||||
if ($this->action)
|
if ($this->action)
|
||||||
{
|
{
|
||||||
if (in_array($this->action, $this->available_tabs))
|
if (in_array($this->action, array_keys($this->available_tabs)))
|
||||||
$this->tab_display = $this->action;
|
$this->tab_display = $this->action;
|
||||||
elseif ($this->action == 'new' || $this->action == 'save')
|
elseif ($this->action == 'new' || $this->action == 'save')
|
||||||
$this->tab_display = 'Informations';
|
$this->tab_display = 'Informations';
|
||||||
@@ -1877,7 +1863,7 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
$advanced_stock_management_active = Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT');
|
$advanced_stock_management_active = Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT');
|
||||||
$stock_management_active = Configuration::get('PS_STOCK_MANAGEMENT');
|
$stock_management_active = Configuration::get('PS_STOCK_MANAGEMENT');
|
||||||
|
|
||||||
foreach ($this->available_tabs as $product_tab)
|
foreach ($this->available_tabs as $product_tab => $value)
|
||||||
{
|
{
|
||||||
// if it's the quantities tab and stock management is disabled, continue
|
// if it's the quantities tab and stock management is disabled, continue
|
||||||
if ($stock_management_active == 0 && $product_tab == 'Quantities')
|
if ($stock_management_active == 0 && $product_tab == 'Quantities')
|
||||||
@@ -2124,8 +2110,9 @@ class AdminProductsControllerCore extends AdminController
|
|||||||
if(!method_exists($this, 'initForm'.$this->tab_display))
|
if(!method_exists($this, 'initForm'.$this->tab_display))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Used for loading each tab
|
// Sort the tabs that need to be preloaded by their priority number
|
||||||
$this->tpl_form_vars['tabs_preloaded'] = $this->tabs_preloaded;
|
asort($this->available_tabs, SORT_NUMERIC);
|
||||||
|
$this->tpl_form_vars['tabs_preloaded'] = $this->available_tabs;
|
||||||
|
|
||||||
$this->addJqueryUI('ui.datepicker');
|
$this->addJqueryUI('ui.datepicker');
|
||||||
// getLanguages init this->_languages
|
// getLanguages init this->_languages
|
||||||
|
|||||||
Reference in New Issue
Block a user