r114685 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r114684‎ | r114685 | r114686 >
Date:19:07, 3 April 2012
Author:raindrift
Status:deferred
Tags:
Comment:
fixed the jumpy scroll bug with the top (control) navbar
stuck the bottom (stats) navbar to the window
Modified paths:
  • /trunk/extensions/PageTriage/SpecialPageTriage.php (modified) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listControlNav.css (modified) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listControlNav.js (modified) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listStatsNav.css (modified) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listStatsNav.js (modified) (history)
  • /trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listView.js (modified) (history)

Diff [purge]

Index: trunk/extensions/PageTriage/SpecialPageTriage.php
@@ -61,13 +61,15 @@
6262
6363 // This will hold the HTML for the triage interface
6464 $triageInterface = '';
65 -
 65+
6666 $triageInterface .= "<div id='mwe-pt-list-control-nav' class='mwe-pt-navigation-bar mwe-pt-control-gradient'>";
6767 $triageInterface .= "<div id='mwe-pt-list-control-nav-content'></div>";
6868 $triageInterface .= "</div>";
 69+
6970 // TODO: this should load with a spinner instead of "please wait"
7071 $triageInterface .= "<div id='mwe-pt-list-view'>Please wait...</div>";
7172 $triageInterface .= "<div id='mwe-pt-list-stats-nav' class='mwe-pt-navigation-bar mwe-pt-control-gradient'></div>";
 73+ $triageInterface .= "<div id='mwe-pt-list-stats-nav-anchor'></div>";
7274
7375 // These are the templates that backbone/underscore render on the client.
7476 // It would be awesome if they lived in separate files, but we need to figure out how to make RL do that for us.
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listStatsNav.js
@@ -4,20 +4,67 @@
55 mw.pageTriage.ListStatsNav = Backbone.View.extend( {
66 tagName: "div",
77 template: _.template( $( "#listStatsNavTemplate" ).html() ),
 8+ floatNav: false,
89
910 initialize: function( options ) {
 11+ var _this = this;
1012 this.eventBus = options.eventBus;
 13+
 14+ // make a floating bottom navbar
 15+ $.waypoints.settings.scrollThrottle = 30;
 16+ $( '#mwe-pt-list-stats-nav-anchor' ).waypoint( function( event, direction ) {
 17+ if( _this.floatNav ) {
 18+ $( '#mwe-pt-list-stats-nav' ).parent().toggleClass( 'stickyBottom', direction === "up" );
 19+
 20+ _this.resize();
 21+ }
 22+
 23+ event.stopPropagation();
 24+ }, {
 25+ offset: '100%' // bottom of page
 26+ });
 27+
 28+ // do things that need doing on window resize
 29+ $( window ).resize( _.debounce( _this.resize, 100 ) );
 30+
 31+ // when the list view is updated, do this stuff.
 32+ // (mostly, update the floating-ness of the stats bar)
 33+ this.eventBus.bind( "listAddAll", function() {
 34+ _this.render();
 35+ } );
 36+
 37+ // set the navbar's initial size
 38+ this.resize();
 39+
1140 },
1241
1342 render: function() {
1443 // insert the template into the document. fill with the current model.
15 - this.$el.html( this.template( this.model.toJSON() ) );
 44+ $( "#mwe-pt-list-stats-nav").html( this.template( this.model.toJSON() ) );
 45+
 46+ if( $( '#mwe-pt-list-stats-nav-anchor' ).offset().top < $.waypoints('viewportHeight') ) {
 47+ // turn off floating nav, bring the bar back into the list.
 48+ $( '#mwe-pt-list-stats-nav' ).parent().removeClass('stickyBottom');
 49+ this.floatNav = false;
 50+ } else {
 51+ // bottom nav isn't visible. turn on the floating navbar
 52+ $( '#mwe-pt-list-stats-nav' ).parent().addClass('stickyBottom');
 53+ this.floatNav = true;
 54+ }
1655
1756 // broadcast the stats in case any other views want to display bits of them.
1857 // (the control view displays a summary)
1958 this.eventBus.trigger( 'renderStats', this.model );
2059 return this;
21 - }
 60+ },
 61+
 62+ resize: function() {
 63+ // set the width of the floating bar when the window resizes, if it's floating.
 64+ // the left nav is 176 pixels
 65+ // the right margin is 16 pixels
 66+ // border is 2 pixels
 67+ $( '#mwe-pt-list-stats-nav' ).css( 'width', $(window).width() - 176 - 16 - 2 + "px" );
 68+ },
2269
2370 } );
2471 } );
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listControlNav.js
@@ -12,39 +12,33 @@
1313 this.eventBus = options.eventBus; // access the eventBus
1414
1515 // make a floating top navbar
16 - // TODO: there's a bump when the control div detaches from the page.
17 - // fill some element under it to make it scroll smoothly
18 - $( '.top' ).addClass( 'hidden' );
1916 $.waypoints.settings.scrollThrottle = 30;
2017 $( '#mwe-pt-list-control-nav' ).waypoint( function( event, direction ) {
21 - $( this ).parent().toggleClass( 'sticky', direction === "down" );
 18+ $( this ).parent().toggleClass( 'stickyTop', direction === "down" );
 19+
 20+ // pad the element that scrolls under the bar, so it doesn't jump beneath it when the bar
 21+ // changes to fixed positioning.
 22+ if( direction === 'down' ) {
 23+ $( '#mwe-pt-list-view' ).css('padding-top', $( '#mwe-pt-list-control-nav' ).height() );
 24+ } else {
 25+ $( '#mwe-pt-list-view' ).css('padding-top', 0 );
 26+ }
 27+
2228 _this.resize();
2329 event.stopPropagation();
2430 });
2531
2632 // do things that need doing on window resize
27 - // TODO: switch this to use _.debounce() instead
28 - var resizeTimer;
29 - $( window ).resize( function() {
30 - clearTimeout(mw.pageTriage.resizeTimer);
31 - mw.pageTriage.resizeTimer = setTimeout(_this.resize, 100);
32 - });
 33+ $( window ).resize( _.debounce(_this.resize, 100 ) );
