[*] BO : refact for modules exeptions regarding https://github.com/PrestaShop/PrestaShop/pull/614

This commit is contained in:
gRoussac
2013-07-31 15:16:42 +02:00
parent 69944e1618
commit 5e0b5db23b
@@ -73,39 +73,37 @@
</fieldset> </fieldset>
</form> </form>
<script type="text/javascript"> <script type="text/javascript">
//<![CDATA //<![CDATA
$(document).ready(function() function position_exception_textchange()
{ {
function position_exception_textchange(obj) // TODO : Add & Remove automatically the "custom pages" in the "em_list_x"
{ var obj = $(this);
var shopID = obj.attr('id').replace(/\D/g, ''); var shopID = obj.attr('id').replace(/\D/g, '');
var list = obj.parent().find('#em_list_' + shopID); var list = obj.parent().find('#em_list_' + shopID);
var values = obj.val().split(','); var values = obj.val().split(',');
var len = values.length; var len = values.length;
list.find('option').prop('selected', false);
for (var i = 0; i < len; i++)
list.find('option[value="' + $.trim(values[i]) + '"]').prop('selected', true);
}
function position_exception_listchange(obj)
{
var shopID = obj.attr('id').replace(/\D/g, '');
var str = '';
obj.find('option:selected').each(function(){
str += obj.val()+', ';
});
if (str.length > 2)
str = str.substr(0, str.length - 2);
obj.parent().find('#em_text_' + shopID).val(str);
}
$('form[id="hook_module_form"] input[id^="em_text_"]').on('change', function(){ list.find('option').prop('selected', false);
position_exception_textchange($(this)); for (var i = 0; i < len; i++)
}).change(); list.find('option[value="' + $.trim(values[i]) + '"]').prop('selected', true);
$('form[id="hook_module_form"] select[id^="em_list_"]').on('change', function(){ }
position_exception_listchange($(this));
function position_exception_listchange()
{
var obj = $(this);
var shopID = obj.attr('id').replace(/\D/g, '');
var str = obj.val().join(', ');
obj.parent().find('#em_text_' + shopID).val(str);
}
$(document).ready(function(){
$('form[id="hook_module_form"] input[id^="em_text_"]').each(function(){
$(this).change(position_exception_textchange).change();
});
$('form[id="hook_module_form"] select[id^="em_list_"]').each(function(){
$(this).change(position_exception_listchange);
}); });
}); });
//]]> //]]>