From 5ba59f1454eaf61032284f105b8094b84cb73d2c Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 30 May 2020 16:18:56 +0300 Subject: [PATCH 1/3] Add ESLint support. Used the Bootstrap master branch config and adapted it. Also, remove the `babel-eslint` package since we don't use it. --- .eslintignore | 7 +- .eslintrc | 300 ------------------------- .eslintrc.json | 63 ++++++ .gitignore | 1 + build/config/.eslintrc.json | 14 ++ build/js/.jscsrc | 44 ---- build/npm/.eslintrc.json | 14 ++ dist/js/.eslintrc.json | 46 ++++ package-lock.json | 434 ++++++++++++++++++++++++++++++++++-- package.json | 9 +- 10 files changed, 567 insertions(+), 365 deletions(-) delete mode 100644 .eslintrc create mode 100644 .eslintrc.json create mode 100644 build/config/.eslintrc.json delete mode 100644 build/js/.jscsrc create mode 100644 build/npm/.eslintrc.json create mode 100644 dist/js/.eslintrc.json diff --git a/.eslintignore b/.eslintignore index 4478329ba..d820edc8d 100644 --- a/.eslintignore +++ b/.eslintignore @@ -1,5 +1,4 @@ **/*.min.js -**/plugins/* -**/dist/* -**/build/npm -ad.js +**/plugins/ +/dist/js/adminlte.js +/docs/ diff --git a/.eslintrc b/.eslintrc deleted file mode 100644 index 22bd7583c..000000000 --- a/.eslintrc +++ /dev/null @@ -1,300 +0,0 @@ -{ - "root": true, - "parser": "babel-eslint", - "env": { - "browser": true, - "es6": true, - "amd": true - }, - "extends": "eslint:recommended", - "plugins": [ - "compat" - ], - "globals": { - "jQuery": true - }, - "rules": { - // Possible Errors - "no-await-in-loop": "error", - "no-extra-parens": "error", - "no-prototype-builtins": "error", - "no-template-curly-in-string": "error", - "compat/compat": "error", - "valid-jsdoc": "error", - // Best Practices - "accessor-pairs": "error", - "array-callback-return": "error", - "block-scoped-var": "error", - "class-methods-use-this": "off", - "complexity": "error", - "consistent-return": "error", - "curly": "error", - "default-case": "error", - "dot-location": [ - "error", - "property" - ], - "dot-notation": "error", - "eqeqeq": "error", - "guard-for-in": "error", - "no-alert": "error", - "no-caller": "error", - "no-div-regex": "error", - "no-else-return": "error", - "no-empty-function": "error", - "no-eq-null": "error", - "no-eval": "error", - "no-extend-native": "error", - "no-extra-bind": "error", - "no-extra-label": "error", - "no-floating-decimal": "error", - "no-implicit-coercion": "error", - "no-implicit-globals": "error", - "no-implied-eval": "error", - "no-invalid-this": "off", - "no-iterator": "error", - "no-labels": "error", - "no-lone-blocks": "error", - "no-loop-func": "error", - "no-magic-numbers": [ - "error", - { - "ignore": [ - -1, - 0, - 1 - ], - "ignoreArrayIndexes": true - } - ], - "no-multi-spaces": [ - "error", - { - "ignoreEOLComments": true, - "exceptions": { - "AssignmentExpression": true, - "ArrowFunctionExpression": true, - "CallExpression": true, - "VariableDeclarator": true - } - } - ], - "no-multi-str": "error", - "no-new": "error", - "no-new-func": "error", - "no-new-wrappers": "error", - "no-octal-escape": "error", - "no-param-reassign": "off", - "no-proto": "error", - "no-restricted-properties": "error", - "no-return-assign": "error", - "no-return-await": "error", - "no-script-url": "error", - "no-self-compare": "error", - "no-sequences": "error", - "no-throw-literal": "error", - "no-unmodified-loop-condition": "error", - "no-unused-expressions": "error", - "no-useless-call": "error", - "no-useless-concat": "error", - "no-useless-return": "error", - "no-void": "error", - "no-warning-comments": "off", - "no-with": "error", - "prefer-promise-reject-errors": "error", - "radix": "error", - "require-await": "error", - "vars-on-top": "error", - "wrap-iife": "error", - "yoda": "error", - // Strict Mode - "strict": "error", - // Variables - "init-declarations": "off", - "no-catch-shadow": "error", - "no-label-var": "error", - "no-restricted-globals": "error", - "no-shadow": "off", - "no-shadow-restricted-names": "error", - "no-undef-init": "error", - "no-undefined": "error", - "no-use-before-define": "off", - // Node.js and CommonJS - "callback-return": "off", - "global-require": "error", - "handle-callback-err": "error", - "no-mixed-requires": "error", - "no-new-require": "error", - "no-path-concat": "error", - "no-process-env": "error", - "no-process-exit": "error", - "no-restricted-modules": "error", - "no-sync": "error", - // Stylistic Issues - "array-bracket-spacing": "error", - "block-spacing": "error", - "brace-style": "error", - "camelcase": "error", - "capitalized-comments": "off", - "comma-dangle": "error", - "comma-spacing": "error", - "comma-style": "error", - "computed-property-spacing": "error", - "consistent-this": "error", - "eol-last": "error", - "func-call-spacing": "error", - "func-name-matching": "error", - "func-names": "off", - "func-style": [ - "error", - "declaration" - ], - "id-blacklist": "error", - "id-length": "off", - "id-match": "error", - "indent": [ - "error", - 2, - { - "SwitchCase": 1 - } - ], - "jsx-quotes": "error", - "key-spacing": "off", - "keyword-spacing": "error", - "linebreak-style": [ - "error", - "unix" - ], - "line-comment-position": "off", - "lines-around-comment": "off", - "lines-around-directive": "error", - "max-depth": [ - "error", - 10 - ], - "max-len": "off", - "max-lines": "off", - "max-nested-callbacks": "error", - "max-params": "off", - "max-statements": "off", - "max-statements-per-line": "error", - "multiline-ternary": "off", - "new-cap": [ - "error", - { - "capIsNewExceptionPattern": "$.*" - } - ], - "newline-after-var": "off", - "newline-per-chained-call": [ - "error", - { - "ignoreChainWithDepth": 5 - } - ], - "new-parens": "error", - "no-array-constructor": "error", - "no-bitwise": "error", - "no-continue": "off", - "no-inline-comments": "off", - "no-lonely-if": "error", - "no-mixed-operators": "off", - "no-multi-assign": "error", - "no-multiple-empty-lines": "error", - "nonblock-statement-body-position": "error", - "no-negated-condition": "off", - "no-nested-ternary": "error", - "no-new-object": "error", - "no-plusplus": "off", - "no-restricted-syntax": "error", - "no-tabs": "error", - "no-ternary": "off", - "no-trailing-spaces": "error", - "no-underscore-dangle": "off", - "no-unneeded-ternary": "error", - "no-whitespace-before-property": "error", - "object-curly-newline": [ - "error", - { - "minProperties": 1 - } - ], - "object-curly-spacing": [ - "error", - "always" - ], - "object-property-newline": "error", - "one-var": [ - "error", - "never" - ], - "one-var-declaration-per-line": "error", - "operator-assignment": "error", - "operator-linebreak": "error", - "padded-blocks": [ - "error", - "never" - ], - "padding-line-between-statements": "off", - "quote-props": [ - "error", - "as-needed" - ], - "quotes": [ - "error", - "single" - ], - "require-jsdoc": "off", - "semi": [ - "error", - "never" - ], - "semi-spacing": "error", - "sort-keys": "off", - "sort-vars": "error", - "space-before-blocks": "error", - "space-before-function-paren": [ - "error", - { - "anonymous": "always", - "named": "never" - } - ], - "space-in-parens": "error", - "space-infix-ops": "error", - "space-unary-ops": "error", - "spaced-comment": "error", - "template-tag-spacing": "error", - "unicode-bom": "error", - "wrap-regex": "off", - // ECMAScript 6 - "arrow-body-style": [ - "error", - "as-needed" - ], - "arrow-parens": "error", - "arrow-spacing": "error", - "generator-star-spacing": "error", - "no-confusing-arrow": "error", - "no-duplicate-imports": "error", - "no-restricted-imports": "error", - "no-useless-computed-key": "error", - "no-useless-constructor": "error", - "no-useless-rename": "error", - "no-var": "error", - "object-shorthand": "error", - "prefer-arrow-callback": "error", - "prefer-const": "error", - "prefer-destructuring": "off", - "prefer-numeric-literals": "error", - "prefer-rest-params": "error", - "prefer-spread": "error", - "prefer-template": "error", - "rest-spread-spacing": "error", - "sort-imports": "error", - "symbol-description": "error", - "template-curly-spacing": "error", - "yield-star-spacing": "error" - } -} diff --git a/.eslintrc.json b/.eslintrc.json new file mode 100644 index 000000000..ca36ce204 --- /dev/null +++ b/.eslintrc.json @@ -0,0 +1,63 @@ +{ + "root": true, + "extends": [ + "plugin:compat/recommended", + "plugin:import/errors", + "plugin:import/warnings", + "plugin:unicorn/recommended", + "xo/esnext", + "xo/browser" + ], + "env": { + "jquery": true + }, + "rules": { + "capitalized-comments": "off", + "eqeqeq": "off", + "indent": [ + "error", + 2, + { + "MemberExpression": "off", + "SwitchCase": 1 + } + ], + "multiline-ternary": [ + "error", + "always-multiline" + ], + "new-cap": [ + "error", + { + "properties": false + } + ], + "no-eq-null": "off", + "no-negated-condition": "off", + "no-console": "error", + "object-curly-spacing": [ + "error", + "always" + ], + "prefer-named-capture-group": "off", + "semi": [ + "error", + "never" + ], + "unicorn/filename-case": "off", + "unicorn/import-index": "off", + "unicorn/no-fn-reference-in-iterator": "off", + "unicorn/no-for-loop": "off", + "unicorn/no-null": "off", + "unicorn/no-unused-properties": "error", + "unicorn/prefer-dataset": "off", + "unicorn/prefer-includes": "off", + "unicorn/prefer-node-append": "off", + "unicorn/prefer-node-remove": "off", + "unicorn/prefer-number-properties": "off", + "unicorn/prefer-optional-catch-binding": "off", + "unicorn/prefer-query-selector": "off", + "unicorn/prefer-set-has": "off", + "unicorn/prevent-abbreviations": "off" + } +} diff --git a/.gitignore b/.gitignore index f1192895c..0a13f8012 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ TODO test.html ad.js /.cache/ +/docs/assets/js/.eslintrc.json diff --git a/build/config/.eslintrc.json b/build/config/.eslintrc.json new file mode 100644 index 000000000..e7ff58ade --- /dev/null +++ b/build/config/.eslintrc.json @@ -0,0 +1,14 @@ +{ + "env": { + "browser": false, + "node": true + }, + "parserOptions": { + "sourceType": "script" + }, + "extends": "../../.eslintrc.json", + "rules": { + "no-console": "off", + "strict": "error" + } +} diff --git a/build/js/.jscsrc b/build/js/.jscsrc deleted file mode 100644 index a2ec95bb7..000000000 --- a/build/js/.jscsrc +++ /dev/null @@ -1,44 +0,0 @@ -{ - "esnext": true, - "verbose": true, - "disallowEmptyBlocks": true, - "disallowKeywords": ["with"], - "disallowMixedSpacesAndTabs": true, - "disallowMultipleLineStrings": true, - "disallowMultipleVarDecl": true, - "disallowQuotedKeysInObjects": "allButReserved", - "disallowSpaceAfterPrefixUnaryOperators": ["++", "--", "+", "-", "~", "!"], - "disallowSpaceBeforeBinaryOperators": [","], - "disallowSpaceBeforePostfixUnaryOperators": ["++", "--"], - "disallowSpacesInFunctionDeclaration": { "beforeOpeningRoundBrace": true }, - "disallowSpacesInNamedFunctionExpression": { "beforeOpeningRoundBrace": true }, - "disallowSpacesInsideArrayBrackets": true, - "disallowSpacesInsideParentheses": true, - "disallowTrailingComma": true, - "disallowTrailingWhitespace": true, - "requireCamelCaseOrUpperCaseIdentifiers": true, - "requireCapitalizedConstructors": true, - "requireCommaBeforeLineBreak": true, - "requireDollarBeforejQueryAssignment": true, - "requireDotNotation": true, - "requireLineFeedAtFileEnd": true, - "requirePaddingNewLinesAfterUseStrict": true, - "requirePaddingNewLinesBeforeExport": true, - "requireSpaceAfterBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", "<", ">=", "<="], - "requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], - "requireSpaceAfterLineComment": true, - "requireSpaceBeforeBinaryOperators": ["+", "-", "/", "*", "=", "==", "===", "!=", "!==", ">", "<", ">=", "<="], - "requireSpaceBetweenArguments": true, - "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningCurlyBrace": true, "beforeOpeningRoundBrace": true, "allExcept": ["shorthand"] }, - "requireSpacesInConditionalExpression": true, - "requireSpacesInForStatement": true, - "requireSpacesInFunctionDeclaration": { "beforeOpeningCurlyBrace": true }, - "requireSpacesInFunctionExpression": { "beforeOpeningCurlyBrace": true }, - "requireSpacesInNamedFunctionExpression": { "beforeOpeningCurlyBrace": true }, - "requireSpacesInsideObjectBrackets": "allButNested", - "validateAlignedFunctionParameters": true, - "validateIndentation": 2, - "validateLineBreaks": "LF", - "validateNewlineAfterArrayElements": true, - "validateQuoteMarks": "'" -} diff --git a/build/npm/.eslintrc.json b/build/npm/.eslintrc.json new file mode 100644 index 000000000..e7ff58ade --- /dev/null +++ b/build/npm/.eslintrc.json @@ -0,0 +1,14 @@ +{ + "env": { + "browser": false, + "node": true + }, + "parserOptions": { + "sourceType": "script" + }, + "extends": "../../.eslintrc.json", + "rules": { + "no-console": "off", + "strict": "error" + } +} diff --git a/dist/js/.eslintrc.json b/dist/js/.eslintrc.json new file mode 100644 index 000000000..a042482d1 --- /dev/null +++ b/dist/js/.eslintrc.json @@ -0,0 +1,46 @@ +{ + "root": true, + "parserOptions": { + "ecmaVersion": 5, + "sourceType": "script" + }, + "env": { + "jquery": true + }, + "extends": [ + "plugin:unicorn/recommended", + "xo", + "xo/browser" + ], + "rules": { + "capitalized-comments": "off", + "indent": [ + "error", + 2, + { + "MemberExpression": "off", + "SwitchCase": 1 + } + ], + "multiline-ternary": [ + "error", + "always-multiline" + ], + "object-curly-spacing": [ + "error", + "always" + ], + "semi": [ + "error", + "never" + ], + "strict": "error", + "unicorn/no-for-loop": "off", + "unicorn/no-null": "off", + "unicorn/prefer-dataset": "off", + "unicorn/prefer-includes": "off", + "unicorn/prefer-node-append": "off", + "unicorn/prefer-query-selector": "off", + "unicorn/prevent-abbreviations": "off" + } +} diff --git a/package-lock.json b/package-lock.json index 59207b615..c628b5af4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1374,6 +1374,17 @@ "resolved": "https://registry.npmjs.org/array-from/-/array-from-2.1.1.tgz", "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=" }, + "array-includes": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.1.tgz", + "integrity": "sha512-c2VXaCHl7zPsvpkFsw4nxvFie4fh1ur9bpcgsVkIjqn0H/Xwdg+7fv3n2r/isyS8EBj5b06M9kHyZuIr4El6WQ==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0", + "is-string": "^1.0.5" + } + }, "array-union": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/array-union/-/array-union-2.1.0.tgz", @@ -1386,6 +1397,16 @@ "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", "dev": true }, + "array.prototype.flat": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.3.tgz", + "integrity": "sha512-gBlRZV0VSmfPIeWfuuy56XZMvbVfbEUnOXUvt3F/eUUUSyzlgLxhEX4YAEpxNAogRGehPSnfXyPtYyKAhkzQhQ==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" + } + }, "arraybuffer.slice": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", @@ -1575,20 +1596,6 @@ } } }, - "babel-eslint": { - "version": "10.1.0", - "resolved": "https://registry.npmjs.org/babel-eslint/-/babel-eslint-10.1.0.tgz", - "integrity": "sha512-ifWaTHQ0ce+448CYop8AdrQiBsGrnC+bMgfyKFdi6EsPLTAWG+QfyDeM6OH+FmWnKvEq5NnBMLvlBUPKQZoDSg==", - "dev": true, - "requires": { - "@babel/code-frame": "^7.0.0", - "@babel/parser": "^7.7.0", - "@babel/traverse": "^7.7.0", - "@babel/types": "^7.7.0", - "eslint-visitor-keys": "^1.0.0", - "resolve": "^1.12.0" - } - }, "babel-plugin-dynamic-import-node": { "version": "2.3.3", "resolved": "https://registry.npmjs.org/babel-plugin-dynamic-import-node/-/babel-plugin-dynamic-import-node-2.3.3.tgz", @@ -2416,6 +2423,15 @@ "glob": "7.x" } }, + "clean-regexp": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/clean-regexp/-/clean-regexp-1.0.0.tgz", + "integrity": "sha1-jffHquUf02h06PjQW5GAvBGj/tc=", + "dev": true, + "requires": { + "escape-string-regexp": "^1.0.5" + } + }, "cli-boxes": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/cli-boxes/-/cli-boxes-2.2.0.tgz", @@ -2577,6 +2593,12 @@ "xdg-basedir": "^4.0.0" } }, + "confusing-browser-globals": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.9.tgz", + "integrity": "sha512-KbS1Y0jMtyPgIxjO7ZzMAuUpAKMt1SzCL9fsrKsX6b0zJPTaT0SiSPmewwVZg9UAO83HVIlEhZF84LIjZ0lmAw==", + "dev": true + }, "connect": { "version": "3.6.6", "resolved": "https://registry.npmjs.org/connect/-/connect-3.6.6.tgz", @@ -2628,6 +2650,12 @@ "upper-case": "^1.1.1" } }, + "contains-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", + "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", + "dev": true + }, "convert-source-map": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", @@ -3796,6 +3824,79 @@ } } }, + "eslint-ast-utils": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-ast-utils/-/eslint-ast-utils-1.1.0.tgz", + "integrity": "sha512-otzzTim2/1+lVrlH19EfQQJEhVJSu0zOb9ygb3iapN6UlyaDtyRq4b5U1FuW0v1lRa9Fp/GJyHkSwm6NqABgCA==", + "dev": true, + "requires": { + "lodash.get": "^4.4.2", + "lodash.zip": "^4.2.0" + } + }, + "eslint-config-xo": { + "version": "0.29.1", + "resolved": "https://registry.npmjs.org/eslint-config-xo/-/eslint-config-xo-0.29.1.tgz", + "integrity": "sha512-RDjeKh8CV0/EH4utW/6uOkwJJOOU+rX3uE5eUBOamcLNe4lNjyo8kSt3B6DzAm1L/1tWGikI7LFNVY9gG7PDQw==", + "dev": true, + "requires": { + "confusing-browser-globals": "1.0.9" + } + }, + "eslint-import-resolver-node": { + "version": "0.3.3", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.3.tgz", + "integrity": "sha512-b8crLDo0M5RSe5YG8Pu2DYBj71tSB6OvXkfzwbJU2w7y8P4/yo0MyF8jU26IEuEuHF2K5/gcAJE3LhQGqBBbVg==", + "dev": true, + "requires": { + "debug": "^2.6.9", + "resolve": "^1.13.1" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, + "eslint-module-utils": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz", + "integrity": "sha512-6j9xxegbqe8/kZY8cYpcp0xhbK0EgJlg3g9mib3/miLaExuuwc3n5UEfSnU6hWMbT0FAYVvDbL9RrRgpUeQIvA==", + "dev": true, + "requires": { + "debug": "^2.6.9", + "pkg-dir": "^2.0.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + } + } + }, "eslint-plugin-compat": { "version": "3.7.0", "resolved": "https://registry.npmjs.org/eslint-plugin-compat/-/eslint-plugin-compat-3.7.0.tgz", @@ -3825,6 +3926,231 @@ } } }, + "eslint-plugin-import": { + "version": "2.20.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.20.2.tgz", + "integrity": "sha512-FObidqpXrR8OnCh4iNsxy+WACztJLXAHBO5hK79T1Hc77PgQZkyDGA5Ag9xAvRpglvLNxhH/zSmZ70/pZ31dHg==", + "dev": true, + "requires": { + "array-includes": "^3.0.3", + "array.prototype.flat": "^1.2.1", + "contains-path": "^0.1.0", + "debug": "^2.6.9", + "doctrine": "1.5.0", + "eslint-import-resolver-node": "^0.3.2", + "eslint-module-utils": "^2.4.1", + "has": "^1.0.3", + "minimatch": "^3.0.4", + "object.values": "^1.1.0", + "read-pkg-up": "^2.0.0", + "resolve": "^1.12.0" + }, + "dependencies": { + "debug": { + "version": "2.6.9", + "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", + "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", + "dev": true, + "requires": { + "ms": "2.0.0" + } + }, + "doctrine": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", + "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "isarray": "^1.0.0" + } + }, + "load-json-file": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "strip-bom": "^3.0.0" + } + }, + "ms": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", + "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=", + "dev": true + }, + "path-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", + "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "dev": true, + "requires": { + "pify": "^2.0.0" + } + }, + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "dev": true, + "requires": { + "load-json-file": "^2.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^2.0.0" + } + }, + "read-pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", + "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "dev": true, + "requires": { + "find-up": "^2.0.0", + "read-pkg": "^2.0.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + } + } + }, + "eslint-plugin-unicorn": { + "version": "20.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-unicorn/-/eslint-plugin-unicorn-20.1.0.tgz", + "integrity": "sha512-XQxLBJT/gnwyRR6cfYsIK1AdekQchAt5tmcsnldevGjgR2xoZsRUa5/i6e0seNHy2RoT57CkTnbVHwHF8No8LA==", + "dev": true, + "requires": { + "ci-info": "^2.0.0", + "clean-regexp": "^1.0.0", + "eslint-ast-utils": "^1.1.0", + "eslint-template-visitor": "^2.0.0", + "eslint-utils": "^2.0.0", + "import-modules": "^2.0.0", + "lodash": "^4.17.15", + "pluralize": "^8.0.0", + "read-pkg-up": "^7.0.1", + "regexp-tree": "^0.1.21", + "reserved-words": "^0.1.2", + "safe-regex": "^2.1.1", + "semver": "^7.3.2" + }, + "dependencies": { + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "p-try": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", + "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", + "dev": true + }, + "parse-json": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-5.0.0.tgz", + "integrity": "sha512-OOY5b7PAEFV0E2Fir1KOkxchnZNCdowAJgQ5NuxjpBKTRP3pQhwkrkxqQjeoKJ+fO7bCpmIZaogI4eZGDMEGOw==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.0.0", + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1", + "lines-and-columns": "^1.1.6" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "read-pkg": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-5.2.0.tgz", + "integrity": "sha512-Ug69mNOpfvKDAc2Q8DRpMjjzdtrnv9HcSMX+4VsZxD1aZ6ZzrIE7rlzXBtWTyhULSMKg076AW6WR5iZpD0JiOg==", + "dev": true, + "requires": { + "@types/normalize-package-data": "^2.4.0", + "normalize-package-data": "^2.5.0", + "parse-json": "^5.0.0", + "type-fest": "^0.6.0" + }, + "dependencies": { + "type-fest": { + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.6.0.tgz", + "integrity": "sha512-q+MB8nYR1KDLrgr4G5yemftpMC7/QLqVndBmEEdqzmNj5dcFOO4Oo8qlwZE3ULT3+Zim1F8Kq4cBnikNhlCMlg==", + "dev": true + } + } + }, + "read-pkg-up": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-7.0.1.tgz", + "integrity": "sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==", + "dev": true, + "requires": { + "find-up": "^4.1.0", + "read-pkg": "^5.2.0", + "type-fest": "^0.8.1" + } + }, + "safe-regex": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-2.1.1.tgz", + "integrity": "sha512-rx+x8AMzKb5Q5lQ95Zoi6ZbJqwCLkqi3XuJXp5P3rT8OEc6sZCJG5AE5dU3lsgRr/F4Bs31jSlVN+j5KrsGu9A==", + "dev": true, + "requires": { + "regexp-tree": "~0.1.1" + } + }, + "semver": { + "version": "7.3.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.3.2.tgz", + "integrity": "sha512-OrOb32TeeambH6UrhtShmF7CRDqhL6/5XpPNp2DuRH6+9QLw/orhp72j87v8Qa1ScDkvrrBNpZcDejAirJmfXQ==", + "dev": true + } + } + }, "eslint-scope": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.0.0.tgz", @@ -3835,6 +4161,17 @@ "estraverse": "^4.1.1" } }, + "eslint-template-visitor": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/eslint-template-visitor/-/eslint-template-visitor-2.0.0.tgz", + "integrity": "sha512-WijrLXWk/TiiG9FBTeEeb2pj/nD8H4eKIYx1DhTv/c7QoFmelE5P+3gzKUcXWZz88AI2+Wjse9DTV8lXrhcUsw==", + "dev": true, + "requires": { + "eslint-visitor-keys": "^1.1.0", + "espree": "^7.0.0", + "multimap": "^1.1.0" + } + }, "eslint-utils": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/eslint-utils/-/eslint-utils-2.0.0.tgz", @@ -5075,6 +5412,12 @@ "integrity": "sha1-BWmOPUXIjo1+nZLLBYTnfwlvPkM=", "dev": true }, + "import-modules": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/import-modules/-/import-modules-2.0.0.tgz", + "integrity": "sha512-iczM/v9drffdNnABOKwj0f9G3cFDon99VcG1mxeBsdqnbd+vnQ5c2uAiCHNQITqFTOPaEvwg3VjoWCur0uHLEw==", + "dev": true + }, "imurmurhash": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/imurmurhash/-/imurmurhash-0.1.4.tgz", @@ -5537,6 +5880,12 @@ "integrity": "sha512-OZ4IlER3zmRIoB9AqNhEggVxqIH4ofDns5nRrPS6yQxXE1TPCUpFznBfRQmQa8uC+pXqjMnukiJBxCisIxiLGA==", "dev": true }, + "is-string": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", + "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==", + "dev": true + }, "is-symbol": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.3.tgz", @@ -5935,6 +6284,12 @@ "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "dev": true }, + "lodash.get": { + "version": "4.4.2", + "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", + "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=", + "dev": true + }, "lodash.isfinite": { "version": "3.3.2", "resolved": "https://registry.npmjs.org/lodash.isfinite/-/lodash.isfinite-3.3.2.tgz", @@ -5947,6 +6302,12 @@ "integrity": "sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=", "dev": true }, + "lodash.zip": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/lodash.zip/-/lodash.zip-4.2.0.tgz", + "integrity": "sha1-7GZi5IlkCO1KtsVCo5kLcswIACA=", + "dev": true + }, "log-symbols": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-2.2.0.tgz", @@ -6296,6 +6657,12 @@ "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", "dev": true }, + "multimap": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/multimap/-/multimap-1.1.0.tgz", + "integrity": "sha512-0ZIR9PasPxGXmRsEF8jsDzndzHDj7tIav+JUmvIFB/WHswliFnquxECT/De7GR4yg99ky/NlRKJT82G1y271bw==", + "dev": true + }, "mute-stream": { "version": "0.0.8", "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", @@ -6919,6 +7286,18 @@ "isobject": "^3.0.1" } }, + "object.values": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.1.tgz", + "integrity": "sha512-WTa54g2K8iu0kmS/us18jEmdv1a4Wi//BZ/DTVYEcH0XhLM5NYdpDHja3gt57VrZLcNAO2WGA+KpWsDBaHt6eA==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1", + "function-bind": "^1.1.1", + "has": "^1.0.3" + } + }, "on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", @@ -7262,6 +7641,15 @@ "pinkie": "^2.0.0" } }, + "pkg-dir": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", + "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", + "dev": true, + "requires": { + "find-up": "^2.1.0" + } + }, "pkg-up": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-2.0.0.tgz", @@ -7271,6 +7659,12 @@ "find-up": "^2.1.0" } }, + "pluralize": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", + "integrity": "sha512-Nc3IT5yHzflTfbjgqWcCPpo7DaKy4FnpB0l/zCAW0Tc7jxAiuqSxHasntB3D7887LSrA93kDJ9IXovxJYxyLCA==", + "dev": true + }, "png-js": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/png-js/-/png-js-1.0.0.tgz", @@ -8047,6 +8441,12 @@ "safe-regex": "^1.1.0" } }, + "regexp-tree": { + "version": "0.1.21", + "resolved": "https://registry.npmjs.org/regexp-tree/-/regexp-tree-0.1.21.tgz", + "integrity": "sha512-kUUXjX4AnqnR8KRTCrayAo9PzYMRKmVoGgaz2tBuz0MF3g1ZbGebmtW0yFHfFK9CmBjQKeYIgoL22pFLBJY7sw==", + "dev": true + }, "regexp.prototype.flags": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.3.0.tgz", @@ -8261,6 +8661,12 @@ "integrity": "sha1-kl0mAdOaxIXgkc8NpcbmlNw9yv8=", "dev": true }, + "reserved-words": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/reserved-words/-/reserved-words-0.1.2.tgz", + "integrity": "sha1-AKCUD5jNUBrqqsMWQR2a3FKzGrE=", + "dev": true + }, "resolve": { "version": "1.17.0", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", diff --git a/package.json b/package.json index 00aa2f65a..872fbcf9a 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,8 @@ "js": "npm-run-all --sequential js-compile js-minify", "js-compile": "rollup --config build/config/rollup.config.js --sourcemap", "js-minify": "terser --compress typeofs=false --mangle --comments \"/^!/\" --source-map \"content=dist/js/adminlte.js.map,includeSources,url=adminlte.min.js.map\" --output dist/js/adminlte.min.js dist/js/adminlte.js", - "lint": "npm run css-lint", + "js-lint": "eslint --cache --cache-location .cache/.eslintcache --report-unused-disable-directives .", + "lint": "npm-run-all --continue-on-error --parallel css-lint js-lint", "production": "npm-run-all --sequential compile plugins", "prepare-release": "npm-run-all --sequential production docs", "test": "npm-run-all lint production", @@ -45,7 +46,7 @@ "sync": "browser-sync start --server --files *.html pages/ dist/", "watch": "npm-run-all --parallel watch-css watch-js", "watch-css": "nodemon --watch build/scss -e scss -x \"npm-run-all css-lint css\"", - "watch-js": "nodemon --watch build/js -e js -x \"npm run js\"" + "watch-js": "nodemon --watch build/js -e js -x \"npm-run-all js-lint js\"" }, "keywords": [ "css", @@ -134,11 +135,13 @@ "@babel/preset-env": "^7.10.2", "@rollup/plugin-babel": "^5.0.2", "autoprefixer": "^9.8.0", - "babel-eslint": "^10.1.0", "browser-sync": "^2.26.7", "clean-css-cli": "^4.3.0", "eslint": "^7.1.0", + "eslint-config-xo": "^0.29.1", "eslint-plugin-compat": "^3.7.0", + "eslint-plugin-import": "^2.20.2", + "eslint-plugin-unicorn": "^20.1.0", "node-sass": "^4.14.1", "node-sass-package-importer": "^5.3.2", "nodemon": "^2.0.4", From 27ff009494f71bf4ee08df5c27a4816836775a56 Mon Sep 17 00:00:00 2001 From: XhmikosR Date: Sat, 30 May 2020 16:44:20 +0300 Subject: [PATCH 2/3] Comply to the ESLint rules. --- build/config/postcss.config.js | 2 +- build/config/rollup.config.js | 4 +- build/js/CardRefresh.js | 47 ++++--- build/js/CardWidget.js | 39 +++--- build/js/ControlSidebar.js | 126 +++++++++-------- build/js/DirectChat.js | 31 +++-- build/js/Dropdown.js | 57 ++++---- build/js/Layout.js | 99 ++++++-------- build/js/PushMenu.js | 56 ++++---- build/js/SiteSearch.js | 24 ++-- build/js/Toasts.js | 94 ++++++------- build/js/TodoList.js | 39 +++--- build/js/Treeview.js | 48 +++---- build/npm/DocsPlugins.js | 20 +-- build/npm/DocsPublish.js | 12 +- build/npm/Plugins.js | 90 ++++++------ build/npm/Publish.js | 12 +- dist/js/demo.js | 163 +++++++++++----------- dist/js/pages/dashboard.js | 243 +++++++++++++++++---------------- dist/js/pages/dashboard2.js | 141 +++++++++---------- dist/js/pages/dashboard3.js | 115 ++++++++-------- pages/UI/modals.html | 2 +- 22 files changed, 720 insertions(+), 744 deletions(-) diff --git a/build/config/postcss.config.js b/build/config/postcss.config.js index 1b960e94f..273ee9413 100644 --- a/build/config/postcss.config.js +++ b/build/config/postcss.config.js @@ -1,6 +1,6 @@ 'use strict' -module.exports = (ctx) => ({ +module.exports = () => ({ map: { inline: false, annotation: true, diff --git a/build/config/rollup.config.js b/build/config/rollup.config.js index 913926032..66d19c095 100644 --- a/build/config/rollup.config.js +++ b/build/config/rollup.config.js @@ -1,6 +1,8 @@ +'use strict' + const { babel } = require('@rollup/plugin-babel') -const pkg = require('../../package') +const pkg = require('../../package') const year = new Date().getFullYear() const banner = `/*! * AdminLTE v${pkg.version} (${pkg.homepage}) diff --git a/build/js/CardRefresh.js b/build/js/CardRefresh.js index cacc7b161..03532a975 100644 --- a/build/js/CardRefresh.js +++ b/build/js/CardRefresh.js @@ -5,30 +5,30 @@ * -------------------------------------------- */ -const CardRefresh = (($) => { +const CardRefresh = ($ => { /** * Constants * ==================================================== */ - const NAME = 'CardRefresh' - const DATA_KEY = 'lte.cardrefresh' - const EVENT_KEY = `.${DATA_KEY}` + const NAME = 'CardRefresh' + const DATA_KEY = 'lte.cardrefresh' + const EVENT_KEY = `.${DATA_KEY}` const JQUERY_NO_CONFLICT = $.fn[NAME] const Event = { LOADED: `loaded${EVENT_KEY}`, OVERLAY_ADDED: `overlay.added${EVENT_KEY}`, - OVERLAY_REMOVED: `overlay.removed${EVENT_KEY}`, + OVERLAY_REMOVED: `overlay.removed${EVENT_KEY}` } const ClassName = { - CARD: 'card', + CARD: 'card' } const Selector = { CARD: `.${ClassName.CARD}`, - DATA_REFRESH: '[data-card-widget="card-refresh"]', + DATA_REFRESH: '[data-card-widget="card-refresh"]' } const Default = { @@ -41,16 +41,16 @@ const CardRefresh = (($) => { loadOnInit: true, responseType: '', overlayTemplate: '
', - onLoadStart: function () { + onLoadStart() { }, - onLoadDone: function (response) { - return response; + onLoadDone(response) { + return response } } class CardRefresh { constructor(element, settings) { - this._element = element + this._element = element this._parent = element.parents(Selector.CARD).first() this._settings = $.extend({}, Default, settings) this._overlay = $(this._settings.overlayTemplate) @@ -60,7 +60,7 @@ const CardRefresh = (($) => { } if (this._settings.source === '') { - throw new Error('Source url was not defined. Please specify a url in your CardRefresh source option.'); + throw new Error('Source url was not defined. Please specify a url in your CardRefresh source option.') } } @@ -68,9 +68,9 @@ const CardRefresh = (($) => { this._addOverlay() this._settings.onLoadStart.call($(this)) - $.get(this._settings.source, this._settings.params, function (response) { + $.get(this._settings.source, this._settings.params, response => { if (this._settings.loadInContent) { - if (this._settings.sourceSelector != '') { + if (this._settings.sourceSelector !== '') { response = $(response).find(this._settings.sourceSelector).html() } @@ -78,8 +78,8 @@ const CardRefresh = (($) => { } this._settings.onLoadDone.call($(this), response) - this._removeOverlay(); - }.bind(this), this._settings.responseType !== '' && this._settings.responseType) + this._removeOverlay() + }, this._settings.responseType !== '' && this._settings.responseType) const loadedEvent = $.Event(Event.LOADED) $(this._element).trigger(loadedEvent) @@ -90,19 +90,18 @@ const CardRefresh = (($) => { const overlayAddedEvent = $.Event(Event.OVERLAY_ADDED) $(this._element).trigger(overlayAddedEvent) - }; + } _removeOverlay() { this._parent.find(this._overlay).remove() const overlayRemovedEvent = $.Event(Event.OVERLAY_REMOVED) $(this._element).trigger(overlayRemovedEvent) - }; - + } // Private - _init(card) { + _init() { $(this).find(this._settings.trigger).on('click', () => { this.load() }) @@ -120,7 +119,7 @@ const CardRefresh = (($) => { if (!data) { data = new CardRefresh($(this), _options) - $(this).data(DATA_KEY, typeof config === 'string' ? data: config) + $(this).data(DATA_KEY, typeof config === 'string' ? data : config) } if (typeof config === 'string' && config.match(/load/)) { @@ -144,8 +143,8 @@ const CardRefresh = (($) => { CardRefresh._jQueryInterface.call($(this), 'load') }) - $(document).ready(function () { - $(Selector.DATA_REFRESH).each(function() { + $(document).ready(() => { + $(Selector.DATA_REFRESH).each(function () { CardRefresh._jQueryInterface.call($(this)) }) }) @@ -157,7 +156,7 @@ const CardRefresh = (($) => { $.fn[NAME] = CardRefresh._jQueryInterface $.fn[NAME].Constructor = CardRefresh - $.fn[NAME].noConflict = function () { + $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT return CardRefresh._jQueryInterface } diff --git a/build/js/CardWidget.js b/build/js/CardWidget.js index 3bd0403bb..3358b89ab 100644 --- a/build/js/CardWidget.js +++ b/build/js/CardWidget.js @@ -5,15 +5,15 @@ * -------------------------------------------- */ -const CardWidget = (($) => { +const CardWidget = ($ => { /** * Constants * ==================================================== */ - const NAME = 'CardWidget' - const DATA_KEY = 'lte.cardwidget' - const EVENT_KEY = `.${DATA_KEY}` + const NAME = 'CardWidget' + const DATA_KEY = 'lte.cardwidget' + const EVENT_KEY = `.${DATA_KEY}` const JQUERY_NO_CONFLICT = $.fn[NAME] const Event = { @@ -30,7 +30,7 @@ const CardWidget = (($) => { COLLAPSING: 'collapsing-card', EXPANDING: 'expanding-card', WAS_COLLAPSED: 'was-collapsed', - MAXIMIZED: 'maximized-card', + MAXIMIZED: 'maximized-card' } const Selector = { @@ -40,8 +40,7 @@ const CardWidget = (($) => { CARD: `.${ClassName.CARD}`, CARD_HEADER: '.card-header', CARD_BODY: '.card-body', - CARD_FOOTER: '.card-footer', - COLLAPSED: `.${ClassName.COLLAPSED}`, + CARD_FOOTER: '.card-footer' } const Default = { @@ -52,12 +51,12 @@ const CardWidget = (($) => { collapseIcon: 'fa-minus', expandIcon: 'fa-plus', maximizeIcon: 'fa-expand', - minimizeIcon: 'fa-compress', + minimizeIcon: 'fa-compress' } class CardWidget { constructor(element, settings) { - this._element = element + this._element = element this._parent = element.parents(Selector.CARD).first() if (element.hasClass(ClassName.CARD)) { @@ -113,21 +112,22 @@ const CardWidget = (($) => { this.collapse() } - + maximize() { this._parent.find(this._settings.maximizeTrigger + ' .' + this._settings.maximizeIcon) .addClass(this._settings.minimizeIcon) .removeClass(this._settings.maximizeIcon) this._parent.css({ - 'height': this._parent.height(), - 'width': this._parent.width(), - 'transition': 'all .15s' - }).delay(150).queue(function(){ + height: this._parent.height(), + width: this._parent.width(), + transition: 'all .15s' + }).delay(150).queue(function () { $(this).addClass(ClassName.MAXIMIZED) $('html').addClass(ClassName.MAXIMIZED) if ($(this).hasClass(ClassName.COLLAPSED)) { $(this).addClass(ClassName.WAS_COLLAPSED) } + $(this).dequeue() }) @@ -142,16 +142,17 @@ const CardWidget = (($) => { .removeClass(this._settings.minimizeIcon) this._parent.css('cssText', 'height:' + this._parent[0].style.height + ' !important;' + 'width:' + this._parent[0].style.width + ' !important; transition: all .15s;' - ).delay(10).queue(function(){ + ).delay(10).queue(function () { $(this).removeClass(ClassName.MAXIMIZED) $('html').removeClass(ClassName.MAXIMIZED) $(this).css({ - 'height': 'inherit', - 'width': 'inherit' + height: 'inherit', + width: 'inherit' }) if ($(this).hasClass(ClassName.WAS_COLLAPSED)) { $(this).removeClass(ClassName.WAS_COLLAPSED) } + $(this).dequeue() }) @@ -195,7 +196,7 @@ const CardWidget = (($) => { if (!data) { data = new CardWidget($(this), _options) - $(this).data(DATA_KEY, typeof config === 'string' ? data: config) + $(this).data(DATA_KEY, typeof config === 'string' ? data : config) } if (typeof config === 'string' && config.match(/collapse|expand|remove|toggle|maximize|minimize|toggleMaximize/)) { @@ -242,7 +243,7 @@ const CardWidget = (($) => { $.fn[NAME] = CardWidget._jQueryInterface $.fn[NAME].Constructor = CardWidget - $.fn[NAME].noConflict = function () { + $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT return CardWidget._jQueryInterface } diff --git a/build/js/ControlSidebar.js b/build/js/ControlSidebar.js index a33088586..39a17dbf0 100644 --- a/build/js/ControlSidebar.js +++ b/build/js/ControlSidebar.js @@ -5,30 +5,28 @@ * -------------------------------------------- */ -const ControlSidebar = (($) => { +const ControlSidebar = ($ => { /** * Constants * ==================================================== */ - const NAME = 'ControlSidebar' - const DATA_KEY = 'lte.controlsidebar' - const EVENT_KEY = `.${DATA_KEY}` + const NAME = 'ControlSidebar' + const DATA_KEY = 'lte.controlsidebar' + const EVENT_KEY = `.${DATA_KEY}` const JQUERY_NO_CONFLICT = $.fn[NAME] - const DATA_API_KEY = '.data-api' const Event = { COLLAPSED: `collapsed${EVENT_KEY}`, - EXPANDED: `expanded${EVENT_KEY}`, + EXPANDED: `expanded${EVENT_KEY}` } const Selector = { CONTROL_SIDEBAR: '.control-sidebar', CONTROL_SIDEBAR_CONTENT: '.control-sidebar-content', DATA_TOGGLE: '[data-widget="control-sidebar"]', - CONTENT: '.content-wrapper', HEADER: '.main-header', - FOOTER: '.main-footer', + FOOTER: '.main-footer' } const ClassName = { @@ -45,13 +43,13 @@ const ControlSidebar = (($) => { FOOTER_SM_FIXED: 'layout-sm-footer-fixed', FOOTER_MD_FIXED: 'layout-md-footer-fixed', FOOTER_LG_FIXED: 'layout-lg-footer-fixed', - FOOTER_XL_FIXED: 'layout-xl-footer-fixed', + FOOTER_XL_FIXED: 'layout-xl-footer-fixed' } const Default = { controlsidebarSlide: true, - scrollbarTheme : 'os-theme-light', - scrollbarAutoHide: 'l', + scrollbarTheme: 'os-theme-light', + scrollbarAutoHide: 'l' } /** @@ -62,7 +60,7 @@ const ControlSidebar = (($) => { class ControlSidebar { constructor(element, config) { this._element = element - this._config = config + this._config = config this._init() } @@ -73,7 +71,7 @@ const ControlSidebar = (($) => { // Show the control sidebar if (this._config.controlsidebarSlide) { $('html').addClass(ClassName.CONTROL_SIDEBAR_ANIMATE) - $('body').removeClass(ClassName.CONTROL_SIDEBAR_SLIDE).delay(300).queue(function(){ + $('body').removeClass(ClassName.CONTROL_SIDEBAR_SLIDE).delay(300).queue(function () { $(Selector.CONTROL_SIDEBAR).hide() $('html').removeClass(ClassName.CONTROL_SIDEBAR_ANIMATE) $(this).dequeue() @@ -90,8 +88,8 @@ const ControlSidebar = (($) => { // Collapse the control sidebar if (this._config.controlsidebarSlide) { $('html').addClass(ClassName.CONTROL_SIDEBAR_ANIMATE) - $(Selector.CONTROL_SIDEBAR).show().delay(10).queue(function(){ - $('body').addClass(ClassName.CONTROL_SIDEBAR_SLIDE).delay(300).queue(function(){ + $(Selector.CONTROL_SIDEBAR).show().delay(10).queue(function () { + $('body').addClass(ClassName.CONTROL_SIDEBAR_SLIDE).delay(300).queue(function () { $('html').removeClass(ClassName.CONTROL_SIDEBAR_ANIMATE) $(this).dequeue() }) @@ -130,7 +128,7 @@ const ControlSidebar = (($) => { $(window).scroll(() => { if ($('body').hasClass(ClassName.CONTROL_SIDEBAR_OPEN) || $('body').hasClass(ClassName.CONTROL_SIDEBAR_SLIDE)) { - this._fixScrollHeight() + this._fixScrollHeight() } }) } @@ -140,65 +138,64 @@ const ControlSidebar = (($) => { scroll: $(document).height(), window: $(window).height(), header: $(Selector.HEADER).outerHeight(), - footer: $(Selector.FOOTER).outerHeight(), + footer: $(Selector.FOOTER).outerHeight() } const positions = { bottom: Math.abs((heights.window + $(window).scrollTop()) - heights.scroll), - top: $(window).scrollTop(), + top: $(window).scrollTop() } - let navbarFixed = false; - let footerFixed = false; + let navbarFixed = false + let footerFixed = false if ($('body').hasClass(ClassName.LAYOUT_FIXED)) { if ( - $('body').hasClass(ClassName.NAVBAR_FIXED) - || $('body').hasClass(ClassName.NAVBAR_SM_FIXED) - || $('body').hasClass(ClassName.NAVBAR_MD_FIXED) - || $('body').hasClass(ClassName.NAVBAR_LG_FIXED) - || $('body').hasClass(ClassName.NAVBAR_XL_FIXED) + $('body').hasClass(ClassName.NAVBAR_FIXED) || + $('body').hasClass(ClassName.NAVBAR_SM_FIXED) || + $('body').hasClass(ClassName.NAVBAR_MD_FIXED) || + $('body').hasClass(ClassName.NAVBAR_LG_FIXED) || + $('body').hasClass(ClassName.NAVBAR_XL_FIXED) ) { - if ($(Selector.HEADER).css("position") === "fixed") { - navbarFixed = true; + if ($(Selector.HEADER).css('position') === 'fixed') { + navbarFixed = true } } + if ( - $('body').hasClass(ClassName.FOOTER_FIXED) - || $('body').hasClass(ClassName.FOOTER_SM_FIXED) - || $('body').hasClass(ClassName.FOOTER_MD_FIXED) - || $('body').hasClass(ClassName.FOOTER_LG_FIXED) - || $('body').hasClass(ClassName.FOOTER_XL_FIXED) + $('body').hasClass(ClassName.FOOTER_FIXED) || + $('body').hasClass(ClassName.FOOTER_SM_FIXED) || + $('body').hasClass(ClassName.FOOTER_MD_FIXED) || + $('body').hasClass(ClassName.FOOTER_LG_FIXED) || + $('body').hasClass(ClassName.FOOTER_XL_FIXED) ) { - if ($(Selector.FOOTER).css("position") === "fixed") { - footerFixed = true; + if ($(Selector.FOOTER).css('position') === 'fixed') { + footerFixed = true } } if (positions.top === 0 && positions.bottom === 0) { - $(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer); - $(Selector.CONTROL_SIDEBAR).css('top', heights.header); + $(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer) + $(Selector.CONTROL_SIDEBAR).css('top', heights.header) $(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window - (heights.header + heights.footer)) } else if (positions.bottom <= heights.footer) { - if (footerFixed === false) { - $(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer - positions.bottom); + if (footerFixed === false) { + $(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer - positions.bottom) $(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window - (heights.footer - positions.bottom)) } else { - $(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer); + $(Selector.CONTROL_SIDEBAR).css('bottom', heights.footer) } } else if (positions.top <= heights.header) { if (navbarFixed === false) { - $(Selector.CONTROL_SIDEBAR).css('top', heights.header - positions.top); + $(Selector.CONTROL_SIDEBAR).css('top', heights.header - positions.top) $(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window - (heights.header - positions.top)) } else { - $(Selector.CONTROL_SIDEBAR).css('top', heights.header); + $(Selector.CONTROL_SIDEBAR).css('top', heights.header) } + } else if (navbarFixed === false) { + $(Selector.CONTROL_SIDEBAR).css('top', 0) + $(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window) } else { - if (navbarFixed === false) { - $(Selector.CONTROL_SIDEBAR).css('top', 0); - $(Selector.CONTROL_SIDEBAR + ', ' + Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', heights.window) - } else { - $(Selector.CONTROL_SIDEBAR).css('top', heights.header); - } + $(Selector.CONTROL_SIDEBAR).css('top', heights.header) } } } @@ -207,40 +204,39 @@ const ControlSidebar = (($) => { const heights = { window: $(window).height(), header: $(Selector.HEADER).outerHeight(), - footer: $(Selector.FOOTER).outerHeight(), + footer: $(Selector.FOOTER).outerHeight() } if ($('body').hasClass(ClassName.LAYOUT_FIXED)) { - let sidebarHeight = heights.window - heights.header; + let sidebarHeight = heights.window - heights.header if ( - $('body').hasClass(ClassName.FOOTER_FIXED) - || $('body').hasClass(ClassName.FOOTER_SM_FIXED) - || $('body').hasClass(ClassName.FOOTER_MD_FIXED) - || $('body').hasClass(ClassName.FOOTER_LG_FIXED) - || $('body').hasClass(ClassName.FOOTER_XL_FIXED) + $('body').hasClass(ClassName.FOOTER_FIXED) || + $('body').hasClass(ClassName.FOOTER_SM_FIXED) || + $('body').hasClass(ClassName.FOOTER_MD_FIXED) || + $('body').hasClass(ClassName.FOOTER_LG_FIXED) || + $('body').hasClass(ClassName.FOOTER_XL_FIXED) ) { - if ($(Selector.FOOTER).css("position") === "fixed") { - sidebarHeight = heights.window - heights.header - heights.footer; + if ($(Selector.FOOTER).css('position') === 'fixed') { + sidebarHeight = heights.window - heights.header - heights.footer } } $(Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).css('height', sidebarHeight) - + if (typeof $.fn.overlayScrollbars !== 'undefined') { $(Selector.CONTROL_SIDEBAR + ' ' + Selector.CONTROL_SIDEBAR_CONTENT).overlayScrollbars({ - className : this._config.scrollbarTheme, - sizeAutoCapable : true, - scrollbars : { - autoHide: this._config.scrollbarAutoHide, - clickScrolling : true + className: this._config.scrollbarTheme, + sizeAutoCapable: true, + scrollbars: { + autoHide: this._config.scrollbarAutoHide, + clickScrolling: true } }) } } } - // Static static _jQueryInterface(operation) { @@ -280,7 +276,7 @@ const ControlSidebar = (($) => { $.fn[NAME] = ControlSidebar._jQueryInterface $.fn[NAME].Constructor = ControlSidebar - $.fn[NAME].noConflict = function () { + $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT return ControlSidebar._jQueryInterface } @@ -289,4 +285,4 @@ const ControlSidebar = (($) => { })(jQuery) export default ControlSidebar - + diff --git a/build/js/DirectChat.js b/build/js/DirectChat.js index c211bc710..79633b0d3 100644 --- a/build/js/DirectChat.js +++ b/build/js/DirectChat.js @@ -5,30 +5,28 @@ * -------------------------------------------- */ -const DirectChat = (($) => { +const DirectChat = ($ => { /** * Constants * ==================================================== */ - const NAME = 'DirectChat' - const DATA_KEY = 'lte.directchat' - const EVENT_KEY = `.${DATA_KEY}` + const NAME = 'DirectChat' + const DATA_KEY = 'lte.directchat' const JQUERY_NO_CONFLICT = $.fn[NAME] - const DATA_API_KEY = '.data-api' const Event = { - TOGGLED: `toggled{EVENT_KEY}` + TOGGLED: 'toggled{EVENT_KEY}' } const Selector = { DATA_TOGGLE: '[data-widget="chat-pane-toggle"]', DIRECT_CHAT: '.direct-chat' - }; + } const ClassName = { DIRECT_CHAT_OPEN: 'direct-chat-contacts-open' - }; + } /** * Class Definition @@ -36,12 +34,12 @@ const DirectChat = (($) => { */ class DirectChat { - constructor(element, config) { + constructor(element) { this._element = element } toggle() { - $(this._element).parents(Selector.DIRECT_CHAT).first().toggleClass(ClassName.DIRECT_CHAT_OPEN); + $(this._element).parents(Selector.DIRECT_CHAT).first().toggleClass(ClassName.DIRECT_CHAT_OPEN) const toggledEvent = $.Event(Event.TOGGLED) $(this._element).trigger(toggledEvent) @@ -51,7 +49,7 @@ const DirectChat = (($) => { static _jQueryInterface(config) { return this.each(function () { - let data = $(this).data(DATA_KEY) + let data = $(this).data(DATA_KEY) if (!data) { data = new DirectChat($(this)) @@ -70,9 +68,12 @@ const DirectChat = (($) => { */ $(document).on('click', Selector.DATA_TOGGLE, function (event) { - if (event) event.preventDefault(); - DirectChat._jQueryInterface.call($(this), 'toggle'); - }); + if (event) { + event.preventDefault() + } + + DirectChat._jQueryInterface.call($(this), 'toggle') + }) /** * jQuery API @@ -81,7 +82,7 @@ const DirectChat = (($) => { $.fn[NAME] = DirectChat._jQueryInterface $.fn[NAME].Constructor = DirectChat - $.fn[NAME].noConflict = function () { + $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT return DirectChat._jQueryInterface } diff --git a/build/js/Dropdown.js b/build/js/Dropdown.js index a28c927e2..dd579deb9 100644 --- a/build/js/Dropdown.js +++ b/build/js/Dropdown.js @@ -5,33 +5,30 @@ * -------------------------------------------- */ -const Dropdown = (($) => { +const Dropdown = ($ => { /** * Constants * ==================================================== */ - const NAME = 'Dropdown' - const DATA_KEY = 'lte.dropdown' - const EVENT_KEY = `.${DATA_KEY}` + const NAME = 'Dropdown' + const DATA_KEY = 'lte.dropdown' const JQUERY_NO_CONFLICT = $.fn[NAME] const Selector = { NAVBAR: '.navbar', DROPDOWN_MENU: '.dropdown-menu', DROPDOWN_MENU_ACTIVE: '.dropdown-menu.show', - DROPDOWN_TOGGLE: '[data-toggle="dropdown"]', + DROPDOWN_TOGGLE: '[data-toggle="dropdown"]' } const ClassName = { - DROPDOWN_HOVER: 'dropdown-hover', DROPDOWN_RIGHT: 'dropdown-menu-right' } const Default = { } - /** * Class Definition * ==================================================== @@ -39,26 +36,26 @@ const Dropdown = (($) => { class Dropdown { constructor(element, config) { - this._config = config + this._config = config this._element = element } // Public toggleSubmenu() { - this._element.siblings().show().toggleClass("show") + this._element.siblings().show().toggleClass('show') - if (! this._element.next().hasClass('show')) { - this._element.parents('.dropdown-menu').first().find('.show').removeClass("show").hide() + if (!this._element.next().hasClass('show')) { + this._element.parents('.dropdown-menu').first().find('.show').removeClass('show').hide() } - this._element.parents('li.nav-item.dropdown.show').on('hidden.bs.dropdown', function(e) { - $('.dropdown-submenu .show').removeClass("show").hide() + this._element.parents('li.nav-item.dropdown.show').on('hidden.bs.dropdown', () => { + $('.dropdown-submenu .show').removeClass('show').hide() }) } fixPosition() { - let elm = $(Selector.DROPDOWN_MENU_ACTIVE) + const elm = $(Selector.DROPDOWN_MENU_ACTIVE) if (elm.length !== 0) { if (elm.hasClass(ClassName.DROPDOWN_RIGHT)) { @@ -69,28 +66,26 @@ const Dropdown = (($) => { elm.css('right', 'inherit') } - let offset = elm.offset() - let width = elm.width() - let windowWidth = $(window).width() - let visiblePart = windowWidth - offset.left + const offset = elm.offset() + const width = elm.width() + const windowWidth = $(window).width() + const visiblePart = windowWidth - offset.left if (offset.left < 0) { elm.css('left', 'inherit') elm.css('right', (offset.left - 5)) - } else { - if (visiblePart < width) { - elm.css('left', 'inherit') - elm.css('right', 0) - } + } else if (visiblePart < width) { + elm.css('left', 'inherit') + elm.css('right', 0) } - } + } } // Static static _jQueryInterface(config) { return this.each(function () { - let data = $(this).data(DATA_KEY) + let data = $(this).data(DATA_KEY) const _config = $.extend({}, Default, $(this).data()) if (!data) { @@ -98,7 +93,7 @@ const Dropdown = (($) => { $(this).data(DATA_KEY, data) } - if (config === 'toggleSubmenu' || config == 'fixPosition') { + if (config === 'toggleSubmenu' || config === 'fixPosition') { data[config]() } }) @@ -110,20 +105,20 @@ const Dropdown = (($) => { * ==================================================== */ - $(Selector.DROPDOWN_MENU + ' ' + Selector.DROPDOWN_TOGGLE).on("click", function(event) { + $(Selector.DROPDOWN_MENU + ' ' + Selector.DROPDOWN_TOGGLE).on('click', function (event) { event.preventDefault() event.stopPropagation() Dropdown._jQueryInterface.call($(this), 'toggleSubmenu') - }); + }) - $(Selector.NAVBAR + ' ' + Selector.DROPDOWN_TOGGLE).on("click", function(event) { + $(Selector.NAVBAR + ' ' + Selector.DROPDOWN_TOGGLE).on('click', event => { event.preventDefault() - setTimeout(function() { + setTimeout(function () { Dropdown._jQueryInterface.call($(this), 'fixPosition') }, 1) - }); + }) /** * jQuery API diff --git a/build/js/Layout.js b/build/js/Layout.js index 510d47594..83fc64a29 100644 --- a/build/js/Layout.js +++ b/build/js/Layout.js @@ -5,58 +5,41 @@ * -------------------------------------------- */ -const Layout = (($) => { +const Layout = ($ => { /** * Constants * ==================================================== */ - const NAME = 'Layout' - const DATA_KEY = 'lte.layout' - const EVENT_KEY = `.${DATA_KEY}` + const NAME = 'Layout' + const DATA_KEY = 'lte.layout' const JQUERY_NO_CONFLICT = $.fn[NAME] - const Event = { - SIDEBAR: 'sidebar' - } - const Selector = { - HEADER : '.main-header', - MAIN_SIDEBAR : '.main-sidebar', - SIDEBAR : '.main-sidebar .sidebar', - CONTENT : '.content-wrapper', - BRAND : '.brand-link', - CONTENT_HEADER : '.content-header', - WRAPPER : '.wrapper', - CONTROL_SIDEBAR: '.control-sidebar', + HEADER: '.main-header', + MAIN_SIDEBAR: '.main-sidebar', + SIDEBAR: '.main-sidebar .sidebar', + CONTENT: '.content-wrapper', CONTROL_SIDEBAR_CONTENT: '.control-sidebar-content', CONTROL_SIDEBAR_BTN: '[data-widget="control-sidebar"]', - LAYOUT_FIXED : '.layout-fixed', - FOOTER : '.main-footer', - PUSHMENU_BTN : '[data-widget="pushmenu"]', - LOGIN_BOX : '.login-box', - REGISTER_BOX : '.register-box' + FOOTER: '.main-footer', + PUSHMENU_BTN: '[data-widget="pushmenu"]', + LOGIN_BOX: '.login-box', + REGISTER_BOX: '.register-box' } const ClassName = { - HOLD : 'hold-transition', - SIDEBAR : 'main-sidebar', - CONTENT_FIXED : 'content-fixed', SIDEBAR_FOCUSED: 'sidebar-focused', - LAYOUT_FIXED : 'layout-fixed', - NAVBAR_FIXED : 'layout-navbar-fixed', - FOOTER_FIXED : 'layout-footer-fixed', - LOGIN_PAGE : 'login-page', - REGISTER_PAGE : 'register-page', + LAYOUT_FIXED: 'layout-fixed', CONTROL_SIDEBAR_SLIDE_OPEN: 'control-sidebar-slide-open', - CONTROL_SIDEBAR_OPEN: 'control-sidebar-open', + CONTROL_SIDEBAR_OPEN: 'control-sidebar-open' } const Default = { - scrollbarTheme : 'os-theme-light', + scrollbarTheme: 'os-theme-light', scrollbarAutoHide: 'l', panelAutoHeight: true, - loginRegisterAutoHeight: true, + loginRegisterAutoHeight: true } /** @@ -66,7 +49,7 @@ const Layout = (($) => { class Layout { constructor(element, config) { - this._config = config + this._config = config this._element = element this._init() @@ -75,10 +58,10 @@ const Layout = (($) => { // Public fixLayoutHeight(extra = null) { - let control_sidebar = 0 + let controlSidebar = 0 - if ($('body').hasClass(ClassName.CONTROL_SIDEBAR_SLIDE_OPEN) || $('body').hasClass(ClassName.CONTROL_SIDEBAR_OPEN) || extra == 'control_sidebar') { - control_sidebar = $(Selector.CONTROL_SIDEBAR_CONTENT).height() + if ($('body').hasClass(ClassName.CONTROL_SIDEBAR_SLIDE_OPEN) || $('body').hasClass(ClassName.CONTROL_SIDEBAR_OPEN) || extra === 'controlSidebar') { + controlSidebar = $(Selector.CONTROL_SIDEBAR_CONTENT).height() } const heights = { @@ -86,26 +69,27 @@ const Layout = (($) => { header: $(Selector.HEADER).length !== 0 ? $(Selector.HEADER).outerHeight() : 0, footer: $(Selector.FOOTER).length !== 0 ? $(Selector.FOOTER).outerHeight() : 0, sidebar: $(Selector.SIDEBAR).length !== 0 ? $(Selector.SIDEBAR).height() : 0, - control_sidebar: control_sidebar, + controlSidebar } const max = this._max(heights) let offset = this._config.panelAutoHeight if (offset === true) { - offset = 0; + offset = 0 } if (offset !== false) { - if (max == heights.control_sidebar) { + if (max === heights.controlSidebar) { $(Selector.CONTENT).css('min-height', (max + offset)) - } else if (max == heights.window) { + } else if (max === heights.window) { $(Selector.CONTENT).css('min-height', (max + offset) - heights.header - heights.footer) } else { $(Selector.CONTENT).css('min-height', (max + offset) - heights.header) } + if (this._isFooterFixed()) { - $(Selector.CONTENT).css('min-height', parseFloat($(Selector.CONTENT).css('min-height')) + heights.footer); + $(Selector.CONTENT).css('min-height', parseFloat($(Selector.CONTENT).css('min-height')) + heights.footer) } } @@ -116,11 +100,11 @@ const Layout = (($) => { if (typeof $.fn.overlayScrollbars !== 'undefined') { $(Selector.SIDEBAR).overlayScrollbars({ - className : this._config.scrollbarTheme, - sizeAutoCapable : true, - scrollbars : { - autoHide: this._config.scrollbarAutoHide, - clickScrolling : true + className: this._config.scrollbarTheme, + sizeAutoCapable: true, + scrollbars: { + autoHide: this._config.scrollbarAutoHide, + clickScrolling: true } }) } @@ -131,10 +115,10 @@ const Layout = (($) => { if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length === 0) { $('body, html').css('height', 'auto') } else if ($(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).length !== 0) { - let box_height = $(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).height() + const boxHeight = $(Selector.LOGIN_BOX + ', ' + Selector.REGISTER_BOX).height() - if ($('body').css('min-height') !== box_height) { - $('body').css('min-height', box_height) + if ($('body').css('min-height') !== boxHeight) { + $('body').css('min-height', boxHeight) } } } @@ -148,7 +132,7 @@ const Layout = (($) => { if (this._config.loginRegisterAutoHeight === true) { this.fixLoginRegisterHeight() } else if (Number.isInteger(this._config.loginRegisterAutoHeight)) { - setInterval(this.fixLoginRegisterHeight, this._config.loginRegisterAutoHeight); + setInterval(this.fixLoginRegisterHeight, this._config.loginRegisterAutoHeight) } $(Selector.SIDEBAR) @@ -166,7 +150,7 @@ const Layout = (($) => { this.fixLayoutHeight() }) .on('expanded.lte.controlsidebar', () => { - this.fixLayoutHeight('control_sidebar') + this.fixLayoutHeight('controlSidebar') }) $(window).resize(() => { @@ -175,15 +159,14 @@ const Layout = (($) => { setTimeout(() => { $('body.hold-transition').removeClass('hold-transition') - - }, 50); + }, 50) } _max(numbers) { // Calculate the maximum number in a list let max = 0 - Object.keys(numbers).forEach((key) => { + Object.keys(numbers).forEach(key => { if (numbers[key] > max) { max = numbers[key] } @@ -193,7 +176,7 @@ const Layout = (($) => { } _isFooterFixed() { - return $('.main-footer').css('position') === 'fixed'; + return $('.main-footer').css('position') === 'fixed' } // Static @@ -209,7 +192,7 @@ const Layout = (($) => { } if (config === 'init' || config === '') { - data['_init']() + data._init() } else if (config === 'fixLayoutHeight' || config === 'fixLoginRegisterHeight') { data[config]() } @@ -227,11 +210,11 @@ const Layout = (($) => { }) $(Selector.SIDEBAR + ' a').on('focusin', () => { - $(Selector.MAIN_SIDEBAR).addClass(ClassName.SIDEBAR_FOCUSED); + $(Selector.MAIN_SIDEBAR).addClass(ClassName.SIDEBAR_FOCUSED) }) $(Selector.SIDEBAR + ' a').on('focusout', () => { - $(Selector.MAIN_SIDEBAR).removeClass(ClassName.SIDEBAR_FOCUSED); + $(Selector.MAIN_SIDEBAR).removeClass(ClassName.SIDEBAR_FOCUSED) }) /** diff --git a/build/js/PushMenu.js b/build/js/PushMenu.js index 5a73360a5..886e7a70f 100644 --- a/build/js/PushMenu.js +++ b/build/js/PushMenu.js @@ -5,15 +5,15 @@ * -------------------------------------------- */ -const PushMenu = (($) => { +const PushMenu = ($ => { /** * Constants * ==================================================== */ - const NAME = 'PushMenu' - const DATA_KEY = 'lte.pushmenu' - const EVENT_KEY = `.${DATA_KEY}` + const NAME = 'PushMenu' + const DATA_KEY = 'lte.pushmenu' + const EVENT_KEY = `.${DATA_KEY}` const JQUERY_NO_CONFLICT = $.fn[NAME] const Event = { @@ -29,8 +29,6 @@ const PushMenu = (($) => { const Selector = { TOGGLE_BUTTON: '[data-widget="pushmenu"]', - SIDEBAR_MINI: '.sidebar-mini', - SIDEBAR_COLLAPSED: '.sidebar-collapse', BODY: 'body', OVERLAY: '#sidebar-overlay', WRAPPER: '.wrapper' @@ -52,7 +50,7 @@ const PushMenu = (($) => { this._element = element this._options = $.extend({}, Default, options) - if (!$(Selector.OVERLAY).length) { + if ($(Selector.OVERLAY).length === 0) { this._addOverlay() } @@ -70,7 +68,7 @@ const PushMenu = (($) => { $(Selector.BODY).removeClass(ClassName.COLLAPSED).removeClass(ClassName.CLOSED) - if(this._options.enableRemember) { + if (this._options.enableRemember) { localStorage.setItem(`remember${EVENT_KEY}`, ClassName.OPEN) } @@ -87,7 +85,7 @@ const PushMenu = (($) => { $(Selector.BODY).addClass(ClassName.COLLAPSED) - if(this._options.enableRemember) { + if (this._options.enableRemember) { localStorage.setItem(`remember${EVENT_KEY}`, ClassName.COLLAPSED) } @@ -96,10 +94,10 @@ const PushMenu = (($) => { } toggle() { - if (!$(Selector.BODY).hasClass(ClassName.COLLAPSED)) { - this.collapse() - } else { + if ($(Selector.BODY).hasClass(ClassName.COLLAPSED)) { this.expand() + } else { + this.collapse() } } @@ -109,10 +107,10 @@ const PushMenu = (($) => { if (!$(Selector.BODY).hasClass(ClassName.OPEN)) { this.collapse() } - } else if (resize == true) { + } else if (resize === true) { if ($(Selector.BODY).hasClass(ClassName.OPEN)) { $(Selector.BODY).removeClass(ClassName.OPEN) - } else if($(Selector.BODY).hasClass(ClassName.CLOSED)) { + } else if ($(Selector.BODY).hasClass(ClassName.CLOSED)) { this.expand() } } @@ -120,26 +118,24 @@ const PushMenu = (($) => { } remember() { - if(this._options.enableRemember) { - let toggleState = localStorage.getItem(`remember${EVENT_KEY}`) - if (toggleState == ClassName.COLLAPSED){ + if (this._options.enableRemember) { + const toggleState = localStorage.getItem(`remember${EVENT_KEY}`) + if (toggleState === ClassName.COLLAPSED) { if (this._options.noTransitionAfterReload) { - $("body").addClass('hold-transition').addClass(ClassName.COLLAPSED).delay(50).queue(function() { - $(this).removeClass('hold-transition') - $(this).dequeue() - }) - } else { - $("body").addClass(ClassName.COLLAPSED) - } - } else { - if (this._options.noTransitionAfterReload) { - $("body").addClass('hold-transition').removeClass(ClassName.COLLAPSED).delay(50).queue(function() { + $('body').addClass('hold-transition').addClass(ClassName.COLLAPSED).delay(50).queue(function () { $(this).removeClass('hold-transition') $(this).dequeue() }) } else { - $("body").removeClass(ClassName.COLLAPSED) + $('body').addClass(ClassName.COLLAPSED) } + } else if (this._options.noTransitionAfterReload) { + $('body').addClass('hold-transition').removeClass(ClassName.COLLAPSED).delay(50).queue(function () { + $(this).removeClass('hold-transition') + $(this).dequeue() + }) + } else { + $('body').removeClass(ClassName.COLLAPSED) } } } @@ -191,7 +187,7 @@ const PushMenu = (($) => { * ==================================================== */ - $(document).on('click', Selector.TOGGLE_BUTTON, (event) => { + $(document).on('click', Selector.TOGGLE_BUTTON, event => { event.preventDefault() let button = event.currentTarget @@ -214,7 +210,7 @@ const PushMenu = (($) => { $.fn[NAME] = PushMenu._jQueryInterface $.fn[NAME].Constructor = PushMenu - $.fn[NAME].noConflict = function () { + $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT return PushMenu._jQueryInterface } diff --git a/build/js/SiteSearch.js b/build/js/SiteSearch.js index b3ed9e5ad..a1dbbae8a 100644 --- a/build/js/SiteSearch.js +++ b/build/js/SiteSearch.js @@ -5,24 +5,21 @@ * -------------------------------------------- */ -const SiteSearch = (($) => { +const SiteSearch = ($ => { /** * Constants * ==================================================== */ - const NAME = 'SiteSearch' - const DATA_KEY = 'lte.site-search' - const EVENT_KEY = `.${DATA_KEY}` + const NAME = 'SiteSearch' + const DATA_KEY = 'lte.site-search' const JQUERY_NO_CONFLICT = $.fn[NAME] - const Event = {} - const Selector = { - TOGGLE_BUTTON : '[data-widget="site-search"]', - SEARCH_BLOCK : '.site-search-block', + TOGGLE_BUTTON: '[data-widget="site-search"]', + SEARCH_BLOCK: '.site-search-block', SEARCH_BACKDROP: '.site-search-backdrop', - SEARCH_INPUT : '.site-search-block .form-control' + SEARCH_INPUT: '.site-search-block .form-control' } const ClassName = { @@ -39,7 +36,6 @@ const SiteSearch = (($) => { */ class SiteSearch { - constructor(_element, _options) { this.element = _element this.options = $.extend({}, Default, _options) @@ -80,7 +76,7 @@ const SiteSearch = (($) => { } if (!/toggle|close/.test(options)) { - throw Error(`Undefined method ${options}`) + throw new Error(`Undefined method ${options}`) } data[options]() @@ -92,7 +88,7 @@ const SiteSearch = (($) => { * Data API * ==================================================== */ - $(document).on('click', Selector.TOGGLE_BUTTON, (event) => { + $(document).on('click', Selector.TOGGLE_BUTTON, event => { event.preventDefault() let button = $(event.currentTarget) @@ -104,7 +100,7 @@ const SiteSearch = (($) => { SiteSearch._jQueryInterface.call(button, 'toggle') }) - $(document).on('click', Selector.SEARCH_BACKDROP, (event) => { + $(document).on('click', Selector.SEARCH_BACKDROP, event => { const backdrop = $(event.currentTarget) SiteSearch._jQueryInterface.call(backdrop, 'close') }) @@ -116,7 +112,7 @@ const SiteSearch = (($) => { $.fn[NAME] = SiteSearch._jQueryInterface $.fn[NAME].Constructor = SiteSearch - $.fn[NAME].noConflict = function () { + $.fn[NAME].noConflict = function () { $.fn[NAME] = JQUERY_NO_CONFLICT return SiteSearch._jQueryInterface } diff --git a/build/js/Toasts.js b/build/js/Toasts.js index a4cfc2570..c9d9b1ee2 100644 --- a/build/js/Toasts.js +++ b/build/js/Toasts.js @@ -5,51 +5,42 @@ * -------------------------------------------- */ -const Toasts = (($) => { +const Toasts = ($ => { /** * Constants * ==================================================== */ - const NAME = 'Toasts' - const DATA_KEY = 'lte.toasts' - const EVENT_KEY = `.${DATA_KEY}` + const NAME = 'Toasts' + const DATA_KEY = 'lte.toasts' + const EVENT_KEY = `.${DATA_KEY}` const JQUERY_NO_CONFLICT = $.fn[NAME] const Event = { INIT: `init${EVENT_KEY}`, CREATED: `created${EVENT_KEY}`, - REMOVED: `removed${EVENT_KEY}`, + REMOVED: `removed${EVENT_KEY}` } const Selector = { - BODY: 'toast-body', CONTAINER_TOP_RIGHT: '#toastsContainerTopRight', CONTAINER_TOP_LEFT: '#toastsContainerTopLeft', CONTAINER_BOTTOM_RIGHT: '#toastsContainerBottomRight', - CONTAINER_BOTTOM_LEFT: '#toastsContainerBottomLeft', + CONTAINER_BOTTOM_LEFT: '#toastsContainerBottomLeft' } const ClassName = { TOP_RIGHT: 'toasts-top-right', TOP_LEFT: 'toasts-top-left', BOTTOM_RIGHT: 'toasts-bottom-right', - BOTTOM_LEFT: 'toasts-bottom-left', - FADE: 'fade', + BOTTOM_LEFT: 'toasts-bottom-left' } const Position = { TOP_RIGHT: 'topRight', TOP_LEFT: 'topLeft', BOTTOM_RIGHT: 'bottomRight', - BOTTOM_LEFT: 'bottomLeft', - } - - const Id = { - CONTAINER_TOP_RIGHT: 'toastsContainerTopRight', - CONTAINER_TOP_LEFT: 'toastsContainerTopLeft', - CONTAINER_BOTTOM_RIGHT: 'toastsContainerBottomRight', - CONTAINER_BOTTOM_LEFT: 'toastsContainerBottomLeft', + BOTTOM_LEFT: 'bottomLeft' } const Default = { @@ -67,7 +58,7 @@ const Toasts = (($) => { subtitle: null, close: true, body: null, - class: null, + class: null } /** @@ -76,9 +67,9 @@ const Toasts = (($) => { */ class Toasts { constructor(element, config) { - this._config = config + this._config = config - this._prepareContainer(); + this._prepareContainer() const initEvent = $.Event(Event.INIT) $('body').trigger(initEvent) @@ -87,11 +78,11 @@ const Toasts = (($) => { // Public create() { - var toast = $('