Skip to content
This repository has been archived by the owner on Oct 8, 2021. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
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 committed Feb 23, 2012
1 parent 522543e commit 95bffbb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 22 deletions.
2 changes: 1 addition & 1 deletion docs/pages/dialog.html
Expand Up @@ -14,7 +14,7 @@
</head>
<body>

<div data-role="page">
<div data-role="dialog">

<div data-role="header" data-theme="d">
<h1>Dialog</h1>
Expand Down
23 changes: 2 additions & 21 deletions js/jquery.mobile.init.js
Expand Up @@ -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
Expand Down

0 comments on commit 95bffbb

Please sign in to comment.