@@ -284,7 +284,11 @@ function performLfmRequest(url, parameter, type) {
284
284
}
285
285
286
286
function displayErrorResponse ( jqXHR ) {
287
- notify ( '<div style="max-height:50vh;overflow: scroll;">' + jqXHR . responseText + '</div>' ) ;
287
+ var message = JSON . parse ( jqXHR . responseText )
288
+ if ( Array . isArray ( message ) ) {
289
+ message = message . join ( '<br>' )
290
+ }
291
+ notify ( '<div style="max-height:50vh;overflow: auto;">' + message + '</div>' ) ;
288
292
}
289
293
290
294
var refreshFoldersAndItems = function ( data ) {
@@ -540,7 +544,7 @@ function rename(item) {
540
544
}
541
545
542
546
function trash ( items ) {
543
- notify ( lang [ 'message-delete' ] , function ( ) {
547
+ confirm ( lang [ 'message-delete' ] , function ( ) {
544
548
performLfmRequest ( 'delete' , {
545
549
items : items . map ( function ( item ) { return item . name ; } )
546
550
} ) . done ( refreshFoldersAndItems )
@@ -794,12 +798,16 @@ function notImp() {
794
798
notify ( 'Not yet implemented!' ) ;
795
799
}
796
800
797
- function notify ( body , callback ) {
798
- $ ( '#notify' ) . find ( '.btn-primary' ) . toggle ( callback !== undefined ) ;
799
- $ ( '#notify' ) . find ( '.btn-primary' ) . unbind ( ) . click ( callback ) ;
801
+ function notify ( body ) {
800
802
$ ( '#notify' ) . modal ( 'show' ) . find ( '.modal-body' ) . html ( body ) ;
801
803
}
802
804
805
+ function confirm ( body , callback ) {
806
+ $ ( '#confirm' ) . find ( '.btn-primary' ) . toggle ( callback !== undefined ) ;
807
+ $ ( '#confirm' ) . find ( '.btn-primary' ) . click ( callback ) ;
808
+ $ ( '#confirm' ) . modal ( 'show' ) . find ( '.modal-body' ) . html ( body ) ;
809
+ }
810
+
803
811
function dialog ( title , value , callback ) {
804
812
$ ( '#dialog' ) . find ( 'input' ) . val ( value ) ;
805
813
$ ( '#dialog' ) . on ( 'shown.bs.modal' , function ( ) {
0 commit comments