"use strict"; /**************************** * SOME COMMON SVG CONSTANT * ****************************/ var SVG_LOADER = ''; /**************************** * SOME COMMON SVG CONSTANT* ****************************/ /* * * @param string $message * @returns {undefined} show flash message */ function flashNotice($message, $class) { $class = ($class != undefined) ? $class : ''; var flashMsgHtml = '

' + $message + '

'; if ($('.ourFlashMsg').length) { $('.ourFlashMsg').remove(); } $("body").append(flashMsgHtml); setTimeout(function () { if ($('.ourFlashMsg').length) { $('.ourFlashMsg').remove(); } }, 3000); } /* * @param {string} $className * @returns {undefined} show loader */ function loading_show($selector) { $($selector).addClass("Polaris-Button--loading").html('' + SVG_LOADER + 'Loading').fadeIn('fast').attr('disabled', 'disabled'); } /** * @param {string} $className * @param {string} $buttonName * @returns {undefined} hide loader */ function loading_hide($selector, $buttonName, $buttonIcon) { if ($buttonIcon != undefined) { $buttonIcon = '' + $buttonIcon + '' } else { $buttonIcon = ''; } $($selector).removeClass("Polaris-Button--loading").html('' + $buttonIcon + '' + $buttonName + '').removeAttr("disabled"); } $(document).on('click', '.close-message', function () { $('.remove-sucees-message').hide(); }); function removeCode(thisObj, data_key) { var current = $(thisObj); var btnText = current.html(); loading_show(current); var deleteAjax = function deleteAjax(){ loading_show(thisObj); $.ajax({ url: "ajax_actions.php", type: "post", dataType: "json", data: {method_name: 'remove_code', data_key: data_key, shop: shop}, success: function (response) { if (response['result'] == 'success') { flashNotice(response['msg']); $('.remove-sucees-message').show(); $('.remove-sucees-message').css({'display': 'flex'}); } loading_hide(current, btnText); }, error: function () { flashNotice('Please try again!','error'); } }); } if(mode == 'live'){ ShopifyApp.Modal.confirm({ title: 'Uninstall', message: 'Are you sure you want to remove? This action cannot be reversed.', okButton: 'Delete', cancelButton: 'Cancel', style: "danger" }, function (result) { if (result) { $('.ui-button.close-modal.btn-destroy-no-hover').addClass("ui-button ui-button--destructive js-btn-loadable is-loading disabled"); deleteAjax(); } }); }else{ var r = confirm('Are you sure you want to remove? This action cannot be reversed.'); if (r == true) { deleteAjax(); } } } function toggleCheckedVal(switchval,userdomain,useremail,datakey){ $.ajax({ url: "ajax_actions.php", type: "post", dataType: "json", data: {method_name: 'change_appStatus', data_status: switchval, user_name:userdomain, user_email:useremail, data_key:datakey, shop: shop}, beforeSend: function(){ $('#myonoffswitch').prop('disabled', true); }, complete: function(){ $('#myonoffswitch').prop('disabled', false); }, success: function (response) { if (response['result'] == 'success') { $(".enable-banner").html(response['msg']); $('#user_key').val(response['key']); } }, error: function () { flashNotice('Please try again!','error'); } }); }