2010-09-17 20:24:12 +00:00
|
|
|
/*
|
2010-11-10 00:55:52 +00:00
|
|
|
* jQuery Mobile Framework : "dialog" plugin.
|
2010-09-17 20:24:12 +00:00
|
|
|
* 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
|
|
|
|
|
*/
|
2010-11-11 15:49:15 +00:00
|
|
|
(function($, undefined ) {
|
2010-10-21 20:29:05 +00:00
|
|
|
$.widget( "mobile.dialog", $.mobile.widget, {
|
|
|
|
|
options: {},
|
|
|
|
|
_create: function(){
|
2010-11-05 02:49:28 +00:00
|
|
|
var self = this,
|
|
|
|
|
$el = self.element,
|
2010-11-11 20:08:48 +00:00
|
|
|
$prevPage = $.mobile.activePage,
|
2010-11-05 02:49:28 +00:00
|
|
|
$closeBtn = $('<a href="#" data-icon="delete" data-iconpos="notext">Close</a>');
|
2010-11-10 00:10:54 +00:00
|
|
|
|
2010-11-16 13:25:44 +00:00
|
|
|
$el.delegate("a, form", "click submit", function(e){
|
2010-11-15 19:55:33 +00:00
|
|
|
if( e.type == "click" && ( $(e.target).closest('[data-back]')[0] || this==$closeBtn[0] ) ){
|
2010-11-05 02:49:28 +00:00
|
|
|
self.close();
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
//otherwise, assume we're headed somewhere new. set activepage to dialog so the transition will work
|
2010-11-15 19:55:33 +00:00
|
|
|
$.mobile.activePage = self.element;
|
2010-11-05 02:49:28 +00:00
|
|
|
});
|
2010-10-21 20:29:05 +00:00
|
|
|
|
|
|
|
|
this.element
|
|
|
|
|
.bind("pageshow",function(){
|
|
|
|
|
return false;
|
|
|
|
|
})
|
2010-10-11 01:17:49 +00:00
|
|
|
//add ARIA role
|
|
|
|
|
.attr("role","dialog")
|
2010-10-07 21:32:45 +00:00
|
|
|
.addClass('ui-page ui-dialog ui-body-a')
|
2010-10-06 05:10:30 +00:00
|
|
|
.find('[data-role=header]')
|
2010-09-17 20:24:12 +00:00
|
|
|
.addClass('ui-corner-top ui-overlay-shadow')
|
2010-10-21 20:29:05 +00:00
|
|
|
.prepend( $closeBtn )
|
2010-09-17 20:55:30 +00:00
|
|
|
.end()
|
2010-11-09 03:20:09 +00:00
|
|
|
.find('.ui-content:not([class*="ui-body-"])')
|
|
|
|
|
.addClass('ui-body-c')
|
|
|
|
|
.end()
|
2010-10-06 05:10:30 +00:00
|
|
|
.find('.ui-content,[data-role=footer]')
|
2010-09-17 20:55:30 +00:00
|
|
|
.last()
|
|
|
|
|
.addClass('ui-corner-bottom ui-overlay-shadow');
|
2010-11-10 00:10:54 +00:00
|
|
|
|
|
|
|
|
$(window).bind('hashchange',function(){
|
|
|
|
|
if( $el.is('.ui-page-active') ){
|
|
|
|
|
self.close();
|
|
|
|
|
$el.bind('pagehide',function(){
|
2010-12-07 17:05:10 +00:00
|
|
|
$.mobile.updateHash( $prevPage.attr('data-url'), true);
|
2010-11-10 00:10:54 +00:00
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
2010-10-21 20:29:05 +00:00
|
|
|
|
2010-11-05 02:49:28 +00:00
|
|
|
},
|
2010-11-10 00:10:54 +00:00
|
|
|
|
2010-11-05 02:49:28 +00:00
|
|
|
close: function(){
|
2010-11-11 20:08:48 +00:00
|
|
|
$.mobile.changePage([this.element, $.mobile.activePage], undefined, true, true );
|
2010-10-21 20:29:05 +00:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
})( jQuery );
|