' )
.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 schedule_dates = alopeyk.wcshm.admin.vars.common.info.alopeyk.wcshm.scope.schedule_dates,
shipDateDropdown = $j( alopeyk.wcshm.admin.vars.forms.dateDropdownElement ).filter ( function () {
return ! $j( this ).data ( 'alopeyk-initiated' );
}).data ( 'alopeyk-initiated', true ),
shipTimeDropdown = $j( alopeyk.wcshm.admin.vars.forms.timeDropdownElement ).filter ( function () {
return ! $j( this ).data ( 'alopeyk-initiated' );
}).data ( 'alopeyk-initiated', true );
if ( shipDateDropdown.length && shipTimeDropdown.length && schedule_dates && Object.keys ( schedule_dates ).length ) {
shipDateDropdown.children().remove().end().on ( 'change', function () {
shipTimeDropdown.children().remove();
var times = $j( this ).find ( ':selected' ).data ( 'times' );
if ( times && Object.keys ( times ).length ) {
for ( var time in times ) {
if ( times.hasOwnProperty ( time ) ) {
$j( '