mirror of
https://github.com/mdbootstrap/mdb-ui-kit.git
synced 2025-02-09 08:10:39 +03:00
resolved some issues with es6 classes, about to break input into discreet classes instead of sharing any handlers to prevent confusion
This commit is contained in:
parent
0bfeb61b69
commit
93f0402161
|
@ -20,8 +20,8 @@ const Autofill = (($) => {
|
||||||
*/
|
*/
|
||||||
class Autofill {
|
class Autofill {
|
||||||
|
|
||||||
constructor($element, config) {
|
constructor(element, config) {
|
||||||
this.$element = $element
|
this.$element = $(element)
|
||||||
this.config = $.extend({}, Default, config)
|
this.config = $.extend({}, Default, config)
|
||||||
|
|
||||||
this._watchLoading()
|
this._watchLoading()
|
||||||
|
|
7
js/src/bootstrapMaterialDesign.js
vendored
7
js/src/bootstrapMaterialDesign.js
vendored
|
@ -84,12 +84,12 @@ const BootstrapMaterialDesign = (($) => {
|
||||||
*/
|
*/
|
||||||
class BootstrapMaterialDesign {
|
class BootstrapMaterialDesign {
|
||||||
|
|
||||||
constructor($element, config) {
|
constructor(element, config) {
|
||||||
this.$element = $element
|
this.$element = $(element)
|
||||||
this.config = $.extend({}, Default, config)
|
this.config = $.extend({}, Default, config)
|
||||||
let $document = $(document)
|
let $document = $(document)
|
||||||
|
|
||||||
for (let component in this.config.instantiation) {
|
for (let component of this.config.instantiation) {
|
||||||
|
|
||||||
// the component's config fragment is passed in directly, allowing users to override
|
// the component's config fragment is passed in directly, allowing users to override
|
||||||
let componentConfig = this.config[component]
|
let componentConfig = this.config[component]
|
||||||
|
@ -101,6 +101,7 @@ 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}`)
|
||||||
$(selector)[component](componentConfig)
|
$(selector)[component](componentConfig)
|
||||||
|
|
||||||
// add to arrive if present and enabled
|
// add to arrive if present and enabled
|
||||||
|
|
|
@ -23,12 +23,12 @@ const Checkbox = (($) => {
|
||||||
*/
|
*/
|
||||||
class Checkbox {
|
class Checkbox {
|
||||||
|
|
||||||
constructor($element, config) {
|
constructor(element, config) {
|
||||||
this.$element = $element
|
this.$element = $(element)
|
||||||
this.config = $.extend({}, Default, config)
|
this.config = $.extend({}, Default, config)
|
||||||
|
|
||||||
this.$element.after(this.config.template)
|
this.$element.after(this.config.template)
|
||||||
this.$formGroup = Util.findFormGroup(this.$element)
|
this.$formGroup = Util.findFormGroup(this.$element, false)
|
||||||
|
|
||||||
this._bindEventListeners()
|
this._bindEventListeners()
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ const FileInput = (($) => {
|
||||||
*/
|
*/
|
||||||
class FileInput {
|
class FileInput {
|
||||||
|
|
||||||
constructor($element, config) {
|
constructor(element, config) {
|
||||||
this.$element = $element
|
this.$element = $(element)
|
||||||
this.config = $.extend({}, Default, config)
|
this.config = $.extend({}, Default, config)
|
||||||
this.$formGroup = Util.findFormGroup(this.$element)
|
this.$formGroup = Util.findFormGroup(this.$element)
|
||||||
|
|
||||||
|
|
|
@ -41,8 +41,8 @@ const Input = (($) => {
|
||||||
*/
|
*/
|
||||||
class Input {
|
class Input {
|
||||||
|
|
||||||
constructor($element, config) {
|
constructor(element, config) {
|
||||||
this.$element = $element
|
this.$element = $(element)
|
||||||
this.config = $.extend({}, Default, config)
|
this.config = $.extend({}, Default, config)
|
||||||
|
|
||||||
// Requires form-group standard markup (will add it if necessary)
|
// Requires form-group standard markup (will add it if necessary)
|
||||||
|
@ -158,8 +158,8 @@ const Input = (($) => {
|
||||||
|
|
||||||
_findOrCreateFormGroup() {
|
_findOrCreateFormGroup() {
|
||||||
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) {
|
if (fg === null || fg.length === 0) {
|
||||||
this.$element.wrap(this.config.$formGroup.template)
|
this.$element.wrap(this.config.formGroup.template)
|
||||||
fg = this.$element.closest(Selector.FORM_GROUP) // find node after attached (otherwise additional attachments don't work)
|
fg = this.$element.closest(Selector.FORM_GROUP) // find node after attached (otherwise additional attachments don't work)
|
||||||
}
|
}
|
||||||
return fg
|
return fg
|
||||||
|
|
|
@ -22,8 +22,8 @@ const Foo = (($) => {
|
||||||
*/
|
*/
|
||||||
class Foo {
|
class Foo {
|
||||||
|
|
||||||
constructor($element, config) {
|
constructor(element, config) {
|
||||||
this.$element = $element
|
this.$element = $(element)
|
||||||
this.config = $.extend({}, Default, config)
|
this.config = $.extend({}, Default, config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,8 +23,8 @@ const Radio = (($) => {
|
||||||
*/
|
*/
|
||||||
class Radio {
|
class Radio {
|
||||||
|
|
||||||
constructor($element, config) {
|
constructor(element, config) {
|
||||||
this.$element = $element
|
this.$element = $(element)
|
||||||
this.config = $.extend({}, Default, config)
|
this.config = $.extend({}, Default, config)
|
||||||
|
|
||||||
this.$element.after(this.config.template)
|
this.$element.after(this.config.template)
|
||||||
|
|
|
@ -44,8 +44,8 @@ const Ripples = (($) => {
|
||||||
*/
|
*/
|
||||||
class Ripples {
|
class Ripples {
|
||||||
|
|
||||||
constructor($element, config) {
|
constructor(element, config) {
|
||||||
this.$element = $element
|
this.$element = $(element)
|
||||||
this.config = $.extend({}, Default, config)
|
this.config = $.extend({}, Default, config)
|
||||||
|
|
||||||
// attach initial listener
|
// attach initial listener
|
||||||
|
|
|
@ -23,8 +23,8 @@ const Togglebutton = (($) => {
|
||||||
*/
|
*/
|
||||||
class Togglebutton {
|
class Togglebutton {
|
||||||
|
|
||||||
constructor($element, config) {
|
constructor(element, config) {
|
||||||
this.$element = $element
|
this.$element = $(element)
|
||||||
this.config = $.extend({}, Default, config)
|
this.config = $.extend({}, Default, config)
|
||||||
|
|
||||||
this.$element.after(this.config.template)
|
this.$element.after(this.config.template)
|
||||||
|
|
|
@ -86,9 +86,9 @@ const Util = (($) => {
|
||||||
/**
|
/**
|
||||||
Find expected form-group
|
Find expected form-group
|
||||||
*/
|
*/
|
||||||
findFormGroup($element) {
|
findFormGroup($element, raiseError = true) {
|
||||||
let fg = $element.closest(Selector.FORM_GROUP) // note that form-group may be grandparent in the case of an input-group
|
let fg = $element.closest(Selector.FORM_GROUP) // note that form-group may be grandparent in the case of an input-group
|
||||||
if (fg.length === 0) {
|
if (fg.length === 0 && raiseError) {
|
||||||
$.error(`Failed to find form-group for ${$element}`)
|
$.error(`Failed to find form-group for ${$element}`)
|
||||||
}
|
}
|
||||||
return fg
|
return fg
|
||||||
|
|
Loading…
Reference in New Issue
Block a user