Liferay.Loader.define("product-navigation-control-menu-web@5.0.58/js/PagesTree.es", ['module', 'exports', 'require', 'frontend-js-web'], function (module, exports, require) {
  var define = undefined;
  var global = window;
  {
    Object.defineProperty(exports, "__esModule", {
      value: true
    });
    exports.default = _default;

    var _frontendJsWeb = require("frontend-js-web");

    /**
     * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
     *
     * This library is free software; you can redistribute it and/or modify it under
     * the terms of the GNU Lesser General Public License as published by the Free
     * Software Foundation; either version 2.1 of the License, or (at your option)
     * any later version.
     *
     * This library is distributed in the hope that it will be useful, but WITHOUT
     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
     * details.
     */
    var KEY_ENTER = 13;

    function _default(_ref) {
      var namespace = _ref.namespace;
      var layoutsTree = document.getElementById("".concat(namespace, "layoutsTree"));
      var eventDelegates = [];

      var dropdownActionKeyupHandler = (0, _frontendJsWeb.delegate)(layoutsTree, 'keyup', '.pages-tree-dropdown button.dropdown-toggle', function dropdownAction(event) {
        if (event.keyCode === KEY_ENTER) {
          event.stopImmediatePropagation();
          var trigger = event.delegateTarget;
          var menu = trigger.parentNode.querySelector('.pages-tree-dropdown .dropdown-menu');
          Liferay.DropdownProvider.show({
            menu: menu,
            trigger: trigger
          });
        }
      });
      eventDelegates.push(dropdownActionKeyupHandler);

      var linkActionKeyupHandler = (0, _frontendJsWeb.delegate)(layoutsTree, 'keyup', 'a.layout-tree[data-url], .pages-tree-dropdown a.dropdown-item', function linkAction(event) {
        if (event.keyCode === KEY_ENTER) {
          event.stopImmediatePropagation();
          window.location.href = event.delegateTarget.href;
        }
      });
      eventDelegates.push(linkActionKeyupHandler);

      var viewCollectionItemsActionOptionQueryClickHandler = (0, _frontendJsWeb.delegate)(layoutsTree, 'click', '.view-collection-items-action-option.collection', function viewCollectionItemsActionOptionQuery(event) {
        Liferay.Util.openModal({
          id: "".concat(namespace, "viewCollectionItemsDialog"),
          title: Liferay.Language.get('collection-items'),
          url: event.delegateTarget.dataset.viewCollectionItemsUrl
        });
      });
      eventDelegates.push(viewCollectionItemsActionOptionQueryClickHandler);
      return {
        dispose: function dispose() {
          Liferay.destroyComponent("".concat(namespace, "pagesTree"));
          eventDelegates.forEach(function (eventDelegate) {
            return eventDelegate.dispose();
          });
        }
      };
    }
    //# sourceMappingURL=PagesTree.es.js.map
  }
});
//# sourceMappingURL=PagesTree.es.js.map