From 0311c91f38e4d37681419f73cbdad4b2f2e49863 Mon Sep 17 00:00:00 2001 From: "Eddie Monge Jr." Date: Fri, 4 Nov 2011 14:43:27 -0700 Subject: [PATCH 1/3] code style cleanup --- experiments/scrollview/scrollview.js | 50 ++++++++++++---------------- 1 file changed, 22 insertions(+), 28 deletions(-) diff --git a/experiments/scrollview/scrollview.js b/experiments/scrollview/scrollview.js index eb6cb020..7ec2834f 100644 --- a/experiments/scrollview/scrollview.js +++ b/experiments/scrollview/scrollview.js @@ -1,48 +1,42 @@ -function ResizePageContentHeight(page) -{ +function ResizePageContentHeight(page) { var $page = $(page); - var $content = $page.children(".ui-content"); - var hh = $page.children(".ui-header").outerHeight(); hh = hh ? hh : 0; - var fh = $page.children(".ui-footer").outerHeight(); fh = fh ? fh : 0; - var pt = parseFloat($content.css("padding-top")); - var pb = parseFloat($content.css("padding-bottom")); - var wh = window.innerHeight; + $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; $content.height(wh - (hh + fh) - (pt + pb)); } $(":jqmData(role='page')").live("pageshow", function(event) { - var $page = $(this); + var $page = $( this ); // For the demos that use this script, we want the content area of each // page to be scrollable in the 'y' direction. - $page.find(".ui-content").attr("data-"+ $.mobile.ns +"scroll", "y"); + $page.find( ".ui-content" ).attr( "data-" + $.mobile.ns + "scroll", "y" ); // 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". - $page.find(":jqmData(scroll):not(.ui-scrollview-clip)").each(function(){ - var $this = $(this); + $page.find(":jqmData(scroll):not(.ui-scrollview-clip)").each(function () { + var $this = $( this ); // XXX: Remove this check for ui-scrolllistview once we've // integrated list divider support into the main scrollview class. - if ($this.hasClass("ui-scrolllistview")) + if ( $this.hasClass( "ui-scrolllistview" ) ) { $this.scrolllistview(); - else - { + } else { var st = $this.jqmData("scroll") + ""; - var paging = st && st.search(/^[xy]p$/) != -1; - var dir = st && st.search(/^[xy]/) != -1 ? st.charAt(0) : null; + paging = st && st.search(/^[xy]p$/) != -1; + dir = st && st.search(/^[xy]/) != -1 ? st.charAt(0) : null, - var opts = {}; - if (dir) - opts.direction = dir; - if (paging) - opts.pagingEnabled = true; - - var method = $this.jqmData("scroll-method"); - if (method) - opts.scrollMethod = method; + opts = { + direction: dir || undefined, + paging: paging || undefined, + scrollMethod: $this.jqmData("scroll-method") || undefined + }; $this.scrollview(opts); } @@ -56,5 +50,5 @@ $(":jqmData(role='page')").live("pageshow", function(event) { }); $(window).bind("orientationchange", function(event) { - ResizePageContentHeight($(".ui-page")); -}); + ResizePageContentHeight( $(".ui-page") ); +}); \ No newline at end of file From e56a382c3f4f90c48b72eee794ee96891e42e33d Mon Sep 17 00:00:00 2001 From: "Eddie Monge Jr." Date: Fri, 4 Nov 2011 14:49:35 -0700 Subject: [PATCH 2/3] Update experiments/scrollview/scrollview.js --- experiments/scrollview/scrollview.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/experiments/scrollview/scrollview.js b/experiments/scrollview/scrollview.js index 7ec2834f..497cb814 100644 --- a/experiments/scrollview/scrollview.js +++ b/experiments/scrollview/scrollview.js @@ -28,7 +28,7 @@ $(":jqmData(role='page')").live("pageshow", function(event) { if ( $this.hasClass( "ui-scrolllistview" ) ) { $this.scrolllistview(); } else { - var st = $this.jqmData("scroll") + ""; + var st = $this.jqmData("scroll") + "", paging = st && st.search(/^[xy]p$/) != -1; dir = st && st.search(/^[xy]/) != -1 ? st.charAt(0) : null, From 2663f95892bbdad33478b039c9d9f385d3949622 Mon Sep 17 00:00:00 2001 From: "Eddie Monge Jr." Date: Sun, 6 Nov 2011 15:09:11 -0800 Subject: [PATCH 3/3] Update experiments/scrollview/scrollview.js --- experiments/scrollview/scrollview.js | 29 ++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/experiments/scrollview/scrollview.js b/experiments/scrollview/scrollview.js index 497cb814..f033c784 100644 --- a/experiments/scrollview/scrollview.js +++ b/experiments/scrollview/scrollview.js @@ -1,15 +1,16 @@ function ResizePageContentHeight(page) { - var $page = $(page); - $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")); + var $page = $(page), + $content = $page.children( ".ui-content" ), + hh = $page.children( ".ui-header" ).outerHeight() : 0, + fh = $page.children( ".ui-footer" ).outerHeight() : 0, + pt = parseFloat($content.css( "padding-top" )), + pb = parseFloat($content.css( "padding-bottom" )), wh = window.innerHeight; + $content.height(wh - (hh + fh) - (pt + pb)); } -$(":jqmData(role='page')").live("pageshow", function(event) { +$( ":jqmData(role='page')" ).live( "pageshow", function(event) { var $page = $( this ); // For the demos that use this script, we want the content area of each @@ -21,15 +22,15 @@ $(":jqmData(role='page')").live("pageshow", function(event) { // into the jqm page processing code when scrollview support is "official" // instead of "experimental". - $page.find(":jqmData(scroll):not(.ui-scrollview-clip)").each(function () { + $page.find( ":jqmData(scroll):not(.ui-scrollview-clip)" ).each(function () { var $this = $( this ); // XXX: Remove this check for ui-scrolllistview once we've // integrated list divider support into the main scrollview class. if ( $this.hasClass( "ui-scrolllistview" ) ) { $this.scrolllistview(); } else { - var st = $this.jqmData("scroll") + "", - paging = st && st.search(/^[xy]p$/) != -1; + var st = $this.jqmData( "scroll" ) + "", + paging = st && st.search(/^[xy]p$/) != -1, dir = st && st.search(/^[xy]/) != -1 ? st.charAt(0) : null, opts = { @@ -38,7 +39,7 @@ $(":jqmData(role='page')").live("pageshow", function(event) { scrollMethod: $this.jqmData("scroll-method") || undefined }; - $this.scrollview(opts); + $this.scrollview( opts ); } }); @@ -46,9 +47,9 @@ $(":jqmData(role='page')").live("pageshow", function(event) { // area that is sized to fit completely within the viewport. This should // also handle the case where pages are loaded dynamically. - ResizePageContentHeight(event.target); + ResizePageContentHeight( event.target ); }); -$(window).bind("orientationchange", function(event) { - ResizePageContentHeight( $(".ui-page") ); +$( window ).bind( "orientationchange", function( event ) { + ResizePageContentHeight( $( ".ui-page" ) ); }); \ No newline at end of file