Skip to content

Commit

Permalink
Clean JS for every Atoms
Browse files Browse the repository at this point in the history
- Fix eslint warnings and errors
- Fix deprecated jQuery API
  • Loading branch information
williambelle committed Dec 1, 2023
1 parent f0b55e3 commit f991ea2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
6 changes: 3 additions & 3 deletions assets/components/atoms/drawer/drawer.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
/* global $ */

const drawer = () => {
$('.drawer-toggle').click(function () {
const $drawer = $(this).parent('.drawer');
$('.drawer-toggle').on('click', (event) => {
const $drawer = $(event.currentTarget).parent('.drawer');
const $drawerLink = $drawer.find('.drawer-link');
const $drawerToggle = $(this);
const $drawerToggle = $(event.currentTarget);
const breakpoint = 992;

if ($drawer.hasClass('open')) {
Expand Down
3 changes: 1 addition & 2 deletions assets/components/atoms/popover/popover.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* globals $ */

export default () => {
$(function () {
$(() => {
$('[data-toggle="popover"]').popover({
placement: 'top',
html: true,
Expand All @@ -10,4 +10,3 @@ export default () => {
});
});
};

2 changes: 1 addition & 1 deletion assets/components/atoms/tag/tag-input.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export default () => {
render: {
item: (data, escape) => `<div class="tag tag-primary">${escape(data.text)}</div>`,
},
create: input => ({
create: (input) => ({
value: input,
text: input,
}),
Expand Down
9 changes: 4 additions & 5 deletions assets/components/atoms/upload/upload.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
/* globals $ */

export default () => {
$('.upload').find('input[type="file"]').each(function () {
const $input = $(this);
$('.upload').find('input[type="file"]').each((index, element) => {
const $input = $(element);
const $preview = $input.next().next('.upload-preview');

$input.on('change', () => {
const files = $input[0].files;
const { files } = $input[0];
let previewContent = files[0].name;

if (files.length > 1) {
previewContent = `<ul>${Array.from(files).map(file => `<li>${file.name}</li>`).join().replace(/,/g, '')}</ul>`;
previewContent = `<ul>${Array.from(files).map((file) => `<li>${file.name}</li>`).join().replace(/,/g, '')}</ul>`;
}

$preview.html(previewContent);
});
});
};

0 comments on commit f991ea2

Please sign in to comment.