Index: trunk/kernel/admin_templates/incs/ajax.js =================================================================== diff -u -r5031 -r5041 --- trunk/kernel/admin_templates/incs/ajax.js (.../ajax.js) (revision 5031) +++ trunk/kernel/admin_templates/incs/ajax.js (.../ajax.js) (revision 5041) @@ -25,6 +25,7 @@ } else { p_errorCallBack(req,p_pass); } + Request.hideProgress(p_progId); } } @@ -54,13 +55,121 @@ } Request.showProgress = function(p_id) { - if (p_id != "") document.getElementById(p_id).innerHTML = Request.getProgressHtml(); + if (p_id != '') { + Request.setOpacity(20, p_id); + + if (!document.getElementById(p_id + '_progress')) { + document.body.appendChild(Request.getProgressObject(p_id)); + } + else { + var $progress_div = document.getElementById(p_id + '_progress'); + $progress_div.style.top = findPosY(p_id) + 'px'; + $progress_div.style.height = document.getElementById(p_id).clientHeight; + $progress_div.style.display = 'block'; + } +// 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); + } +} + +Request.setOpacity = function (opacity, id) { + var object = document.getElementById(id).style; + object.opacity = (opacity / 100); + object.MozOpacity = (opacity / 100); + object.KhtmlOpacity = (opacity / 100); + object.filter = "alpha(opacity=" + opacity + ")"; +} + Request.getProgressHtml = function() { return "

" + Request.progressText + "
" + Request.progressText + "

"; } +function findPosX(obj) +{ + if (typeof(obj) == 'string') { + obj = document.getElementById(obj); + } + var curleft = 0; + if (obj.offsetParent) + { + while (obj.offsetParent) + { + curleft += obj.offsetLeft + obj = obj.offsetParent; + } + } + else if (obj.x) + curleft += obj.x; + return curleft; +} + +function findPosY(obj) +{ + if (typeof(obj) == 'string') { + obj = document.getElementById(obj); + } + var curtop = 0; + if (obj.offsetParent) + { + while (obj.offsetParent) + { + curtop += obj.offsetTop + obj = obj.offsetParent; + } + } + else if (obj.y) + curtop += obj.y; + return curtop; +} + +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 = findPosX($parent_div) + 'px'; + $div.style.top = findPosY($parent_div) + 'px'; + $div.style.position = 'absolute'; + + /*$div.style.border = '1px solid green'; + $div.style.backgroundColor = '#FF0000';*/ + + var $table = addElement($div, 'table'); + $table.style.width = '100%'; + $table.style.height = '100%'; + var $tbody = addElement($table, 'tbody'); + var $row = addElement($tbody, 'tr'); + var $cell = addElement($row, 'td'); + $cell.style.textAlign = 'center'; + + $cell.appendChild( document.createTextNode(Request.progressText) ); + addElement($cell, 'br'); + + var $img = addElement($cell, 'img'); + $img.src = 'img/ajax_progress.gif'; + $img.align = 'absmiddle'; + $img.width = 100; + $img.height = 7; + $img.alt = Request.progressText; + + return $div; +} + +function addElement($dst_element, $tag_name) { + var $new_element = document.createElement($tag_name.toUpperCase()); + $dst_element.appendChild($new_element); + return $new_element; +} + Request.getErrorHtml = function(p_req) { //TODO: implement accepted way to handle request error return "

" + "(" + p_req.status + ") " + p_req.statusText + "

"