/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "/";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = 36);
/******/ })
/************************************************************************/
/******/ ({
/***/ "./resources/js/admin/new_product.js":
/*!*******************************************!*\
!*** ./resources/js/admin/new_product.js ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports) {
function _createForOfIteratorHelper(o, allowArrayLike) { var it; if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = o[Symbol.iterator](); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
(function ($) {
"use strict";
if (jQuery().summernote) {
makeSummernote($('#summernote'), 400);
}
$('body').on('change', '#unlimitedInventorySwitch', function () {
var inventoryInputs = $('.js-inventory-inputs');
if (this.checked) {
inventoryInputs.addClass('d-none');
} else {
inventoryInputs.removeClass('d-none');
}
});
$('body').on('click', '.add-btn', function (e) {
var mainRow = $('.main-row');
var imagesCount = $('.product-images-input-group').length;
if (imagesCount < 4) {
var copy = mainRow.clone();
copy.removeClass('main-row');
copy.removeClass('d-none');
var addBtn = copy.find('.add-btn');
if (addBtn) {
addBtn.removeClass('add-btn btn-primary').addClass('btn-danger remove-btn');
var icon = addBtn.find('i');
icon.removeClass();
icon.addClass('fa fa-times');
}
var copyHtml = copy.prop('innerHTML');
copyHtml = copyHtml.replaceAll('record', randomString());
copyHtml = copyHtml.replaceAll('btn-primary', 'btn-danger');
copyHtml = copyHtml.replaceAll('add-btn', 'remove-btn');
copy.html(copyHtml);
$('#productImagesInputs').append(copy);
} else {
$.toast({
heading: requestFailedLang,
text: maxFourImageCanSelect,
bgColor: '#f63c3c',
textColor: 'white',
hideAfter: 10000,
position: 'bottom-right',
icon: 'error'
});
}
});
$('body').on('click', '.remove-btn', function (e) {
e.preventDefault();
$(this).closest('.input-group').remove();
});
function randomString() {
var text = "";
var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
for (var i = 0; i < 4; i++) {
text += possible.charAt(Math.floor(Math.random() * possible.length));
}
return text;
}
$('body').on('click', '#productAddFile', function (e) {
e.preventDefault();
var nameId = randomString();
var add_file_modal = '
';
add_file_modal += $('#productFileModal').html();
add_file_modal += '
';
add_file_modal = add_file_modal.replaceAll('str_', '');
add_file_modal = add_file_modal.replaceAll('record', nameId);
Swal.fire({
html: add_file_modal,
showCancelButton: false,
showConfirmButton: false,
customClass: {
content: 'p-0 text-left'
},
width: '48rem',
onOpen: function onOpen() {
var $form = $('#addFilesModal form');
handleFileItemsByType($form);
}
});
});
$('body').on('click', '.js-show-description', function (e) {
e.preventDefault();
var message = $(this).parent().find('input[type="hidden"]').val();
var $modal = $('#fileDescriptionModal');
$modal.find('.modal-body').html(message);
$modal.modal('show');
});
$('body').on('click', '.edit-file', function (e) {
e.preventDefault();
var $this = $(this);
loadingSwl();
editFile($this);
});
$('body').on('change', '.js-edit-file-locale-ajax', function (e) {
e.preventDefault();
var $this = $(this);
var locale = $this.val();
editFile($this, locale);
});
function editFile($this) {
var locale = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
var file_id = $this.attr('data-file-id');
var product_id = $this.attr('data-product-id');
var edit_data = {
product_id: product_id,
locale: locale
};
$.post(adminPanelPrefix + '/store/products/files/' + file_id + '/edit', edit_data, function (result) {
if (result && result.file) {
var file = result.file;
createEditFileModal(file);
}
});
}
function createEditFileModal(file) {
var edit_file_modal = '';
edit_file_modal += $('#productFileModal').html();
edit_file_modal += '
';
edit_file_modal = edit_file_modal.replaceAll('/files/store', '/files/' + file.id + '/update');
edit_file_modal = edit_file_modal.replaceAll('str_', '');
var random = randomString();
edit_file_modal = edit_file_modal.replaceAll('record', random);
Swal.fire({
html: edit_file_modal,
showCancelButton: false,
showConfirmButton: false,
customClass: {
content: 'p-0 text-left'
},
width: '48rem',
onOpen: function onOpen() {
var $modal = $('#addFilesModal');
Object.keys(file).forEach(function (key) {
if (key === 'status') {
var checked = file.status === 'active';
$modal.find('input[name="' + key + '"]').prop('checked', checked);
} else if (key === 'online_viewer') {
var _checked = file.online_viewer && file.online_viewer === 1;
$modal.find('input[name="' + key + '"]').prop('checked', _checked);
} else {
$modal.find('[name="' + key + '"]').val(file[key]);
}
});
var localeSelect = $modal.find('select[name="locale"]');
if (localeSelect) {
localeSelect.addClass('js-edit-file-locale-ajax');
localeSelect.attr('data-file-id', file.id);
localeSelect.attr('data-product-id', file.product_id);
}
var $form = $modal.find('form');
handleFileItemsByType($form);
}
});
}
$('body').on('click', '#saveFile', function (e) {
e.preventDefault();
var $this = $(this);
var form = $('#addFilesModal form');
var action = form.attr('action');
handleProductItemForm(form, $this, action);
});
function handleProductItemForm(form, $this, action) {
$this.addClass('loadingbar gray').prop('disabled', true);
form.find('input').removeClass('is-invalid');
form.find('textarea').removeClass('is-invalid');
var formData = new FormData();
var items = form.find('input, textarea, select').serializeArray();
$.each(items, function () {
formData.append(this.name, this.value);
});
$.ajax({
url: action,
type: 'POST',
data: formData,
processData: false,
contentType: false,
cache: false,
success: function success(result) {
if (result && result.code === 200) {
//window.location.reload();
Swal.fire({
icon: 'success',
html: '' + saveSuccessLang + '
',
showConfirmButton: false,
width: '25rem'
});
setTimeout(function () {
window.location.reload();
}, 500);
}
},
error: function error(err) {
$this.removeClass('loadingbar gray').prop('disabled', false);
var errors = err.responseJSON;
if (errors && errors.errors) {
Object.keys(errors.errors).forEach(function (key) {
var error = errors.errors[key];
var element = form.find('[name="' + key + '"]');
element.addClass('is-invalid');
element.parent().find('.invalid-feedback').text(error[0]);
});
}
}
});
}
function handleSpecificationTags(elClassName) {
if (jQuery().tagsinput) {
var input_tags = $('.' + elClassName);
input_tags.tagsinput({
tagClass: 'badge badge-primary',
maxTags: input_tags.data('max-tag') ? input_tags.data('max-tag') : 10
});
}
}
function handleSpecificationSelect2(elClassName) {
var el = $('.' + elClassName);
if (el && el.length) {
el.select2({
placeholder: $(this).data('placeholder'),
//minimumInputLength: 3,
allowClear: true
/*ajax: {
url: adminPanelPrefix + '/store/products/specifications/search',
dataType: 'json',
type: "POST",
quietMillis: 50,
data: function (params) {
return {
term: params.term,
category_id: $('#categories').val(),
};
},
processResults: function (data) {
return {
results: $.map(data, function (item) {
return {
text: item.title,
id: item.id,
input_type: item.input_type,
}
})
};
}
}*/
});
el.on('change', function (e) {
var specificationId = e.target.value;
var $form = $(e.target).closest('.specification-form');
handleSpecificationInputType($form, specificationId);
});
}
}
function handleSpecificationMultiValueSelect2(elClassName) {
var el = $('.' + elClassName);
if (el && el.length) {
el.select2();
}
}
$(document).ready(function () {
handleSpecificationMultiValueSelect2('select-multi-values-select2');
handleSpecificationSelect2('search-specification-select2');
});
function handleSpecificationInputType($form, specificationId) {
$.get(adminPanelPrefix + '/store/products/specifications/' + specificationId + '/get', function (result) {
if (result) {
var specification = result.specification,
multiValues = result.multiValues;
var multiValuesInput = $form.find('.js-multi-values-input');
var summaryInput = $form.find('.js-summery-input');
var allowSelectionInput = $form.find('.js-allow-selection-input');
$form.find('.js-input-type').val(specification.input_type);
allowSelectionInput.find('input').prop('checked', false);
if (specification.input_type === 'multi_value') {
multiValuesInput.removeClass('d-none');
allowSelectionInput.removeClass('d-none');
summaryInput.addClass('d-none');
var select = $('.multi_values-select2');
var html = '';
if (multiValues) {
var _iterator = _createForOfIteratorHelper(multiValues),
_step;
try {
for (_iterator.s(); !(_step = _iterator.n()).done;) {
var multiValue = _step.value;
html += "");
}
} catch (err) {
_iterator.e(err);
} finally {
_iterator.f();
}
}
select.append(html);
handleSpecificationMultiValueSelect2('multi_values-select2');
} else {
multiValuesInput.addClass('d-none');
allowSelectionInput.addClass('d-none');
summaryInput.removeClass('d-none');
}
allowSelectionInput.find('input').prop('checked', false);
}
});
}
$('body').on('click', '#productAddSpecification', function (e) {
e.preventDefault();
var key = randomString();
$(this).closest('.col-12').find('.no-result').addClass('d-none').removeClass('d-flex');
var html = $('#newSpecificationForm').html();
html = html.replaceAll('record', key);
html = html.replaceAll('specification-select2', 'search-specification-select2-' + key);
html = html.replaceAll('multi_values-select', 'multi_values-select2');
html = html.replaceAll('input_tags', 'input_tags-' + key);
$('#specificationsAccordion').prepend(html);
handleSpecificationTags('input_tags-' + key);
handleSpecificationSelect2('search-specification-select2-' + key);
});
$('body').on('click', '.js-save-specification', function (e) {
e.preventDefault();
var $this = $(this);
var form = $this.closest('.specification-form');
var action = form.attr('data-action');
handleProductItemForm(form, $this, action);
});
$('body').on('click', '.cancel-accordion', function (e) {
e.preventDefault();
$(this).closest('.col-12').find('.no-result').removeClass('d-none').addClass('d-flex');
$(this).closest('.accordion-row').remove();
});
$('body').on('click', '#productAddFAQ', function (e) {
e.preventDefault();
$(this).closest('.col-12').find('.no-result').addClass('d-none').removeClass('d-flex');
var key = randomString();
var html = $('#newFaqForm').html();
html = html.replaceAll('record', key);
$('#faqsAccordion').prepend(html);
});
$('body').on('click', '.js-save-faq', function (e) {
e.preventDefault();
var $this = $(this);
var form = $this.closest('.faq-form');
var action = form.attr('data-action');
handleProductItemForm(form, $this, action);
});
$('body').on('click', '#saveAndPublish', function (e) {
e.preventDefault();
$('#productStatusInput').val('active');
$('#productForm').trigger('submit');
});
$('body').on('click', '#saveReject', function (e) {
e.preventDefault();
$('#productStatusInput').val('inactive');
$('#productForm').trigger('submit');
});
$('body').on('change', '#categories', function (e) {
e.preventDefault();
var category_id = this.value;
$.get(adminPanelPrefix + '/store/products/filters/get-by-category-id/' + category_id, function (result) {
if (result && typeof result.filters !== "undefined" && result.filters.length) {
var defaultLocale = result.defaultLocale;
var html = '';
Object.keys(result.filters).forEach(function (key) {
var filter = result.filters[key];
var options = [];
if (filter.options.length) {
options = filter.options;
}
var filterTitle = filter.title;
if (!filterTitle && filter.translations) {
filterTitle = handleGetFiltersTitleFromTranslations(filter.translations, defaultLocale);
}
html += '\n' + '
\n' + '
' + filterTitle + '\n' + '
\n' + '\n';
if (options.length) {
Object.keys(options).forEach(function (index) {
var option = options[index];
var optionTitle = option.title;
if (!optionTitle && option.translations) {
optionTitle = handleGetFiltersTitleFromTranslations(option.translations, defaultLocale);
}
html += '
\n' + '
\n' + '
\n' + '\n' + '\n' + '
\n' + '
\n';
});
}
html += '
';
});
$('#categoriesFiltersContainer').removeClass('d-none');
$('#categoriesFiltersCard').html(html);
} else {
$('#categoriesFiltersContainer').addClass('d-none');
$('#categoriesFiltersCard').html('');
}
});
});
function handleGetFiltersTitleFromTranslations(translations, defaultLocale) {
var title = null;
if (Object.keys(translations).length) {
Object.keys(translations).forEach(function (key) {
var translation = translations[key];
if (translation.locale === defaultLocale) {
title = translation.title;
}
});
if (!title) {
title = translations[0].title;
}
}
return title;
}
$('body').on('change', '.js-product-content-locale', function (e) {
e.preventDefault();
var $this = $(this);
var $form = $(this).closest('.js-content-form');
var locale = $this.val();
var productId = $this.attr('data-product-id');
var item_id = $this.attr('data-id');
var relation = $this.attr('data-relation');
var fields = $this.attr('data-fields');
fields = fields.split(',');
$this.addClass('loadingbar gray');
var path = adminPanelPrefix + '/store/products/' + productId + '/getContentItemByLocale';
var data = {
item_id: item_id,
locale: locale,
relation: relation
};
$.post(path, data, function (result) {
if (result && result.item) {
var item = result.item;
Object.keys(item).forEach(function (key) {
var value = item[key];
if ($.inArray(key, fields) !== -1) {
var elKey = key;
if (relation === 'selectedSpecifications') {
elKey = 'tags';
if (item.type === 'textarea') {
elKey = 'summary';
}
}
var element = $form.find('.js-ajax-' + elKey);
if (elKey === 'tags') {
element.tagsinput('destroy');
}
element.val(value);
if (elKey === 'tags') {
var randomClass = 'tags-' + randomString();
element.addClass(randomClass);
handleSpecificationTags(randomClass);
}
}
});
$this.removeClass('loadingbar gray');
}
}).fail(function (err) {
$this.removeClass('loadingbar gray');
});
});
$('body').on('change', '.js-ajax-file_type', function (e) {
e.preventDefault();
var $form = $(this).closest('form'); //const source = formGroup.find('.js-file-storage').val();
handleFileItemsByType($form);
});
function handleFileItemsByType($form) {
var fileType = $form.find('.js-ajax-file_type').val();
var $onlineViewerInput = $form.find('.js-online_viewer-input');
if (fileType && fileType === 'pdf') {
$onlineViewerInput.removeClass('d-none');
} else {
$onlineViewerInput.find('input').prop('checked', false);
$onlineViewerInput.addClass('d-none');
}
}
})(jQuery);
/***/ }),
/***/ 36:
/*!*************************************************!*\
!*** multi ./resources/js/admin/new_product.js ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(/*! /home/jack/projects/webinar/resources/js/admin/new_product.js */"./resources/js/admin/new_product.js");
/***/ })
/******/ });