require(["jquery","app", "forms", "bootstrap", "extensions"], function ($, app, forms) { $(function () { // Auto-create popovers for all links configured to be popovers $(document).popover({ selector: 'a[data-toggle="popover"]', html: true, placement: 'top' }); // Bind accordions to manage an active class $(document).on({ 'show.bs.collapse': function (event) { $(event.target).parents('.panel').addClass('active'); }, 'hide.bs.collapse': function (event) { $(event.target).parents('.panel').removeClass('active'); } }); // Make Bootstrap dropdowns hoverable $('.dropdown-toggle').dropdownHover( { delay: 250, instantlyCloseOthers: true, hoverDelay: 0 }); // Restrict appropriate field inputs by key forms.restrictInput('[data-restrict-input]'); }); // Start an application timeout feature if (app.authenticated) { require(["jquery", "idletimeout"], function ($) { $(function () { // Ensure that we have everything wrapped up for the smudging if ($('#__idlemask').length == 0) { $('body').wrapInner('
'); } // Inject the modal var modalHtml = [ ' '].join(''); $('body').append(modalHtml); // Start the idle timer $.idleTimeout('#idletimeoutmodal', '#idletimeoutmodal .modal-footer button:first', { keepAliveURL: app.path("app/keepalive"), serverResponseEquals: "OK", pollingInterval: 59, idleAfter: (app.sessiontimeout - 3) * 60, warningLength: 60, onTimeout: function () { window.location = app.path("/www/account/logout"); }, onIdle: function () { $(this).modal("show"); $('#__idlemask').addClass('smudged'); }, onResume: function () { $(this).modal("hide"); $('#__idlemask').removeClass('smudged'); }, onCountdown: function (counter) { $("#idletimeoutcountdown").html(counter); // update the counter } }); }); }); } });