Schedule a `blur` on links when the route changes. Also, convert DOM
cleanup tasks to only schedule once per render.
This commit is contained in:
parent
c0686a6dc6
commit
0b6bd5c187
|
@ -63,6 +63,9 @@ Discourse.URL = Em.Object.createWithMixins({
|
|||
path = path.replace(rootURL, '');
|
||||
}
|
||||
|
||||
// Schedule a DOM cleanup event
|
||||
Em.run.scheduleOnce('afterRender', Discourse.Route, 'cleanDOM');
|
||||
|
||||
// TODO: Extract into rules we can inject into the URL handler
|
||||
if (this.navigatedToHome(oldPath, path)) { return; }
|
||||
if (this.navigatedToListMore(oldPath, path)) { return; }
|
||||
|
|
|
@ -18,21 +18,7 @@ Discourse.Route = Em.Route.extend({
|
|||
**/
|
||||
activate: function() {
|
||||
this._super();
|
||||
|
||||
// Close mini profiler
|
||||
$('.profiler-results .profiler-result').remove();
|
||||
|
||||
// Close some elements that may be open
|
||||
$('.d-dropdown').hide();
|
||||
$('header ul.icons li').removeClass('active');
|
||||
$('[data-toggle="dropdown"]').parent().removeClass('open');
|
||||
// close the lightbox
|
||||
if ($.magnificPopup && $.magnificPopup.instance) { $.magnificPopup.instance.close(); }
|
||||
|
||||
Discourse.set('notifyCount',0);
|
||||
|
||||
var hideDropDownFunction = $('html').data('hide-dropdown');
|
||||
if (hideDropDownFunction) { hideDropDownFunction(); }
|
||||
Em.run.scheduleOnce('afterRender', Discourse.Route, 'cleanDOM');
|
||||
}
|
||||
|
||||
});
|
||||
|
@ -48,6 +34,26 @@ Discourse.Route.reopenClass({
|
|||
};
|
||||
},
|
||||
|
||||
cleanDOM: function() {
|
||||
// Close mini profiler
|
||||
$('.profiler-results .profiler-result').remove();
|
||||
|
||||
// Close some elements that may be open
|
||||
$('.d-dropdown').hide();
|
||||
$('header ul.icons li').removeClass('active');
|
||||
$('[data-toggle="dropdown"]').parent().removeClass('open');
|
||||
// close the lightbox
|
||||
if ($.magnificPopup && $.magnificPopup.instance) { $.magnificPopup.instance.close(); }
|
||||
|
||||
// Remove any link focus
|
||||
$('a').blur();
|
||||
|
||||
Discourse.set('notifyCount',0);
|
||||
|
||||
var hideDropDownFunction = $('html').data('hide-dropdown');
|
||||
if (hideDropDownFunction) { hideDropDownFunction(); }
|
||||
},
|
||||
|
||||
/**
|
||||
Shows a modal
|
||||
|
||||
|
|
Loading…
Reference in New Issue