@@ -618,17 +618,76 @@ OwnCloudApp.prototype.extraBtnLsnr = function() {
618
618
}
619
619
} ;
620
620
621
+ OwnCloudApp . prototype . NewUploadToDavDialog = function ( ) {
622
+ var zimletInstance = appCtxt . _zimletMgr . getZimletByName ( 'tk_barrydegraaff_owncloud_zimlet' ) . handlerObject ;
623
+
624
+ zimletInstance . _uploadDialog = new ZmDialog ( {
625
+ title : ZmMsg . uploadDocs ,
626
+ parent : zimletInstance . getShell ( ) ,
627
+ standardButtons : [ DwtDialog . OK_BUTTON , DwtDialog . CANCEL_BUTTON ] ,
628
+ disposeOnPopDown : true
629
+ } ) ;
630
+ var html = "<div style='width:300px; height: 75px;'>" +
631
+ "<form accept-charset=\"utf-8\" method=\"POST\" id=\"ownCloudZimletUploadFiles\" enctype=\"multipart/form-data\"><table role=\"presentation\" class=\"ZPropertySheet\" cellspacing=\"6\"><tbody><tr><td>File:</td><td><input type=\"file\" multiple=\"\" name=\"uploadFile\" size=\"30\"><input type=\"hidden\" name=\"password\" value=\"" + tk_barrydegraaff_owncloud_zimlet_HandlerObject . settings [ 'owncloud_zimlet_password' ] + "\"></td><td colspan=\"3\"> </td></tr></tbody></table></form>" +
632
+ "</div>" ;
633
+
634
+ zimletInstance . _uploadDialog . setContent ( html ) ;
635
+ zimletInstance . _uploadDialog . setButtonListener ( DwtDialog . OK_BUTTON , new AjxListener ( zimletInstance , OwnCloudApp . prototype . NewUploadToDavDialogOKBtn ) ) ;
636
+ zimletInstance . _uploadDialog . setButtonListener ( DwtDialog . CANCEL_BUTTON , new AjxListener ( zimletInstance , OwnCloudApp . prototype . NewUploadToDavDialogCancelBtn ) ) ;
637
+ zimletInstance . _uploadDialog . _tabGroup . addMember ( document . getElementById ( zimletInstance . _uploadDialog . _button [ 1 ] . __internalId ) ) ;
638
+ zimletInstance . _uploadDialog . _tabGroup . addMember ( document . getElementById ( zimletInstance . _uploadDialog . _button [ 2 ] . __internalId ) ) ;
639
+ zimletInstance . _uploadDialog . _baseTabGroupSize = 2 ;
640
+ zimletInstance . _uploadDialog . popup ( ) ;
641
+ } ;
642
+
643
+ OwnCloudApp . prototype . NewUploadToDavDialogCancelBtn = function ( ) {
644
+ var zimletInstance = appCtxt . _zimletMgr . getZimletByName ( 'tk_barrydegraaff_owncloud_zimlet' ) . handlerObject ;
645
+ zimletInstance . _uploadDialog . popdown ( ) ;
646
+ } ;
647
+
648
+ OwnCloudApp . prototype . NewUploadToDavDialogOKBtn = function ( ) {
649
+ var zimletInstance = appCtxt . _zimletMgr . getZimletByName ( 'tk_barrydegraaff_owncloud_zimlet' ) . handlerObject ;
650
+ if ( ! zimletInstance . _appView . _currentPath || zimletInstance . _appView . _currentPath == '/' )
651
+ {
652
+ zimletInstance . _appView . _currentPath = tk_barrydegraaff_owncloud_zimlet_HandlerObject . settings [ 'owncloud_zimlet_server_path' ] + '/' ;
653
+ }
654
+
655
+ var formData = new FormData ( document . getElementById ( "ownCloudZimletUploadFiles" ) ) ;
656
+ zimletInstance . _uploadDialog . _button [ 2 ] . setEnabled ( false ) ;
657
+ zimletInstance . _uploadDialog . _button [ 1 ] . setText ( ZmMsg . hide ) ;
658
+ zimletInstance . _uploadDialog . setContent ( "<div id=\"ownCloudZimletUploadFilesProgress\" style=\"width:300px; text-align:center;\"><img src=\"" + zimletInstance . getResource ( "progressround.gif" ) + "\"></div>" ) ;
659
+
660
+ var xhr = new XMLHttpRequest ( ) ;
661
+ xhr . open ( "POST" , "/service/extension/dav_upload/?path=" + zimletInstance . _appView . _currentPath , true ) ;
662
+ xhr . onload = function ( event ) {
663
+ var zimletInstance = appCtxt . _zimletMgr . getZimletByName ( 'tk_barrydegraaff_owncloud_zimlet' ) . handlerObject ;
664
+ console . log ( "Success, server responded with: " + event . target . response ) ;
665
+ OwnCloudApp . prototype . refreshViewPropfind ( ) ;
666
+ zimletInstance . _uploadDialog . popdown ( ) ;
667
+ } ;
668
+ xhr . onerror = function ( event ) {
669
+ var zimletInstance = appCtxt . _zimletMgr . getZimletByName ( 'tk_barrydegraaff_owncloud_zimlet' ) . handlerObject ;
670
+ console . log ( "onerror, server responded with: " + event . target . response ) ;
671
+ OwnCloudApp . prototype . refreshViewPropfind ( ) ;
672
+ zimletInstance . _uploadDialog . popdown ( ) ;
673
+ } ;
674
+ xhr . onabort = function ( event ) {
675
+ var zimletInstance = appCtxt . _zimletMgr . getZimletByName ( 'tk_barrydegraaff_owncloud_zimlet' ) . handlerObject ;
676
+ console . log ( "onabort, server responded with: " + event . target . response ) ;
677
+ OwnCloudApp . prototype . refreshViewPropfind ( ) ;
678
+ zimletInstance . _uploadDialog . popdown ( ) ;
679
+ } ;
680
+
681
+ xhr . send ( formData ) ;
682
+ } ;
683
+
621
684
OwnCloudApp . prototype . _uploadBtnLsnr = function ( ev ) {
622
685
var zimletInstance = appCtxt . _zimletMgr . getZimletByName ( 'tk_barrydegraaff_owncloud_zimlet' ) . handlerObject ;
623
686
if ( ! zimletInstance . _appView . _currentPath || zimletInstance . _appView . _currentPath == '/' )
624
687
{
625
688
zimletInstance . _appView . _currentPath = tk_barrydegraaff_owncloud_zimlet_HandlerObject . settings [ 'owncloud_zimlet_server_path' ] + '/' ;
626
689
}
627
- var dialog = new UploadToDavDialog ( appCtxt . getShell ( ) ) ;
628
- dialog . popup (
629
- zimletInstance . _appView . _currentPath ,
630
- new AjxCallback ( this , this . refreshViewPropfind )
631
- ) ;
690
+ OwnCloudApp . prototype . NewUploadToDavDialog ( ) ;
632
691
} ;
633
692
634
693
OwnCloudApp . prototype . refreshViewPropfind = function ( ) {
0 commit comments