2011-11-04 21:43:27 +00:00
|
|
|
function ResizePageContentHeight(page) {
|
2010-11-18 23:12:27 +00:00
|
|
|
var $page = $(page);
|
2011-11-04 21:43:27 +00:00
|
|
|
$content = $page.children(".ui-content");
|
|
|
|
|
hh = $page.children(".ui-header").outerHeight(); hh = hh ? hh : 0;
|
|
|
|
|
fh = $page.children(".ui-footer").outerHeight(); fh = fh ? fh : 0;
|
|
|
|
|
pt = parseFloat($content.css("padding-top"));
|
|
|
|
|
pb = parseFloat($content.css("padding-bottom"));
|
|
|
|
|
wh = window.innerHeight;
|
2010-11-18 23:12:27 +00:00
|
|
|
$content.height(wh - (hh + fh) - (pt + pb));
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-26 14:14:48 +00:00
|
|
|
$(":jqmData(role='page')").live("pageshow", function(event) {
|
2011-11-04 21:43:27 +00:00
|
|
|
var $page = $( this );
|
2010-12-15 00:05:52 +00:00
|
|
|
|
|
|
|
|
// For the demos that use this script, we want the content area of each
|
|
|
|
|
// page to be scrollable in the 'y' direction.
|
|
|
|
|
|
2011-11-04 21:43:27 +00:00
|
|
|
$page.find( ".ui-content" ).attr( "data-" + $.mobile.ns + "scroll", "y" );
|
2010-12-15 00:05:52 +00:00
|
|
|
|
|
|
|
|
// This code that looks for [data-scroll] will eventually be folded
|
|
|
|
|
// into the jqm page processing code when scrollview support is "official"
|
|
|
|
|
// instead of "experimental".
|
|
|
|
|
|
2011-11-04 21:43:27 +00:00
|
|
|
$page.find(":jqmData(scroll):not(.ui-scrollview-clip)").each(function () {
|
|
|
|
|
var $this = $( this );
|
2010-12-01 22:04:54 +00:00
|
|
|
// XXX: Remove this check for ui-scrolllistview once we've
|
|
|
|
|
// integrated list divider support into the main scrollview class.
|
2011-11-04 21:43:27 +00:00
|
|
|
if ( $this.hasClass( "ui-scrolllistview" ) ) {
|
2010-12-01 22:04:54 +00:00
|
|
|
$this.scrolllistview();
|
2011-11-04 21:43:27 +00:00
|
|
|
} else {
|
2011-11-04 21:49:35 +00:00
|
|
|
var st = $this.jqmData("scroll") + "",
|
2011-11-04 21:43:27 +00:00
|
|
|
paging = st && st.search(/^[xy]p$/) != -1;
|
|
|
|
|
dir = st && st.search(/^[xy]/) != -1 ? st.charAt(0) : null,
|
2010-12-01 22:04:54 +00:00
|
|
|
|
2011-11-04 21:43:27 +00:00
|
|
|
opts = {
|
|
|
|
|
direction: dir || undefined,
|
|
|
|
|
paging: paging || undefined,
|
|
|
|
|
scrollMethod: $this.jqmData("scroll-method") || undefined
|
|
|
|
|
};
|
2010-12-15 00:05:52 +00:00
|
|
|
|
2010-12-01 22:04:54 +00:00
|
|
|
$this.scrollview(opts);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
2010-12-15 00:05:52 +00:00
|
|
|
// For the demos, we want to make sure the page being shown has a content
|
|
|
|
|
// area that is sized to fit completely within the viewport. This should
|
|
|
|
|
// also handle the case where pages are loaded dynamically.
|
|
|
|
|
|
2010-11-18 23:12:27 +00:00
|
|
|
ResizePageContentHeight(event.target);
|
|
|
|
|
});
|
|
|
|
|
|
2011-06-08 15:18:05 +00:00
|
|
|
$(window).bind("orientationchange", function(event) {
|
2011-11-04 21:43:27 +00:00
|
|
|
ResizePageContentHeight( $(".ui-page") );
|
|
|
|
|
});
|