namespace all jquery global functions as mdb*

This commit is contained in:
Kevin Ross 2015-12-06 08:11:47 -06:00
parent 97b11afbc4
commit 99bccfde1b
13 changed files with 82 additions and 67 deletions

View File

@ -7,7 +7,8 @@ const Autofill = (($) => {
*/
const NAME = 'autofill'
const DATA_KEY = `mdb.${NAME}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const JQUERY_NAME = `mdb${NAME.charAt(0).toUpperCase() + NAME.slice(1)}`
const JQUERY_NO_CONFLICT = $.fn[JQUERY_NAME]
const Default = {}
@ -95,10 +96,10 @@ const Autofill = (($) => {
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Autofill._jQueryInterface
$.fn[NAME].Constructor = Autofill
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
$.fn[JQUERY_NAME] = Autofill._jQueryInterface
$.fn[JQUERY_NAME].Constructor = Autofill
$.fn[JQUERY_NAME].noConflict = () => {
$.fn[JQUERY_NAME] = JQUERY_NO_CONFLICT
return Autofill._jQueryInterface
}

View File

@ -13,7 +13,8 @@ const BootstrapMaterialDesign = (($) => {
*/
const NAME = 'bootstrapMaterialDesign'
const DATA_KEY = `mdb.${NAME}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const JQUERY_NAME = NAME // retain this full name since it is long enough not to conflict
const JQUERY_NO_CONFLICT = $.fn[JQUERY_NAME]
/**
*
@ -105,14 +106,17 @@ const BootstrapMaterialDesign = (($) => {
// assemble the selector as it may be an array
let selector = this._resolveSelector(componentConfig)
// create the jquery fn name e.g. 'mdbText' for 'text'
let jqueryFn = `mdb${component.charAt(0).toUpperCase() + component.slice(1)}`
// instantiate component on selector elements with config
// console.debug(`instantiating: ${component}`)
$(selector)[component](componentConfig)
$(selector)[jqueryFn](componentConfig)
// add to arrive if present and enabled
if (document.arrive && this.config.arrive) {
$document.arrive(selector, (element) => { // eslint-disable-line no-loop-func
$(element)[component](componentConfig)
$(element)[jqueryFn](componentConfig)
})
}
}
@ -157,10 +161,10 @@ const BootstrapMaterialDesign = (($) => {
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = BootstrapMaterialDesign._jQueryInterface
$.fn[NAME].Constructor = BootstrapMaterialDesign
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
$.fn[JQUERY_NAME] = BootstrapMaterialDesign._jQueryInterface
$.fn[JQUERY_NAME].Constructor = BootstrapMaterialDesign
$.fn[JQUERY_NAME].noConflict = () => {
$.fn[JQUERY_NAME] = JQUERY_NO_CONFLICT
return BootstrapMaterialDesign._jQueryInterface
}

View File

@ -15,7 +15,8 @@ const Checkbox = (($) => {
*/
const NAME = 'checkbox'
const DATA_KEY = `mdb.${NAME}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const JQUERY_NAME = `mdb${NAME.charAt(0).toUpperCase() + NAME.slice(1)}`
const JQUERY_NO_CONFLICT = $.fn[JQUERY_NAME]
const Default = {
template: `<span class='checkbox-decorator'><span class='check'></span></span>`
@ -79,10 +80,10 @@ const Checkbox = (($) => {
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Checkbox._jQueryInterface
$.fn[NAME].Constructor = Checkbox
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
$.fn[JQUERY_NAME] = Checkbox._jQueryInterface
$.fn[JQUERY_NAME].Constructor = Checkbox
$.fn[JQUERY_NAME].noConflict = () => {
$.fn[JQUERY_NAME] = JQUERY_NO_CONFLICT
return Checkbox._jQueryInterface
}

View File

@ -9,7 +9,8 @@ const CheckboxInline = (($) => {
*/
const NAME = 'checkboxInline'
const DATA_KEY = `mdb.${NAME}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const JQUERY_NAME = `mdb${NAME.charAt(0).toUpperCase() + NAME.slice(1)}`
const JQUERY_NO_CONFLICT = $.fn[JQUERY_NAME]
const Default = {}
@ -69,10 +70,10 @@ const CheckboxInline = (($) => {
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = CheckboxInline._jQueryInterface
$.fn[NAME].Constructor = CheckboxInline
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
$.fn[JQUERY_NAME] = CheckboxInline._jQueryInterface
$.fn[JQUERY_NAME].Constructor = CheckboxInline
$.fn[JQUERY_NAME].noConflict = () => {
$.fn[JQUERY_NAME] = JQUERY_NO_CONFLICT
return CheckboxInline._jQueryInterface
}

View File

@ -16,7 +16,8 @@ const File = (($) => {
*/
const NAME = 'file'
const DATA_KEY = `mdb.${NAME}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const JQUERY_NAME = `mdb${NAME.charAt(0).toUpperCase() + NAME.slice(1)}`
const JQUERY_NO_CONFLICT = $.fn[JQUERY_NAME]
const Default = {}
@ -122,10 +123,10 @@ const File = (($) => {
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = File._jQueryInterface
$.fn[NAME].Constructor = File
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
$.fn[JQUERY_NAME] = File._jQueryInterface
$.fn[JQUERY_NAME].Constructor = File
$.fn[JQUERY_NAME].noConflict = () => {
$.fn[JQUERY_NAME] = JQUERY_NO_CONFLICT
return File._jQueryInterface
}

View File

@ -9,7 +9,7 @@ const Foo = (($) => {
*/
const NAME = 'foo'
const DATA_KEY = `mdb.${NAME}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const JQUERY_NO_CONFLICT = $.fn[JQUERY_NAME]
const Default = {
template: ``
@ -61,10 +61,10 @@ const Foo = (($) => {
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Foo._jQueryInterface
$.fn[NAME].Constructor = Foo
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
$.fn[JQUERY_NAME] = Foo._jQueryInterface
$.fn[JQUERY_NAME].Constructor = Foo
$.fn[JQUERY_NAME].noConflict = () => {
$.fn[JQUERY_NAME] = JQUERY_NO_CONFLICT
return Foo._jQueryInterface
}

View File

@ -14,7 +14,8 @@ const Radio = (($) => {
*/
const NAME = 'radio'
const DATA_KEY = `mdb.${NAME}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const JQUERY_NAME = `mdb${NAME.charAt(0).toUpperCase() + NAME.slice(1)}`
const JQUERY_NO_CONFLICT = $.fn[JQUERY_NAME]
const Default = {
template: `<span class='radio-decorator'></span><span class='check'></span>`
@ -75,10 +76,10 @@ const Radio = (($) => {
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Radio._jQueryInterface
$.fn[NAME].Constructor = Radio
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
$.fn[JQUERY_NAME] = Radio._jQueryInterface
$.fn[JQUERY_NAME].Constructor = Radio
$.fn[JQUERY_NAME].noConflict = () => {
$.fn[JQUERY_NAME] = JQUERY_NO_CONFLICT
return Radio._jQueryInterface
}

View File

@ -9,7 +9,8 @@ const RadioInline = (($) => {
*/
const NAME = 'radioInline'
const DATA_KEY = `mdb.${NAME}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const JQUERY_NAME = `mdb${NAME.charAt(0).toUpperCase() + NAME.slice(1)}`
const JQUERY_NO_CONFLICT = $.fn[JQUERY_NAME]
const Default = {}
@ -57,10 +58,10 @@ const RadioInline = (($) => {
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = RadioInline._jQueryInterface
$.fn[NAME].Constructor = RadioInline
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
$.fn[JQUERY_NAME] = RadioInline._jQueryInterface
$.fn[JQUERY_NAME].Constructor = RadioInline
$.fn[JQUERY_NAME].noConflict = () => {
$.fn[JQUERY_NAME] = JQUERY_NO_CONFLICT
return RadioInline._jQueryInterface
}

View File

@ -9,7 +9,8 @@ const Ripples = (($) => {
*/
const NAME = 'ripples'
const DATA_KEY = `mdb.${NAME}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const JQUERY_NAME = `mdb${NAME.charAt(0).toUpperCase() + NAME.slice(1)}`
const JQUERY_NO_CONFLICT = $.fn[JQUERY_NAME]
const ClassName = {
CONTAINER: 'ripple-container',
@ -284,10 +285,10 @@ const Ripples = (($) => {
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Ripples._jQueryInterface
$.fn[NAME].Constructor = Ripples
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
$.fn[JQUERY_NAME] = Ripples._jQueryInterface
$.fn[JQUERY_NAME].Constructor = Ripples
$.fn[JQUERY_NAME].noConflict = () => {
$.fn[JQUERY_NAME] = JQUERY_NO_CONFLICT
return Ripples._jQueryInterface
}

View File

@ -15,7 +15,8 @@ const Select = (($) => {
*/
const NAME = 'select'
const DATA_KEY = `mdb.${NAME}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const JQUERY_NAME = `mdb${NAME.charAt(0).toUpperCase() + NAME.slice(1)}`
const JQUERY_NO_CONFLICT = $.fn[JQUERY_NAME]
const Default = {
requiredClasses: ['form-control||c-select']
@ -73,10 +74,10 @@ const Select = (($) => {
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Select._jQueryInterface
$.fn[NAME].Constructor = Select
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
$.fn[JQUERY_NAME] = Select._jQueryInterface
$.fn[JQUERY_NAME].Constructor = Select
$.fn[JQUERY_NAME].noConflict = () => {
$.fn[JQUERY_NAME] = JQUERY_NO_CONFLICT
return Select._jQueryInterface
}

View File

@ -9,7 +9,8 @@ const Switch = (($) => {
*/
const NAME = 'switch'
const DATA_KEY = `mdb.${NAME}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const JQUERY_NAME = `mdb${NAME.charAt(0).toUpperCase() + NAME.slice(1)}`
const JQUERY_NO_CONFLICT = $.fn[JQUERY_NAME]
const Default = {
template: `<span class='switch-decorator'></span>`
@ -57,10 +58,10 @@ const Switch = (($) => {
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Switch._jQueryInterface
$.fn[NAME].Constructor = Switch
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
$.fn[JQUERY_NAME] = Switch._jQueryInterface
$.fn[JQUERY_NAME].Constructor = Switch
$.fn[JQUERY_NAME].noConflict = () => {
$.fn[JQUERY_NAME] = JQUERY_NO_CONFLICT
return Switch._jQueryInterface
}

View File

@ -16,7 +16,8 @@ const Text = (($) => {
*/
const NAME = 'text'
const DATA_KEY = `mdb.${NAME}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const JQUERY_NAME = `mdb${NAME.charAt(0).toUpperCase() + NAME.slice(1)}`
const JQUERY_NO_CONFLICT = $.fn[JQUERY_NAME]
const Default = {
template: `<span class='text-input-decorator'></span>`,
@ -98,10 +99,10 @@ const Text = (($) => {
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Text._jQueryInterface
$.fn[NAME].Constructor = Text
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
$.fn[JQUERY_NAME] = Text._jQueryInterface
$.fn[JQUERY_NAME].Constructor = Text
$.fn[JQUERY_NAME].noConflict = () => {
$.fn[JQUERY_NAME] = JQUERY_NO_CONFLICT
return Text._jQueryInterface
}

View File

@ -15,7 +15,8 @@ const Textarea = (($) => {
*/
const NAME = 'textarea'
const DATA_KEY = `mdb.${NAME}`
const JQUERY_NO_CONFLICT = $.fn[NAME]
const JQUERY_NAME = `mdb${NAME.charAt(0).toUpperCase() + NAME.slice(1)}`
const JQUERY_NO_CONFLICT = $.fn[JQUERY_NAME]
const Default = {}
@ -71,10 +72,10 @@ const Textarea = (($) => {
* jQuery
* ------------------------------------------------------------------------
*/
$.fn[NAME] = Textarea._jQueryInterface
$.fn[NAME].Constructor = Textarea
$.fn[NAME].noConflict = () => {
$.fn[NAME] = JQUERY_NO_CONFLICT
$.fn[JQUERY_NAME] = Textarea._jQueryInterface
$.fn[JQUERY_NAME].Constructor = Textarea
$.fn[JQUERY_NAME].noConflict = () => {
$.fn[JQUERY_NAME] = JQUERY_NO_CONFLICT
return Textarea._jQueryInterface
}