[ Index ] |
PHP Cross Reference of Unnamed Project |
[Summary view] [Print] [Text view]
1 /** 2 * Maintenance mode timer display. 3 * 4 * @module moodle-core-maintenancemodetimer 5 */ 6 var MAINTENANCEMODETIMER = function() { 7 MAINTENANCEMODETIMER.superclass.constructor.apply(this, arguments); 8 }; 9 10 Y.extend(MAINTENANCEMODETIMER, Y.Base, { 11 timeleftinsec: 0, 12 maintenancenode: Y.one('.box.maintenancewarning'), 13 14 /** 15 * Initialise timer if maintenancemode set. 16 * 17 * @method initializer 18 * @param config {Array} array with timeleftinsec set. 19 */ 20 initializer: function(config) { 21 if (this.maintenancenode) { 22 this.timeleftinsec = config.timeleftinsec; 23 this.maintenancenode.setAttribute('aria-live', 'polite'); 24 Y.later(1000, this, 'updatetimer', null, true); 25 } 26 }, 27 28 /** 29 * Decrement time left and update display text. 30 * 31 * @method updatetimer 32 */ 33 updatetimer: function() { 34 this.timeleftinsec -= 1; 35 if (this.timeleftinsec <= 0) { 36 this.maintenancenode.set('text', M.util.get_string('sitemaintenance', 'admin')); 37 } else { 38 var a = {}; 39 a.sec = this.timeleftinsec % 60; 40 a.min = Math.floor(this.timeleftinsec / 60); 41 this.maintenancenode.set('text', M.util.get_string('maintenancemodeisscheduled', 'admin', a)); 42 } 43 // Set error class to highlight the importance. 44 if (this.timeleftinsec < 30) { 45 this.maintenancenode.addClass('error') 46 .removeClass('warning'); 47 } else { 48 this.maintenancenode.addClass('warning') 49 .removeClass('error'); 50 } 51 } 52 }); 53 54 M.core = M.core || {}; 55 M.core.maintenancemodetimer = M.core.maintenancemodetimer || function(config) { 56 return new MAINTENANCEMODETIMER(config); 57 };
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Thu Aug 11 10:00:09 2016 | Cross-referenced by PHPXref 0.7.1 |