From df60a82b0b402bd24df92a764e1c3cad8f7ecec8 Mon Sep 17 00:00:00 2001 From: lLefevre Date: Tue, 13 Dec 2011 15:31:17 +0000 Subject: [PATCH] // adding counter for short description and adding size of image files in AdminProductsController --- admin-dev/themes/template/products/form.tpl | 36 +++++++++++++++++++ admin-dev/themes/template/products/images.tpl | 2 +- .../themes/template/products/informations.tpl | 3 +- .../template/products/textarea_lang.tpl | 5 +-- controllers/admin/AdminProductsController.php | 2 +- js/admin.js | 19 ++++++++++ 6 files changed, 62 insertions(+), 5 deletions(-) diff --git a/admin-dev/themes/template/products/form.tpl b/admin-dev/themes/template/products/form.tpl index 9cb84995a..b4b24e265 100644 --- a/admin-dev/themes/template/products/form.tpl +++ b/admin-dev/themes/template/products/form.tpl @@ -26,6 +26,42 @@ {extends file="helper/form/form.tpl"} +{block name="autoload_tinyMCE"} + // change each by click to load only on click + $(".autoload_rte").each(function(e){ + tinySetup({ + mode :"exact", + editor_selector :"autoload_rte", + elements : $(this).attr("id"), + theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull|cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,undo,redo", + theme_advanced_buttons2 : "link,unlink,anchor,image,cleanup,code,|,forecolor,backcolor,|,hr,removeformat,visualaid,|,charmap,media,|,ltr,rtl,|,fullscreen", + theme_advanced_buttons3 : "", + theme_advanced_buttons4 : "", + setup : function(ed) { + + {* Count the total number of the field *} + + ed.onKeyUp.add(function(ed, e) { + tinyMCE.triggerSave(); + textarea = $('#'+ed.id); + max = textarea.parent('div').find('span.counter').attr('max'); + if (max != 'none') + { + textarea_value = textarea.val(); + count = stripHTML(textarea_value).length; + rest = max - count; + if (rest < 0) + textarea.parent('div').find('span.counter').html('{l s="Maximum"} '+max+' {l s=' characters'} : '+rest+''); + else + textarea.parent('div').find('span.counter').html(' '); + } + }); + + } + }); + }) +{/block} + {block name="defaultForm"}
diff --git a/admin-dev/themes/template/products/images.tpl b/admin-dev/themes/template/products/images.tpl index ebaf3cc10..f256f0c6b 100644 --- a/admin-dev/themes/template/products/images.tpl +++ b/admin-dev/themes/template/products/images.tpl @@ -40,7 +40,7 @@

- {l s='Format:'} JPG, GIF, PNG. {l s='Filesize:'} {$max_image_size / 1000}{l s='Kb max.'} + {l s='Format:'} JPG, GIF, PNG. {l s='Filesize:'} {$max_image_size|string_format:"%.2f"}{l s='Kb max.'}

diff --git a/admin-dev/themes/template/products/informations.tpl b/admin-dev/themes/template/products/informations.tpl index 70f718b5b..00aa273ac 100644 --- a/admin-dev/themes/template/products/informations.tpl +++ b/admin-dev/themes/template/products/informations.tpl @@ -387,7 +387,8 @@ var textFieldLabel = 0; {include file="products/textarea_lang.tpl" languages=$languages input_name='description_short' - input_value=$product->description_short} + input_value=$product->description_short + max=400}

diff --git a/admin-dev/themes/template/products/textarea_lang.tpl b/admin-dev/themes/template/products/textarea_lang.tpl index 0e967b6a3..503ee4bd9 100644 --- a/admin-dev/themes/template/products/textarea_lang.tpl +++ b/admin-dev/themes/template/products/textarea_lang.tpl @@ -28,8 +28,9 @@ {foreach from=$languages item=language}
+ name="{$input_name}_{$language.id_lang}" + class="autoload_rte" >{$input_value[$language.id_lang]|htmlentitiesUTF8} + {$hint|default:''} 
{/foreach} diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index a59501f9d..5649603b7 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -2999,7 +2999,7 @@ class AdminProductsControllerCore extends AdminController $data->assign('token', $this->token); $data->assign('table', $this->table); - $data->assign('max_image_size', $this->max_image_size); + $data->assign('max_image_size', (int)Configuration::get('PS_PRODUCT_PICTURE_MAX_SIZE') / 1000); $data->assign('up_filename', strval(Tools::getValue('virtual_product_filename_attribute'))); $data->assign('currency', $this->context->currency); diff --git a/js/admin.js b/js/admin.js index 7ac2e340e..b384fe6b6 100644 --- a/js/admin.js +++ b/js/admin.js @@ -1018,3 +1018,22 @@ $(document).ready(function(){ scroll.hide(); }); }); + +// Delete all tags HTML +function stripHTML(oldString) +{ + var newString = ''; + var inTag = false; + for(var i = 0; i < oldString.length; i++) { + if(oldString.charAt(i) == '<') inTag = true; + if(oldString.charAt(i) == '>') { + if(oldString.charAt(i+1)!='<') + { + inTag = false; + i++; + } + } + if(!inTag) newString += oldString.charAt(i); + } + return newString; +}