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