Index: branches/RC/core/admin_templates/js/ajax.js =================================================================== diff -u -N -r11368 -r11576 --- branches/RC/core/admin_templates/js/ajax.js (.../ajax.js) (revision 11368) +++ branches/RC/core/admin_templates/js/ajax.js (.../ajax.js) (revision 11576) @@ -105,61 +105,76 @@ Request.showProgress = function(p_id) { if (p_id != '') { - Request.setOpacity(20, p_id); + var $content_div = $( jq('#' + p_id) ); + var $content_offset = $content_div.offset(); + var $content_height = $content_div.height(); - if (!document.getElementById(p_id + '_progress')) { - document.body.appendChild(Request.getProgressObject(p_id)); +// alert('id: ' + p_id + '; ch: ' + $content_div.get(0).clientHeight + '; sh: ' + $content_div.get(0).style.height); + + var $parent_div = $content_div.parents(':first'); + + // use parent height, when own height is larger, then parent's + $content_height = Math.min($content_height, $parent_div.height()); + + var $progress_overlay = $( jq('#' + p_id + '_progress') ); + + if ($progress_overlay.length == 0) { + $progress_overlay = $('
'); + + var $maximal_height = $(window).height() - $content_offset.top; + + $progress_overlay.css( + { + width: $content_div.width(), + height: $content_height > 0 ? $content_height : $maximal_height, + left: $content_offset.left, + top: $content_offset.top + $parent_div.scrollTop(), + position: 'absolute', + zIndex: 200, + opacity: 0.75, + backgroundColor: 'black', + + // don't show progress overlay, when target div is hidden + display: $content_offset.top /*$content_height*/ > 0 ? 'block' : 'none' + } + ); + + $('body').append($progress_overlay); + + $progress_overlay.html( Request.getProgressHtml() ); } - else if (document.getElementById(p_id).clientHeight > 0) { - // show progress, only when target div is visible - var $progress_div = document.getElementById(p_id + '_progress'); - $progress_div.style.top = getRealTop(p_id) + 'px'; - $progress_div.style.zIndex = 500; - $progress_div.style.height = document.getElementById(p_id).clientHeight + 'px'; - $progress_div.style.display = 'block'; + else { + if ($content_height > 0) { + // show progress, only when target div is visible + $progress_overlay.css( + { + height: $content_height, + top: $content_offset.top + $parent_div.scrollTop() + } + ); + } + + $progress_overlay.show(); } -// document.getElementById(p_id).innerHTML = Request.getProgressHtml(); + } } Request.hideProgress = function(p_id) { if (p_id != '') { - document.getElementById(p_id + '_progress').style.display = 'none'; - Request.setOpacity(100, p_id); + $( jq('#' + p_id + '_progress') ).hide(); } } Request.setOpacity = function (opacity, id) { - var elem = typeof(id)=='string' ? document.getElementById(id) : id; - var object = elem.style; - object.opacity = (opacity / 100); - object.MozOpacity = (opacity / 100); - object.KhtmlOpacity = (opacity / 100); - object.filter = "alpha(opacity=" + opacity + ")"; + var $element = $( typeof(id) == 'string' ? jq('#' + id) : id ); + $element.css('opacity', opacity / 100); } Request.getProgressHtml = function() { - return "
" + Request.progressText + "
" + Request.progressText + "
"; + return "
" + Request.progressText + "
" + Request.progressText + "
"; } -Request.getProgressObject = function($id) { - var $div = document.createElement('DIV'); - var $parent_div = document.getElementById($id); - - $div.id = $id + '_progress'; - - $div.style.width = $parent_div.clientWidth + 'px'; - $div.style.height = '150px'; // default height if div is empty (first ajax request for div) - $div.style.left = getRealLeft($parent_div) + 'px'; - $div.style.top = getRealTop($parent_div) + 'px'; - $div.style.position = 'absolute'; - - $div.style.display = getRealTop($parent_div)/*document.getElementById($id).clientHeight*/ > 0 ? 'block' : 'none'; - - $div.innerHTML = '
'+Request.progressText+'
'+escape(Request.progressText)+'
'; - return $div; -} - Request.getErrorHtml = function(p_req) { //TODO: implement accepted way to handle request error return '[status: ' + p_req.status + '; status_text: ' + p_req.statusText + '; responce_text: ' + p_req.responseText + ']';