mirror of
https://github.com/mdbootstrap/mdb-ui-kit.git
synced 2024-11-26 03:24:05 +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/checkbox.js' : 'js/src/checkbox.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/modal.js' : 'js/src/modal.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/checkbox.js' : 'js/src/checkbox.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/dropdown.js' : 'js/src/dropdown.js',
|
||||
//'dist/js/umd/modal.js' : 'js/src/modal.js',
|
||||
|
@ -195,7 +195,7 @@ module.exports = function (grunt) {
|
|||
'js/src/autofill.js',
|
||||
'js/src/checkbox.js',
|
||||
'js/src/togglebutton.js',
|
||||
//'js/src/collapse.js',
|
||||
'js/src/radio.js',
|
||||
//'js/src/dropdown.js',
|
||||
//'js/src/modal.js',
|
||||
//'js/src/scrollspy.js',
|
||||
|
|
|
@ -65,13 +65,13 @@
|
|||
// .data("mdproc", true)
|
||||
// .after("<span class='toggle'></span>");
|
||||
//},
|
||||
"radio": function(selector) {
|
||||
// Add fake-radio to material radios
|
||||
$((selector) ? selector : this.options.radioElements)
|
||||
.filter(":notmdproc")
|
||||
.data("mdproc", true)
|
||||
.after("<span class='circle'></span><span class='check'></span>");
|
||||
},
|
||||
//"radio": function(selector) {
|
||||
// // Add fake-radio to material radios
|
||||
// $((selector) ? selector : this.options.radioElements)
|
||||
// .filter(":notmdproc")
|
||||
// .data("mdproc", true)
|
||||
// .after("<span class='circle'></span><span class='check'></span>");
|
||||
//},
|
||||
"input": function(selector) {
|
||||
$((selector) ? selector : this.options.inputElements)
|
||||
.filter(":notmdproc")
|
||||
|
@ -249,7 +249,8 @@
|
|||
$(this.options.togglebuttonElements).togglebutton()
|
||||
}
|
||||
if (this.options.radio) {
|
||||
this.radio();
|
||||
//this.radio();
|
||||
$(this.options.radioElements).radio()
|
||||
}
|
||||
if (this.options.autofill) {
|
||||
//this.autofill();
|
||||
|
@ -275,7 +276,7 @@
|
|||
}
|
||||
if (this.options.radio) {
|
||||
$document.arrive(this.options.radioElements, function() {
|
||||
$.material.radio($(this));
|
||||
$(this).radio();
|
||||
});
|
||||
}
|
||||
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