cms/app-client/app/instance-initializers/nav-menu.js
author ymh <ymh.work@gmail.com>
Mon, 19 Mar 2018 15:45:08 +0100
changeset 569 2815e71c65fb
parent 522 c6cad1055714
permissions -rw-r--r--
corrcet https vs http for title image + avoid unused update route on api

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
};