cms/app-client/app/instance-initializers/nav-menu.js
author ymh <ymh.work@gmail.com>
Mon, 12 Jun 2017 14:59:37 +0200
changeset 538 0454014a4bb6
parent 522 c6cad1055714
permissions -rw-r--r--
new version 0.0.20 and small doc improvement

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