1 //quick view source in new window links
2 $.fn.addSourceLink = function(style){
4 return $(this).each(function(){
5 var link = $('<a href="#" data-'+ $.mobile.ns +'inline="true">View Source</a>'),
6 src = src = $('<div></div>').append( $(this).clone() ).html(),
7 page = $( "<div data-"+ $.mobile.ns +"role='dialog' data-"+ $.mobile.ns +"theme='a'>" +
8 "<div data-"+ $.mobile.ns +"role='header' data-"+ $.mobile.ns +"theme='b'>" +
9 "<a href='#' class='ui-btn-left' data-"+ $.mobile.ns +"icon='delete' data-"+ $.mobile.ns +"iconpos='notext'>Close</a>"+
10 "<div class='ui-title'>jQuery Mobile Source Excerpt</div>"+
12 "<div data-"+ $.mobile.ns +"role='content'></div>"+
17 $('<a href="#">View Source</a>')
23 var codeblock = $('<pre><code></code></pre>');
24 src = src.replace(/&/gmi, '&').replace(/"/gmi, '"').replace(/>/gmi, '>').replace(/</gmi, '<').replace('data-'+ $.mobile.ns +'source="true"','');
25 codeblock.find('code').append(src);
27 var activePage = $(this).parents('.ui-page-active');
28 page.find('.ui-content').append(codeblock);
29 $.changePage(page, 'slideup',false);
30 page.find('.ui-btn-left').click(function(){
31 $.changePage(activepage, 'slideup',true);
39 //set up view source links
40 $('div').live('pagebeforecreate',function(){
41 $(this).find('[data-'+ $.mobile.ns +'source="true"]').addSourceLink();