mirror of
https://github.com/mdbootstrap/mdb-ui-kit.git
synced 2024-11-22 17:47:11 +03:00
converted radio to es6
This commit is contained in:
parent
2eb61027da
commit
b034b426bc
|
@ -105,7 +105,7 @@ module.exports = function (grunt) {
|
||||||
'js/dist/autofill.js' : 'js/src/autofill.js',
|
'js/dist/autofill.js' : 'js/src/autofill.js',
|
||||||
'js/dist/checkbox.js' : 'js/src/checkbox.js',
|
'js/dist/checkbox.js' : 'js/src/checkbox.js',
|
||||||
'js/dist/togglebutton.js' : 'js/src/togglebutton.js',
|
'js/dist/togglebutton.js' : 'js/src/togglebutton.js',
|
||||||
//'js/dist/collapse.js' : 'js/src/collapse.js',
|
'js/dist/radio.js' : 'js/src/radio.js',
|
||||||
//'js/dist/dropdown.js' : 'js/src/dropdown.js',
|
//'js/dist/dropdown.js' : 'js/src/dropdown.js',
|
||||||
//'js/dist/modal.js' : 'js/src/modal.js',
|
//'js/dist/modal.js' : 'js/src/modal.js',
|
||||||
//'js/dist/scrollspy.js' : 'js/src/scrollspy.js',
|
//'js/dist/scrollspy.js' : 'js/src/scrollspy.js',
|
||||||
|
@ -132,7 +132,7 @@ module.exports = function (grunt) {
|
||||||
'dist/js/umd/autofill.js' : 'js/src/autofill.js',
|
'dist/js/umd/autofill.js' : 'js/src/autofill.js',
|
||||||
'dist/js/umd/checkbox.js' : 'js/src/checkbox.js',
|
'dist/js/umd/checkbox.js' : 'js/src/checkbox.js',
|
||||||
'dist/js/umd/togglebutton.js' : 'js/src/togglebutton.js',
|
'dist/js/umd/togglebutton.js' : 'js/src/togglebutton.js',
|
||||||
//'dist/js/umd/carousel.js' : 'js/src/carousel.js',
|
'dist/js/umd/radio.js' : 'js/src/radio.js',
|
||||||
//'dist/js/umd/collapse.js' : 'js/src/collapse.js',
|
//'dist/js/umd/collapse.js' : 'js/src/collapse.js',
|
||||||
//'dist/js/umd/dropdown.js' : 'js/src/dropdown.js',
|
//'dist/js/umd/dropdown.js' : 'js/src/dropdown.js',
|
||||||
//'dist/js/umd/modal.js' : 'js/src/modal.js',
|
//'dist/js/umd/modal.js' : 'js/src/modal.js',
|
||||||
|
@ -195,7 +195,7 @@ module.exports = function (grunt) {
|
||||||
'js/src/autofill.js',
|
'js/src/autofill.js',
|
||||||
'js/src/checkbox.js',
|
'js/src/checkbox.js',
|
||||||
'js/src/togglebutton.js',
|
'js/src/togglebutton.js',
|
||||||
//'js/src/collapse.js',
|
'js/src/radio.js',
|
||||||
//'js/src/dropdown.js',
|
//'js/src/dropdown.js',
|
||||||
//'js/src/modal.js',
|
//'js/src/modal.js',
|
||||||
//'js/src/scrollspy.js',
|
//'js/src/scrollspy.js',
|
||||||
|
|
|
@ -65,13 +65,13 @@
|
||||||
// .data("mdproc", true)
|
// .data("mdproc", true)
|
||||||
// .after("<span class='toggle'></span>");
|
// .after("<span class='toggle'></span>");
|
||||||
//},
|
//},
|
||||||
"radio": function(selector) {
|
//"radio": function(selector) {
|
||||||
// Add fake-radio to material radios
|
// // Add fake-radio to material radios
|
||||||
$((selector) ? selector : this.options.radioElements)
|
// $((selector) ? selector : this.options.radioElements)
|
||||||
.filter(":notmdproc")
|
// .filter(":notmdproc")
|
||||||
.data("mdproc", true)
|
// .data("mdproc", true)
|
||||||
.after("<span class='circle'></span><span class='check'></span>");
|
// .after("<span class='circle'></span><span class='check'></span>");
|
||||||
},
|
//},
|
||||||
"input": function(selector) {
|
"input": function(selector) {
|
||||||
$((selector) ? selector : this.options.inputElements)
|
$((selector) ? selector : this.options.inputElements)
|
||||||
.filter(":notmdproc")
|
.filter(":notmdproc")
|
||||||
|
@ -249,7 +249,8 @@
|
||||||
$(this.options.togglebuttonElements).togglebutton()
|
$(this.options.togglebuttonElements).togglebutton()
|
||||||
}
|
}
|
||||||
if (this.options.radio) {
|
if (this.options.radio) {
|
||||||
this.radio();
|
//this.radio();
|
||||||
|
$(this.options.radioElements).radio()
|
||||||
}
|
}
|
||||||
if (this.options.autofill) {
|
if (this.options.autofill) {
|
||||||
//this.autofill();
|
//this.autofill();
|
||||||
|
@ -275,7 +276,7 @@
|
||||||
}
|
}
|
||||||
if (this.options.radio) {
|
if (this.options.radio) {
|
||||||
$document.arrive(this.options.radioElements, function() {
|
$document.arrive(this.options.radioElements, function() {
|
||||||
$.material.radio($(this));
|
$(this).radio();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (this.options.togglebutton) {
|
if (this.options.togglebutton) {
|
||||||
|
|
72
js/src/radio.js
Normal file
72
js/src/radio.js
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
//import Util from './util'
|
||||||
|
|
||||||
|
const Radio = (($) => {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
* Constants
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
const NAME = 'radio'
|
||||||
|
const DATA_KEY = `mdb.${NAME}`
|
||||||
|
const JQUERY_NO_CONFLICT = $.fn[NAME]
|
||||||
|
|
||||||
|
const Default = {
|
||||||
|
template: `<span class='circle'></span><span class='check'></span>`
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
* Class Definition
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
class Radio {
|
||||||
|
|
||||||
|
constructor(element, config) {
|
||||||
|
this.element = element
|
||||||
|
this.config = $.extend({}, Default, config)
|
||||||
|
|
||||||
|
this.element.after(this.config.template)
|
||||||
|
}
|
||||||
|
|
||||||
|
dispose() {
|
||||||
|
$.removeData(this.element, DATA_KEY)
|
||||||
|
this.element = null
|
||||||
|
this.config = null
|
||||||
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// private
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
// static
|
||||||
|
static _jQueryInterface(config) {
|
||||||
|
return this.each(function () {
|
||||||
|
let $element = $(this)
|
||||||
|
let data = $element.data(DATA_KEY)
|
||||||
|
|
||||||
|
if (!data) {
|
||||||
|
data = new Radio(this, config)
|
||||||
|
$element.data(DATA_KEY, data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
* jQuery
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
$.fn[NAME] = Radio._jQueryInterface
|
||||||
|
$.fn[NAME].Constructor = Radio
|
||||||
|
$.fn[NAME].noConflict = () => {
|
||||||
|
$.fn[NAME] = JQUERY_NO_CONFLICT
|
||||||
|
return Radio._jQueryInterface
|
||||||
|
}
|
||||||
|
|
||||||
|
return Radio
|
||||||
|
|
||||||
|
})(jQuery)
|
||||||
|
|
||||||
|
export default Radio
|
Loading…
Reference in New Issue
Block a user