From 99bccfde1b504ff5280e3e8661db61b75c179fb0 Mon Sep 17 00:00:00 2001 From: Kevin Ross Date: Sun, 6 Dec 2015 08:11:47 -0600 Subject: [PATCH] namespace all jquery global functions as mdb* --- js/src/autofill.js | 11 ++++++----- js/src/bootstrapMaterialDesign.js | 18 +++++++++++------- js/src/checkbox.js | 11 ++++++----- js/src/checkboxInline.js | 11 ++++++----- js/src/file.js | 11 ++++++----- js/src/old/es6Template.js | 10 +++++----- js/src/radio.js | 11 ++++++----- js/src/radioInline.js | 11 ++++++----- js/src/ripples.js | 11 ++++++----- js/src/select.js | 11 ++++++----- js/src/switch.js | 11 ++++++----- js/src/text.js | 11 ++++++----- js/src/textarea.js | 11 ++++++----- 13 files changed, 82 insertions(+), 67 deletions(-) diff --git a/js/src/autofill.js b/js/src/autofill.js index 6dd49990..88feb7bf 100644 --- a/js/src/autofill.js +++ b/js/src/autofill.js @@ -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 } diff --git a/js/src/bootstrapMaterialDesign.js b/js/src/bootstrapMaterialDesign.js index 1f7b1888..f5f6eb0c 100644 --- a/js/src/bootstrapMaterialDesign.js +++ b/js/src/bootstrapMaterialDesign.js @@ -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 } diff --git a/js/src/checkbox.js b/js/src/checkbox.js index 9263f81b..88f4ee79 100644 --- a/js/src/checkbox.js +++ b/js/src/checkbox.js @@ -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: `` @@ -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 } diff --git a/js/src/checkboxInline.js b/js/src/checkboxInline.js index 23bac7d7..d65f2181 100644 --- a/js/src/checkboxInline.js +++ b/js/src/checkboxInline.js @@ -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 } diff --git a/js/src/file.js b/js/src/file.js index 4774c936..cf901637 100644 --- a/js/src/file.js +++ b/js/src/file.js @@ -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 } diff --git a/js/src/old/es6Template.js b/js/src/old/es6Template.js index 48d24395..aed29e1e 100644 --- a/js/src/old/es6Template.js +++ b/js/src/old/es6Template.js @@ -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 } diff --git a/js/src/radio.js b/js/src/radio.js index a7dabe86..6812f702 100644 --- a/js/src/radio.js +++ b/js/src/radio.js @@ -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: `` @@ -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 } diff --git a/js/src/radioInline.js b/js/src/radioInline.js index 440ae5d7..a71fdb2b 100644 --- a/js/src/radioInline.js +++ b/js/src/radioInline.js @@ -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 } diff --git a/js/src/ripples.js b/js/src/ripples.js index 7fab574e..daacb2a8 100644 --- a/js/src/ripples.js +++ b/js/src/ripples.js @@ -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 } diff --git a/js/src/select.js b/js/src/select.js index 9105ab2d..104bc859 100644 --- a/js/src/select.js +++ b/js/src/select.js @@ -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 } diff --git a/js/src/switch.js b/js/src/switch.js index eea03298..a9548db5 100644 --- a/js/src/switch.js +++ b/js/src/switch.js @@ -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: `` @@ -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 } diff --git a/js/src/text.js b/js/src/text.js index be83d9a1..9acf6304 100644 --- a/js/src/text.js +++ b/js/src/text.js @@ -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: ``, @@ -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 } diff --git a/js/src/textarea.js b/js/src/textarea.js index 40483864..071089ca 100644 --- a/js/src/textarea.js +++ b/js/src/textarea.js @@ -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 }