mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-04-29 23:43:55 -04:00
BUGFIX: progress bar was hidden when the composer was open - TAKE 2
This commit is contained in:
parent
04e94bec5f
commit
2cb6bec014
4 changed files with 65 additions and 21 deletions
app/assets/javascripts/discourse
|
@ -0,0 +1,11 @@
|
||||||
|
export default {
|
||||||
|
name: "inject-app-events",
|
||||||
|
initialize: function(container, application) {
|
||||||
|
application.register('app-events:main', Discourse.AppEvents, { singleton: true });
|
||||||
|
|
||||||
|
application.inject('controller', 'appEvents', 'app-events:main');
|
||||||
|
application.inject('route', 'appEvents', 'app-events:main');
|
||||||
|
application.inject('view', 'appEvents', 'app-events:main');
|
||||||
|
application.inject('model', 'appEvents', 'app-events:main');
|
||||||
|
}
|
||||||
|
};
|
1
app/assets/javascripts/discourse/lib/app_events.js
Normal file
1
app/assets/javascripts/discourse/lib/app_events.js
Normal file
|
@ -0,0 +1 @@
|
||||||
|
Discourse.AppEvents = Ember.Object.extend(Ember.Evented);
|
|
@ -61,18 +61,17 @@ Discourse.ComposerView = Discourse.View.extend(Ember.Evented, {
|
||||||
movePanels: function(sizePx) {
|
movePanels: function(sizePx) {
|
||||||
$('#main-outlet').css('padding-bottom', sizePx);
|
$('#main-outlet').css('padding-bottom', sizePx);
|
||||||
$('.composer-popup').css('bottom', sizePx);
|
$('.composer-popup').css('bottom', sizePx);
|
||||||
|
// signal the progress bar it should move!
|
||||||
|
this.appEvents.trigger("composer:resized");
|
||||||
},
|
},
|
||||||
|
|
||||||
resize: function() {
|
resize: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
return Em.run.schedule('afterRender', function() {
|
Em.run.scheduleOnce('afterRender', function() {
|
||||||
var $replyControl = $('#reply-control');
|
if (self.movePanels) {
|
||||||
// wait for the transitions
|
var h = $('#reply-control').height() || 0;
|
||||||
$replyControl.on("transitionend", function() {
|
self.movePanels.apply(self, [h + "px"]);
|
||||||
var h = $replyControl.height() || 0;
|
}
|
||||||
var sizePx = "" + h + "px";
|
|
||||||
if (self.movePanels) { self.movePanels(sizePx); }
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}.observes('model.composeState'),
|
}.observes('model.composeState'),
|
||||||
|
|
||||||
|
@ -107,8 +106,12 @@ Discourse.ComposerView = Discourse.View.extend(Ember.Evented, {
|
||||||
},
|
},
|
||||||
|
|
||||||
_enableResizing: function() {
|
_enableResizing: function() {
|
||||||
var $replyControl = $('#reply-control');
|
var $replyControl = $('#reply-control'),
|
||||||
$replyControl.DivResizer({ resize: this.resize, onDrag: this.movePanels });
|
self = this;
|
||||||
|
$replyControl.DivResizer({
|
||||||
|
resize: this.resize,
|
||||||
|
onDrag: function (sizePx) { self.movePanels.apply(self, [sizePx]); }
|
||||||
|
});
|
||||||
Discourse.TransitionHelper.after($replyControl, this.resize);
|
Discourse.TransitionHelper.after($replyControl, this.resize);
|
||||||
this.ensureMaximumDimensionForImagesInPreview();
|
this.ensureMaximumDimensionForImagesInPreview();
|
||||||
}.on('didInsertElement'),
|
}.on('didInsertElement'),
|
||||||
|
@ -203,11 +206,11 @@ Discourse.ComposerView = Discourse.View.extend(Ember.Evented, {
|
||||||
});
|
});
|
||||||
|
|
||||||
// HACK to change the upload icon of the composer's toolbar
|
// HACK to change the upload icon of the composer's toolbar
|
||||||
Em.run.scheduleOnce("afterRender", function() {
|
if (!Discourse.Utilities.allowsAttachments()) {
|
||||||
if (!Discourse.Utilities.allowsAttachments()) {
|
Em.run.scheduleOnce("afterRender", function() {
|
||||||
$("#wmd-image-button").addClass("image-only");
|
$("#wmd-image-button").addClass("image-only");
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
|
|
||||||
this.editor.hooks.insertImageDialog = function(callback) {
|
this.editor.hooks.insertImageDialog = function(callback) {
|
||||||
callback(null);
|
callback(null);
|
||||||
|
@ -402,14 +405,18 @@ Discourse.ComposerView = Discourse.View.extend(Ember.Evented, {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// I hate to use Em.run.later, but I don't think there's a way of waiting for a CSS transition
|
// need to wait a bit for the "slide up" transition of the composer
|
||||||
// to finish.
|
// we could use .on("transitionend") but it's not firing when the transition isn't completed :(
|
||||||
Em.run.later(jQuery, (function() {
|
Em.run.later(function() {
|
||||||
var replyTitle = $('#reply-title');
|
|
||||||
self.resize();
|
self.resize();
|
||||||
self.refreshPreview();
|
self.refreshPreview();
|
||||||
return replyTitle.length ? replyTitle.putCursorAtEnd() : $wmdInput.putCursorAtEnd();
|
if ($replyTitle.length) {
|
||||||
}), 300);
|
$replyTitle.putCursorAtEnd();
|
||||||
|
} else {
|
||||||
|
$wmdInput.putCursorAtEnd();
|
||||||
|
}
|
||||||
|
self.appEvents.trigger("composer:opened");
|
||||||
|
}, 400);
|
||||||
},
|
},
|
||||||
|
|
||||||
addMarkdown: function(text) {
|
addMarkdown: function(text) {
|
||||||
|
@ -442,8 +449,17 @@ Discourse.ComposerView = Discourse.View.extend(Ember.Evented, {
|
||||||
},
|
},
|
||||||
|
|
||||||
childWillDestroyElement: function() {
|
childWillDestroyElement: function() {
|
||||||
$('#main-outlet').css('padding-bottom', 0);
|
var self = this;
|
||||||
|
|
||||||
this._unbindUploadTarget();
|
this._unbindUploadTarget();
|
||||||
|
|
||||||
|
Em.run.next(function() {
|
||||||
|
$('#main-outlet').css('padding-bottom', 0);
|
||||||
|
// need to wait a bit for the "slide down" transition of the composer
|
||||||
|
Em.run.later(function() {
|
||||||
|
self.appEvents.trigger("composer:closed");
|
||||||
|
}, 400);
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
titleValidation: function() {
|
titleValidation: function() {
|
||||||
|
|
|
@ -94,6 +94,11 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
||||||
if ($target.hasClass('mention') || $target.parents('.expanded-embed').length) { return false; }
|
if ($target.hasClass('mention') || $target.parents('.expanded-embed').length) { return false; }
|
||||||
return Discourse.ClickTrack.trackClick(e);
|
return Discourse.ClickTrack.trackClick(e);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
var dockProgressBar = function () { self._dockProgressBar(); };
|
||||||
|
this.appEvents.on("composer:opened", dockProgressBar)
|
||||||
|
.on("composer:resized", dockProgressBar)
|
||||||
|
.on("composer:closed", dockProgressBar);
|
||||||
}.on('didInsertElement'),
|
}.on('didInsertElement'),
|
||||||
|
|
||||||
// This view is being removed. Shut down operations
|
// This view is being removed. Shut down operations
|
||||||
|
@ -108,6 +113,11 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
||||||
|
|
||||||
// this happens after route exit, stuff could have trickled in
|
// this happens after route exit, stuff could have trickled in
|
||||||
this.set('controller.controllers.header.showExtraInfo', false);
|
this.set('controller.controllers.header.showExtraInfo', false);
|
||||||
|
|
||||||
|
// unbind events
|
||||||
|
this.appEvents.off("composer:opened")
|
||||||
|
.off("composer:resized")
|
||||||
|
.off("composer:closed");
|
||||||
}.on('willDestroyElement'),
|
}.on('willDestroyElement'),
|
||||||
|
|
||||||
debounceLoadSuggested: Discourse.debounce(function(){
|
debounceLoadSuggested: Discourse.debounce(function(){
|
||||||
|
@ -172,12 +182,18 @@ Discourse.TopicView = Discourse.View.extend(Discourse.Scrolling, {
|
||||||
}
|
}
|
||||||
|
|
||||||
// dock the counter if necessary
|
// dock the counter if necessary
|
||||||
|
this._dockProgressBar(offset);
|
||||||
|
},
|
||||||
|
|
||||||
|
_dockProgressBar: function (offset) {
|
||||||
var maximumOffset = $('#topic-footer-buttons').offset(),
|
var maximumOffset = $('#topic-footer-buttons').offset(),
|
||||||
composerHeight = $('#reply-control').height() || 0,
|
composerHeight = $('#reply-control').height() || 0,
|
||||||
$topicProgressWrapper = $('#topic-progress-wrapper'),
|
$topicProgressWrapper = $('#topic-progress-wrapper'),
|
||||||
style = $topicProgressWrapper.attr('style') || '',
|
style = $topicProgressWrapper.attr('style') || '',
|
||||||
isDocked = false;
|
isDocked = false;
|
||||||
|
|
||||||
|
offset = offset || window.pageYOffset || $('html').scrollTop();
|
||||||
|
|
||||||
if (maximumOffset) {
|
if (maximumOffset) {
|
||||||
var threshold = maximumOffset.top,
|
var threshold = maximumOffset.top,
|
||||||
windowHeight = $(window).height(),
|
windowHeight = $(window).height(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue