<%-- /** * 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. */ --%> <% String backURL = PortalUtil.getCurrentURL(request); %> window.calendarListsMenu = new Liferay.SimpleMenu( { align: { points: [A.WidgetPositionAlign.TL, A.WidgetPositionAlign.BL] }, constrain: true, items: [ { caption: '', fn: function(event) { var instance = this; var calendarResourceId = instance.calendarResourceId; if (calendarResourceId) { Liferay.Util.openWindow( { dialog: { after: { destroy: function(event) { Liferay.CalendarUtil.getResourceCalendars( calendarResourceId, function(calendars) { var calendarList = window.calendarLists[calendarResourceId]; calendarList.set('calendars', calendars); syncCalendarsMap(); scheduler.load(); } ); } }, destroyOnHide: true, modal: true }, refreshWindow: window, title: '', uri: A.Lang.sub( decodeURIComponent('<%= editCalendarURL %>'), { calendarResourceId: calendarResourceId } ) } ); } }, icon: 'icon-plus', id: 'add' }, { caption: '', fn: function(event) { var instance = this; var calendarResourceId = instance.calendarResourceId; if (calendarResourceId) { window.location.href = A.Lang.sub( decodeURIComponent('<%= calendarsURL %>'), { calendarResourceId: calendarResourceId } ); } }, icon: 'icon-calendar', id: 'manage' } ], visible: false, width: 290, zIndex: 500 } ).render(); window.calendarsMenu = { items: [ { caption: '', fn: function(event) { var instance = this; var calendarList = instance.get('host'); var activeCalendar = calendarList.activeItem; Liferay.Util.openWindow( { dialog: { after: { destroy: function(event) { scheduler.load(); } }, destroyOnHide: true, modal: true }, refreshWindow: window, title: '', uri: A.Lang.sub( decodeURIComponent('<%= addCalendarBookingURL %>'), { calendarId: activeCalendar.get('calendarId') } ) } ); }, icon: 'icon-plus', id: 'addEvent' }, { caption: '', fn: function(event) { var instance = this; var calendarList = instance.get('host'); calendarList.remove(calendarList.activeItem); refreshVisibleCalendarRenderingRules(); instance.set('visible', false); }, icon: 'icon-remove', id: 'hide' }, { caption: '', fn: function(event) { var instance = this; var calendarList = instance.get('host'); var activeCalendar = calendarList.activeItem; Liferay.Util.openWindow( { dialog: { after: { destroy: function(event) { Liferay.CalendarUtil.getResourceCalendars( activeCalendar.get('calendarResourceId'), function(calendars) { calendarList.set('calendars', calendars); syncCalendarsMap(); scheduler.load(); } ); } }, destroyOnHide: true, modal: true }, refreshWindow: window, title: '', uri: A.Lang.sub( decodeURIComponent('<%= editCalendarURL %>'), { calendarId: activeCalendar.get('calendarId'), calendarResourceId: activeCalendar.get('calendarResourceId') } ) } ); }, icon: 'icon-edit', id: 'settings' }, { caption: '', fn: function(event) { var instance = this; var calendarList = instance.get('host'); var activeCalendar = calendarList.activeItem; Liferay.Util.openWindow( { dialog: { after: { destroy: function(event) { scheduler.load(); } }, destroyOnHide: true, modal: true }, refreshWindow: window, title: '', uri: A.Lang.sub( decodeURIComponent('<%= permissionsURL %>'), { resourceGroupId: activeCalendar.get('groupId'), resourcePrimKey: activeCalendar.get('calendarId'), modelResourceDescription: activeCalendar.get('name') } ) } ); }, icon: 'icon-lock', id: 'permissions' }, { caption: '', fn: function(event) { var instance = this; var calendarList = instance.get('host'); var activeCalendar = calendarList.activeItem; if (confirm('')) { Liferay.CalendarUtil.deleteCalendar( activeCalendar.get('calendarId'), function() { Liferay.CalendarUtil.getResourceCalendars( activeCalendar.get('calendarResourceId'), function(calendars) { calendarList.set('calendars', calendars); syncCalendarsMap(); scheduler.load(); Liferay.CalendarMessageUtil.showAlert('#alert', ''); } ); } ); } }, icon: 'icon-remove', id: 'delete' }, { caption: '', cssClass: 'calendar-subscribe-link', fn: function(event) { var instance = this; var calendarList = instance.get('host'); var activeCalendar = calendarList.activeItem; var url = A.Lang.sub( decodeURIComponent('<%= calendarRSSURL %>'), { calendarId: activeCalendar.get('calendarId') } ); window.open(url, '_blank'); instance.set('visible', false); }, icon: 'icon-rss', id: 'subscribe' }, { caption: '-', id: 'separator1' }, { caption: '
', id: 'colorPicker' } ], on: { visibleChange: function(event) { var instance = this; var calendarList = instance.get('host'); var calendar = calendarList.activeItem; if (calendar && event.newVal) { var permissions = calendar.get('permissions'); var hiddenItems = []; if (calendarList !== window.otherCalendarList) { hiddenItems.push('hide'); } var defaultCalendar = calendar.get('defaultCalendar'); if ((permissions.DELETE === false) || (defaultCalendar === true)) { hiddenItems.push('delete'); } if (permissions.MANAGE_BOOKINGS === false) { hiddenItems.push('addEvent'); } if (permissions.PERMISSIONS === false) { hiddenItems.push('permissions'); } if (permissions.UPDATE === false) { hiddenItems.push('settings'); hiddenItems.push('separator1'); hiddenItems.push('colorPicker'); } instance.set('hiddenItems', hiddenItems); colorPicker.set('host', instance); colorPicker.setAttrs( { color: calendar.get('color'), visible: true } ); var colorPickerContainer = instance.get('boundingBox').one('.calendar-portlet-color-picker'); colorPickerContainer.append(window.colorPicker.get('boundingBox')); } } }, width: 225 }; colorPicker = new Liferay.SimpleColorPicker( { on: { colorChange: function(event) { var instance = this; var simpleMenu = instance.get('host'); if (simpleMenu) { var calendarList = simpleMenu.get('host'); calendarList.activeItem.set( 'color', event.newVal, { silent: true } ); simpleMenu.set('visible', false); } } }, visible: false } ).render(); A.one('#calendarListContainer').delegate( 'click', function(event) { var currentTarget = event.currentTarget; window.calendarListsMenu.setAttrs( { alignNode: currentTarget, visible: !window.calendarListsMenu.get('visible') } ); window.calendarListsMenu.calendarResourceId = currentTarget.getAttribute('data-calendarResourceId'); event.stopImmediatePropagation(); }, '.calendar-list-item-arrow' );