2016-06-09 13:05:02 +03:00
/ *
* Copyright ( c ) 2016 Lukas Reschke < lukas @ statuscode . ch >
*
* This file is licensed under the Affero General Public License version 3
* or later .
*
* See the COPYING - README file .
*
* /
( function ( $ ) {
var Drop = {
initialize : function ( ) {
$ ( document ) . bind ( 'drop dragover' , function ( e ) {
// Prevent the default browser drop action:
e . preventDefault ( ) ;
} ) ;
2016-06-09 18:45:16 +03:00
$ ( '#public-upload' ) . fileupload ( {
2016-06-09 13:05:02 +03:00
url : OC . linkTo ( 'files' , 'ajax/upload.php' ) ,
dataType : 'json' ,
2016-06-09 18:45:16 +03:00
dropZone : $ ( '#public-upload' ) ,
2016-06-09 13:05:02 +03:00
formData : {
dirToken : $ ( '#sharingToken' ) . val ( )
2016-06-09 18:45:16 +03:00
} ,
add : function ( e , data ) {
_ . each ( data [ 'files' ] , function ( file ) {
$ ( '#public-upload ul' ) . append ( '<li data-name="' + escapeHTML ( file . name ) + '"><span class="icon-loading-small"></span> ' + escapeHTML ( file . name ) + '</li>' ) ;
} ) ;
data . submit ( ) ;
} ,
success : function ( response ) {
var mimeTypeUrl = OC . MimeType . getIconUrl ( response [ 'mimetype' ] ) ;
$ ( '#public-upload ul li[data-name="' + escapeHTML ( response [ 'filename' ] ) + '"]' ) . html ( '<img src="' + escapeHTML ( mimeTypeUrl ) + '"/> ' + escapeHTML ( response [ 'filename' ] ) ) ;
2016-06-09 13:05:02 +03:00
}
} ) ;
2016-06-09 18:45:16 +03:00
$ ( '#public-upload .button.icon-upload' ) . click ( function ( e ) {
e . preventDefault ( ) ;
$ ( '#public-upload #emptycontent input' ) . focus ( ) . trigger ( 'click' ) ;
} ) ;
2016-06-09 13:05:02 +03:00
}
} ;
$ ( document ) . ready ( function ( ) {
2016-06-09 18:45:16 +03:00
if ( $ ( '#upload-only-interface' ) . val ( ) === "1" ) {
2016-06-09 13:05:02 +03:00
$ ( '.avatardiv' ) . avatar ( $ ( '#sharingUserId' ) . val ( ) , 128 , true ) ;
}
OCA . Files _Sharing _Drop = Drop ;
OCA . Files _Sharing _Drop . initialize ( ) ;
} ) ;
} ) ( jQuery ) ;