force router refresh and close notice or transcript when clicking on navigation links. Fix #0025933
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/app/instance-initializers/nav-menu.js Thu Feb 23 10:37:22 2017 +0100
@@ -0,0 +1,25 @@
+import Ember from 'ember';
+import ENV from 'app-client/config/environment';
+import URI from 'urijs';
+
+export function initialize(appInstance) {
+ // appInstance.inject('route', 'foo', 'service:foo');
+ const player = appInstance.lookup('service:player');
+ Ember.$(ENV.APP.navigationLinksSelector).click(function(e) {
+ const locHash = window.location.hash;
+ const uri = URI(Ember.$(e.target).prop('href'));
+ Ember.run(() => {
+ // close notice or transcript "window"
+ player.displayMetadata(false);
+ // if we do not navigate, force the router refresh
+ if(locHash === "#"+uri.fragment()) {
+ appInstance.get('router').router.refresh();
+ }
+ });
+ });
+}
+
+export default {
+ name: 'nav-menu',
+ initialize
+};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/cms/app-client/tests/unit/instance-initializers/nav-menu-test.js Thu Feb 23 10:37:22 2017 +0100
@@ -0,0 +1,25 @@
+import Ember from 'ember';
+import { initialize } from 'app-client/instance-initializers/nav-menu';
+import { module, test } from 'qunit';
+import destroyApp from '../../helpers/destroy-app';
+
+module('Unit | Instance Initializer | nav menu', {
+ beforeEach() {
+ Ember.run(() => {
+ this.application = Ember.Application.create();
+ this.appInstance = this.application.buildInstance();
+ });
+ },
+ afterEach() {
+ Ember.run(this.appInstance, 'destroy');
+ destroyApp(this.application);
+ }
+});
+
+// Replace this with your real tests.
+test('it works', function(assert) {
+ initialize(this.appInstance);
+
+ // you would normally confirm the results of the initializer here
+ assert.ok(true);
+});