' +\n '
' +\n '
');\n });\n $('#new-product-tags').on('chip.delete', function (e, chip) {\n $('#product-tags-fields input[data-input-value=\"' + chip.tag + '\"]').val('1');\n });\n },\n\n preArchiveWarning: function () {\n $('body').on('click', '.archive-product', function () {\n var $this = $(this),\n productId = $this.attr('data-product-id'),\n productPlans = $this.attr('data-product-plans');\n\n seller_admin.base.assignLoadingModal(\"loadingArchiveProduct\", \"Archiving your product...\");\n\n if (productPlans === \"true\") {\n $('.confirm-archive-product').attr('data-product-id', productId);\n seller_admin.base.openModal('#pre-archive-product-modal');\n } else {\n seller_admin.base.enableLoadingModal(\"#loadingArchiveProduct\", $this);\n seller_admin.product.archive($this);\n }\n });\n },\n\n archive: function (link) {\n var $this = link,\n productId = $this.attr('data-product-id'),\n productSearchTable = $('table#product-search-table'),\n productRow = $('tr.product-' + productId);\n\n $.ajax(\n {\n url: '/admin/products/' + productId + '/archive',\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (productRow.length > 0) {\n if (productSearchTable.length > 0) {\n productRow.replaceWith(data.row);\n } else {\n productRow.remove();\n }\n } else {\n $('#single-product-header span').replaceWith('
Archived');\n $('a.archive-product').replaceWith('
Unarchive');\n }\n $('#pre-archive-product-modal').modal('hide');\n seller_admin.base.disableLoadingModal(\"#loadingArchiveProduct\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully archived a product.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingArchiveProduct\", $this);\n admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n admin.base.scrollTop(\"main\");\n }\n });\n },\n\n confirmArchive: function () {\n $('body').on('click', '.confirm-archive-product', function () {\n seller_admin.base.enableLoadingModal(\"#loadingArchiveProduct\", $('#pre-archive-product-modal'));\n seller_admin.product.archive($(this));\n return false;\n });\n },\n\n unarchive: function () {\n $('body').on('click', '.unarchive-product', function () {\n var $this = $(this),\n url = $this.attr('href'),\n productId = $this.attr('data-product-id'),\n productSearchTable = $('table#product-search-table'),\n productRow = $('tr.product-' + productId);\n\n seller_admin.base.assignLoadingModal(\"loadingUnarchiveProduct\", \"Unarchiving your product...\");\n seller_admin.base.enableLoadingModal(\"#loadingUnarchiveProduct\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (productRow.length > 0) {\n if (productSearchTable.length > 0) {\n productRow.replaceWith(data.row);\n } else {\n productRow.remove();\n }\n } else {\n $('#single-product-header span').replaceWith('
Draft');\n $('a.unarchive-product').replaceWith('
Archive');\n }\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveProduct\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully unarchived a product.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveProduct\", $this);\n admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n publish: function () {\n $('body').on('click', '.publish-product', function () {\n var $this = $(this),\n url = $this.attr('href'),\n productId = $this.attr('data-product-id');\n seller_admin.base.assignLoadingModal(\"loadingPublishProduct\", \"Publishing your product...\");\n seller_admin.base.enableLoadingModal(\"#loadingPublishProduct\", $this);\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('tr.product-' + productId).replaceWith(data.row);\n $('#product-publishing-buttons').html(data.buttons);\n seller_admin.base.disableLoadingModal(\"#loadingPublishProduct\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully published a product.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingPublishProduct\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n unpublish: function () {\n $('body').on('click', '.unpublish-product', function () {\n var $this = $(this),\n url = $this.attr('href'),\n productId = $this.attr('data-product-id');\n\n seller_admin.base.assignLoadingModal(\"loadingUnpublishProduct\", \"Unpublishing your product...\");\n seller_admin.base.enableLoadingModal(\"#loadingUnpublishProduct\", $this);\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('tr.product-' + productId).replaceWith(data.row);\n $('#product-publishing-buttons').html(data.buttons);\n seller_admin.base.disableLoadingModal(\"#loadingUnpublishProduct\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully unpublished a product.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUnpublishProduct\", $this);\n admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n changeShippingType: function () {\n $('select#product_shipping_type').on('change', function () {\n if (this.value === 'weight') {\n $('#new-product-shippings').hide().html();\n $('#edit-product-shippings').hide();\n $('#add-product-shipping-wrapper').hide();\n $('#product-row-section').hide();\n $('#product-weight-wrapper').show();\n $('#new-product-shippings').empty();\n } else {\n $('#new-product-shippings').show();\n $('#edit-product-shippings').show();\n $('#add-product-shipping-wrapper').show();\n $('#product-row-section').show();\n $('#product-weight-wrapper').hide();\n }\n });\n },\n\n addImage: function (link, association, content) {\n var new_id = new Date().getTime(),\n regexp = new RegExp(\"new_\" + association, \"g\");\n $('ul#product-images').append(content.replace(regexp, new_id));\n var productImageFileUpload = $('#product_images_attributes_' + new_id + '_imageable_type').parent().find('.file-upload-wrapper input');\n seller_admin.base.initDragDropFileUpload(productImageFileUpload);\n seller_admin.product.checkImageCap();\n },\n\n removeImage: function (link) {\n $(link).prev(\"input[type=hidden]\").val(\"1\");\n $(link).closest(\".fields\").hide();\n seller_admin.product.checkImageCap();\n },\n\n addShipping: function (link, association, content) {\n var new_id = new Date().getTime(),\n regexp = new RegExp(\"new_\" + association, \"g\");\n $('#new-product-shippings').append(content.replace(regexp, new_id));\n var countryIdSelect = $('#product_shippings_attributes_' + new_id + '_country_ids'),\n countryIdInput = $('#product_shippings_attributes_' + new_id + '_country_ids_input');\n countryIdInput.attr('name', 'product[shippings_attributes][][country_ids][' + new_id + ']');\n countryIdSelect.materialSelect();\n countryIdSelect.click(e => e.stopPropagation());\n $('#product_shippings_attributes_' + new_id + '_price').focus();\n },\n\n editShipping: function (link, association, content) {\n var new_id = new Date().getTime(),\n regexp = new RegExp(\"new_\" + association, \"g\");\n $('#edit-product-shippings').append(content.replace(regexp, new_id));\n var countryIdSelect = $('#product_shippings_attributes_' + new_id + '_country_ids'),\n countryIdInput = $('#product_shippings_attributes_' + new_id + '_country_ids_input');\n countryIdInput.attr('name', 'product[shippings_attributes][][country_ids][' + new_id + ']');\n countryIdSelect.materialSelect();\n countryIdSelect.click(e => e.stopPropagation());\n $('#product_shippings_attributes_' + new_id + '_price').focus();\n },\n\n removeShipping: function (link) {\n $(link).prev(\"input[type=hidden]\").val(\"1\");\n $(link).closest(\".fields\").hide();\n seller_admin.product.checkImageCap();\n },\n\n saveContent: function () {\n var $this = $(this),\n accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content'),\n productId = $('.is-wrapper').attr('data-product-id'),\n html = window.contentBuilder.html();\n\n seller_admin.base.assignLoadingModal(\"loadingSaveProductContent\", \"Saving your product content...\");\n seller_admin.base.enableLoadingModal(\"#loadingSaveProductContent\", $this);\n\n $('#design-image-progress .progress-bar').css('width', '100%');\n\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/products/' + productId + '/update_draft_content',\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: 'PATCH',\n data: {'product_content': {'content': html}},\n dataType: 'json',\n success: function (data) {\n seller_admin.base.disableLoadingModal(\"#loadingSaveProductContent\", $this);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE SUCCESSFUL\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSaveProductContent\", $this);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE FAILED\");\n }\n });\n },\n\n autoSaveContent: function () {\n var accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content'),\n productId = $('.is-wrapper').attr('data-product-id'),\n html = window.contentBuilder.html();\n\n $('#design-image-progress .progress-bar').css('width', '100%');\n\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/products/' + productId + '/update_draft_content',\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: 'PATCH',\n data: {'product_content': {'content': html}},\n dataType: 'json',\n success: function (data) {\n seller_admin.base.successfulDesignerAutoSave();\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE SUCCESSFUL\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.failedDesignerAutoSave();\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE FAILED\");\n }\n });\n },\n\n\n publishContent: function () {\n $('body').on('click', '.publish-content-to-product', function () {\n var $this = $(this),\n accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content'),\n productId = $('.is-wrapper').attr('data-product-id');\n\n seller_admin.base.assignLoadingModal(\"loadingPublishProductContent\", \"Publishing your product content...\");\n seller_admin.base.enableLoadingModal(\"#loadingPublishProductContent\", $this);\n\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/products/' + productId + '/publish_draft_content',\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n seller_admin.base.openModal(\"#publishProductContentModal\");\n seller_admin.base.disableLoadingModal(\"#loadingPublishProductContent\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingPublishProductContent\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n });\n },\n\n changeProductType: function () {\n $('select#product_product_type').on('change', function () {\n if (this.value === 'digital') {\n $('#product-row-section').hide();\n $('.product-shipping-section').hide();\n $('#new-product-shippings').html('');\n $('#product-pricing-section').show();\n $('#product-inventory-oos-section').show();\n $('#product-inventory-quantity-section').show();\n $('#product-fulfillment-section').hide();\n $('#product-variant-section').show();\n $('#product-sale-option-section').show();\n $('#physical-incentive-save').hide();\n $('#non-physical-incentive-save').show();\n } else if (this.value == 'physical_incentive') {\n $('#product-row-section').hide();\n $('.product-shipping-section').hide();\n $('#product-pricing-section').hide();\n $('#product-inventory-oos-section').hide();\n $('#product-inventory-quantity-section').hide();\n $('#product-fulfillment-section').hide();\n $('#product-variant-section').hide();\n $('#product-sale-option-section').hide();\n $('#physical-incentive-save').show();\n $('#non-physical-incentive-save').hide();\n } else {\n $('#product-row-section').show();\n $('.product-shipping-section').show();\n $('#product-pricing-section').show();\n $('#product-inventory-oos-section').show();\n $('#product-inventory-quantity-section').show();\n $('#product-fulfillment-section').show();\n $('#product-variant-section').show();\n $('#product-sale-option-section').show();\n $('#physical-incentive-save').hide();\n $('#non-physical-incentive-save').show();\n }\n });\n },\n\n imageVariantsModal: function () {\n $('body').on('click', '.edit-image-variants', function () {\n var url = $(this).attr('href');\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#image-variants-wrapper').html(data.modal);\n\n $('#image-variants-form .mdb-select').materialSelect();\n seller_admin.base.openModal('#image-variants-form');\n }\n });\n return false;\n });\n },\n\n updateImageVariants: function () {\n $(\"body\").on(\"submit\", '.update-image-variants', function () {\n var url = $(this).attr('action'),\n $this = $(this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $(this).serialize(),\n dataType: 'json',\n success: function (data) {\n $('#image-variants-form').modal('hide');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n }\n });\n return false;\n });\n },\n\n createCsvReport: function () {\n $('#export-product-csv-button').on('click', function () {\n $('.csv-report-flash').remove();\n var productIds = $('#product-list-section').attr('data-product-ids').split(',');\n\n $.ajax(\n {\n url: '/admin/product_csvs',\n type: 'POST',\n data: {'product_ids': productIds},\n dataType: 'json',\n success: function (data) {\n $('#seller-admin-flashes').prepend('
Successfully created the CSV report. Please check your store email for a link to the file.
')\n seller_admin.base.scrollTop(\"main\");\n $('.customer_checkbox').prop('checked', false);\n },\n error: function (xhr, evt, status) {\n $('#seller-admin-flashes').prepend('
Unable to create the CSV report. Please try again.
');\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n changeGoogleMerchant: function () {\n $('select#product_google_merchant').on('change', function () {\n if (this.value === 'enabled') {\n $('#google-merchant-product-wrapper').show();\n } else {\n $('#google-merchant-product-wrapper').hide();\n }\n });\n }\n }","seller_admin.variant =\n {\n add: function () {\n $('body').on('click', '.create-variant', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingAddVariant\", \"Creating variant...\");\n seller_admin.base.enableLoadingModal(\"#loadingAddVariant\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#variant-wrapper').html(data.modal);\n seller_admin.base.openModal('#variant-form');\n $('#variant-wrapper .mdb-select').materialSelect();\n $('#variant-wrapper-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingAddVariant\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingAddVariant\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n create: function () {\n $('body').on('submit', '#create-variant', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingAddVariant\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#variant-form').modal('hide');\n $('#variants-table tbody').prepend(data.row);\n seller_admin.base.addCustomFlash('#variants-section', 'success', 'Successfully added a variant to your product.');\n seller_admin.base.disableLoadingModal(\"#loadingAddVariant\", $this);\n seller_admin.base.scrollTop('#variants-section');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingAddVariant\", $this);\n }\n });\n return false;\n });\n },\n\n edit: function () {\n $('body').on('click', '.edit-variant', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingEditVariant\", \"Updating variant...\");\n seller_admin.base.enableLoadingModal(\"#loadingEditVariant\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#variant-wrapper').html(data.modal);\n seller_admin.base.openModal('#variant-form');\n $('#variant-wrapper .mdb-select').materialSelect();\n $('#variant-wrapper-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingEditVariant\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingEditVariant\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n update: function () {\n $('body').on('submit', '#edit-variant', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingEditVariant\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#variant-form').modal('hide');\n $('#variants-table tbody tr#variant-' + data.variant_id).replaceWith(data.row);\n seller_admin.base.addCustomFlash('#variants-section', 'success', 'Successfully updated a variant for your product.');\n seller_admin.base.disableLoadingModal(\"#loadingEditVariant\", $this);\n seller_admin.base.scrollTop('#variants-section');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingEditVariant\", $this);\n }\n });\n return false;\n });\n },\n\n archive: function()\n {\n $('body').on('click', '.prompt-archive-variant', function() {\n var variantId = $(this).attr('data-record-id'),\n productId = $(this).attr('data-secondary-record-id');\n\n seller_admin.base.assignConfirmationModal('archive-variant',\n 'Are you sure you wish to remove a variant?', variantId, productId);\n seller_admin.base.enableConfirmationModal();\n return false;\n });\n $('body').on('click', '.archive-variant', function () {\n var $this = $(this),\n variantId = $this.attr('data-record-id'),\n productId = $this.attr('data-secondary-record-id');\n\n seller_admin.base.disableConfirmationModal();\n seller_admin.base.assignLoadingModal(\"loadingArchiveVariant\", \"Archiving variant...\");\n seller_admin.base.enableLoadingModal(\"#loadingArchiveVariant\", $this);\n\n $.ajax(\n {\n url: '/admin/products/' + productId + '/variants/' + variantId + '/archive',\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('tr#variant-' + variantId).remove();\n seller_admin.base.addCustomFlash('#variants-section', 'success', 'Successfully archived a variant for your product.');\n seller_admin.base.disableLoadingModal(\"#loadingArchiveVariant\", $this);\n seller_admin.base.scrollTop('#variants-section');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingArchiveVariant\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n initTagit: function () {\n $('.option-type-tagit').tagit({\n singleField: true,\n allowSpaces: true,\n afterTagAdded: function (event, ui) {\n seller_admin.variant.refreshVariants();\n },\n afterTagRemoved: function (event, ui) {\n seller_admin.variant.refreshVariants();\n }\n });\n\n },\n\n addOptionType: function () {\n $('body').on('click', '#add-option-type', function () {\n var $this = $(this);\n\n seller_admin.base.assignLoadingModal(\"loadingAddOptionType\", \"Creating option...\");\n seller_admin.base.enableLoadingModal(\"#loadingAddOptionType\", $this);\n\n $.ajax(\n {\n url: '/admin/products/option_types/new',\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n if ($('.option-type-cluster').length < 3) {\n $('#option-types').append(data.fields);\n }\n seller_admin.variant.optionTypeFull();\n seller_admin.base.disableLoadingModal(\"#loadingAddOptionType\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingAddOptionType\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n removeOptionType: function () {\n $('body').on('click', '.remove-option-type', function () {\n $(this).parent().parent().parent().remove();\n\n seller_admin.variant.optionTypeFull();\n seller_admin.variant.refreshVariants();\n return false;\n });\n },\n\n optionTypeFull: function () {\n if ($('.option-type-cluster').length === 3) {\n $('#add-option-type').hide();\n } else {\n $('#add-option-type').show();\n }\n },\n\n refreshVariants: function () {\n var variantJson = {},\n masterVariantPrice = $('#master-variant-price').val(),\n masterVariantStock = $('#master-variant-stock').val(),\n productSku = $('#product_sku').val(),\n $this = $(this);\n\n $('.option-type-cluster').each(function () {\n var optionType = $(this).find('.option-type').val(),\n optionValue = $(this).find('.option-values').val();\n\n if (optionType && optionValue) {\n variantJson[optionType] = optionValue;\n }\n });\n if (Object.keys(variantJson).length > 0) {\n seller_admin.base.assignLoadingModal(\"loadingUpdateVariants\", \"Updating variants...\");\n seller_admin.base.enableLoadingModal(\"#loadingUpdateVariants\", $this);\n $.ajax(\n {\n url: '/admin/products/variants/collection',\n type: \"POST\",\n data: {\n variant: {variants: variantJson},\n master_price: masterVariantPrice,\n master_stock: masterVariantStock,\n product_sku: productSku\n },\n dataType: \"json\",\n success: function (data) {\n $('#new_variants tbody').html(data.new_collection);\n seller_admin.base.disableLoadingModal(\"#loadingUpdateVariants\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUpdateVariants\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n } else {\n $('#new_variants tbody').html('');\n }\n },\n\n sortEditOptionTypesModal: function () {\n $('body').on('click', '#reorder-option-types', function () {\n var url = $(this).attr('href');\n\n\n seller_admin.base.assignLoadingModal(\"loadingSortOptionValues\", \"Sorting option types...\");\n seller_admin.base.enableLoadingModal(\"#loadingSortOptionValues\", $('#sort-option-types-form'));\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#sort-option-types-wrapper').html(data.modal);\n seller_admin.base.openModal('#sort-option-types-form');\n seller_admin.base.disableLoadingModal(\"#loadingSortOptionValues\", $('#sort-option-types-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortOptionValues\", $('#sort-option-types-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n initOptionTypeSortable: function () {\n $('#sortable-option-type-list').sortable({\n placeholder: \"ui-state-highlight\",\n forcePlaceholderSize: true,\n tolerance: \"pointer\",\n update: function (e, ui) {\n seller_admin.base.enableLoadingModal(\"#loadingSortOptionValues\", $('#sort-option-types-form'));\n $.ajax(\n {\n url: $(this).data(\"url\"),\n type: \"PATCH\",\n data: $(this).sortable('serialize'),\n success: function (data) {\n $('#variants-table').html(data.table);\n $('#variant-value-reorder-links').html(data.reorder_links);\n seller_admin.base.disableLoadingModal(\"#loadingSortOptionValues\", $('#sort-option-types-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortOptionValues\", $('#sort-option-types-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n });\n $(\"#sortable-option-type-list\").disableSelection();\n },\n\n sortEditOptionValuesModal: function () {\n $('body').on('click', '.reorder-option-values', function () {\n var $this = $(this),\n url = $this.attr('href'),\n optionTypeName = $this.attr('data-option-type-name');\n\n seller_admin.base.assignLoadingModal(\"loadingSortOptionValues\", \"Sorting \" + optionTypeName + \" values...\");\n seller_admin.base.enableLoadingModal(\"#loadingSortOptionValues\", $('#sort-option-values-form'));\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#sort-option-values-wrapper').html(data.modal);\n seller_admin.base.openModal('#sort-option-values-form');\n seller_admin.base.disableLoadingModal(\"#loadingSortOptionValues\", $('#sort-option-values-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortOptionValues\", $('#sort-option-values-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n initSortableOptionValueList: function () {\n $('#sortable-option-value-list').sortable({\n placeholder: \"ui-state-highlight\",\n forcePlaceholderSize: true,\n tolerance: \"pointer\",\n update: function (e, ui) {\n seller_admin.base.enableLoadingModal(\"#loadingSortOptionValues\", $('#sort-option-values-form'));\n $.ajax(\n {\n url: $(this).data(\"url\"),\n type: \"PATCH\",\n data: $(this).sortable('serialize'),\n success: function (data) {\n $('#variants-table').html(data.table);\n $('#variant-value-reorder-links').html(data.reorder_links);\n seller_admin.base.disableLoadingModal(\"#loadingSortOptionValues\", $('#sort-option-values-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortOptionValues\", $('#sort-option-values-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n });\n $(\"#sortable-option-value-list\").disableSelection();\n },\n\n createModalOptiontype: function () {\n $('body').on('click', '#add-option-type-edit-product', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingAddOptionType\", \"Creating option...\");\n seller_admin.base.enableLoadingModal(\"#loadingAddOptionType\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#add-option-types-wrapper').html(data.modal);\n seller_admin.base.openModal('#add-option-type-form');\n seller_admin.base.disableLoadingModal(\"#loadingAddOptionType\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingAddOptionType\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n createOptionType: function () {\n $(\"body\").on(\"submit\", '#create-option-type', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingAddOptionType\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $(this).serialize(),\n dataType: 'json',\n success: function (data) {\n $('#add-option-type-form').modal('hide');\n $('#variants-table').html(data.table);\n $('#variant-value-reorder-links').html(data.reorder_links);\n seller_admin.base.addCustomFlash('#variants-section', 'success', 'Successfully created an option type from your product.');\n seller_admin.base.disableLoadingModal(\"#loadingAddOptionType\", $this);\n seller_admin.base.scrollTop(\"#variants-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingAddOptionType\", $this);\n }\n });\n return false;\n });\n },\n\n removeModalOptiontype: function () {\n $('body').on('click', '#remove-option-type-edit-product', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingRemoveOptionType\", \"Removing option type...\");\n seller_admin.base.enableLoadingModal(\"#loadingRemoveOptionType\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#remove-option-types-wrapper').html(data.modal);\n seller_admin.base.openModal('#remove-option-type-form');\n $('#remove-option-type .mdb-select').materialSelect();\n $('#remove-option-type .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingRemoveOptionType\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingRemoveOptionType\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n removeModalOptiontypeSubmit: function () {\n $(\"body\").on(\"submit\", '#remove-option-type', function () {\n var $this = $(this),\n productId = $('#product_id').val(),\n optionTypeId = $('#option_type_id').val();\n\n seller_admin.base.enableLoadingModal(\"#loadingRemoveOptionType\", $this);\n\n $.ajax(\n {\n url: '/admin/products/' + productId + '/option_types/' + optionTypeId,\n type: 'DELETE',\n dataType: 'json',\n success: function (data) {\n $('#remove-option-type-form').modal('hide');\n $('#variants-wrapper').html(data.variant_edit_product_form);\n $('#variant-value-reorder-links').html(data.reorder_links);\n seller_admin.base.addCustomFlash('#variants-section', 'success', 'Successfully removed an option type from your product.');\n seller_admin.base.disableLoadingModal(\"#loadingRemoveOptionType\", $this);\n seller_admin.base.scrollTop(\"#variants-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingRemoveOptionType\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n }","seller_admin.order =\n {\n selectAllOrders: function () {\n $(\"#check_all_orders\").on('click', function () {\n $('.order_checkbox').prop('checked', this.checked);\n });\n },\n\n selectAllOrderAttributes: function () {\n $('#order_csv_attribute_select_all').on('click', function () {\n $('.order_csv_attribute_checkbox').prop('checked', this.checked);\n });\n },\n\n openCsvReportModal: function () {\n $('#export-order-csv-button').on('click', function () {\n var $this = $(this);\n $('.csv-report-flash').remove();\n\n seller_admin.base.assignLoadingModal(\"loadingCreateOrderCSVReport\", \"Creating CSV report for your orders...\");\n seller_admin.base.enableLoadingModal(\"#loadingCreateOrderCSVReport\", $this);\n\n var orderIds = [];\n $.each($(\".order_checkbox:checked\"), function () {\n orderIds.push($(this).val());\n });\n if (orderIds.length === 0) {\n seller_admin.base.addFlash(\"warning csv-report-flash\", \"You need to select some orders before requesting a CSV report.\");\n seller_admin.base.disableLoadingModal(\"#loadingCreateOrderCSVReport\", $this);\n seller_admin.base.scrollTop(\"main\");\n } else {\n seller_admin.base.disableLoadingModal(\"#loadingCreateOrderCSVReport\", $(this));\n seller_admin.base.openModal('#create-order-csv-form');\n }\n return false;\n });\n },\n\n createCsvReport: function () {\n $('body').on('submit', '#create-order-csv', function () {\n var $this = $(this);\n\n $('#create-order-csv .json-error-wrapper').hide();\n $('#create-order-csv .json-error-wrapper #errors ul').empty();\n\n seller_admin.base.assignLoadingModal(\"loadingCreateOrderCSVReport\", \"Creating CSV report for your orders...\");\n seller_admin.base.enableLoadingModal(\"#loadingCreateOrderCSVReport\", $('#create-order-csv-form'));\n var orderIds = [];\n $.each($(\".order_checkbox:checked\"), function () {\n orderIds.push($(this).val());\n });\n var attributeValues = []\n $.each($(\".order_csv_attribute_checkbox:checked\"), function () {\n attributeValues.push($(this).val());\n });\n if (attributeValues.length === 0) {\n seller_admin.base.customJsonErrors(['Please select at least one checkbox.'], $('#create-order-csv-form'));\n seller_admin.base.disableLoadingModal(\"#loadingCreateOrderCSVReport\", $('#create-order-csv-form'));\n } else {\n $.ajax(\n {\n url: '/admin/order_csvs',\n type: 'POST',\n data: {\n 'order_ids': orderIds,\n 'selected_attributes': attributeValues\n },\n dataType: 'json',\n success: function (data) {\n seller_admin.base.addFlash(\"success csv-report-flash\", \"Successfully created the CSV report. Please check your store email for a link to the file.\");\n seller_admin.base.disableLoadingModal(\"#loadingCreateOrderCSVReport\", $('#create-order-csv-form'));\n $('#create-order-csv-form').modal('hide');\n seller_admin.base.scrollTop(\"main\");\n $('.order_checkbox').prop('checked', false);\n $('.order_csv_attribute_checkbox').prop('checked', false);\n $('#check_all_orders').prop('checked', false);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingCreateOrderCSVReport\", $('#create-order-csv-form'));\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n }\n });\n }\n return false;\n });\n },\n\n createSingleEmailPdf: function () {\n $('#create-email-pdf').on('click', function () {\n var $this = $(this),\n orderId = $this.attr('data-order-id');\n $('.email-pdf-flash').remove();\n\n\n seller_admin.base.assignLoadingModal(\"loadingCreateOrderEmailPdf\", \"Creating Email PDF for your order...\");\n seller_admin.base.enableLoadingModal(\"#loadingCreateOrderEmailPdf\", $this);\n\n $.ajax(\n {\n url: '/admin/order_email_pdfs/shop',\n type: 'POST',\n data: {'order_ids': [orderId]},\n dataType: 'json',\n success: function (data) {\n seller_admin.base.addFlash(\"success email-pdf-flash\", \"Successfully created an Email PDF. Please check your email for a link to the file.\");\n seller_admin.base.disableLoadingModal(\"#loadingCreateOrderEmailPdf\", $this);\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"warning email-pdf-flash\", \"Unable to create an Email PDF. Please try again.\");\n seller_admin.base.disableLoadingModal(\"#loadingCreateOrderEmailPdf\", $this);\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n createCombinedEmailPdf: function () {\n $('#export-pdfs-button').on('click', function () {\n var $this = $(this);\n $('.export-pdfs-flash').remove();\n\n\n seller_admin.base.assignLoadingModal(\"loadingCreateCombinedPDF\", \"Creating combined PDF invoice for your orders...\");\n seller_admin.base.enableLoadingModal(\"#loadingCreateCombinedPDF\", $this);\n\n var orderIds = [];\n $.each($(\".order_checkbox:checked\"), function () {\n orderIds.push($(this).val());\n });\n if (orderIds.length === 0) {\n seller_admin.base.addFlash(\"warning export-pdfs-flash\", \"You need to select some orders before requesting a combined PDF invoice.\");\n seller_admin.base.disableLoadingModal(\"#loadingCreateCombinedPDF\", $this);\n seller_admin.base.scrollTop(\"main\");\n } else {\n $.ajax(\n {\n url: '/admin/order_email_pdfs/shop',\n type: 'POST',\n data: {'order_ids': orderIds},\n dataType: 'json',\n success: function (data) {\n seller_admin.base.addFlash(\"success export-pdfs-flash\", \"Successfully created a combined PDF invoice. Please check your store email for a link to the file.\");\n seller_admin.base.disableLoadingModal(\"#loadingCreateCombinedPDF\", $this);\n seller_admin.base.scrollTop(\"main\");\n $('.order_checkbox').prop('checked', false);\n $('#check_all_orders').prop('checked', false);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"warning export-pdfs-flash\", \"Unable to create a combined PDF invoice. Please try again.\");\n seller_admin.base.disableLoadingModal(\"#loadingCreateCombinedPDF\", $this);\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n return false;\n });\n },\n\n retryPayment: function () {\n $('body').on('click', '.retry-payment', function () {\n var url = $(this).attr('href'),\n $this = $(this);\n\n seller_admin.base.assignLoadingModal(\"loadingRetryPaymentOrder\", \"Retrying payment for your order...\");\n seller_admin.base.enableLoadingModal(\"#loadingRetryPaymentOrder\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('#order-payment-status').text('Completed');\n $('.retry-payment').remove();\n seller_admin.base.disableLoadingModal(\"#loadingRetryPaymentOrder\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully captured payment for the order. Updates will appear momentarily.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n var error = $.parseJSON(xhr.responseText).error;\n seller_admin.base.disableLoadingModal(\"#loadingRetryPaymentOrder\", $this);\n seller_admin.base.addFlash(\"warning\", error);\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n shopSingleFulfillOrder: function () {\n $('#fulfill-shop-order').on('click', function () {\n var $this = $(this),\n orderId = $this.attr('data-order-id');\n\n $('.fulfilled-flash').remove();\n\n seller_admin.base.assignLoadingModal(\"loadingSingleFulfillShopOrder\", \"Sending your order to be fulfilled...\");\n seller_admin.base.enableLoadingModal(\"#loadingSingleFulfillShopOrder\", $this);\n\n $.ajax(\n {\n url: '/admin/orders/shop/fulfillment/single_order',\n type: 'POST',\n data: {'order_id': orderId},\n dataType: 'json',\n success: function (data) {\n $('#order-fulfillment-status').text('Completed');\n $('#fulfill-shop-order').remove();\n seller_admin.base.addFlash(\"success fulfilled-flash\", \"Your order has been successfully fulfilled.\");\n seller_admin.base.disableLoadingModal(\"#loadingSingleFulfillShopOrder\", $this);\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"warning fulfilled-flash\", \"Unable to send your order for fulfillment. Please try again.\");\n seller_admin.base.disableLoadingModal(\"#loadingSingleFulfillShopOrder\", $this);\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n shopMarkSingleAsShipped: function () {\n $('#mark-shop-as-shipped').on('click', function () {\n var $this = $(this),\n orderId = $this.attr('data-order-id');\n $('.shipped-flash').remove();\n\n seller_admin.base.assignLoadingModal(\"loadingMarkSingleShopShipped\", \"Marking your order as shipped...\");\n seller_admin.base.enableLoadingModal(\"#loadingMarkSingleShopShipped\", $this);\n\n $.ajax(\n {\n url: '/admin/orders/shop/shipping/bulk',\n type: 'POST',\n data: {'order_ids': [orderId]},\n dataType: 'json',\n success: function (data) {\n seller_admin.base.addFlash(\"success shipped-flash\", \"Your order has been marked as shipped.\");\n seller_admin.base.disableLoadingModal(\"#loadingMarkSingleShopShipped\", $this);\n seller_admin.base.scrollTop(\"main\");\n $('#mark-shop-as-shipped').remove();\n $('#order-shipping-status').text('Completed');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"warning shipped-flash\", \"Unable to mark your order as shipped. Please try again.\");\n seller_admin.base.disableLoadingModal(\"#loadingMarkSingleShopShipped\", $this);\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n singleFulfillOrder: function () {\n $('#fulfill-subscription-order').on('click', function () {\n var $this = $(this),\n orderId = $this.attr('data-order-id');\n\n $('.fulfilled-flash').remove();\n\n seller_admin.base.assignLoadingModal(\"loadingSingleFulfillSubscriptionOrder\", \"Sending your order to be fulfilled...\");\n seller_admin.base.enableLoadingModal(\"#loadingSingleFulfillSubscriptionOrder\", $this);\n\n $.ajax(\n {\n url: '/admin/orders/subscription/fulfillment/single',\n type: 'POST',\n data: {'order_id': orderId},\n dataType: 'json',\n success: function (data) {\n $('#order-fulfillment-status').text('Completed');\n $('#fulfill-subscription-order').remove();\n seller_admin.base.addFlash(\"success fulfilled-flash\", \"Your order has been successfully fulfilled.\");\n seller_admin.base.disableLoadingModal(\"#loadingSingleFulfillSubscriptionOrder\", $this);\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"warning fulfilled-flash\", \"Unable to send your order for fulfillment. Please try again.\");\n seller_admin.base.disableLoadingModal(\"#loadingSingleFulfillSubscriptionOrder\", $this);\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n bulkFulfillOrder: function () {\n $('#fulfill-subscription-orders').on('click', function () {\n var $this = $(this);\n $('.fulfilled-flash').remove();\n\n seller_admin.base.assignLoadingModal(\"loadingFulfillSubscriptionOrders\", \"Sending your orders to be fulfilled...\");\n seller_admin.base.enableLoadingModal(\"#loadingFulfillSubscriptionOrders\", $this);\n\n var orderIds = [];\n $.each($(\".order_checkbox:checked\"), function () {\n orderIds.push($(this).val());\n });\n if (orderIds.length === 0) {\n seller_admin.base.addFlash(\"warning fulfilled-flash\", \"You need to select some orders before sending them to be fulfilled.\");\n seller_admin.base.disableLoadingModal(\"#loadingFulfillSubscriptionOrders\", $this);\n seller_admin.base.scrollTop(\"main\");\n } else {\n $.ajax(\n {\n url: '/admin/orders/subscription/fulfillment/bulk',\n type: 'POST',\n data: {'order_ids': orderIds},\n dataType: 'json',\n success: function (data) {\n seller_admin.base.addFlash(\"success fulfilled-flash\", \"Your orders are being fulfilled now. When completed, you will be notified via email. You can safely leave this screen and return at any time.\");\n seller_admin.base.disableLoadingModal(\"#loadingFulfillSubscriptionOrders\", $this);\n seller_admin.base.scrollTop(\"main\");\n $('.order_checkbox').prop('checked', false);\n $('#check_all_orders').prop('checked', false);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"warning fulfilled-flash\", \"Unable to send your orders for fulfillment. Please try again.\");\n seller_admin.base.disableLoadingModal(\"#loadingFulfillSubscriptionOrders\", $this);\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n return false;\n });\n },\n\n markSingleAsShipped: function () {\n $('#mark-subscription-as-shipped').on('click', function () {\n var $this = $(this),\n orderId = $this.attr('data-order-id');\n $('.shipped-flash').remove();\n\n seller_admin.base.assignLoadingModal(\"loadingMarkSingleSubscriptionShipped\", \"Marking your order as shipped...\");\n seller_admin.base.enableLoadingModal(\"#loadingMarkSingleSubscriptionShipped\", $this);\n\n $.ajax(\n {\n url: '/admin/orders/subscription/shipping/bulk',\n type: 'POST',\n data: {'order_ids': [orderId]},\n dataType: 'json',\n success: function (data) {\n seller_admin.base.addFlash(\"success shipped-flash\", \"Your order has been marked as shipped.\");\n seller_admin.base.disableLoadingModal(\"#loadingMarkSingleSubscriptionShipped\", $this);\n seller_admin.base.scrollTop(\"main\");\n $('#mark-subscription-as-shipped').remove();\n $('#order-shipping-status').text('Completed');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"warning shipped-flash\", \"Unable to mark your order as shipped. Please try again.\");\n seller_admin.base.disableLoadingModal(\"#loadingMarkSingleSubscriptionShipped\", $this);\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n markCollectionAsShipped: function () {\n $('#mark-subscriptions-as-shipped').on('click', function () {\n var $this = $(this);\n $('.shipped-flash').remove();\n\n seller_admin.base.assignLoadingModal(\"loadingMarkSubscriptionsShipped\", \"Marking your orders as shipped...\");\n seller_admin.base.enableLoadingModal(\"#loadingMarkSubscriptionsShipped\", $this);\n\n var orderIds = [];\n $.each($(\".order_checkbox:checked\"), function () {\n orderIds.push($(this).val());\n });\n if (orderIds.length === 0) {\n seller_admin.base.addFlash(\"warning shipped-flash\", \"You need to select some orders before marking them as shipped.\");\n seller_admin.base.disableLoadingModal(\"#loadingMarkSubscriptionsShipped\", $this);\n seller_admin.base.scrollTop(\"main\");\n } else {\n $.ajax(\n {\n url: '/admin/orders/subscription/shipping/bulk',\n type: 'POST',\n data: {'order_ids': orderIds},\n dataType: 'json',\n success: function (data) {\n if (data.order_ids !== undefined) {\n for (_i = 0, _len = data.order_ids.length; _i < _len; _i++) {\n value = data.order_ids[_i]\n $('tr.order_' + value + ' td.shipping-status').text('Completed');\n }\n }\n seller_admin.base.addFlash(\"success shipped-flash\", \"Your orders have been marked as shipped.\");\n seller_admin.base.disableLoadingModal(\"#loadingMarkSubscriptionsShipped\", $this);\n seller_admin.base.scrollTop(\"main\");\n $('.order_checkbox').prop('checked', false);\n $('#check_all_orders').prop('checked', false);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"warning shipped-flash\", \"Unable to mark your orders as shipped. Please try again.\");\n seller_admin.base.disableLoadingModal(\"#loadingMarkSubscriptionsShipped\", $this);\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n return false;\n });\n },\n\n pickedUpOrder: function () {\n $('body').on('click', '#prompt-picked-up-order', function () {\n var orderId = $(this).attr('data-record-id');\n\n seller_admin.base.assignConfirmationModal('picked-up-order',\n 'Are you sure you wish to mark this order with a successful picked up status?', orderId);\n seller_admin.base.enableConfirmationModal();\n return false;\n });\n\n $('body').on('click', '.picked-up-order', function () {\n var $this = $(this),\n orderId = $this.attr('data-record-id');\n\n seller_admin.base.disableConfirmationModal();\n seller_admin.base.assignLoadingModal(\"loadingOrderPickedUp\", \"Marking order with successful pick up...\");\n seller_admin.base.enableLoadingModal(\"#loadingOrderPickedUp\", $this);\n\n $.ajax(\n {\n url: '/admin/orders/picked_up/' + orderId,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('#pick-up-status').text('Completed');\n seller_admin.base.addFlash('success', 'Successfully marked the order with a successful picked up status.');\n seller_admin.base.disableLoadingModal(\"#loadingOrderPickedUp\", $this);\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingOrderPickedUp\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n }\n","seller_admin.subscription = {\n\n createSingleEmailPdf: function () {\n $('#create-subscription-email-pdf').on('click', function () {\n var $this = $(this),\n orderId = $this.attr('data-order-id');\n $('.email-pdf-flash').remove();\n\n\n seller_admin.base.assignLoadingModal(\"loadingCreateOrderEmailPdf\", \"Creating Email PDF for your order...\");\n seller_admin.base.enableLoadingModal(\"#loadingCreateOrderEmailPdf\", $this);\n\n $.ajax(\n {\n url: '/admin/order_email_pdfs/subscription',\n type: 'POST',\n data: {'order_ids': [orderId]},\n dataType: 'json',\n success: function (data) {\n seller_admin.base.addFlash(\"success email-pdf-flash\", \"Successfully created an Email PDF. Please check your email for a link to the file.\");\n seller_admin.base.disableLoadingModal(\"#loadingCreateOrderEmailPdf\", $this);\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"warning email-pdf-flash\", \"Unable to create an Email PDF. Please try again.\");\n seller_admin.base.disableLoadingModal(\"#loadingCreateOrderEmailPdf\", $this);\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n createCombinedEmailPdf: function () {\n $('#export-subscription-pdfs-button').on('click', function () {\n var $this = $(this);\n $('.export-pdfs-flash').remove();\n\n seller_admin.base.assignLoadingModal(\"loadingCreateCombinedPDF\", \"Creating combined PDF invoice for your orders...\");\n seller_admin.base.enableLoadingModal(\"#loadingCreateCombinedPDF\", $this);\n\n var orderIds = [];\n $.each($(\".order_checkbox:checked\"), function () {\n orderIds.push($(this).val());\n });\n if (orderIds.length === 0) {\n seller_admin.base.addFlash(\"warning export-pdfs-flash\", \"You need to select some orders before requesting a combined PDF invoice.\");\n seller_admin.base.disableLoadingModal(\"#loadingCreateCombinedPDF\", $this);\n seller_admin.base.scrollTop(\"main\");\n } else {\n $.ajax(\n {\n url: '/admin/order_email_pdfs/subscription',\n type: 'POST',\n data: {'order_ids': orderIds},\n dataType: 'json',\n success: function (data) {\n seller_admin.base.addFlash(\"success export-pdfs-flash\", \"Successfully created a combined PDF invoice. Please check your store email for a link to the file.\");\n seller_admin.base.disableLoadingModal(\"#loadingCreateCombinedPDF\", $this);\n seller_admin.base.scrollTop(\"main\");\n $('.order_checkbox').prop('checked', false);\n $('#check_all_orders').prop('checked', false);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"warning export-pdfs-flash\", \"Unable to create a combined PDF invoice. Please try again.\");\n seller_admin.base.disableLoadingModal(\"#loadingCreateCombinedPDF\", $this);\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n return false;\n });\n },\n\n pause: function()\n {\n $('body').on('click', '.pause-customer-subscription', function () {\n var modalId = $(this).attr('data-modal-id'),\n $this = $('#' + modalId),\n pauseDateTime = $(this).attr('data-pause-timestamp'),\n subscriptionId = $(this).attr('data-subscription-id');\n\n seller_admin.base.assignLoadingModal(\"loadingPauseCustomerSubscription\", \"Pausing subscription...\");\n seller_admin.base.enableLoadingModal(\"#loadingPauseCustomerSubscription\", $this);\n\n $.ajax(\n {\n url: '/admin/customers/stripe/subscriptions/' + subscriptionId +'/pause',\n type: 'PATCH',\n data: { pause_datetime: pauseDateTime },\n dataType: 'json',\n success: function (data) {\n $('#pause-customer-subscription').remove();\n $('.subscription-status-badge').replaceWith('
Paused');\n $('#customer-unpause-subscription').show();\n $('#next-rebill-wrapper').text(data.resume_paused_at);\n seller_admin.base.disableLoadingModal(\"#loadingPauseCustomerSubscription\", $this);\n $('#' + modalId).modal('hide');\n seller_admin.base.addFlash(\"success\", \"Successfully paused this subscription. Payments will resume on \" + data.resume_paused_at_datetime + \".\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingPauseCustomerSubscription\", $this);\n $('#' + modalId).modal('hide');\n seller_admin.base.addFlash(\"danger\", \"Failed to pause subscription, please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n}","seller_admin.transaction =\n {\n newRefund: function () {\n $('body').on('click', '.create-transaction-refund', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingRefundTransaction\", \"Creating your refund...\");\n seller_admin.base.enableLoadingModal(\"#loadingRefundTransaction\", $this);\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#transaction-refund-modal').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingRefundTransaction\", $this);\n seller_admin.base.openModal('#transaction-refund-form');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingRefundTransaction\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n createRefund: function () {\n $('body').on('submit', '.transaction-refund-form', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingRefundTransaction\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#transaction-refund-form').modal('hide');\n $('#refunds-table tbody').prepend(data.row);\n seller_admin.base.disableLoadingModal(\"#loadingRefundTransaction\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully created a refund for this order.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingRefundTransaction\", $this);\n }\n });\n return false;\n });\n }\n }","seller_admin.tax_rule =\n {\n add: function () {\n $('body').on('click', '.create-tax-rule', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingAddTaxRule\", \"Creating tax rule...\");\n seller_admin.base.enableLoadingModal(\"#loadingAddTaxRule\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#tax-rule-modal').html(data.modal);\n seller_admin.base.openModal('#tax-rule-form');\n $('#tax-rule-modal .mdb-select').materialSelect();\n $('#tax-rule-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingAddTaxRule\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingAddTaxRule\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n create: function () {\n $('body').on('submit', '#create-tax-rule', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingAddTaxRule\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#tax-rule-form').modal('hide');\n $('#tax-rules-table tbody').prepend(data.tax_rule_row);\n seller_admin.base.addCustomFlash('#tax-rules-section', 'success', 'Successfully added a tax rule to your store.');\n seller_admin.base.disableLoadingModal(\"#loadingAddTaxRule\", $this);\n seller_admin.base.scrollTop('#tax-rules-section');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingAddTaxRule\", $this);\n }\n });\n return false;\n });\n },\n\n edit: function () {\n $('body').on('click', '.edit-tax-rule', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingEditTaxRule\", \"Updating tax rule...\");\n seller_admin.base.enableLoadingModal(\"#loadingEditTaxRule\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#tax-rule-modal').html(data.modal);\n seller_admin.base.openModal('#tax-rule-form');\n $('#tax-rule-modal .mdb-select').materialSelect();\n $('#tax-rule-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingEditTaxRule\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingEditTaxRule\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n update: function () {\n $('body').on('submit', '#edit-tax-rule', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingEditTaxRule\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#tax-rule-form').modal('hide');\n $('#tax-rules-table tbody tr#tax-rule-' + data.tax_rule_id).replaceWith(data.tax_rule_row);\n seller_admin.base.addCustomFlash('#tax-rules-section', 'success', 'Successfully updated a tax rule for your store.');\n seller_admin.base.disableLoadingModal(\"#loadingEditTaxRule\", $this);\n seller_admin.base.scrollTop('#tax-rules-section');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingEditTaxRule\", $this);\n }\n });\n return false;\n });\n },\n\n archive: function()\n {\n $('body').on('click', '.archive-tax-rule', function () {\n var $this = $(this),\n url = $this.attr('href'),\n taxRuleId = $this.attr('data-tax-rule-id');\n\n seller_admin.base.assignLoadingModal(\"loadingArchiveTaxRule\", \"Archiving tax rule from your store...\");\n seller_admin.base.enableLoadingModal(\"#loadingArchiveTaxRule\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('tr#tax-rule-' + taxRuleId).remove();\n seller_admin.base.addCustomFlash('#tax-rules-section', 'success', 'Successfully archived a tax rule from your store.');\n seller_admin.base.disableLoadingModal(\"#loadingArchiveTaxRule\", $this);\n seller_admin.base.scrollTop('#tax-rules-section');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingArchiveTaxRule\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n }","seller_admin.email_integration =\n {\n revealApiKey: function () {\n $('.reveal-api-key').on('click', function () {\n $('#email-integration-api-key').removeClass('blur');\n $('.hide-api-key').show();\n $('.reveal-api-key').hide();\n return false;\n });\n },\n\n hidelApiKey: function () {\n $('.hide-api-key').on('click', function () {\n $('#email-integration-api-key').addClass('blur');\n $('.reveal-api-key').show();\n $('.hide-api-key').hide();\n return false;\n });\n },\n\n add: function () {\n $('body').on('click', '.create-email-integration', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingAddEmailIntegration\", \"Creating email integration...\");\n seller_admin.base.enableLoadingModal(\"#loadingAddEmailIntegration\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#email-integration-modal').html(data.modal);\n seller_admin.base.openModal('#email-integration-form');\n $('#email-integration-modal .mdb-select').materialSelect();\n $('#email-integration-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingAddEmailIntegration\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingAddEmailIntegration\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n create: function () {\n $('body').on('submit', '#create-email-integration', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingAddEmailIntegration\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#email-integration-form').modal('hide');\n $('#email-integrations-table tbody').prepend(data.email_integration_row);\n seller_admin.email_integration.updateActiveList(data.email_integration_array);\n seller_admin.base.addCustomFlash('#email-integrations-section', 'success', 'Successfully added an email integration to your store.');\n seller_admin.base.disableLoadingModal(\"#loadingAddEmailIntegration\", $this);\n seller_admin.base.scrollTop(\"#email-integrations-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingAddEmailIntegration\", $this);\n }\n });\n return false;\n });\n },\n\n edit: function () {\n $('body').on('click', '.edit-email-integration', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingEditEmailIntegration\", \"Updating email integration...\");\n seller_admin.base.enableLoadingModal(\"#loadingEditEmailIntegration\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#email-integration-modal').html(data.modal);\n seller_admin.base.openModal('#email-integration-form');\n $('#email-integration-modal .mdb-select').materialSelect();\n $('#email-integration-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingEditEmailIntegration\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingEditEmailIntegration\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n update: function () {\n $('body').on('submit', '#edit-email-integration', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#email-integration-form').modal('hide');\n $('#email-integrations-table tbody tr#email-integration-' + data.email_integration_id).replaceWith(data.email_integration_row);\n seller_admin.base.addCustomFlash('#email-integrations-section', 'success', 'Successfully updated an email integration to your store.');\n seller_admin.base.disableLoadingModal(\"#loadingEditEmailIntegration\", $this);\n seller_admin.base.scrollTop(\"#email-integrations-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingEditEmailIntegration\", $this);\n }\n });\n return false;\n });\n },\n\n updateActiveList: function (email_integration_array) {\n var $select = $('#store_email_integration_id');\n $select.empty();\n $.each(email_integration_array, function (index, option) {\n $select.append($(\"
\")\n .attr(\"value\", option.value).text(option.text));\n });\n $('#email-integration-modal .mdb-select').materialSelect({\n destroy: true\n });\n $('#email-integration-modal .mdb-select').materialSelect();\n $('#email-integration-modal .mdb-select').click(e => e.stopPropagation());\n },\n\n updateMailchimpForm: function () {\n var selectElem = $('#create-email-integration #email_integration_provider');\n if (selectElem.val() === 'mailchimp')\n {\n\n $('#create-email-integration #account-id-wrapper').hide().val('');\n }\n $('body').on('change', '#create-email-integration #email_integration_provider', function() {\n if ($(this).val() === 'mailchimp') {\n $('#create-email-integration #account-id-wrapper').hide().val('');\n } else {\n $('#create-email-integration #account-id-wrapper').show();\n }\n });\n },\n\n remove: function()\n {\n $('body').on('click', '.prompt-remove-email-integration', function() {\n var emailIntegrationId = $(this).attr('data-record-id');\n\n seller_admin.base.assignConfirmationModal('remove-email-integration',\n 'Are you sure you wish to remove your email integration?', emailIntegrationId);\n seller_admin.base.enableConfirmationModal();\n return false;\n });\n $('body').on('click', '.remove-email-integration', function () {\n var $this = $(this),\n emailIntegrationId = $this.attr('data-record-id');\n\n seller_admin.base.disableConfirmationModal();\n seller_admin.base.assignLoadingModal(\"loadingRemoveEmailIntegration\", \"Removing email integration from your store...\");\n seller_admin.base.enableLoadingModal(\"#loadingRemoveEmailIntegration\", $this);\n\n $.ajax(\n {\n url: '/admin/email_integrations/' + emailIntegrationId,\n type: 'DELETE',\n dataType: 'json',\n success: function (data) {\n $('tr#email-integration-' + emailIntegrationId).remove();\n seller_admin.base.addCustomFlash('#email-integrations-section', 'success', 'Successfully removed an email integration from your store.');\n seller_admin.base.disableLoadingModal(\"#loadingRemoveEmailIntegration\", $this);\n seller_admin.base.scrollTop(\"#email-integrations-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingRemoveEmailIntegration\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n }\n\n\n","seller_admin.email_integration_rule =\n {\n\n add: function () {\n $('body').on('click', '.create-email-integration-rule', function () {\n var $this = $(this),\n url = $this.attr('data-url');\n\n seller_admin.base.assignLoadingModal(\"loadingAddEmailIntegrationRule\", \"Creating email integration rule...\");\n seller_admin.base.enableLoadingModal(\"#loadingAddEmailIntegrationRule\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#email-integration-rule-modal').html(data.modal);\n seller_admin.base.openModal('#email-integration-rule-form');\n $('#email-integration-rule-modal .mdb-select').materialSelect();\n $('#email-integration-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingAddEmailIntegrationRule\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingAddEmailIntegrationRule\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n create: function () {\n $('body').on('submit', '#create-email-integration-rule', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingAddEmailIntegrationRule\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#email-integration-rule-form').modal('hide');\n $('#email-integration-rules-table tbody').prepend(data.row);\n seller_admin.base.addCustomFlash('#email-integration-rules-section', 'success', 'Successfully added an email integration rule to your ' + data.provider + ' provider.');\n seller_admin.base.disableLoadingModal(\"#loadingAddEmailIntegrationRule\", $this);\n seller_admin.base.scrollTop(\"#email-integration-rules-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingAddEmailIntegrationRule\", $this);\n }\n });\n return false;\n });\n },\n\n edit: function () {\n $('body').on('click', '.edit-email-integration-rule', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingEditEmailIntegrationRule\", \"Updating an email integration rule...\");\n seller_admin.base.enableLoadingModal(\"#loadingEditEmailIntegrationRule\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#email-integration-rule-modal').html(data.modal);\n seller_admin.base.openModal('#email-integration-rule-form');\n $('#email-integration-rule-modal .mdb-select').materialSelect();\n $('#email-integration-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingEditEmailIntegrationRule\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingEditEmailIntegrationRule\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n update: function () {\n $('body').on('submit', '#edit-email-integration-rule', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingEditEmailIntegrationRule\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#email-integration-rule-form').modal('hide');\n $('#email-integration-rules-table tbody tr#email-integration-rule-' + data.integration_rule_collection_id).replaceWith(data.row);\n seller_admin.base.addCustomFlash('#email-integration-rules-section', 'success', 'Successfully updated an email integration rule to your ' + data.provider + ' provider.');\n seller_admin.base.disableLoadingModal(\"#loadingEditEmailIntegrationRule\", $this);\n seller_admin.base.scrollTop(\"#email-integration-rules-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingEditEmailIntegrationRule\", $this);\n }\n });\n return false;\n });\n },\n\n remove: function()\n {\n $('body').on('click', '.remove-email-integration-rule', function () {\n var $this = $(this),\n url = $this.attr('href'),\n emailIntegrationRuleId = $this.attr('data-email-integration-rule-id');\n\n seller_admin.base.assignLoadingModal(\"loadingRemoveEmailIntegrationRule\", \"Removing email integration rule from your store...\");\n seller_admin.base.enableLoadingModal(\"#loadingRemoveEmailIntegrationRule\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'DELETE',\n dataType: 'json',\n success: function (data) {\n $('tr#email-integration-rule-' + emailIntegrationRuleId).remove();\n seller_admin.base.addCustomFlash('#email-integration-rules-section', 'success', 'Successfully removed an email integration rule from your ' + data.provider + ' store integration.');\n seller_admin.base.disableLoadingModal(\"#loadingRemoveEmailIntegrationRule\", $this);\n seller_admin.base.scrollTop(\"#email-integration-rules-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingRemoveEmailIntegrationRule\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n addRule: function (link, association, content) {\n var new_id = new Date().getTime(),\n regexp = new RegExp(\"new_\" + association, \"g\");\n $(link).before(content.replace(regexp, new_id));\n var selectTags = $('div[data-fields-id=\"' + new_id + '\"] select');\n selectTags.materialSelect()\n selectTags.each(function () {\n $(this).click(e => e.stopPropagation());\n });\n },\n\n removeRule: function (link) {\n $(link).prev(\"input[type=hidden]\").val(\"1\");\n $(link).closest(\".fields\").hide();\n var wrapperElem = $(link).closest('.section');\n wrapperElem.hide();\n wrapperElem.find(\"input[type=hidden].rule-collection-destroy\").val(\"1\");\n },\n\n changeFilterType: function () {\n $('body').on('change', 'select.email-integration-rule-filter-type', function () {\n var $this = $(this),\n parentWrapper = $this.parent().parent().parent();\n seller_admin.email_integration_rule.updateConditionSelect(parentWrapper, this.value);\n if (this.value === 'cart_item') {\n parentWrapper.find('.email-integration-rule-filter-value-wrapper').show();\n parentWrapper.find('.email-integration-rule-filter-value-wrapper div label').text('Quantity');\n parentWrapper.find('.email-integration-rule-product-id-wrapper').show();\n } else if (this.value === 'cart_item_count') {\n parentWrapper.find('.email-integration-rule-filter-value-wrapper').show();\n parentWrapper.find('.email-integration-rule-filter-value-wrapper div label').text('Quantity');\n parentWrapper.find('.email-integration-rule-product-id-wrapper').hide();\n } else if (this.value === 'cart_subtotal') {\n parentWrapper.find('.email-integration-rule-filter-value-wrapper').show();\n parentWrapper.find('.email-integration-rule-filter-value-wrapper div label').text('Cart value');\n parentWrapper.find('.email-integration-rule-product-id-wrapper').hide();\n } else if (this.value === 'product_tag') {\n parentWrapper.find('.email-integration-rule-filter-value-wrapper').show();\n parentWrapper.find('.email-integration-rule-filter-value-wrapper div label').text('Filter');\n parentWrapper.find('.email-integration-rule-product-id-wrapper').hide();\n } else if (this.value === 'product_title') {\n parentWrapper.find('.email-integration-rule-filter-value-wrapper').show();\n parentWrapper.find('.email-integration-rule-filter-value-wrapper div label').text('Filter');\n parentWrapper.find('.email-integration-rule-product-id-wrapper').hide();\n } else if (this.value === 'product_collection') {\n parentWrapper.find('.email-integration-rule-filter-value-wrapper').show();\n parentWrapper.find('.email-integration-rule-filter-value-wrapper div label').text('Filter');\n parentWrapper.find('.email-integration-rule-product-id-wrapper').hide();\n }\n\n });\n },\n\n updateConditionSelect: function (parentWrapper, selectValue) {\n var conditions = window.email_integration_rule_conditions[selectValue],\n selectElem = parentWrapper.find('select.email-integration-rule-condition');\n selectElem.empty();\n for (var i = 0; i < conditions.length; i++) {\n selectElem.append('
');\n }\n }\n }\n\n\n","seller_admin.plan =\n {\n purchaseDateRebillSelect: function () {\n $(\"body\").on('change', 'select#plan_purchase_date_rebill', function () {\n var val = $(this).val();\n seller_admin.plan.purchaseDateRebillCondition(val);\n });\n },\n\n purchaseDateRebillOnLoad: function () {\n var val = $('select#plan_purchase_date_rebill').val();\n seller_admin.plan.purchaseDateRebillCondition(val);\n },\n\n purchaseDateRebillCondition: function (value) {\n if (value === 'enabled') {\n $('#plan_cutoff_day_wrapper').hide();\n $('#plan_renewal_day_wrapper').hide();\n } else {\n $('#plan_cutoff_day_wrapper').show();\n $('#plan_renewal_day_wrapper').show();\n }\n },\n\n archive: function()\n {\n $('body').on('click', '.archive-plan', function () {\n var $this = $(this),\n url = $(this).attr('href'),\n planId = $this.attr('data-plan-id'),\n planSearchTable = $('table#plan-search-table'),\n planRow = $('tr.plan-' + planId);\n\n seller_admin.base.assignLoadingModal(\"loadingArchivePlan\", \"Archiving your subscription...\");\n seller_admin.base.enableLoadingModal(\"#loadingArchivePlan\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (planSearchTable.length > 0) {\n planRow.replaceWith(data.row);\n } else {\n planRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingArchivePlan\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully archived a subscription.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingArchivePlan\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n initSortableList: function () {\n $('#sortable-product-plan-list').sortable({\n placeholder: \"ui-state-highlight\",\n forcePlaceholderSize: true,\n tolerance: \"pointer\",\n update: function (e, ui) {\n var productId = $(this).data('product-id');\n seller_admin.base.enableLoadingModal(\"#loadingSortPlan\", $('#sort-product-plans-form'));\n $.ajax(\n {\n url: $(this).data(\"url\"),\n type: \"PATCH\",\n data: $(this).sortable('serialize'),\n success: function (data) {\n $('#product-' + productId + '-plan-table tbody').html(data.table);\n seller_admin.base.disableLoadingModal(\"#loadingSortPlan\", $('#sort-product-plans-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortPlan\", $('#sort-product-plans-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n });\n $(\"#sortable-product-plan-list\").disableSelection();\n },\n\n sortModal: function () {\n $('body').on('click', '.reorder-plans', function () {\n var url = $(this).attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingSortPlan\", \"Sorting your subscriptions...\");\n seller_admin.base.enableLoadingModal(\"#loadingSortPlan\", $('#sort-product-gifts-form'));\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#sort-plans-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingSortPlan\", $('#sort-product-plans-form'));\n seller_admin.base.openModal('#sort-product-plans-form');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortPlan\", $('#sort-product-plans-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n planTypeSelect: function () {\n $(\"body\").on('change', 'select#plan_plan_type', function () {\n var val = $(this).val();\n if (val === 'custom')\n {\n\n $('#custom-interval-type-wrapper').css('display', 'flex');\n $('#custom-interval-type').materialSelect();\n $('#custom-interval-type').click(e => e.stopPropagation());\n $('#custom-interval-value-wrapper').css('display', 'flex');\n $('#custom-interval-value').materialSelect();\n $('#custom-interval-value').click(e => e.stopPropagation());\n $('#plan-rebilling').hide();\n $('#custom-interval-save').show();\n } else {\n $('#custom-interval-type-wrapper').hide();\n $('#custom-interval-value-wrapper').hide();\n $('#plan-rebilling').show();\n $('#custom-interval-save').hide();\n }\n });\n }\n }","seller_admin.gift =\n {\n archive: function()\n {\n $('body').on('click', '.archive-gift', function () {\n var $this = $(this),\n url = $this.attr('href'),\n giftId = $this.attr('data-gift-id'),\n giftSearchTable = $('table#gift-search-table'),\n giftRow = $('tr.gift-' + giftId);\n\n seller_admin.base.assignLoadingModal(\"loadingArchiveGift\", \"Archiving your gift...\");\n seller_admin.base.enableLoadingModal(\"#loadingArchiveGift\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (giftSearchTable.length > 0) {\n giftRow.replaceWith(data.row);\n } else {\n giftRow.remove();\n }\n\n seller_admin.base.disableLoadingModal(\"#loadingArchiveGift\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully archived a gift.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingArchiveGift\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n initSortableList: function () {\n $('#sortable-product-gift-list').sortable({\n placeholder: \"ui-state-highlight\",\n forcePlaceholderSize: true,\n tolerance: \"pointer\",\n update: function (e, ui) {\n var productId = $(this).data('product-id');\n seller_admin.base.enableLoadingModal(\"#loadingSortGift\", $('#sort-product-gifts-form'));\n $.ajax(\n {\n url: $(this).data(\"url\"),\n type: \"PATCH\",\n data: $(this).sortable('serialize'),\n success: function (data) {\n $('#product-' + productId + '-gift-table tbody').html(data.table);\n seller_admin.base.disableLoadingModal(\"#loadingSortGift\", $('#sort-product-gifts-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortGift\", $('#sort-product-gifts-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n });\n $(\"#sortable-product-gift-list\").disableSelection();\n },\n\n sortModal: function () {\n $('body').on('click', '.reorder-gifts', function () {\n var url = $(this).attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingSortGift\", \"Sorting your gifts...\");\n seller_admin.base.enableLoadingModal(\"#loadingSortGift\", $('#sort-product-gifts-form'));\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#sort-gifts-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingSortGift\", $('#sort-product-gifts-form'));\n seller_admin.base.openModal('#sort-product-gifts-form');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortGift\", $('#sort-product-gifts-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n }","seller_admin.stock_movement =\n {\n addFields: function (content) {\n var new_id = new Date().getTime();\n var regexp = new RegExp(\"variant_stock_movements\", \"g\")\n $('#stock-movements-fields').append(content.replace(regexp, new_id));\n $('#'+ new_id + '_attributes_'+ new_id +'_variant_id').materialSelect();\n $('#'+ new_id + '_attributes_'+ new_id +'_quantity').focus();\n },\n\n removeFields: function (link) {\n if ($('#stock-movements-fields .fields:not(.deleted)').length > 1) {\n $(link).prev(\"input[type=hidden]\").val(\"1\");\n $(link).closest(\".fields\").addClass('deleted').hide();\n }\n },\n\n createStockCollection: function () {\n $(\"body\").on(\"submit\", '#new_stock_movements', function () {\n var url = $(this).attr('action'),\n $this = $(this);\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $(this).serialize(),\n dataType: 'json',\n success: function (data) {\n $this[0].submit();\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n }\n });\n return false;\n });\n }\n }\n","seller_admin.funnel =\n {\n duplicate: function () {\n },\n\n changeFunnelType: function () {\n $('#funnel_funnel_type').on('change', function () {\n if (this.value == 'shop')\n {\n $('#standalone-product-wrapper').hide();\n $('#standard-product-wrapper').show();\n $('#standalone-landing-wrapper').hide();\n } else {\n $('#standalone-product-wrapper').show();\n $('#standard-product-wrapper').hide();\n $('#standalone-landing-wrapper').show();\n }\n });\n },\n\n scheduledPublishModal: function()\n {\n $('body').on('click', '.scheduled-funnel-publish', function () {\n var url = $(this).attr('href');\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#scheduled-funnel-publish-wrapper').html(data.modal);\n seller_admin.base.openModal('#scheduledFunnelPublishModal');\n seller_admin.base.dateTimePicker();\n\n }\n });\n return false;\n });\n },\n\n scheduledPublish: function()\n {\n $('body').on('submit', '#scheduled-funnel-publish-form', function () {\n var $this = $(this),\n url = $this.attr('action'),\n funnelId = $this.attr('data-funnel-id');\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#scheduledFunnelPublishModal').modal('hide');\n $('tr.funnel-' + funnelId + ' td.scheduled-at-column').text(data.scheduled_publish_at);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n }\n });\n return false;\n });\n }\n }","seller_admin.onboarding =\n {\n changePlan: function () {\n $(\"body\").on(\"submit\", '#change-onboarding-plan', function () {\n var url = $(this).attr('action'),\n $this = $(this);\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $(this).serialize(),\n dataType: 'json',\n success: function (data) {\n window.location.reload();\n },\n error: function (xhr, evt, status) {\n $('#change-onboarding-plan #errors').html(\"
Plan does not exist\");\n }\n });\n return false;\n });\n },\n\n termsDisablePlaceOrder: function () {\n $('#onboardingTerms').change(function () {\n if (this.checked) {\n $('#place-order-button').removeAttr('disabled');\n } else {\n $('#place-order-button').attr('disabled', 'true');\n }\n });\n },\n\n pollStoreSetupValidation: function () {\n var storeSetupPollingInterval = window.setInterval(function () {\n $.ajax(\n {\n url: '/store/validate_setup',\n type: 'GET',\n dataType: 'json',\n success: function (data) {\n window.clearInterval(storeSetupPollingInterval);\n window.redirectUrl = data.redirect_url;\n }\n });\n }, 3000);\n },\n\n storeSetupVerticalAlign: function () {\n $(function () {\n $(window).on('resize', function resize() {\n $(window).off('resize', resize);\n setTimeout(function () {\n var content = $('#store-setup-content'),\n top = (window.innerHeight - content.height()) / 2;\n content.css('top', Math.max(0, top) + 'px');\n $(window).on('resize', resize);\n }, 50);\n }).resize();\n });\n },\n\n storeSetupAnimations: function () {\n window.stepsCompleted = false;\n var stepElem = $('#store-setup-step');\n\n setTimeout(function () {\n stepElem.text('2 of 3: Initializing your store');\n setTimeout(function () {\n stepElem.text('3 of 3: Applying store settings');\n window.stepsCompleted = true;\n }, 5000);\n }, 5000);\n },\n\n storeSetupRedirect: function () {\n var redirectInterval = window.setInterval(function () {\n var validUrl = window.redirectUrl !== undefined && seller_admin.base.isValidURL(window.redirectUrl);\n if (validUrl && window.stepsCompleted === true) {\n window.clearInterval(redirectInterval);\n window.location = window.redirectUrl;\n }\n }, 1000);\n }\n }","seller_admin.notification =\n {\n bindNavbarNotifications: function (channel) {\n channel.bind('navbar_notifications', function (data) {\n $('.notifications-nav #unread-notification-count').text(data.unread_count);\n var existingNotification = $('.notifications-nav .dropdown-menu a#notification-' + data.uid);\n if (existingNotification.length < 1) {\n $('.notifications-nav .dropdown-menu').prepend(data.html);\n }\n });\n },\n\n markAsRead: function () {\n $('.notifications-nav').on('show.bs.dropdown', function () {\n var notificationIds = [];\n $('.notifications-nav .dropdown-menu a.dropdown-item[data-unread=\"true\"]').each(function () {\n notificationIds.push($(this).attr('data-notification-id'));\n $(this).attr('data-unread', 'false')\n });\n if (notificationIds.length > 0) {\n $('.notifications-nav #unread-notification-count').text(0);\n $.ajax(\n {\n url: '/admin/notifications/read',\n type: 'PATCH',\n data: {notification_ids: notificationIds},\n dataType: 'json',\n success: function (data) {\n }\n });\n }\n });\n },\n\n markAllAsRead: function () {\n $('body').on('click', '#mark-all-notifications-read', function () {\n var notificationDataIds = $(this).attr('data-notification-ids'),\n notificationIds = notificationDataIds.split(\",\").map(Number);\n if (notificationIds.length > 0) {\n $('.notifications-nav #unread-notification-count').text(0);\n $.ajax(\n {\n url: '/admin/notifications/read',\n type: 'PATCH',\n data: {notification_ids: notificationIds},\n dataType: 'json',\n success: function (data) {\n window.location.reload();\n }\n });\n }\n return false;\n });\n }\n }","seller_admin.page = {\n\n\n bindPublishNotification: function (channel) {\n channel.bind('page_publish_list', function (data) {\n var draftPage = $('table#pages-list tr#page-' + data.draft_page_id);\n if (draftPage.length > 0) {\n draftPage.find('td.page-draft-version').text(data.current_draft_version);\n draftPage.find('td.page-live-version').text(data.current_live_version);\n draftPage.find('td.page-publish-status').text(data.publish_status);\n draftPage.find('td.page-published-at').text(data.published_at);\n }\n });\n },\n\n updateNameToSlug: function () {\n var nameInput = document.getElementById('page_name'),\n slugInput = document.getElementById('page_slug'),\n slugLabel = $('label[for=\"page_slug\"]');\n\n // Init a timeout variable to be used below\n var timeout = null;\n\n // Listen for keystroke events\n if (typeof (nameInput) != 'undefined' && nameInput != null) {\n nameInput.onkeyup = function (e) {\n\n // Clear the timeout if it has already been set.\n // This will prevent the previous task from executing\n // if it has been less than
\n clearTimeout(timeout);\n\n // Make a new timeout set to go off in 800ms\n timeout = setTimeout(function () {\n if (slugInput.value === \"\") {\n slugInput.value = seller_admin.base.string_parameterize(nameInput.value);\n slugLabel.addClass('active');\n }\n }, 2000);\n };\n }\n },\n\n formatSlug: function () {\n var slugInput = document.getElementById('page_slug');\n\n // Init a timeout variable to be used below\n var timeout = null;\n\n // Listen for keystroke events\n if (typeof (slugInput) != 'undefined' && slugInput != null) {\n slugInput.onkeyup = function (e) {\n\n // Clear the timeout if it has already been set.\n // This will prevent the previous task from executing\n // if it has been less than \n clearTimeout(timeout);\n\n // Make a new timeout set to go off in 800ms\n timeout = setTimeout(function () {\n slugInput.value = seller_admin.base.string_parameterize(slugInput.value);\n }, 500);\n };\n }\n },\n\n initSortable: function () {\n $('#sortable-page-list').sortable({\n placeholder: \"ui-state-highlight\",\n forcePlaceholderSize: true,\n tolerance: \"pointer\",\n update: function (e, ui) {\n seller_admin.base.enableLoadingModal(\"#loadingSortPages\", $('#sort-pages-form'));\n $.ajax(\n {\n url: $(this).data(\"url\"),\n type: \"PATCH\",\n data: $(this).sortable('serialize'),\n success: function (data) {\n $('#pages-table').html(data.table);\n seller_admin.base.disableLoadingModal(\"#loadingSortPages\", $('#sort-pages-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortPages\", $('#sort-pages-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n });\n $(\"#sortable-page-list\").disableSelection();\n },\n\n sortPagesModal: function () {\n $('body').on('click', '#reorder-pages', function () {\n var url = $(this).attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingSortPages\", \"Sorting your pages...\");\n seller_admin.base.enableLoadingModal(\"#loadingSortPages\", $('#sort-pages-form'));\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#sort-pages-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingSortPages\", $('#sort-pages-form'));\n seller_admin.base.openModal('#sort-pages-form');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortPages\", $('#sort-pages-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n newDuplicate: function () {\n $('body').on('click', '.duplicate-page', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingDuplicatePage\", \"Duplicating your page...\");\n seller_admin.base.enableLoadingModal(\"#loadingDuplicatePage\", $this);\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#duplicate-page-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingDuplicatePage\", $this);\n seller_admin.base.openModal('#duplicate-page-modal');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingDuplicatePage\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n createDuplicate: function () {\n $('body').on('submit', '#duplicate-page-form', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingDuplicatePage\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#duplicate-page-modal').modal('hide');\n seller_admin.base.disableLoadingModal(\"#loadingDuplicatePage\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully duplicated the page, updates will appear in a few moments.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingDuplicatePage\", $this);\n }\n });\n return false;\n });\n },\n\n saveContent: function () {\n var $this = $(this),\n accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content'),\n pageId = $('.is-wrapper').attr('data-page-id'),\n wrapperContent = $('.is-wrapper'),\n html = window.contentBuilder.html();\n\n seller_admin.base.assignLoadingModal(\"loadingSavePageDesign\", \"Saving your page design...\");\n seller_admin.base.enableLoadingModal(\"#loadingSavePageDesign\", $this);\n\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/pages/' + pageId,\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: 'PATCH',\n data: {\n 'page': {'content': html},\n 'version_number': wrapperContent.attr('data-version')\n },\n dataType: 'json',\n success: function (data) {\n seller_admin.base.disableLoadingModal(\"#loadingSavePageDesign\", $this);\n wrapperContent.attr('data-version', data.version_number);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE SUCCESSFUL\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSavePageDesign\", $this);\n seller_admin.base.addFlash(\"danger\", \"Failed to save page, please try again.\");\n seller_admin.base.scrollTop(\"main\");\n seller_admin.page_designer.versionMismatchModal(xhr.responseJSON.version_mismatch);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE FAILED\");\n }\n });\n },\n\n autoSaveContent: function () {\n var accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content'),\n pageId = $('.is-wrapper').attr('data-page-id'),\n wrapperContent = $('.is-wrapper'),\n html = window.contentBuilder.html();\n\n $('#design-image-progress .progress-bar').css('width', '100%');\n\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/pages/' + pageId,\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: 'PATCH',\n data: {\n 'page': {'content': html},\n 'version_number': wrapperContent.attr('data-version')\n },\n dataType: 'json',\n success: function (data) {\n seller_admin.base.successfulDesignerAutoSave();\n wrapperContent.attr('data-version', data.version_number);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE SUCCESSFUL\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.failedDesignerAutoSave();\n seller_admin.page_designer.versionMismatchModal(xhr.responseJSON.version_mismatch);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE FAILED\");\n }\n });\n },\n\n publish: function () {\n $('body').on('click', '.publish-page', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingPublishPageDesign\", \"Publishing your page design...\");\n seller_admin.base.enableLoadingModal(\"#loadingPublishPageDesign\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n dataType: 'json',\n success: function (data) {\n seller_admin.base.disableLoadingModal(\"#loadingPublishPageDesign\", $this);\n seller_admin.base.addFlash(\"success\", \"Updates will appear live in a few moments.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingPublishPageDesign\", $this);\n seller_admin.base.addFlash(\"danger\", \"Failed to publish page, please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n remove: function () {\n $('body').on('click', '.prompt-remove-page', function () {\n var pageId = $(this).attr('data-record-id');\n\n seller_admin.base.assignConfirmationModal('remove-page',\n 'Are you sure you wish to remove your page?', pageId);\n seller_admin.base.enableConfirmationModal();\n return false;\n });\n $('body').on('click', '.remove-page', function () {\n var $this = $(this),\n pageId = $this.attr('data-record-id');\n\n seller_admin.base.disableConfirmationModal();\n seller_admin.base.assignLoadingModal(\"loadingRemovePage\", \"Removing page from your store...\");\n seller_admin.base.enableLoadingModal(\"#loadingRemovePage\", $this);\n\n $.ajax(\n {\n url: '/admin/pages/' + pageId,\n type: 'DELETE',\n dataType: 'json',\n success: function (data) {\n $('tr#page-' + pageId).remove();\n seller_admin.base.addFlash('success', 'Successfully removed a page from your store.');\n seller_admin.base.disableLoadingModal(\"#loadingRemovePage\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingRemovePage\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n}","seller_admin.billing =\n {\n updateCountryAlpha2: function()\n {\n $('#billing_country').change(function () {\n $('#update-payment-submit').attr('disabled', true);\n $.ajax(\n {\n url: '/countries/' + $(this).val(),\n type: 'GET',\n dataType: 'json',\n success: function (data) {\n $('#country_alpha_2').val(data.alpha_2);\n $('#update-payment-submit').attr('disabled', false);\n },\n error: function (xhr, evt, status) {\n $('#update-payment-submit').attr('disabled', false);\n }\n });\n });\n }\n }","seller_admin.nav_item = {\n\n addFormChangeNavType: function () {\n $('body').on('change', '#change-nav-item-type', function () {\n var accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content');\n if (this.value == 'Page') {\n seller_admin.nav_item.listPages(accessToken, clientId, uid, storeId);\n } else if (this.value == 'Collection') {\n seller_admin.nav_item.listCollections(accessToken, clientId, uid, storeId);\n } else if (this.value == 'Product') {\n seller_admin.nav_item.listProducts(accessToken, clientId, uid, storeId);\n }\n });\n },\n\n listPages: function (accessToken, clientId, uid, storeId) {\n var selectInput = document.getElementById(\"navable-id-selector\");\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/pages?status=active&publish_status=published&page_type=standard',\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: 'GET',\n dataType: 'json',\n success: function (data) {\n seller_admin.base.removeSelectOptions(selectInput);\n data.pages.forEach(function(page)\n {\n var opt = document.createElement(\"option\");\n opt.value= page.uid;\n opt.innerHTML = page.name; // whatever property it has\n\n // then append it to the select element\n selectInput.appendChild(opt);\n });\n console.log(data.pages);\n }\n });\n },\n\n listCollections: function (accessToken, clientId, uid, storeId) {\n var selectInput = document.getElementById(\"navable-id-selector\");\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/collections?status=active',\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: 'GET',\n dataType: 'json',\n success: function (data) {\n seller_admin.base.removeSelectOptions(selectInput);\n data.collections.forEach(function(collection)\n {\n var opt = document.createElement(\"option\");\n opt.value= collection.uid;\n opt.innerHTML = collection.name;\n\n selectInput.appendChild(opt);\n });\n console.log(data.collections);\n }\n });\n },\n\n listProducts: function (accessToken, clientId, uid, storeId) {\n var selectInput = document.getElementById(\"navable-id-selector\");\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/products?status=active',\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: 'GET',\n dataType: 'json',\n success: function (data) {\n seller_admin.base.removeSelectOptions(selectInput);\n data.products.forEach(function(product)\n {\n var opt = document.createElement(\"option\");\n opt.value= product.uid;\n opt.innerHTML = product.name;\n\n selectInput.appendChild(opt);\n });\n console.log(data.products);\n }\n });\n },\n\n initSortable: function () {\n $('#sortable-nav-item-list').sortable({\n placeholder: \"ui-state-highlight\",\n forcePlaceholderSize: true,\n tolerance: \"pointer\",\n update: function (e, ui) {\n seller_admin.base.enableLoadingModal(\"#loadingSortNavItem\", $('#sort-nav-items-form'));\n $.ajax(\n {\n url: $(this).data(\"url\"),\n type: \"PATCH\",\n data: $(this).sortable('serialize'),\n success: function (data) {\n $('#nav-items-table').html(data.table);\n seller_admin.base.disableLoadingModal(\"#loadingSortNavItem\", $('#sort-nav-items-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortNavItem\", $('#sort-nav-items-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n });\n $(\"#sortable-nav-item-list\").disableSelection();\n },\n\n sortModal: function () {\n $('body').on('click', '#reorder-nav-items', function () {\n var url = $(this).attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingSortNavItem\", \"Sorting your navigation items...\");\n seller_admin.base.enableLoadingModal(\"#loadingSortNavItem\", $('#sort-nav-items-form'));\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#sort-nav-items-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingSortNavItem\", $('#sort-nav-items-form'));\n seller_admin.base.openModal('#sort-nav-items-form');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortNavItem\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n remove: function()\n {\n $('body').on('click', '.prompt-remove-nav-item', function() {\n var navItemId = $(this).attr('data-record-id');\n\n seller_admin.base.assignConfirmationModal('remove-nav-item',\n 'Are you sure you wish to remove your navigation item?', navItemId);\n seller_admin.base.enableConfirmationModal();\n return false;\n });\n $('body').on('click', '.remove-nav-item', function () {\n var $this = $(this),\n navItemId = $this.attr('data-record-id');\n\n seller_admin.base.disableConfirmationModal();\n seller_admin.base.assignLoadingModal(\"loadingRemoveNavItem\", \"Removing navigation item from your store...\");\n seller_admin.base.enableLoadingModal(\"#loadingRemoveNavItem\", $this);\n\n $.ajax(\n {\n url: '/admin/nav_items/' + navItemId,\n type: 'DELETE',\n dataType: 'json',\n success: function (data) {\n $('tr#nav-item-' + navItemId).remove();\n seller_admin.base.addFlash('success', 'Successfully removed a navigation item from your store.');\n seller_admin.base.disableLoadingModal(\"#loadingRemoveNavItem\", $this);\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingRemoveNavItem\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n}","seller_admin.template =\n {\n initTemplateCategoryFilter: function () {\n var $grid = $('#template-grid.grid').isotope({\n });\n $grid.imagesLoaded().progress( function() {\n $grid.isotope('layout');\n });\n $('.template-category-group').on('click', 'button', function () {\n var filterValue = $(this).attr('data-filter');\n $grid.isotope({filter: filterValue});\n return false;\n });\n },\n\n previewModal: function()\n {\n $('body').on('click', '.preview-template-button', function () {\n var $this = $(this),\n templateId = $this.attr('data-template-id');\n\n seller_admin.base.assignLoadingModal(\"loadingPreviewTemplate\", \"Loading preview template...\");\n seller_admin.base.enableLoadingModal(\"#loadingPreviewTemplate\", $this);\n\n $.ajax(\n {\n url: '/admin/templates/' + templateId + '/preview_modal',\n type: 'GET',\n dataType: 'json',\n success: function (data) {\n $('#preview-template-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingPreviewTemplate\", $this);\n seller_admin.base.openModal('#preview-template-modal');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingPreviewTemplate\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n }","seller_admin.discount =\n {\n create: function () {\n $(\"body\").on(\"submit\", '#new-discount-form', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.assignLoadingModal(\"loadingCreateDiscount\", \"Creating discount...\");\n seller_admin.base.enableLoadingModal(\"#loadingCreateDiscount\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $(this).serialize(),\n dataType: 'json',\n success: function (data) {\n $this[0].submit();\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingCreateDiscount\", $this);\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.scrollTop(\"#add-discount-header\");\n }\n });\n return false;\n });\n },\n\n edit: function () {\n $(\"body\").on(\"submit\", '#edit-discount-form', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n\n seller_admin.base.assignLoadingModal(\"loadingUpdateDiscount\", \"Updating discount...\");\n seller_admin.base.enableLoadingModal(\"#loadingUpdateDiscount\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $(this).serialize(),\n dataType: 'json',\n success: function (data) {\n $this[0].submit();\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUpdateDiscount\", $this);\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.scrollTop(\"#edit-discount-header\");\n }\n });\n return false;\n });\n },\n\n changeDiscountSaleOption: function () {\n $(\"body\").on('change', 'select#discount_sale_option', function () {\n var val = $(this).val();\n if (val === 'subscription') {\n $('#discount-duration-wrapper').show();\n $('#discount-subscriptions').show();\n $('#discount-products').hide();\n $('#discount-rules-header').hide();\n $('#discount-rules').hide();\n } else if (val === 'overall_order') {\n $('#discount-duration-wrapper select').val('single');\n $('#discount-duration-wrapper').hide();\n $('#discount-subscriptions').hide();\n $('#discount-products').hide();\n $('#discount-rules-header').show();\n $('#discount-rules').show();\n } else if (val === 'single_purchase') {\n $('#discount-duration-wrapper').hide();\n $('#discount-duration-wrapper select').val('single');\n $('#discount-subscriptions').hide();\n $('#discount-products').show();\n $('#discount-rules-header').hide();\n $('#discount-rules').hide();\n }\n });\n },\n\n changeDiscountType: function () {\n $(\"body\").on('change', 'select#discount_discount_type', function () {\n var val = $(this).val();\n if (val === 'free_shipping') {\n $('#discount-value-wrapper').hide();\n $('#discount-value-wrapper input').val(1);\n } else {\n $('#discount-value-wrapper').show();\n }\n });\n },\n\n addRule: function (link, association, content) {\n var new_id = new Date().getTime(),\n regexp = new RegExp(\"new_\" + association, \"g\");\n $(\"#discount-rules\").append(content.replace(regexp, new_id));\n var selectTags = $('div[data-fields-id=\"' + new_id + '\"] select');\n selectTags.materialSelect();\n selectTags.each(function () {\n $(this).click(e => e.stopPropagation());\n });\n },\n\n removeRule: function (link) {\n $(link).prev(\"input[type=hidden]\").val(\"1\");\n $(link).closest(\".fields\").hide();\n },\n\n changeFilterType: function () {\n $('body').on('change', 'select.discount-rule-filter-type', function () {\n var $this = $(this),\n parentWrapper = $this.parent().parent().parent();\n seller_admin.discount.updateConditionSelect(parentWrapper, this.value);\n if (this.value === 'cart_item') {\n parentWrapper.find('.discount-rule-filter-value-wrapper').show();\n parentWrapper.find('.discount-rule-filter-value-wrapper div label').text('Quantity');\n parentWrapper.find('.discount-rule-product-id-wrapper').show();\n } else if (this.value === 'cart_subtotal') {\n parentWrapper.find('.discount-rule-filter-value-wrapper').show();\n parentWrapper.find('.discount-rule-filter-value-wrapper div label').text('Cart value');\n parentWrapper.find('.discount-rule-product-id-wrapper').hide();\n } else if (this.value === 'cart_shipping') {\n parentWrapper.find('.discount-rule-filter-value-wrapper').show();\n parentWrapper.find('.discount-rule-filter-value-wrapper div label').text('Shipping value');\n parentWrapper.find('.discount-rule-product-id-wrapper').hide();\n }\n });\n },\n\n updateConditionSelect: function (parentWrapper, selectValue) {\n var conditions = window.discount_rule_conditions[selectValue],\n selectElem = parentWrapper.find('select.discount-rule-condition');\n selectElem.empty();\n for (var i = 0; i < conditions.length; i++) {\n selectElem.append('');\n }\n },\n\n\n archive: function () {\n $('body').on('click', '.archive-discount', function () {\n var $this = $(this),\n url = $this.attr('href'),\n discountId = $this.attr('data-discount-id'),\n discountSearchTable = $('table#discount-search-table'),\n discountRow = $('tr#discount-' + discountId);\n\n seller_admin.base.assignLoadingModal(\"loadingArchiveDiscount\", \"Archiving your discount...\");\n seller_admin.base.enableLoadingModal(\"#loadingArchiveDiscount\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (discountSearchTable.length > 0) {\n discountRow.replaceWith(data.row);\n } else {\n discountRow.remove();\n }\n $('#view-discount-archive-button').remove();\n seller_admin.base.disableLoadingModal(\"#loadingArchiveDiscount\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully archived a discount.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingArchiveDiscount\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n }","seller_admin.setting = {\n\n copyCnameRecord: function()\n {\n new ClipboardJS('#copy-cname-record');\n },\n\n changeDefaultShippingCountry: function()\n {\n $('#store_default_shipping_country').change(function () {\n if ($(this).val() === 'enabled') {\n $('#default-shipping-country-wrapper').show();\n } else {\n $('#default-shipping-country-wrapper').hide();\n }\n });\n }\n}","seller_admin.cart_abandonment =\n {\n publishEmail: function()\n {\n $('body').on('click', '.publish-abandon-email', function () {\n var $this = $(this),\n url = $this.attr('href'),\n abandonEmailId = $this.attr('data-abandon-email-id');\n\n seller_admin.base.assignLoadingModal(\"loadingPublishAbandonEmail\", \"Publishing your abandoned email template...\");\n seller_admin.base.enableLoadingModal(\"#loadingPublishAbandonEmail\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('tr.abandon-email-' + abandonEmailId).replaceWith(data.row);\n seller_admin.base.disableLoadingModal(\"#loadingPublishAbandonEmail\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully published a cart abandonment email template.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingPublishAbandonEmail\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n unpublishEmail: function()\n {\n $('body').on('click', '.unpublish-abandon-email', function () {\n var $this = $(this),\n url = $this.attr('href'),\n abandonEmailId = $this.attr('data-abandon-email-id');\n\n seller_admin.base.assignLoadingModal(\"loadingUnpublishAbandonEmail\", \"Unpublishing your abandoned email template...\");\n seller_admin.base.enableLoadingModal(\"#loadingUnpublishAbandonEmail\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('tr.abandon-email-' + abandonEmailId).replaceWith(data.row);\n seller_admin.base.disableLoadingModal(\"#loadingUnpublishAbandonEmail\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully unpublished a cart abandonment email template.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUnpublishAbandonEmail\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n sendTestEmailModal: function () {\n $('body').on('click', '.send-test-email-modal', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingTestAbandonEmail\", \"Sending test abandoned email...\");\n seller_admin.base.enableLoadingModal(\"#loadingTestAbandonEmail\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#send-test-email-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingTestAbandonEmail\", $this);\n seller_admin.base.openModal('#test-abandon-email-form');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingTestAbandonEmail\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n sendTestEmail: function () {\n $('body').on('submit', '#send-test-abandon-email', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingTestAbandonEmail\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#test-abandon-email-form').modal('hide');\n seller_admin.base.disableLoadingModal(\"#loadingTestAbandonEmail\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully sent a test email for \" + data.abandon_email.subject + \".\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n $('#test-abandon-email-form #errors ul').html(\"Invalid email, please try again.\");\n $('#test-abandon-email-form .json-error-wrapper').show();\n seller_admin.base.disableLoadingModal(\"#loadingTestAbandonEmail\", $this);\n }\n });\n return false;\n });\n },\n\n cancel: function()\n {\n $('body').on('click', '.cancel-abandoned-cart', function () {\n var $this = $(this),\n url = $this.attr('href'),\n abandonedCartId = $this.data('abandoned-cart-id');\n\n seller_admin.base.assignLoadingModal(\"loadingCancelCartAbandonment\", \"Cancelling an abandoned cart...\");\n seller_admin.base.enableLoadingModal(\"#loadingCancelCartAbandonment\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('tr.abandoned-cart-' + abandonedCartId).remove();\n seller_admin.base.disableLoadingModal(\"#loadingCancelCartAbandonment\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully cancelled an abandoned cart.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingCancelCartAbandonment\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n }","seller_admin.member_dashboard =\n {\n saveContent: function () {\n var accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content'),\n wrapperContent = $('.is-wrapper'),\n html = window.contentBuilder.html();\n\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/member/dashboard',\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: 'PATCH',\n data: {\n 'member_dashboard': {'content': html},\n 'version_number': wrapperContent.attr('data-version')\n },\n dataType: 'json',\n success: function (data) {\n wrapperContent.attr('data-version', data.version_number);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE SUCCESSFUL\");\n },\n error: function (xhr, evt, status) {\n seller_admin.page_designer.versionMismatchModal(xhr.responseJSON.version_mismatch);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE FAILED\");\n }\n });\n },\n\n autoSaveContent: function () {\n var accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content'),\n wrapperContent = $('.is-wrapper'),\n html = window.contentBuilder.html();\n\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/member/dashboard',\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: 'PATCH',\n data: {\n 'member_dashboard': {'content': html},\n 'version_number': wrapperContent.attr('data-version')\n },\n dataType: 'json',\n success: function (data) {\n seller_admin.base.successfulDesignerAutoSave();\n wrapperContent.attr('data-version', data.version_number);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE SUCCESSFUL\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.failedDesignerAutoSave();\n seller_admin.page_designer.versionMismatchModal(xhr.responseJSON.version_mismatch);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE FAILED\");\n }\n });\n }\n }","seller_admin.member_category =\n {\n archive: function () {\n $('body').on('click', '.archive-member-category', function () {\n var $this = $(this),\n url = $this.attr('href'),\n memberCategoryId = $this.attr('data-member-category-id'),\n memberCategorytSearchTable = $('table#member-category-search-table'),\n memberCategoryRow = $('tr.member-category-' + memberCategoryId);\n\n seller_admin.base.assignLoadingModal(\"loadingArchiveMemberCategory\", \"Archiving your member category...\");\n seller_admin.base.enableLoadingModal(\"#loadingArchiveMemberCategory\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (memberCategorytSearchTable.length > 0) {\n memberCategoryRow.replaceWith(data.row);\n } else {\n memberCategoryRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingArchiveMemberCategory\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully archived a member category.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingArchiveMemberCategory\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n unarchive: function () {\n $('body').on('click', '.unarchive-member-category', function () {\n var $this = $(this),\n url = $this.attr('href'),\n memberCategoryId = $this.attr('data-member-category-id'),\n memberCategorytSearchTable = $('table#member-category-search-table'),\n memberCategoryRow = $('tr.member-category-' + memberCategoryId);\n\n seller_admin.base.assignLoadingModal(\"loadingUnarchiveMemberCategory\", \"Unarchiving your member category...\");\n seller_admin.base.enableLoadingModal(\"#loadingUnarchiveMemberCategory\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (memberCategorytSearchTable.length > 0) {\n memberCategoryRow.replaceWith(data.row);\n } else {\n memberCategoryRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveMemberCategory\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully unarchived a member category.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveMemberCategory\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n initSortable: function () {\n $('#sortable-member-category-list').sortable({\n placeholder: \"ui-state-highlight\",\n forcePlaceholderSize: true,\n tolerance: \"pointer\",\n update: function (e, ui) {\n seller_admin.base.enableLoadingModal(\"#loadingSortMemberCategory\", $('#sort-member-categories-form'));\n $.ajax(\n {\n url: $(this).data(\"url\"),\n type: \"PATCH\",\n data: $(this).sortable('serialize'),\n success: function (data) {\n $('#member-categories-table tbody').html(data.table);\n seller_admin.base.disableLoadingModal(\"#loadingSortMemberCategory\", $('#sort-member-categories-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortMemberCategory\", $('#sort-member-categories-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n });\n $(\"#sortable-member-category-list\").disableSelection();\n },\n\n sortModal: function () {\n $('body').on('click', '#reorder-member-categories', function () {\n var url = $(this).attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingSortMemberCategory\", \"Sorting your member categories...\");\n seller_admin.base.enableLoadingModal(\"#loadingSortMemberCategory\", $('#sort-member-categories-form'));\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#sort-member-categories-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingSortMemberCategory\", $('#sort-member-categories-form'));\n seller_admin.base.openModal('#sort-member-categories-form');\n }\n });\n return false;\n });\n },\n\n initIconPicker: function () {\n var formElem = $('.iconpicker');\n formElem.iconpicker();\n formElem.on('iconpickerSelected', function (event) {\n $('label[for=\"' + formElem.attr('id') + '\"').addClass('active');\n $('#member_category_icon_class').val(event.iconpickerValue);\n $('#icon_class_icon').html('');\n });\n formElem.on('iconpickerSetValue', function (event) {\n $('#member_category_icon_class').val(event.iconpickerValue);\n $('#icon_class_icon').html('');\n });\n },\n\n addAccessRule: function (link, association, content) {\n var new_id = new Date().getTime(),\n regexp = new RegExp(\"new_\" + association, \"g\");\n $('#access-rules-header').after(content.replace(regexp, new_id));\n var selectTags = $('div[data-fields-id=\"' + new_id + '\"] select');\n selectTags.materialSelect()\n selectTags.each(function () {\n $(this).click(e => e.stopPropagation());\n });\n },\n\n removeAccessRule: function (link) {\n $(link).prev(\"input[type=hidden]\").val(\"1\");\n $(link).closest(\".fields\").hide();\n var wrapperElem = $(link).closest('.section');\n wrapperElem.hide();\n }\n }","seller_admin.member_post =\n {\n archive: function () {\n $('body').on('click', '.archive-member-post', function () {\n var $this = $(this),\n url = $this.attr('href'),\n memberPostId = $this.attr('data-member-post-id'),\n memberPostSearchTable = $('table#member-post-search-table'),\n memberPostRow = $('tr.member-post-' + memberPostId);\n\n seller_admin.base.assignLoadingModal(\"loadingArchiveMemberPost\", \"Archiving your member post...\");\n seller_admin.base.enableLoadingModal(\"#loadingArchiveMemberPost\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (memberPostSearchTable.length > 0) {\n memberPostRow.replaceWith(data.row);\n } else {\n memberPostRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingArchiveMemberPost\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully archived a member post.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingArchiveMemberPost\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n unarchive: function () {\n $('body').on('click', '.unarchive-member-post', function () {\n var url = $(this).attr('href'),\n $this = $(this),\n memberPostId = $this.attr('data-member-post-id'),\n memberPostSearchTable = $('table#member-post-search-table'),\n memberPostRow = $('tr.member-post-' + memberPostId);\n\n seller_admin.base.assignLoadingModal(\"loadingUnarchiveMemberPost\", \"Unarchiving your member post...\");\n seller_admin.base.enableLoadingModal(\"#loadingUnarchiveMemberPost\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (memberPostSearchTable.length > 0) {\n memberPostRow.replaceWith(data.row);\n } else {\n memberPostRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveMemberPost\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully unarchived a member post.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveMemberPost\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n bindPublishNotification: function (channel) {\n channel.bind('member_post_publish_list', function (data) {\n var draftMemberPost = $('tr.member-post-' + data.draft_member_post_id);\n if (draftMemberPost.length > 0) {\n draftMemberPost.find('td.member-post-publish-status').text(data.publish_status);\n }\n });\n },\n\n newDuplicate: function () {\n $('body').on('click', '.duplicate-member-post', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingDuplicateMemberPost\", \"Duplicating your member post...\");\n seller_admin.base.enableLoadingModal(\"#loadingDuplicateMemberPost\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#duplicate-member-post-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingDuplicateMemberPost\", $this);\n seller_admin.base.openModal('#duplicate-member-post-modal');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingDuplicateMemberPost\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n createDuplicate: function () {\n $('body').on('submit', '#duplicate-member-post-form', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingDuplicateMemberPost\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#duplicate-member-post-modal').modal('hide');\n $('#member-category-' + data.member_category_id + '-post-table tbody').prepend(data.row);\n seller_admin.base.disableLoadingModal(\"#loadingDuplicateMemberPost\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully duplicated the member post, updates will appear in a few moments.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingDuplicateMemberPost\", $this);\n }\n });\n return false;\n });\n },\n\n initSortableList: function () {\n $('#sortable-member-category-post-list').sortable({\n placeholder: \"ui-state-highlight\",\n forcePlaceholderSize: true,\n tolerance: \"pointer\",\n update: function (e, ui) {\n var memberCategoryId = $(this).data('member-category-id');\n seller_admin.base.enableLoadingModal(\"#loadingSortMemberPosts\", $('#sort-member-category-posts-form'));\n $.ajax(\n {\n url: $(this).data(\"url\"),\n type: \"PATCH\",\n data: $(this).sortable('serialize'),\n success: function (data) {\n $('#member-category-' + memberCategoryId + '-post-table tbody').html(data.table);\n seller_admin.base.disableLoadingModal(\"#loadingSortMemberPosts\", $('#sort-member-category-posts-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortMemberPosts\", $('#sort-member-category-posts-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n });\n $(\"#sortable-member-category-post-list\").disableSelection();\n },\n\n sortModal: function () {\n $('body').on('click', '.reorder-member-category-posts', function () {\n var url = $(this).attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingSortMemberPosts\", \"Sorting your member posts...\");\n seller_admin.base.enableLoadingModal(\"#loadingSortMemberPosts\", $('#sort-member-category-posts-form'));\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#sort-member-category-posts-wrapper').html(data.modal);\n seller_admin.base.openModal('#sort-member-category-posts-form');\n seller_admin.base.disableLoadingModal(\"#loadingSortMemberPosts\", $('#sort-member-category-posts-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortMemberPosts\", $('#sort-member-category-posts-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n saveContent: function () {\n var $this = $(this),\n accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content'),\n memberPostId = $('.is-wrapper').attr('data-member-post-id'),\n wrapperContent = $('.is-wrapper'),\n html = window.contentBuilder.html();\n\n seller_admin.base.assignLoadingModal(\"loadingSaveMemberPostDesign\", \"Saving your member post design...\");\n seller_admin.base.enableLoadingModal(\"#loadingSaveMemberPostDesign\", $this);\n\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/member/posts/' + memberPostId,\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: 'PATCH',\n data: {\n 'member_post': {'content': html},\n 'version_number': wrapperContent.attr('data-version')\n },\n dataType: 'json',\n success: function (data) {\n seller_admin.base.disableLoadingModal(\"#loadingSaveMemberPostDesign\", $this);\n wrapperContent.attr('data-version', data.version_number);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE SUCCESSFUL\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSaveMemberPostDesign\", $this);\n seller_admin.base.addFlash(\"danger\", \"Failed to save member post, please try again.\");\n seller_admin.base.scrollTop(\"main\");\n seller_admin.page_designer.versionMismatchModal(xhr.responseJSON.version_mismatch);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE FAILED\");\n }\n });\n },\n\n autoSaveContent: function () {\n var accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content'),\n memberPostId = $('.is-wrapper').attr('data-member-post-id'),\n wrapperContent = $('.is-wrapper'),\n html = window.contentBuilder.html();\n\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/member/posts/' + memberPostId,\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: 'PATCH',\n data: {\n 'member_post': {'content': html},\n 'version_number': wrapperContent.attr('data-version')\n },\n dataType: 'json',\n success: function (data) {\n seller_admin.base.successfulDesignerAutoSave();\n wrapperContent.attr('data-version', data.version_number);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE SUCCESSFUL\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.failedDesignerAutoSave();\n seller_admin.page_designer.versionMismatchModal(xhr.responseJSON.version_mismatch);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE FAILED\");\n }\n });\n },\n\n publish: function () {\n $('body').on('click', '.publish-member-post', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingPublishMemberPost\", \"Publishing your member post...\");\n seller_admin.base.enableLoadingModal(\"#loadingPublishMemberPost\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n dataType: 'json',\n success: function (data) {\n seller_admin.base.disableLoadingModal(\"#loadingPublishMemberPost\", $this);\n seller_admin.base.addFlash(\"success\", \"Updates will appear live in a few moments.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingPublishMemberPost\", $this);\n seller_admin.base.addFlash(\"danger\", \"Failed to publish member post, please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n updateTitleToSlug: function () {\n var nameInput = document.getElementById('member_post_title'),\n slugInput = document.getElementById('member_post_slug'),\n slugLabel = $('label[for=\"member_post_slug\"]'),\n timeout = null;\n\n if (typeof (nameInput) != 'undefined' && nameInput != null) {\n nameInput.onkeyup = function (e) {\n\n clearTimeout(timeout);\n timeout = setTimeout(function () {\n if (slugInput.value === \"\") {\n slugInput.value = seller_admin.base.string_parameterize(nameInput.value);\n slugLabel.addClass('active');\n }\n }, 2000);\n };\n }\n },\n\n formatSlug: function () {\n var slugInput = document.getElementById('member_post_slug'),\n timeout = null;\n\n if (typeof (slugInput) != 'undefined' && slugInput != null) {\n slugInput.onkeyup = function (e) {\n\n clearTimeout(timeout);\n timeout = setTimeout(function () {\n slugInput.value = seller_admin.base.string_parameterize(slugInput.value);\n }, 500);\n };\n }\n },\n\n addAccessRule: function (link, association, content) {\n var new_id = new Date().getTime(),\n regexp = new RegExp(\"new_\" + association, \"g\");\n $('#access-rules-header').after(content.replace(regexp, new_id));\n var selectTags = $('div[data-fields-id=\"' + new_id + '\"] select');\n selectTags.materialSelect()\n selectTags.each(function () {\n $(this).click(e => e.stopPropagation());\n });\n },\n\n removeAccessRule: function (link) {\n $(link).prev(\"input[type=hidden]\").val(\"1\");\n $(link).closest(\".fields\").hide();\n var wrapperElem = $(link).closest('.section');\n wrapperElem.hide();\n }\n }","seller_admin.shipping =\n {\n\n add: function () {\n $('body').on('click', '.create-shipping-rule', function () {\n var $this = $(this),\n url = $this.attr('href'),\n shippingWeightUnit = $('#shipping-settings').attr('data-current-shipping-weight-unit');\n\n seller_admin.base.assignLoadingModal(\"loadingAddShippingRule\", \"Creating shipping rule...\");\n seller_admin.base.enableLoadingModal(\"#loadingAddShippingRule\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#shipping-rule-modal').html(data.modal);\n $('#shipping-rule-form .shipping-weight-unit').text(shippingWeightUnit);\n seller_admin.base.openModal('#shipping-rule-form');\n $('#shipping-rule-modal .mdb-select').materialSelect();\n $('#shipping-rule-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingAddShippingRule\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingAddShippingRule\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n create: function () {\n $('body').on('submit', '#create-shipping-rule', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingAddShippingRule\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#shipping-rule-form').modal('hide');\n $('#shipping-rules-table tbody').prepend(data.shipping_rule_row);\n seller_admin.base.addCustomFlash('#shipping-rules-section', 'success', 'Successfully added a shipping rule to your store.');\n seller_admin.base.disableLoadingModal(\"#loadingAddShippingRule\", $this);\n seller_admin.base.scrollTop('#shipping-rules-section');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingAddShippingRule\", $this);\n }\n });\n return false;\n });\n },\n\n edit: function () {\n $('body').on('click', '.edit-shipping-rule', function () {\n var $this = $(this),\n url = $this.attr('href'),\n shippingWeightUnit = $('#shipping-settings').attr('data-current-shipping-weight-unit');\n\n seller_admin.base.assignLoadingModal(\"loadingEditShippingRule\", \"Updating shipping rule...\");\n seller_admin.base.enableLoadingModal(\"#loadingEditShippingRule\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#shipping-rule-modal').html(data.modal);\n $('#shipping-rule-form .shipping-weight-unit').text(shippingWeightUnit);\n seller_admin.base.openModal('#shipping-rule-form');\n $('#shipping-rule-modal .mdb-select').materialSelect();\n $('#shipping-rule-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingEditShippingRule\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingEditShippingRule\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n update: function () {\n $('body').on('submit', '#edit-shipping-rule', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingEditShippingRule\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#shipping-rule-form').modal('hide');\n $('#shipping-rules-table tbody tr#shipping-rule-' + data.shipping_rule_id).replaceWith(data.shipping_rule_row);\n seller_admin.base.addCustomFlash('#shipping-rules-section', 'success', 'Successfully updated a shipping rule to your store.');\n seller_admin.base.disableLoadingModal(\"#loadingEditShippingRule\", $this);\n seller_admin.base.scrollTop('#shipping-rules-section');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingEditShippingRule\", $this);\n }\n });\n return false;\n });\n },\n\n remove: function () {\n $('body').on('click', '.prompt-remove-shipping-rule', function() {\n var shippingRuleId = $(this).attr('data-record-id');\n\n seller_admin.base.assignConfirmationModal('remove-shipping-rule',\n 'Are you sure you wish to remove your shipping rule?', shippingRuleId);\n seller_admin.base.enableConfirmationModal();\n return false;\n });\n $('body').on('click', '.remove-shipping-rule', function () {\n var $this = $(this),\n shippingRuleId = $this.attr('data-record-id');\n\n seller_admin.base.disableConfirmationModal();\n seller_admin.base.assignLoadingModal(\"loadingRemoveShippingRule\", \"Removing shipping rule from your store...\");\n seller_admin.base.enableLoadingModal(\"#loadingRemoveShippingRule\", $this);\n\n $.ajax(\n {\n url: '/admin/settings/shipping_rules/' + shippingRuleId,\n type: 'DELETE',\n dataType: 'json',\n success: function (data) {\n $('tr#shipping-rule-' + shippingRuleId).remove();\n seller_admin.base.addCustomFlash('#shipping-rules-section', 'success', 'Successfully removed a shipping rule from your store.');\n seller_admin.base.disableLoadingModal(\"#loadingRemoveShippingRule\", $this);\n seller_admin.base.scrollTop('#shipping-rules-section');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingRemoveShippingRule\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n onChangeWeightUnit: function () {\n $('select#store_shipping_weight_unit').on('change', function () {\n $('#shipping-settings').attr('data-current-shipping-weight-unit', seller_admin.shipping.weightUnitLabel(this.value));\n $('.shipping-weight-unit').text(seller_admin.shipping.weightUnitLabel(this.value));\n seller_admin.base.openModal('#shipping-warning-modal');\n });\n },\n\n weightUnitLabel: function (value) {\n if (value === 'pounds') {\n return 'lb';\n } else if (value === 'ounces') {\n return 'oz';\n } else if (value === 'kilograms') {\n return 'kg';\n } else if (value === 'grams') {\n return 'g';\n }\n },\n }","seller_admin.order_bump =\n {\n create: function () {\n $(\"body\").on(\"submit\", '#new_product_order_bump', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n\n seller_admin.base.assignLoadingModal(\"loadingCreateOrderBump\", \"Creating order bump...\");\n seller_admin.base.enableLoadingModal(\"#loadingCreateOrderBump\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $(this).serialize(),\n dataType: 'json',\n success: function (data) {\n $this[0].submit();\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingCreateOrderBump\", $this);\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.scrollTop(\"#add-order-bump-header\");\n }\n });\n return false;\n });\n },\n\n edit: function () {\n $(\"body\").on(\"submit\", '.edit_product_order_bump', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.assignLoadingModal(\"loadingUpdateOrderBump\", \"Updating order bump...\");\n seller_admin.base.enableLoadingModal(\"#loadingUpdateOrderBump\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $(this).serialize(),\n dataType: 'json',\n success: function (data) {\n $this[0].submit();\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUpdateOrderBump\", $this);\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.scrollTop(\"#edit-order-bump-header\");\n }\n });\n return false;\n });\n },\n\n changeFilterType: function () {\n $('body').on('change', 'select.order-bump-rule-filter-type', function () {\n var $this = $(this),\n parentWrapper = $this.parent().parent().parent();\n seller_admin.order_bump.updateConditionSelect(parentWrapper, this.value);\n if (this.value === 'cart_item') {\n parentWrapper.find('.order-bump-rule-filter-value-wrapper').show();\n parentWrapper.find('.order-bump-rule-filter-value-wrapper div label').text('Quantity');\n parentWrapper.find('.order-bump-rule-product-id-wrapper').show();\n } else if (this.value === 'cart_item_count') {\n parentWrapper.find('.order-bump-rule-filter-value-wrapper').show();\n parentWrapper.find('.order-bump-rule-filter-value-wrapper div label').text('Quantity');\n parentWrapper.find('.order-bump-rule-product-id-wrapper').hide();\n } else if (this.value === 'cart_subtotal') {\n parentWrapper.find('.order-bump-rule-filter-value-wrapper').show();\n parentWrapper.find('.order-bump-rule-filter-value-wrapper div label').text('Cart value');\n parentWrapper.find('.order-bump-rule-product-id-wrapper').hide();\n } else if (this.value === 'product_tag') {\n parentWrapper.find('.order-bump-rule-filter-value-wrapper').show();\n parentWrapper.find('.order-bump-rule-filter-value-wrapper div label').text('Filter');\n parentWrapper.find('.order-bump-rule-product-id-wrapper').hide();\n } else if (this.value === 'product_title') {\n parentWrapper.find('.order-bump-rule-filter-value-wrapper').show();\n parentWrapper.find('.order-bump-rule-filter-value-wrapper div label').text('Filter');\n parentWrapper.find('.order-bump-rule-product-id-wrapper').hide();\n } else if (this.value === 'product_collection') {\n parentWrapper.find('.order-bump-rule-filter-value-wrapper').show();\n parentWrapper.find('.order-bump-rule-filter-value-wrapper div label').text('Filter');\n parentWrapper.find('.order-bump-rule-product-id-wrapper').hide();\n }\n\n });\n },\n\n firstRuleCollection: function (link, association, content) {\n var new_id = new Date().getTime(),\n regexp = new RegExp(\"new_\" + association, \"g\"),\n wrapperElem = $(link).closest('.section');\n $('#order-bump-rules-header').after(content.replace(regexp, new_id));\n var selectTags = $('div[data-fields-id=\"' + new_id + '\"] select');\n selectTags.materialSelect()\n selectTags.each(function () {\n $(this).click(e => e.stopPropagation());\n });\n if ($('section.order-bump-rule-collection:visible').length > 1) {\n wrapperElem.find('.order-bump-or-header').show();\n }\n $('#add-order-bump-rule-collection').show();\n $(link).hide();\n },\n\n addRuleCollection: function (link, association, content) {\n var new_id = new Date().getTime(),\n regexp = new RegExp(\"new_\" + association, \"g\"),\n wrapperElem = $(link).closest('.section');\n $(link).before(content.replace(regexp, new_id));\n var selectTags = $('div[data-fields-id=\"' + new_id + '\"] select');\n selectTags.materialSelect()\n selectTags.each(function () {\n $(this).click(e => e.stopPropagation());\n });\n if ($('section.order-bump-rule-collection:visible').length > 1) {\n wrapperElem.find('.order-bump-or-header').show();\n }\n },\n\n addRule: function (link, association, content) {\n var new_id = new Date().getTime(),\n regexp = new RegExp(\"new_\" + association, \"g\");\n $(link).before(content.replace(regexp, new_id));\n var selectTags = $('div[data-fields-id=\"' + new_id + '\"] select');\n selectTags.materialSelect()\n selectTags.each(function () {\n $(this).click(e => e.stopPropagation());\n });\n },\n\n removeRule: function (link) {\n $(link).prev(\"input[type=hidden]\").val(\"1\");\n $(link).closest(\".fields\").hide();\n var wrapperElem = $(link).closest('.section');\n if (wrapperElem.find('.fields:visible').length < 1) {\n wrapperElem.hide();\n wrapperElem.find(\"input[type=hidden].rule-collection-destroy\").val(\"1\");\n }\n if ($('section.order-bump-rule-collection:visible').length < 1) {\n $('#first-order-bump-rule-wrapper').show();\n $('#first-order-bump-rule-wrapper a').show();\n $('#add-order-bump-rule-collection').hide();\n }\n },\n\n updateConditionSelect: function (parentWrapper, selectValue) {\n var conditions = window.bump_rule_conditions[selectValue],\n selectElem = parentWrapper.find('select.order-bump-rule-condition');\n selectElem.empty();\n for (var i = 0; i < conditions.length; i++) {\n selectElem.append('');\n }\n },\n\n archive: function () {\n $('body').on('click', '.archive-order-bump', function () {\n var $this = $(this),\n url = $this.attr('href'),\n orderBumpId = $this.attr('data-order-bump-id'),\n orderBumpSearchTable = $('table#order-bump-search-table'),\n orderBumpRow = $('tr.order-bump-' + orderBumpId);\n\n seller_admin.base.assignLoadingModal(\"loadingArchiveOrderBump\", \"Archiving order bump...\");\n seller_admin.base.enableLoadingModal(\"#loadingArchiveOrderBump\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (orderBumpSearchTable.length > 0) {\n orderBumpRow.replaceWith(data.row);\n } else {\n orderBumpRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingArchiveOrderBump\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully archived a Product Order Bump.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingArchiveOrderBump\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n unarchive: function () {\n $('body').on('click', '.unarchive-order-bump', function () {\n var $this = $(this),\n url = $this.attr('href'),\n orderBumpId = $this.attr('data-order-bump-id'),\n orderBumpSearchTable = $('table#order-bump-search-table'),\n orderBumpRow = $('tr.order-bump-' + orderBumpId);\n\n seller_admin.base.assignLoadingModal(\"loadingUnarchiveOrderBump\", \"Unarchiving order bump...\");\n seller_admin.base.enableLoadingModal(\"#loadingUnarchiveOrderBump\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (orderBumpSearchTable.length > 0) {\n orderBumpRow.replaceWith(data.row);\n } else {\n orderBumpRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveOrderBump\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully unarchived a Product Order Bump.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveOrderBump\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n changeOverridePrice: function () {\n $('#product_order_bump_override_price').change(function () {\n if ($(this).val() === 'enabled') {\n $('#order-bump-quantity-wrapper').show();\n $('#order-bump-price-wrapper').show();\n } else {\n $('#order-bump-quantity-wrapper').hide();\n $('#order-bump-price-wrapper').hide();\n }\n });\n },\n }","seller_admin.blog_category =\n {\n archive: function () {\n $('body').on('click', '.archive-blog-category', function () {\n var $this = $(this),\n url = $this.attr('href'),\n blogCategorySearchTable = $('table#blog-category-search-table'),\n blogCategoryId = $this.attr('data-blog-category-id'),\n blogCategoryRow = $('tr.blog-category-' + blogCategoryId);\n\n seller_admin.base.assignLoadingModal(\"loadingArchiveBlogCategory\", \"Archiving your blog category...\");\n seller_admin.base.enableLoadingModal(\"#loadingArchiveBlogCategory\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (blogCategorySearchTable.length > 0) {\n blogCategoryRow.replaceWith(data.row);\n } else {\n blogCategoryRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingArchiveBlogCategory\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully archived a blog category.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingArchiveBlogCategory\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n unarchive: function () {\n $('body').on('click', '.unarchive-blog-category', function () {\n var $this = $(this),\n url = $this.attr('href'),\n blogCategorySearchTable = $('table#blog-category-search-table'),\n blogCategoryId = $this.attr('data-blog-category-id'),\n blogCategoryRow = $('tr.blog-category-' + blogCategoryId);\n\n seller_admin.base.assignLoadingModal(\"loadingUnarchiveBlogCategory\", \"Unarchiving your blog category...\");\n seller_admin.base.enableLoadingModal(\"#loadingUnarchiveBlogCategory\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (blogCategorySearchTable.length > 0) {\n blogCategoryRow.replaceWith(data.row);\n } else {\n blogCategoryRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveBlogCategory\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully unarchived a blog category.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveBlogCategory\", $this);\n }\n });\n return false;\n });\n },\n\n updateNameToSlug: function()\n {\n var nameInput = document.getElementById('seller_blog_category_name'),\n slugInput = document.getElementById('seller_blog_category_slug'),\n slugLabel = $('label[for=\"seller_blog_category_slug\"]');\n\n var timeout = null;\n\n if (typeof (nameInput) != 'undefined' && nameInput != null) {\n nameInput.onkeyup = function (e) {\n\n clearTimeout(timeout);\n\n timeout = setTimeout(function () {\n if (slugInput.value === \"\") {\n slugInput.value = seller_admin.base.string_parameterize(nameInput.value);\n slugLabel.addClass('active');\n }\n }, 2000);\n };\n }\n },\n\n formatSlug: function()\n {\n var slugInput = document.getElementById('seller_blog_category_slug');\n\n var timeout = null;\n\n if (typeof (slugInput) != 'undefined' && slugInput != null) {\n slugInput.onkeyup = function (e) {\n\n clearTimeout(timeout);\n\n timeout = setTimeout(function () {\n slugInput.value = seller_admin.base.string_parameterize(slugInput.value);\n }, 500);\n };\n }\n }\n }","seller_admin.blog_post =\n {\n archive: function () {\n $('body').on('click', '.archive-blog-post', function () {\n var $this = $(this),\n url = $this.attr('href'),\n blogPostSearchTable = $('table#blog-post-search-table'),\n blogPostId = $this.attr('data-blog-post-id'),\n blogPostRow = $('tr.blog-post-' + blogPostId);\n\n seller_admin.base.assignLoadingModal(\"loadingArchiveBlogPost\", \"Archiving your blog post...\");\n seller_admin.base.enableLoadingModal(\"#loadingArchiveBlogPost\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (blogPostSearchTable.length > 0) {\n blogPostRow.replaceWith(data.row);\n } else {\n blogPostRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingArchiveBlogPost\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully archived a blog post.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingArchiveBlogPost\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n unarchive: function () {\n $('body').on('click', '.unarchive-blog-post', function () {\n var $this = $(this),\n url = $this.attr('href'),\n blogPostSearchTable = $('table#blog-post-search-table'),\n blogPostId = $this.attr('data-blog-post-id'),\n blogPostRow = $('tr.blog-post-' + blogPostId);\n\n seller_admin.base.assignLoadingModal(\"loadingUnarchiveBlogPost\", \"Unarchiving your blog post...\");\n seller_admin.base.enableLoadingModal(\"#loadingUnarchiveBlogPost\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (blogPostSearchTable.length > 0) {\n blogPostRow.replaceWith(data.row);\n } else {\n blogPostRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveBlogPost\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully unarchived a blog post.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveBlogPost\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n updateNameToSlug: function () {\n var nameInput = document.getElementById('seller_blog_post_title'),\n slugInput = document.getElementById('seller_blog_post_slug'),\n slugLabel = $('label[for=\"seller_blog_post_slug\"]');\n\n var timeout = null;\n\n if (typeof (nameInput) != 'undefined' && nameInput != null) {\n nameInput.onkeyup = function (e) {\n\n clearTimeout(timeout);\n\n timeout = setTimeout(function () {\n if (slugInput.value === \"\") {\n slugInput.value = seller_admin.base.string_parameterize(nameInput.value);\n slugLabel.addClass('active');\n }\n }, 2000);\n };\n }\n },\n\n formatSlug: function () {\n var slugInput = document.getElementById('seller_blog_post_slug');\n\n var timeout = null;\n\n if (typeof (slugInput) != 'undefined' && slugInput != null) {\n slugInput.onkeyup = function (e) {\n\n clearTimeout(timeout);\n\n timeout = setTimeout(function () {\n slugInput.value = seller_admin.base.string_parameterize(slugInput.value);\n }, 500);\n };\n }\n },\n\n bindBlogPostNotification: function (channel) {\n channel.bind('blog_post_publish_list', function (data) {\n var draftBlogPost = $('tbody#blog-posts-table tr.blog-post-' + data.draft_blog_post_id);\n if (draftBlogPost.length > 0) {\n draftBlogPost.find('td.blog-post-publish-status').text(data.publish_status);\n }\n });\n },\n\n saveContent: function () {\n var $this = $(this),\n accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content'),\n blogPostId = $('.is-wrapper').attr('data-blog-post-id'),\n wrapperContent = $('.is-wrapper'),\n html = window.contentBuilder.html();\n\n seller_admin.base.assignLoadingModal(\"loadingSaveBlogPostDesign\", \"Saving your blog post design...\");\n seller_admin.base.enableLoadingModal(\"#loadingSaveBlogPostDesign\", $this);\n\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/blog/posts/' + blogPostId,\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: 'PATCH',\n data: {\n 'seller_blog_post': {'content': html},\n 'version_number': wrapperContent.attr('data-version')\n },\n dataType: 'json',\n success: function (data) {\n seller_admin.base.disableLoadingModal(\"#loadingSaveBlogPostDesign\", $this);\n wrapperContent.attr('data-version', data.version_number);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE SUCCESSFUL\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSaveBlogPostDesign\", $this);\n seller_admin.base.addFlash(\"danger\", \"Failed to save blog post, please try again.\");\n seller_admin.base.scrollTop(\"main\");\n seller_admin.page_designer.versionMismatchModal(xhr.responseJSON.version_mismatch);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE FAILED\");\n }\n });\n },\n\n autoSaveContent: function () {\n var accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content'),\n blogPostId = $('.is-wrapper').attr('data-blog-post-id'),\n wrapperContent = $('.is-wrapper'),\n html = window.contentBuilder.html();\n\n $('#design-image-progress .progress-bar').css('width', '100%');\n\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/blog/posts/' + blogPostId,\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: 'PATCH',\n data: {\n 'seller_blog_post': {'content': html},\n 'version_number': wrapperContent.attr('data-version')\n },\n dataType: 'json',\n success: function (data) {\n seller_admin.base.successfulDesignerAutoSave();\n wrapperContent.attr('data-version', data.version_number);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE SUCCESSFUL\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.failedDesignerAutoSave();\n seller_admin.page_designer.versionMismatchModal(xhr.responseJSON.version_mismatch);\n $('#design-image-progress .progress-bar').css('width', '0%');\n console.log(\"DESIGN UPDATE FAILED\");\n }\n });\n },\n\n publish: function () {\n $('body').on('click', '.publish-blog-post', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingPublishBlogPost\", \"Publishing your blog post...\");\n seller_admin.base.enableLoadingModal(\"#loadingPublishBlogPost\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n dataType: 'json',\n success: function (data) {\n seller_admin.base.disableLoadingModal(\"#loadingPublishBlogPost\", $this);\n seller_admin.base.addFlash(\"success\", \"Updates will appear live in a few moments.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingPublishBlogPost\", $this);\n seller_admin.base.addFlash(\"danger\", \"Failed to publish blog post, please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n }","seller_admin.page_designer =\n {\n\n prepareContent: function () {\n $('body').on('click', '#save-content', function () {\n $('#design-image-progress .progress-bar').css('width', '100%');\n seller_admin.page_designer.uploadBase64Images();\n return false;\n });\n window.addEventListener('load', function () {\n seller_admin.page_designer.enableNavbarActions();\n });\n setTimeout(function () {\n seller_admin.page_designer.enableNavbarActions();\n }, 10000);\n },\n\n enableNavbarActions: function () {\n $('#publish-page-designer').removeClass('disabled');\n $('.exit-page-designer').removeClass('disabled');\n $('#btnPreview').removeClass('disabled');\n $('#save-content').removeClass('disabled');\n },\n\n clearContent: function()\n {\n $('#clear-content-designer').on('click', function()\n {\n seller_admin.base.openModal('#clearContentModal');\n });\n $('#clear-design-trigger').on('click', function()\n {\n var url = $(this).attr('href');\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n window.location = data.redirect_url;\n },\n });\n return false;\n });\n },\n\n versionMismatchModal: function(version_mismatch) {\n if (version_mismatch === true)\n {\n seller_admin.base.openModal('#versionMismatchModal');\n }\n },\n\n uploadCoverImageToCloudinary: function (e) {\n const selectedFile = e.target.files[0],\n cloudinaryEnv = $('meta[name=cloudinary-env]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n cloudName = $('meta[name=cloudinary-cloud-name]').attr('content'),\n uploadPreset = $('meta[name=cloudinary-upload-preset]').attr('content');\n $(e.target).unsigned_cloudinary_upload(uploadPreset,\n {\n cloud_name: cloudName,\n folder: cloudinaryEnv + '/stores/' + storeId + '/designs'\n }\n ).cloudinary_upload_url(selectedFile)\n .on('cloudinarydone', function (e, data) {\n var url = data.result.secure_url;\n var surl = url.split('/upload/');\n var furl = surl[0] + '/upload/fl_lossy/q_auto/' + surl[1];\n window.contentBuilder.boxImage(furl);\n $('#design-image-progress .progress-bar').css('width', '0%');\n }\n ).on('cloudinaryprogress', function (e, data) {\n $('#design-image-progress .progress-bar').css('width',\n Math.round((data.loaded * 100.0) / data.total) + '%');\n\n });\n },\n\n uploadImageToCloudinary: function (img) {\n console.log('hello');\n const cloudinaryEnv = $('meta[name=cloudinary-env]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n cloudName = $('meta[name=cloudinary-cloud-name]').attr('content'),\n uploadPreset = $('meta[name=cloudinary-upload-preset]').attr('content'),\n imgSrc = img.src;\n $(img).unsigned_cloudinary_upload(uploadPreset,\n {\n cloud_name: cloudName,\n folder: cloudinaryEnv + '/stores/' + storeId + '/designs'\n }\n ).cloudinary_upload_url(imgSrc)\n .on('cloudinarydone', function (e, data) {\n var url = data.result.secure_url;\n var surl = url.split('/upload/');\n var furl = surl[0] + '/upload/fl_lossy/q_auto/' + surl[1];\n $(img).attr('src', furl);\n $(img).attr('data-cloudinary-public-id', data.result.public_id);\n }\n ).on('cloudinaryprogress', function (e, data) {\n $('#design-image-progress .progress-bar').css('width',\n Math.round((data.loaded * 100.0) / data.total) + '%');\n\n });\n },\n\n uploadBase64Images: function () {\n window.contentBuilder.saveImages('', () => {\n eval(window.saveContentFunction);\n }, (img, base64, filename) => {\n seller_admin.page_designer.uploadImageToCloudinary(img);\n });\n },\n }","seller_admin.dashboard = {\n\n buildOnPageLoad: function() {\n seller_admin.dashboard.buildInitial();\n // seller_admin.dashboard.buildOrders();\n // seller_admin.dashboard.buildRevenue();\n // seller_admin.dashboard.buildVisitors();\n // seller_admin.dashboard.buildConversions();\n },\n\n resetData: function() {\n $('body').on('click', '#reset-dashboard-data', function() {\n\n seller_admin.base.assignLoadingModal(\"loadingDashboardData\", \"Refreshing Dashboard...\");\n seller_admin.base.enableLoadingModal(\"#loadingDashboardData\", $('main'));\n\n $.ajax(\n {\n url: '/admin/dashboard/reset',\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n seller_admin.base.disableLoadingModal(\"#loadingDashboardData\", $('main'));\n seller_admin.dashboard.buildInitial();\n // seller_admin.dashboard.buildOrders();\n // seller_admin.dashboard.buildRevenue();\n // seller_admin.dashboard.buildVisitors();\n // seller_admin.dashboard.buildConversions();\n }\n });\n return false;\n });\n },\n\n buildInitial: function () {\n $.ajax(\n {\n url: '/admin/dashboard/initial',\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#initial-total-active-subscriptions').text(data.total_active_subscriptions);\n $('#initial-average-order-value').text(data.average_order_value);\n $('#initial-total-shop-orders').text(data.total_shop_orders);\n $('#initial-total-revenue').text(data.total_revenue);\n }\n });\n },\n\n buildOrders: function () {\n $.ajax(\n {\n url: '/admin/dashboard/orders',\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#orders-today').text(data.today);\n $('#orders-yesterday').text(data.yesterday);\n $('#orders-30-day').text(data.last_30_days);\n $('#orders-90-day').text(data.last_90_days);\n }\n });\n },\n\n buildRevenue: function () {\n $.ajax(\n {\n url: '/admin/dashboard/revenue',\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#revenue-today').text(data.today);\n $('#revenue-yesterday').text(data.yesterday);\n $('#revenue-30-day').text(data.last_30_days);\n $('#revenue-90-day').text(data.last_90_days);\n }\n });\n },\n\n buildVisitors: function () {\n $.ajax(\n {\n url: '/admin/dashboard/visitors',\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#visitors-today').text(data.today);\n $('#visitors-yesterday').text(data.yesterday);\n $('#visitors-30-day').text(data.last_30_days);\n $('#visitors-90-day').text(data.last_90_days);\n }\n });\n },\n\n updateDataByDate: function () {\n $('#dashboard-conversions .dateranger').on('apply.daterangepicker', function(ev, picker) {\n var dateRange = $(this).val().replace(/ /g,'');\n\n seller_admin.dashboard.buildConversions(dateRange);\n });\n },\n\n buildConversions: function(dateRange)\n {\n $.ajax(\n {\n url: '/admin/dashboard/date_range?start_end_range=' + dateRange,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#dashboard-conversions #added-to-cart-conversion').text(data.added_to_cart + '%');\n $('#dashboard-conversions #reached-checkout-conversion').text(data.reached_checkout + '%');\n $('#dashboard-conversions #purchased-conversion').text(data.purchased + '%');\n seller_admin.chart.completedOrdersByDateRange(data.orders);\n seller_admin.chart.popularProductsByDateRange(data.products);\n }\n });\n }\n}","seller_admin.customer = {\n duplicateAddress: function () {\n $('.use-delivery-address').change(function () {\n if (this.checked) {\n $('.copy-delivery').each(function () {\n var fieldValue = $(this).val(),\n fieldAttribute = $(this).attr('data-field-name');\n return $('[data-field-name=\"billing-' + fieldAttribute + '\"]').val(fieldValue).focus();\n });\n } else {\n return $('input[data-field-name*=\"billing-\"]').val('');\n }\n });\n },\n\n selectAllCustomers: function () {\n $(\"#check_all_customers\").on('click', function () {\n $('.customer_checkbox').prop('checked', this.checked);\n });\n },\n\n createCsvReport: function () {\n $('#export-customer-csv-button').on('click', function () {\n $('.csv-report-flash').remove();\n var customerIds = [];\n $.each($(\".customer_checkbox:checked\"), function () {\n customerIds.push($(this).val());\n });\n if (customerIds.length === 0) {\n $('#seller-admin-flashes').prepend('You need to select some orders before requesting a CSV report.
');\n seller_admin.base.scrollTop(\"main\");\n } else {\n $.ajax(\n {\n url: '/admin/customer_csvs',\n type: 'POST',\n data: {'customer_ids': customerIds},\n dataType: 'json',\n success: function (data) {\n $('#seller-admin-flashes').prepend('Successfully created the CSV report. Please check your store email for a link to the file.
')\n seller_admin.base.scrollTop(\"main\");\n $('.customer_checkbox').prop('checked', false);\n },\n error: function (xhr, evt, status) {\n $('#seller-admin-flashes').prepend('Unable to create the CSV report. Please try again.
');\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n return false;\n });\n },\n\n changePassword: function () {\n $('body').on('submit', '.change-customer-password-form', function () {\n var $this = $(this),\n url = $(this).attr('action');\n\n seller_admin.base.assignLoadingModal(\"loadingChangeCustomerPassword\", \"Updating the customer's password...\");\n seller_admin.base.enableLoadingModal(\"#loadingChangeCustomerPassword\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#user-confirmed-status').text('Yes');\n $('#change-customer-password-form').modal('hide');\n seller_admin.base.disableLoadingModal(\"#loadingChangeCustomerPassword\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully updated the customer's password.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n $('#change-customer-password-form').modal('hide');\n seller_admin.base.disableLoadingModal(\"#loadingChangeCustomerPassword\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n}","seller_admin.checkout_trust =\n {\n add: function () {\n $('body').on('click', '.create-checkout-trust', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingAddCheckoutTrust\", \"Creating checkout trust...\");\n seller_admin.base.enableLoadingModal(\"#loadingAddCheckoutTrust\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#checkout-trust-modal').html(data.modal);\n seller_admin.base.openModal('#checkout-trust-form');\n $('#checkout-trust-modal .mdb-select').materialSelect();\n $('#checkout-trust-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingAddCheckoutTrust\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingAddCheckoutTrust\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n create: function () {\n $('body').on('submit', '#create-checkout-trust', function () {\n var $this = $(this),\n url = $this.attr('action'),\n formData = new FormData(),\n serializedData = seller_admin.base.getSerializedUrlVars($(this).serialize());\n\n seller_admin.base.enableLoadingModal(\"#loadingAddCheckoutTrust\", $this);\n\n formData.append('checkout_trust[headline]', serializedData['checkout_trust[headline]'].replace(/\\+/g, ' '));\n formData.append('checkout_trust[body]', serializedData['checkout_trust[body]'].replace(/\\+/g, ' '));\n formData.append('checkout_trust[image]', $('#checkout_trust_image')[0].files[0]);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: formData,\n cache: false,\n processData: false,\n contentType: false,\n success: function (data) {\n $('#checkout-trust-form').modal('hide');\n $('#checkout-trusts-table tbody').prepend(data.row);\n seller_admin.base.addCustomFlash('#increase-trust-section', 'success', 'Successfully added a checkout trust to your store.');\n seller_admin.base.disableLoadingModal(\"#loadingAddCheckoutTrust\", $this);\n seller_admin.base.scrollTop(\"#increase-trust-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingAddCheckoutTrust\", $this);\n }\n });\n return false;\n });\n },\n\n edit: function () {\n $('body').on('click', '.edit-checkout-trust', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingEditCheckoutTrust\", \"Updating checkout trust...\");\n seller_admin.base.enableLoadingModal(\"#loadingEditCheckoutTrust\", $this);\n\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#checkout-trust-modal').html(data.modal);\n seller_admin.base.openModal('#checkout-trust-form');\n $('#checkout-trust-modal .mdb-select').materialSelect();\n $('#checkout-trust-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingEditCheckoutTrust\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingEditCheckoutTrust\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n update: function () {\n $('body').on('submit', '#edit-checkout-trust', function () {\n var $this = $(this),\n url = $this.attr('action'),\n formData = new FormData(),\n serializedData = seller_admin.base.getSerializedUrlVars($(this).serialize()),\n checkoutTrustFile = $('#checkout_trust_image')[0].files[0];\n\n seller_admin.base.enableLoadingModal(\"#loadingEditCheckoutTrust\", $this);\n\n formData.append('checkout_trust[headline]', serializedData['checkout_trust[headline]'].replace(/\\+/g, ' '));\n formData.append('checkout_trust[body]', serializedData['checkout_trust[body]'].replace(/\\+/g, ' '));\n if(checkoutTrustFile !== undefined) {\n formData.append('checkout_trust[image]', checkoutTrustFile);\n }\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: formData,\n cache: false,\n processData: false,\n contentType: false,\n success: function (data) {\n $('#checkout-trust-form').modal('hide');\n $('#checkout-trusts-table tbody tr#checkout-trust-' + data.checkout_trust_id).replaceWith(data.row);\n seller_admin.base.addCustomFlash('#increase-trust-section', 'success', 'Successfully updated a checkout trust to your store.');\n seller_admin.base.disableLoadingModal(\"#loadingEditCheckoutTrust\", $this);\n seller_admin.base.scrollTop(\"#increase-trust-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingEditCheckoutTrust\", $this);\n }\n });\n return false;\n });\n },\n\n initSortable: function () {\n $('#sortable-checkout-trust-list').sortable({\n placeholder: \"ui-state-highlight\",\n forcePlaceholderSize: true,\n tolerance: \"pointer\",\n update: function (e, ui) {\n seller_admin.base.enableLoadingModal(\"#loadingSortCheckoutTrust\", $('#sort-checkout-trusts-form'));\n $.ajax(\n {\n url: $(this).data(\"url\"),\n type: \"PATCH\",\n data: $(this).sortable('serialize'),\n success: function (data) {\n $('#checkout-trusts-table tbody').html(data.table);\n seller_admin.base.disableLoadingModal(\"#loadingSortCheckoutTrust\", $('#sort-checkout-trusts-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortCheckoutTrust\", $('#sort-checkout-trusts-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n });\n $(\"#sortable-checkout-trust-list\").disableSelection();\n },\n\n sortModal: function () {\n $('body').on('click', '#reorder-checkout-trusts', function () {\n var url = $(this).attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingSortCheckoutTrust\", \"Sorting your checkout trusts...\");\n seller_admin.base.enableLoadingModal(\"#loadingSortCheckoutTrust\", $('#sort-checkout-trusts-form'));\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#sort-checkout-trusts-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingSortCheckoutTrust\", $('#sort-checkout-trusts-form'));\n seller_admin.base.openModal('#sort-checkout-trusts-form');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortCheckoutTrust\", $('#sort-checkout-trusts-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n remove: function()\n {\n $('body').on('click', '.prompt-remove-checkout-trust', function() {\n var checkoutTrustId = $(this).attr('data-record-id');\n\n seller_admin.base.assignConfirmationModal('remove-checkout-trust',\n 'Are you sure you wish to remove a checkout trust?', checkoutTrustId);\n seller_admin.base.enableConfirmationModal();\n return false;\n });\n $('body').on('click', '.remove-checkout-trust', function () {\n var $this = $(this),\n checkoutTrustId = $this.attr('data-record-id');\n\n seller_admin.base.disableConfirmationModal();\n seller_admin.base.assignLoadingModal(\"loadingRemoveCheckoutTrust\", \"Removing checkout trust from your store...\");\n seller_admin.base.enableLoadingModal(\"#loadingRemoveCheckoutTrust\", $this);\n\n $.ajax(\n {\n url: '/admin/settings/checkout_trusts/' + checkoutTrustId,\n type: 'DELETE',\n dataType: 'json',\n success: function (data) {\n $('tr#checkout-trust-' + checkoutTrustId).remove();\n seller_admin.base.addCustomFlash('#increase-trust-section','success', 'Successfully removed a checkout trust from your store.');\n seller_admin.base.disableLoadingModal(\"#loadingRemoveCheckoutTrust\", $this);\n seller_admin.base.scrollTop(\"#increase-trust-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingRemoveCheckoutTrust\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n }","seller_admin.checkout_additional_fee =\n {\n add: function () {\n $('body').on('click', '.create-checkout-additional-fee', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingAddCheckoutAdditionalFee\", \"Creating checkout additional fee...\");\n seller_admin.base.enableLoadingModal(\"#loadingAddCheckoutAdditionalFee\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#checkout-additional-fee-modal').html(data.modal);\n seller_admin.base.openModal('#checkout-additional-fee-form');\n $('#checkout-additional-fee-modal .mdb-select').materialSelect();\n $('#checkout-additional-fee-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingAddCheckoutAdditionalFee\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingAddCheckoutAdditionalFee\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n create: function () {\n $('body').on('submit', '#create-checkout-additional-fee', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingAddCheckoutAdditionalFee\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#checkout-additional-fee-form').modal('hide');\n $('#checkout-additional-fees-table tbody').prepend(data.row);\n seller_admin.base.addCustomFlash('#additional-fee-section', 'success', 'Successfully added a checkout additional fee to your store.');\n seller_admin.base.disableLoadingModal(\"#loadingAddCheckoutAdditionalFee\", $this);\n seller_admin.base.scrollTop(\"#additional-fee-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingAddCheckoutAdditionalFee\", $this);\n }\n });\n return false;\n });\n },\n\n edit: function () {\n $('body').on('click', '.edit-checkout-additional-fee', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingEditCheckoutAdditionalFee\", \"Updating checkout additional fee...\");\n seller_admin.base.enableLoadingModal(\"#loadingEditCheckoutAdditionalFee\", $this);\n\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#checkout-additional-fee-modal').html(data.modal);\n seller_admin.base.openModal('#checkout-additional-fee-form');\n $('#checkout-additional-fee-modal .mdb-select').materialSelect();\n $('#checkout-additional-fee-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingEditCheckoutAdditionalFee\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingEditCheckoutAdditionalFee\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n update: function () {\n $('body').on('submit', '#edit-checkout-additional-fee', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingEditCheckoutAdditionalFee\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#checkout-additional-fee-form').modal('hide');\n $('#checkout-additional-fees-table tbody tr#checkout-additional-fee-' + data.checkout_additional_fee_id).replaceWith(data.row);\n seller_admin.base.addCustomFlash('#additional-fee-section', 'success', 'Successfully updated a checkout additional fee to your store.');\n seller_admin.base.disableLoadingModal(\"#loadingEditCheckoutAdditionalFee\", $this);\n seller_admin.base.scrollTop(\"#additional-fee-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingEditCheckoutAdditionalFee\", $this);\n }\n });\n return false;\n });\n },\n\n initSortable: function () {\n $('#sortable-checkout-additional-fee-list').sortable({\n placeholder: \"ui-state-highlight\",\n forcePlaceholderSize: true,\n tolerance: \"pointer\",\n update: function (e, ui) {\n seller_admin.base.enableLoadingModal(\"#loadingSortCheckoutAdditionalFee\", $('#sort-checkout-additional-fees-form'));\n $.ajax(\n {\n url: $(this).data(\"url\"),\n type: \"PATCH\",\n data: $(this).sortable('serialize'),\n success: function (data) {\n $('#checkout-additional-fees-table tbody').html(data.table);\n seller_admin.base.disableLoadingModal(\"#loadingSortCheckoutAdditionalFee\", $('#sort-checkout-additional-fees-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortCheckoutAdditionalFee\", $('#sort-checkout-additional-fees-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n });\n $(\"#sortable-checkout-additional-fee-list\").disableSelection();\n },\n\n sortModal: function () {\n $('body').on('click', '#reorder-checkout-additional-fees', function () {\n var url = $(this).attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingSortCheckoutAdditionalFee\", \"Sorting your checkout additional fees...\");\n seller_admin.base.enableLoadingModal(\"#loadingSortCheckoutAdditionalFee\", $('#sort-checkout-additional-fees-form'));\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#sort-checkout-additional-fees-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingSortCheckoutAdditionalFee\", $('#sort-checkout-additional-fees-form'));\n seller_admin.base.openModal('#sort-checkout-additional-fees-form');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortCheckoutAdditionalFee\", $('#sort-checkout-additional-fees-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n remove: function()\n {\n $('body').on('click', '.prompt-remove-checkout-additional-fee', function() {\n var checkoutTrustId = $(this).attr('data-record-id');\n\n seller_admin.base.assignConfirmationModal('remove-checkout-additional-fee',\n 'Are you sure you wish to remove a checkout additional fee?', checkoutTrustId);\n seller_admin.base.enableConfirmationModal();\n return false;\n });\n $('body').on('click', '.remove-checkout-additional-fee', function () {\n var $this = $(this),\n checkoutTrustId = $this.attr('data-record-id');\n\n seller_admin.base.disableConfirmationModal();\n seller_admin.base.assignLoadingModal(\"loadingRemoveCheckoutAdditionalFee\", \"Removing checkout additional fee from your store...\");\n seller_admin.base.enableLoadingModal(\"#loadingRemoveCheckoutAdditionalFee\", $this);\n\n $.ajax(\n {\n url: '/admin/settings/checkout_additional_fees/' + checkoutTrustId,\n type: 'DELETE',\n dataType: 'json',\n success: function (data) {\n $('tr#checkout-additional-fee-' + checkoutTrustId).remove();\n seller_admin.base.addCustomFlash('#additional-fee-section','success', 'Successfully removed a checkout additional fee from your store.');\n seller_admin.base.disableLoadingModal(\"#loadingRemoveCheckoutAdditionalFee\", $this);\n seller_admin.base.scrollTop(\"#additional-fee-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingRemoveCheckoutAdditionalFee\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n }","seller_admin.vendor =\n {\n sendAccountSetupEmail: function()\n {\n $('body').on('click', '.send-account-setup-email-team-member', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingAccountSetupEmailTeamAccount\", \"Sending account setup email to team member...\");\n seller_admin.base.enableLoadingModal(\"#loadingAccountSetupEmailTeamAccount\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n dataType: 'json',\n success: function (data) {\n seller_admin.base.addFlash('success', 'Successfully sent an account setup email to ' + data.email + '.');\n seller_admin.base.disableLoadingModal(\"#loadingAccountSetupEmailTeamAccount\", $this);\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingAccountSetupEmailTeamAccount\", $this);\n seller_admin.base.addFlash('success', 'Vendor has already set up their account');\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n block: function()\n {\n $('body').on('click', '.block-team-member', function () {\n var $this = $(this),\n url = $this.attr('href'),\n teamMemberId = $this.attr('data-team-member-id');\n\n seller_admin.base.assignLoadingModal(\"loadingBlockTeamAccount\", \"Blocking team member from your store...\");\n seller_admin.base.enableLoadingModal(\"#loadingBlockTeamAccount\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('tr#team-member-' + teamMemberId).replaceWith(data.row);\n seller_admin.base.addFlash('success', 'Successfully blocked a team member from your store.');\n seller_admin.base.disableLoadingModal(\"#loadingBlockTeamAccount\", $this);\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingBlockTeamAccount\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n \n unblock: function()\n {\n $('body').on('click', '.unblock-team-member', function () {\n var $this = $(this),\n url = $this.attr('href'),\n teamMemberId = $this.attr('data-team-member-id');\n\n seller_admin.base.assignLoadingModal(\"loadingUnblockTeamAccount\", \"Unblocking team member from your store...\");\n seller_admin.base.enableLoadingModal(\"#loadingUnblockTeamAccount\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('tr#team-member-' + teamMemberId).replaceWith(data.row);\n seller_admin.base.addFlash('success', 'Successfully unblocked a team member from your store.');\n seller_admin.base.disableLoadingModal(\"#loadingUnblockTeamAccount\", $this);\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUnblockTeamAccount\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n remove: function()\n {\n $('body').on('click', '.prompt-remove-team-member', function() {\n var teamMemberId = $(this).attr('data-record-id');\n\n seller_admin.base.assignConfirmationModal('remove-team-member',\n 'Are you sure you wish to remove a team member?', teamMemberId);\n seller_admin.base.enableConfirmationModal();\n return false;\n });\n $('body').on('click', '.remove-team-member', function () {\n var $this = $(this),\n teamMemberId = $this.attr('data-record-id');\n\n seller_admin.base.disableConfirmationModal();\n seller_admin.base.assignLoadingModal(\"loadingRemoveTeamAccount\", \"Removing team member from your store...\");\n seller_admin.base.enableLoadingModal(\"#loadingRemoveTeamAccount\", $this);\n\n $.ajax(\n {\n url: '/admin/vendors/' + teamMemberId,\n type: 'DELETE',\n dataType: 'json',\n success: function (data) {\n $('tr#team-member-' + teamMemberId).remove();\n seller_admin.base.addFlash('success', 'Successfully removed a team member from your store.');\n seller_admin.base.disableLoadingModal(\"#loadingRemoveTeamAccount\", $this);\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingRemoveTeamAccount\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n }","seller_admin.app_integration =\n {\n initAppCategoryFilter: function () {\n var $grid = $('#app-integration.grid').isotope({});\n $grid.imagesLoaded().progress( function() {\n $grid.isotope('layout');\n });\n $('.app-integration-category-group').on('click', 'li', function () {\n var filterValue = $(this).attr('data-filter');\n $grid.isotope({filter: filterValue});\n return false;\n });\n },\n }","seller_admin.order_item = {\n\n editTracking: function () {\n $('body').on('click', '.edit-order-item-tracking', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingEditOrderItemTracking\", \"Updating order item tracking...\");\n seller_admin.base.enableLoadingModal(\"#loadingEditOrderItemTracking\", $('#order-item-tracking-form'));\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#order-item-tracking-modal').html(data.modal);\n seller_admin.base.openModal('#order-item-tracking-form');\n seller_admin.base.disableLoadingModal(\"#loadingEditOrderItemTracking\", $('#order-item-tracking-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingEditOrderItemTracking\", $('#order-item-tracking-form'));\n seller_admin.base.addCustomFlash('#shop-order-items', \"danger\", \"Something went wrong. Please try again.\");\n }\n });\n return false;\n });\n },\n\n updateTracking: function () {\n $('body').on('submit', '#edit-order-item-tracking', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n $('.tracking-flash').remove();\n seller_admin.base.enableLoadingModal(\"#loadingEditOrderItemTracking\", $('#order-item-tracking-form'));\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#order-item-tracking-form').modal('hide');\n seller_admin.base.addCustomFlash('#shop-order-items', 'success tracking-flash', 'Successfully updated an order item tracking.')\n seller_admin.base.disableLoadingModal(\"#loadingEditOrderItemTracking\", $('#order-item-tracking-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingEditOrderItemTracking\", $('#order-item-tracking-form'));\n }\n });\n return false;\n });\n },\n\n singleFulfillOrder: function () {\n $('body').on('click', '.fulfill-shop-order-item', function () {\n var $this = $(this),\n orderItemId = $this.attr('data-order-item-id');\n\n $('.fulfilled-flash').remove();\n\n seller_admin.base.assignLoadingModal(\"loadingFulfillShopOrderItem\", \"Sending your order item to be fulfilled...\");\n seller_admin.base.enableLoadingModal(\"#loadingFulfillShopOrderItem\", $this);\n\n $.ajax(\n {\n url: '/admin/orders/shop/fulfillment/single_order_item',\n type: 'POST',\n data: {'order_item_id': orderItemId},\n dataType: 'json',\n success: function (data) {\n $('tr#order-item-' + orderItemId).replaceWith(data.row);\n $('#order-fulfillment-status').text(data.order_fulfillment_status);\n seller_admin.base.addCustomFlash('#shop-order-items', 'success fulfilled-flash', 'Your order item has been successfully fulfilled.')\n seller_admin.base.disableLoadingModal(\"#loadingFulfillShopOrderItem\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addCustomFlash('#shop-order-items', \"warning fulfilled-flash\", \"Unable to send your order item for fulfillment. Please try again.\");\n seller_admin.base.disableLoadingModal(\"#loadingFulfillShopOrderItem\", $this);\n }\n });\n return false;\n });\n },\n\n bulkFulfillOrder: function () {\n $('#fulfill-shop-orders').on('click', function () {\n var $this = $(this);\n $('.fulfilled-flash').remove();\n\n seller_admin.base.assignLoadingModal(\"loadingFulfillShopOrders\", \"Sending your orders to be fulfilled...\");\n seller_admin.base.enableLoadingModal(\"#loadingFulfillShopOrders\", $this);\n\n var orderIds = [];\n $.each($(\".order_checkbox:checked\"), function () {\n orderIds.push($(this).val());\n });\n if (orderIds.length === 0) {\n seller_admin.base.addFlash(\"warning fulfilled-flash\", \"You need to select some orders before sending them to be fulfilled.\");\n seller_admin.base.disableLoadingModal(\"#loadingFulfillShopOrders\", $this);\n seller_admin.base.scrollTop(\"main\");\n } else {\n $.ajax(\n {\n url: '/admin/orders/shop/fulfillment/bulk',\n type: 'POST',\n data: {'order_ids': orderIds},\n dataType: 'json',\n success: function (data) {\n seller_admin.base.addFlash(\"success fulfilled-flash\", \"Your orders are being fulfilled now. When completed, you will be notified via email. You can safely leave this screen and return at any time.\");\n seller_admin.base.disableLoadingModal(\"#loadingFulfillShopOrders\", $this);\n seller_admin.base.scrollTop(\"main\");\n $('.order_checkbox').prop('checked', false);\n $('#check_all_orders').prop('checked', false);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"warning fulfilled-flash\", \"Unable to send your orders for fulfillment. Please try again.\");\n seller_admin.base.disableLoadingModal(\"#loadingFulfillShopOrders\", $this);\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n return false;\n });\n },\n\n markSingleAsShipped: function () {\n $('body').on('click', '.mark-shop-as-shipped', function () {\n var $this = $(this),\n orderItemId = $this.attr('data-order-item-id');\n\n seller_admin.base.assignLoadingModal(\"loadingMarkSingleShopShipped\", \"Marking your order item as shipped...\");\n seller_admin.base.enableLoadingModal(\"#loadingMarkSingleShopShipped\", $this);\n\n $.ajax(\n {\n url: '/admin/orders/shop/shipping/single_order_item',\n type: 'POST',\n data: {'order_item_id': orderItemId},\n dataType: 'json',\n success: function (data) {\n $('tr#order-item-' + orderItemId).replaceWith(data.row);\n $('#order-shipping-status').text(data.order_shipping_status);\n seller_admin.base.addCustomFlash('#shop-order-items', \"success\", \"Your order item has been marked as shipped.\");\n seller_admin.base.disableLoadingModal(\"#loadingMarkSingleShopShipped\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingMarkSingleShopShipped\", $this);\n seller_admin.base.addCustomFlash('#shop-order-items', \"danger\", \"Something went wrong. Please try again.\");\n }\n });\n return false;\n });\n },\n\n markCollectionAsShipped: function () {\n $('#mark-shops-as-shipped').on('click', function () {\n var $this = $(this);\n $('.shipped-flash').remove();\n\n seller_admin.base.assignLoadingModal(\"loadingMarkShopsShipped\", \"Marking your orders as shipped...\");\n seller_admin.base.enableLoadingModal(\"#loadingMarkShopsShipped\", $this);\n\n var orderIds = [];\n $.each($(\".order_checkbox:checked\"), function () {\n orderIds.push($(this).val());\n });\n if (orderIds.length === 0) {\n seller_admin.base.addFlash(\"warning shipped-flash\", \"You need to select some orders before marking them as shipped.\");\n seller_admin.base.disableLoadingModal(\"#loadingMarkShopsShipped\", $this);\n seller_admin.base.scrollTop(\"main\");\n } else {\n $.ajax(\n {\n url: '/admin/orders/shop/shipping/bulk',\n type: 'POST',\n data: {'order_ids': orderIds},\n dataType: 'json',\n success: function (data) {\n if (data.order_ids !== undefined) {\n for (_i = 0, _len = data.order_ids.length; _i < _len; _i++) {\n value = data.order_ids[_i]\n $('tr.order_' + value + ' td.shipping-status').text('Completed');\n }\n }\n seller_admin.base.addFlash(\"success shipped-flash\", \"Your orders have been marked as shipped.\");\n seller_admin.base.disableLoadingModal(\"#loadingMarkShopsShipped\", $this);\n seller_admin.base.scrollTop(\"main\");\n $('.order_checkbox').prop('checked', false);\n $('#check_all_orders').prop('checked', false);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"warning shipped-flash\", \"Unable to mark your orders as shipped. Please try again.\");\n seller_admin.base.disableLoadingModal(\"#loadingMarkShopsShipped\", $this);\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n return false;\n });\n }\n}","seller_admin.pick_up_location = {\n add: function () {\n $('body').on('click', '.create-pick-up-location', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingAddPickUpLocation\", \"Creating pickup location...\");\n seller_admin.base.enableLoadingModal(\"#loadingAddPickUpLocation\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#pick-up-location-modal').html(data.modal);\n seller_admin.base.openModal('#pick-up-location-form');\n $('#pick-up-location-modal .mdb-select').materialSelect();\n $('#pick-up-location-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingAddPickUpLocation\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingAddPickUpLocation\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n create: function () {\n $('body').on('submit', '#create-pick-up-location', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingAddPickUpLocation\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $(this).serialize(),\n dataType: 'json',\n success: function (data) {\n $('#pick-up-location-form').modal('hide');\n $('#pick-up-locations-table tbody').prepend(data.row);\n seller_admin.base.addCustomFlash('#pick-up-shipping-section', 'success', 'Successfully added a pickup location to your store.');\n seller_admin.base.disableLoadingModal(\"#loadingAddPickUpLocation\", $this);\n seller_admin.base.scrollTop(\"#pick-up-shipping-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingAddPickUpLocation\", $this);\n }\n });\n return false;\n });\n },\n\n edit: function () {\n $('body').on('click', '.edit-pick-up-location', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingEditPickUpLocation\", \"Updating pickup location...\");\n seller_admin.base.enableLoadingModal(\"#loadingEditPickUpLocation\", $this);\n\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#pick-up-location-modal').html(data.modal);\n seller_admin.base.openModal('#pick-up-location-form');\n $('#pick-up-location-modal .mdb-select').materialSelect();\n $('#pick-up-location-modal .mdb-select').click(e => e.stopPropagation());\n seller_admin.base.disableLoadingModal(\"#loadingEditPickUpLocation\", $this);\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingEditPickUpLocation\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n update: function () {\n $('body').on('submit', '#edit-pick-up-location', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingEditPickUpLocation\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $(this).serialize(),\n dataType: 'json',\n success: function (data) {\n $('#pick-up-location-form').modal('hide');\n $('#pick-up-locations-table tbody tr#pick-up-location-' + data.pick_up_location_id).replaceWith(data.row);\n seller_admin.base.addCustomFlash('#pick-up-shipping-section', 'success', 'Successfully updated a pickup location in your store.');\n seller_admin.base.disableLoadingModal(\"#loadingEditPickUpLocation\", $this);\n seller_admin.base.scrollTop(\"#pick-up-shipping-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n seller_admin.base.disableLoadingModal(\"#loadingEditPickUpLocation\", $this);\n }\n });\n return false;\n });\n },\n\n initSortable: function () {\n $('#sortable-pick-up-location-list').sortable({\n placeholder: \"ui-state-highlight\",\n forcePlaceholderSize: true,\n tolerance: \"pointer\",\n update: function (e, ui) {\n seller_admin.base.enableLoadingModal(\"#loadingSortPickUpLocation\", $('#sort-pick-up-locations-form'));\n $.ajax(\n {\n url: $(this).data(\"url\"),\n type: \"PATCH\",\n data: $(this).sortable('serialize'),\n success: function (data) {\n $('#pick-up-locations-table tbody').html(data.table);\n seller_admin.base.disableLoadingModal(\"#loadingSortPickUpLocation\", $('#sort-pick-up-locations-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortPickUpLocation\", $('#sort-pick-up-locations-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n });\n $(\"#sortable-pick-up-location-list\").disableSelection();\n },\n\n sortModal: function () {\n $('body').on('click', '#reorder-pick-up-locations', function () {\n var url = $(this).attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingSortPickUpLocation\", \"Sorting your pickup locations...\");\n seller_admin.base.enableLoadingModal(\"#loadingSortPickUpLocation\", $('#sort-pick-up-locations-form'));\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#sort-pick-up-locations-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingSortPickUpLocation\", $('#sort-pick-up-locations-form'));\n seller_admin.base.openModal('#sort-pick-up-locations-form');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortPickUpLocation\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n remove: function()\n {\n $('body').on('click', '.prompt-remove-pick-up-location', function() {\n var pickUpLocationId = $(this).attr('data-record-id');\n\n seller_admin.base.assignConfirmationModal('remove-pick-up-location',\n 'Are you sure you wish to remove a pick up location?', pickUpLocationId);\n seller_admin.base.enableConfirmationModal();\n return false;\n });\n $('body').on('click', '.remove-pick-up-location', function () {\n var $this = $(this),\n pickUpLocationId = $this.attr('data-record-id');\n\n seller_admin.base.disableConfirmationModal();\n seller_admin.base.assignLoadingModal(\"loadingRemovePickUpLocation\", \"Removing pickup location from your store...\");\n seller_admin.base.enableLoadingModal(\"#loadingRemovePickUpLocation\", $this);\n\n $.ajax(\n {\n url: '/admin/settings/pick_ups/locations/' + pickUpLocationId,\n type: 'DELETE',\n dataType: 'json',\n success: function (data) {\n $('tr#pick-up-location-' + pickUpLocationId).remove();\n seller_admin.base.addCustomFlash('#increase-trust-section','success', 'Successfully removed a pickup location from your store.');\n seller_admin.base.disableLoadingModal(\"#loadingRemovePickUpLocation\", $this);\n seller_admin.base.scrollTop(\"#pick-up-shipping-section\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingRemovePickUpLocation\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n}","seller_admin.pick_up_time = {\n\n add: function (link, association, content) {\n var new_id = new Date().getTime(),\n regexp = new RegExp(\"new_\" + association, \"g\");\n $('#pick-up-times').append(content.replace(regexp, new_id));\n var selectTags = $('div[data-fields-id=\"' + new_id + '\"] select');\n selectTags.materialSelect()\n selectTags.each(function () {\n $(this).click(e => e.stopPropagation());\n });\n },\n\n remove: function (link) {\n $(link).prev(\"input[type=hidden]\").val(\"1\");\n $(link).closest(\".fields\").hide();\n }\n}","seller_admin.pause_option = {\n\n archive: function () {\n $('body').on('click', '.archive-pause-option', function () {\n var $this = $(this),\n url = $this.attr('href'),\n pauseOptionId = $this.attr('data-pause-option-id');\n\n seller_admin.base.assignLoadingModal(\"loadingArchivePauseOption\", \"Disabling your pause option...\");\n seller_admin.base.enableLoadingModal(\"#loadingArchivePauseOption\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('tr.pause-option-' + pauseOptionId).replaceWith(data.row);\n seller_admin.base.disableLoadingModal(\"#loadingArchivePauseOption\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully disabled a pause option.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingArchivePauseOption\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n unarchive: function () {\n $('body').on('click', '.unarchive-pause-option', function () {\n var $this = $(this),\n url = $this.attr('href'),\n pauseOptionId = $this.attr('data-pause-option-id');\n\n seller_admin.base.assignLoadingModal(\"loadingUarchivePauseOption\", \"Enabling your pause option...\");\n seller_admin.base.enableLoadingModal(\"#loadingUarchivePauseOption\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('tr.pause-option-' + pauseOptionId).replaceWith(data.row);\n seller_admin.base.disableLoadingModal(\"#loadingUarchivePauseOption\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully enabled a pause option.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUarchivePauseOption\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n}","seller_admin.survey = {\n\n archive: function () {\n $('body').on('click', '.archive-survey', function () {\n var $this = $(this),\n url = $this.attr('href'),\n surveyId = $this.attr('data-survey-id'),\n surveySearchTable = $('table#survey-search-table'),\n surveyRow = $('tr.survey-' + surveyId);\n\n seller_admin.base.assignLoadingModal(\"loadingArchiveSurvey\", \"Archiving your survey...\");\n seller_admin.base.enableLoadingModal(\"#loadingArchiveSurvey\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (surveySearchTable.length > 0) {\n surveyRow.replaceWith(data.row);\n } else {\n surveyRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingArchiveSurvey\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully archived a survey.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingArchiveSurvey\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n unarchive: function () {\n $('body').on('click', '.unarchive-survey', function () {\n var url = $(this).attr('href'),\n $this = $(this),\n surveyId = $this.attr('data-survey-id'),\n surveySearchTable = $('table#survey-search-table'),\n surveyRow = $('tr.survey-' + surveyId);\n\n seller_admin.base.assignLoadingModal(\"loadingUnarchiveSurvey\", \"Unarchiving your survey...\");\n seller_admin.base.enableLoadingModal(\"#loadingUnarchiveSurvey\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (surveySearchTable.length > 0) {\n surveyRow.replaceWith(data.row);\n } else {\n surveyRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveSurvey\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully unarchived a survey.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveSurvey\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n initOptionsSortable: function () {\n $('#sortable-survey-option-list').sortable({\n placeholder: \"ui-state-highlight\",\n forcePlaceholderSize: true,\n tolerance: \"pointer\",\n update: function (e, ui) {\n seller_admin.base.enableLoadingModal(\"#loadingSortSurveyOptions\", $('#sort-survey-options-form'));\n $.ajax(\n {\n url: $(this).data(\"url\"),\n type: \"PATCH\",\n data: $(this).sortable('serialize'),\n success: function (data) {\n seller_admin.base.disableLoadingModal(\"#loadingSortSurveyOptions\", $('#sort-survey-options-form'));\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortSurveyOptions\", $('#sort-survey-options-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n }\n });\n $(\"#sortable-survey-option-list\").disableSelection();\n },\n\n sortTemplateCategoriesModal: function () {\n $('body').on('click', '.reorder-survey-options', function () {\n var url = $(this).attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingSortSurveyOptions\", \"Sorting your survey options...\");\n seller_admin.base.enableLoadingModal(\"#loadingSortSurveyOptions\", $('#sort-survey-options-form'));\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#sort-survey-options-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingSortSurveyOptions\", $('#sort-survey-options-form'));\n seller_admin.base.openModal('#sort-survey-options-form');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingSortSurveyOptions\", $('#sort-survey-options-form'));\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n addOption: function (link, association, content) {\n var new_id = new Date().getTime(),\n regexp = new RegExp(\"new_\" + association, \"g\");\n $(\"#survey-options\").append(content.replace(regexp, new_id));\n var selectTags = $('div[data-fields-id=\"' + new_id + '\"] select');\n },\n\n removeOption: function (link) {\n $(link).prev(\"input[type=hidden]\").val(\"1\");\n $(link).closest(\".fields\").hide();\n },\n}","seller_admin.churn =\n {\n updateDataByDate: function () {\n $('#churn-date-ranger').on('apply.daterangepicker', function(ev, picker) {\n var dateRange = $(this).val().replace(/ /g,'');\n\n seller_admin.churn.getChartData(dateRange);\n });\n $('select#churn-product-id').on('change', function()\n {\n var dateRange = $('#churn-date-ranger').val().replace(/ /g,'');\n seller_admin.churn.getChartData(dateRange);\n });\n },\n\n getChartData: function (dateRange) {\n var productId = $('#churn-product-id').val();\n\n $.ajax(\n {\n url: '/admin/churn/analytics/date_range?start_end_range=' + dateRange + '&product_id=' + productId,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#churn-data #save-rate').text(data.save_rate + '%');\n $('#churn-data #total-cancel-triggers').text(data.total_cancel_triggers);\n $('#churn-data #total-subscriptions-saved').text(data.total_subscriptions_saved);\n $('#churn-data #estimated-mrr-saved').text(data.estimated_mrr_saved);\n seller_admin.chart.surveyAnswersByDateRange(data.survey_options);\n }\n });\n }\n }","seller_admin.review =\n {\n edit: function ()\n {\n $('body').on('click', '.edit-review', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#edit-review-modal').html(data.modal);\n seller_admin.base.openModal('#edit-review-form');\n $('#edit-review-modal .mdb-select').materialSelect();\n $('#edit-review-modal .mdb-select').click(e => e.stopPropagation());\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n update: function () {\n $(\"body\").on(\"submit\", '#edit-review', function () {\n var url = $(this).attr('action'),\n $this = $(this);\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n data: $(this).serialize(),\n dataType: 'json',\n success: function (data) {\n $('#edit-review-form').modal('hide');\n $('tr#review-' + data.id + ' .publish-status').text(data.publish_status);\n seller_admin.base.addFlash(\"success\", \"Successfully updated a review.\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.jsonErrors(xhr, evt, status, $this);\n }\n });\n return false;\n });\n },\n\n archive: function () {\n $('body').on('click', '.archive-review', function () {\n var $this = $(this),\n url = $this.attr('href'),\n reviewId = $this.attr('data-review-id'),\n reviewRow = $('tr#review-' + reviewId);\n\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n reviewRow.replaceWith(data.row);\n seller_admin.base.addFlash(\"success\", \"Successfully archived a review.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n unarchive: function()\n {\n $('body').on('click', '.unarchive-review', function () {\n var $this = $(this),\n url = $this.attr('href'),\n reviewId = $this.attr('data-review-id'),\n reviewRow = $('tr#review-' + reviewId);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n reviewRow.replaceWith(data.row);\n seller_admin.base.addFlash(\"success\", \"Successfully unarchived a review.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n }","seller_admin.lite =\n {\n revealAuthToken: function () {\n $('.reveal-auth-token').on('click', function () {\n $('#store-authentication-token').removeClass('blur');\n $('.hide-auth-token').show();\n $('.reveal-auth-token').hide();\n return false;\n });\n },\n\n hideAuthToken: function () {\n $('.hide-auth-token').on('click', function () {\n $('#store-authentication-token').addClass('blur');\n $('.reveal-auth-token').show();\n $('.hide-auth-token').hide();\n return false;\n });\n },\n\n verifyDomain: function() {\n $('#verify-domain-trigger').on('click', function() {\n seller_admin.base.openModal(\"#verifyingDomainModal\");\n $('.verify-domain-flash').remove();\n $.ajax(\n {\n url: '/admin/settings/product_embed/verify_domain',\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (data.success) {\n $('.verified-domain-badge-wrapper').html('Verified');\n seller_admin.base.addCustomFlash('#verified-domain-section', 'success verify-domain-flash', 'Successfully verified the TXT record for your domain.');\n seller_admin.base.scrollTop(\"#verified-domain-section\");\n } else {\n $('.verified-domain-badge-wrapper').html('Pending');\n seller_admin.base.addCustomFlash('#verified-domain-section', 'danger verify-domain-flash', 'Could not verify the TXT record for your domain, please try again.');\n seller_admin.base.scrollTop(\"#verified-domain-section\");\n }\n $('#verifyingDomainModal').modal('hide');\n },\n error: function (xhr, evt, status) {\n $('.verified-domain-badge-wrapper').html('Pending');\n seller_admin.base.addCustomFlash('#verified-domain-section', 'danger verify-domain-flash', 'Could not verify TXT record, please try again.');\n seller_admin.base.scrollTop(\"#verified-domain-section\");\n $('#verifyingDomainModal').modal('hide');\n }\n });\n return false;\n });\n },\n\n\n openProductEmbedModal: function()\n {\n $('#open-product-embed-modal').click(function() {\n seller_admin.base.openModal('#product-lite-embed-form')\n });\n },\n\n embedProductVariant: function()\n {\n window.baseApiUrl = $('meta[name=base-api-url]').attr('content');\n $('body').on('change', '#lite_product_id', function() {\n var productId = $(this).val(),\n accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content'),\n selectElem = $('#lite_sale_option');\n\n $('#product-lite-embed-form .modal-content-overlay').show();\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/products/' + productId + '/sale_options',\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n selectElem.empty();\n selectElem.append('');\n for (var i = 0; i < data.sale_options.length; i++) {\n selectElem.append('');\n }\n $('#lite-embed-sale-option').css('display', 'flex');\n $('#product-lite-embed-form .modal-content-overlay').hide();\n },\n error: function (xhr, evt, status) {\n $('#product-lite-embed-form .modal-content-overlay').hide();\n }\n });\n });\n },\n\n embedProductSaleOption: function()\n {\n window.baseApiUrl = $('meta[name=base-api-url]').attr('content');\n $('body').on('change', '#lite_sale_option', function() {\n var saleOption = $(this).val(),\n productId = $('#lite_product_id').val(),\n accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content'),\n selectElemPlan = $('#lite_plan_id'),\n selectElemVariant = $('#lite_variant_id');\n\n $('#product-lite-embed-form .modal-content-overlay').show();\n if(saleOption ==='subscription' || saleOption == 'gift')\n {\n if(saleOption ==='subscription') {\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/products/' + productId + '/plans/subscription',\n headers: {\n 'access-token': accessToken,\n 'client': clientId,\n 'uid': uid,\n 'store-id': storeId\n },\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n selectElemPlan.empty();\n for (var i = 0; i < data.plans.length; i++) {\n selectElemPlan.append('');\n }\n $('#lite-embed-plan-id').css('display', 'flex');\n seller_admin.lite.updateProductEmbed();\n $('#product-lite-embed-form .modal-content-overlay').hide();\n },\n error: function (xhr, evt, status) {\n $('#product-lite-embed-form .modal-content-overlay').hide();\n }\n });\n }\n if (saleOption == 'gift')\n {\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/products/' + productId + '/plans/gift',\n headers: {\n 'access-token': accessToken,\n 'client': clientId,\n 'uid': uid,\n 'store-id': storeId\n },\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n selectElemPlan.empty();\n for (var i = 0; i < data.plans.length; i++) {\n selectElemPlan.append('');\n }\n $('#lite-embed-plan-id').css('display', 'flex');\n seller_admin.lite.updateProductEmbed();\n $('#product-lite-embed-form .modal-content-overlay').hide();\n },\n error: function (xhr, evt, status) {\n $('#product-lite-embed-form .modal-content-overlay').hide();\n }\n });\n }\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/products/' + productId + '/variants',\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n selectElemVariant.empty();\n for (var i = 0; i < data.variants.length; i++) {\n var skuName = data.variants[i]['sku'],\n skuName = skuName === 'MA' ? 'MA (Master)' : skuName;\n selectElemVariant.append('');\n }\n $('#lite-embed-variant-id').css('display', 'flex');\n seller_admin.lite.updateProductEmbed();\n $('#product-lite-embed-form .modal-content-overlay').hide();\n },\n error: function (xhr, evt, status) {\n $('#product-lite-embed-form .modal-content-overlay').hide();\n }\n });\n } else {\n $('#lite-embed-plan-id').hide();\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/products/' + productId + '/variants',\n headers: {'access-token': accessToken, 'client': clientId, 'uid': uid, 'store-id': storeId},\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n selectElemVariant.empty();\n for (var i = 0; i < data.variants.length; i++) {\n var skuName = data.variants[i]['sku'],\n skuName = skuName === 'MA' ? 'MA (Master)' : skuName;\n selectElemVariant.append('');\n }\n $('#lite-embed-variant-id').css('display', 'flex');\n seller_admin.lite.updateProductEmbed();\n $('#product-lite-embed-form .modal-content-overlay').hide();\n },\n error: function (xhr, evt, status) {\n $('#product-lite-embed-form .modal-content-overlay').hide();\n }\n });\n }\n });\n },\n\n productEmbedTrigger: function()\n {\n $('#product-lite-embed-form #lite_button_border').on('change', function() {\n seller_admin.lite.updateProductEmbed();\n });\n $('#product-lite-embed-form #lite_button_background_color').on('change', function() {\n seller_admin.lite.updateProductEmbed();\n });\n $('#product-lite-embed-form #lite_button_background_color').on('change', function() {\n seller_admin.lite.updateProductEmbed();\n });\n var textInput = document.getElementById('lite_button_txt'),\n timeout = null;\n\n if (typeof (textInput) != 'undefined' && textInput != null) {\n textInput.onkeyup = function (e) {\n\n clearTimeout(timeout);\n\n timeout = setTimeout(function () {\n seller_admin.lite.updateProductEmbed();\n }, 500);\n };\n }\n },\n\n newColorPicker: function (targetElem, defaultColor, inputField) {\n new Pickr({\n el: targetElem,\n default: defaultColor,\n components: {\n preview: true,\n opacity: true,\n hue: true,\n\n interaction: {\n hex: true,\n rgba: true,\n input: true,\n clear: true,\n save: true\n }\n },\n onChange(hsva, instance) {\n $(inputField).val(hsva.toRGBA().toString());\n seller_admin.lite.updateProductEmbed();\n }\n });\n },\n\n updateProductEmbed: function()\n {\n var backgroundColorVal = $('#product-lite-embed-form #lite_button_background_color').val(),\n textColorVal = $('#product-lite-embed-form #lite_button_text_color').val(),\n borderDecorationVal = $('#product-lite-embed-form #lite_button_border').val(),\n borderDecoration = borderDecorationVal === 'sharp' ? '0.125rem' : '0.25rem',\n buttonText = $('#product-lite-embed-form #lite_button_txt').val(),\n variantId = $('#product-lite-embed-form #lite_variant_id').val(),\n planId = $('#product-lite-embed-form #lite_plan_id').val(),\n saleOption = $('#product-lite-embed-form #lite_sale_option').val(),\n cartItemTriggerClass = saleOption === 'single_purchase' ? 'sublite-add-single-cart-item' : 'sublite-add-recurring-cart-item'\n\n if(saleOption === 'single_purchase') {\n planId = undefined;\n }\n if(planId === undefined) {\n var buttonHtml = '' + buttonText + '
'\n } else {\n var buttonHtml = '' + buttonText + '
'\n }\n $('#product-embed-demo-element').html(buttonHtml);\n $('#product_embed_button_code').val(buttonHtml);\n }\n }","seller_admin.free_gift = {\n\n addRule: function (link, association, content) {\n var new_id = new Date().getTime(),\n regexp = new RegExp(\"new_\" + association, \"g\");\n $(\"#free-gift-rules\").append(content.replace(regexp, new_id));\n var selectTags = $('div[data-fields-id=\"' + new_id + '\"] select');\n selectTags.materialSelect();\n selectTags.each(function () {\n $(this).click(e => e.stopPropagation());\n });\n },\n\n removeRule: function (link) {\n $(link).prev(\"input[type=hidden]\").val(\"1\");\n $(link).closest(\".fields\").hide();\n },\n\n changeFilterType: function () {\n $('body').on('change', 'select.free-gift-rule-filter-type', function () {\n var $this = $(this),\n parentWrapper = $this.parent().parent().parent();\n seller_admin.free_gift.updateConditionSelect(parentWrapper, this.value);\n if (this.value === 'cart_item') {\n parentWrapper.find('.free-gift-rule-filter-value-wrapper').show();\n parentWrapper.find('.free-gift-rule-filter-value-wrapper div label').text('Quantity');\n parentWrapper.find('.free-gift-rule-product-id-wrapper').show();\n } else if (this.value === 'cart_subtotal') {\n parentWrapper.find('.free-gift-rule-filter-value-wrapper').show();\n parentWrapper.find('.free-gift-rule-filter-value-wrapper div label').text('Cart value');\n parentWrapper.find('.free-gift-rule-product-id-wrapper').hide();\n }\n });\n },\n\n updateConditionSelect: function (parentWrapper, selectValue) {\n var conditions = window.free_gift_rule_conditions[selectValue],\n selectElem = parentWrapper.find('select.free-gift-rule-condition');\n selectElem.empty();\n for (var i = 0; i < conditions.length; i++) {\n selectElem.append('');\n }\n },\n\n updateVariantSelect: function(productId)\n {\n var $this = $(this),\n accessToken = $('meta[name=api-access-token]').attr('content'),\n clientId = $('meta[name=api-client]').attr('content'),\n storeId = $('meta[name=store-id]').attr('content'),\n uid = $('meta[name=api-uid]').attr('content'),\n selectElemVariant = $('#free_gift_variant_id');\n\n $.ajax(\n {\n url: window.baseApiUrl + '/v1/store/products/' + productId + '/variants',\n headers: {\n 'access-token': accessToken,\n 'client': clientId,\n 'uid': uid,\n 'store-id': storeId\n },\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n selectElemVariant.empty();\n for (var i = 0; i < data.variants.length; i++) {\n var skuName = data.variants[i]['sku'],\n skuName = skuName === 'MA' ? 'MA (Master)' : skuName;\n selectElemVariant.append('');\n }\n },\n error: function (xhr, evt, status) {\n }\n });\n },\n\n selectProduct: function()\n {\n $('body').on('change', '#free_gift_product_id', function() {\n seller_admin.free_gift.updateVariantSelect($(this).val());\n });\n },\n\n archive: function () {\n $('body').on('click', '.archive-free-gift', function () {\n var $this = $(this),\n url = $this.attr('href'),\n freeGiftId = $this.attr('data-free-gift-id'),\n freeGiftSearchTable = $('table#free-gift-search-table'),\n freeGiftRow = $('tr.free_gift-' + freeGiftId);\n\n seller_admin.base.assignLoadingModal(\"loadingArchiveFreeGift\", \"Archiving your free gift...\");\n seller_admin.base.enableLoadingModal(\"#loadingArchiveFreeGift\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (freeGiftSearchTable.length > 0) {\n freeGiftRow.replaceWith(data.row);\n } else {\n freeGiftRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingArchiveFreeGift\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully archived a free gift.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingArchiveFreeGift\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n unarchive: function () {\n $('body').on('click', '.unarchive-free-gift', function () {\n var url = $(this).attr('href'),\n $this = $(this),\n freeGiftId = $this.attr('data-free-gift-id'),\n freeGiftSearchTable = $('table#free-gift-search-table'),\n freeGiftRow = $('tr.free_gift-' + freeGiftId);\n\n seller_admin.base.assignLoadingModal(\"loadingUnarchiveFreeGift\", \"Unarchiving your free gift...\");\n seller_admin.base.enableLoadingModal(\"#loadingUnarchiveFreeGift\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n if (freeGiftSearchTable.length > 0) {\n freeGiftRow.replaceWith(data.row);\n } else {\n freeGiftRow.remove();\n }\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveFreeGift\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully unarchived a free gift.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUnarchiveFreeGift\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n remove: function () {\n $('body').on('click', '.prompt-remove-free-gift', function() {\n var freeGiftId = $(this).attr('data-record-id');\n\n seller_admin.base.assignConfirmationModal('remove-free-gift',\n 'Are you sure you wish to remove your free gift?', freeGiftId);\n seller_admin.base.enableConfirmationModal();\n return false;\n });\n $('body').on('click', '.remove-free-gift', function () {\n var $this = $(this),\n freeGiftId = $this.attr('data-record-id'),\n freeGiftRow = $('tr.free_gift-' + freeGiftId);\n\n seller_admin.base.disableConfirmationModal();\n seller_admin.base.assignLoadingModal(\"loadingRemoveFreeGift\", \"Removing your free gift...\");\n seller_admin.base.enableLoadingModal(\"#loadingRemoveFreeGift\", $this);\n\n $.ajax(\n {\n url: '/admin/free_gifts/' + freeGiftId,\n type: 'DELETE',\n dataType: 'json',\n success: function (data) {\n freeGiftRow.remove();\n seller_admin.base.disableLoadingModal(\"#loadingRemoveFreeGift\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully removed a free gift.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingRemoveFreeGift\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n }\n}","seller_admin.dunning =\n {\n updateDataByDate: function () {\n $('#dunning-date-ranger').on('apply.daterangepicker', function(ev, picker) {\n var dateRange = $(this).val().replace(/ /g,'');\n\n seller_admin.dunning.getDashboardData(dateRange);\n });\n $('select#churn-product-id').on('change', function()\n {\n var dateRange = $('#dunning-date-ranger').val().replace(/ /g,'');\n seller_admin.dunning.getDashboardData(dateRange);\n });\n },\n\n getDashboardData: function (dateRange) {\n\n $.ajax(\n {\n url: '/admin/dunning/analytics/date_range?start_end_range=' + dateRange,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#dunning-total-data #recovered-revenue').text(data.recovered_revenue);\n $('#dunning-date-data #dunning-email-1').text(data.dunning_1);\n $('#dunning-date-data #dunning-email-2').text(data.dunning_2);\n $('#dunning-date-data #dunning-email-3').text(data.dunning_3);\n }\n });\n }\n }","seller_admin.incentive_email =\n {\n publish: function () {\n $('body').on('click', '.publish-incentive-email', function () {\n var $this = $(this),\n url = $this.attr('href'),\n incentiveEmailId = $this.attr('data-incentive-email-id');\n\n seller_admin.base.assignLoadingModal(\"loadingPublishIncentiveEmail\", \"Publishing your incentive email template...\");\n seller_admin.base.enableLoadingModal(\"#loadingPublishIncentiveEmail\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('tr.incentive-email-' + incentiveEmailId).replaceWith(data.row);\n seller_admin.base.disableLoadingModal(\"#loadingPublishIncentiveEmail\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully published an incentive email template.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingPublishIncentiveEmail\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n unpublish: function () {\n $('body').on('click', '.unpublish-incentive-email', function () {\n var $this = $(this),\n url = $this.attr('href'),\n incentiveEmailId = $this.attr('data-incentive-email-id');\n\n seller_admin.base.assignLoadingModal(\"loadingUnpublishIncentiveEmail\", \"Unpublishing your incentive email template...\");\n seller_admin.base.enableLoadingModal(\"#loadingUnpublishIncentiveEmail\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('tr.incentive-email-' + incentiveEmailId).replaceWith(data.row);\n seller_admin.base.disableLoadingModal(\"#loadingUnpublishIncentiveEmail\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully unpublished an incentive email template.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUnpublishIncentiveEmail\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n sendTestEmailModal: function () {\n $('body').on('click', '.send-incentive-test-email-modal', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingTestIncentiveEmail\", \"Sending test incentive email...\");\n seller_admin.base.enableLoadingModal(\"#loadingTestIncentiveEmail\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#send-test-email-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingTestIncentiveEmail\", $this);\n seller_admin.base.openModal('#test-incentive-email-form');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingTestIncentiveEmail\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n sendTestEmail: function () {\n $('body').on('submit', '#send-test-incentive-email', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingTestIncentiveEmail\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#test-incentive-email-form').modal('hide');\n seller_admin.base.disableLoadingModal(\"#loadingTestIncentiveEmail\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully sent a test email for \" + data.incentive_email.subject + \".\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n $('#test-incentive-email-form #errors ul').html(\"Invalid email, please try again.\");\n $('#test-incentive-email-form .json-error-wrapper').show();\n seller_admin.base.disableLoadingModal(\"#loadingTestIncentiveEmail\", $this);\n }\n });\n return false;\n });\n }\n }","seller_admin.review_email =\n {\n publish: function () {\n $('body').on('click', '.publish-review-email', function () {\n var $this = $(this),\n url = $this.attr('href'),\n reviewEmailId = $this.attr('data-review-email-id');\n\n seller_admin.base.assignLoadingModal(\"loadingPublishReviewEmail\", \"Publishing your review email template...\");\n seller_admin.base.enableLoadingModal(\"#loadingPublishReviewEmail\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('tr.review-email-' + reviewEmailId).replaceWith(data.row);\n seller_admin.base.disableLoadingModal(\"#loadingPublishReviewEmail\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully published an review email template.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingPublishReviewEmail\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n unpublish: function () {\n $('body').on('click', '.unpublish-review-email', function () {\n var $this = $(this),\n url = $this.attr('href'),\n reviewEmailId = $this.attr('data-review-email-id');\n\n seller_admin.base.assignLoadingModal(\"loadingUnpublishReviewEmail\", \"Unpublishing your review email template...\");\n seller_admin.base.enableLoadingModal(\"#loadingUnpublishReviewEmail\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'PATCH',\n dataType: 'json',\n success: function (data) {\n $('tr.review-email-' + reviewEmailId).replaceWith(data.row);\n seller_admin.base.disableLoadingModal(\"#loadingUnpublishReviewEmail\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully unpublished an review email template.\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingUnpublishReviewEmail\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n sendTestEmailModal: function () {\n $('body').on('click', '.send-review-test-email-modal', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingTestReviewEmail\", \"Sending test review email...\");\n seller_admin.base.enableLoadingModal(\"#loadingTestReviewEmail\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#send-test-email-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingTestReviewEmail\", $this);\n seller_admin.base.openModal('#test-review-email-form');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingTestReviewEmail\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n sendTestEmail: function () {\n $('body').on('submit', '#send-test-review-email', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingTestReviewEmail\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#test-review-email-form').modal('hide');\n seller_admin.base.disableLoadingModal(\"#loadingTestReviewEmail\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully sent a test email for \" + data.email_template.subject + \".\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n $('#test-review-email-form #errors ul').html(\"Invalid email, please try again.\");\n $('#test-review-email-form .json-error-wrapper').show();\n seller_admin.base.disableLoadingModal(\"#loadingTestReviewEmail\", $this);\n }\n });\n return false;\n });\n }\n }","seller_admin.dunning_email =\n {\n\n sendTestEmailModal: function () {\n $('body').on('click', '.send-dunning-test-email-modal', function () {\n var $this = $(this),\n url = $this.attr('href');\n\n seller_admin.base.assignLoadingModal(\"loadingTestDunningEmail\", \"Sending test dunning email...\");\n seller_admin.base.enableLoadingModal(\"#loadingTestDunningEmail\", $this);\n\n $.ajax(\n {\n url: url,\n type: \"GET\",\n dataType: \"json\",\n success: function (data) {\n $('#send-test-email-wrapper').html(data.modal);\n seller_admin.base.disableLoadingModal(\"#loadingTestDunningEmail\", $this);\n seller_admin.base.openModal('#test-dunning-email-form');\n },\n error: function (xhr, evt, status) {\n seller_admin.base.disableLoadingModal(\"#loadingTestDunningEmail\", $this);\n seller_admin.base.addFlash(\"danger\", \"Something went wrong. Please try again.\");\n seller_admin.base.scrollTop(\"main\");\n }\n });\n return false;\n });\n },\n\n sendTestEmail: function () {\n $('body').on('submit', '#send-test-dunning-email', function () {\n var $this = $(this),\n url = $this.attr('action');\n\n seller_admin.base.enableLoadingModal(\"#loadingTestDunningEmail\", $this);\n\n $.ajax(\n {\n url: url,\n type: 'POST',\n data: $this.serialize(),\n dataType: 'json',\n success: function (data) {\n $('#test-dunning-email-form').modal('hide');\n seller_admin.base.disableLoadingModal(\"#loadingTestDunningEmail\", $this);\n seller_admin.base.addFlash(\"success\", \"Successfully sent a test email for \" + data.email_template.subject + \".\");\n seller_admin.base.scrollTop(\"main\");\n },\n error: function (xhr, evt, status) {\n $('#test-dunning-email-form #errors ul').html(\"Invalid email, please try again.\");\n $('#test-dunning-email-form .json-error-wrapper').show();\n seller_admin.base.disableLoadingModal(\"#loadingTestDunningEmail\", $this);\n }\n });\n return false;\n });\n }\n }","seller_admin.api = {\n revealAuthToken: function () {\n $('.reveal-api-token').on('click', function () {\n $('#store-api-token').removeClass('blur');\n $('.hide-auth-token').show();\n $('.reveal-auth-token').hide();\n return false;\n });\n },\n\n hideAuthToken: function () {\n $('.hide-api-token').on('click', function () {\n $('#store-api-token').addClass('blur');\n $('.reveal-auth-token').show();\n $('.hide-auth-token').hide();\n return false;\n });\n },\n}","ready = function () {\n seller_admin.base.mdbootstrap();\n seller_admin.base.subscribeStoreChannel();\n seller_admin.base.populateCountryAlpha2();\n seller_admin.base.datePicker();\n seller_admin.base.dateRangePicker();\n seller_admin.base.initCharCounter(\"#product_description\", \"#product-description-char-count\", 400);\n seller_admin.base.initCharCounter(\"#store_nav_design_announce_text\", \"#nav-design-announce-char-count\", 104);\n seller_admin.base.initCharCounter(\"#store_statement_descriptor\", \"#statement-descriptor-char-count\", 22);\n seller_admin.base.initDragDropFileUpload($('.file-upload'));\n seller_admin.base.changeSearchLimitParam();\n seller_admin.base.disabledLink();\n\n seller_admin.base.initDataTables('#products-table', 4);\n seller_admin.base.initDataTables('#product-search-table', 4);\n seller_admin.base.initDataTables('#collections-table', 2);\n seller_admin.base.initDataTables('#collection-search-table', 2);\n seller_admin.base.initDataTables('#inventory-table', 3);\n\n seller_admin.dashboard.updateDataByDate();\n seller_admin.dashboard.resetData();\n seller_admin.churn.updateDataByDate();\n seller_admin.dunning.updateDataByDate();\n\n seller_admin.notification.markAsRead();\n seller_admin.notification.markAllAsRead();\n\n seller_admin.onboarding.changePlan();\n seller_admin.onboarding.termsDisablePlaceOrder();\n\n seller_admin.tax_rule.add();\n seller_admin.tax_rule.create();\n seller_admin.tax_rule.edit();\n seller_admin.tax_rule.update();\n seller_admin.tax_rule.archive();\n\n seller_admin.shipping.add();\n seller_admin.shipping.create();\n seller_admin.shipping.edit();\n seller_admin.shipping.update();\n seller_admin.shipping.remove();\n seller_admin.shipping.onChangeWeightUnit();\n\n seller_admin.app_integration.initAppCategoryFilter();\n\n seller_admin.email_integration.revealApiKey();\n seller_admin.email_integration.hidelApiKey();\n seller_admin.email_integration.add();\n seller_admin.email_integration.create();\n seller_admin.email_integration.edit();\n seller_admin.email_integration.update();\n seller_admin.email_integration.remove();\n seller_admin.email_integration.updateMailchimpForm();\n\n seller_admin.email_integration_rule.add();\n seller_admin.email_integration_rule.create();\n seller_admin.email_integration_rule.edit();\n seller_admin.email_integration_rule.update();\n seller_admin.email_integration_rule.remove();\n seller_admin.email_integration_rule.changeFilterType();\n\n seller_admin.inventory.newStock();\n seller_admin.inventory.createStock();\n\n seller_admin.collection.updateNameToSlug();\n seller_admin.collection.formatSlug();\n seller_admin.collection.initProductsSortable();\n seller_admin.collection.sortProductsModal();\n seller_admin.collection.archive();\n seller_admin.collection.unarchive();\n seller_admin.collection.remove();\n\n seller_admin.product.create();\n seller_admin.product.edit();\n seller_admin.product.updateNameToSlug();\n seller_admin.product.formatSlug();\n seller_admin.product.scheduledPublishModal();\n seller_admin.product.scheduledPublish();\n seller_admin.product.initImagesSortable();\n seller_admin.product.newDuplicate();\n seller_admin.product.createDuplicate();\n seller_admin.product.preArchiveWarning();\n seller_admin.product.confirmArchive();\n seller_admin.product.unarchive();\n seller_admin.product.publish();\n seller_admin.product.unpublish();\n seller_admin.product.changeShippingType();\n seller_admin.product.changeProductType();\n seller_admin.product.imageVariantsModal();\n seller_admin.product.updateImageVariants();\n seller_admin.product.createCsvReport();\n seller_admin.product.changeGoogleMerchant();\n\n seller_admin.variant.initTagit();\n seller_admin.variant.addOptionType();\n seller_admin.variant.removeOptionType();\n seller_admin.variant.add();\n seller_admin.variant.create();\n seller_admin.variant.edit();\n seller_admin.variant.update();\n seller_admin.variant.archive();\n seller_admin.variant.sortEditOptionTypesModal();\n seller_admin.variant.sortEditOptionValuesModal();\n seller_admin.variant.createModalOptiontype();\n seller_admin.variant.createOptionType();\n seller_admin.variant.removeModalOptiontype();\n seller_admin.variant.removeModalOptiontypeSubmit();\n\n\n seller_admin.plan.purchaseDateRebillSelect();\n seller_admin.plan.purchaseDateRebillOnLoad();\n seller_admin.plan.archive();\n seller_admin.plan.sortModal();\n seller_admin.plan.planTypeSelect();\n\n seller_admin.gift.archive();\n seller_admin.gift.sortModal();\n\n seller_admin.stock_movement.createStockCollection();\n\n seller_admin.transaction.newRefund();\n seller_admin.transaction.createRefund();\n\n seller_admin.order.selectAllOrders();\n seller_admin.order.selectAllOrderAttributes();\n seller_admin.order.openCsvReportModal();\n seller_admin.order.createCsvReport();\n seller_admin.order.retryPayment();\n seller_admin.order.shopSingleFulfillOrder();\n seller_admin.order.shopMarkSingleAsShipped();\n seller_admin.order.singleFulfillOrder();\n seller_admin.order.bulkFulfillOrder();\n seller_admin.order.markSingleAsShipped();\n seller_admin.order.markCollectionAsShipped();\n seller_admin.order.createSingleEmailPdf();\n seller_admin.order.createCombinedEmailPdf();\n seller_admin.order.pickedUpOrder();\n\n seller_admin.subscription.createSingleEmailPdf();\n seller_admin.subscription.createCombinedEmailPdf();\n seller_admin.subscription.pause();\n\n seller_admin.order_item.editTracking();\n seller_admin.order_item.updateTracking();\n seller_admin.order_item.singleFulfillOrder();\n seller_admin.order_item.bulkFulfillOrder();\n seller_admin.order_item.markSingleAsShipped();\n seller_admin.order_item.markCollectionAsShipped();\n\n seller_admin.page.updateNameToSlug();\n seller_admin.page.formatSlug();\n seller_admin.page.sortPagesModal();\n seller_admin.page.newDuplicate();\n seller_admin.page.createDuplicate();\n seller_admin.page.publish();\n seller_admin.page.remove();\n\n seller_admin.billing.updateCountryAlpha2();\n\n seller_admin.nav_item.addFormChangeNavType();\n seller_admin.nav_item.sortModal();\n seller_admin.nav_item.remove();\n\n seller_admin.template.initTemplateCategoryFilter();\n seller_admin.template.previewModal();\n\n seller_admin.discount.create();\n seller_admin.discount.edit();\n seller_admin.discount.changeDiscountSaleOption();\n seller_admin.discount.changeDiscountType();\n seller_admin.discount.archive();\n seller_admin.discount.changeFilterType();\n\n seller_admin.cart_abandonment.publishEmail();\n seller_admin.cart_abandonment.unpublishEmail();\n seller_admin.cart_abandonment.sendTestEmailModal();\n seller_admin.cart_abandonment.sendTestEmail();\n seller_admin.cart_abandonment.cancel();\n\n seller_admin.incentive_email.publish();\n seller_admin.incentive_email.unpublish();\n seller_admin.incentive_email.sendTestEmailModal();\n seller_admin.incentive_email.sendTestEmail();\n\n seller_admin.review_email.publish();\n seller_admin.review_email.unpublish();\n seller_admin.review_email.sendTestEmailModal();\n seller_admin.review_email.sendTestEmail();\n\n seller_admin.dunning_email.sendTestEmailModal();\n seller_admin.dunning_email.sendTestEmail();\n\n seller_admin.member_post.archive();\n seller_admin.member_post.unarchive();\n seller_admin.member_post.newDuplicate();\n seller_admin.member_post.createDuplicate();\n seller_admin.member_post.initSortableList();\n seller_admin.member_post.sortModal();\n seller_admin.member_post.publish();\n seller_admin.member_post.updateTitleToSlug();\n seller_admin.member_post.formatSlug();\n\n seller_admin.member_category.archive();\n seller_admin.member_category.unarchive();\n seller_admin.member_category.sortModal();\n\n seller_admin.order_bump.create();\n seller_admin.order_bump.edit();\n seller_admin.order_bump.changeFilterType();\n seller_admin.order_bump.archive();\n seller_admin.order_bump.unarchive();\n seller_admin.order_bump.changeOverridePrice();\n\n seller_admin.blog_category.archive();\n seller_admin.blog_category.unarchive();\n seller_admin.blog_category.updateNameToSlug();\n seller_admin.blog_category.formatSlug();\n\n seller_admin.blog_post.archive();\n seller_admin.blog_post.unarchive();\n seller_admin.blog_post.updateNameToSlug();\n seller_admin.blog_post.formatSlug();\n seller_admin.blog_post.publish();\n\n seller_admin.customer.duplicateAddress();\n seller_admin.customer.selectAllCustomers();\n seller_admin.customer.createCsvReport();\n seller_admin.customer.changePassword();\n\n seller_admin.checkout_trust.add();\n seller_admin.checkout_trust.create();\n seller_admin.checkout_trust.edit();\n seller_admin.checkout_trust.update();\n seller_admin.checkout_trust.remove();\n seller_admin.checkout_trust.sortModal();\n\n seller_admin.checkout_additional_fee.add();\n seller_admin.checkout_additional_fee.create();\n seller_admin.checkout_additional_fee.edit();\n seller_admin.checkout_additional_fee.update();\n seller_admin.checkout_additional_fee.remove();\n seller_admin.checkout_additional_fee.sortModal();\n\n seller_admin.pick_up_location.add();\n seller_admin.pick_up_location.create();\n seller_admin.pick_up_location.edit();\n seller_admin.pick_up_location.update();\n seller_admin.pick_up_location.sortModal();\n seller_admin.pick_up_location.remove();\n\n seller_admin.vendor.sendAccountSetupEmail();\n seller_admin.vendor.block();\n seller_admin.vendor.unblock();\n seller_admin.vendor.remove();\n\n seller_admin.setting.changeDefaultShippingCountry();\n\n seller_admin.pause_option.archive();\n seller_admin.pause_option.unarchive();\n\n seller_admin.survey.archive();\n seller_admin.survey.unarchive();\n seller_admin.survey.sortTemplateCategoriesModal();\n\n seller_admin.lite.revealAuthToken();\n seller_admin.lite.hideAuthToken();\n seller_admin.lite.verifyDomain();\n seller_admin.lite.openProductEmbedModal();\n seller_admin.lite.embedProductVariant();\n seller_admin.lite.embedProductSaleOption();\n seller_admin.lite.productEmbedTrigger();\n\n seller_admin.free_gift.changeFilterType();\n seller_admin.free_gift.selectProduct();\n seller_admin.free_gift.remove();\n seller_admin.free_gift.archive();\n seller_admin.free_gift.unarchive();\n\n seller_admin.review.edit();\n seller_admin.review.update();\n seller_admin.review.archive();\n seller_admin.review.unarchive();\n\n seller_admin.api.revealAuthToken();\n seller_admin.api.hideAuthToken();\n}\n\n$(document).ready(ready);\n\n$(document).ajaxComplete(function() {\n\n seller_admin.variant.initTagit();\n\n seller_admin.variant.initOptionTypeSortable();\n seller_admin.variant.initSortableOptionValueList();\n seller_admin.nav_item.initSortable();\n seller_admin.pick_up_location.initSortable();\n seller_admin.page.initSortable();\n seller_admin.gift.initSortableList();\n seller_admin.plan.initSortableList();\n seller_admin.member_category.initSortable();\n seller_admin.member_post.initSortableList();\n seller_admin.checkout_trust.initSortable();\n seller_admin.checkout_additional_fee.initSortable();\n seller_admin.survey.initOptionsSortable();\n\n $(\"input[type=text]\").trigger(\"focusin\");\n $(\"input[type=text]\").trigger(\"blur\");\n});"],"sourceRoot":""}