Skip to content

Commit

Permalink
Update eslint and fix some errors
Browse files Browse the repository at this point in the history
  • Loading branch information
wenzhixin committed Dec 29, 2024
1 parent c958767 commit 689ef25
Show file tree
Hide file tree
Showing 104 changed files with 1,810 additions and 1,279 deletions.
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

4 changes: 0 additions & 4 deletions .eslintignore

This file was deleted.

79 changes: 0 additions & 79 deletions .eslintrc.js

This file was deleted.

24 changes: 24 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Test

on:
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- uses: actions/setup-node@v3
with:
node-version: 20

- uses: actions/checkout@v3
with:
repository: 'wenzhixin/bootstrap-table-examples'
path: './tools/bootstrap-table-examples'

- name: Lint all
run: |
yarn install
yarn lint
73 changes: 40 additions & 33 deletions assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ window._config = {
themes: []
}

function initUrl() {
var href = location.hash.substring(1)
function initUrl () {
let href = location.hash.substring(1)

window._config.isViewSource = false
if (href.indexOf('view-source') > -1) {
href = href.replace('#view-source', '').replace('view-source', '')
Expand All @@ -15,7 +16,7 @@ function initUrl() {
return href || 'welcome.html'
}

function initThemes() {
function initThemes () {
$('[data-theme]').each(function () {
if ($(this).data('theme')) {
window._config.themes.push($(this).data('theme'))
Expand All @@ -24,32 +25,35 @@ function initThemes() {
if (window._config.themes.indexOf(window._config.theme) === -1) {
window._config.theme = ''
}
var $theme = $('[data-theme="' + window._config.theme + '"]').addClass('active')
const $theme = $(`[data-theme="${window._config.theme}"]`).addClass('active')

$('#theme-title').text($theme.text())

$('[data-show]').each(function () {
$(this).toggle($(this).data('show').split(',').indexOf(window._config.theme) > -1)
})
}

function loadUrl(url_) {
var template = 'template'
function loadUrl (url_) {
let template = 'template'

if (window._config.themes.indexOf(window._config.theme) > -1) {
template += '-' + window._config.theme
template += `-${window._config.theme}`
}
var url = template + '.html?v=VERSION&url=' + url_
let url = `${template}.html?v=VERSION&url=${url_}`

if (window._config.isDebug) {
url = template + '.html?t=' + (+new Date()) + '&url=' + url_
url = `${template}.html?t=${+new Date()}&url=${url_}`
}
if (window._config.isViewSource) {
url = template + '.html?v=VERSION&view-source&url=' + url_ + '#view-source'
url = `${template}.html?v=VERSION&view-source&url=${url_}#view-source`
}
$('iframe').attr('src', url)
}

function initNavigation(href) {
var $el = $('a[href="#' + href + '"]')
var $parent = $el.parent()
function initNavigation (href) {
const $el = $(`a[href="#${href}"]`)
const $parent = $el.parent()

if (!$el.length) {
return
Expand All @@ -61,20 +65,21 @@ function initNavigation(href) {
}

function autoScrollNavigation () {
var $el = $('.bd-sidenav >li.active')
const $el = $('.bd-sidenav >li.active')

$('#bd-docs-nav').scrollTop(0)
if ($el.length && $el.offset().top > $(window).height() / 2) {
$('#bd-docs-nav').scrollTop($el.offset().top - $(window).height() / 2)
}
}

function doSearch() {
var searchClient = window.algoliasearch('FXDJ517Z8G', '9b89c4a7048370f4809b0bc77b2564ac')
function doSearch () {
const searchClient = window.algoliasearch('FXDJ517Z8G', '9b89c4a7048370f4809b0bc77b2564ac')

var search = window.instantsearch({
const search = window.instantsearch({
indexName: 'bootstrap-table-example',
searchClient: searchClient,
searchFunction: function (helper) {
searchClient,
searchFunction (helper) {
if (helper.state.query) {
helper.clearTags()
helper.addTag(window._config.theme)
Expand All @@ -96,13 +101,14 @@ function doSearch() {
window.instantsearch.widgets.hits({
container: '.hits-body',
templates: {
item: function (hit) {
var search = ''
item (hit) {
let search = ''

if (window._config.theme) {
search = '?' + window._config.theme
search = `?${window._config.theme}`
}
return [
'<div class="link" data-href="' + hit.url + search + hit.anchor + '">',
`<div class="link" data-href="${hit.url}${search}${hit.anchor}">`,
'<div class="category">',
hit.anchor.split('/')[0].slice(1),
'</div>',
Expand All @@ -120,7 +126,8 @@ function doSearch() {
)

$(document).on('click', '.ais-Hits-item .link', function (e) {
var href = $(e.currentTarget).data('href')
const href = $(e.currentTarget).data('href')

if ($(e.target).is('a')) {
return
}
Expand All @@ -134,7 +141,7 @@ function doSearch() {
}

function initViewSource () {
var isSource = /view-source$/.test(location.hash)
const isSource = /view-source$/.test(location.hash)

if (isSource) {
$('.view-example').css('display', 'block')
Expand All @@ -147,15 +154,13 @@ function initViewSource () {
$('.view-example, .view-source').off('click').click(function () {
if (isSource) {
location.hash = location.hash.replace('#view-source', '')
} else {
if (location.hash.indexOf('view-source') === -1) {
location.hash += '#view-source'
}
} else if (location.hash.indexOf('view-source') === -1) {
location.hash += '#view-source'
}
})

$('.view-online').attr('href', 'https://live.bootstrap-table.com/example/' +
(location.hash.slice(1).split('#')[0] || 'welcome.html'))
$('.view-online').attr('href', `https://live.bootstrap-table.com/example/${
location.hash.slice(1).split('#')[0] || 'welcome.html'}`)
}

$(function () {
Expand All @@ -166,14 +171,16 @@ $(function () {
$('[data-toggle="tooltip"]').tooltip()

$(window).hashchange(function () {
var href = initUrl()
const href = initUrl()

loadUrl(href)
initNavigation(href)
initViewSource()
})

initThemes()
var href = initUrl()
const href = initUrl()

loadUrl(href)
initNavigation(href)
autoScrollNavigation()
Expand Down
Loading

0 comments on commit 689ef25

Please sign in to comment.