All Downloads are FREE. Search and download functionalities are using the official Maven repository.

template.js.base.checkboxradio.min.js Maven / Gradle / Ivy

There is a newer version: 5.0.5
Show newest version
'use strict';(function(c){"function"===typeof define&&define.amd?define(["jquery","../escape-selector","../form-reset-mixin","../labels","../widget"],c):c(jQuery)})(function(c){c.widget("ui.checkboxradio",[c.ui.formResetMixin,{version:"1.12.1",options:{disabled:null,label:null,icon:!0,classes:{"ui-checkboxradio-label":"ui-corner-all","ui-checkboxradio-icon":"ui-corner-all"}},_getCreateOptions:function(){var a,b=this,d=this._super()||{};this._readType();a=this.element.labels();this.label=c(a[a.length-
1]);this.label.length||c.error("No label found for checkboxradio widget");this.originalLabel="";this.label.contents().not(this.element[0]).each(function(){b.originalLabel+=3===this.nodeType?c(this).text():this.outerHTML});this.originalLabel&&(d.label=this.originalLabel);a=this.element[0].disabled;null!=a&&(d.disabled=a);return d},_create:function(){var a=this.element[0].checked;this._bindFormResetHandler();null==this.options.disabled&&(this.options.disabled=this.element[0].disabled);this._setOption("disabled",
this.options.disabled);this._addClass("ui-checkboxradio","ui-helper-hidden-accessible");this._addClass(this.label,"ui-checkboxradio-label","ui-button ui-widget");"radio"===this.type&&this._addClass(this.label,"ui-checkboxradio-radio-label");this.options.label&&this.options.label!==this.originalLabel?this._updateLabel():this.originalLabel&&(this.options.label=this.originalLabel);this._enhance();a&&(this._addClass(this.label,"ui-checkboxradio-checked","ui-state-active"),this.icon&&this._addClass(this.icon,
null,"ui-state-hover"));this._on({change:"_toggleClasses",focus:function(){this._addClass(this.label,null,"ui-state-focus ui-visual-focus")},blur:function(){this._removeClass(this.label,null,"ui-state-focus ui-visual-focus")}})},_readType:function(){var a=this.element[0].nodeName.toLowerCase();this.type=this.element[0].type;"input"===a&&/radio|checkbox/.test(this.type)||c.error("Can't create checkboxradio on element.nodeName\x3d"+a+" and element.type\x3d"+this.type)},_enhance:function(){this._updateIcon(this.element[0].checked)},
widget:function(){return this.label},_getRadioGroup:function(){var a=this.element[0].name,b="input[name\x3d'"+c.ui.escapeSelector(a)+"']";return a?(this.form.length?c(this.form[0].elements).filter(b):c(b).filter(function(){return 0===c(this).form().length})).not(this.element):c([])},_toggleClasses:function(){var a=this.element[0].checked;this._toggleClass(this.label,"ui-checkboxradio-checked","ui-state-active",a);this.options.icon&&"checkbox"===this.type&&this._toggleClass(this.icon,null,"ui-icon-check ui-state-checked",
a)._toggleClass(this.icon,null,"ui-icon-blank",!a);"radio"===this.type&&this._getRadioGroup().each(function(){var a=c(this).checkboxradio("instance");a&&a._removeClass(a.label,"ui-checkboxradio-checked","ui-state-active")})},_destroy:function(){this._unbindFormResetHandler();this.icon&&(this.icon.remove(),this.iconSpace.remove())},_setOption:function(a,b){if("label"!==a||b)this._super(a,b),"disabled"===a?(this._toggleClass(this.label,null,"ui-state-disabled",b),this.element[0].disabled=b):this.refresh()},
_updateIcon:function(a){var b="ui-icon ui-icon-background ";this.options.icon?(this.icon||(this.icon=c("\x3cspan\x3e"),this.iconSpace=c("\x3cspan\x3e \x3c/span\x3e"),this._addClass(this.iconSpace,"ui-checkboxradio-icon-space")),"checkbox"===this.type?(b+=a?"ui-icon-check ui-state-checked":"ui-icon-blank",this._removeClass(this.icon,null,a?"ui-icon-blank":"ui-icon-check")):b+="ui-icon-blank",this._addClass(this.icon,"ui-checkboxradio-icon",b),a||this._removeClass(this.icon,null,"ui-icon-check ui-state-checked"),
this.icon.prependTo(this.label).after(this.iconSpace)):void 0!==this.icon&&(this.icon.remove(),this.iconSpace.remove(),delete this.icon)},_updateLabel:function(){var a=this.label.contents().not(this.element[0]);this.icon&&(a=a.not(this.icon[0]));this.iconSpace&&(a=a.not(this.iconSpace[0]));a.remove();this.label.append(this.options.label)},refresh:function(){var a=this.element[0].checked,b=this.element[0].disabled;this._updateIcon(a);this._toggleClass(this.label,"ui-checkboxradio-checked","ui-state-active",
a);null!==this.options.label&&this._updateLabel();b!==this.options.disabled&&this._setOptions({disabled:b})}}]);return c.ui.checkboxradio});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy