Working : Coupon : fix links and errors display

This commit is contained in:
gmorel
2013-09-13 12:42:33 +02:00
parent 530c3d1102
commit ed4809bac4
14 changed files with 411 additions and 397 deletions

View File

@@ -115,6 +115,8 @@ $(function($){
// Reload effect inputs when changing effect
couponManager.onEffectChange = function() {
var optionSelected = $("option:selected", this);
$('#effectToolTip').html(optionSelected.attr("data-description"));
$('#effect').on('change', function () {
var optionSelected = $("option:selected", this);
$('#effectToolTip').html(optionSelected.attr("data-description"));
@@ -134,6 +136,32 @@ $(function($){
// var onInputsChange = function()
// In AJAX response
// Set max usage to unlimited or not
couponManager.onUsageUnlimitedChange = function() {
if (!$('#max-usage').parent().hasClass('has-error')) {
$('#max-usage').hide().attr('value', '-1');
}
$('#is-unlimited').change(function(){
var $this = $(this);
if ($this.is(':checked')) {
$('#max-usage').hide().attr('value', '-1');
} else {
$('#max-usage').show().val('').attr('value', '');
}
});
};
couponManager.onUsageUnlimitedChange();
// // -- Effect description
// if($('[name=effect]').length){
// var $effectSelect = $('[name=effect]'),
// $helpBlock = $effectSelect.next('.help-block');
//
// $effectSelect.change(function(){
// var description = $(this).find(":selected").data('description');
// $helpBlock.text(description);
// });
// }
});
// Rule to save

View File

@@ -40,34 +40,7 @@
});
}*/
// -- Effect description
if($('[name=effect]').length){
var $effectSelect = $('[name=effect]'),
$helpBlock = $effectSelect.next('.help-block');
$effectSelect.change(function(){
var description = $(this).find(":selected").data('description');
$helpBlock.text(description);
});
}
// -- Max usage --
if($('#is-unlimited').length){
if($('#is-unlimited').is(':checked')){
$('#max-usage').hide().attr('value', '-1');
}
$('#is-unlimited').change(function(){
if($('#is-unlimited').is(':checked')){
$('#max-usage').hide().attr('value', '-1');
}
else{
$('#max-usage').show().val('').attr('value', '');
}
});
}
// -- Bootstrap tooltip --
if($('[rel="tooltip"]').length){