1 | function ResizePageContentHeight(page) |
---|
2 | { |
---|
3 | var $page = $(page); |
---|
4 | var $content = $page.children(".ui-content"); |
---|
5 | var hh = $page.children(".ui-header").outerHeight(); hh = hh ? hh : 0; |
---|
6 | var fh = $page.children(".ui-footer").outerHeight(); fh = fh ? fh : 0; |
---|
7 | var pt = parseFloat($content.css("padding-top")); |
---|
8 | var pb = parseFloat($content.css("padding-bottom")); |
---|
9 | var wh = window.innerHeight; |
---|
10 | $content.height(wh - (hh + fh) - (pt + pb)); |
---|
11 | } |
---|
12 | |
---|
13 | $(":jqmData(role='page')").live("pageshow", function(event) { |
---|
14 | var $page = $(this); |
---|
15 | |
---|
16 | // For the demos that use this script, we want the content area of each |
---|
17 | // page to be scrollable in the 'y' direction. |
---|
18 | |
---|
19 | $page.find(".ui-content").attr("data-"+ $.mobile.ns +"scroll", "y"); |
---|
20 | |
---|
21 | // This code that looks for [data-scroll] will eventually be folded |
---|
22 | // into the jqm page processing code when scrollview support is "official" |
---|
23 | // instead of "experimental". |
---|
24 | |
---|
25 | $page.find(":jqmData(scroll):not(.ui-scrollview-clip)").each(function(){ |
---|
26 | var $this = $(this); |
---|
27 | // XXX: Remove this check for ui-scrolllistview once we've |
---|
28 | // integrated list divider support into the main scrollview class. |
---|
29 | if ($this.hasClass("ui-scrolllistview")) |
---|
30 | $this.scrolllistview(); |
---|
31 | else |
---|
32 | { |
---|
33 | var st = $this.jqmData("scroll") + ""; |
---|
34 | var paging = st && st.search(/^[xy]p$/) != -1; |
---|
35 | var dir = st && st.search(/^[xy]/) != -1 ? st.charAt(0) : null; |
---|
36 | |
---|
37 | var opts = {}; |
---|
38 | if (dir) |
---|
39 | opts.direction = dir; |
---|
40 | if (paging) |
---|
41 | opts.pagingEnabled = true; |
---|
42 | |
---|
43 | var method = $this.jqmData("scroll-method"); |
---|
44 | if (method) |
---|
45 | opts.scrollMethod = method; |
---|
46 | |
---|
47 | $this.scrollview(opts); |
---|
48 | } |
---|
49 | }); |
---|
50 | |
---|
51 | // For the demos, we want to make sure the page being shown has a content |
---|
52 | // area that is sized to fit completely within the viewport. This should |
---|
53 | // also handle the case where pages are loaded dynamically. |
---|
54 | |
---|
55 | ResizePageContentHeight(event.target); |
---|
56 | }); |
---|
57 | |
---|
58 | $(window).bind("orientationchange", function(event) { |
---|
59 | ResizePageContentHeight($(".ui-page")); |
---|
60 | }); |
---|
61 | |
---|
62 | // $().isChildOf |
---|
63 | (function ($) { |
---|
64 | $.fn.extend({ |
---|
65 | isChildOf: function (filter_string) { |
---|
66 | |
---|
67 | var parents = $(this).parents().get(); |
---|
68 | |
---|
69 | for (j = 0; j < parents.length; j++) { |
---|
70 | if ($(parents[j]).is(filter_string)) { |
---|
71 | return true; |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | return false; |
---|
76 | } |
---|
77 | }); |
---|
78 | })(jQuery); |
---|
79 | |
---|
80 | $(function () { |
---|
81 | document.addEventListener('touchmove', function (e) { if (!IsSlider()) { e.preventDefault(); } }, true); |
---|
82 | }); |
---|
83 | |
---|
84 | |
---|
85 | var hd = $.mobile.scrollview.prototype._handleDragStart; |
---|
86 | var hm = $.mobile.scrollview.prototype._handleDragMove; |
---|
87 | var hu = $.mobile.scrollview.prototype._handleDragStop; |
---|
88 | |
---|
89 | function IsSlider(e) { |
---|
90 | var element = $(e); |
---|
91 | return element.hasClass('ui-slider') |
---|
92 | || element.hasClass('noscroll') |
---|
93 | || element.isChildOf('.noscroll'); |
---|
94 | } |
---|
95 | |
---|
96 | $.mobile.scrollview.prototype._handleDragStart = function (e, x, y) { |
---|
97 | if (IsSlider(e.target)) return; |
---|
98 | |
---|
99 | hd.call(this, e, x, y); |
---|
100 | }; |
---|
101 | |
---|
102 | $.mobile.scrollview.prototype._handleDragMove = function (e, x, y) { |
---|
103 | if (IsSlider(e.target)) { |
---|
104 | e.preventDefault(); |
---|
105 | |
---|
106 | return; |
---|
107 | } |
---|
108 | |
---|
109 | hm.call(this, e, x, y); |
---|
110 | }; |
---|
111 | |
---|
112 | $.mobile.scrollview.prototype._handleDragStop = function (e) { |
---|
113 | if (IsSlider(e.target)) return; |
---|
114 | |
---|
115 | hu.call(this, e); |
---|
116 | }; |
---|