This repository was archived by the owner on Sep 15, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor jquery #65
Merged
Merged
Refactor jquery #65
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
d93b0c9
Remove old multipleSelect plugin
5758637
Refactor the framework Index file
5b913ec
Refactor the flatpickr components
abb870e
Refactor the Flash component
f30078d
Drop old JS componenets we no longer use
f7644ce
Rename the drag and drop component to avoid mix with Sortable
868583e
Refactor common use of jQuery in the remaining components
c8c1b04
Use the new data attribute to read the dark theme style path
23e6b82
Check if the dark style link tag exists before trying to delete it
e4d2967
Drop more deprecated modules
d37adcd
Add a check before using the JS back button
61a3206
Update popover init to BS 5 method
41b88bd
Merge and update the scrolling components
afca62f
Update theme component to use classList
52fab4c
Remove navbar and scrollevent import
9590a8e
Remove Slider and Table componenets
fc68728
Refactor more jQuery usage
c1c5af7
Check for multiple forms in hyjack submit listener
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,27 +1,26 @@ | ||
| export class Clipboard { | ||
| constructor(element) | ||
| { | ||
| constructor (element) { | ||
| element.addEventListener('click', (event) => { | ||
| const elementId = event.currentTarget.getAttribute('data-clipboard-target'); | ||
| const elementId = event.currentTarget.getAttribute('data-clipboard-target') | ||
|
|
||
| if (elementId === null) { | ||
| console.error( | ||
| 'data-clipboard-target attribute was not provided. This is the element we will be copying from.' | ||
| ); | ||
| ) | ||
|
|
||
| return; | ||
| return | ||
| } | ||
|
|
||
| const textSource = document.querySelector(elementId); | ||
| const textSource = document.querySelector(elementId) | ||
|
|
||
| if (textSource === null) { | ||
| console.error('Source element was not found "' + elementId + '".'); | ||
| console.error('Source element was not found "' + elementId + '".') | ||
|
|
||
| return; | ||
| return | ||
| } | ||
|
|
||
| const text = textSource.select(); | ||
| document.execCommand('copy'); | ||
| }); | ||
| const text = textSource.select() | ||
| document.execCommand('copy') | ||
| }) | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,56 +1,39 @@ | ||
| export class Cookies { | ||
| constructor () { | ||
| /** | ||
| * Utilities; useful scripts | ||
| */ | ||
| this.cookies = {}; | ||
| this.cookies = {} | ||
| } | ||
|
|
||
| /** | ||
| * Are cookies enabled? | ||
| * | ||
| * @return bool | ||
| */ | ||
| isEnabled () { | ||
| // try to grab the property | ||
| var cookiesEnabled = !!(navigator.cookieEnabled) | ||
| let cookiesEnabled = !!(navigator.cookieEnabled) | ||
|
|
||
| // unknown property? | ||
| if (typeof navigator.cookieEnabled === 'undefined' && !cookiesEnabled) { | ||
| // try to set a cookie | ||
| document.cookie = 'testcookie' | ||
| cookiesEnabled = ($.inArray('testcookie', document.cookie) !== -1) | ||
| cookiesEnabled = document.cookie.includes('testcookie') | ||
| } | ||
|
|
||
| // return | ||
| return cookiesEnabled | ||
| } | ||
|
|
||
| /** | ||
| * Read a cookie | ||
| * | ||
| * @return mixed | ||
| */ | ||
| readCookie (name) { | ||
| // get cookies | ||
| var cookies = document.cookie.split(';') | ||
| const cookies = document.cookie.split(';') | ||
| name = name + '=' | ||
|
|
||
| for (var i = 0; i < cookies.length; i++) { | ||
| var cookie = cookies[i] | ||
| while (cookie.charAt(0) === ' ') cookie = cookie.substring(1, cookie.length) | ||
| if (cookie.indexOf(name) === 0) return cookie.substring(name.length, cookie.length) | ||
| } | ||
| cookies.forEach((cookie) => { | ||
| cookie.trim() | ||
| if (cookie.indexOf(name) === 0) { | ||
| return cookie.substring(name.length, cookie.length) | ||
| } | ||
| }) | ||
|
|
||
| // fallback | ||
| return null | ||
| } | ||
|
|
||
| setCookie (name, value, days) { | ||
| if (typeof days === 'undefined') days = 7 | ||
|
|
||
| var expireDate = new Date() | ||
| setCookie (name, value, days = 7) { | ||
| const expireDate = new Date() | ||
| expireDate.setDate(expireDate.getDate() + days) | ||
| document.cookie = name + '=' + escape(value) + ';expires=' + expireDate.toUTCString() + ';path=/' | ||
| document.cookie = name + '=' + value + ';expires=' + expireDate.toUTCString() + ';path=/' | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,25 +1,8 @@ | ||
| import {DatePicker} from './DatePicker'; | ||
| import flatpickr from "flatpickr" | ||
| import { DatePicker } from './DatePicker' | ||
|
|
||
| export class DateTimePicker extends DatePicker { | ||
| constructor (element) { | ||
| super(element) | ||
| } | ||
|
|
||
| init () { | ||
| flatpickr(this._element, { | ||
| enableTime: true, | ||
| locale: { | ||
| firstDayOfWeek: 1, | ||
| weekdays: { | ||
| shorthand: this.dayNamesShort, | ||
| longhand: this.dayNames | ||
| }, | ||
| months: { | ||
| shorthand: this.monthNamesShort, | ||
| longhand: this.monthNames | ||
| } | ||
| } | ||
| }) | ||
| this.element._flatpickr.config.enableTime = true | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,10 @@ | ||
| import flatpickr from "flatpickr" | ||
| import flatpickr from 'flatpickr' | ||
|
|
||
| export class TimePicker { | ||
| constructor (element) { | ||
| this._element = $(element) | ||
| } | ||
|
|
||
| init () { | ||
| flatpickr(this._element, { | ||
| this.element = flatpickr(element, { | ||
| enableTime: true, | ||
| noCalendar: true, | ||
| noCalendar: true | ||
| }) | ||
| } | ||
| } |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,65 +1,13 @@ | ||
| export class Form { | ||
| constructor () { | ||
| this.initForm() | ||
| } | ||
|
|
||
| initForm () { | ||
| this.dateFields() | ||
| $('form').on('submit', $.proxy(this.hijackSubmit, this)) | ||
| } | ||
|
|
||
| parseDate (element, key) { | ||
| if (typeof element.data(key) === 'undefined' || element.data(key) === null) { | ||
| return '' | ||
| } | ||
|
|
||
| let data = element.data(key).split('-') | ||
| return new Date( | ||
| parseInt(data[0], 10), | ||
| parseInt(data[1], 10) - 1, | ||
| parseInt(data[2], 10) | ||
| ) | ||
| } | ||
|
|
||
| dateFields () { | ||
| $('[data-role=datepicker]').each((i, el) => { | ||
| let datepicker = $(el); | ||
| let format = datepicker.data('format'); | ||
|
|
||
| let startDate = false; | ||
| if (typeof datepicker.data('date-start-date') !== 'undefined' && datepicker.data('date-start-date')) { | ||
| startDate = moment(datepicker.data('date-start-date'), format); | ||
| } | ||
|
|
||
| let endDate = false; | ||
| if (typeof datepicker.data('date-end-date') !== 'undefined' && datepicker.data('date-end-date')) { | ||
| endDate = moment(datepicker.data('date-end-date'), format); | ||
| } | ||
|
|
||
| datepicker.datetimepicker({ | ||
| dayViewHeaderFormat: "MMMM YYYY", /* Leverages same syntax as 'format' */ | ||
| locale: jsData.request.locale, | ||
| format: format, | ||
| minDate: startDate, | ||
| maxDate: endDate, | ||
| keepOpen: true, | ||
| icons: { | ||
| time: "fa fa-clock-o", | ||
| date: "fa fa-calendar", | ||
| up: "fa fa-arrow-up", | ||
| down: "fa fa-arrow-down", | ||
| previous: "fa fa-arrow-left", | ||
| next: "fa fa-arrow-right" | ||
| }, | ||
| }); | ||
| }); | ||
|
|
||
| $('.js-input-focus').on('click', function() { | ||
| $($(this).data('toggle')).focus(); | ||
| }); | ||
| this.forms = document.querySelectorAll('form') | ||
| this.forms.forEach((form) => { | ||
| form.addEventListener('submit', () => { this.hijackSubmit() }) | ||
| }) | ||
| } | ||
|
|
||
| hijackSubmit () { | ||
| $(this).trigger('form_submitting') | ||
| const event = new Event('form_submitting') | ||
| document.dispatchEvent(event) | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is die remove niet meer nodig?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Geen idee. Een toast leeft sowieso maar voor 2 requests in Symfony, dus ik weet niet of we die ooit manueel moeten verwijderen. Misschien als we een SPA of volledige Vue applicatie maken wel.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, ik gebruikte wel vaak tijdelijke toasts voor confirmation messages of zo die na x seconden vanzelf verdwijnen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ik ga het zo laten en het terug toevoegen als we het nodig hebben in een project (zoals bij veel zaken in deze PR). Goed?