All Downloads are FREE. Search and download functionalities are using the official Maven repository.

META-INF.resources.control_menu.js.product_navigation_control_menu_add_application.js Maven / Gradle / Ivy

There is a newer version: 7.4.3.112-ga112
Show newest version
AUI.add(
	'liferay-product-navigation-control-menu-add-application',
	function(A) {
		var ControlMenu = Liferay.ControlMenu;

		var CSS_LFR_PORTLET_USED = 'lfr-portlet-used';

		var DATA_PORTLET_ID = 'data-portlet-id';

		var SELECTOR_ADD_CONTENT_ITEM = '.add-content-item';

		var SELECTOR_CONTENT_ITEM = '.lfr-content-item';

		var STR_CLICK = 'click';

		var STR_ENTER_DOWN = 'down:ENTER';

		var STR_KEY = 'key';

		var AddApplication = A.Component.create(
			{
				AUGMENTS: Liferay.PortletBase,

				EXTENDS: ControlMenu.AddBase,

				NAME: 'addapplication',

				prototype: {
					initializer: function(config) {
						var instance = this;

						instance._config = config;

						instance._addApplicationForm = instance.byId('addApplicationForm');
						instance._entriesPanel = instance.byId('applicationList');

						var togglerSelector = instance.ns('addApplicationPanelContainer');

						var togglerDelegate = Liferay.component(togglerSelector);

						if (togglerDelegate) {
							togglerDelegate.plug(
								Liferay.TogglerInteraction,
								{
									children: '.lfr-content-item',
									parents: '.lfr-content-category'
								}
							);
						}

						instance._panelSearch = new Liferay.PanelSearch(
							{
								categorySelector: '.panel-page-category',
								inputNode: instance.get('inputNode'),
								nodeContainerSelector: '.lfr-content-item',
								nodeList: config.nodeList,
								nodeSelector: '.drag-content-item',
								togglerId: togglerSelector
							}
						);

						instance._bindUI();
					},

					destructor: function() {
						var instance = this;

						instance._panelSearch.destroy();

						(new A.EventHandle(instance._eventHandles)).detach();
					},

					_addApplication: function(event) {
						var instance = this;

						var portlet = event.currentTarget;

						if (event.type === STR_KEY) {
							portlet = portlet.one(SELECTOR_ADD_CONTENT_ITEM);
						}

						instance.addPortlet(portlet);
					},

					_bindUI: function() {
						var instance = this;

						instance._eventHandles.push(
							instance._entriesPanel.delegate(STR_CLICK, instance._addApplication, SELECTOR_ADD_CONTENT_ITEM, instance),
							Liferay.on('closePortlet', instance._onPortletClose, instance)
						);
					},

					_onPortletClose: function(event) {
						var instance = this;

						var item = instance._entriesPanel.one('.drag-content-item[data-plid=' + event.plid + '][data-portlet-id=' + event.portletId + '][data-instanceable=false]');

						if (item && item.hasClass(CSS_LFR_PORTLET_USED)) {
							var portletId = item.attr(DATA_PORTLET_ID);

							instance._enablePortletEntry(portletId);
						}
					}
				}
			}
		);

		ControlMenu.AddApplication = AddApplication;
	},
	'',
	{
		requires: ['aui-io-request', 'event-key', 'event-mouseenter', 'liferay-product-navigation-control-menu', 'liferay-product-navigation-control-menu-add-base', 'liferay-panel-search', 'liferay-portlet-base', 'liferay-toggler-interaction']
	}
);




© 2015 - 2024 Weber Informatics LLC | Privacy Policy