|
293 | 293 | this.activeIndex = newActiveIndex !== undefined ? newActiveIndex : this.activeIndex; |
294 | 294 |
|
295 | 295 | if( back ) { |
296 | | - opts.isBack( prev, back ); |
| 296 | + (opts.either || opts.isBack)( back ); |
297 | 297 | } else if( forward ) { |
298 | | - opts.isForward( prev, back ); |
| 298 | + (opts.either || opts.isForward)( back ); |
299 | 299 | } |
300 | 300 | }, |
301 | 301 |
|
|
1185 | 1185 | }); |
1186 | 1186 | } ); |
1187 | 1187 |
|
1188 | | - $.mobile.handleHashChange = function( hash ) { |
| 1188 | + $.mobile._handleHashChange = function( hash ) { |
1189 | 1189 | //find first page via hash |
1190 | | - var reverse, role, to = path.stripHash( hash ), |
| 1190 | + var to = path.stripHash( hash ), |
1191 | 1191 | //transition is false if it's the first page, undefined otherwise (and may be overridden by default) |
1192 | 1192 | transition = $.mobile.urlHistory.stack.length === 0 ? "none" : undefined, |
1193 | 1193 |
|
| 1194 | + // default options for the changPage calls made after examining the current state |
| 1195 | + // of the page and the hash |
1194 | 1196 | changePageOptions = { |
1195 | 1197 | transition: transition, |
1196 | 1198 | changeHash: false, |
|
1220 | 1222 | // prevent changepage |
1221 | 1223 | return; |
1222 | 1224 | } else { |
1223 | | - var setTo = function( previousPage, isBack ) { |
1224 | | - var active = $.mobile.urlHistory.getActive(); |
1225 | | - |
1226 | | - to = active.pageUrl; |
1227 | | - role = active.role; |
1228 | | - transition = active.transition; |
1229 | | - reverse = isBack; |
1230 | | - }; |
1231 | 1225 | // if the current active page is a dialog and we're navigating |
1232 | 1226 | // to a dialog use the dialog objected saved in the stack |
1233 | | - urlHistory.directHashChange({ currentUrl: to, isBack: setTo, isForward: setTo }); |
| 1227 | + urlHistory.directHashChange({ |
| 1228 | + currentUrl: to, |
| 1229 | + |
| 1230 | + // regardless of the direction of the history change |
| 1231 | + // do the following |
| 1232 | + either: function( isBack ) { |
| 1233 | + var active = $.mobile.urlHistory.getActive(); |
| 1234 | + |
| 1235 | + to = active.pageUrl; |
| 1236 | + |
| 1237 | + // make sure to set the role, transition and reversal |
| 1238 | + // as most of this is lost by the domCache cleaning |
| 1239 | + $.extend( changePageOptions, { |
| 1240 | + role: active.role, |
| 1241 | + transition: active.transition, |
| 1242 | + reverse: isBack |
| 1243 | + }); |
| 1244 | + } |
| 1245 | + }); |
1234 | 1246 | } |
1235 | 1247 | } |
1236 | 1248 |
|
1237 | 1249 | //if to is defined, load it |
1238 | 1250 | if ( to ) { |
1239 | 1251 | to = ( typeof to === "string" && !path.isPath( to ) ) ? ( '#' + to ) : to; |
1240 | | - $.mobile.changePage( to, { transition: transition, changeHash: false, fromHashChange: true , role: role, reverse: reverse } ); |
1241 | | - } |
1242 | | - //there's no hash, go to the first page in the dom |
1243 | | - else { |
1244 | | - $.mobile.changePage( $.mobile.firstPage, { transition: transition, changeHash: false, fromHashChange: true, roll: roll, reverse: reverse } ); |
| 1252 | + $.mobile.changePage( to, changePageOptions ); |
| 1253 | + } else { |
| 1254 | + //there's no hash, go to the first page in the dom |
| 1255 | + $.mobile.changePage( $.mobile.firstPage, changePageOptions ); |
1245 | 1256 | } |
1246 | 1257 | }; |
1247 | 1258 |
|
1248 | 1259 | //hashchange event handler |
1249 | 1260 | $window.bind( "hashchange", function( e, triggered ) { |
1250 | | - $.mobile.handleHashChange( location.hash ); |
| 1261 | + $.mobile._handleHashChange( location.hash ); |
1251 | 1262 | }); |
1252 | 1263 |
|
1253 | 1264 | //set page min-heights to be device specific |
|
0 commit comments