mirror of
https://github.com/discourse/discourse.git
synced 2025-03-06 11:19:51 +00:00
FIX: cleanDOM
couldn't be called from url
This commit is contained in:
parent
eeee5f4c08
commit
3bb4e22692
@ -1,4 +1,4 @@
|
|||||||
import { cleanDOM } from 'discourse/routes/discourse';
|
import { cleanDOM } from 'discourse/lib/clean-dom';
|
||||||
import { startPageTracking, onPageChange } from 'discourse/lib/page-tracker';
|
import { startPageTracking, onPageChange } from 'discourse/lib/page-tracker';
|
||||||
import { viewTrackingRequired } from 'discourse/lib/ajax';
|
import { viewTrackingRequired } from 'discourse/lib/ajax';
|
||||||
|
|
||||||
@ -10,10 +10,7 @@ export default {
|
|||||||
// Tell our AJAX system to track a page transition
|
// Tell our AJAX system to track a page transition
|
||||||
const router = container.lookup('router:main');
|
const router = container.lookup('router:main');
|
||||||
router.on('willTransition', viewTrackingRequired);
|
router.on('willTransition', viewTrackingRequired);
|
||||||
|
router.on('didTransition', cleanDOM);
|
||||||
router.on('didTransition', function() {
|
|
||||||
Em.run.scheduleOnce('afterRender', Ember.Route, cleanDOM);
|
|
||||||
});
|
|
||||||
|
|
||||||
startPageTracking(router);
|
startPageTracking(router);
|
||||||
|
|
||||||
|
32
app/assets/javascripts/discourse/lib/clean-dom.js.es6
Normal file
32
app/assets/javascripts/discourse/lib/clean-dom.js.es6
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
function _clean() {
|
||||||
|
if (window.MiniProfiler) {
|
||||||
|
window.MiniProfiler.pageTransition();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Close some elements that may be open
|
||||||
|
$('header ul.icons li').removeClass('active');
|
||||||
|
$('[data-toggle="dropdown"]').parent().removeClass('open');
|
||||||
|
// close the lightbox
|
||||||
|
if ($.magnificPopup && $.magnificPopup.instance) {
|
||||||
|
$.magnificPopup.instance.close();
|
||||||
|
$('body').removeClass('mfp-zoom-out-cur');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove any link focus
|
||||||
|
// NOTE: the '.not("body")' is here to prevent a bug in IE10 on Win7
|
||||||
|
// cf. https://stackoverflow.com/questions/5657371
|
||||||
|
$(document.activeElement).not("body").not(".no-blur").blur();
|
||||||
|
|
||||||
|
Discourse.set('notifyCount',0);
|
||||||
|
Discourse.__container__.lookup('route:application').send('closeModal');
|
||||||
|
const hideDropDownFunction = $('html').data('hide-dropdown');
|
||||||
|
if (hideDropDownFunction) { hideDropDownFunction(); }
|
||||||
|
|
||||||
|
// TODO: Avoid container lookup here
|
||||||
|
const appEvents = Discourse.__container__.lookup('app-events:main');
|
||||||
|
appEvents.trigger('dom:clean');
|
||||||
|
}
|
||||||
|
|
||||||
|
export function cleanDOM() {
|
||||||
|
Ember.run.scheduleOnce('afterRender', _clean);
|
||||||
|
}
|
@ -168,9 +168,6 @@ const DiscourseURL = Ember.Object.extend({
|
|||||||
|
|
||||||
if (this.navigatedToPost(oldPath, path, opts)) { return; }
|
if (this.navigatedToPost(oldPath, path, opts)) { return; }
|
||||||
|
|
||||||
// Schedule a DOM cleanup event
|
|
||||||
Em.run.scheduleOnce('afterRender', Discourse.Route, 'cleanDOM');
|
|
||||||
|
|
||||||
if (oldPath === path) {
|
if (oldPath === path) {
|
||||||
// If navigating to the same path send an app event. Views can watch it
|
// If navigating to the same path send an app event. Views can watch it
|
||||||
// and tell their controllers to refresh
|
// and tell their controllers to refresh
|
||||||
|
@ -74,33 +74,4 @@ const DiscourseRoute = Ember.Route.extend({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
export function cleanDOM() {
|
|
||||||
if (window.MiniProfiler) {
|
|
||||||
window.MiniProfiler.pageTransition();
|
|
||||||
}
|
|
||||||
|
|
||||||
// Close some elements that may be open
|
|
||||||
$('header ul.icons li').removeClass('active');
|
|
||||||
$('[data-toggle="dropdown"]').parent().removeClass('open');
|
|
||||||
// close the lightbox
|
|
||||||
if ($.magnificPopup && $.magnificPopup.instance) {
|
|
||||||
$.magnificPopup.instance.close();
|
|
||||||
$('body').removeClass('mfp-zoom-out-cur');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove any link focus
|
|
||||||
// NOTE: the '.not("body")' is here to prevent a bug in IE10 on Win7
|
|
||||||
// cf. https://stackoverflow.com/questions/5657371
|
|
||||||
$(document.activeElement).not("body").not(".no-blur").blur();
|
|
||||||
|
|
||||||
Discourse.set('notifyCount',0);
|
|
||||||
Discourse.__container__.lookup('route:application').send('closeModal');
|
|
||||||
const hideDropDownFunction = $('html').data('hide-dropdown');
|
|
||||||
if (hideDropDownFunction) { hideDropDownFunction(); }
|
|
||||||
|
|
||||||
// TODO: Avoid container lookup here
|
|
||||||
const appEvents = Discourse.__container__.lookup('app-events:main');
|
|
||||||
appEvents.trigger('dom:clean');
|
|
||||||
}
|
|
||||||
|
|
||||||
export default DiscourseRoute;
|
export default DiscourseRoute;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user