pageSelectorをVanilla化
This commit is contained in:
parent
a52211758e
commit
a4fdd220ba
@ -7,6 +7,5 @@ declare namespace JQueryTissue {
|
||||
|
||||
interface JQuery<TElement = HTMLElement> {
|
||||
linkCard: (options?: JQueryTissue.LinkCardOptions) => this;
|
||||
pageSelector: () => this;
|
||||
deleteCheckinModal: () => this;
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user