123456789101112131415161718192021222324252627282930313233343536373839404142 |
- //quick view source in new window links
- $.fn.addSourceLink = function(style){
- return $(this).each(function(){
- var link = $('<a href="#" data-'+ $.mobile.ns +'inline="true">View Source</a>'),
- src = src = $('<div></div>').append( $(this).clone() ).html(),
- page = $( "<div data-"+ $.mobile.ns +"role='dialog' data-"+ $.mobile.ns +"theme='a'>" +
- "<div data-"+ $.mobile.ns +"role='header' data-"+ $.mobile.ns +"theme='b'>" +
- "<a href='#' class='ui-btn-left' data-"+ $.mobile.ns +"icon='delete' data-"+ $.mobile.ns +"iconpos='notext'>Close</a>"+
- "<div class='ui-title'>jQuery Mobile Source Excerpt</div>"+
- "</div>"+
- "<div data-"+ $.mobile.ns +"role='content'></div>"+
- "</div>" )
- .appendTo( "body" )
- .page();
-
- $('<a href="#">View Source</a>')
- .buttonMarkup({
- icon: 'arrow-u',
- iconpos: 'notext'
- })
- .click(function(){
- var codeblock = $('<pre><code></code></pre>');
- src = src.replace(/&/gmi, '&').replace(/"/gmi, '"').replace(/>/gmi, '>').replace(/</gmi, '<').replace('data-'+ $.mobile.ns +'source="true"','');
- codeblock.find('code').append(src);
- var activePage = $(this).parents('.ui-page-active');
- page.find('.ui-content').append(codeblock);
- $.changePage(page, 'slideup',false);
- page.find('.ui-btn-left').click(function(){
- $.changePage(activepage, 'slideup',true);
- return false;
- });
- })
- .insertAfter(this);
- });
- };
- //set up view source links
- $('div').live('pagebeforecreate',function(){
- $(this).find('[data-'+ $.mobile.ns +'source="true"]').addSourceLink();
- });
|