template.js.base.controlgroup.min.js Maven / Gradle / Ivy
'use strict';(function(e){"function"===typeof define&&define.amd?define(["jquery","../widget"],e):e(jQuery)})(function(e){var k=/ui-corner-([a-z]){2,6}/g;return e.widget("ui.controlgroup",{version:"1.12.1",defaultElement:"\x3cdiv\x3e",options:{direction:"horizontal",disabled:null,onlyVisible:!0,items:{button:"input[type\x3dbutton], input[type\x3dsubmit], input[type\x3dreset], button, a",controlgroupLabel:".ui-controlgroup-label",checkboxradio:"input[type\x3d'checkbox'], input[type\x3d'radio']",selectmenu:"select",
spinner:".ui-spinner-input"}},_create:function(){this._enhance()},_enhance:function(){this.element.attr("role","toolbar");this.refresh()},_destroy:function(){this._callChildMethod("destroy");this.childWidgets.removeData("ui-controlgroup-data");this.element.removeAttr("role");this.options.items.controlgroupLabel&&this.element.find(this.options.items.controlgroupLabel).find(".ui-controlgroup-label-contents").contents().unwrap()},_initWidgets:function(){var a=this,b=[];e.each(this.options.items,function(f,
c){var d,h={};c&&("controlgroupLabel"===f?(d=a.element.find(c),d.each(function(){var a=e(this);a.children(".ui-controlgroup-label-contents").length||a.contents().wrapAll("\x3cspan class\x3d'ui-controlgroup-label-contents'\x3e\x3c/span\x3e")}),a._addClass(d,null,"ui-widget ui-widget-content ui-state-default"),b=b.concat(d.get())):e.fn[f]&&(h=a["_"+f+"Options"]?a["_"+f+"Options"]("middle"):{classes:{}},a.element.find(c).each(function(){var c=e(this),d=c[f]("instance"),g=e.widget.extend({},h);"button"===
f&&c.parent(".ui-spinner").length||(d||(d=c[f]()[f]("instance")),d&&(g.classes=a._resolveClassesValues(g.classes,d)),c[f](g),g=c[f]("widget"),e.data(g[0],"ui-controlgroup-data",d?d:c[f]("instance")),b.push(g[0]))})))});this.childWidgets=e(e.unique(b));this._addClass(this.childWidgets,"ui-controlgroup-item")},_callChildMethod:function(a){this.childWidgets.each(function(){var b=e(this).data("ui-controlgroup-data");if(b&&b[a])b[a]()})},_updateCornerClass:function(a,b){var f=this._buildSimpleOptions(b,
"label").classes.label;this._removeClass(a,null,"ui-corner-top ui-corner-bottom ui-corner-left ui-corner-right ui-corner-all");this._addClass(a,null,f)},_buildSimpleOptions:function(a,b){var f="vertical"===this.options.direction,c={classes:{}};c.classes[b]={middle:"",first:"ui-corner-"+(f?"top":"left"),last:"ui-corner-"+(f?"bottom":"right"),only:"ui-corner-all"}[a];return c},_spinnerOptions:function(a){a=this._buildSimpleOptions(a,"ui-spinner");a.classes["ui-spinner-up"]="";a.classes["ui-spinner-down"]=
"";return a},_buttonOptions:function(a){return this._buildSimpleOptions(a,"ui-button")},_checkboxradioOptions:function(a){return this._buildSimpleOptions(a,"ui-checkboxradio-label")},_selectmenuOptions:function(a){var b="vertical"===this.options.direction;return{width:b?"auto":!1,classes:{middle:{"ui-selectmenu-button-open":"","ui-selectmenu-button-closed":""},first:{"ui-selectmenu-button-open":"ui-corner-"+(b?"top":"tl"),"ui-selectmenu-button-closed":"ui-corner-"+(b?"top":"left")},last:{"ui-selectmenu-button-open":b?
"":"ui-corner-tr","ui-selectmenu-button-closed":"ui-corner-"+(b?"bottom":"right")},only:{"ui-selectmenu-button-open":"ui-corner-top","ui-selectmenu-button-closed":"ui-corner-all"}}[a]}},_resolveClassesValues:function(a,b){var f={};e.each(a,function(c){var d=b.options.classes[c]||"",d=e.trim(d.replace(k,""));f[c]=(d+" "+a[c]).replace(/\s+/g," ")});return f},_setOption:function(a,b){"direction"===a&&this._removeClass("ui-controlgroup-"+this.options.direction);this._super(a,b);"disabled"===a?this._callChildMethod(b?
"disable":"enable"):this.refresh()},refresh:function(){var a,b=this;this._addClass("ui-controlgroup ui-controlgroup-"+this.options.direction);"horizontal"===this.options.direction&&this._addClass(null,"ui-helper-clearfix");this._initWidgets();a=this.childWidgets;this.options.onlyVisible&&(a=a.filter(":visible"));a.length&&(e.each(["first","last"],function(f,c){var d=a[c]().data("ui-controlgroup-data");if(d&&b["_"+d.widgetName+"Options"]){var e=b["_"+d.widgetName+"Options"](1===a.length?"only":c);
e.classes=b._resolveClassesValues(e.classes,d);d.element[d.widgetName](e)}else b._updateCornerClass(a[c](),c)}),this._callChildMethod("refresh"))}})});
© 2015 - 2024 Weber Informatics LLC | Privacy Policy