3334
3435 this.eventBus.bind( "renderStats", function( stats ) {
3536 // fill in the counter when the stats view gets loaded.
3637 $( "#mwe-pt-control-stats" ).html( gM( 'pagetriage-article-count', stats.get('ptr_untriaged_article_count') ) );
3738 } );
38 -
39 - // hover for the dropdown menu control
40 - /*
41 - $( '#mwe-pt-filter-dropdown-control' ).hover( function() {
42 - _this.toggleFilterMenu();
43 - } );
44 - */
4539 },
4640
4741 render: function() {
48 - _this = this;
 42+ var _this = this;
4943 // render and return the template. fill with the current model.
5044 $( "#mwe-pt-list-control-nav-content").html( this.template( ) );
5145
@@ -63,6 +57,7 @@
6458 } );
6559 $( ".mwe-pt-filter-set-button" ).click( function( e ) {
6660 _this.filterSet();
 61+ _this.toggleFilterMenu();
6762 e.stopPropagation();
6863 } );
6964
@@ -106,7 +101,6 @@
107102
108103 filterSet: function() {
109104 console.log('clicked');
110 - this.toggleFilterMenu();
111105
112106 // fetch the values from the menu
113107 var apiParams = {};
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listView.js
@@ -47,7 +47,7 @@
4848 // add stats data to the navigation
4949 addStats: function( stats ) {
5050 var statsNav = new mw.pageTriage.ListStatsNav( { eventBus: this.eventBus, model: stats } );
51 - $( "#mwe-pt-list-stats-nav").html( statsNav.render().el );
 51+ statsNav.render();
5252 },
5353
5454 // add a single article to the list
@@ -72,6 +72,7 @@
7373 addAll: function() {
7474 $("#mwe-pt-list-view").empty(); // remove the spinner before displaying.
7575 articles.each( this.addOne );
 76+ this.eventBus.trigger( 'listAddAll' );
7677 }
7778
7879 } );
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listStatsNav.css
@@ -1,3 +1,11 @@
22 #mwe-pt-list-stats-nav {
33 border-top: none;
44 }
 5+
 6+.stickyBottom #mwe-pt-list-stats-nav {
 7+ position: fixed;
 8+ bottom: 0;
 9+ left: 160px;
 10+ margin-left: 16px;
 11+ z-index: 1;
 12+}
Index: trunk/extensions/PageTriage/modules/ext.pageTriage.views/ext.pageTriage.listControlNav.css
@@ -6,7 +6,7 @@
77 padding: 0.5em 1em;
88 }
99
10 -.sticky #mwe-pt-list-control-nav {
 10+.stickyTop #mwe-pt-list-control-nav {
1111 position: fixed;
1212 top: 0;
1313 left: 160px;

Status & tagging log