Using template for coupons HTML fragments
This commit is contained in:
@@ -4,7 +4,7 @@ $(function($){
|
||||
$.couponManager = {};
|
||||
|
||||
// Condition being updated category id
|
||||
$.couponManager.conditionToUpdateServiceId = -1;
|
||||
$.couponManager.conditionToUpdateServiceId = '';
|
||||
// Condition being updated index
|
||||
$.couponManager.conditionToUpdateIndex = false;
|
||||
|
||||
@@ -20,6 +20,7 @@ $(function($){
|
||||
$.couponManager.intlPleaseRetry = '';
|
||||
$.couponManager.intlPleaseSelectAnotherCondition = '';
|
||||
$.couponManager.intlDoYouReallyWantToSetCouponAvailableForEveryOne = '';
|
||||
$.couponManager.intlDoYouReallyWantToDeleteThisCondition = '';
|
||||
|
||||
// *****************************************
|
||||
// ****************** Delete ***************
|
||||
@@ -28,11 +29,13 @@ $(function($){
|
||||
$.couponManager.onClickDeleteCondition = function() {
|
||||
$('.condition-delete-btn').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
var index = $this.attr('data-conditionIndex');
|
||||
$.couponManager.conditionToUpdateServiceId = -1;
|
||||
$.couponManager.conditionToUpdateIndex = false;
|
||||
$.couponManager.removeConditionAjax(index);
|
||||
if (confirm($.couponManager.intlDoYouReallyWantToDeleteThisCondition)) {
|
||||
var $this = $(this);
|
||||
var index = $this.data('condition-index');
|
||||
$.couponManager.conditionToUpdateServiceId = '';
|
||||
$.couponManager.conditionToUpdateIndex = false;
|
||||
$.couponManager.removeConditionAjax(index);
|
||||
}
|
||||
});
|
||||
};
|
||||
$.couponManager.onClickDeleteCondition();
|
||||
@@ -94,7 +97,7 @@ $(function($){
|
||||
$('#condition-add-operators-values').html('');
|
||||
// Set the condition selector to default
|
||||
$("#category-condition option").filter(function() {
|
||||
return $(this).val() == '-1';
|
||||
return $(this).val() == '';
|
||||
}).prop('selected', true);
|
||||
}).fail(function() {
|
||||
$('#condition-add-operators-values').html(
|
||||
@@ -115,8 +118,8 @@ $(function($){
|
||||
$('.condition-update-btn').on('click', function (e) {
|
||||
e.preventDefault();
|
||||
var $this = $(this);
|
||||
$.couponManager.conditionToUpdateServiceId = $this.attr('data-serviceId');
|
||||
$.couponManager.conditionToUpdateIndex = $this.attr('data-conditionIndex');
|
||||
$.couponManager.conditionToUpdateServiceId = $this.data('service-id');
|
||||
$.couponManager.conditionToUpdateIndex = $this.data('condition-index');
|
||||
|
||||
$.couponManager.updateConditionSelectFromConditionInterfaceAjax(
|
||||
$.couponManager.conditionToUpdateIndex,
|
||||
@@ -135,7 +138,7 @@ $(function($){
|
||||
var $this = $(this);
|
||||
var mainDiv = $('#condition-add-type');
|
||||
var optionSelected = $('option:selected', this);
|
||||
mainDiv.find('.typeToolTip').html(optionSelected.attr('data-description'));
|
||||
mainDiv.find('.typeToolTip').html(optionSelected.data('description'));
|
||||
|
||||
// Only if add mode
|
||||
if (false != $.couponManager.conditionToUpdateIndex) {
|
||||
@@ -179,7 +182,7 @@ $(function($){
|
||||
}
|
||||
}).done(function(data) {
|
||||
$('#condition-add-operators-values').html(data);
|
||||
if ($.couponManager.conditionToUpdateServiceId == -1) {
|
||||
if ($.couponManager.conditionToUpdateServiceId == '') {
|
||||
// Placeholder can't be saved
|
||||
$('#condition-save-btn').hide();
|
||||
} else {
|
||||
@@ -213,7 +216,7 @@ $(function($){
|
||||
$.couponManager.onEffectChange = function() {
|
||||
var mainDiv = $('#coupon-type');
|
||||
var optionSelected = mainDiv.find('#type option:selected');
|
||||
mainDiv.find('.typeToolTip').html(optionSelected.attr('data-description'));
|
||||
mainDiv.find('.typeToolTip').html(optionSelected.data('description'));
|
||||
|
||||
mainDiv.find('#type').on('change', function () {
|
||||
var optionSelected = $('option:selected', this);
|
||||
@@ -225,7 +228,7 @@ $(function($){
|
||||
|
||||
$.couponManager.displayEfffect = function(optionSelected) {
|
||||
var mainDiv = $('#coupon-type');
|
||||
mainDiv.find('.typeToolTip').html(optionSelected.attr('data-description'));
|
||||
mainDiv.find('.typeToolTip').html(optionSelected.data('description'));
|
||||
|
||||
var inputsDiv = mainDiv.find('.inputs');
|
||||
inputsDiv.html('<div class="loading" ></div>');
|
||||
|
||||
Reference in New Issue
Block a user