From 6d8f2fa790db60f21b0cd7ee2fd0b4be98006aa1 Mon Sep 17 00:00:00 2001 From: "Rico Sta. Cruz" Date: Mon, 2 Oct 2017 04:45:09 +0800 Subject: [PATCH] Remove more jQuery --- _js/behaviors/h3-section-list.js | 1 - _js/behaviors/main-body.js | 1 - _js/behaviors/search-input.js | 12 +++++------- _js/behaviors/searchable-item.js | 7 ++----- 4 files changed, 7 insertions(+), 14 deletions(-) diff --git a/_js/behaviors/h3-section-list.js b/_js/behaviors/h3-section-list.js index 49eb24831..f1606fa2b 100644 --- a/_js/behaviors/h3-section-list.js +++ b/_js/behaviors/h3-section-list.js @@ -1,6 +1,5 @@ /* eslint-disable no-new */ -import $ from 'jquery' import Isotope from 'isotope-layout/dist/isotope.pkgd.js' import onmount from 'onmount' diff --git a/_js/behaviors/main-body.js b/_js/behaviors/main-body.js index 5dc63ebb4..66553153c 100644 --- a/_js/behaviors/main-body.js +++ b/_js/behaviors/main-body.js @@ -1,4 +1,3 @@ -import onmount from 'onmount' import wrapify from '../wrapify' import ready from 'dom101/ready' diff --git a/_js/behaviors/search-input.js b/_js/behaviors/search-input.js index b42698315..0162a2903 100644 --- a/_js/behaviors/search-input.js +++ b/_js/behaviors/search-input.js @@ -1,13 +1,11 @@ -import $ from 'jquery' import onmount from 'onmount' import * as Search from '../helpers/search' import qs from '../helpers/qs' +import on from 'dom101/on' onmount('[data-js-search-input]', function () { - const $this = $(this) - - $this.on('input', () => { - const val = $this.val() + on(this, 'input', () => { + const val = this.value if (val === '') { Search.showAll() @@ -18,7 +16,7 @@ onmount('[data-js-search-input]', function () { const query = (qs(window.location.search) || {}).q if (query && query.length) { - $this.val(query) - Search.show(query) + this.value = query + setTimeout(() => { Search.show(query) }) } }) diff --git a/_js/behaviors/searchable-item.js b/_js/behaviors/searchable-item.js index 74b747b8f..0f45f10d6 100644 --- a/_js/behaviors/searchable-item.js +++ b/_js/behaviors/searchable-item.js @@ -1,5 +1,3 @@ - -import $ from 'jquery' import onmount from 'onmount' import permutate from '../helpers/permutate' @@ -8,9 +6,8 @@ import permutate from '../helpers/permutate' */ onmount('[data-js-searchable-item]', function () { - const $this = $(this) - const data = $this.data('js-searchable-item') + const data = JSON.parse(this.getAttribute('data-js-searchable-item') || '{}') const words = permutate(data) - $this.attr('data-search-index', words.join(' ')) + this.setAttribute('data-search-index', words.join(' ')) })