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

template.js.base.button.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","./controlgroup","./checkboxradio","../keycode","../widget"],c):c(jQuery)})(function(c){c.widget("ui.button",{version:"1.12.1",defaultElement:"\x3cbutton\x3e",options:{classes:{"ui-button":"ui-corner-all"},disabled:null,icon:null,iconPosition:"beginning",label:null,showLabel:!0},_getCreateOptions:function(){var a,b=this._super()||{};this.isInput=this.element.is("input");a=this.element[0].disabled;null!=a&&(b.disabled=
a);if(this.originalLabel=this.isInput?this.element.val():this.element.html())b.label=this.originalLabel;return b},_create:function(){!this.option.showLabel&!this.options.icon&&(this.options.showLabel=!0);null==this.options.disabled&&(this.options.disabled=this.element[0].disabled||!1);this.hasTitle=!!this.element.attr("title");this.options.label&&this.options.label!==this.originalLabel&&(this.isInput?this.element.val(this.options.label):this.element.html(this.options.label));this._addClass("ui-button",
"ui-widget");this._setOption("disabled",this.options.disabled);this._enhance();this.element.is("a")&&this._on({keyup:function(a){a.keyCode===c.ui.keyCode.SPACE&&(a.preventDefault(),this.element[0].click?this.element[0].click():this.element.trigger("click"))}})},_enhance:function(){this.element.is("button")||this.element.attr("role","button");this.options.icon&&(this._updateIcon("icon",this.options.icon),this._updateTooltip())},_updateTooltip:function(){this.title=this.element.attr("title");this.options.showLabel||
this.title||this.element.attr("title",this.options.label)},_updateIcon:function(a,b){var e="iconPosition"!==a,d=e?this.options.iconPosition:b,f="top"===d||"bottom"===d;this.icon?e&&this._removeClass(this.icon,null,this.options.icon):(this.icon=c("\x3cspan\x3e"),this._addClass(this.icon,"ui-button-icon","ui-icon"),this.options.showLabel||this._addClass("ui-button-icon-only"));e&&this._addClass(this.icon,null,b);this._attachIcon(d);f?(this._addClass(this.icon,null,"ui-widget-icon-block"),this.iconSpace&&
this.iconSpace.remove()):(this.iconSpace||(this.iconSpace=c("\x3cspan\x3e \x3c/span\x3e"),this._addClass(this.iconSpace,"ui-button-icon-space")),this._removeClass(this.icon,null,"ui-wiget-icon-block"),this._attachIconSpace(d))},_destroy:function(){this.element.removeAttr("role");this.icon&&this.icon.remove();this.iconSpace&&this.iconSpace.remove();this.hasTitle||this.element.removeAttr("title")},_attachIconSpace:function(a){this.icon[/^(?:end|bottom)/.test(a)?"before":"after"](this.iconSpace)},_attachIcon:function(a){this.element[/^(?:end|bottom)/.test(a)?
"append":"prepend"](this.icon)},_setOptions:function(a){var b=void 0===a.icon?this.options.icon:a.icon;(void 0===a.showLabel?this.options.showLabel:a.showLabel)||b||(a.showLabel=!0);this._super(a)},_setOption:function(a,b){"icon"===a&&(b?this._updateIcon(a,b):this.icon&&(this.icon.remove(),this.iconSpace&&this.iconSpace.remove()));"iconPosition"===a&&this._updateIcon(a,b);"showLabel"===a&&(this._toggleClass("ui-button-icon-only",null,!b),this._updateTooltip());"label"===a&&(this.isInput?this.element.val(b):
(this.element.html(b),this.icon&&(this._attachIcon(this.options.iconPosition),this._attachIconSpace(this.options.iconPosition))));this._super(a,b);"disabled"===a&&(this._toggleClass(null,"ui-state-disabled",b),(this.element[0].disabled=b)&&this.element.blur())},refresh:function(){var a=this.element.is("input, button")?this.element[0].disabled:this.element.hasClass("ui-button-disabled");a!==this.options.disabled&&this._setOptions({disabled:a});this._updateTooltip()}});!1!==c.uiBackCompat&&(c.widget("ui.button",
c.ui.button,{options:{text:!0,icons:{primary:null,secondary:null}},_create:function(){this.options.showLabel&&!this.options.text&&(this.options.showLabel=this.options.text);!this.options.showLabel&&this.options.text&&(this.options.text=this.options.showLabel);this.options.icon||!this.options.icons.primary&&!this.options.icons.secondary?this.options.icon&&(this.options.icons.primary=this.options.icon):this.options.icons.primary?this.options.icon=this.options.icons.primary:(this.options.icon=this.options.icons.secondary,
this.options.iconPosition="end");this._super()},_setOption:function(a,b){"text"===a?this._super("showLabel",b):("showLabel"===a&&(this.options.text=b),"icon"===a&&(this.options.icons.primary=b),"icons"===a&&(b.primary?(this._super("icon",b.primary),this._super("iconPosition","beginning")):b.secondary&&(this._super("icon",b.secondary),this._super("iconPosition","end"))),this._superApply(arguments))}}),c.fn.button=function(a){return function(){if(!this.length||this.length&&"INPUT"!==this[0].tagName||
this.length&&"INPUT"===this[0].tagName&&"checkbox"!==this.attr("type")&&"radio"!==this.attr("type"))return a.apply(this,arguments);c.ui.checkboxradio||c.error("Checkboxradio widget missing");return 0===arguments.length?this.checkboxradio({icon:!1}):this.checkboxradio.apply(this,arguments)}}(c.fn.button),c.fn.buttonset=function(){c.ui.controlgroup||c.error("Controlgroup widget missing");if("option"===arguments[0]&&"items"===arguments[1]&&arguments[2])return this.controlgroup.apply(this,[arguments[0],
"items.button",arguments[2]]);if("option"===arguments[0]&&"items"===arguments[1])return this.controlgroup.apply(this,[arguments[0],"items.button"]);"object"===typeof arguments[0]&&arguments[0].items&&(arguments[0].items={button:arguments[0].items});return this.controlgroup.apply(this,arguments)});return c.ui.button});




© 2015 - 2024 Weber Informatics LLC | Privacy Policy