@ -15,8 +15,8 @@ define('forum/category', [
] , function ( infinitescroll , share , navigator , categoryTools , sort , components , translator , topicSelect , pagination , storage ) {
var Category = { } ;
$ ( window ) . on ( 'action:ajaxify. start ', function ( ev , data ) {
if ( ajaxify. currentPage !== data . url ) {
$ ( window ) . on ( 'action:ajaxify. end ', function ( ev , data ) {
if ( data. tpl _url !== 'category' ) {
navigator . disable ( ) ;
removeListeners ( ) ;
@ -113,11 +113,14 @@ define('forum/category', [
return bottomIndex ;
} ;
$ ( window ) . on ( 'action: ajaxify.contentLoaded ', function ( ) {
$ ( window ) . on ( 'action: popstate ', function ( ) {
if ( ajaxify . data . template . category && ajaxify . data . cid ) {
var bookmarkIndex = storage . getItem ( 'category:' + ajaxify . data . cid + ':bookmark' ) ;
var clickedIndex = storage . getItem ( 'category:' + ajaxify . data . cid + ':bookmark:clicked' ) ;
storage . removeItem ( 'category:' + ajaxify . data . cid + ':bookmark' ) ;
storage . removeItem ( 'category:' + ajaxify . data . cid + ':bookmark:clicked' ) ;
bookmarkIndex = Math . max ( 0 , parseInt ( bookmarkIndex , 10 ) || 0 ) ;
clickedIndex = Math . max ( 0 , parseInt ( clickedIndex , 10 ) || 0 ) ;
if ( ! parseInt ( bookmarkIndex , 10 ) ) {
@ -128,10 +131,10 @@ define('forum/category', [
var page = Math . ceil ( ( parseInt ( bookmarkIndex , 10 ) + 1 ) / config . topicsPerPage ) ;
if ( parseInt ( page , 10 ) !== ajaxify . data . pagination . currentPage ) {
pagination . loadPage ( page , function ( ) {
Category . scrollToTopic ( bookmarkIndex , clickedIndex , 40 0) ;
Category . scrollToTopic ( bookmarkIndex , clickedIndex , 0) ;
} ) ;
} else {
Category . scrollToTopic ( bookmarkIndex , clickedIndex , 40 0) ;
Category . scrollToTopic ( bookmarkIndex , clickedIndex , 0) ;
}
} else {
if ( bookmarkIndex === 0 ) {