diff --git a/.babelrc b/.babelrc deleted file mode 100644 index 1320b9a3..00000000 --- a/.babelrc +++ /dev/null @@ -1,3 +0,0 @@ -{ - "presets": ["@babel/preset-env"] -} diff --git a/.eslintignore b/.eslintignore deleted file mode 100644 index 5b8c087e..00000000 --- a/.eslintignore +++ /dev/null @@ -1,4 +0,0 @@ -assets/js/ga.js -dist -node_modules -*.min.js diff --git a/.eslintrc.js b/.eslintrc.js deleted file mode 100644 index a23a0ac2..00000000 --- a/.eslintrc.js +++ /dev/null @@ -1,79 +0,0 @@ -module.exports = { - 'root': true, - 'env': { - 'browser': true, - 'node': true - }, - 'parserOptions': { - 'parser': 'babel-eslint', - 'ecmaVersion': 2017, - 'sourceType': 'module' - }, - 'extends': [ - 'eslint:recommended' - ], - 'plugins': ['html'], - 'settings': { - 'html/html-extensions': ['.html'] - }, - 'rules': { - 'indent': ['error', - 2, - { - 'SwitchCase': 1, - 'MemberExpression': 1, - 'ArrayExpression': 1, - 'FunctionDeclaration': {'parameters': 'first'}, - 'CallExpression': {'arguments': 1}, - 'ImportDeclaration': 'first', - 'ObjectExpression': 1 - } - ], - 'linebreak-style': 'off', - 'quotes': ['error', 'single'], - 'semi': ['error', 'never'], - 'semi-style': ['error', 'last'], - 'semi-spacing': ['error', {'before': false, 'after': true}], - 'camelcase': 'off', - 'default-case': 'error', - 'no-new-func': 'error', - 'no-void': 'error', - 'array-bracket-spacing': ['error', 'never'], - 'no-tabs': 'error', - 'one-var': ['error', 'never'], - 'prefer-const': 'error', - 'no-trailing-spaces': 'error', - 'operator-assignment': ['error', 'always'], - 'dot-location': ['error', 'property'], - 'no-console': ['error', { allow: ['log', 'info', 'warn', 'error'] }], - 'no-else-return': ['error', {allowElseIf: false}], - 'no-case-declarations': 'off', - 'no-unused-vars': 'off', - 'no-multi-spaces': 'error', - 'valid-jsdoc': 'warn', - 'eqeqeq': 'error', - 'guard-for-in': 'warn', - 'no-multi-str': 'error', - 'no-return-await': 'error', - 'no-return-assign': 'error', - 'no-throw-literal': 'error', - 'no-undef-init': 'error', - 'no-use-before-define': 'warn', - 'key-spacing': ['error', {'beforeColon': false, 'afterColon': true, 'mode': 'strict'}], - 'keyword-spacing': ['error', {'before': true, 'after': true}], - 'space-before-blocks': ['error', {'functions': 'always', 'keywords': 'always', 'classes': 'always'}], - 'spaced-comment': ['error', 'always'], - 'space-infix-ops': 'error', - 'arrow-spacing': ['error', { 'before': true, 'after': true }], - 'no-useless-constructor': 'warn', - 'comma-dangle': ['error', 'never'] - }, - 'globals': { - '$': true, - 'sprintf': true, - 'init': true, - 'Vue': true, - 'BootstrapTable': true, - 'marked': true - } -} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 00000000..4623fb9d --- /dev/null +++ b/.github/workflows/test.yml @@ -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 diff --git a/assets/js/index.js b/assets/js/index.js index 364aceda..e595f7db 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -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', '') @@ -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')) @@ -24,7 +25,8 @@ 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 () { @@ -32,24 +34,26 @@ function initThemes() { }) } -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 @@ -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) @@ -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 [ - '