1 function collapseHeader() |
1 var collapsed = true; |
2 { |
2 var displayImagesHidden = false; |
3 handleHeaderDisplay( "header_table", "table_initial" ) |
3 var previousPageYOffset = -1; |
4 parent.document.getElementById('headerBody').rows = '10%,*'; |
4 var setScrollPositionInterval; |
|
5 |
|
6 function collapseHeader(sendEvent) { |
|
7 if (sendEvent) { |
|
8 location.href = "cmail://collapseHeader/"; |
|
9 } |
|
10 collapsed = true; |
|
11 handleHeaderDisplay( "header_table", "table_initial" ); |
|
12 updateHeader(); |
5 } |
13 } |
6 |
14 |
7 function expandHeader() |
15 function expandHeader(sendEvent) { |
8 { |
16 if (sendEvent) { |
|
17 location.href = "cmail://expandHeader/"; |
|
18 } |
|
19 collapsed = false; |
9 handleHeaderDisplay( "table_initial", "header_table" ) |
20 handleHeaderDisplay( "table_initial", "header_table" ) |
10 parent.document.getElementById('headerBody').rows = '40%,*'; |
21 parent.document.getElementById('email_frameSet').rows = "40%, *"; |
11 } |
22 } |
12 |
23 |
13 function handleHeaderDisplay( tableToHide, tableToShow ) |
24 function updateHeader() { |
14 { |
25 var rows = "40%, *"; |
|
26 if (collapsed) { |
|
27 if (displayImagesHidden || (parent.header_frame.g_autoLoadImages != 0) || (parent.hiddenCount == 0)) { |
|
28 rows = "10%, *"; |
|
29 } else { |
|
30 rows = "17%, *"; |
|
31 } |
|
32 } |
|
33 parent.document.getElementById('email_frameSet').rows = rows; |
|
34 } |
|
35 |
|
36 function handleHeaderDisplay( tableToHide, tableToShow ) { |
15 document.getElementById(tableToShow).style.display = ""; |
37 document.getElementById(tableToShow).style.display = ""; |
16 document.getElementById(tableToHide).style.display = "none"; |
38 document.getElementById(tableToHide).style.display = "none"; |
17 } |
39 } |
18 |
40 |
19 var intervalHandler; |
41 function init(scrollPos) { |
20 function fetchMoreIfAtBottom() |
42 if (document.getElementById("table_initial").style.display != "none") { |
21 { |
43 collapseHeader(false); |
22 var element = parent.body_frame.document.body; |
44 } else { |
|
45 expandHeader(false); |
|
46 } |
|
47 window.scrollTo(0, scrollPos); |
|
48 setScrollPositionInterval = setInterval("updateScrollPosition()", 500); |
|
49 } |
23 |
50 |
24 if ( element == null ) |
51 function displayImagesButtonPressed() { |
25 { |
52 hideDisplayImagesButton(); |
26 return; |
53 parent.restoreImages("body_frame"); |
27 } |
54 requestDisplayImages(); |
28 |
55 } |
29 var viewport = parent.pageYOffset; |
56 |
30 var elementHeight = element.offsetHeight; |
57 function hideDisplayImagesButton() { |
31 var elementOffsetTop = element.offsetTop; |
58 document.getElementById("displayImagesTable").style.display = "none"; |
32 var screenHeight = screen.availHeight; |
59 displayImagesHidden = true; |
33 if ( elementOffsetTop + elementHeight - viewport < screenHeight ) |
60 updateHeader(); |
34 { |
61 } |
35 location.href = "cmail://body/" + viewport |
62 |
36 clearInterval(intervalHandler); |
63 function showDisplayImagesButton() { |
37 } |
64 document.getElementById("displayImagesTable").style.display = ""; |
|
65 displayImagesHidden = false; |
|
66 updateHeader(); |
|
67 } |
|
68 |
|
69 function requestDisplayImages() { |
|
70 location.href = "cmail://displayImages/"; |
|
71 } |
|
72 |
|
73 function updateScrollPosition() { |
|
74 if (previousPageYOffset != parent.pageYOffset) { |
|
75 previousPageYOffset = parent.pageYOffset; |
|
76 location.href = "cmail://body/" + previousPageYOffset; |
38 } |
77 } |
39 |
78 } |
40 function scrollHandler() |
|
41 { |
|
42 intervalHandler = setInterval( "fetchMoreIfAtBottom()", 500); |
|
43 } |
|
44 |
|
45 function init(scrollPos) |
|
46 { |
|
47 collapseHeader(); |
|
48 window.scrollTo(0, scrollPos); |
|
49 //start a scrolling event which will trigger the check of bottom reached... |
|
50 //this will take care of short document not does not need scrolling |
|
51 scrollHandler(); |
|
52 } |
|
53 |
79 |
54 //onload=init; |
|