@@ -366,6 +366,66 @@ var UserProfileView = Backbone.View.extend({
366
366
}
367
367
} ) ;
368
368
369
+ // error handler
370
+ var ErrorHandlerView = Backbone . View . extend ( {
371
+
372
+ initialize :function ( options ) {
373
+ this . options = options ;
374
+ if ( ! this . template ) {
375
+ this . template = _ . template ( $ ( '#tmpl-error-box' ) . html ( ) ) ;
376
+ }
377
+ if ( ! this . headerTemplate ) {
378
+ this . headerTemplate = _ . template ( $ ( '#tmpl-error-header' ) . html ( ) ) ;
379
+ }
380
+ } ,
381
+
382
+ reloadPage :function ( event ) {
383
+ event . preventDefault ( ) ;
384
+ window . location . reload ( true ) ;
385
+ } ,
386
+
387
+ handleError :function ( message ) {
388
+
389
+ if ( ! message ) {
390
+ message = { } ;
391
+ }
392
+
393
+ if ( message . log ) {
394
+ console . log ( message . log ) ;
395
+ }
396
+
397
+ var _self = this ;
398
+
399
+ return function ( model , response , options ) {
400
+
401
+ _self . showErrorMessage (
402
+ _self . headerTemplate ( { message : message , model : model , response : response , options : options } ) ,
403
+ _self . template ( { message : message , model : model , response : response , options : options } )
404
+ ) ;
405
+
406
+ $ ( '#modalAlert .modal-body .page-reload' ) . on ( 'click' , _self . reloadPage ) ;
407
+
408
+ }
409
+ } ,
410
+
411
+ showErrorMessage :function ( header , message ) {
412
+ // hide the sheet if it's visible
413
+ $ ( '#loadingbox' ) . sheet ( 'hide' ) ;
414
+
415
+ $ ( '#modalAlert' ) . i18n ( ) ;
416
+ $ ( '#modalAlert div.modal-header' ) . html ( header ) ;
417
+ $ ( '#modalAlert .modal-body' ) . html ( message ) ;
418
+
419
+ $ ( '#modalAlert' ) . modal ( {
420
+ 'backdrop' : 'static' ,
421
+ 'keyboard' : true ,
422
+ 'show' : true
423
+ } ) ;
424
+
425
+ }
426
+ } ) ;
427
+
428
+
369
429
// Router
370
430
var AppRouter = Backbone . Router . extend ( {
371
431
@@ -431,6 +491,8 @@ var AppRouter = Backbone.Router.extend({
431
491
432
492
this . breadCrumbView . render ( ) ;
433
493
494
+ this . errorHandlerView = new ErrorHandlerView ( ) ;
495
+
434
496
var base = $ ( 'base' ) . attr ( 'href' ) ;
435
497
$ . getJSON ( base + '.well-known/openid-configuration' , function ( data ) {
436
498
app . serverConfiguration = data ;
@@ -1142,9 +1204,10 @@ $(function () {
1142
1204
} ) ;
1143
1205
1144
1206
window . onerror = function ( message , filename , lineno , colno , error ) {
1207
+ console . log ( message ) ;
1145
1208
//Display an alert with an error message
1146
1209
$ ( '#modalAlert div.modal-header' ) . html ( $ . t ( 'error.title' ) ) ;
1147
- $ ( '#modalAlert div.modal-body' ) . html ( $ . t ( 'error.message' ) + ' <br /> ' [ filename , lineno , colno , error ] ) ;
1210
+ $ ( '#modalAlert div.modal-body' ) . html ( $ . t ( 'error.message' ) + message + ' <br /> ' + [ filename , lineno , colno , error ] ) ;
1148
1211
1149
1212
$ ( "#modalAlert" ) . modal ( { // wire up the actual modal functionality and show the dialog
1150
1213
"backdrop" : "static" ,
0 commit comments