FleetCart/Themes/Storefront/resources/assets/public/js/functions.js

70 lines
1.7 KiB
JavaScript
Raw Permalink Normal View History

2023-12-03 14:07:47 +00:00
import Vue from "vue";
2023-06-11 12:14:03 +00:00
export function notify(message, options = {}) {
Vue.$toast.open({
message,
2023-12-03 14:07:47 +00:00
type: "default",
2023-06-11 12:14:03 +00:00
duration: 3000,
2023-12-03 14:07:47 +00:00
position: screen.width < 992 ? "bottom" : "bottom-right",
2023-06-11 12:14:03 +00:00
...options,
});
}
export function trans(langKey, replace = {}) {
let line = window.FleetCart.langs[langKey];
for (let key in replace) {
line = line.replace(`:${key}`, replace[key]);
}
return line;
}
export function isEmpty(value) {
return $.isEmptyObject(value);
}
export function chunk(array, size) {
let chunkedArray = [];
let index = 0;
while (index < array.length) {
chunkedArray.push(array.slice(index, size + index));
index += size;
}
return chunkedArray;
}
export function slickPrevArrow() {
if (window.FleetCart.rtl) {
return `<div class="arrow-prev">
2023-12-03 14:07:47 +00:00
<i class="las la-angle-right"></i> ${trans(
"storefront::layout.prev"
)}
2023-06-11 12:14:03 +00:00
</div>`;
}
return `<div class="arrow-prev">
2023-12-03 14:07:47 +00:00
<i class="las la-angle-left"></i> ${trans(
"storefront::layout.prev"
)}
2023-06-11 12:14:03 +00:00
</div>`;
}
export function slickNextArrow() {
if (window.FleetCart.rtl) {
return `<div class="arrow-next">
2023-12-03 14:07:47 +00:00
${trans(
"storefront::layout.next"
)} <i class="las la-angle-left"></i>
2023-06-11 12:14:03 +00:00
</div>`;
}
return `<div class="arrow-next">
2023-12-03 14:07:47 +00:00
${trans(
"storefront::layout.next"
)} <i class="las la-angle-right"></i>
2023-06-11 12:14:03 +00:00
</div>`;
}