Permalink
Browse files

Added support for data-role="dialog". When a dialog is the first "pag…

…e"-type element in the DOM, jQM will enhance it, triggering dialog enhancements as usual for non-ajax environments. Updated the /docs/pages/dialog.html page's role to date-role="dialog" to demonstrate the change. Fixes #3276.
  • Loading branch information...
scottjehl
scottjehl committed Feb 23, 2012
1 parent 522543e commit 95bffbb231162068a7505f6ff8bc597d1e2b598c
Showing with 3 additions and 22 deletions.
  1. +1 −1 docs/pages/dialog.html
  2. +2 −21 js/jquery.mobile.init.js
View
@@ -14,7 +14,7 @@
</head>
<body>
<div data-role="page">
<div data-role="dialog">
<div data-role="header" data-theme="d">
<h1>Dialog</h1>
View
@@ -93,29 +93,10 @@ define( [ "jquery", "./jquery.mobile.core", "./jquery.mobile.support", "./jquery
// find and enhance the pages in the dom and transition to the first page.
initializePage: function() {
// find present pages
var $dialogs, $pages = $( ":jqmData(role='page')" );
// if no pages are found, check for dialogs or create one with body's inner html
if ( !$pages.length ) {
$dialogs = $( ":jqmData(role='dialog')" );
// if there are no pages but a dialog is present, load it as a page
if( $dialogs.length ) {
// alter the attribute so it will be treated as a page unpon enhancement
// TODO allow for the loading of a dialog as the first page (many considerations)
$dialogs.first().attr( "data-" + $.mobile.ns + "role", "page" );
// remove the first dialog from the set of dialogs since it's now a page
// add it to the empty set of pages to be loaded by the initial changepage
$pages = $pages.add( $dialogs.get().shift() );
} else {
$pages = $( "body" ).wrapInner( "<div data-" + $.mobile.ns + "role='page'></div>" ).children( 0 );
}
}
var $pages = $( ":jqmData(role='page'), :jqmData(role='dialog')" );
// add dialogs, set data-url attrs
$pages.add( ":jqmData(role='dialog')" ).each(function() {
$pages.each(function() {
var $this = $(this);
// unless the data url is already set set it to the pathname

0 comments on commit 95bffbb

Please sign in to comment.