From f9c4975a456940bb24cacd6723a37f2857fbc65c Mon Sep 17 00:00:00 2001 From: Georg Ehrke Date: Fri, 13 Jan 2012 13:57:46 +0100 Subject: [PATCH] improve import form for calendar --- apps/calendar/js/loader.js | 39 ++++++++++++- apps/calendar/templates/part.import.php | 75 ++++--------------------- 2 files changed, 48 insertions(+), 66 deletions(-) diff --git a/apps/calendar/js/loader.js b/apps/calendar/js/loader.js index c21c20275e..50a7b082d9 100644 --- a/apps/calendar/js/loader.js +++ b/apps/calendar/js/loader.js @@ -2,10 +2,43 @@ Calendar_Import={ importdialog: function(filename){ var path = $('#dir').val(); $('body').append('
'); - $('#calendar_import').load(OC.filePath('calendar', 'ajax', 'importdialog.php'), {filename:filename, path:path}, Calendar_Import.initdialog()); + $('#calendar_import').load(OC.filePath('calendar', 'ajax', 'importdialog.php'), {filename:filename, path:path}, function(){Calendar_Import.initdialog(filename);}); }, - initdialog: function(){ - + initdialog: function(filename){ + $("#calendar_import_dialog").dialog({ + width : 500, + close : function() { + $(this).dialog('destroy').remove(); + $("#calendar_import").remove(); + } + }); + $('#progressbar').progressbar({value: 87}); + $('#startimport').click(function(){ + var filename = $('#filename').val(); + var path = $('#path').val(); + if($('#calendar option:selected').val() == 'newcal'){ + var method = 'new'; + var calname = $('#newcalendar').val(); + var calname = $.trim(calname); + if(calname == ''){ + $('#newcalendar').css('background-color', '#FF2626'); + return false; + } + }else{ + var method = 'old'; + } + $('#newcalendar').attr('readonly', 'readonly'); + $('#calendar').attr('disabled', 'disabled'); + $.post(OC.filePath('calendar', '', 'import.php'), {'method':method, 'calname':calname, 'path':path, 'file':filename}, function(){}); + $('#progressbar').slideDown('slow'); + }); + $('#calendar').change(function(){ + if($('#calendar option:selected').val() == 'newcal'){ + $('#newcalform').slideDown('slow'); + }else{ + $('#newcalform').slideUp('slow'); + } + }); }, getimportstatus: function(){ diff --git a/apps/calendar/templates/part.import.php b/apps/calendar/templates/part.import.php index b8805e6b6e..13685cfb27 100644 --- a/apps/calendar/templates/part.import.php +++ b/apps/calendar/templates/part.import.php @@ -1,69 +1,18 @@ -
"> +
"> "> "> -
t("How to import the new calendar?");?> -

-" onclick="$('#first').css('display', 'none');$('#existingcal').css('display', 'block');"> -" onclick="$('#first').css('display', 'none');$('#newcal').css('display', 'block');"> -
- - \ No newline at end of file + +
\ No newline at end of file