feat(svg_icon): Add standard svg icons
-Adds icons to use with the svg_icon smarty helper in the is_themecore module. See is_themecore-PS9 repo. - Uses chevron svg icons by default on bootstrap touchspin AND on main menu if it has children.
This commit is contained in:
@ -1,90 +1,108 @@
|
||||
import $ from 'jquery';
|
||||
import prestashop from 'prestashop';
|
||||
import $ from "jquery";
|
||||
import prestashop from "prestashop";
|
||||
|
||||
$(() => {
|
||||
const createInputFile = () => {
|
||||
$('.js-file-input').on('change', (event) => {
|
||||
const target = $(event.currentTarget)[0];
|
||||
const file = (target) ? target.files[0] : null;
|
||||
const createInputFile = () => {
|
||||
$(".js-file-input").on("change", (event) => {
|
||||
const target = $(event.currentTarget)[0];
|
||||
const file = target ? target.files[0] : null;
|
||||
|
||||
if (target && file) {
|
||||
$(target).prev().text(file.name);
|
||||
}
|
||||
});
|
||||
};
|
||||
if (target && file) {
|
||||
$(target).prev().text(file.name);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
const createProductSpin = () => {
|
||||
const $quantityInput = $('#quantity_wanted');
|
||||
const createProductSpin = () => {
|
||||
const $quantityInput = $("#quantity_wanted");
|
||||
|
||||
$quantityInput.TouchSpin({
|
||||
verticalupclass: 'material-icons touchspin-up',
|
||||
verticaldownclass: 'material-icons touchspin-down',
|
||||
buttondown_class: 'btn btn-touchspin js-touchspin',
|
||||
buttonup_class: 'btn btn-touchspin js-touchspin',
|
||||
min: parseInt($quantityInput.attr('min'), 10),
|
||||
max: 1000000,
|
||||
});
|
||||
$quantityInput.TouchSpin({
|
||||
min: parseInt($quantityInput.attr("min"), 10),
|
||||
max: 1000000,
|
||||
verticalbuttons: true,
|
||||
verticalupclass: "btn btn-touchspin js-touchspin",
|
||||
verticaldownclass: "btn btn-touchspin js-touchspin",
|
||||
verticalup:
|
||||
'<img src="/themes/falcon/_dev/img/chevron_up.svg" alt="Up" />',
|
||||
verticaldown:
|
||||
'<img src="/themes/falcon/_dev/img/chevron_down.svg" alt="Down" />',
|
||||
});
|
||||
|
||||
$quantityInput.on('focusout', () => {
|
||||
if ($quantityInput.val() === '' || $quantityInput.val() < $quantityInput.attr('min')) {
|
||||
$quantityInput.val($quantityInput.attr('min'));
|
||||
$quantityInput.trigger('change');
|
||||
}
|
||||
});
|
||||
$quantityInput.on("focusout", () => {
|
||||
if (
|
||||
$quantityInput.val() === "" ||
|
||||
$quantityInput.val() < $quantityInput.attr("min")
|
||||
) {
|
||||
$quantityInput.val($quantityInput.attr("min"));
|
||||
$quantityInput.trigger("change");
|
||||
}
|
||||
});
|
||||
|
||||
$('body').on('change keyup', '#quantity_wanted', (event) => {
|
||||
$(event.currentTarget).trigger('touchspin.stopspin');
|
||||
prestashop.emit('updateProduct', {
|
||||
eventType: 'updatedProductQuantity',
|
||||
event,
|
||||
});
|
||||
});
|
||||
};
|
||||
$("body").on("change keyup", "#quantity_wanted", (event) => {
|
||||
$(event.currentTarget).trigger("touchspin.stopspin");
|
||||
prestashop.emit("updateProduct", {
|
||||
eventType: "updatedProductQuantity",
|
||||
event,
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
createProductSpin();
|
||||
createInputFile();
|
||||
let updateEvenType = false;
|
||||
|
||||
prestashop.on('updateProduct', ({ eventType }) => {
|
||||
updateEvenType = eventType;
|
||||
});
|
||||
|
||||
prestashop.on('updateCart', (event) => {
|
||||
if (
|
||||
prestashop.page.page_name === 'product'
|
||||
&& parseInt(event.reason.idProduct, 10) === parseInt($('#add-to-cart-or-refresh').find('[name="id_product"]').val(), 10)) {
|
||||
prestashop.emit('updateProduct', {
|
||||
event,
|
||||
resp: {},
|
||||
reason: {
|
||||
productUrl: prestashop.urls.pages.product || '',
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
prestashop.on('updatedProduct', (event) => {
|
||||
createProductSpin();
|
||||
createInputFile();
|
||||
let updateEvenType = false;
|
||||
|
||||
if (event && event.product_minimal_quantity) {
|
||||
const minimalProductQuantity = parseInt(event.product_minimal_quantity, 10);
|
||||
const quantityInputSelector = '#quantity_wanted';
|
||||
const quantityInput = $(quantityInputSelector);
|
||||
prestashop.on("updateProduct", ({ eventType }) => {
|
||||
updateEvenType = eventType;
|
||||
});
|
||||
|
||||
// @see http://www.virtuosoft.eu/code/bootstrap-touchspin/ about Bootstrap TouchSpin
|
||||
quantityInput.trigger('touchspin.updatesettings', {
|
||||
min: minimalProductQuantity,
|
||||
});
|
||||
}
|
||||
prestashop.on("updateCart", (event) => {
|
||||
if (
|
||||
prestashop.page.page_name === "product" &&
|
||||
parseInt(event.reason.idProduct, 10) ===
|
||||
parseInt(
|
||||
$("#add-to-cart-or-refresh")
|
||||
.find('[name="id_product"]')
|
||||
.val(),
|
||||
10
|
||||
)
|
||||
) {
|
||||
prestashop.emit("updateProduct", {
|
||||
event,
|
||||
resp: {},
|
||||
reason: {
|
||||
productUrl: prestashop.urls.pages.product || "",
|
||||
},
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
if (updateEvenType === 'updatedProductCombination') {
|
||||
$('.js-product-images').replaceWith(event.product_cover_thumbnails);
|
||||
$('.js-product-images-modal').replaceWith(event.product_images_modal);
|
||||
prestashop.emit('updatedProductCombination', event);
|
||||
}
|
||||
prestashop.on("updatedProduct", (event) => {
|
||||
createInputFile();
|
||||
|
||||
updateEvenType = false;
|
||||
if (event && event.product_minimal_quantity) {
|
||||
const minimalProductQuantity = parseInt(
|
||||
event.product_minimal_quantity,
|
||||
10
|
||||
);
|
||||
const quantityInputSelector = "#quantity_wanted";
|
||||
const quantityInput = $(quantityInputSelector);
|
||||
|
||||
prestashop.pageLazyLoad.update();
|
||||
});
|
||||
// @see http://www.virtuosoft.eu/code/bootstrap-touchspin/ about Bootstrap TouchSpin
|
||||
quantityInput.trigger("touchspin.updatesettings", {
|
||||
min: minimalProductQuantity,
|
||||
});
|
||||
}
|
||||
|
||||
if (updateEvenType === "updatedProductCombination") {
|
||||
$(".js-product-images").replaceWith(event.product_cover_thumbnails);
|
||||
$(".js-product-images-modal").replaceWith(
|
||||
event.product_images_modal
|
||||
);
|
||||
prestashop.emit("updatedProductCombination", event);
|
||||
}
|
||||
|
||||
updateEvenType = false;
|
||||
|
||||
prestashop.pageLazyLoad.update();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user