Permalink
Browse files

create content widget, move navigate binding in

  • Loading branch information...
johnbender committed Apr 23, 2013
1 parent 94b59a3 commit 04636aab1f34994ee0773bd05950a406ec539ef7
Showing with 46 additions and 22 deletions.
  1. +4 −1 js/jquery.mobile.init.js
  2. +42 −21 js/jquery.mobile.navigation.js
View
@@ -76,7 +76,10 @@ define([
$.mobile.firstPage = $pages.first();
// define page container
$.mobile.pageContainer = $.mobile.firstPage.parent().addClass( "ui-mobile-viewport" );
$.mobile.pageContainer = $.mobile.firstPage
.parent()
.addClass( "ui-mobile-viewport" )
.content();
// initialize navigation events now, after mobileinit has occurred and the page container
// has been created but before the rest of the library is alerted to that fact
@@ -18,6 +18,48 @@ define( [
//>>excludeEnd("jqmBuildExclude");
(function( $, undefined ) {
$.widget( "mobile.content", $.mobile.widget, {
// element should be the $.mobile.pageContainer
_create: function() {
// TODO roll the logic here into the handleHashChange method
this._on( $window, { navigate: 'filterNavigateEvents' });
// navigate binding using _on
},
filterNavigateEvents: function( e, data ) {
var url;
if ( e.originalEvent && e.originalEvent.isDefaultPrevented() ) {
return;
}
url = $.event.special.navigate.originalEventName.indexOf( "hashchange" ) > -1 ? data.state.hash : data.state.url;
if( !url ) {
url = $.mobile.path.parseLocation().hash;
}
if( !url || url === "#" || url.indexOf( "#" + $.mobile.path.uiStateKey ) === 0 ){
url = location.href;
}
$.mobile._handleHashChange( url, data.state );
}
// handle hashchange
// focus page
// scroll position
// transitionPages
// resetActivePageHeight
// enhancePage
// _bindPageRemove
// enhancePage
// loadPage
// changePage
});
//define vars for interal use
var $window = $.mobile.window,
$head = $( "head" ),
@@ -1361,27 +1403,6 @@ define( [
}
};
// TODO roll the logic here into the handleHashChange method
$window.bind( "navigate", function( e, data ) {
var url;
if ( e.originalEvent && e.originalEvent.isDefaultPrevented() ) {
return;
}
url = $.event.special.navigate.originalEventName.indexOf( "hashchange" ) > -1 ? data.state.hash : data.state.url;
if( !url ) {
url = $.mobile.path.parseLocation().hash;
}
if( !url || url === "#" || url.indexOf( "#" + $.mobile.path.uiStateKey ) === 0 ){
url = location.href;
}
$.mobile._handleHashChange( url, data.state );
});
//set page min-heights to be device specific
$.mobile.document.bind( "pageshow", $.mobile.resetActivePageHeight );
$.mobile.window.bind( "throttledresize", $.mobile.resetActivePageHeight );

0 comments on commit 04636aa

Please sign in to comment.