<%-- /** * 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. */ --%> <% int count = 0; String exceptionDatesString = StringPool.BLANK; Frequency frequency = null; int interval = 0; PositionalWeekday positionalWeekday = new PositionalWeekday(Weekday.getWeekday(startTimeJCalendar), JCalendarUtil.getWeekdayPosition(startTimeJCalendar)); java.util.Calendar untilJCalendar = startTimeJCalendar; List weekdays = new ArrayList(); boolean afterChecked = false; boolean onChecked = false; if (recurrence != null) { count = recurrence.getCount(); frequency = recurrence.getFrequency(); interval = recurrence.getInterval(); if (recurrence.getUntilJCalendar() != null) { untilJCalendar = recurrence.getUntilJCalendar(); } for (PositionalWeekday curPositionalWeekday : recurrence.getPositionalWeekdays()) { weekdays.add(curPositionalWeekday.getWeekday()); positionalWeekday = curPositionalWeekday; } if (count > 0) { afterChecked = true; } if (recurrence.getUntilJCalendar() != null) { onChecked = true; } StringBundler sb = new StringBundler(); List exceptionJCalendars = recurrence.getExceptionJCalendars(); Iterator iterator = exceptionJCalendars.iterator(); while (iterator.hasNext()) { java.util.Calendar exceptionJCalendar = iterator.next(); sb.append(exceptionJCalendar.getTimeInMillis()); if (iterator.hasNext()) { sb.append(StringPool.COMMA); } } exceptionDatesString = sb.toString(); } %>
" id="view<%= Frequency.WEEKLY %>"> " id="viewPositionInMonth">
: <% for (Frequency curFrequency : Frequency.values()) { %> <%= LanguageUtil.get(pageContext, StringUtil.toLowerCase(curFrequency.getValue())) %> <% } %>
: <% for (int i = 1; i <= 30; i++) { %> <%= i %> <% } %>
: <% Weekday[] weekdaysArray = Weekday.values(); Collections.rotate(Arrays.asList(weekdaysArray), -weekStartsOn); %> <% for (Weekday weekday : weekdaysArray) { %> <% } %>
:
<% for (Weekday weekday : weekdaysArray) { %> <% } %>
:
:
var countNode = A.one('#count'); var endsRadioNodes = A.all('[name=ends]'); var frequencyNode = A.one('#frequency'); var positionInMonthNode = A.one('#viewPositionInMonth'); var positionalWeekdayNode = A.one('#viewPositionalWeekday'); var recurrenceContainerNode = A.one('#recurrenceContainer'); var repeatCheckboxNode = A.one('#repeatCheckbox'); var summaryNode = A.one('#summary'); var untilDateDatePicker = Liferay.component('untilDateDatePicker'); var getRecurrenceDialogTitle = function() { var summary = window.getSummary(); return ' ' + (summary.charAt(0).toLowerCase() + summary.slice(1)); }; window.recurrenceDialog; window.openRecurrenceDialog = function(visible) { recurrenceContainerNode.toggle(visible); window.recurrenceDialog = Liferay.Util.Window.getWindow( { dialog: { after:{ visibleChange: function(event) { recurrenceContainerNode.toggle(event.newVal); window.updateSummaries(); } }, bodyContent: recurrenceContainerNode, centered: true, height: 600, id: 'recurrenceDialog', modal: true, render: '#fm', toolbars: { footer: [ { label: '', on: { click: function() { window.recurrenceDialog.hide(); } } } ] }, visible: visible, width: 600 }, title: getRecurrenceDialogTitle() } ); }; var onInputChange = function(event) { var target = event.target; var value = target.val(); if (target.test('#frequency')) { window.toggleView('<%= Frequency.WEEKLY %>', (value == '<%= Frequency.WEEKLY %>')); window.toggleView('PositionInMonth', ((value === '<%= Frequency.MONTHLY %>') || (value === '<%= Frequency.YEARLY %>'))); } if (target.get('name') == 'repeatOnWeekday') { window.toggleView('PositionalWeekday', value === 'true'); } var endValue = endsRadioNodes.filter(':checked').val()[0]; if ((endValue == 'never') || (endValue == 'on')) { countNode.set('disabled', true); } else { countNode.set('disabled', false); } countNode.selectText(); if ((endValue == 'never') || (endValue == 'after')) { untilDateDatePicker.set('disabled', true); } else { untilDateDatePicker.set('disabled', false); } window.updateSummaries(); }; recurrenceContainerNode.delegate('change', onInputChange, 'select,input'); recurrenceContainerNode.delegate('keypress', onInputChange, 'select'); repeatCheckboxNode.on( 'change', function(event) { var checked = event.currentTarget.get('checked'); if (!checked) { summaryNode.empty(); } openRecurrenceDialog(checked); } ); summaryNode.on( 'click', function(event) { openRecurrenceDialog(true); event.halt(); } ); untilDateDatePicker.after( 'selectionChange', function(event) { window.updateSummaries(); } ); window.getSummary = function() { var frequency = frequencyNode.val(); var intervalNode = A.one('#interval'); var weekdays = A.all('#view<%= Frequency.WEEKLY %> input:checked'); var selectedWeekdays = []; if (weekdays.size()) { selectedWeekdays = weekdays.getAttribute('data-weekday'); } var positionalWeekday = null; if ((frequency == '<%= Frequency.MONTHLY %>') || (frequency == '<%= Frequency.YEARLY %>')) { if (positionInMonthNode.one('input:checked').val() == 'true') { positionalWeekday = { month: parseInt(A.one('#startTimeMonth').val(), 10), position: A.one('#position').val(), weekday: A.one('#weekday').val() }; } } var endValue = endsRadioNodes.filter(':checked').val()[0]; var recurrence = { count: countNode.val(), endValue: endValue, frequency: frequency, interval: intervalNode.val(), positionalWeekday: positionalWeekday, untilDate: untilDateDatePicker.getDate(), weekdays: selectedWeekdays } return Liferay.RecurrenceUtil.getSummary(recurrence); }; window.toggleView = function(viewName, show) { var viewNode = A.one('#view' + viewName); if (viewNode) { viewNode.toggle(show); } }; window.updateSummary = function(element) { var previewNode = A.one(element); if (previewNode) { previewNode.html(window.getSummary()); } }; window.updateSummaries = function() { window.updateSummary(summaryNode); window.updateSummary('#summaryPreview'); if (window.recurrenceDialog) { window.recurrenceDialog.titleNode.html(getRecurrenceDialogTitle()); window.recurrenceDialog.fillHeight(window.recurrenceDialog.bodyNode); } } window.updateSummaries();