diff --git a/resources/assets/js/@types/jquery-tissue.d.ts b/resources/assets/js/@types/jquery-tissue.d.ts index 3938ccb..5d49f3c 100644 --- a/resources/assets/js/@types/jquery-tissue.d.ts +++ b/resources/assets/js/@types/jquery-tissue.d.ts @@ -7,6 +7,5 @@ declare namespace JQueryTissue { interface JQuery { linkCard: (options?: JQueryTissue.LinkCardOptions) => this; - pageSelector: () => this; deleteCheckinModal: () => this; } diff --git a/resources/assets/js/app.ts b/resources/assets/js/app.ts index 1196678..6975556 100644 --- a/resources/assets/js/app.ts +++ b/resources/assets/js/app.ts @@ -1,5 +1,6 @@ import * as Cookies from 'js-cookie'; import { fetchPostJson, fetchDeleteJson, ResponseError } from './fetch'; +import { pageSelector } from './tissue'; require('./bootstrap'); @@ -20,7 +21,7 @@ $(() => { } $('[data-toggle="tooltip"]').tooltip(); $('.alert').alert(); - $('.tis-page-selector').pageSelector(); + document.querySelectorAll('.tis-page-selector').forEach(pageSelector); $('.link-card').linkCard(); const $deleteCheckinModal = $('#deleteCheckinModal').deleteCheckinModal(); diff --git a/resources/assets/js/tissue.ts b/resources/assets/js/tissue.ts index e059c75..6e12259 100644 --- a/resources/assets/js/tissue.ts +++ b/resources/assets/js/tissue.ts @@ -1,5 +1,12 @@ import { fetchGet } from './fetch'; +export function pageSelector(el: Element) { + if (!(el instanceof HTMLSelectElement)) return; + el.addEventListener('change', function () { + location.href = this.options[this.selectedIndex].dataset.href as string; + }); +} + (function ($) { $.fn.linkCard = function (options) { const settings = $.extend( @@ -52,12 +59,6 @@ import { fetchGet } from './fetch'; }); }; - $.fn.pageSelector = function () { - return this.on('change', function () { - location.href = $(this).find(':selected').data('href'); - }); - }; - $.fn.deleteCheckinModal = function () { return this.each(function () { $(this)