From d8feba6ce7659e82062d47f1669c55943218b862 Mon Sep 17 00:00:00 2001 From: Ruslan Kabalin Date: Mon, 23 Apr 2012 14:45:44 +0100 Subject: [PATCH] MDL-31052 Add generic lightbox spinner to indicate progress to user --- lib/javascript-static.js | 43 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/lib/javascript-static.js b/lib/javascript-static.js index ef1ec74fff9..f2666474058 100644 --- a/lib/javascript-static.js +++ b/lib/javascript-static.js @@ -789,6 +789,49 @@ M.util.focus_login_form = function(Y) { } } +/** + * Adds lightbox hidden element that covers the whole node. + * + * @param {YUI} Y + * @param {Node} the node lightbox should be added to + * @retun {Node} created lightbox node + */ +M.util.add_lightbox = function(Y, node) { + var WAITICON = {'pix':"i/loading_small",'component':'moodle'}; + + // Check if lightbox is already there + if (node.one('.lightbox')) { + return node.one('.lightbox'); + } + + node.setStyle('position', 'relative'); + var waiticon = Y.Node.create('') + .setAttrs({ + 'src' : M.util.image_url(WAITICON.pix, WAITICON.component) + }) + .setStyles({ + 'position' : 'relative', + 'top' : '50%' + }); + + var lightbox = Y.Node.create('
') + .setStyles({ + 'opacity' : '.75', + 'position' : 'absolute', + 'width' : '100%', + 'height' : '100%', + 'top' : 0, + 'left' : 0, + 'backgroundColor' : 'white', + 'text-align' : 'center' + }) + .setAttribute('class', 'lightbox') + .hide(); + + lightbox.appendChild(waiticon); + node.append(lightbox); + return lightbox; +} //=== old legacy JS code, hopefully to be replaced soon by M.xx.yy and YUI3 code ===