Tizen 2.1 base
[platform/framework/web/web-ui-fw.git] / libs / patch / 0009-JQM-Resize-content-in-scrollview.patch
1 From c1aaf9af8c239fa8d6da305a74dcbd355fa65c99 Mon Sep 17 00:00:00 2001
2 From: Lee Wongi <wongi11.lee@samsung.com>
3 Date: Thu, 23 Feb 2012 11:28:27 +0900
4 Subject: [PATCH] JQM Resize content in scrollview.
5
6 Change-Id: If40d512a7d2df0d038013bb6ebc06de90c13d1af
7 ---
8  .../js/jquery.mobile.fixHeaderFooter.js            |  117 +++++++++----------
9  1 files changed, 55 insertions(+), 62 deletions(-)
10
11 diff --git a/libs/js/jquery-mobile-1.0.1pre/js/jquery.mobile.fixHeaderFooter.js b/libs/js/jquery-mobile-1.0.1pre/js/jquery.mobile.fixHeaderFooter.js
12 index 2aa10b5..d05fe11 100644
13 --- a/libs/js/jquery-mobile-1.0.1pre/js/jquery.mobile.fixHeaderFooter.js
14 +++ b/libs/js/jquery-mobile-1.0.1pre/js/jquery.mobile.fixHeaderFooter.js
15 @@ -105,8 +105,7 @@ $.mobile.fixedToolbars = (function() {
16                 // If we are in autoHideMode, we don't do anything because we know the scroll
17                 // callbacks for the plugin will fire off a show when the scrolling has stopped.
18  
19 -
20 -               /* resize test : Jinhyuk    */
21 +               
22                 var footer_filter;
23                 if( $( document ).find( ".ui-page-active" ).length ) 
24                         footer_filter = $( document ).find( ".ui-page-active" ).find( ":jqmData(role='footer')" );              
25 @@ -124,11 +123,38 @@ $.mobile.fixedToolbars = (function() {
26                         footerNavbar
27                                 .css("width", window.innerWidth - footerNavbar.siblings(".ui-btn").width());            
28                 }                                       
29 -               /* resize test : Jinhyuk    */
30  
31 +               // NOTE : by Jinhyuk Jun <jinhyuk.jun@samsung.com>
32 +               //     divide content mode scrollview and non-scrollview
33 +               //     recalculate content area when resize callback occur
34 +
35 +               if(event.type == "resize") /* resize only */
36 +               {
37 +                       var s_theme_header = $( document ).find( ".ui-page-active" ).find( ":jqmData(role='header')" );
38 +                       var s_theme_content = $( document ).find( ".ui-page-active" ).find( ":jqmData(role='content')" );
39 +                       
40 +                       // data-role != "fixed", scrollview=false -> header scroll support
41 +                       if( $.support.scrollview === false && s_theme_header.css("position") != "fixed" ){
42 +                               s_theme_header.css( "position", "relative" );
43 +                               s_theme_content
44 +                                       .css( "top", "0" )
45 +                                       .css( "height", "" );
46 +                       } else if( $.support.scrollview === true ) {
47 +                               if(s_theme_header.css( "position") != "fixed" )
48 +                                       s_theme_header.css( "position", "fixed" );
49 +                                       s_theme_content.css( "top", s_theme_header.height() );
50 +                       }
51 +               
52 +                       // resize content size in case scrollview
53 +                       if( $.support.scrollview === true ) {
54 +                               s_theme_content
55 +                                       .css( "height", document.documentElement.clientHeight - footer_filter.height() - s_theme_header.height());      
56 +                       }
57 +               }
58 +               
59                 if ( !autoHideMode && currentstate === "overlay" ) {
60                         if ( !delayTimer ) {
61 -                               /* Fixed header modify for theme-s : Jinhyuk */
62 +                               /* Fixed header modify for theme-s */
63                                 if(!($( event.target).find( ":jqmData(role='header')" ).is(":jqmData(position='fixed')")&&
64                                 $( event.target).find( ":jqmData(role='header')" ).is(".ui-bar-s")))                            
65                                         $.mobile.fixedToolbars.hide( true );
66 @@ -173,7 +199,7 @@ $.mobile.fixedToolbars = (function() {
67  
68                 ( ( $document.scrollTop() === 0 ) ? $window : $document )
69                         .bind( "scrollstart", function( event ) {
70 -                               /* Fixed header modify for theme-s : Jinhyuk */
71 +                               /* Fixed header modify for theme-s */
72                                 if(!$( event.target).find( ":jqmData(role='header')" ).is(":jqmData(position='fixed')"))
73                                 {
74                                         scrollTriggered = true;
75 @@ -219,7 +245,7 @@ $.mobile.fixedToolbars = (function() {
76  
77         // 1. Before page is shown, check for duplicate footer
78         // 2. After page is shown, append footer to new page
79 -       $( ".ui-page" )  /* Fixed header modify for theme-s : Jinhyuk */
80 +       $( ".ui-page" )  /* Fixed header modify for theme-s */
81                 .live( "pagebeforeshow", function( event, ui ) {                
82                         var s_theme_header = $( event.target ).find( ":jqmData(role='header')" );
83                         var s_theme_fieldcontain = s_theme_header.find( ":jqmData(role='fieldcontain')" );
84 @@ -249,7 +275,7 @@ $.mobile.fixedToolbars = (function() {
85                                         else
86                                                 s_theme_content.addClass( "ui-title-content-option-header-expanded-1line-height" );
87                                 }
88 -                       } else if( s_theme_header.find("input").jqmData("type") == "search" ){ /* In case searchbar in header : Jinhyuk */
89 +                       } else if( s_theme_header.find("input").jqmData("type") == "search" ){
90                                 s_theme_content
91                                         .removeClass( "ui-title-content-" + title_style + "-height" )
92                                         .addClass( "ui-title-content-search" );
93 @@ -280,14 +306,30 @@ $.mobile.fixedToolbars = (function() {
94                                 s_theme_content.addClass( "ui-title-content-" + title_style + "-height" );
95                         }
96  
97 -                       /* resize footer : Jinhyuk    */
98 +                       // NOTE : by Jinhyuk Jun <jinhyuk.jun@samsung.com>
99 +                       //     divide content mode scrollview and non-scrollview
100 +                       //     recalculate content area when resize callback occur
101 +
102 +                       if(event.type == "resize") /* resize only */
103 +                       {
104 +                               // data-role != "fixed", scrollview=false -> header scroll support
105 +                               if( $.support.scrollview === false && s_theme_header.css("position") != "fixed" ){
106 +                                       s_theme_header.css( "position", "relative" );
107 +                                       s_theme_content.css( "top", "0" );
108 +                               } else if( $.support.scrollview === true ){
109 +                                       if( s_theme_header.css("position") != "fixed" )
110 +                                               s_theme_header.css( "position", "fixed" );
111 +                                               s_theme_content.css( "top", s_theme_header.height() );
112 +                               }
113 +                       }
114 +
115                         var footer_filter = $(document).find(":jqmData(role='footer')");
116                         if( footer_filter.find(".ui-navbar").is(".ui-controlbar-s") ){
117                                 footer_filter
118                                         .css( "top", window.innerHeight  - footer_filter.height() )
119                                         .show();
120                         }               
121 -                       /* resize footer : Jinhyuk    */
122 +
123                         if( footer_filter.children().find(".ui-radio").length != 0 ){
124                                 var footerGroup = footer_filter.find( ":jqmData(role='fieldcontain')" );
125                                 var groupLength = footerGroup.find( ".ui-radio" ).length;
126 @@ -337,13 +379,13 @@ $.mobile.fixedToolbars = (function() {
127                                         $( ".dummy-div" ).css( "height", defaultFooterHeight );
128                         }
129  
130 -                       /* Header position fix(remove transition) : Jinhyuk */
131 +                       /* Header position fix(remove transition) */
132                         var next_id = $( event.target ).attr( "id" );
133                         $( "#"+next_id ).find( ":jqmData(role='header')" ).removeClass( "fade in out" ).appendTo( $.mobile.pageContainer );
134                 })
135  
136                 .live( "pageshow", function( event, ui ) {
137 -                       /* Fixed header modify for theme-s : Jinhyuk */
138 +                       /* Fixed header modify for theme-s */
139                         var s_theme_header = $( event.target ).find( ":jqmData(role='header')" );
140                         if( s_theme_header.is(".ui-header-fixed") && s_theme_header.is(".ui-bar-s") ){  
141                                 $( event.target ).find( ":jqmData(role='header')" )
142 @@ -366,49 +408,10 @@ $.mobile.fixedToolbars = (function() {
143  
144                         $.mobile.fixedToolbars.show( true, this );                                      
145  
146 -                       /* Header position fix(remove transition) : Jinhyuk */
147 +                       /* Header position fix(remove transition) */
148                         $("body").children(":jqmData(role='header')").insertBefore($(event.target).find(":jqmData(role='content')").eq(0));
149                 })
150  
151 -               .live( "vclick", function( event, ui ) {
152 -/*
153 -                       var previous_index = $(".ui-page-active").find(":jqmData(role='footer')" ).find(".ui-state-persist").parents("li").index();
154 -                       var active_index = $(event.target).parents("li").index();
155 -                       var navbar_filter = $(".ui-page-active").find(":jqmData(role='footer')" ).find(":jqmData(role='navbar')");
156 -                       var element_count = navbar_filter.find('li').length;
157 -                       var style = navbar_filter.jqmData( "style" );
158 -                       var list_width = $(".ui-page-active").find('.ui-navbar').width()/element_count;
159 -                       
160 -                       var next_link = $(event.target).parents("a").attr("href");
161 -                       
162 -                       
163 -                       $(".ui-page-active").addClass("ui-btn-hide-style");
164 -
165 -
166 -                       if(navbar_filter.find(".ui-btn-animation").length == 0 && style != "toolbar"){                                  
167 -                               $('<div class="ani-focus"></div>').appendTo(navbar_filter.children());
168 -                               $(".ani-focus")
169 -                                       .addClass("ui-btn-animation")   
170 -                                       .removeClass("ui-btn-ani-verticalendposition")
171 -                                       .removeClass("ui-btn-ani-endposition");
172 -
173 -                       }                                       
174 -                               $(".ani-focus")                         
175 -                                       .css("width", navbar_filter.width()/element_count )
176 -                                       .css("height",navbar_filter.css("height"))      
177 -                                       .css("left", previous_index * list_width);
178 -
179 -
180 -                               $(".ui-btn-ani-startposition").css("-webkit-transform","translateX("+previous_index *list_width+")");
181 -                               $(".ani-focus").addClass("ui-btn-ani-startposition");
182 -                               
183 -                               var t=setTimeout("",10);
184 -                               $(".ui-btn-ani-endposition").css("-webkit-transform","translateX("+active_index *list_width+")");
185 -                               $(".ani-focus").removeClass("ui-btn-ani-startposition");
186 -                               $(".ani-focus").addClass("ui-btn-ani-endposition");
187 -*/
188 -               });
189 -               
190  
191         // When a collapsiable is hidden or shown we need to trigger the fixed toolbar to reposition itself (#1635)
192         $( ".ui-collapsible-contain" ).live( "collapse expand", showEventCallback );
193 @@ -497,17 +500,7 @@ $.mobile.fixedToolbars = (function() {
194                                         screenHeight = window.innerHeight,
195                                         thisHeight = el.outerHeight(),
196                                         alreadyVisible = ( el.is( ".ui-header-fixed" ) && fromTop <= thisTop + thisHeight ) ||
197 -                                                                                                               ( el.is( ".ui-footer-fixed" ) && thisTop <= fromTop + screenHeight );
198 -// block blink code in title : Jinhyuk
199 -                               // Add state class
200 -//                             el.addClass( "ui-fixed-overlay" ).removeClass( "ui-fixed-inline" );
201 -
202 -/*                             if ( !alreadyVisible && !immediately ) {
203 -                                       el.animationComplete(function() {
204 -                                               el.removeClass( "in" );
205 -                                       }).addClass( "in" );
206 -                               }*/
207 -//                             setTop(el);
208 +                                                       ( el.is( ".ui-footer-fixed" ) && thisTop <= fromTop + screenHeight );
209                         });
210                 },
211  
212 -- 
213 1.7.0.4
214