Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #162 from ryandv/scroll_up_on_hide_reviews
Browse files Browse the repository at this point in the history
Scroll up on hide reviews
  • Loading branch information
divad12 committed Apr 20, 2014
2 parents 7c714fe + 71001d8 commit e5461b9
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 25 deletions.
63 changes: 38 additions & 25 deletions server/static/js/prof.js
Expand Up @@ -135,36 +135,49 @@ function($, _, _s, bootstrap, jqSlide, RmcBackbone, ratings, util, review) {
return Math.max(this.numReviews() - this.numShown);
},

// TODO(mack): refactor this mess
toggleExpand: function() {
if (!this.firstExpanded) {
this._loadReviews();
} else if (this.expanded) {
this._collapseReviews();
} else {
this._expandReviews();
}
},

var toggle = _.bind(function() {
if (this.expanded) {
this.$('.expanded-reviews').fancySlide('up');
this.$('.toggle-reviews')
.html('See ' + this.numHidden() + ' more ' +
util.pluralize(this.numHidden(), 'review') + ' »');
} else {
this.$('.expanded-reviews').fancySlide('down');
this.$('.toggle-reviews').html('« Hide reviews');
}
this.expanded = !this.expanded;
}, this);
_loadReviews: function() {
this.firstExpanded = true;
this.$('.toggle-reviews').text('Loading...');
window.setTimeout(_.bind(function() {
this.profReviewCollectionView.render(false);

if (!this.firstExpanded) {
this.firstExpanded = true;
this.$('.toggle-reviews').text('Loading...');
window.setTimeout(_.bind(function() {
this.profReviewCollectionView.render(false);
this.$('.review-post').slice(this.numShown)
.wrapAll('<div class="expanded-reviews hide-initial">');

this._expandReviews();
}, this), 100);
},

this.$('.review-post').slice(this.numShown)
.wrapAll('<div class="expanded-reviews hide-initial">');
_collapseReviews: function() {
var profCardTop = this.$('.expandable-prof').offset().top;
var navBarHeight = $("#site-nav").height();
var margin = 16;

toggle();
}, this), 100);
} else {
toggle();
}
$('html,body').animate({
scrollTop: profCardTop - navBarHeight - margin
}, 300);

this.$('.expanded-reviews').fancySlide('up');
this.$('.toggle-reviews')
.html('See ' + this.numHidden() + ' more ' +
util.pluralize(this.numHidden(), 'review') + ' &raquo;');
this.expanded = false;
},

_expandReviews: function() {
this.$('.expanded-reviews').fancySlide('down');
this.$('.toggle-reviews').html('&laquo; Hide reviews');
this.expanded = true;
}
});

Expand Down
9 changes: 9 additions & 0 deletions server/templates/about_page.html
Expand Up @@ -294,6 +294,15 @@ <h1>Contributors</h1>
contributions
</a>
</li>
<li>
<a target="_blank" href="https://github.com/ryandv">
Ryan De Villa
</a> &mdash;
<a target="_blank"
href="https://github.com/UWFlow/rmc/commits/master?author=ryandv">
contributions
</a>
</li>
</ul>

<h1 class="sponsors-heading">Thank you sponsors</h1>
Expand Down

0 comments on commit e5461b9

Please sign in to comment.