310 | | (typeof buttons == 'object' && buttons !== null && |
311 | | $.each(buttons, function() { return !(hasButtons = true); })); |
312 | | if (hasButtons) { |
313 | | $.each(buttons, function(name, fn) { |
314 | | var button = $('<button type="button"></button>') |
315 | | .text(name) |
316 | | .click(function() { fn.apply(self.element[0], arguments); }) |
317 | | .appendTo(uiDialogButtonPane); |
318 | | ($.fn.button && button.button()); |
319 | | }); |
| 310 | if( $.isArray(buttons) ) { |
| 311 | $.each(buttons, function( index,value ) { |
| 312 | // Default button type is in fact "button", available is button, submit and reset |
| 313 | var options = { 'type': 'button' }; |
| 314 | var button_options = {}; |
| 315 | |
| 316 | // normal callback |
| 317 | if( typeof value.callback != 'undefined' ) { |
| 318 | options = $.extend( options, { 'click': value.callback } ); |
| 319 | } |
| 320 | |
| 321 | // normal label |
| 322 | if( typeof value.label != 'undefined' ) { |
| 323 | options = $.extend( options, { 'html': value.label } ); |
| 324 | } |
| 325 | |
| 326 | // extend with optional attributes, methods and callbacks |
| 327 | if( typeof value.options != 'undefined' ) { |
| 328 | options = $.extend( options, value.options ); |
| 329 | } |
| 330 | // ui.button specific options |
| 331 | if( typeof value.button_options != 'undefined' ) { |
| 332 | options = $.extend( button_options, value.button_options ); |
| 333 | } |
| 334 | |
| 335 | var button = $("<button/>", options ).appendTo(uiDialogButtonPane).button(button_options); |
| 336 | |
| 337 | }); |
| 339 | } else { |
| 340 | (typeof buttons == 'object' && buttons !== null && |
| 341 | $.each(buttons, function() { return !(hasButtons = true); })); |
| 342 | if (hasButtons) { |
| 343 | $.each(buttons, function(name, fn) { |
| 344 | var button = $('<button type="button"></button>') |
| 345 | .text(name) |
| 346 | .click(function() { fn.apply(self.element[0], arguments); }) |
| 347 | .appendTo(uiDialogButtonPane); |
| 348 | ($.fn.button && button.button()); |
| 349 | }); |
| 350 | uiDialogButtonPane.appendTo(self.uiDialog); |
| 351 | } |