mirror of
https://github.com/mdbootstrap/mdb-ui-kit.git
synced 2025-02-09 08:10:39 +03:00
eslinted
This commit is contained in:
parent
c5282e7097
commit
6f0e41a486
|
@ -1,5 +1,3 @@
|
||||||
import Util from './util'
|
|
||||||
|
|
||||||
const BaseInput = (($) => {
|
const BaseInput = (($) => {
|
||||||
|
|
||||||
const Default = {
|
const Default = {
|
||||||
|
@ -42,7 +40,7 @@ const BaseInput = (($) => {
|
||||||
// Enforce required classes for a consistent rendering
|
// Enforce required classes for a consistent rendering
|
||||||
this._rejectWithoutRequiredClasses()
|
this._rejectWithoutRequiredClasses()
|
||||||
|
|
||||||
if(this.config.formGroup.autoCreate) {
|
if (this.config.formGroup.autoCreate) {
|
||||||
// Will create form-group if necessary
|
// Will create form-group if necessary
|
||||||
this.autoCreateFormGroup()
|
this.autoCreateFormGroup()
|
||||||
}
|
}
|
||||||
|
@ -64,7 +62,7 @@ const BaseInput = (($) => {
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// protected
|
// protected
|
||||||
|
|
||||||
rejectWithoutRequiredStructure(){
|
rejectWithoutRequiredStructure() {
|
||||||
// implement
|
// implement
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +112,7 @@ const BaseInput = (($) => {
|
||||||
|
|
||||||
// Demarcation element (e.g. first child of a form-group)
|
// Demarcation element (e.g. first child of a form-group)
|
||||||
// Subclasses such as file inputs may have different structures
|
// Subclasses such as file inputs may have different structures
|
||||||
outerElement(){
|
outerElement() {
|
||||||
return this.$element
|
return this.$element
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -122,7 +120,7 @@ const BaseInput = (($) => {
|
||||||
findFormGroup(raiseError = true) {
|
findFormGroup(raiseError = true) {
|
||||||
let fg = this.$element.closest(Selector.FORM_GROUP) // note that form-group may be grandparent in the case of an input-group
|
let fg = this.$element.closest(Selector.FORM_GROUP) // note that form-group may be grandparent in the case of an input-group
|
||||||
if (fg.length === 0 && raiseError) {
|
if (fg.length === 0 && raiseError) {
|
||||||
$.error(`Failed to find form-group for ${$element}`)
|
$.error(`Failed to find form-group for ${this.$element}`)
|
||||||
}
|
}
|
||||||
return fg
|
return fg
|
||||||
}
|
}
|
||||||
|
@ -138,15 +136,15 @@ const BaseInput = (($) => {
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// private
|
// private
|
||||||
_rejectInvalidComponentMatches(){
|
_rejectInvalidComponentMatches() {
|
||||||
for(let otherComponent in this.config.invalidComponentMatches){
|
for (let otherComponent in this.config.invalidComponentMatches) {
|
||||||
otherComponent.rejectMatch(this.constructor.name, $element)
|
otherComponent.rejectMatch(this.constructor.name, this.$element)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_rejectWithoutRequiredClasses(){
|
_rejectWithoutRequiredClasses() {
|
||||||
for(let requiredClass in this.config.requiredClasses){
|
for (let requiredClass in this.config.requiredClasses) {
|
||||||
if(!$element.hasClass(requiredClass)){
|
if (!this.$element.hasClass(requiredClass)) {
|
||||||
$.error(`${this.constructor.name} elements require class: ${requiredClass}`)
|
$.error(`${this.constructor.name} elements require class: ${requiredClass}`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,10 +38,6 @@ const BaseToggle = (($) => {
|
||||||
this.outerClass = outerClass
|
this.outerClass = outerClass
|
||||||
}
|
}
|
||||||
|
|
||||||
dispose() {
|
|
||||||
super.dispose(DATA_KEY)
|
|
||||||
}
|
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
// protected
|
// protected
|
||||||
|
|
||||||
|
@ -55,8 +51,8 @@ const BaseToggle = (($) => {
|
||||||
rejectWithoutRequiredStructure() {
|
rejectWithoutRequiredStructure() {
|
||||||
// '.checkbox|switch|radio > label > input[type=checkbox|radio]'
|
// '.checkbox|switch|radio > label > input[type=checkbox|radio]'
|
||||||
// '.${this.outerClass} > label > input[type=${this.inputType}]'
|
// '.${this.outerClass} > label > input[type=${this.inputType}]'
|
||||||
Util.assert(this.$element.parent().prop('tagName') === 'label', `${component} parent element should be <label>.`)
|
Util.assert(this.$element.parent().prop('tagName') === 'label', `${this.constructor.name}'s ${this.$element} parent element should be <label>.`)
|
||||||
Util.assert(this.outerElement().hasClass(this.outerClass), `${component} grandparent element should have class .${this.outerClass}.`)
|
Util.assert(this.outerElement().hasClass(this.outerClass), `${this.constructor.name}'s ${this.$element} grandparent element should have class .${this.outerClass}.`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------------------------------------------------------------------------
|
// ------------------------------------------------------------------------
|
||||||
|
|
4
js/src/bootstrapMaterialDesign.js
vendored
4
js/src/bootstrapMaterialDesign.js
vendored
|
@ -101,13 +101,13 @@ const BootstrapMaterialDesign = (($) => {
|
||||||
let selector = this._resolveSelector(componentConfig)
|
let selector = this._resolveSelector(componentConfig)
|
||||||
|
|
||||||
// instantiate component on selector elements with config
|
// instantiate component on selector elements with config
|
||||||
console.debug(`instantiating: ${component}`)
|
// console.debug(`instantiating: ${component}`)
|
||||||
$(selector)[component](componentConfig)
|
$(selector)[component](componentConfig)
|
||||||
|
|
||||||
// add to arrive if present and enabled
|
// add to arrive if present and enabled
|
||||||
if (document.arrive && this.config.arrive) {
|
if (document.arrive && this.config.arrive) {
|
||||||
$document.arrive(selector, (element) => { // eslint-disable-line no-loop-func
|
$document.arrive(selector, (element) => { // eslint-disable-line no-loop-func
|
||||||
$($element)[component](componentConfig)
|
$(element)[component](componentConfig)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ import BaseToggle from './baseToggle'
|
||||||
import TextInput from './textInput'
|
import TextInput from './textInput'
|
||||||
import FileInput from './fileInput'
|
import FileInput from './fileInput'
|
||||||
import Radio from './radio'
|
import Radio from './radio'
|
||||||
import Switch from './switch'
|
|
||||||
import Util from './util'
|
import Util from './util'
|
||||||
|
|
||||||
const Checkbox = (($) => {
|
const Checkbox = (($) => {
|
||||||
|
@ -21,10 +20,6 @@ const Checkbox = (($) => {
|
||||||
invalidComponentMatches: [FileInput, Radio, TextInput]
|
invalidComponentMatches: [FileInput, Radio, TextInput]
|
||||||
}
|
}
|
||||||
|
|
||||||
const Selector = {
|
|
||||||
LABEL: 'label'
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ------------------------------------------------------------------------
|
* ------------------------------------------------------------------------
|
||||||
* Class Definition
|
* Class Definition
|
||||||
|
@ -36,6 +31,10 @@ const Checkbox = (($) => {
|
||||||
super(element, $.extend({}, Default, config), inputType, outerClass)
|
super(element, $.extend({}, Default, config), inputType, outerClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispose() {
|
||||||
|
super.dispose(DATA_KEY)
|
||||||
|
}
|
||||||
|
|
||||||
static matches($element) {
|
static matches($element) {
|
||||||
// '.checkbox > label > input[type=checkbox]'
|
// '.checkbox > label > input[type=checkbox]'
|
||||||
if ($element.attr('type') === 'checkbox') {
|
if ($element.attr('type') === 'checkbox') {
|
||||||
|
|
|
@ -25,7 +25,7 @@ const FileInput = (($) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const ClassName = {
|
const ClassName = {
|
||||||
IS_FILEINPUT: 'is-fileinput',
|
IS_FILEINPUT: 'is-fileinput'
|
||||||
}
|
}
|
||||||
|
|
||||||
const Selector = {
|
const Selector = {
|
||||||
|
|
|
@ -33,6 +33,10 @@ const Radio = (($) => {
|
||||||
super(element, $.extend({}, Default, config), NAME, NAME)
|
super(element, $.extend({}, Default, config), NAME, NAME)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dispose() {
|
||||||
|
super.dispose(DATA_KEY)
|
||||||
|
}
|
||||||
|
|
||||||
static matches($element) {
|
static matches($element) {
|
||||||
// '.radio > label > input[type=radio]'
|
// '.radio > label > input[type=radio]'
|
||||||
if ($element.attr('type') === 'radio') {
|
if ($element.attr('type') === 'radio') {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user