FIX: Progress bar wasn't showing percentage after 2nd post was made
This commit is contained in:
parent
f87fc98411
commit
fe18bdbcfb
|
@ -16,10 +16,10 @@
|
||||||
label="topic.progress.go_bottom"}}
|
label="topic.progress.go_bottom"}}
|
||||||
</nav>
|
</nav>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<nav id='topic-progress' title="{{i18n 'topic.progress.title'}}" {{bind-attr class="hideProgress:hidden"}}>
|
<nav id='topic-progress' title="{{i18n 'topic.progress.title'}}" class="{{if hideProgress 'hidden'}}">
|
||||||
<div class='nums'>
|
<div class='nums'>
|
||||||
<h4>{{progressPosition}}</h4><span {{bind-attr class="hugeNumberOfPosts:hidden"}}> <span>/</span> <h4>{{model.postStream.filteredPostsCount}}</h4></span>
|
<h4>{{progressPosition}}</h4><span class="{{if hugeNumberOfPosts 'hidden'}}"> <span>/</span> <h4>{{model.postStream.filteredPostsCount}}</h4></span>
|
||||||
</div>
|
</div>
|
||||||
<i {{bind-attr class=":fa expanded::fa-sort"}}></i>
|
<i class="fa {{if expanded 'fa-sort'}}"></i>
|
||||||
<div class='bg'> </div>
|
<div class='bg'> </div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -4,11 +4,6 @@ export default Ember.View.extend({
|
||||||
classNameBindings: ['docked'],
|
classNameBindings: ['docked'],
|
||||||
|
|
||||||
_inserted: function() {
|
_inserted: function() {
|
||||||
// This get seems counter intuitive, but it's to trigger the observer on
|
|
||||||
// the streamPercentage for this view. Otherwise the process bar does not
|
|
||||||
// update.
|
|
||||||
this.get('controller.streamPercentage');
|
|
||||||
|
|
||||||
this.appEvents.on("composer:opened", this, '_dock')
|
this.appEvents.on("composer:opened", this, '_dock')
|
||||||
.on("composer:resized", this, '_dock')
|
.on("composer:resized", this, '_dock')
|
||||||
.on("composer:closed", this, '_dock')
|
.on("composer:closed", this, '_dock')
|
||||||
|
@ -17,7 +12,6 @@ export default Ember.View.extend({
|
||||||
// Reflows are expensive. Cache the jQuery selector
|
// Reflows are expensive. Cache the jQuery selector
|
||||||
// and the width when inserted into the DOM
|
// and the width when inserted into the DOM
|
||||||
this._$topicProgress = this.$('#topic-progress');
|
this._$topicProgress = this.$('#topic-progress');
|
||||||
this._progressWidth = this._$topicProgress[0].offsetWidth;
|
|
||||||
}.on('didInsertElement'),
|
}.on('didInsertElement'),
|
||||||
|
|
||||||
_unbindEvents: function() {
|
_unbindEvents: function() {
|
||||||
|
@ -29,28 +23,31 @@ export default Ember.View.extend({
|
||||||
|
|
||||||
_updateBar: function() {
|
_updateBar: function() {
|
||||||
Em.run.scheduleOnce('afterRender', this, '_updateProgressBar');
|
Em.run.scheduleOnce('afterRender', this, '_updateProgressBar');
|
||||||
}.observes('controller.streamPercentage', 'controller.model.postStream.stream.@each'),
|
}.observes('controller.streamPercentage', 'controller.model.postStream.stream.@each').on('init'),
|
||||||
|
|
||||||
_updateProgressBar: function() {
|
_updateProgressBar: function() {
|
||||||
// speeds up stuff, bypass jquery slowness and extra checks
|
// speeds up stuff, bypass jquery slowness and extra checks
|
||||||
var totalWidth = this._progressWidth,
|
if (!this._totalWidth) {
|
||||||
progressWidth = this.get('controller.streamPercentage') * totalWidth;
|
this._totalWidth = this._$topicProgress[0].offsetWidth;
|
||||||
|
}
|
||||||
|
const totalWidth = this._totalWidth;
|
||||||
|
const progressWidth = this.get('controller.streamPercentage') * totalWidth;
|
||||||
|
|
||||||
this._$topicProgress.find('.bg')
|
this._$topicProgress.find('.bg')
|
||||||
.css("border-right-width", (progressWidth === totalWidth) ? "0px" : "1px")
|
.css("border-right-width", (progressWidth === totalWidth) ? "0px" : "1px")
|
||||||
.width(progressWidth);
|
.width(progressWidth);
|
||||||
},
|
},
|
||||||
|
|
||||||
_dock: function () {
|
_dock() {
|
||||||
var maximumOffset = $('#topic-footer-buttons').offset(),
|
const maximumOffset = $('#topic-footer-buttons').offset(),
|
||||||
composerHeight = $('#reply-control').height() || 0,
|
composerHeight = $('#reply-control').height() || 0,
|
||||||
$topicProgressWrapper = this.$(),
|
$topicProgressWrapper = this.$(),
|
||||||
style = $topicProgressWrapper.attr('style') || '',
|
style = $topicProgressWrapper.attr('style') || '',
|
||||||
isDocked = false,
|
|
||||||
offset = window.pageYOffset || $('html').scrollTop();
|
offset = window.pageYOffset || $('html').scrollTop();
|
||||||
|
|
||||||
|
let isDocked = false;
|
||||||
if (maximumOffset) {
|
if (maximumOffset) {
|
||||||
var threshold = maximumOffset.top,
|
const threshold = maximumOffset.top,
|
||||||
windowHeight = $(window).height(),
|
windowHeight = $(window).height(),
|
||||||
topicProgressHeight = $('#topic-progress').height();
|
topicProgressHeight = $('#topic-progress').height();
|
||||||
|
|
||||||
|
@ -63,7 +60,7 @@ export default Ember.View.extend({
|
||||||
$topicProgressWrapper.css('bottom', '');
|
$topicProgressWrapper.css('bottom', '');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var height = composerHeight + "px";
|
const height = composerHeight + "px";
|
||||||
if ($topicProgressWrapper.css('bottom') !== height) {
|
if ($topicProgressWrapper.css('bottom') !== height) {
|
||||||
$topicProgressWrapper.css('bottom', height);
|
$topicProgressWrapper.css('bottom', height);
|
||||||
}
|
}
|
||||||
|
@ -84,21 +81,21 @@ export default Ember.View.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.get('controller.expanded')) {
|
if (this.get('controller.expanded')) {
|
||||||
var self = this;
|
const self = this;
|
||||||
Em.run.schedule('afterRender', function() {
|
Em.run.schedule('afterRender', function() {
|
||||||
self.$('input').focus();
|
self.$('input').focus();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}.observes('controller.expanded'),
|
}.observes('controller.expanded'),
|
||||||
|
|
||||||
click: function(e) {
|
click(e) {
|
||||||
if ($(e.target).parents('#topic-progress').length) {
|
if ($(e.target).parents('#topic-progress').length) {
|
||||||
this.get('controller').send('toggleExpansion');
|
this.get('controller').send('toggleExpansion');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
keyDown: function(e) {
|
keyDown(e) {
|
||||||
var controller = this.get('controller');
|
const controller = this.get('controller');
|
||||||
if (controller.get('expanded')) {
|
if (controller.get('expanded')) {
|
||||||
if (e.keyCode === 13) {
|
if (e.keyCode === 13) {
|
||||||
controller.send('jumpPost');
|
controller.send('jumpPost');
|
||||||
|
|
Loading…
Reference in New Issue