<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:meta="http://xml.zope.org/namespaces/meta"
      meta:interpolation="true"
      i18n:domain="nuplone"
      tal:define="tools context/@@tools; factories view/factories">
  <head tal:define="style_url tools/portal/++resource++NuPlone.style">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <script type="text/javascript" src="${tools/portal/++resource++NuPlone.libraries}/css_browser_selector.js"></script>
    <link rel="stylesheet" type="text/css" media="all" href="${style_url}/main/base.css" />
    <!--[if IE 6]> <link rel="stylesheet" type="text/css" media="screen" href="${style_url}/main/base-ie6.css" /> <![endif]-->
    <!--[if IE 7]> <link rel="stylesheet" type="text/css" media="screen" href="${style_url}/main/base-ie7.css" /> <![endif]-->
    <!--[if IE 8]> <link rel="stylesheet" type="text/css" media="screen" href="${style_url}/main/base-ie8.css" /> <![endif]-->
    <title i18n:translate="title_site_menu">Site menu</title>
    <base target="_parent"/>
  </head>
  <body class="siteMenu">
    <ul class="menu" id="siteMenu">
      <li id="user" tal:condition="tools/anonymous">
        <a href="${tools/navroot_url}/@@login?came_from=${request/environ/HTTP_REFERER|context/absolute_url}" i18n:translate="menu_login">Login</a>
      </li>
      <li id="user" tal:condition="not:tools/anonymous">
      <a href="${view/settings_url}">${python:tools.user.getProperty('fullname', '') or tools.user.getUserName()}</a>
        <ul>
          <li>
            <ul>
              <li>
                <a href="${tools/portal_url}/@@logout" i18n:translate="menu_logout">Log out</a>
              </li>
              <li>
                <a href="${view/settings_url}" i18n:translate="menu_settings">Settings</a>
              </li>
            </ul>
          </li>
        </ul>
      </li>
      <tal:block condition="python:view.view_type=='view' and view.actions">
        <li tal:define="menu view/actions">
          <a class="contextActions" href="${menu/url|string:#}">${menu/title}</a>
          <ul>
            <li tal:repeat="submenu menu/children">${submenu/title}
              <ul>
                <li tal:repeat="entry submenu/children"><a href="${entry/url}" title="${entry/description|nothing}">${entry/title}</a></li>
              </ul>
            </li>
          </ul>
        </li>
        <li tal:condition="permission:Modify portal content">
          <a href="${context/absolute_url}/@@edit" i18n:translate="menu_edit">Edit</a>
        </li>
      </tal:block>
    </ul>

  <script type="text/javascript" src="${tools/portal/++resource++NuPlone.libraries}/jquery-1.11.3.min.js"></script>
    <script type="text/javascript" src="${tools/portal/++resource++NuPlone.libraries}/jquery.browser.min.js"></script>
  <script type="text/javascript" src="${tools/portal/++resource++NuPlone.behaviour}/behaviour.js"></script>
  <script tal:define="menu view/actions; url menu/url|nothing" tal:condition="not: url" type="text/javascript" meta:interpolation="false">
        $("a.contextActions").click(function(event) {
                event.preventDefault();
        })
  </script>
  <script type="text/javascript" meta:interpolation="false">
var sitemenu = {
    // Timer to control hiding of the sitemenu in the main document
    timer: null,

    getIframeElement: function() {
        return window.parent.$("#siteMenu")
    },

    clearTimer: function() {
        if (sitemenu.timer) {
            clearTimeout(sitemenu.timer);
            sitemenu.timer = null;
        }
    },

    setTimer: function() {
        if (sitemenu.timer) {
            return;
        }

        sitemenu.timer = setTimeout(function() {
            sitemenu.getIframeElement().css("height", '');
            }, 500);
    },

    init: function() {
        $("#siteMenu").on("mouseover", function(e) {
            if (!sitemenu.clearTimer()) {
                sitemenu.getIframeElement().css("height", "100%");
            }
        });

        $("#siteMenu").on("mouseout", function(e) {
            sitemenu.clearTimer();
            sitemenu.setTimer();
        });
    }
};

sitemenu.init();
  </script>
  </body>
</html>

