mirror of
https://github.com/Hopiu/jquery-mobile.git
synced 2026-04-27 17:34:45 +00:00
The shift away from interal ID attribute usage also allows users to bind page events (pagecreate, pagebeforecreate) to a page div by its ID, which was a frequent cause of confusion when it didn't work as expected in former versions of the framework. Seemingly unrelated: these commits allow you to specify data-role="dialog" in multipage and single page templates. In multipage templates, the role must be on the page (a link with data-rel alone will not work in multi-page). This addresses issue number 464, but may need further testing for obscure scenarios. Fixes #477 (Pages are not enhanced when linking to a filename without a path) Fixes #493 (Click the same link twice -> blank page) Fixes #513 (closing dialog + returning to the same dialog) Fixes #550 (changePage() not updating hash for internal pages - breaks ) Fixes #464 (Dialogs don't work within multi-pages) Fixes #633 (Recent change to prevent same-page requests breaks select menu close button) Fixes #599 (Page ids & page specific events) Fixes #634 (After a bad page request, base url is not reset to current path) booya.
38 lines
1.2 KiB
JavaScript
38 lines
1.2 KiB
JavaScript
//quick & dirty theme switcher, written to potentially work as a bookmarklet
|
|
(function($){
|
|
$.themeswitcher = function(){
|
|
if( $('[data-url=themeswitcher]').length ){ return; }
|
|
var themesDir = 'http://jquerymobile.com/test/themes/',
|
|
themes = ['default','valencia'],
|
|
currentPage = $.mobile.activePage,
|
|
menuPage = $( '<div data-url="themeswitcher" data-role=\'dialog\' data-theme=\'a\'>' +
|
|
'<div data-role=\'header\' data-theme=\'b\'>' +
|
|
'<div class=\'ui-title\'>Switch Theme:</div>'+
|
|
'</div>'+
|
|
'<div data-role=\'content\' data-theme=\'c\'><ul data-role=\'listview\' data-inset=\'true\'></ul></div>'+
|
|
'</div>' )
|
|
.appendTo( $.mobile.pageContainer ),
|
|
menu = menuPage.find('ul');
|
|
|
|
//menu items
|
|
$.each(themes, function( i ){
|
|
$('<li><a href=\'#\'>' + themes[ i ].charAt(0).toUpperCase() + themes[ i ].substr(1) + '</a></li>')
|
|
.click(function(){
|
|
addTheme( themes[i] );
|
|
menuPage.dialog('close');
|
|
})
|
|
.appendTo(menu);
|
|
});
|
|
|
|
//remover, adder
|
|
function addTheme(theme){
|
|
$('head').append( '<link rel=\'stylesheet\' href=\''+ themesDir + theme +'/\' />' );
|
|
}
|
|
|
|
|
|
|
|
//create page, listview
|
|
menuPage.page();
|
|
|
|
};
|
|
})(jQuery);
|