|
275 | 275 | }, |
276 | 276 |
|
277 | 277 | directHashChange: function( opts ) { |
278 | | - var back , forward, newActiveIndex; |
| 278 | + var back , forward, newActiveIndex, prev = this.getActive(); |
279 | 279 |
|
280 | 280 | // check if url isp in history and if it's ahead or behind current page |
281 | 281 | $.each( urlHistory.stack, function( i, historyEntry ) { |
|
293 | 293 | this.activeIndex = newActiveIndex !== undefined ? newActiveIndex : this.activeIndex; |
294 | 294 |
|
295 | 295 | if( back ) { |
296 | | - opts.isBack(); |
| 296 | + opts.isBack( prev, back ); |
297 | 297 | } else if( forward ) { |
298 | | - opts.isForward(); |
| 298 | + opts.isForward( prev, back ); |
299 | 299 | } |
300 | 300 | }, |
301 | 301 |
|
|
1185 | 1185 | }); |
1186 | 1186 | } ); |
1187 | 1187 |
|
1188 | | - //hashchange event handler |
1189 | | - $window.bind( "hashchange", function( e, triggered ) { |
| 1188 | + $.mobile.handleHashChange = function( hash ) { |
1190 | 1189 | //find first page via hash |
1191 | | - var role, to = path.stripHash( location.hash ), |
| 1190 | + var reverse, role, to = path.stripHash( hash ), |
1192 | 1191 | //transition is false if it's the first page, undefined otherwise (and may be overridden by default) |
1193 | | - transition = $.mobile.urlHistory.stack.length === 0 ? "none" : undefined; |
| 1192 | + transition = $.mobile.urlHistory.stack.length === 0 ? "none" : undefined, |
| 1193 | + |
| 1194 | + changePageOptions = { |
| 1195 | + transition: transition, |
| 1196 | + changeHash: false, |
| 1197 | + fromHashChange: true |
| 1198 | + }; |
1194 | 1199 |
|
1195 | 1200 | //if listening is disabled (either globally or temporarily), or it's a dialog hash |
1196 | 1201 | if( !$.mobile.hashListeningEnabled || urlHistory.ignoreNextHashChange ) { |
|
1215 | 1220 | // prevent changepage |
1216 | 1221 | return; |
1217 | 1222 | } else { |
1218 | | - var setTo = function() { |
| 1223 | + var setTo = function( previousPage, isBack ) { |
1219 | 1224 | var active = $.mobile.urlHistory.getActive(); |
| 1225 | + |
1220 | 1226 | to = active.pageUrl; |
1221 | 1227 | role = active.role; |
| 1228 | + transition = active.transition; |
| 1229 | + reverse = isBack; |
1222 | 1230 | }; |
1223 | 1231 | // if the current active page is a dialog and we're navigating |
1224 | 1232 | // to a dialog use the dialog objected saved in the stack |
|
1229 | 1237 | //if to is defined, load it |
1230 | 1238 | if ( to ) { |
1231 | 1239 | to = ( typeof to === "string" && !path.isPath( to ) ) ? ( '#' + to ) : to; |
1232 | | - $.mobile.changePage( to, { transition: transition, changeHash: false, fromHashChange: true , role: role} ); |
| 1240 | + $.mobile.changePage( to, { transition: transition, changeHash: false, fromHashChange: true , role: role, reverse: reverse } ); |
1233 | 1241 | } |
1234 | 1242 | //there's no hash, go to the first page in the dom |
1235 | 1243 | else { |
1236 | | - $.mobile.changePage( $.mobile.firstPage, { transition: transition, changeHash: false, fromHashChange: true, roll: rolle } ); |
| 1244 | + $.mobile.changePage( $.mobile.firstPage, { transition: transition, changeHash: false, fromHashChange: true, roll: roll, reverse: reverse } ); |
1237 | 1245 | } |
| 1246 | + }; |
| 1247 | + |
| 1248 | + //hashchange event handler |
| 1249 | + $window.bind( "hashchange", function( e, triggered ) { |
| 1250 | + $.mobile.handleHashChange( location.hash ); |
1238 | 1251 | }); |
1239 | 1252 |
|
1240 | 1253 | //set page min-heights to be device specific |
|
0 commit comments