jquery-mobile/js/jquery.mobile.dialog.js
jblas@adobe.com 729cda075a Merge branch 'master' into fastclick
Resolved Conflicts:
	js/jquery.mobile.buttonMarkup.js
	js/jquery.mobile.event.js
	js/jquery.mobile.forms.checkboxradio.js
	js/jquery.mobile.forms.select.js
	js/jquery.mobile.listview.js
2011-03-27 21:00:22 -07:00

61 lines
No EOL
1.8 KiB
JavaScript

/*
* jQuery Mobile Framework : "dialog" plugin.
* Copyright (c) jQuery Project
* Dual licensed under the MIT (MIT-LICENSE.txt) and GPL (GPL-LICENSE.txt) licenses.
* Note: Code is in draft form and is subject to change
*/
(function($, undefined ) {
$.widget( "mobile.dialog", $.mobile.widget, {
options: {
closeBtnText: "Close"
},
_create: function(){
var self = this,
$el = self.element;
/* class the markup for dialog styling */
this.element
//add ARIA role
.attr("role","dialog")
.addClass('ui-page ui-dialog ui-body-a')
.find( ":jqmData(role=header)" )
.addClass('ui-corner-top ui-overlay-shadow')
.prepend( "<a href='#' data-" + $.mobile.ns + "icon='delete' data-" + $.mobile.ns + "rel='back' data-" + $.mobile.ns + "iconpos='notext'>"+ this.options.closeBtnText +"</a>" )
.end()
.find('.ui-content:not([class*="ui-body-"])')
.addClass('ui-body-c')
.end()
.find( ".ui-content,:jqmData(role='footer')" )
.last()
.addClass('ui-corner-bottom ui-overlay-shadow');
/* bind events
- clicks and submits should use the closing transition that the dialog opened with
unless a data-transition is specified on the link/form
- if the click was on the close button, or the link has a data-rel="back" it'll go back in history naturally
*/
this.element
.bind( "vclick submit", function(e){
var $targetel;
if( e.type == "vclick" ){
$targetel = $(e.target).closest("a");
}
else{
$targetel = $(e.target).closest("form");
}
if( $targetel.length && !$targetel.jqmData("transition") ){
$targetel
.attr("data-" + $.mobile.ns + "transition", $.mobile.urlHistory.getActive().transition )
.attr("data-" + $.mobile.ns + "direction", "reverse");
}
});
},
//close method goes back in history
close: function(){
window.history.back();
}
});
})( jQuery );