Si potrebbe creare il proprio widget di estendere $ .ui.dialog aggiungere Mostra sovrapposizione e nascondere animazioni con configurazione accurata utilizzando l'opzione.
Un'altra funzionalità manca per chiudere la finestra cliccando sulla sovrapposizione è anche facilmente aggiunto:
in qualche file, dicono jquery-ui.fsrc.dialog.js:
(function($, undefined) {
$.widget('fsrc.fsrc_dialog', $.ui.dialog, {
open: function() {
// some helpful vars
var self = this,
options = self.options;
// call parent method - it will create overlay and save it in self.overlay variable
var ret = $.ui.dialog.prototype.open.apply(this, arguments);
if (options.showOverlay) {
// immediately hide and animate overlay
// kind a hack, but jquery ui developers left no better way
self.overlay.$el.hide().show(options.showOverlay)
}
if (options.closeOnOverlay) {
// close dialog on click on overlay
self.overlay.$el.click(function() {
self.close();
})
}
return ret;
},
close: function(event) {
var self = this,
options = self.options;
if (options.hideOverlay) {
// save and unset self.overlay, so it will not be destroyed by parent function during animation
var overlay = self.overlay
self.overlay = null;
overlay.$el.hide(options.hideOverlay, function() {
// destroy overlay after animation as parent would do
overlay.destroy();
})
}
// call parent method
var ret = $.ui.dialog.prototype.close.apply(this, arguments);
return ret;
}
});
}(jQuery));
Nella pagina:
<script src='/js/jquery-ui.fsrc.dialog.js' type='text/javascript'></script>
<script type="text/javascript">
<!--
jQuery(document).ready(function(){
jQuery('#show').click(function(){
jQuery('#order_form_container').fsrc_dialog({
modal: true,
closeOnOverlay: true,
show: {effect: "fade", duration: 500},
showOverlay: {effect: "fade", duration: 500},
hide: {effect: "fade", duration: 300},
hideOverlay: {effect: "fade", duration: 300},
});
})
})
-->
</script>`
Ho chiamato spazio dei nomi, widget e opzioni a mio favore.
jquery1.7.2 Tested, jquery-ui1.8.19, IE9, FF11, chrome18.0.1025.168m, opera11.61
perfetto, non posso credere che non ho pensato a quello! –