From e5624fb883b4cb7e6a83c56558cd9a56a4a50cff Mon Sep 17 00:00:00 2001 From: tDidierjean Date: Tue, 3 Apr 2012 09:34:56 +0000 Subject: [PATCH] [*] BO : #PI-107 refactoring product page JS - adding ProductTabsManager --- .../controllers/products/attachments.tpl | 36 - .../controllers/products/combinations.tpl | 10 +- .../controllers/products/features.tpl | 7 - .../products/helpers/form/form.tpl | 25 +- .../controllers/products/informations.tpl | 61 +- .../template/controllers/products/pack.tpl | 132 +-- controllers/admin/AdminProductsController.php | 2 +- js/admin-product-tab.js | 112 --- js/admin-products.js | 849 ++++++++++++------ js/productTabsManager.js | 122 +++ 10 files changed, 708 insertions(+), 648 deletions(-) delete mode 100644 js/admin-product-tab.js create mode 100644 js/productTabsManager.js diff --git a/admin-dev/themes/default/template/controllers/products/attachments.tpl b/admin-dev/themes/default/template/controllers/products/attachments.tpl index fe4293513..4554d7e97 100644 --- a/admin-dev/themes/default/template/controllers/products/attachments.tpl +++ b/admin-dev/themes/default/template/controllers/products/attachments.tpl @@ -90,40 +90,4 @@
 
- - - {/if} diff --git a/admin-dev/themes/default/template/controllers/products/combinations.tpl b/admin-dev/themes/default/template/controllers/products/combinations.tpl index bcacc8acf..57665673b 100644 --- a/admin-dev/themes/default/template/controllers/products/combinations.tpl +++ b/admin-dev/themes/default/template/controllers/products/combinations.tpl @@ -25,15 +25,15 @@ *} diff --git a/admin-dev/themes/default/template/controllers/products/features.tpl b/admin-dev/themes/default/template/controllers/products/features.tpl index c1475184c..445a8cbe1 100644 --- a/admin-dev/themes/default/template/controllers/products/features.tpl +++ b/admin-dev/themes/default/template/controllers/products/features.tpl @@ -98,11 +98,4 @@ new_features {l s='Add a new feature'} - - - {/if} diff --git a/admin-dev/themes/default/template/controllers/products/helpers/form/form.tpl b/admin-dev/themes/default/template/controllers/products/helpers/form/form.tpl index 2f292bf6d..aec18cf70 100644 --- a/admin-dev/themes/default/template/controllers/products/helpers/form/form.tpl +++ b/admin-dev/themes/default/template/controllers/products/helpers/form/form.tpl @@ -28,7 +28,7 @@ {block name="autoload_tinyMCE"} // Execute when tab Informations has finished loading - new ProductTab('Informations').onDisplay(function(){ + tabs_manager.onLoad('Informations', function(){ // change each by click to load only on click $(".autoload_rte").each(function(e){ tinySetup({ @@ -93,17 +93,22 @@ var post_data = {$post_data}; var product_type; + {*var is_pack = {$is_pack}; + var is_virtual = {$product->is_virtual}; + var mce_maximum = '{l s='Maximum'}'; + var mce_characters = '{l s='characters'}';*} + $(document).ready(function() { product_type = $("input[name=type_product]:checked").val(); $('#product-tab-content-wait').show(); {if $is_pack} - new ProductTab('Informations').onDisplay(function(){ + tabs_manager.onLoad('Informations', function(){ $('#pack_product').attr('checked', 'checked'); }); $('li.tab-row a[id*="VirtualProduct"]').hide(); {elseif $product->is_virtual} - new ProductTab('Informations').onDisplay(function(){ + tabs_manager.onLoad('Informations', function(){ $('#virtual_product').attr('checked', 'checked'); $('#condition').attr('disabled', 'disabled'); $('#condition option[value=new]').attr('selected', 'selected'); @@ -111,7 +116,7 @@ $('li.tab-row a[id*="Pack"]').hide(); $('li.tab-row a[id*="Shipping"]').hide(); {else} - new ProductTab('Informations').onDisplay(function(){ + tabs_manager.onLoad('Informations', function(){ $('#simple_product').attr('checked', 'checked'); }); $('li.tab-row a[id*="Pack"]').hide(); @@ -159,20 +164,20 @@ { $('li.tab-row a[id*="VirtualProduct"]').show().click(); - new ProductTab('VirtualProduct').onDisplay(function(){ + tabs_manager.onLoad('VirtualProduct', function(){ $('#is_virtual_good').attr('checked', true); $('#virtual_good').show(); $('#is_virtual').val(1); $("#virtual_good_attributes").show(); }); - new ProductTab('Quantities').onDisplay(function(){ + tabs_manager.onLoad('Quantities', function(){ $('.stockForVirtualProduct').hide(); }); $('li.tab-row a[id*="Shipping"]').hide(); - new ProductTab('Informations').onDisplay(function(){ + tabs_manager.onLoad('Informations', function(){ $('#condition').attr('disabled', 'disabled'); $('#condition option[value=refurbished]').removeAttr('selected'); $('#condition option[value=used]').removeAttr('selected'); @@ -215,7 +220,7 @@ } if ($("#product-tab-content-"+id).hasClass('not-loaded') && !$("#product-tab-content-"+id).hasClass('loading')) - ProductTab.display(id, true, 0, null); + tabs_manager.display(id, true, 0, null); else { $("#product-tab-content-"+id).show(0, function(){ @@ -249,7 +254,7 @@ if ($('#product-tab-content-Associations').hasClass('not-loaded')) disableSave(); - new ProductTab('Associations').onDisplay(function(){ + tabs_manager.onLoad('Associations', function(){ handleSaveButtons(); }); @@ -275,7 +280,7 @@ {/foreach} // Recursively load tabs starting with the first element of stack - ProductTab.display(tabs_to_preload[0], false, 0, tabs_to_preload); + tabs_manager.display(tabs_to_preload[0], false, 0, tabs_to_preload); $('.productTabs').show(); $('#product_form').show(); diff --git a/admin-dev/themes/default/template/controllers/products/informations.tpl b/admin-dev/themes/default/template/controllers/products/informations.tpl index 967d9fa35..6324ecf0c 100644 --- a/admin-dev/themes/default/template/controllers/products/informations.tpl +++ b/admin-dev/themes/default/template/controllers/products/informations.tpl @@ -115,31 +115,17 @@