%--
/**
* 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.
*/
--%>
<%@ include file="/init.jsp" %>
<%
String redirect = ParamUtil.getString(request, "redirect");
CalendarResource calendarResource = (CalendarResource)request.getAttribute(WebKeys.CALENDAR_RESOURCE);
%>
var importDialog;
Liferay.provide(
window,
'importCalendar',
function(url) {
var A = AUI();
if (!importDialog) {
var importCalendarContainer = A.one('#importCalendarContainer');
var buttons = [
{
label: Liferay.Language.get('import'),
on: {
click: function() {
A.io.request(
url,
{
dataType: 'json',
form: {
id: 'importFm',
upload: true
},
method: 'post',
on: {
complete: function() {
var responseData = this.get('responseData');
var portletErrorMessage = A.one('#portletErrorMessage');
var portletSuccessMessage = A.one('#portletSuccessMessage');
var error = responseData && responseData.error;
if (error) {
portletErrorMessage.show();
portletSuccessMessage.hide();
portletErrorMessage.html(error);
}
else {
portletErrorMessage.hide();
portletSuccessMessage.show();
}
}
}
}
);
}
}
}
];
var buttonClose = [
{
cssClass: 'close',
label: '\u00D7',
render: true,
on: {
click: function() {
importDialog.hide();
}
}
}
];
importDialog = Liferay.Util.Window.getWindow(
{
dialog: {
bodyContent: importCalendarContainer.html(),
toolbars: {
footer: buttons,
header: buttonClose
},
modal: true,
on: {
visibleChange: function(event) {
A.one('#importFm').reset();
A.one('#portletErrorMessage').hide();
A.one('#portletSuccessMessage').hide();
}
}
},
title: Liferay.Language.get('import')
}
).render();
}
importDialog.show();
},
['aui-io', 'liferay-util-window']
);