Sha256: 99512819cb92a231854b01f1b899d22cc7ebbb92cd5a9b6c83b860c8b2145c36

Contents?: true

Size: 1.41 KB

Versions: 18

Compression:

Stored size: 1.41 KB

Contents

$( document ).on( "pageinit", "[data-role='page'].demo-page", function() {
	var page = "#" + $( this ).attr( "id" ),
		// Get the filename of the next page that we stored in the data-next attribute
		next = $( this ).jqmData( "next" ),
		// Get the filename of the previous page that we stored in the data-prev attribute
		prev = $( this ).jqmData( "prev" );
	
	// Check if we did set the data-next attribute
	if ( next ) {
		// Prefetch the next page
		$.mobile.loadPage( next + ".html" );
		// Navigate to next page on swipe left
		$( document ).on( "swipeleft", page, function() {
			$.mobile.changePage( next + ".html", { transition: "slide" });
		});
		// Navigate to next page when the "next" button is clicked
		$( ".control .next", page ).on( "click", function() {
			$.mobile.changePage( next + ".html", { transition: "slide" } );
		});
	}
	// Disable the "next" button if there is no next page
	else {
		$( ".control .next", page ).addClass( "ui-disabled" );
	}
	// The same for the previous page (we set data-dom-cache="true" so there is no need to prefetch)
	if ( prev ) {
		$( document ).on( "swiperight", page, function() {
			$.mobile.changePage( prev + ".html", { transition: "slide", reverse: true } );
		});
		$( ".control .prev", page ).on( "click", function() {
			$.mobile.changePage( prev + ".html", { transition: "slide", reverse: true } );
		});
	}
	else {
		$( ".control .prev", page ).addClass( "ui-disabled" );
	}
});

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
RubyApp-0.7.16 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.7.15 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.7.14 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.7.13 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.7.12 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.7.11 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.7.10 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.7.9 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.7.5 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.7.4 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.7.3 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.7.2 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.7.1 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.7.0 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.6.71 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.6.70 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.6.69 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js
RubyApp-0.6.68 lib/ruby_app/resources/elements/mobile/document/jquery.mobile-1.3.0/demos/docs/examples/swipe/swipe-page.js