1 YUI.add('moodle-core-maintenancemode', function (Y, NAME) {
4 * Maintenance mode timer display.
6 * @module moodle-core-maintenancemodetimer
8 var MAINTENANCEMODETIMER = function() {
9 MAINTENANCEMODETIMER.superclass.constructor.apply(this, arguments);
12 Y.extend(MAINTENANCEMODE, Y.Base, {
14 maintenancenode: Y.one('.box.maintenancewarning'),
17 * Initialise timer if maintenancemode set.
19 * @param config {Array} array with timeleftinsec set.
21 initializer: function(config) {
22 if (this.maintenancenode) {
23 this.timeleftinsec = config.timeleftinsec;
24 this.maintenancenode.setAttribute('aria-live', 'polite');
25 Y.later(1000, this, 'updatetimer', null, true);
30 * Decrement time left and update display text.
32 updatetimer: function() {
33 this.timeleftinsec -= 1;
34 if (this.timeleftinsec <= 0) {
35 this.maintenancenode.set('text', M.str.admin.sitemaintenance);
38 a.sec = this.timeleftinsec % 60;
39 a.min = Math.floor(this.timeleftinsec / 60);
40 this.maintenancenode.set('text', M.util.get_string('maintenancemodeisscheduled', 'admin', a));
42 // Set error class to highlight the importance.
43 if (this.timeleftinsec < 30) {
44 this.maintenancenode.addClass('error')
45 .removeClass('warning');
47 this.maintenancenode.addClass('warning')
48 .removeClass('error');
52 M.core = M.core || {};
53 M.core.maintenancemodetimer = M.core.maintenancemodetimer || function(config) {
54 return new MAINTENANCEMODETIMER(config);
58 }, '@VERSION@', {"requires": ["base", "node"]});