//quick & dirty theme switcher, written to potentially work as a bookmarklet
(function($){
$.themeswitcher = function(){
var themesDir = 'http://jquerymobile.com/test/themes/',
themes = ['default','dobson'],
currentPage = $('.ui-page-active'),
menuPage = $( '
' +
'
' +
'
Cancel '+
'
Choose a theme:
'+
'
'+
'
'+
'
' )
.appendTo( 'body' ),
menu = menuPage.find('ul');
//menu items
$.each(themes, function( i ){
$('' + themes[ i ] + ' ')
.click(function(){
addTheme( themes[i] );
done();
return false;
})
.appendTo(menu);
});
//remover, adder
function addTheme(theme){
/*
//way too greedy theme remover
$.each(themes,function( i ){
$('head link[href*='+themes[ i ]+']').remove();
});
*/
$('head').append( ' ' );
}
//finished with this
function done(){
$.changePage(menuPage, currentPage, 'slideup', true);
menuPage.bind('pagehide',function(){
$(this).remove();
});
return false;
}
//create page, listview
menuPage.page();
//change page now
$.changePage(currentPage, menuPage, 'slideup', false);
//destroy
menuPage.find('.ui-btn-left').click(done);
};
})(jQuery);