summaryrefslogtreecommitdiffstats
path: root/apps/calendar/js/calendar.js
diff options
context:
space:
mode:
Diffstat (limited to 'apps/calendar/js/calendar.js')
-rw-r--r--apps/calendar/js/calendar.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/apps/calendar/js/calendar.js b/apps/calendar/js/calendar.js
index 80b5dd88c5e..8a3f714c5f7 100644
--- a/apps/calendar/js/calendar.js
+++ b/apps/calendar/js/calendar.js
@@ -601,6 +601,50 @@ Calendar={
});
/*var permissions = (this.checked) ? 1 : 0;*/
}
+ },
+ Drop:{
+ init:function(){
+ if (typeof window.FileReader === 'undefined') {
+ console.log('The drop-import feature is not supported in your browser :(');
+ return false;
+ }
+ droparea = document.getElementById('calendar_holder');
+ droparea.ondrop = function(e){
+ e.preventDefault();
+ Calendar.UI.Drop.drop(e);
+ }
+ console.log('Drop initialized successfully');
+ },
+ drop:function(e){
+ var files = e.dataTransfer.files;
+ for(var i = 0;i < files.length;i++){
+ var file = files[i]
+ reader = new FileReader();
+ reader.onload = function(event){
+ if(file.type != 'text/calendar'){
+ $('#notification').html('At least one file don\'t seems to be a calendar file. File skipped.');
+ $('#notification').slideDown();
+ window.setTimeout(function(){$('#notification').slideUp();}, 5000);
+ return false;
+ }else{
+ Calendar.UI.Drop.import(event.target.result);
+ }
+ }
+ reader.readAsDataURL(file);
+ }
+ $('#calendar_holder').fullCalendar('refetchEvents');
+ },
+ import:function(data){
+ $.post(OC.filePath('calendar', 'ajax/import', 'dropimport.php'), {'data':data},function(result) {
+ if(result.data == 'success'){
+ return true;
+ }else{
+ $('#notification').html('ownCloud wasn\'t able to import at least one file. File skipped.');
+ $('#notification').slideDown();
+ window.setTimeout(function(){$('#notification').slideUp();}, 5000);
+ }
+ });
+ }
}
}
}
@@ -858,4 +902,5 @@ $(document).ready(function(){
$('#calendar_holder').fullCalendar('next');
});
Calendar.UI.Share.init();
+ Calendar.UI.Drop.init();
});