// Fix attr('checked'), attr('disabled') and attr('selected') with jquery update #PSCFV-2142

This commit is contained in:
rMalie
2012-05-02 08:29:30 +00:00
parent faea9caafb
commit d0b4e96ab3
17 changed files with 43 additions and 43 deletions
@@ -394,7 +394,7 @@
function disableConstraint() function disableConstraint()
{ {
$('#constraint').attr('disabled', 'disabled'); $('#constraint').attr('disabled', true);
}; };
function ShowHandlers() function ShowHandlers()
{ {
@@ -496,7 +496,7 @@
*/ */
function cancelChangeMode() function cancelChangeMode()
{ {
$('#formAction input[@value=' + $('#image_mode').val() + ']').attr('checked', 'checked'); $('#formAction input[@value=' + $('#image_mode').val() + ']').attr('checked', true);
}; };
/** /**
* get the image element which is going to be modified * get the image element which is going to be modified
@@ -669,7 +669,7 @@ function toggleDisabledButton(buttonId, forceDisable)
if(forceDisable && currentClass == 'button') if(forceDisable && currentClass == 'button')
{ {
newClass = 'disabledButton'; newClass = 'disabledButton';
$(disabledButton).attr('disabled', 'disabled'); $(disabledButton).attr('disabled', true);
}else if(!forceDisable && currentClass == 'disabledButton') }else if(!forceDisable && currentClass == 'disabledButton')
{ {
newClass = 'button'; newClass = 'button';
@@ -684,7 +684,7 @@ function toggleDisabledButton(buttonId, forceDisable)
else if(currentClass == 'button') else if(currentClass == 'button')
{ {
newClass = 'disabledButton'; newClass = 'disabledButton';
$(disabledButton).attr('disabled', 'disabled'); $(disabledButton).attr('disabled', true);
}else }else
{ {
newClass = 'button'; newClass = 'button';
@@ -223,13 +223,13 @@ $('#cart_rule_form').submit(function() {
else else
{ {
$('#' + restrictions[i] + '_select_2 option').each(function(i) { $('#' + restrictions[i] + '_select_2 option').each(function(i) {
$(this).attr('selected', 'selected'); $(this).attr('selected', true);
}); });
} }
} }
$('.product_rule_toselect option').each(function(i) { $('.product_rule_toselect option').each(function(i) {
$(this).attr('selected', 'selected'); $(this).attr('selected', true);
}); });
}); });
@@ -43,7 +43,7 @@
if (r == 'ok') if (r == 'ok')
{ {
$('#note_feedback').html("<b style='color:green'>{l s='Your note has been saved'}</b>").fadeIn(400); $('#note_feedback').html("<b style='color:green'>{l s='Your note has been saved'}</b>").fadeIn(400);
$('#submitCustomerNote').attr('disabled', 'disabled'); $('#submitCustomerNote').attr('disabled', true);
} }
else if (r == 'error:validation') else if (r == 'error:validation')
$('#note_feedback').html("<b style='color:red'>({l s='Error: your note is not valid'}</b>").fadeIn(400); $('#note_feedback').html("<b style='color:red'>({l s='Error: your note is not valid'}</b>").fadeIn(400);
@@ -97,7 +97,7 @@
if (!val || val == {$smarty.const._PS_ADMIN_PROFILE_}) if (!val || val == {$smarty.const._PS_ADMIN_PROFILE_})
{ {
$('.assoShop input[type=checkbox]').attr('disabled', true); $('.assoShop input[type=checkbox]').attr('disabled', true);
$('.assoShop input[type=checkbox]').attr('checked', 'checked'); $('.assoShop input[type=checkbox]').attr('checked', true);
} }
else else
$('.assoShop input[type=checkbox]').attr('disabled', false); $('.assoShop input[type=checkbox]').attr('disabled', false);
@@ -77,7 +77,7 @@
else else
{ {
$(elt).addClass('select_all').removeClass('unselect_all'); $(elt).addClass('select_all').removeClass('unselect_all');
$('ul#sortable_module_'+$(elt).attr('id')).find('input[type="checkbox"]').attr('checked', 'checked'); $('ul#sortable_module_'+$(elt).attr('id')).find('input[type="checkbox"]').attr('checked', true);
$(elt).html('{l s='Unselect all'}'); $(elt).html('{l s='Unselect all'}');
} }
} }
@@ -625,11 +625,11 @@
updateDeliveryOptionList(jsonSummary.delivery_option_list); updateDeliveryOptionList(jsonSummary.delivery_option_list);
if (jsonSummary.cart.gift == 1) if (jsonSummary.cart.gift == 1)
$('#order_gift').attr('checked', 'checked'); $('#order_gift').attr('checked', true);
else else
$('#carrier_gift').removeAttr('checked'); $('#carrier_gift').removeAttr('checked');
if (jsonSummary.cart.recyclable == 1) if (jsonSummary.cart.recyclable == 1)
$('#carrier_recycled_package').attr('checked', 'checked'); $('#carrier_recycled_package').attr('checked', true);
else else
$('#carrier_recycled_package').removeAttr('checked'); $('#carrier_recycled_package').removeAttr('checked');
$('#gift_message').html(jsonSummary.cart.gift_message); $('#gift_message').html(jsonSummary.cart.gift_message);
@@ -645,11 +645,11 @@
$('#total_products').html(jsonSummary.summary.total_products); $('#total_products').html(jsonSummary.summary.total_products);
id_currency = jsonSummary.cart.id_currency; id_currency = jsonSummary.cart.id_currency;
$('#id_currency option').removeAttr('selected'); $('#id_currency option').removeAttr('selected');
$('#id_currency option[value="'+id_currency+'"]').attr('selected', 'selected'); $('#id_currency option[value="'+id_currency+'"]').attr('selected', true);
updateCurrencySign(); updateCurrencySign();
id_lang = jsonSummary.cart.id_lang; id_lang = jsonSummary.cart.id_lang;
$('#id_lang option').removeAttr('selected'); $('#id_lang option').removeAttr('selected');
$('#id_lang option[value="'+id_lang+'"]').attr('selected', 'selected'); $('#id_lang option[value="'+id_lang+'"]').attr('selected', true);
$('#send_email_to_customer').attr('rel', jsonSummary.link_order); $('#send_email_to_customer').attr('rel', jsonSummary.link_order);
$('#go_order_process').attr('href', jsonSummary.link_order); $('#go_order_process').attr('href', jsonSummary.link_order);
$('#order_message').val(jsonSummary.order_message); $('#order_message').val(jsonSummary.order_message);
@@ -44,7 +44,7 @@
event.preventDefault(); event.preventDefault();
$('#block_category_tree').toggle(); $('#block_category_tree').toggle();
if ($('#block_category_tree').is(':visible')) if ($('#block_category_tree').is(':visible'))
$(this).find('input').attr('checked', 'checked'); $(this).find('input').attr('checked', true);
else else
{ {
$(this).find('input').removeAttr('checked'); $(this).find('input').removeAttr('checked');
@@ -35,14 +35,14 @@
if (disabled_customer || disabled_stock) if (disabled_customer || disabled_stock)
{ {
$("input[name=share_order]").each(function(i) { $("input[name=share_order]").each(function(i) {
$(this).attr('disabled', 'disabled'); $(this).attr('disabled', true);
}); });
$('#share_order_off').attr('checked', true); $('#share_order_off').attr('checked', true);
} }
else else
{ {
$('input[name=share_order]').attr('disabled', ''); $('input[name=share_order]').attr('disabled', false);
} }
} }
@@ -223,13 +223,13 @@ $(document).ready(function() {
new_condition_group(); new_condition_group();
{foreach from=$condition_group item='condition'} {foreach from=$condition_group item='condition'}
{if $condition.type == 'attribute'} {if $condition.type == 'attribute'}
$('#id_attribute_group option[value="{$condition.id_attribute_group}"]').attr('selected', 'selected'); $('#id_attribute_group option[value="{$condition.id_attribute_group}"]').attr('selected', true);
$('#id_attribute_{$condition.id_attribute_group} option[value="{$condition.value}"]').attr('selected', 'selected'); $('#id_attribute_{$condition.id_attribute_group} option[value="{$condition.value}"]').attr('selected', true);
{elseif $condition.type == 'feature'} {elseif $condition.type == 'feature'}
$('#id_feature[value="{$condition.id_feature}"]').attr('selected', 'selected'); $('#id_feature[value="{$condition.id_feature}"]').attr('selected', true);
$('#id_feature_{$condition.id_feature} option[value="{$condition.value}"]').attr('selected', 'selected'); $('#id_feature_{$condition.id_feature} option[value="{$condition.value}"]').attr('selected', true);
{else} {else}
$('#id_{$condition.type} option[value="{$condition.value}"]').attr('selected', 'selected'); $('#id_{$condition.type} option[value="{$condition.value}"]').attr('selected', true);
{/if} {/if}
$('#add_condition_{$condition.type}').click(); $('#add_condition_{$condition.type}').click();
{/foreach} {/foreach}
+2 -2
View File
@@ -203,7 +203,7 @@ function checkAllCategories()
else else
{ {
$('input[name="categoryBox[]"]').not(':checked').each(function () { $('input[name="categoryBox[]"]').not(':checked').each(function () {
$(this).attr('checked', 'checked'); $(this).attr('checked', true);
clickOnCategoryBox($(this)); clickOnCategoryBox($(this));
}); });
} }
@@ -352,7 +352,7 @@ function checkCategory()
} }
else else
{ {
$('li#'+category_to_check+' > input').attr('checked', 'checked'); $('li#'+category_to_check+' > input').attr('checked', true);
updateNbSubCategorySelected($('li#'+category_to_check+' > input[type=checkbox]'), true); updateNbSubCategorySelected($('li#'+category_to_check+' > input[type=checkbox]'), true);
} }
} }
+13 -13
View File
@@ -740,12 +740,12 @@ product_tabs['Informations'] = new function(){
$("#available_for_order").click(function(){ $("#available_for_order").click(function(){
if ($(this).is(':checked') || !$('input[name=\'multishop_check[show_price]\']').prop('checked')) if ($(this).is(':checked') || !$('input[name=\'multishop_check[show_price]\']').prop('checked'))
{ {
$('#show_price').attr('checked', 'checked'); $('#show_price').attr('checked', true);
$('#show_price').attr('disabled', 'disabled'); $('#show_price').attr('disabled', true);
} }
else else
{ {
$('#show_price').attr('disabled', ''); $('#show_price').attr('disabled', false);
} }
}); });
}; };
@@ -782,17 +782,17 @@ product_tabs['Informations'] = new function(){
this.switchProductType = function(){ this.switchProductType = function(){
if (product_type == product_type_pack) if (product_type == product_type_pack)
{ {
$('#pack_product').attr('checked', 'checked'); $('#pack_product').attr('checked', true);
} }
else if (product_type == product_type_virtual) else if (product_type == product_type_virtual)
{ {
$('#virtual_product').attr('checked', 'checked'); $('#virtual_product').attr('checked', true);
$('#condition').attr('disabled', 'disabled'); $('#condition').attr('disabled', true);
$('#condition option[value=new]').attr('selected', 'selected'); $('#condition option[value=new]').attr('selected', true);
} }
else else
{ {
$('#simple_product').attr('checked', 'checked'); $('#simple_product').attr('checked', true);
} }
$('input[name="type_product"]').live('click', function() $('input[name="type_product"]').live('click', function()
@@ -813,11 +813,11 @@ product_tabs['Informations'] = new function(){
{ {
//when you change the type of the product, directly go to the pack tab //when you change the type of the product, directly go to the pack tab
$('li.tab-row a[id*="Pack"]').show().click(); $('li.tab-row a[id*="Pack"]').show().click();
$('#ppack').val(1).attr('checked', true).attr('disabled', 'disabled'); $('#ppack').val(1).attr('checked', true).attr('disabled', true);
$('#ppackdiv').show(); $('#ppackdiv').show();
// If the pack tab has not finished loaded the changes will be made when the loading event is triggered // If the pack tab has not finished loaded the changes will be made when the loading event is triggered
$("#product-tab-content-Pack").bind('loaded', function(){ $("#product-tab-content-Pack").bind('loaded', function(){
$('#ppack').val(1).attr('checked', true).attr('disabled', 'disabled'); $('#ppack').val(1).attr('checked', true).attr('disabled', true);
$('#ppackdiv').show(); $('#ppackdiv').show();
}); });
$("#product-tab-content-Quantities").bind('loaded', function(){ $("#product-tab-content-Quantities").bind('loaded', function(){
@@ -834,7 +834,7 @@ product_tabs['Informations'] = new function(){
{ {
if (has_combinations) if (has_combinations)
{ {
$('#simple_product').attr('checked', 'checked'); $('#simple_product').attr('checked', true);
$('#warn_virtual_combinations').show(); $('#warn_virtual_combinations').show();
} }
else else
@@ -854,7 +854,7 @@ product_tabs['Informations'] = new function(){
$('li.tab-row a[id*="Shipping"]').hide(); $('li.tab-row a[id*="Shipping"]').hide();
tabs_manager.onLoad('Informations', function(){ tabs_manager.onLoad('Informations', function(){
$('#condition').attr('disabled', 'disabled'); $('#condition').attr('disabled', true);
$('#condition option[value=refurbished]').removeAttr('selected'); $('#condition option[value=refurbished]').removeAttr('selected');
$('#condition option[value=used]').removeAttr('selected'); $('#condition option[value=used]').removeAttr('selected');
}); });
@@ -905,7 +905,7 @@ product_tabs['Pack'] = new function(){
this.bindPackEvents = function (){ this.bindPackEvents = function (){
if ($('#ppack').prop('checked')) if ($('#ppack').prop('checked'))
{ {
$('#ppack').attr('disabled', 'disabled'); $('#ppack').attr('disabled', true);
$('#ppackdiv').show(); $('#ppackdiv').show();
} }
+1 -1
View File
@@ -344,7 +344,7 @@ function init()
{ {
$('tr#new_product input, tr#new_product select').each(function() { $('tr#new_product input, tr#new_product select').each(function() {
if ($(this).attr('id') != 'add_product_product_name') if ($(this).attr('id') != 'add_product_product_name')
$('tr#new_product input, tr#new_product select').attr('disabled', 'disabled'); $('tr#new_product input, tr#new_product select').attr('disabled', true);
}); });
} }
else else
+2 -2
View File
@@ -184,11 +184,11 @@ var ajaxCart = {
//disabled the button when adding to do not double add if user double click //disabled the button when adding to do not double add if user double click
if (addedFromProductPage) if (addedFromProductPage)
{ {
$('body#product p#add_to_cart input').attr('disabled', 'disabled').removeClass('exclusive').addClass('exclusive_disabled'); $('body#product p#add_to_cart input').attr('disabled', true).removeClass('exclusive').addClass('exclusive_disabled');
$('.filled').removeClass('filled'); $('.filled').removeClass('filled');
} }
else else
$(callerElement).attr('disabled', 'disabled'); $(callerElement).attr('disabled', true);
if ($('#cart_block #cart_block_list').hasClass('collapsed')) if ($('#cart_block #cart_block_list').hasClass('collapsed'))
this.expand(); this.expand();
+1 -1
View File
@@ -412,7 +412,7 @@ function reloadContent(params_plus)
val = $('#pagination #nb_item').val(); val = $('#pagination #nb_item').val();
$('#pagination #nb_item').children().each(function(it, option) { $('#pagination #nb_item').children().each(function(it, option) {
if (option.value == val) if (option.value == val)
$(option).attr('selected', 'selected'); $(option).attr('selected', true);
else else
$(option).removeAttr('selected'); $(option).removeAttr('selected');
}); });
+1 -1
View File
@@ -45,7 +45,7 @@ countriesNeedZipCode = new Array();
{/if} {/if}
{/foreach} {/foreach}
$(function(){ldelim} $(function(){ldelim}
$('.id_state option[value={if isset($smarty.post.id_state)}{$smarty.post.id_state}{else}{if isset($address->id_state)}{$address->id_state|escape:'htmlall':'UTF-8'}{/if}{/if}]').attr('selected', 'selected'); $('.id_state option[value={if isset($smarty.post.id_state)}{$smarty.post.id_state}{else}{if isset($address->id_state)}{$address->id_state|escape:'htmlall':'UTF-8'}{/if}{/if}]').attr('selected', true);
{rdelim}); {rdelim});
{if $vat_management} {if $vat_management}
{literal} {literal}
+1 -1
View File
@@ -50,7 +50,7 @@ countriesNeedZipCode = new Array();
{/foreach} {/foreach}
{/if} {/if}
$(function(){ldelim} $(function(){ldelim}
$('.id_state option[value={if isset($smarty.post.id_state)}{$smarty.post.id_state}{else}{if isset($address)}{$address->id_state|escape:'htmlall':'UTF-8'}{/if}{/if}]').attr('selected', 'selected'); $('.id_state option[value={if isset($smarty.post.id_state)}{$smarty.post.id_state}{else}{if isset($address)}{$address->id_state|escape:'htmlall':'UTF-8'}{/if}{/if}]').attr('selected', true);
{rdelim}); {rdelim});
//]]> //]]>
{if $vat_management} {if $vat_management}
+1 -1
View File
@@ -703,7 +703,7 @@ function checkUrl()
count++; count++;
// add class 'selected' to the selected color // add class 'selected' to the selected color
$('#color_'+attributesCombinations[a]['id_attribute']).addClass('selected'); $('#color_'+attributesCombinations[a]['id_attribute']).addClass('selected');
$('input:radio[value='+attributesCombinations[a]['id_attribute']+']').attr('checked', 'checked'); $('input:radio[value='+attributesCombinations[a]['id_attribute']+']').attr('checked', true);
$('input:hidden[name=group_'+attributesCombinations[a]['id_attribute_group']+']').val(attributesCombinations[a]['id_attribute']); $('input:hidden[name=group_'+attributesCombinations[a]['id_attribute_group']+']').val(attributesCombinations[a]['id_attribute']);
$('select[name=group_'+attributesCombinations[a]['id_attribute_group']+']').val(attributesCombinations[a]['id_attribute']); $('select[name=group_'+attributesCombinations[a]['id_attribute_group']+']').val(attributesCombinations[a]['id_attribute']);
} }