' )
.attr ( 'align', 'center' )
.append ( $j( '
![]()
' ).attr ( 'src', alopeyk.wcshm.admin.vars.common.info.alopeyk.wcshm.loader ) );
$j( '
' )
.attr ( 'id', id ? alopeyk.wcshm.admin.fn.addPrefix ( 'modal-' + id ) : null )
.addClass ( alopeyk.wcshm.admin.fn.addPrefix ( alopeyk.wcshm.admin.vars.common.modalContentClass ) )
.html ( content ? content : dialogLoader )
.dialog ( modalOptions );
},
createOrderModal : function ( orders, type, description ) {
var buttons = [{
text : alopeyk.wcshm.admin.fn.translate ( 'Cancel' ),
click : function () {
$j( this ).dialog ( 'destroy' );
}
}, {
text : alopeyk.wcshm.admin.fn.translate ( 'Ship' ),
class : 'button-primary',
click : function () {
$j( this ).find ( '[type="submit"]' ).trigger ( 'click' );
}
}],
data = {
type : type,
orders : orders,
description : description
}
alopeyk.wcshm.admin.fn.showModal ( 'create-order', alopeyk.wcshm.admin.fn.translate ( 'Ship via Alopeyk' ), 'create_order_modal', data, buttons, null, function () {
alopeyk.wcshm.admin.fn.handleDateTimeFilters();
});
},
createCreditModal : function ( amount ) {
var buttons = [{
text : alopeyk.wcshm.admin.fn.translate ( 'Cancel' ),
click : function () {
$j( this ).dialog ( 'destroy' );
}
}, {
text : alopeyk.wcshm.admin.fn.translate ( 'Add Coupon' ),
click : function () {
alopeyk.wcshm.admin.fn.createCouponModal();
}
}, {
text : alopeyk.wcshm.admin.fn.translate ( 'Pay' ),
class : 'button-primary',
click : function () {
if ( $j( this ).find ( '[type="submit"]' ).trigger ( 'click' ).parents ( 'form' ).get ( 0 ).checkValidity() ) {
$j( this ).dialog ( 'destroy' );
var orderCheckModal = $j( '#' + alopeyk.wcshm.admin.fn.addPrefix ( 'modal-check-order' ) );
if ( orderCheckModal.length ) {
orderCheckModal.dialog ( 'destroy' );
}
}
}
}],
data = {
amount : amount
}
alopeyk.wcshm.admin.fn.showModal ( 'create-credit', alopeyk.wcshm.admin.fn.translate ( 'Add Alopeyk Credit' ), 'create_credit_modal', data, buttons, null );
},
createCouponModal : function () {
var buttons = [{
text : alopeyk.wcshm.admin.fn.translate ( 'Cancel' ),
click : function () {
$j( this ).dialog ( 'destroy' );
}
}, {
text : alopeyk.wcshm.admin.fn.translate ( 'Apply' ),
class : 'button-primary',
click : function () {
$j( this ).find ( '[type="submit"]' ).trigger ( 'click' );
}
}],
data = null;
alopeyk.wcshm.admin.fn.showModal ( 'create-coupon', alopeyk.wcshm.admin.fn.translate ( 'Add Alopeyk Coupon' ), 'create_coupon_modal', data, buttons, null );
},
createCancelModal : function ( order ) {
var buttons = [{
text : alopeyk.wcshm.admin.fn.translate ( 'Close' ),
click : function () {
$j( this ).dialog ( 'destroy' );
}
}, {
text : alopeyk.wcshm.admin.fn.translate ( 'Cancel' ),
class : 'button-primary',
click : function () {
$j( this ).find ( '[type="submit"]' ).trigger ( 'click' );
}
}],
data = {
order : order
};
alopeyk.wcshm.admin.fn.showModal ( 'cancel-order', alopeyk.wcshm.admin.fn.translate ( 'Cancel Alopeyk Order' ), 'create_cancel_modal', data, buttons, null );
},
createRateModal : function ( order ) {
var buttons = [{
text : alopeyk.wcshm.admin.fn.translate ( 'Close' ),
click : function () {
$j( this ).dialog ( 'destroy' );
}
}, {
text : alopeyk.wcshm.admin.fn.translate ( 'Submit' ),
class : 'button-primary',
click : function () {
$j( this ).find ( '[type="submit"]' ).trigger ( 'click' );
}
}],
data = {
order : order
};
alopeyk.wcshm.admin.fn.showModal ( 'rate-order', alopeyk.wcshm.admin.fn.translate ( 'Rate Alopeyk Courier' ), 'create_rate_modal', data, buttons, null, function ( dialogElement ) {
dialogElement.find ( 'input[type="radio"]' ).on ( 'change', function () {
dialogElement.dialog ( 'option', 'position', {
of : window,
my : 'center',
at : 'center',
});
});
});
},
handleDateTimeFilters : function () {
var lastActiveHour = 0,
lastActiveMinute = 0,
schedule_dates = alopeyk.wcshm.admin.vars.common.info.alopeyk.wcshm.scope.schedule_dates.dates,
schedule_steps = alopeyk.wcshm.admin.vars.common.info.alopeyk.wcshm.scope.schedule_dates.steps,
shipDateDropdown = $j( alopeyk.wcshm.admin.vars.forms.dateDropdownElement ).filter ( function () {
return ! $j( this ).data ( 'alopeyk-initiated' );
}).data ( 'alopeyk-initiated', true ),
shipHourDropdown = $j( alopeyk.wcshm.admin.vars.forms.hourDropdownElement ).filter ( function () {
return ! $j( this ).data ( 'alopeyk-initiated' );
}).data ( 'alopeyk-initiated', true ),
shipMinuteDropdown = $j( alopeyk.wcshm.admin.vars.forms.minuteDropdownElement ).filter ( function () {
return ! $j( this ).data ( 'alopeyk-initiated' );
}).data ( 'alopeyk-initiated', true );
if ( shipDateDropdown.length && shipHourDropdown.length && shipMinuteDropdown.length && schedule_dates && Object.keys ( schedule_dates ).length ) {
shipDateDropdown.children().remove().end().on ( 'change', function () {
shipHourDropdown.children().remove();
var selected_date = $j( this ).find ( ':selected' ),
initial_hour = parseInt ( selected_date.data ( 'initial_hour' ) ),
initial_minute = parseInt ( selected_date.data ( 'initial_minute' ) );
for ( var h = initial_hour; h < 24; h++ ) {
var hour = alopeyk.wcshm.admin.fn.pad ( h, 2, '0' );
$j( '