https://www.mediawiki.org/wiki/Special:Code/MediaWiki/114785
Revision: 114785
Author: raindrift
Date: 2012-04-06 23:08:08 +0000 (Fri, 06 Apr 2012)
Log Message:
-----------
fixed bugs i introduced in sticky bars, that are triggered by loading more
articles
Modified Paths:
--------------
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listControlNav.js
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listStatsNav.js
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listView.js
Modified:
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listControlNav.js
===================================================================
---
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listControlNav.js
2012-04-06 23:06:13 UTC (rev 114784)
+++
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listControlNav.js
2012-04-06 23:08:08 UTC (rev 114785)
@@ -12,24 +12,9 @@
var _this = this;
this.eventBus = options.eventBus; // access the eventBus
-
- // make a floating top navbar
- $.waypoints.settings.scrollThrottle = 30;
- $( '#mwe-pt-list-control-nav' ).waypoint( function(
event, direction ) {
- $( this ).parent().toggleClass( 'stickyTop',
direction === "down" );
-
- // pad the element that scrolls under the bar,
so it doesn't jump beneath it when the bar
- // changes to fixed positioning.
- if( direction === 'down' ) {
- $( '#mwe-pt-list-view'
).css('padding-top', $( '#mwe-pt-list-control-nav' ).height() );
- } else {
- $( '#mwe-pt-list-view'
).css('padding-top', 0 );
- }
-
- _this.resize();
- event.stopPropagation();
- });
+ this.setWaypoint();
+
// do things that need doing on window resize
$( window ).resize( _.debounce(_this.resize, 100 ) );
@@ -38,6 +23,10 @@
$( "#mwe-pt-control-stats" ).html( gM(
'pagetriage-article-count', stats.get('ptr_unreviewed_article_count') ) );
} );
+ this.eventBus.bind( 'articleListChange', function() {
+ _this.setWaypoint();
+ } );
+
// update the filter display on load.
this.menuSync();
},
@@ -91,6 +80,38 @@
} );
},
+ setWaypoint: function() {
+ // make a floating top navbar
+ $( '#mwe-pt-list-control-nav' ).waypoint('destroy');
// remove the old, maybe inaccurate ones.
+ var _this = this;
+ $.waypoints.settings.scrollThrottle = 30;
+ $( '#mwe-pt-list-control-nav' ).waypoint( function(
event, direction ) {
+ $( this ).parent().toggleClass( 'stickyTop',
direction === "down" );
+
+ // pad the element that scrolls under the bar,
so it doesn't jump beneath it when the bar
+ // changes to fixed positioning.
+ if( direction === 'down' ) {
+ $( '#mwe-pt-list-view'
).css('padding-top', $( '#mwe-pt-list-control-nav' ).height() );
+ } else {
+ $( '#mwe-pt-list-view'
).css('padding-top', 0 );
+ }
+
+ _this.resize();
+ event.stopPropagation();
+ } );
+
+ //$.waypoints('refresh'); // this ends up happening a
lot. :(
+ if( $( '#mwe-pt-list-view' ).offset().top >
$('body').scrollTop() ) {
+ // turn off floating nav, bring the bar back
into the list.
+ $( '#mwe-pt-list-control-nav'
).parent().removeClass('stickyTop');
+ this.floatNav = false;
+ } else {
+ // top nav isn't visible. turn on the floating
navbar
+ $( '#mwe-pt-list-control-nav'
).parent().addClass('stickyTop');
+ this.floatNav = true;
+ }
+ },
+
resize: function() {
// set the width of the floating bar when the window
resizes, if it's floating.
// the left nav is 176 pixels
Modified:
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listStatsNav.js
===================================================================
---
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listStatsNav.js
2012-04-06 23:06:13 UTC (rev 114784)
+++
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listStatsNav.js
2012-04-06 23:08:08 UTC (rev 114785)
@@ -30,18 +30,28 @@
// when the list view is updated, do this stuff.
// (mostly, update the floating-ness of the stats bar)
this.eventBus.bind( "articleListChange", function() {
- _this.render();
+ _this.setPosition();
} );
// set the navbar's initial size
this.resize();
+ $.waypoints('refresh');
},
render: function() {
// insert the template into the document. fill with
the current model.
$( "#mwe-pt-list-stats-nav-content" ).html(
this.template( this.model.toJSON() ) );
-
+
+ this.setPosition();
+
+ // broadcast the stats in case any other views want to
display bits of them.
+ // (the control view displays a summary)
+ this.eventBus.trigger( 'renderStats', this.model );
+ return this;
+ },
+
+ setPosition: function() {
if( $( '#mwe-pt-list-stats-nav-anchor' ).offset().top <
$.waypoints('viewportHeight') ) {
// turn off floating nav, bring the bar back
into the list.
$( '#mwe-pt-list-stats-nav'
).parent().removeClass('stickyBottom');
@@ -51,11 +61,6 @@
$( '#mwe-pt-list-stats-nav'
).parent().addClass('stickyBottom');
this.floatNav = true;
}
-
- // broadcast the stats in case any other views want to
display bits of them.
- // (the control view displays a summary)
- this.eventBus.trigger( 'renderStats', this.model );
- return this;
},
resize: function() {
Modified:
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listView.js
===================================================================
---
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listView.js
2012-04-06 23:06:13 UTC (rev 114784)
+++
trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listView.js
2012-04-06 23:08:08 UTC (rev 114785)
@@ -27,7 +27,7 @@
//articles.bind( 'all', this.render, this );
// bind manualLoadMore function to 'More' link
- _this = this;
+ var _this = this;
$( '#mwe-pt-list-more-link' ).click( function() {
_this.manualLoadMore();
return false;
@@ -48,7 +48,7 @@
initializeInfiniteScrolling: function() {
// make the article list infinitely scrolling
- _this = this;
+ var _this = this;
var $anchor = $( '#mwe-pt-list-load-more-anchor' );
opts = { offset: '100%' };
$anchor.waypoint( function( event, direction ) {
@@ -67,10 +67,10 @@
success: function() {
$( '.mwe-pt-article-row' ).last().css(
'border-bottom', 'none' );
$.waypoints( 'refresh' );
+ _this.eventBus.trigger(
"articleListChange" );
if ( !articles.moreToLoad ) {
$(
'#mwe-pt-list-load-more-anchor' ).waypoint( 'destroy' );
}
- _this.eventBus.trigger(
"articleListChange" );
}
} );
},
_______________________________________________
MediaWiki-CVS mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs