Subversion Repositories oidplus

Rev

Rev 829 | Rev 839 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 829 Rev 833
Line 17... Line 17...
17
 
17
 
18
/*jshint esversion: 6 */
18
/*jshint esversion: 6 */
19
 
19
 
20
// $('#html').jstree();
20
// $('#html').jstree();
21
 
21
 
-
 
22
var bs5Utils = undefined;
-
 
23
 
22
var current_node = "";
24
var current_node = "";
23
var popstate_running = false;
25
var popstate_running = false;
24
// DEFAULT_LANGUAGE will be set by oidplus.min.js.php
26
// DEFAULT_LANGUAGE will be set by oidplus.min.js.php
25
// language_messages will be set by oidplus.min.js.php
27
// language_messages will be set by oidplus.min.js.php
26
// language_tblprefix will be set by oidplus.min.js.php
28
// language_tblprefix will be set by oidplus.min.js.php
Line 28... Line 30...
28
// samesite_policy will bet set by oidplus.min.js.php
30
// samesite_policy will bet set by oidplus.min.js.php
29
 
31
 
30
var pageChangeCallbacks = [];
32
var pageChangeCallbacks = [];
31
var pageChangeRequestCallbacks = [];
33
var pageChangeRequestCallbacks = [];
32
 
34
 
-
 
35
var ajaxPageLoadedCallbacks = [];
-
 
36
 
33
var oidplus_menu_width = 450; // In pixels. You can change this at runtime because of the glayoutWorkaroundB() workaround
37
var oidplus_menu_width = 450; // In pixels. You can change this at runtime because of the glayoutWorkaroundB() workaround
34
 
38
 
35
function isInternetExplorer() {
39
function isInternetExplorer() {
36
        // see also includes/functions.inc.php
40
        // see also includes/functions.inc.php
37
        var ua = window.navigator.userAgent;
41
        var ua = window.navigator.userAgent;
Line 251... Line 255...
251
                        id:id,
255
                        id:id,
252
                        anticache:Date.now()
256
                        anticache:Date.now()
253
                },
257
                },
254
                error:function(jqXHR, textStatus, errorThrown) {
258
                error:function(jqXHR, textStatus, errorThrown) {
255
                        if (errorThrown == "abort") return;
259
                        if (errorThrown == "abort") return;
256
                        alert(_L("Failed to load content: %1",errorThrown));
260
                        alertError(_L("Failed to load content: %1",errorThrown));
257
                        console.error(_L("Error: %1",errorThrown));
261
                        console.error(_L("Error: %1",errorThrown));
258
                },
262
                },
259
                success:function(data) {
263
                success:function(data) {
260
                        if ("error" in data) {
264
                        if ("error" in data) {
261
                                alert(_L("Failed to load content: %1",data.error));
265
                                alertError(_L("Failed to load content: %1",data.error));
262
                                console.error(data.error);
266
                                console.error(data.error);
263
                        } else if (data.status >= 0) {
267
                        } else if (data.status >= 0) {
264
                                data.id = id;
268
                                data.id = id;
265
 
269
 
266
                                var state = {
270
                                var state = {
Line 284... Line 288...
284
                                }
288
                                }
285
                                $('#real_content').html(data.text);
289
                                $('#real_content').html(data.text);
286
                                document.title = combine_systemtitle_and_pagetitle(getOidPlusSystemTitle(), data.title);
290
                                document.title = combine_systemtitle_and_pagetitle(getOidPlusSystemTitle(), data.title);
287
                                current_node = id;
291
                                current_node = id;
288
 
292
 
-
 
293
                                ajaxPageLoadedCallbacks.forEach(
-
 
294
                                        function(listener) {
-
 
295
                                                if (typeof listener == 'function') listener();
-
 
296
                                        }
-
 
297
                                );
-
 
298
 
289
                                if (anchor != '') {
299
                                if (anchor != '') {
290
                                        jumpToAnchor(anchor);
300
                                        jumpToAnchor(anchor);
291
                                }
301
                                }
292
                        } else {
302
                        } else {
293
                                alert(_L("Failed to load content: %1",data.status));
303
                                alertError(_L("Failed to load content: %1",data.status));
294
                                console.error(data);
304
                                console.error(data);
295
                        }
305
                        }
296
                }
306
                }
297
        });
307
        });
298
 
308
 
Line 456... Line 466...
456
                var keycode = (event.keyCode ? event.keyCode : event.which);
466
                var keycode = (event.keyCode ? event.keyCode : event.which);
457
                if (keycode == '13') {
467
                if (keycode == '13') {
458
                        gotoButtonClicked();
468
                        gotoButtonClicked();
459
                }
469
                }
460
        });
470
        });
-
 
471
 
-
 
472
        if (typeof Bs5Utils !== "undefined") {
-
 
473
                Bs5Utils.defaults.toasts.position = 'top-center';
-
 
474
                Bs5Utils.defaults.toasts.stacking = true;
-
 
475
                bs5Utils = new Bs5Utils();
-
 
476
        }
461
});
477
});
462
 
478
 
463
// can be overridden if necessary
479
// can be overridden if necessary
464
var handle_glayout_onresize_start = undefined;
480
var handle_glayout_onresize_start = undefined;
465
 
481
 
Line 643... Line 659...
643
                return def;
659
                return def;
644
        } else {
660
        } else {
645
                return val;
661
                return val;
646
        }
662
        }
647
}
663
}
-
 
664
 
-
 
665
/* Individual alert types */
-
 
666
/* TODO: alert() blocks program flow, but alertSuccess() not! Will the mass change have negative effects (e.g. a redirect without the user seeing the toast)? */
-
 
667
 
-
 
668
function alertSuccess(txt) {
-
 
669
        if (typeof bs5Utils !== "undefined") {
-
 
670
                bs5Utils.Snack.show('success', _L(txt), delay = 5000, dismissible = true);
-
 
671
        } else {
-
 
672
                alert(txt);
-
 
673
        }
-
 
674
}
-
 
675
 
-
 
676
function alertWarning(txt) {
-
 
677
        // TODO: as toast?
-
 
678
        alert(txt);
-
 
679
}
-
 
680
 
-
 
681
function alertError(txt) {
-
 
682
        // TODO: as toast?
-
 
683
        alert(txt);
-
 
684
}