Skip to content

Saleor Core: the high performance, composable, headless commerce API.

use default prettier config

Julian Böhnkef28e7d854de2
diff --git a/.gitignore b/.gitignore
index 6b28c378af..b1f4b63a3e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,7 +13,6 @@
!.npmrc
!.nvmrc
!.plop
-!.prettierrc.json
!.pylintrc
!.testcafe
!.travis*
diff --git a/.prettierrc.json b/.prettierrc.json
deleted file mode 100644
index ffdb9e97f7..0000000000
--- a/.prettierrc.json
+++ /dev/null
@@ -1,17 +0,0 @@
-{
- "arrowParens": "avoid",
- "bracketSpacing": true,
- "htmlWhitespaceSensitivity": "css",
- "insertPragma": false,
- "jsxBracketSameLine": false,
- "jsxSingleQuote": false,
- "printWidth": 80,
- "proseWrap": "preserve",
- "quoteProps": "as-needed",
- "requirePragma": false,
- "semi": true,
- "singleQuote": true,
- "tabWidth": 2,
- "trailingComma": "none",
- "useTabs": false
-}
diff --git a/saleor/static/dashboard/js/components/async-form.js b/saleor/static/dashboard/js/components/async-form.js
index 3139ae23b9..d9a523ca3d 100644
--- a/saleor/static/dashboard/js/components/async-form.js
+++ b/saleor/static/dashboard/js/components/async-form.js
@@ -1,16 +1,16 @@
-import { initSelects } from './selects';
+import { initSelects } from "./selects";
const onAsyncFormSubmit = e => {
const $target = $(e.currentTarget);
- let $action = $target.attr('action');
- const $submitButton = $target.find('button[type=submit][clicked=true]');
- const $formAction = $submitButton.attr('formaction');
+ let $action = $target.attr("action");
+ const $submitButton = $target.find("button[type=submit][clicked=true]");
+ const $formAction = $submitButton.attr("formaction");
if (typeof $formAction !== typeof undefined && $formAction !== false) {
$action = $formAction;
}
$.ajax({
url: $action,
- method: 'POST',
+ method: "POST",
data: $target.serialize(),
complete: response => {
// Write HTML if got 400 response, otherwise pretend nothing happened
@@ -18,7 +18,7 @@ const onAsyncFormSubmit = e => {
$target.parent().html(response.responseText);
initSelects();
} else {
- $('.modal-close').click();
+ $(".modal-close").click();
}
},
success: response => {
@@ -34,16 +34,16 @@ const onAsyncFormSubmit = e => {
const onAsyncFormButtonClick = e => {
const $button = $(e.currentTarget);
- const $formAsync = $button.parents('.form-async');
- $('button[type=submit]', $formAsync).removeAttr('clicked');
- $button.attr('clicked', 'true');
+ const $formAsync = $button.parents(".form-async");
+ $("button[type=submit]", $formAsync).removeAttr("clicked");
+ $button.attr("clicked", "true");
};
-const onModalClose = () => $('.modal').modal('close');
+const onModalClose = () => $(".modal").modal("close");
// -----
$(document)
- .on('click', '.form-async button[type=submit]', onAsyncFormButtonClick)
- .on('submit', '.form-async', onAsyncFormSubmit)
- .on('click', '.modal-close', onModalClose);
+ .on("click", ".form-async button[type=submit]", onAsyncFormButtonClick)
+ .on("submit", ".form-async", onAsyncFormSubmit)
+ .on("click", ".modal-close", onModalClose);
diff --git a/saleor/static/dashboard/js/components/bulk-actions.js b/saleor/static/dashboard/js/components/bulk-actions.js
index a87d30e3a7..cafb80566c 100644
--- a/saleor/static/dashboard/js/components/bulk-actions.js
+++ b/saleor/static/dashboard/js/components/bulk-actions.js
@@ -4,58 +4,58 @@
* and some rows are checked but have no .highlight class.
*/
function initCheckedRows() {
- $('.select-item:checked:not(#select-all-items)').each((itemIndex, item) => {
+ $(".select-item:checked:not(#select-all-items)").each((itemIndex, item) => {
$(item)
.parent()
.parent()
- .addClass('highlight');
+ .addClass("highlight");
});
- $('.select-item:not(:checked):not(#select-all-items)').each(
+ $(".select-item:not(:checked):not(#select-all-items)").each(
(itemIndex, item) => {
$(item)
.parent()
.parent()
- .removeClass('highlight');
+ .removeClass("highlight");
}
);
}
function moveSelectAllCheckbox(bulk, selectAllState) {
- const $selectAll = $('#select-all-items').parent()[0].innerHTML;
- const $headerContainer = $('thead .bulk-checkbox');
- const $actionBarContainer = $('.data-table-bulk-actions__select-all');
+ const $selectAll = $("#select-all-items").parent()[0].innerHTML;
+ const $headerContainer = $("thead .bulk-checkbox");
+ const $actionBarContainer = $(".data-table-bulk-actions__select-all");
if (bulk) {
- $headerContainer.html('');
+ $headerContainer.html("");
$actionBarContainer[0].innerHTML = $selectAll;
} else {
- $actionBarContainer.html('');
+ $actionBarContainer.html("");
$headerContainer[0].innerHTML = $selectAll;
}
- $actionBarContainer.find('#select-all-items').prop('checked', selectAllState);
- $('.select-all').on('change', onSelectAll);
+ $actionBarContainer.find("#select-all-items").prop("checked", selectAllState);
+ $(".select-all").on("change", onSelectAll);
}
function onItemSelect(e) {
const count =
- $('.select-item:checked').length - $('#select-all-items:checked').length;
- const maxCount = $('.select-item').length - 1;
+ $(".select-item:checked").length - $("#select-all-items:checked").length;
+ const maxCount = $(".select-item").length - 1;
const $target = $(e.currentTarget);
$target
.parent()
.parent()
- .toggleClass('highlight', $target.checked);
+ .toggleClass("highlight", $target.checked);
updateSelectedItemsText(count === maxCount);
}
function onPageInit() {
- if (document.querySelector('#bulk-action')) {
+ if (document.querySelector("#bulk-action")) {
initCheckedRows();
updateSelectedItemsText();
- $('.select-all').on('change', onSelectAll);
- $('.select-item').on('change', onItemSelect);
- $('.data-table-bulk-actions__action-choice a').on('click', onSubmit);
- $('.data-table-bulk-actions__dropdown-container .dropdown-content a').on(
- 'click',
+ $(".select-all").on("change", onSelectAll);
+ $(".select-item").on("change", onItemSelect);
+ $(".data-table-bulk-actions__action-choice a").on("click", onSubmit);
+ $(".data-table-bulk-actions__dropdown-container .dropdown-content a").on(
+ "click",
onSubmit
);
}
@@ -63,32 +63,32 @@ function onPageInit() {
function onSelectAll(e) {
const $target = $(e.currentTarget);
- const $targetForm = $target.parents('form');
- const $items = $targetForm.find('.select-item:not(.select-all)');
- $items.prop('checked', $target[0].checked);
+ const $targetForm = $target.parents("form");
+ const $items = $targetForm.find(".select-item:not(.select-all)");
+ $items.prop("checked", $target[0].checked);
initCheckedRows();
- $target.off('change');
+ $target.off("change");
updateSelectedItemsText($target[0].checked);
}
function onSubmit(e) {
const a = $(e.currentTarget);
e.preventDefault();
- $('#bulk-action').val(a.attr('data-action'));
- $('#bulk-actions-form').submit();
+ $("#bulk-action").val(a.attr("data-action"));
+ $("#bulk-actions-form").submit();
}
function updateSelectedItemsText(selectAllState) {
const count =
- $('.select-item:checked').length - $('#select-all-items:checked').length;
- const $counterTextNode = $('.data-table-bulk-actions__selected-items');
- const $header = $('.data-table-bulk-actions');
- const counterText = ngettext('item selected', 'items selected', count);
+ $(".select-item:checked").length - $("#select-all-items:checked").length;
+ const $counterTextNode = $(".data-table-bulk-actions__selected-items");
+ const $header = $(".data-table-bulk-actions");
+ const counterText = ngettext("item selected", "items selected", count);
if (count) {
$counterTextNode.html(`${count} ${counterText}`);
}
- $header.toggleClass('show', count > 0);
+ $header.toggleClass("show", count > 0);
moveSelectAllCheckbox(count > 0, selectAllState);
}
diff --git a/saleor/static/dashboard/js/components/datepicker.js b/saleor/static/dashboard/js/components/datepicker.js
index e7228ca015..c5092f4308 100644
--- a/saleor/static/dashboard/js/components/datepicker.js
+++ b/saleor/static/dashboard/js/components/datepicker.js
@@ -1,77 +1,77 @@
// -----
-$('.datepicker').pickadate({
- labelMonthNext: pgettext('Datepicker option', 'Next month'),
- labelMonthPrev: pgettext('Datepicker option', 'Previous month'),
+$(".datepicker").pickadate({
+ labelMonthNext: pgettext("Datepicker option", "Next month"),
+ labelMonthPrev: pgettext("Datepicker option", "Previous month"),
// The title label to use for the dropdown selectors
- labelMonthSelect: pgettext('Datepicker option', 'Select a month'),
- labelYearSelect: pgettext('Datepicker option', 'Select a year'),
+ labelMonthSelect: pgettext("Datepicker option", "Select a month"),
+ labelYearSelect: pgettext("Datepicker option", "Select a year"),
// Months and weekdays
monthsFull: [
- pgettext('Datepicker month', 'January'),
- pgettext('Datepicker month', 'February'),
- pgettext('Datepicker month', 'March'),
- pgettext('Datepicker month', 'April'),
- pgettext('Datepicker month', 'May'),
- pgettext('Datepicker month', 'June'),
- pgettext('Datepicker month', 'July'),
- pgettext('Datepicker month', 'August'),
- pgettext('Datepicker month', 'September'),
- pgettext('Datepicker month', 'October'),
- pgettext('Datepicker month', 'November'),
- pgettext('Datepicker month', 'December')
+ pgettext("Datepicker month", "January"),
+ pgettext("Datepicker month", "February"),
+ pgettext("Datepicker month", "March"),
+ pgettext("Datepicker month", "April"),
+ pgettext("Datepicker month", "May"),
+ pgettext("Datepicker month", "June"),
+ pgettext("Datepicker month", "July"),
+ pgettext("Datepicker month", "August"),
+ pgettext("Datepicker month", "September"),
+ pgettext("Datepicker month", "October"),
+ pgettext("Datepicker month", "November"),
+ pgettext("Datepicker month", "December")
],
monthsShort: [
- pgettext('Datepicker month shortcut', 'Jan'),
- pgettext('Datepicker month shortcut', 'Feb'),
- pgettext('Datepicker month shortcut', 'Mar'),
- pgettext('Datepicker month shortcut', 'Apr'),
- pgettext('Datepicker month shortcut', 'May'),
- pgettext('Datepicker month shortcut', 'Jun'),
- pgettext('Datepicker month shortcut', 'Jul'),
- pgettext('Datepicker month shortcut', 'Aug'),
- pgettext('Datepicker month shortcut', 'Sep'),
- pgettext('Datepicker month shortcut', 'Oct'),
- pgettext('Datepicker month shortcut', 'Nov'),
- pgettext('Datepicker month shortcut', 'Dec')
+ pgettext("Datepicker month shortcut", "Jan"),
+ pgettext("Datepicker month shortcut", "Feb"),
+ pgettext("Datepicker month shortcut", "Mar"),
+ pgettext("Datepicker month shortcut", "Apr"),
+ pgettext("Datepicker month shortcut", "May"),
+ pgettext("Datepicker month shortcut", "Jun"),
+ pgettext("Datepicker month shortcut", "Jul"),
+ pgettext("Datepicker month shortcut", "Aug"),
+ pgettext("Datepicker month shortcut", "Sep"),
+ pgettext("Datepicker month shortcut", "Oct"),
+ pgettext("Datepicker month shortcut", "Nov"),
+ pgettext("Datepicker month shortcut", "Dec")
],
weekdaysFull: [
- pgettext('Datepicker weekday', 'Sunday'),
- pgettext('Datepicker weekday', 'Monday'),
- pgettext('Datepicker weekday', 'Tuesday'),
- pgettext('Datepicker weekday', 'Wednesday'),
- pgettext('Datepicker weekday', 'Thursday'),
- pgettext('Datepicker weekday', 'Friday'),
- pgettext('Datepicker weekday', 'Saturday')
+ pgettext("Datepicker weekday", "Sunday"),
+ pgettext("Datepicker weekday", "Monday"),
+ pgettext("Datepicker weekday", "Tuesday"),
+ pgettext("Datepicker weekday", "Wednesday"),
+ pgettext("Datepicker weekday", "Thursday"),
+ pgettext("Datepicker weekday", "Friday"),
+ pgettext("Datepicker weekday", "Saturday")
],
weekdaysShort: [
- pgettext('Datepicker weekday shortcut', 'Sun'),
- pgettext('Datepicker weekday shortcut', 'Mon'),
- pgettext('Datepicker weekday shortcut', 'Tue'),
- pgettext('Datepicker weekday shortcut', 'Wed'),
- pgettext('Datepicker weekday shortcut', 'Thu'),
- pgettext('Datepicker weekday shortcut', 'Fri'),
- pgettext('Datepicker weekday shortcut', 'Sat')
+ pgettext("Datepicker weekday shortcut", "Sun"),
+ pgettext("Datepicker weekday shortcut", "Mon"),
+ pgettext("Datepicker weekday shortcut", "Tue"),
+ pgettext("Datepicker weekday shortcut", "Wed"),
+ pgettext("Datepicker weekday shortcut", "Thu"),
+ pgettext("Datepicker weekday shortcut", "Fri"),
+ pgettext("Datepicker weekday shortcut", "Sat")
],
// Materialize modified
weekdaysLetter: [
- pgettext('Sunday shortcut', 'S'),
- pgettext('Monday shortcut', 'M'),
- pgettext('Tuesday shortcut', 'T'),
- pgettext('Wednesday shortcut', 'W'),
- pgettext('Thursday shortcut', 'T'),
- pgettext('Friday shortcut', 'F'),
- pgettext('Saturday shortcut', 'S')
+ pgettext("Sunday shortcut", "S"),
+ pgettext("Monday shortcut", "M"),
+ pgettext("Tuesday shortcut", "T"),
+ pgettext("Wednesday shortcut", "W"),
+ pgettext("Thursday shortcut", "T"),
+ pgettext("Friday shortcut", "F"),
+ pgettext("Saturday shortcut", "S")
],
- today: pgettext('Datepicker option', 'Today'),
- clear: pgettext('Datepicker option', 'Clear'),
- close: pgettext('Datepicker option', 'Close'),
+ today: pgettext("Datepicker option", "Today"),
+ clear: pgettext("Datepicker option", "Clear"),
+ close: pgettext("Datepicker option", "Close"),
- format: 'd mmmm yyyy',
- formatSubmit: 'yyyy-mm-dd',
+ format: "d mmmm yyyy",
+ formatSubmit: "yyyy-mm-dd",
selectMonths: true,
hiddenName: true,
onClose: () => $(document.activeElement).blur()
diff --git a/saleor/static/dashboard/js/components/editor.js b/saleor/static/dashboard/js/components/editor.js
index 744a55af0c..5cbb6671a0 100644
--- a/saleor/static/dashboard/js/components/editor.js
+++ b/saleor/static/dashboard/js/components/editor.js
@@ -1,92 +1,92 @@
-import MediumEditor from 'medium-editor';
+import MediumEditor from "medium-editor";
-import alignCenterIcon from '../../images/editor/align_center.svg';
-import alignJustifyIcon from '../../images/editor/align_justify.svg';
-import alignLeftIcon from '../../images/editor/align_left.svg';
-import alignRightIcon from '../../images/editor/align_right.svg';
-import insertLinkIcon from '../../images/editor/insert_link.svg';
-import insertPhotoIcon from '../../images/editor/insert_photo.svg';
-import quoteIcon from '../../images/editor/quote.svg';
-import formatClear from '../../images/editor/format_clear.svg';
+import alignCenterIcon from "../../images/editor/align_center.svg";
+import alignJustifyIcon from "../../images/editor/align_justify.svg";
+import alignLeftIcon from "../../images/editor/align_left.svg";
+import alignRightIcon from "../../images/editor/align_right.svg";
+import insertLinkIcon from "../../images/editor/insert_link.svg";
+import insertPhotoIcon from "../../images/editor/insert_photo.svg";
+import quoteIcon from "../../images/editor/quote.svg";
+import formatClear from "../../images/editor/format_clear.svg";
-import doneIcon from '../../images/done.svg';
-import closeIcon from '../../images/close.svg';
+import doneIcon from "../../images/done.svg";
+import closeIcon from "../../images/close.svg";
// Solve an auto-resize conflict between Materialize and medium-editor.
-$('.rich-text-editor').removeClass('materialize-textarea');
+$(".rich-text-editor").removeClass("materialize-textarea");
// eslint-disable-next-line
-const editor = new MediumEditor('.rich-text-editor', {
+const editor = new MediumEditor(".rich-text-editor", {
paste: {
forcePlainText: true
},
toolbar: {
buttons: [
{
- name: 'bold',
- aria: pgettext('Rich text editor option', 'Bold text')
+ name: "bold",
+ aria: pgettext("Rich text editor option", "Bold text")
},
{
- name: 'italic',
- aria: pgettext('Rich text editor option', 'Italic text')
+ name: "italic",
+ aria: pgettext("Rich text editor option", "Italic text")
},
{
- name: 'h2',
- aria: pgettext('Rich text editor option', 'Header'),
- tagNames: ['h2'],
- contentDefault: '<b>T</b>',
- classList: ['custom-class-h1']
+ name: "h2",
+ aria: pgettext("Rich text editor option", "Header"),
+ tagNames: ["h2"],
+ contentDefault: "<b>T</b>",
+ classList: ["custom-class-h1"]
},
{
- name: 'h3',
- aria: pgettext('Rich text editor option', 'Subheader'),
- tagNames: ['h3'],
+ name: "h3",
+ aria: pgettext("Rich text editor option", "Subheader"),
+ tagNames: ["h3"],
contentDefault: '<b style="font-size: .75rem">T</b>',
- classList: ['custom-class-h2']
+ classList: ["custom-class-h2"]
},
{
- name: 'quote',
- aria: pgettext('Rich text editor option', 'Quote'),
+ name: "quote",
+ aria: pgettext("Rich text editor option", "Quote"),
contentDefault: `<img src="${quoteIcon}">`
},
{
- name: 'anchor',
- aria: pgettext('Rich text editor option', 'Link'),
+ name: "anchor",
+ aria: pgettext("Rich text editor option", "Link"),
contentDefault: `<img src="${insertLinkIcon}">`,
formSaveLabel: `<img src="${doneIcon}"`,
formCloseLabel: `<img src="${closeIcon}">`
},
{
- name: 'image',
+ name: "image",
aria: pgettext(
- 'Rich text editor option',
- 'Image (converts selected text to an image tag)'
+ "Rich text editor option",
+ "Image (converts selected text to an image tag)"
),
contentDefault: `<img src="${insertPhotoIcon}">`
},
{
- name: 'justifyLeft',
- aria: pgettext('Rich text editor option', 'Left align'),
+ name: "justifyLeft",
+ aria: pgettext("Rich text editor option", "Left align"),
contentDefault: `<img src="${alignLeftIcon}">`
},
{
- name: 'justifyCenter',
- aria: pgettext('Rich text editor option', 'Center align'),
+ name: "justifyCenter",
+ aria: pgettext("Rich text editor option", "Center align"),
contentDefault: `<img src="${alignCenterIcon}">`
},
{
- name: 'justifyRight',
- aria: pgettext('Rich text editor option', 'Right align'),
+ name: "justifyRight",
+ aria: pgettext("Rich text editor option", "Right align"),
contentDefault: `<img src="${alignRightIcon}">`
},
{
- name: 'justifyFull',
- aria: pgettext('Rich text editor option', 'Justify'),
+ name: "justifyFull",
+ aria: pgettext("Rich text editor option", "Justify"),
contentDefault: `<img src="${alignJustifyIcon}">`
},
{
- name: 'removeFormat',
- aria: pgettext('Rich text editor option', 'Remove formatting'),
+ name: "removeFormat",
+ aria: pgettext("Rich text editor option", "Remove formatting"),
contentDefault: `<img src="${formatClear}">`
}
]
@@ -94,15 +94,15 @@ const editor = new MediumEditor('.rich-text-editor', {
keyboardCommands: {
commands: [
{
- command: 'bold',
- key: 'B',
+ command: "bold",
+ key: "B",
meta: true,
shift: false,
alt: false
},
{
- command: 'italic',
- key: 'I',
+ command: "italic",
+ key: "I",
meta: true,
shift: false,
alt: false
diff --git a/saleor/static/dashboard/js/components/filters.js b/saleor/static/dashboard/js/components/filters.js
index 019bebe979..f07aac3820 100644
--- a/saleor/static/dashboard/js/components/filters.js
+++ b/saleor/static/dashboard/js/components/filters.js
@@ -1,23 +1,23 @@
-import { screenSizes } from './misc';
+import { screenSizes } from "./misc";
let prevWindowWidth = null;
let initialized = false;
let $list = null;
-const $filters = $('#filters');
+const $filters = $("#filters");
const moveFilters = () => {
if (prevWindowWidth !== window.innerWidth) {
- const $collapsibleCard = $('.collapse');
+ const $collapsibleCard = $(".collapse");
prevWindowWidth = window.innerWidth;
if (window.innerWidth < screenSizes.md) {
$list.before($filters);
if (!initialized) {
- $collapsibleCard.addClass('collapsed');
+ $collapsibleCard.addClass("collapsed");
initialized = true;
}
} else {
$list.after($filters);
- $collapsibleCard.removeClass('collapsed');
+ $collapsibleCard.removeClass("collapsed");
}
}
};
@@ -27,14 +27,14 @@ const moveFilters = () => {
$list = $filters.prev();
if ($filters.length) {
moveFilters();
- $(window).on('resize', moveFilters);
+ $(window).on("resize", moveFilters);
}
-$('.collapse-activate').on('click', e => {
- const $collapsibleCard = $('.collapse');
- if ($collapsibleCard.hasClass('collapsed')) {
- $collapsibleCard.removeClass('collapsed');
+$(".collapse-activate").on("click", e => {
+ const $collapsibleCard = $(".collapse");
+ if ($collapsibleCard.hasClass("collapsed")) {
+ $collapsibleCard.removeClass("collapsed");
} else {
- $collapsibleCard.addClass('collapsed');
+ $collapsibleCard.addClass("collapsed");
}
});
diff --git a/saleor/static/dashboard/js/components/google-preview.js b/saleor/static/dashboard/js/components/google-preview.js
index c3f5453005..45ac777aaf 100644
--- a/saleor/static/dashboard/js/components/google-preview.js
+++ b/saleor/static/dashboard/js/components/google-preview.js
@@ -1,13 +1,13 @@
-const $seoTitle = $('#id_seo_title');
+const $seoTitle = $("#id_seo_title");
-const $nameId = $seoTitle.data('bind');
+const $nameId = $seoTitle.data("bind");
const $name = $(`#${$nameId}`);
-const $seoDescription = $('#id_seo_description');
-const $descriptionMaterialize = $seoDescription.data('materialize');
+const $seoDescription = $("#id_seo_description");
+const $descriptionMaterialize = $seoDescription.data("materialize");
-let $description = '';
-const $descriptionId = $seoDescription.data('bind');
+let $description = "";
+const $descriptionId = $seoDescription.data("bind");
if ($descriptionMaterialize) {
const $descriptions = $(
`.materialize-textarea[name='${$descriptionMaterialize}']`
@@ -20,43 +20,43 @@ if ($descriptionMaterialize) {
}
}
-const $googleTitlePreview = $('#google-preview-title');
-const $googleDescriptionPreview = $('#google-preview-description');
-const $preview = $('#google-preview');
+const $googleTitlePreview = $("#google-preview-title");
+const $googleDescriptionPreview = $("#google-preview-description");
+const $preview = $("#google-preview");
-const watchedEvents = 'input propertychange cut paste copy change';
+const watchedEvents = "input propertychange cut paste copy change";
function setPlaceholderAndPreview(field, seoField, previewField) {
const $text = field.text() || field.val();
const $placeholderText = truncate($text, seoField);
- seoField.attr('placeholder', $placeholderText);
+ seoField.attr("placeholder", $placeholderText);
previewField.text(seoField.val() || $placeholderText);
}
function updateCharsCount(seoField) {
- const $fieldId = seoField.attr('id');
+ const $fieldId = seoField.attr("id");
const $charCount = $(`span[data-bind=${$fieldId}]`);
let $fieldLength = seoField.val().length || seoField.text().length;
- if (!$fieldLength && seoField.attr('placeholder')) {
- $fieldLength = seoField.attr('placeholder').length;
+ if (!$fieldLength && seoField.attr("placeholder")) {
+ $fieldLength = seoField.attr("placeholder").length;
}
- const $minRecommendedLength = seoField.data('min-recommended-length');
+ const $minRecommendedLength = seoField.data("min-recommended-length");
const $charCountWrapper = $charCount.parent();
if ($fieldLength < $minRecommendedLength) {
- $charCountWrapper.addClass('orange-text');
- $charCountWrapper.removeClass('green-text');
+ $charCountWrapper.addClass("orange-text");
+ $charCountWrapper.removeClass("green-text");
$charCountWrapper.attr(
- 'title',
+ "title",
gettext(
- 'Your input might be a little too short, think of something more descriptive'
+ "Your input might be a little too short, think of something more descriptive"
)
);
} else {
- $charCountWrapper.removeClass('orange-text');
- $charCountWrapper.addClass('green-text');
+ $charCountWrapper.removeClass("orange-text");
+ $charCountWrapper.addClass("green-text");
$charCountWrapper.attr(
- 'title',
- gettext('Your input fits between the recommended lengths')
+ "title",
+ gettext("Your input fits between the recommended lengths")
);
}
$charCount.text($fieldLength);
@@ -73,7 +73,7 @@ function checkForErrors() {
}
function truncate(text, seoField) {
- const $fieldMaxLength = seoField.prop('maxLength');
+ const $fieldMaxLength = seoField.prop("maxLength");
if (text && text.length > $fieldMaxLength) {
return text.substring(text, $fieldMaxLength);
}
@@ -84,7 +84,7 @@ function updatePlaceholderOnInput(field, seoField, previewField) {
field.on(watchedEvents, e => {
const $target = $(e.currentTarget);
const $placeholderText = $target.val() || $target.text();
- seoField.attr('placeholder', truncate($placeholderText, seoField));
+ seoField.attr("placeholder", truncate($placeholderText, seoField));
const $seoText = seoField.val();
if (!$seoText) {
previewField.text(truncate($placeholderText, seoField));
@@ -101,7 +101,7 @@ function updatePreviewOnInput(seoField, previewField) {
if ($currentText) {
previewField.text(truncate($currentText, seoField));
} else {
- const $placeholderValue = seoField.attr('placeholder');
+ const $placeholderValue = seoField.attr("placeholder");
previewField.text(truncate($placeholderValue, seoField));
}
checkForErrors();
diff --git a/saleor/static/dashboard/js/components/image-gallery.js b/saleor/static/dashboard/js/components/image-gallery.js
index 6acfa0728a..46c575bcdc 100644
--- a/saleor/static/dashboard/js/components/image-gallery.js
+++ b/saleor/static/dashboard/js/components/image-gallery.js
@@ -1,38 +1,38 @@
// eslint-disable-next-line no-unused-vars
-import Dropzone from 'dropzone';
+import Dropzone from "dropzone";
function createLink(link, index, replacement) {
- const outputLink = link.attr('data-href-template').split('/');
+ const outputLink = link.attr("data-href-template").split("/");
outputLink[outputLink.length + index] = replacement;
- return outputLink.join('/');
+ return outputLink.join("/");
}
// -----
-$('#product-image-form').dropzone({
- paramName: 'image_0',
+$("#product-image-form").dropzone({
+ paramName: "image_0",
maxFilesize: 20,
- previewsContainer: '.product-gallery',
+ previewsContainer: ".product-gallery",
thumbnailWidth: 400,
thumbnailHeight: 400,
- previewTemplate: $('#template').html(),
- method: 'POST',
- clickable: '.dropzone-message',
+ previewTemplate: $("#template").html(),
+ method: "POST",
+ clickable: ".dropzone-message",
init: function() {
- this.on('success', (e, response) => {
+ this.on("success", (e, response) => {
const $previewElement = $(e.previewElement);
- $previewElement.find('.product-gallery-item-desc').html(response.image);
- $previewElement.attr('data-id', response.id);
+ $previewElement.find(".product-gallery-item-desc").html(response.image);
+ $previewElement.attr("data-id", response.id);
- const $editLinkElement = $previewElement.find('.card-action-edit');
+ const $editLinkElement = $previewElement.find(".card-action-edit");
const editLinkHref = createLink($editLinkElement, -2, response.id);
- $editLinkElement.attr('href', editLinkHref);
+ $editLinkElement.attr("href", editLinkHref);
- const $deleteLinkElement = $previewElement.find('.card-action-delete');
+ const $deleteLinkElement = $previewElement.find(".card-action-delete");
const deleteLinkHref = createLink($deleteLinkElement, -3, response.id);
- $deleteLinkElement.attr('data-href', deleteLinkHref);
+ $deleteLinkElement.attr("data-href", deleteLinkHref);
- $('.no-images').addClass('hide');
+ $(".no-images").addClass("hide");
});
}
});
diff --git a/saleor/static/dashboard/js/components/index.js b/saleor/static/dashboard/js/components/index.js
index 064c0ca02c..05189af018 100644
--- a/saleor/static/dashboard/js/components/index.js
+++ b/saleor/static/dashboard/js/components/index.js
@@ -1,17 +1,17 @@
-import './async-form';
-import './bulk-actions';
-import './datepicker';
-import './editor';
-import './filters';
-import './google-preview';
-import './image-gallery';
-import './load-action';
-import './messages';
-import './misc';
-import './modal';
-import './search';
-import './selects';
-import './side-menu';
-import './sortable.js';
-import './tab';
-import './vouchers';
+import "./async-form";
+import "./bulk-actions";
+import "./datepicker";
+import "./editor";
+import "./filters";
+import "./google-preview";
+import "./image-gallery";
+import "./load-action";
+import "./messages";
+import "./misc";
+import "./modal";
+import "./search";
+import "./selects";
+import "./side-menu";
+import "./sortable.js";
+import "./tab";
+import "./vouchers";
diff --git a/saleor/static/dashboard/js/components/load-action.js b/saleor/static/dashboard/js/components/load-action.js
index 630ef895ab..cd2f37d0d3 100644
--- a/saleor/static/dashboard/js/components/load-action.js
+++ b/saleor/static/dashboard/js/components/load-action.js
@@ -3,10 +3,10 @@ function disableSubsequentClicks(e) {
}
function initLoadAction(e) {
- $('body').css('cursor', 'progress');
- $(e.target).on('click', disableSubsequentClicks);
+ $("body").css("cursor", "progress");
+ $(e.target).on("click", disableSubsequentClicks);
}
// -----
-$('.load-action').on('click', initLoadAction);
+$(".load-action").on("click", initLoadAction);
diff --git a/saleor/static/dashboard/js/components/messages.js b/saleor/static/dashboard/js/components/messages.js
index 3e4488ebd3..f202cb8990 100644
--- a/saleor/static/dashboard/js/components/messages.js
+++ b/saleor/static/dashboard/js/components/messages.js
@@ -1,6 +1,6 @@
-const dataElement = $('#messages-container');
-const data = dataElement.data('messages');
-const $messages = $('.message');
+const dataElement = $("#messages-container");
+const data = dataElement.data("messages");
+const $messages = $(".message");
const offset = 100;
const firstMessageOffset = 250;
@@ -16,11 +16,11 @@ setTimeout(() => {
let timeout = 0;
$messages.each((index, msg) => {
setTimeout(() => {
- msg.removeClass('toast--hidden');
+ msg.removeClass("toast--hidden");
}, timeout + offset);
timeout += 3000;
setTimeout(() => {
- msg.addClass('toast--hidden');
+ msg.addClass("toast--hidden");
}, timeout - offset);
});
}, firstMessageOffset);
diff --git a/saleor/static/dashboard/js/components/misc.js b/saleor/static/dashboard/js/components/misc.js
index a4808819c2..36c83bca1c 100644
--- a/saleor/static/dashboard/js/components/misc.js
+++ b/saleor/static/dashboard/js/components/misc.js
@@ -1,7 +1,7 @@
-import SVGInjector from 'svg-injector-2';
+import SVGInjector from "svg-injector-2";
-import { initSelects } from './selects';
-import { onScroll } from './utils';
+import { initSelects } from "./selects";
+import { onScroll } from "./utils";
const screenSizes = {
sm: 600,
@@ -14,44 +14,44 @@ const svgInjector = new SVGInjector();
// -----
// Inject all SVGs
-svgInjector.inject(document.querySelectorAll('svg[data-src]'));
+svgInjector.inject(document.querySelectorAll("svg[data-src]"));
// Custom select inputs
initSelects();
// Materialize modals
-$('.modal').modal();
+$(".modal").modal();
// Print button
-$('.btn-print').click(e => {
+$(".btn-print").click(e => {
window.print();
});
// Clickable rows in dashboard tables
-$(document).on('mouseup', 'tr[data-action-go] > td:not(.ignore-link)', e => {
+$(document).on("mouseup", "tr[data-action-go] > td:not(.ignore-link)", e => {
const $target = $(e.currentTarget);
// Ignore selecting text
const selectedText = getSelection().toString();
- if (selectedText === '' || selectedText === $target.data('ignore-text')) {
- window.location.href = $target.parent().data('action-go');
+ if (selectedText === "" || selectedText === $target.data("ignore-text")) {
+ window.location.href = $target.parent().data("action-go");
} else {
- $target.data('ignore-text', selectedText);
+ $target.data("ignore-text", selectedText);
}
});
// Publish / unpublish lever in detail views
-const selectors = ['#product-is-published', '#collection-is-published'];
+const selectors = ["#product-is-published", "#collection-is-published"];
selectors.forEach(selector => {
- $(selector).on('click', e => {
- const form = $(e.currentTarget).closest('#toggle-publish-form');
- const input = form.find('#toggle-publish-switch')[0];
+ $(selector).on("click", e => {
+ const form = $(e.currentTarget).closest("#toggle-publish-form");
+ const input = form.find("#toggle-publish-switch")[0];
if (e.target === input) {
- const url = form.attr('action');
+ const url = form.attr("action");
fetch(url, {
- method: 'POST',
- credentials: 'same-origin',
+ method: "POST",
+ credentials: "same-origin",
headers: {
- 'X-CSRFToken': $('[name=csrfmiddlewaretoken]').val()
+ "X-CSRFToken": $("[name=csrfmiddlewaretoken]").val()
}
})
.then(() => {
@@ -66,7 +66,7 @@ selectors.forEach(selector => {
// Styleguide sticky right menu
onScroll(() =>
- $('.styleguide__menu').toggleClass('fixed', $(window).scrollTop() > 100)
+ $(".styleguide__menu").toggleClass("fixed", $(window).scrollTop() > 100)
);
export { screenSizes, svgInjector };
diff --git a/saleor/static/dashboard/js/components/modal.js b/saleor/static/dashboard/js/components/modal.js
index 977f4fa04d..9bb94e06f4 100644
--- a/saleor/static/dashboard/js/components/modal.js
+++ b/saleor/static/dashboard/js/components/modal.js
@@ -1,45 +1,45 @@
-import { svgInjector } from './misc';
-import { initSelects } from './selects';
+import { svgInjector } from "./misc";
+import { initSelects } from "./selects";
// List of input types that can be autofocused after opening modal
const focusInputs = [
- 'textarea',
+ "textarea",
'input[type="text"]:not(.select-dropdown)',
'input[type="number"]'
];
// -----
-$('body').on('click', '.modal-trigger-custom', e => {
+$("body").on("click", ".modal-trigger-custom", e => {
const target = e.currentTarget;
e.preventDefault();
$.ajax({
url: target.dataset.href,
- method: 'GET',
+ method: "GET",
success: response => {
- const $modal = $(target.getAttribute('href'));
- $modal.html(response).modal('open');
+ const $modal = $(target.getAttribute("href"));
+ $modal.html(response).modal("open");
initSelects();
- const inputs = $modal.find(focusInputs.join(','));
+ const inputs = $modal.find(focusInputs.join(","));
// Automatically focus first autofocusable input in modal after opening
if (inputs.length) {
- $modal.find(focusInputs.join(','))[0].focus();
+ $modal.find(focusInputs.join(","))[0].focus();
}
// Image checkbox selector
- $('.image_select-item-overlay').on('click', e => {
- const imageId = e.currentTarget.getAttribute('id');
- const checkbox = document.querySelector('input#' + imageId);
- const checkboxState = checkbox.getAttribute('checked');
- checkbox.setAttribute('checked', !checkboxState);
- $(e.target).toggleClass('checked', !checkbox);
+ $(".image_select-item-overlay").on("click", e => {
+ const imageId = e.currentTarget.getAttribute("id");
+ const checkbox = document.querySelector("input#" + imageId);
+ const checkboxState = checkbox.getAttribute("checked");
+ checkbox.setAttribute("checked", !checkboxState);
+ $(e.target).toggleClass("checked", !checkbox);
});
// Inject all SVGs from modal
svgInjector.inject(
document.querySelectorAll(
- '.modal-content svg[data-src]:not(.injected-svg)'
+ ".modal-content svg[data-src]:not(.injected-svg)"
)
);
}
diff --git a/saleor/static/dashboard/js/components/search.js b/saleor/static/dashboard/js/components/search.js
index 040eae6a95..800076fc03 100644
--- a/saleor/static/dashboard/js/components/search.js
+++ b/saleor/static/dashboard/js/components/search.js
@@ -8,18 +8,18 @@ function submit(e) {
function openSearchBar(e) {
e.preventDefault();
const $target = $(e.currentTarget);
- $('.search').toggleClass('expanded', !$target.hasClass('expanded'));
+ $(".search").toggleClass("expanded", !$target.hasClass("expanded"));
}
function closeSearchBar(e) {
const $target = $(e.currentTarget);
- const isExpanded = $target.hasClass('expanded');
- $('.search').toggleClass('expanded', isExpanded);
- $target.toggleClass('active', !isExpanded);
+ const isExpanded = $target.hasClass("expanded");
+ $(".search").toggleClass("expanded", isExpanded);
+ $target.toggleClass("active", !isExpanded);
}
// -----
-$('#btn-search').on('click', openSearchBar);
-$('#btn-search-close').on('click', closeSearchBar);
-$('#btn-search-submit').on('click', submit);
+$("#btn-search").on("click", openSearchBar);
+$("#btn-search-close").on("click", closeSearchBar);
+$("#btn-search-submit").on("click", submit);
diff --git a/saleor/static/dashboard/js/components/selects.js b/saleor/static/dashboard/js/components/selects.js
index 98c1585acd..9641a49de8 100644
--- a/saleor/static/dashboard/js/components/selects.js
+++ b/saleor/static/dashboard/js/components/selects.js
@@ -1,32 +1,32 @@
-import 'select2';
+import "select2";
function appendOption($select, option) {
$select.append(
- $('<option></option>')
- .attr('value', option.id)
+ $("<option></option>")
+ .attr("value", option.id)
.text(option.text)
);
}
function initSelects() {
// Custom variant attribute select that allows creating new attribute values.
- let $variantAttrsSelect = $('.attribute-select-or-create select');
+ let $variantAttrsSelect = $(".attribute-select-or-create select");
$variantAttrsSelect.select2({
tags: true,
- width: '100%'
+ width: "100%"
});
- $variantAttrsSelect.addClass('select2-enabled');
+ $variantAttrsSelect.addClass("select2-enabled");
$(
- 'select:not(.browser-default):not(.enable-ajax-select2):not([multiple])'
+ "select:not(.browser-default):not(.enable-ajax-select2):not([multiple])"
).material_select();
- $('select[multiple]:not(.browser-default):not(.enable-ajax-select2)').select2(
- { width: '100%' }
+ $("select[multiple]:not(.browser-default):not(.enable-ajax-select2)").select2(
+ { width: "100%" }
);
- $('select.enable-ajax-select2:not(.select2-enabled)').each((i, select) => {
+ $("select.enable-ajax-select2:not(.select2-enabled)").each((i, select) => {
const $select = $(select);
- const initial = $select.data('initial');
+ const initial = $select.data("initial");
if (initial) {
const initialData = initial instanceof Array ? initial : [initial];
@@ -39,13 +39,13 @@ function initSelects() {
$select.select2({
ajax: {
- url: $select.data('url'),
+ url: $select.data("url"),
delay: 250
},
- width: '100%',
- minimumInputLength: $select.data('min-input')
+ width: "100%",
+ minimumInputLength: $select.data("min-input")
});
- $select.addClass('select2-enabled');
+ $select.addClass("select2-enabled");
});
}
diff --git a/saleor/static/dashboard/js/components/side-menu.js b/saleor/static/dashboard/js/components/side-menu.js
index 0deb093585..8e2e7512c4 100644
--- a/saleor/static/dashboard/js/components/side-menu.js
+++ b/saleor/static/dashboard/js/components/side-menu.js
@@ -1,23 +1,23 @@
-import { onScroll } from './utils';
+import { onScroll } from "./utils";
function toggleMenu(e) {
e.preventDefault();
- $('body').toggleClass('nav-toggled');
+ $("body").toggleClass("nav-toggled");
}
-const $mainNavTop = $('.side-nav');
-const $toggleMenu = $('#toggle-menu');
+const $mainNavTop = $(".side-nav");
+const $toggleMenu = $("#toggle-menu");
// -----
if ($mainNavTop.length) {
const mainNavTop = $mainNavTop.offset().top;
- $toggleMenu.on('click', toggleMenu);
+ $toggleMenu.on("click", toggleMenu);
if ($mainNavTop.length > 0) {
onScroll(() => {
const stickSideMenu =
Math.floor($(window).scrollTop()) > Math.ceil(mainNavTop);
- $('body').toggleClass('sticky-nav', stickSideMenu);
+ $("body").toggleClass("sticky-nav", stickSideMenu);
});
}
}
diff --git a/saleor/static/dashboard/js/components/sortable.js b/saleor/static/dashboard/js/components/sortable.js
index c7d0bbdaea..a26ce6da19 100644
--- a/saleor/static/dashboard/js/components/sortable.js
+++ b/saleor/static/dashboard/js/components/sortable.js
@@ -1,26 +1,26 @@
-import Sortable from 'sortablejs';
+import Sortable from "sortablejs";
-$('.sortable-items').each((sortableIndex, sortableItems) => {
+$(".sortable-items").each((sortableIndex, sortableItems) => {
const sortable = $(sortableItems);
Sortable.create(sortableItems, {
- handle: '.sortable__drag-area',
+ handle: ".sortable__drag-area",
animation: 150,
onUpdate: () => {
const sortedItems = sortable
- .find('.sortable-item[data-id]')
+ .find(".sortable-item[data-id]")
.map((index, item) => item.dataset.id)
.toArray();
const data = {};
- data[sortable.data('post-name')] = sortedItems;
+ data[sortable.data("post-name")] = sortedItems;
// TODO: Get rid of ajax() in favour of fetch()
$.ajax({
- method: 'POST',
- url: sortable.data('post-url'),
+ method: "POST",
+ url: sortable.data("post-url"),
data: data,
traditional: true,
headers: {
- 'X-CSRFToken': $.cookie('csrftoken')
+ "X-CSRFToken": $.cookie("csrftoken")
}
});
}
diff --git a/saleor/static/dashboard/js/components/tab.js b/saleor/static/dashboard/js/components/tab.js
index b5bea935d2..464762975e 100644
--- a/saleor/static/dashboard/js/components/tab.js
+++ b/saleor/static/dashboard/js/components/tab.js
@@ -1,15 +1,15 @@
-const $tabs = $('ul.tabs');
+const $tabs = $("ul.tabs");
if ($tabs.length) {
- $tabs.find('.tab').on('click', e => {
+ $tabs.find(".tab").on("click", e => {
const tabSelector = $(e.currentTarget)
- .find('a')
- .attr('href');
- $('.btn-fab').addClass('btn-fab-hidden');
- $(tabSelector + '-btn').removeClass('btn-fab-hidden');
+ .find("a")
+ .attr("href");
+ $(".btn-fab").addClass("btn-fab-hidden");
+ $(tabSelector + "-btn").removeClass("btn-fab-hidden");
});
$tabs
- .find('a.active')
+ .find("a.active")
.parent()
.click();
}
diff --git a/saleor/static/dashboard/js/components/utils.js b/saleor/static/dashboard/js/components/utils.js
index 7e066041bb..d6ba6e4ee6 100644
--- a/saleor/static/dashboard/js/components/utils.js
+++ b/saleor/static/dashboard/js/components/utils.js
@@ -1,9 +1,9 @@
-import detectPassiveEvents from 'detect-passive-events';
-import { parse, stringify } from 'qs';
+import detectPassiveEvents from "detect-passive-events";
+import { parse, stringify } from "qs";
function onScroll(func) {
window.addEventListener(
- 'scroll',
+ "scroll",
func,
detectPassiveEvents.hasSupport
? {
diff --git a/saleor/static/dashboard/js/components/vouchers.js b/saleor/static/dashboard/js/components/vouchers.js
index 02070ac5e6..e80f6cf018 100644
--- a/saleor/static/dashboard/js/components/vouchers.js
+++ b/saleor/static/dashboard/js/components/vouchers.js
@@ -4,9 +4,9 @@
*/
function onVoucherTypeChange(e) {
const $target = $(e.currentTarget);
- $('.voucher-form').each((index, form) => {
+ $(".voucher-form").each((index, form) => {
const $form = $(form);
- $form.toggleClass('hide', $form.data('type') !== $target.val());
+ $form.toggleClass("hide", $form.data("type") !== $target.val());
});
}
@@ -18,15 +18,15 @@ function onDiscountTypeChange(e) {
const $target = $(e.currentTarget);
const showOnPercentage =
'[name="product-apply_to"], [name="category-apply_to"]';
- const $showOnPercentage = $(showOnPercentage).parents('.input');
- $showOnPercentage.toggleClass('hide', $target.val() === 'percentage');
+ const $showOnPercentage = $(showOnPercentage).parents(".input");
+ $showOnPercentage.toggleClass("hide", $target.val() === "percentage");
}
// -----
$('[name="discount_value_type"]')
- .on('change', onDiscountTypeChange)
- .trigger('change');
+ .on("change", onDiscountTypeChange)
+ .trigger("change");
$('[name="type"]')
- .on('change', onVoucherTypeChange)
- .trigger('change');
+ .on("change", onVoucherTypeChange)
+ .trigger("change");
diff --git a/saleor/static/dashboard/js/dashboard.js b/saleor/static/dashboard/js/dashboard.js
index 2ff551a4fe..c4e9bbcf7a 100644
--- a/saleor/static/dashboard/js/dashboard.js
+++ b/saleor/static/dashboard/js/dashboard.js
@@ -1,5 +1,5 @@
-import 'materialize-css/dist/js/materialize';
-import 'jquery.cookie';
+import "materialize-css/dist/js/materialize";
+import "jquery.cookie";
-import '../scss/dashboard.scss';
-import './components';
+import "../scss/dashboard.scss";
+import "./components";
diff --git a/saleor/static/dashboard/js/document.js b/saleor/static/dashboard/js/document.js
index c591eed04a..0493bc1b5f 100644
--- a/saleor/static/dashboard/js/document.js
+++ b/saleor/static/dashboard/js/document.js
@@ -1 +1 @@
-import '../scss/document.scss';
+import "../scss/document.scss";
diff --git a/saleor/static/js/components/address-form.js b/saleor/static/js/components/address-form.js
index 98f1202ef5..4a3c74b467 100644
--- a/saleor/static/js/components/address-form.js
+++ b/saleor/static/js/components/address-form.js
@@ -1,46 +1,46 @@
export default $(document).ready(e => {
$(function() {
- const $i18nAddresses = $('.i18n-address');
+ const $i18nAddresses = $(".i18n-address");
$i18nAddresses.each(function() {
- const $form = $(this).closest('form');
- const $countryField = $form.find('select[name=country]');
- const $previewField = $form.find('input.preview');
- $countryField.on('change', () => {
- $previewField.val('on');
+ const $form = $(this).closest("form");
+ const $countryField = $form.find("select[name=country]");
+ const $previewField = $form.find("input.preview");
+ $countryField.on("change", () => {
+ $previewField.val("on");
$form.submit();
});
});
});
- let $deleteAdressIcons = $('.icons');
- let $deleteAdressIcon = $('.delete-icon');
- let $deleteAddress = $('.address-delete');
+ let $deleteAdressIcons = $(".icons");
+ let $deleteAdressIcon = $(".delete-icon");
+ let $deleteAddress = $(".address-delete");
- $deleteAdressIcon.on('click', e => {
- if ($deleteAddress.hasClass('none')) {
- $deleteAddress.removeClass('none');
- $deleteAdressIcons.addClass('none');
+ $deleteAdressIcon.on("click", e => {
+ if ($deleteAddress.hasClass("none")) {
+ $deleteAddress.removeClass("none");
+ $deleteAdressIcons.addClass("none");
} else {
- $deleteAddress.addClass('none');
+ $deleteAddress.addClass("none");
}
});
- $deleteAddress.find('.cancel').on('click', e => {
- $deleteAddress.addClass('none');
- $deleteAdressIcons.removeClass('none');
+ $deleteAddress.find(".cancel").on("click", e => {
+ $deleteAddress.addClass("none");
+ $deleteAdressIcons.removeClass("none");
});
// New address dropdown
- let $addressShow = $('.address_show label');
- let $addressHide = $('.address_hide label');
- let $addressForm = $('.checkout__new-address');
- let $initialValue = $('#address_new_address').prop('checked');
+ let $addressShow = $(".address_show label");
+ let $addressHide = $(".address_hide label");
+ let $addressForm = $(".checkout__new-address");
+ let $initialValue = $("#address_new_address").prop("checked");
$addressShow.click(e => {
- $addressForm.slideDown('slow');
+ $addressForm.slideDown("slow");
});
$addressHide.click(e => {
- $addressForm.slideUp('slow');
+ $addressForm.slideUp("slow");
});
if ($initialValue) {
$addressForm.slideDown(0);
diff --git a/saleor/static/js/components/checkout.js b/saleor/static/js/components/checkout.js
index 09b3d61778..b943a29310 100644
--- a/saleor/static/js/components/checkout.js
+++ b/saleor/static/js/components/checkout.js
@@ -1,10 +1,10 @@
-import { getAjaxError } from './misc';
+import { getAjaxError } from "./misc";
-export const summaryLink = $('html').data('checkout-summary-url');
-export const $checkoutDropdown = $('.checkout-preview-dropdown');
-export const $checkoutIcon = $('.checkout__icon');
-export const $addToCheckoutError = $('.product__info__form-error small');
-export const $removeProductSuccess = $('.remove-product-alert');
+export const summaryLink = $("html").data("checkout-summary-url");
+export const $checkoutDropdown = $(".checkout-preview-dropdown");
+export const $checkoutIcon = $(".checkout__icon");
+export const $addToCheckoutError = $(".product__info__form-error small");
+export const $removeProductSuccess = $(".remove-product-alert");
export const onAddToCheckoutError = response => {
$addToCheckoutError.html(getAjaxError(response));
@@ -13,22 +13,22 @@ export const onAddToCheckoutError = response => {
export const onAddToCheckoutSuccess = () => {
$.get(summaryLink, data => {
$checkoutDropdown.html(data);
- $addToCheckoutError.html('');
- var newQunatity = $('.checkout-preview-dropdown__total').data('quantity');
- $('.badge')
+ $addToCheckoutError.html("");
+ var newQunatity = $(".checkout-preview-dropdown__total").data("quantity");
+ $(".badge")
.html(newQunatity)
- .removeClass('empty');
- $checkoutDropdown.addClass('show');
- $checkoutIcon.addClass('hover');
+ .removeClass("empty");
+ $checkoutDropdown.addClass("show");
+ $checkoutIcon.addClass("hover");
$checkoutDropdown
- .find('.checkout-preview-dropdown__list')
+ .find(".checkout-preview-dropdown__list")
.scrollTop(
- $checkoutDropdown.find('.checkout-preview-dropdown__list')[0]
+ $checkoutDropdown.find(".checkout-preview-dropdown__list")[0]
.scrollHeight
);
setTimeout(e => {
- $checkoutDropdown.removeClass('show');
- $checkoutIcon.removeClass('hover');
+ $checkoutDropdown.removeClass("show");
+ $checkoutIcon.removeClass("hover");
}, 2500);
});
};
@@ -38,24 +38,24 @@ export default $(document).ready(e => {
$.get(summaryLink, data => {
$checkoutDropdown.html(data);
});
- $('.navbar__brand__checkout').hover(
+ $(".navbar__brand__checkout").hover(
e => {
- $checkoutDropdown.addClass('show');
- $checkoutIcon.addClass('hover');
+ $checkoutDropdown.addClass("show");
+ $checkoutIcon.addClass("hover");
},
e => {
- $checkoutDropdown.removeClass('show');
- $checkoutIcon.removeClass('hover');
+ $checkoutDropdown.removeClass("show");
+ $checkoutIcon.removeClass("hover");
}
);
- $('.product-form button').click(e => {
+ $(".product-form button").click(e => {
e.preventDefault();
let $target = $(e.target.form);
let quantity = $target.find('input[name="quantity"]').val();
let variant = $target.find('[name="variant"]').val();
$.ajax({
- url: $target.attr('action'),
- type: 'POST',
+ url: $target.attr("action"),
+ type: "POST",
data: {
variant: variant,
quantity: quantity
@@ -68,14 +68,14 @@ export default $(document).ready(e => {
}
});
});
- $('.checkout-preview__clear').click(e => {
+ $(".checkout-preview__clear").click(e => {
$.ajax({
- url: $('.checkout-preview__clear').data('action'),
- method: 'POST',
+ url: $(".checkout-preview__clear").data("action"),
+ method: "POST",
data: {},
success: response => {
- $('.badge').html(response.numItems);
- $.cookie('alert', 'true', { path: '/checkout' });
+ $(".badge").html(response.numItems);
+ $.cookie("alert", "true", { path: "/checkout" });
location.reload();
}
});
@@ -83,43 +83,43 @@ export default $(document).ready(e => {
// Checkout quantity form
- let $checkoutLine = $('.checkout-preview__line');
- let $total = $('.checkout-preview-subtotal');
- let $checkoutBadge = $('.navbar__brand__checkout .badge');
- let $closeMsg = $('.close-msg');
- $closeMsg.on('click', e => {
- $removeProductSuccess.addClass('d-none');
+ let $checkoutLine = $(".checkout-preview__line");
+ let $total = $(".checkout-preview-subtotal");
+ let $checkoutBadge = $(".navbar__brand__checkout .badge");
+ let $closeMsg = $(".close-msg");
+ $closeMsg.on("click", e => {
+ $removeProductSuccess.addClass("d-none");
});
$checkoutLine.each(function() {
- let $quantityInput = $(this).find('#id_quantity');
+ let $quantityInput = $(this).find("#id_quantity");
let checkoutFormUrl = $(this)
- .find('.form-checkout')
- .attr('action');
+ .find(".form-checkout")
+ .attr("action");
let $qunatityError = $(this).find(
- '.checkout-preview__line__quantity-error'
+ ".checkout-preview__line__quantity-error"
);
- let $subtotal = $(this).find('.checkout-preview-item-price p');
- let $deleteIcon = $(this).find('.checkout-preview-item-delete');
- $(this).on('change', $quantityInput, e => {
+ let $subtotal = $(this).find(".checkout-preview-item-price p");
+ let $deleteIcon = $(this).find(".checkout-preview-item-delete");
+ $(this).on("change", $quantityInput, e => {
let newQuantity = $quantityInput.val();
$.ajax({
url: checkoutFormUrl,
- method: 'POST',
+ method: "POST",
data: { quantity: newQuantity },
success: response => {
if (newQuantity === 0) {
if (response.checkout.numLines === 0) {
- $.cookie('alert', 'true', { path: '/checkout' });
+ $.cookie("alert", "true", { path: "/checkout" });
location.reload();
} else {
- $removeProductSuccess.removeClass('d-none');
+ $removeProductSuccess.removeClass("d-none");
$(this).fadeOut();
}
} else {
$subtotal.html(response.subtotal);
}
$checkoutBadge.html(response.checkout.numItems);
- $qunatityError.html('');
+ $qunatityError.html("");
$checkoutDropdown.load(summaryLink);
deliveryAjax();
},
@@ -128,10 +128,10 @@ export default $(document).ready(e => {
}
});
});
- $deleteIcon.on('click', e => {
+ $deleteIcon.on("click", e => {
$.ajax({
url: checkoutFormUrl,
- method: 'POST',
+ method: "POST",
data: { quantity: 0 },
success: response => {
if (response.checkout.numLines >= 1) {
@@ -139,9 +139,9 @@ export default $(document).ready(e => {
$total.html(response.total);
$checkoutBadge.html(response.checkout.numItems);
$checkoutDropdown.load(summaryLink);
- $removeProductSuccess.removeClass('d-none');
+ $removeProductSuccess.removeClass("d-none");
} else {
- $.cookie('alert', 'true', { path: '/checkout' });
+ $.cookie("alert", "true", { path: "/checkout" });
location.reload();
}
deliveryAjax();
@@ -152,15 +152,15 @@ export default $(document).ready(e => {
// Delivery information
- let $deliveryForm = $('.deliveryform');
- let crsfToken = $deliveryForm.data('crsf');
- let countrySelect = '#id_country';
- let $checkoutSubtotal = $('.checkout__subtotal');
+ let $deliveryForm = $(".deliveryform");
+ let crsfToken = $deliveryForm.data("crsf");
+ let countrySelect = "#id_country";
+ let $checkoutSubtotal = $(".checkout__subtotal");
let deliveryAjax = e => {
let newCountry = $(countrySelect).val();
$.ajax({
- url: $('html').data('shipping-options-url'),
- type: 'POST',
+ url: $("html").data("shipping-options-url"),
+ type: "POST",
data: {
csrfmiddlewaretoken: crsfToken,
country: newCountry
@@ -171,10 +171,10 @@ export default $(document).ready(e => {
});
};
- $checkoutSubtotal.on('change', countrySelect, deliveryAjax);
+ $checkoutSubtotal.on("change", countrySelect, deliveryAjax);
- if ($.cookie('alert') === 'true') {
- $removeProductSuccess.removeClass('d-none');
- $.cookie('alert', 'false', { path: '/checkout' });
+ if ($.cookie("alert") === "true") {
+ $removeProductSuccess.removeClass("d-none");
+ $.cookie("alert", "false", { path: "/checkout" });
}
});
diff --git a/saleor/static/js/components/description-json.js b/saleor/static/js/components/description-json.js
index 9f42ea66d4..0d819a460d 100644
--- a/saleor/static/js/components/description-json.js
+++ b/saleor/static/js/components/description-json.js
@@ -1,7 +1,7 @@
-import draftToHtml from 'draftjs-to-html';
+import draftToHtml from "draftjs-to-html";
export default $(document).ready(e => {
- const data = 'data-description-json';
+ const data = "data-description-json";
const description = document.querySelector(`[${data}]`);
if (description) {
const parsed = JSON.parse(description.getAttribute(data));
diff --git a/saleor/static/js/components/footer.js b/saleor/static/js/components/footer.js
index 05121e5675..5739c9495e 100644
--- a/saleor/static/js/components/footer.js
+++ b/saleor/static/js/components/footer.js
@@ -1,9 +1,9 @@
export default $(document).ready(e => {
- let navbarHeight = $('.navbar').outerHeight(true);
- let footerHeight = $('.footer').outerHeight(true);
+ let navbarHeight = $(".navbar").outerHeight(true);
+ let footerHeight = $(".footer").outerHeight(true);
let windowHeight = $(window).height();
- $('.maincontent').css(
- 'min-height',
+ $(".maincontent").css(
+ "min-height",
windowHeight - navbarHeight - footerHeight
);
});
diff --git a/saleor/static/js/components/language-picker.js b/saleor/static/js/components/language-picker.js
index 6ea913dec5..c80346a15e 100644
--- a/saleor/static/js/components/language-picker.js
+++ b/saleor/static/js/components/language-picker.js
@@ -1,10 +1,10 @@
-$('.language-pick').on('click', e => {
+$(".language-pick").on("click", e => {
const $option = $(e.currentTarget);
- const $langCode = $option.data('lang');
+ const $langCode = $option.data("lang");
const $input = $(
`<input name="language" type="hidden" value="${$langCode}">`
);
- const $languagePickerForm = $('#language-picker');
+ const $languagePickerForm = $("#language-picker");
$languagePickerForm.append($input);
$languagePickerForm.submit();
});
diff --git a/saleor/static/js/components/misc.js b/saleor/static/js/components/misc.js
index 2da8a9b26e..16a35b8a4e 100644
--- a/saleor/static/js/components/misc.js
+++ b/saleor/static/js/components/misc.js
@@ -1,23 +1,23 @@
-import 'lazysizes';
-import SVGInjector from 'svg-injector-2';
+import "lazysizes";
+import SVGInjector from "svg-injector-2";
export const getAjaxError = response => {
let ajaxError = $.parseJSON(response.responseText).error.quantity;
return ajaxError;
};
-export const csrftoken = $.cookie('csrftoken');
+export const csrftoken = $.cookie("csrftoken");
export default $(document).ready(e => {
function csrfSafeMethod(method) {
return /^(GET|HEAD|OPTIONS|TRACE)$/.test(method);
}
- new SVGInjector().inject(document.querySelectorAll('svg[data-src]'));
+ new SVGInjector().inject(document.querySelectorAll("svg[data-src]"));
$.ajaxSetup({
beforeSend: function(xhr, settings) {
if (!csrfSafeMethod(settings.type) && !this.crossDomain) {
- xhr.setRequestHeader('X-CSRFToken', csrftoken);
+ xhr.setRequestHeader("X-CSRFToken", csrftoken);
}
}
});
@@ -25,22 +25,22 @@ export default $(document).ready(e => {
// Open tab from the link
let hash = window.location.hash;
- $('.nav-tabs a[href="' + hash + '"]').tab('show');
+ $('.nav-tabs a[href="' + hash + '"]').tab("show");
// Preload all images
window.lazySizesConfig.preloadAfterLoad = true;
// Function for update product image height
function updateProductImageHeight() {
- let productImageWidth = $('.product-image').width();
- $('.product-image').css({ height: productImageWidth + 'px' });
+ let productImageWidth = $(".product-image").width();
+ $(".product-image").css({ height: productImageWidth + "px" });
}
// Update product-image height when window is initialized
updateProductImageHeight();
// Update product-image height
- $(window).bind('resized', function() {
+ $(window).bind("resized", function() {
updateProductImageHeight();
});
});
diff --git a/saleor/static/js/components/navbar.js b/saleor/static/js/components/navbar.js
index 5adab6bb59..713b3c14e1 100644
--- a/saleor/static/js/components/navbar.js
+++ b/saleor/static/js/components/navbar.js
@@ -1,60 +1,60 @@
-const $toogleIcon = $('.navbar__brand__menu-toggle');
-const $mobileNav = $('nav');
-const $searchIcon = $('.mobile-search-icon');
-const $closeSearchIcon = $('.mobile-close-search');
-const $searchForm = $('.search-form');
+const $toogleIcon = $(".navbar__brand__menu-toggle");
+const $mobileNav = $("nav");
+const $searchIcon = $(".mobile-search-icon");
+const $closeSearchIcon = $(".mobile-close-search");
+const $searchForm = $(".search-form");
const renderNavbar = () => {
- const $desktopLinkBar = $('.navbar__login');
- const $mobileLinkBar = $('.navbar__menu__login');
+ const $desktopLinkBar = $(".navbar__login");
+ const $mobileLinkBar = $(".navbar__menu__login");
const windowWidth = window.innerWidth;
- const $languagePicker = $('.language-picker');
- const $languagePickerButton = $('#language-picker-button');
+ const $languagePicker = $(".language-picker");
+ const $languagePickerButton = $("#language-picker-button");
if (windowWidth < 768) {
- const $desktopLinks = $desktopLinkBar.find('a').not('.dropdown-link');
+ const $desktopLinks = $desktopLinkBar.find("a").not(".dropdown-link");
if ($desktopLinks.length) {
- $searchForm.addClass('search-form--hidden');
+ $searchForm.addClass("search-form--hidden");
$mobileNav.append('<ul class="nav navbar-nav navbar__menu__login"></ul>');
$languagePicker
- .appendTo('.navbar__menu__login')
+ .appendTo(".navbar__menu__login")
.wrap('<li class="nav-item login-item"></li>')
- .addClass('nav-link');
+ .addClass("nav-link");
$desktopLinks
- .appendTo('.navbar__menu__login')
+ .appendTo(".navbar__menu__login")
.wrap('<li class="nav-item login-item"></li>')
- .addClass('nav-link');
- $desktopLinkBar.find('li').remove();
+ .addClass("nav-link");
+ $desktopLinkBar.find("li").remove();
}
- $languagePickerButton.attr('data-target', '#languagePickerModal');
- $languagePickerButton.attr('data-toggle', 'modal');
+ $languagePickerButton.attr("data-target", "#languagePickerModal");
+ $languagePickerButton.attr("data-toggle", "modal");
} else {
- const $mobileLinks = $mobileLinkBar.find('a').not('.dropdown-link');
+ const $mobileLinks = $mobileLinkBar.find("a").not(".dropdown-link");
if ($mobileLinks.length) {
- $searchForm.removeClass('search-form--hidden');
+ $searchForm.removeClass("search-form--hidden");
$languagePicker
- .appendTo('.navbar__login ul')
- .wrap('<li></li>')
- .removeClass('nav-link');
+ .appendTo(".navbar__login ul")
+ .wrap("<li></li>")
+ .removeClass("nav-link");
$mobileLinks
- .appendTo('.navbar__login ul')
- .wrap('<li></li>')
- .removeClass('nav-link');
+ .appendTo(".navbar__login ul")
+ .wrap("<li></li>")
+ .removeClass("nav-link");
$mobileLinkBar.remove();
}
- $languagePickerButton.attr('data-target', '');
- $languagePickerButton.attr('data-toggle', 'dropdown');
+ $languagePickerButton.attr("data-target", "");
+ $languagePickerButton.attr("data-toggle", "dropdown");
}
};
// -----
renderNavbar();
-$toogleIcon.on('click', e => {
- $mobileNav.toggleClass('open');
+$toogleIcon.on("click", e => {
+ $mobileNav.toggleClass("open");
e.stopPropagation();
});
-$(document).on('click', () => $mobileNav.removeClass('open'));
-$(window).on('resize', renderNavbar);
-$searchIcon.on('click', () => $searchForm.removeClass('search-form--hidden'));
-$closeSearchIcon.on('click', () => $searchForm.addClass('search-form--hidden'));
+$(document).on("click", () => $mobileNav.removeClass("open"));
+$(window).on("resize", renderNavbar);
+$searchIcon.on("click", () => $searchForm.removeClass("search-form--hidden"));
+$closeSearchIcon.on("click", () => $searchForm.addClass("search-form--hidden"));
diff --git a/saleor/static/js/components/password-input.js b/saleor/static/js/components/password-input.js
index 03128ed646..353d42c6a2 100644
--- a/saleor/static/js/components/password-input.js
+++ b/saleor/static/js/components/password-input.js
@@ -1,22 +1,22 @@
-import passwordIvisible from '../../images/pass-invisible.svg';
-import passwordVisible from '../../images/pass-visible.svg';
+import passwordIvisible from "../../images/pass-invisible.svg";
+import passwordVisible from "../../images/pass-visible.svg";
export default $(document).ready(e => {
- let $inputPassword = $('input[type=password]');
- $('<img class="passIcon" src=' + passwordIvisible + ' />').insertAfter(
+ let $inputPassword = $("input[type=password]");
+ $('<img class="passIcon" src=' + passwordIvisible + " />").insertAfter(
$inputPassword
);
- $inputPassword.parent().addClass('relative');
- $('.passIcon').on('click', e => {
+ $inputPassword.parent().addClass("relative");
+ $(".passIcon").on("click", e => {
let $input = $(e.target)
.parent()
- .find('input');
- if ($input.attr('type') === 'password') {
- $input.attr('type', 'text');
- $(e.target).attr('src', passwordVisible);
+ .find("input");
+ if ($input.attr("type") === "password") {
+ $input.attr("type", "text");
+ $(e.target).attr("src", passwordVisible);
} else {
- $input.attr('type', 'password');
- $(e.target).attr('src', passwordIvisible);
+ $input.attr("type", "password");
+ $(e.target).attr("src", passwordIvisible);
}
});
});
diff --git a/saleor/static/js/components/product-filters.js b/saleor/static/js/components/product-filters.js
index 10e1ffbff7..a00a0f175d 100644
--- a/saleor/static/js/components/product-filters.js
+++ b/saleor/static/js/components/product-filters.js
@@ -1,21 +1,21 @@
-$('.filters-menu').on('click', e => {
- const menuContainer = $('.filters-menu__body');
- if (menuContainer.hasClass('d-none')) {
- menuContainer.removeClass('d-none');
+$(".filters-menu").on("click", e => {
+ const menuContainer = $(".filters-menu__body");
+ if (menuContainer.hasClass("d-none")) {
+ menuContainer.removeClass("d-none");
} else {
- menuContainer.addClass('d-none');
+ menuContainer.addClass("d-none");
}
});
-$('.filter-section__header').on('click', event => {
+$(".filter-section__header").on("click", event => {
const $target = $(event.currentTarget).parent();
- if ($target.attr('aria-expanded') === 'true') {
- $target.attr('aria-expanded', 'false').addClass('filter-section--closed');
+ if ($target.attr("aria-expanded") === "true") {
+ $target.attr("aria-expanded", "false").addClass("filter-section--closed");
} else {
- $target.attr('aria-expanded', 'true').removeClass('filter-section--closed');
+ $target.attr("aria-expanded", "true").removeClass("filter-section--closed");
}
});
-$('.filters-toggle').on('click', () => {
- $('.filters-menu__body').toggleClass('d-none');
+$(".filters-toggle").on("click", () => {
+ $(".filters-menu__body").toggleClass("d-none");
});
diff --git a/saleor/static/js/components/sorter.js b/saleor/static/js/components/sorter.js
index 12c2df21c1..793ecec7e9 100644
--- a/saleor/static/js/components/sorter.js
+++ b/saleor/static/js/components/sorter.js
@@ -1,19 +1,19 @@
export default $(document).ready(e => {
$(document).ready(e => {
- $('.sort-by button').on('click', e => {
+ $(".sort-by button").on("click", e => {
const parentContainer = $(e.currentTarget).parent();
- const list = parentContainer.find('.sort-list');
- if (list.hasClass('d-none')) {
- list.removeClass('d-none');
- parentContainer.find('.click-area').removeClass('d-none');
+ const list = parentContainer.find(".sort-list");
+ if (list.hasClass("d-none")) {
+ list.removeClass("d-none");
+ parentContainer.find(".click-area").removeClass("d-none");
} else {
- list.addClass('d-none');
- parentContainer.find('.click-area').addClass('d-none');
+ list.addClass("d-none");
+ parentContainer.find(".click-area").addClass("d-none");
}
});
- $('.sort-by .click-area').on('click', e => {
- $('.sort-by .sort-list').addClass('d-none');
- $(e.currentTarget).addClass('d-none');
+ $(".sort-by .click-area").on("click", e => {
+ $(".sort-by .sort-list").addClass("d-none");
+ $(e.currentTarget).addClass("d-none");
});
});
});
diff --git a/saleor/static/js/components/styleguide.js b/saleor/static/js/components/styleguide.js
index 3b3ddaa104..563693087f 100644
--- a/saleor/static/js/components/styleguide.js
+++ b/saleor/static/js/components/styleguide.js
@@ -1,10 +1,10 @@
export default $(document).ready(function() {
- let styleGuideMenu = $('.styleguide__nav');
+ let styleGuideMenu = $(".styleguide__nav");
$(window).scroll(function() {
if ($(this).scrollTop() > 100) {
- styleGuideMenu.addClass('fixed');
+ styleGuideMenu.addClass("fixed");
} else {
- styleGuideMenu.removeClass('fixed');
+ styleGuideMenu.removeClass("fixed");
}
});
});
diff --git a/saleor/static/js/components/variant-picker.js b/saleor/static/js/components/variant-picker.js
index 49a33e4b3d..875a42e6d5 100644
--- a/saleor/static/js/components/variant-picker.js
+++ b/saleor/static/js/components/variant-picker.js
@@ -1,16 +1,16 @@
-import React from 'react';
-import ReactDOM from 'react-dom';
+import React from "react";
+import ReactDOM from "react-dom";
-import VariantPicker from './variantPicker/VariantPicker';
-import VariantPrice from './variantPicker/VariantPrice';
-import variantPickerStore from '../stores/variantPicker';
+import VariantPicker from "./variantPicker/VariantPicker";
+import VariantPrice from "./variantPicker/VariantPrice";
+import variantPickerStore from "../stores/variantPicker";
-import { onAddToCheckoutSuccess, onAddToCheckoutError } from './checkout';
+import { onAddToCheckoutSuccess, onAddToCheckoutError } from "./checkout";
export default $(document).ready(e => {
- const variantPickerContainer = document.getElementById('variant-picker');
+ const variantPickerContainer = document.getElementById("variant-picker");
const variantPriceContainer = document.getElementById(
- 'variant-price-component'
+ "variant-price-component"
);
if (variantPickerContainer) {
diff --git a/saleor/static/js/components/variantPicker/AttributeSelectionWidget.js b/saleor/static/js/components/variantPicker/AttributeSelectionWidget.js
index 9c484c8dfc..5a03aeb4c3 100644
--- a/saleor/static/js/components/variantPicker/AttributeSelectionWidget.js
+++ b/saleor/static/js/components/variantPicker/AttributeSelectionWidget.js
@@ -1,6 +1,6 @@
-import React, { Component } from 'react';
-import PropTypes from 'prop-types';
-import classNames from 'classnames';
+import React, { Component } from "react";
+import PropTypes from "prop-types";
+import classNames from "classnames";
export default class AttributeSelectionWidget extends Component {
static propTypes = {
@@ -22,7 +22,7 @@ export default class AttributeSelectionWidget extends Component {
{attribute.values.map((value, i) => {
const active = selected === value.pk.toString();
const labelClass = classNames({
- 'btn btn-secondary variant-picker__option': true,
+ "btn btn-secondary variant-picker__option": true,
active: active
});
return (
diff --git a/saleor/static/js/components/variantPicker/QuantityInput.js b/saleor/static/js/components/variantPicker/QuantityInput.js
index 4eae24b1ac..dcc0fabfd7 100644
--- a/saleor/static/js/components/variantPicker/QuantityInput.js
+++ b/saleor/static/js/components/variantPicker/QuantityInput.js
@@ -1,6 +1,6 @@
-import classNames from 'classnames';
-import React, { Component } from 'react';
-import PropTypes from 'prop-types';
+import classNames from "classnames";
+import React, { Component } from "react";
+import PropTypes from "prop-types";
export default class QuantityInput extends Component {
static propTypes = {
@@ -12,8 +12,8 @@ export default class QuantityInput extends Component {
render() {
const { errors, quantity } = this.props;
const formGroupClasses = classNames({
- 'form-group': true,
- 'has-error': errors && !!errors.length,
+ "form-group": true,
+ "has-error": errors && !!errors.length,
product__info__quantity: true
});
return (
@@ -22,7 +22,7 @@ export default class QuantityInput extends Component {
className="control-label product__variant-picker__label"
htmlFor="id_quantity"
>
- {pgettext('Add to cart form field label', 'Quantity')}
+ {pgettext("Add to cart form field label", "Quantity")}
</label>
<input
className="form-control"
@@ -34,7 +34,7 @@ export default class QuantityInput extends Component {
onChange={this.props.handleChange}
type="number"
/>
- {errors && <span className="help-block">{errors.join(' ')}</span>}
+ {errors && <span className="help-block">{errors.join(" ")}</span>}
</div>
);
}
diff --git a/saleor/static/js/components/variantPicker/VariantPicker.js b/saleor/static/js/components/variantPicker/VariantPicker.js
index 84934d9a10..d218897a2e 100644
--- a/saleor/static/js/components/variantPicker/VariantPicker.js
+++ b/saleor/static/js/components/variantPicker/VariantPicker.js
@@ -1,13 +1,13 @@
-import _ from 'lodash';
-import $ from 'jquery';
-import classNames from 'classnames';
-import { observer } from 'mobx-react';
-import React, { Component } from 'react';
-import PropTypes from 'prop-types';
+import _ from "lodash";
+import $ from "jquery";
+import classNames from "classnames";
+import { observer } from "mobx-react";
+import React, { Component } from "react";
+import PropTypes from "prop-types";
-import AttributeSelectionWidget from './AttributeSelectionWidget';
-import QuantityInput from './QuantityInput';
-import * as queryString from 'query-string';
+import AttributeSelectionWidget from "./AttributeSelectionWidget";
+import QuantityInput from "./QuantityInput";
+import * as queryString from "query-string";
export default observer(
class VariantPicker extends Component {
@@ -69,7 +69,7 @@ export default observer(
if (quantity > 0 && !store.isEmpty) {
$.ajax({
url: this.props.url,
- method: 'post',
+ method: "post",
data: {
quantity: quantity,
variant: store.variant.id
@@ -104,7 +104,7 @@ export default observer(
params[attribute.slug] = value.slug;
}
});
- history.pushState(null, null, '?' + queryString.stringify(params));
+ history.pushState(null, null, "?" + queryString.stringify(params));
}
);
};
@@ -161,7 +161,7 @@ export default observer(
store.isEmpty || !this.checkVariantAvailability();
const addToCheckoutBtnClasses = classNames({
- 'btn btn-primary': true,
+ "btn btn-primary": true,
disabled: disableAddToCheckout
});
@@ -187,7 +187,7 @@ export default observer(
onClick={this.handleAddToCheckout}
disabled={disableAddToCheckout}
>
- {pgettext('Product details primary action', 'Add to cart')}
+ {pgettext("Product details primary action", "Add to cart")}
</button>
</div>
</div>
diff --git a/saleor/static/js/components/variantPicker/VariantPrice.js b/saleor/static/js/components/variantPicker/VariantPrice.js
index dd11f54eb2..4db5ee2729 100644
--- a/saleor/static/js/components/variantPicker/VariantPrice.js
+++ b/saleor/static/js/components/variantPicker/VariantPrice.js
@@ -1,6 +1,6 @@
-import { observer } from 'mobx-react';
-import React, { Component } from 'react';
-import PropTypes from 'prop-types';
+import { observer } from "mobx-react";
+import React, { Component } from "react";
+import PropTypes from "prop-types";
export default observer(
class VariantPrice extends Component {
diff --git a/saleor/static/js/storefront.js b/saleor/static/js/storefront.js
index f10b923e9e..0595d9ee89 100644
--- a/saleor/static/js/storefront.js
+++ b/saleor/static/js/storefront.js
@@ -1,18 +1,18 @@
-import 'jquery';
-import 'jquery.cookie';
-import 'bootstrap';
+import "jquery";
+import "jquery.cookie";
+import "bootstrap";
-import '../scss/storefront.scss';
+import "../scss/storefront.scss";
-import './components/address-form';
-import './components/checkout';
-import './components/footer';
-import './components/language-picker';
-import './components/misc';
-import './components/navbar';
-import './components/password-input';
-import './components/product-filters';
-import './components/sorter';
-import './components/styleguide';
-import './components/variant-picker';
-import './components/description-json';
+import "./components/address-form";
+import "./components/checkout";
+import "./components/footer";
+import "./components/language-picker";
+import "./components/misc";
+import "./components/navbar";
+import "./components/password-input";
+import "./components/product-filters";
+import "./components/sorter";
+import "./components/styleguide";
+import "./components/variant-picker";
+import "./components/description-json";
diff --git a/saleor/static/js/stores/variantPicker.js b/saleor/static/js/stores/variantPicker.js
index 9059dc6bb1..68d93b847c 100644
--- a/saleor/static/js/stores/variantPicker.js
+++ b/saleor/static/js/stores/variantPicker.js
@@ -1,4 +1,4 @@
-import { extendObservable } from 'mobx';
+import { extendObservable } from "mobx";
class VariantPickerStore {
constructor() {