5 (function( $, window, undefined ) {
7 $.widget( "mobile.dialog", $.mobile.widget, {
9 closeBtnText : "Close",
11 initSelector : ":jqmData(role='dialog')"
16 headerCloseButton = $( "<a href='#' data-" + $.mobile.ns + "icon='delete' data-" + $.mobile.ns + "iconpos='notext'>"+ this.options.closeBtnText + "</a>" );
18 $el.addClass( "ui-overlay-" + this.options.overlayTheme );
20 // Class the markup for dialog styling
22 $el.attr( "role", "dialog" )
23 .addClass( "ui-dialog" )
24 .find( ":jqmData(role='header')" )
25 .addClass( "ui-corner-top ui-overlay-shadow" )
26 .prepend( headerCloseButton )
28 .find( ":jqmData(role='content'),:jqmData(role='footer')" )
29 .addClass( "ui-overlay-shadow" )
31 .addClass( "ui-corner-bottom" );
33 // this must be an anonymous function so that select menu dialogs can replace
34 // the close method. This is a change from previously just defining data-rel=back
35 // on the button and letting nav handle it
36 headerCloseButton.bind( "vclick", function() {
41 - clicks and submits should use the closing transition that the dialog opened with
42 unless a data-transition is specified on the link/form
43 - if the click was on the close button, or the link has a data-rel="back" it'll go back in history naturally
45 $el.bind( "vclick submit", function( event ) {
46 var $target = $( event.target ).closest( event.type === "vclick" ? "a" : "form" ),
49 if ( $target.length && !$target.jqmData( "transition" ) ) {
51 active = $.mobile.urlHistory.getActive() || {};
53 $target.attr( "data-" + $.mobile.ns + "transition", ( active.transition || $.mobile.defaultDialogTransition ) )
54 .attr( "data-" + $.mobile.ns + "direction", "reverse" );
57 .bind( "pagehide", function() {
58 $( this ).find( "." + $.mobile.activeBtnClass ).removeClass( $.mobile.activeBtnClass );
62 // Close method goes back in history
64 window.history.back();
68 //auto self-init widgets
69 $( $.mobile.dialog.prototype.options.initSelector ).live( "pagecreate", function(){