Skip to content

Commit fde58ad

Browse files
committed
Button: backcompat for old button widget
1 parent 9a32fca commit fde58ad

File tree

1 file changed

+76
-1
lines changed

1 file changed

+76
-1
lines changed

ui/button.js

Lines changed: 76 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,9 +229,84 @@ $.widget( "ui.button", {
229229

230230
this._updateTooltip();
231231
}
232-
233232
});
234233

234+
// DEPRECATED
235+
if ( $.uiBackCompat ) {
236+
237+
// Text and Icons options
238+
$.widget( "ui.button", $.ui.button, {
239+
options: {
240+
text: true,
241+
icons: {
242+
primary: null,
243+
secondary: null
244+
}
245+
},
246+
247+
_create: function() {
248+
if ( this.options.showLabel && !this.options.text ) {
249+
this.options.showLabel = this.options.text;
250+
}
251+
if ( !this.options.icon && ( this.options.icons.primary ||
252+
this.options.icons.secondary ) ) {
253+
if ( this.options.icons.primary ) {
254+
this.options.icon = this.options.icons.primary;
255+
} else {
256+
this.options.icon = this.options.icons.secondary;
257+
this.options.iconPosition = "end";
258+
}
259+
}
260+
this._super();
261+
},
262+
263+
_setOption: function( key, value ) {
264+
if ( key === "text" ) {
265+
this._setOption( "showLabel", value );
266+
}
267+
if ( key === "icons" ) {
268+
this._setOption( "icon", value );
269+
if ( value.primary ) {
270+
this._setOption( "icon", value );
271+
this._setOption( "iconPosition", "beginning" );
272+
} else if ( value.secondary ) {
273+
this._setOption( "icon", value );
274+
this._setOption( "iconPosition", "end" );
275+
}
276+
}
277+
this._superApply( arguments );
278+
}
279+
});
280+
$.fn.button = (function( orig ) {
281+
return function() {
282+
if ( this[ 0 ].tagName === "input" && ( this.attr( "type") === "checkbox" ||
283+
this.attr( "type" ) === "radio" ) ) {
284+
if ( $.ui.checkboxradio ) {
285+
if ( arguments.length === 0 ) {
286+
return this.checkboxradio({
287+
"icon": false
288+
});
289+
} else {
290+
return this.checkboxradio.apply( arguments );
291+
}
292+
} else {
293+
$.error( "Checkboxradio widget missing" );
294+
}
295+
} else {
296+
return orig.apply( this, arguments );
297+
}
298+
};
299+
})( $.fn.button );
300+
$.fn.buttonset = function( method, key, value ) {
301+
if ( method === "option" && key === "items" ) {
302+
value = {
303+
"button": value
304+
};
305+
}
306+
this.controlgroup.call( method, key, value );
307+
};
308+
}
309+
235310
return $.ui.button;
236311

237312
}));

0 commit comments

Comments
 (0)