From 4cce17070f03d335469c291a360781f7971f081a Mon Sep 17 00:00:00 2001 From: Klaus Leithoff Date: Tue, 4 Feb 2014 14:36:37 +0000 Subject: [PATCH] * eMail: completely remove the ui/bo/sofilter classes as they are not effectively used anymore --- felamimail/inc/class.ajaxfelamimail.inc.php | 30 +- felamimail/inc/class.bocompose.inc.php | 2 +- felamimail/inc/class.uifelamimail.inc.php | 34 - felamimail/js/jscode/viewMainScreen.js | 660 ++++++++++++++++++++ 4 files changed, 674 insertions(+), 52 deletions(-) create mode 100644 felamimail/js/jscode/viewMainScreen.js diff --git a/felamimail/inc/class.ajaxfelamimail.inc.php b/felamimail/inc/class.ajaxfelamimail.inc.php index cd99c262e8..8f53fa7ac2 100644 --- a/felamimail/inc/class.ajaxfelamimail.inc.php +++ b/felamimail/inc/class.ajaxfelamimail.inc.php @@ -135,13 +135,11 @@ class ajaxfelamimail $this->bofelamimail->restoreSessionData(); $this->bofelamimail->compressFolder($this->sessionData['mailbox']); - $bofilter = CreateObject('felamimail.bofilter'); - $sortResult = $this->bofelamimail->getSortedList( $this->sessionData['mailbox'], $this->sessionData['sort'], $this->sessionData['sortReverse'], - $bofilter->getFilter($this->sessionData['activeFilter']) + $this->sessionData['messageFilter'] ); if(!is_array($sortResult) || empty($sortResult)) { @@ -398,18 +396,6 @@ class ajaxfelamimail return $this->generateMessageList($this->sessionData['mailbox']); } - function extendedSearch($_filterID) - { - // start displaying at message 1 - $this->sessionData['startMessage'] = 1; - $this->sessionData['activeFilter'] = (int)$_filterID; - $this->saveSessionData(); - $GLOBALS['egw']->session->commit_session(); - - // generate the new messageview - return $this->generateMessageList($this->sessionData['mailbox']); - } - /* * flag messages as read, unread, flagged, ... * @@ -738,8 +724,6 @@ class ajaxfelamimail function quickSearch($_searchType, $_searchString, $_status) { - // save the filter - $bofilter = CreateObject('felamimail.bofilter'); $filter['filterName'] = lang('Quicksearch'); $filter['type'] = $_searchType; @@ -756,6 +740,18 @@ class ajaxfelamimail return $this->generateMessageList($this->sessionData['mailbox']); } + function clearSearch() + { + $this->sessionData['messageFilter'] = array(); + + $this->sessionData['startMessage'] = 1; + + $this->saveSessionData(); + + // generate the new messageview + return $this->generateMessageList($this->sessionData['mailbox']); + } + function refreshMessagePreview($_messageID,$_folderType) { diff --git a/felamimail/inc/class.bocompose.inc.php b/felamimail/inc/class.bocompose.inc.php index ed8bcdede2..ff1794c78b 100644 --- a/felamimail/inc/class.bocompose.inc.php +++ b/felamimail/inc/class.bocompose.inc.php @@ -16,7 +16,7 @@ { var $public_functions = array ( - 'addAtachment' => True, + 'addAttachment' => True, 'action' => True ); diff --git a/felamimail/inc/class.uifelamimail.inc.php b/felamimail/inc/class.uifelamimail.inc.php index 619bf1e0a2..eb48c906d0 100644 --- a/felamimail/inc/class.uifelamimail.inc.php +++ b/felamimail/inc/class.uifelamimail.inc.php @@ -18,7 +18,6 @@ var $public_functions = array ( 'addVcard' => True, - 'changeFilter' => True, 'changeFolder' => True, 'changeSorting' => True, 'compressFolder' => True, @@ -41,7 +40,6 @@ var $icServerID=0; var $connectionStatus = false; var $bofelamimail; - var $bofilter; var $bopreferences; function uifelamimail() @@ -54,7 +52,6 @@ $this->displayCharset = $GLOBALS['egw']->translation->charset(); $this->bofelamimail = CreateObject('felamimail.bofelamimail',$this->displayCharset,false); - $this->bofilter = CreateObject('felamimail.bofilter',false); $this->bopreferences =& $this->bofelamimail->bopreferences; //CreateObject('felamimail.bopreferences'); $this->preferences = $this->bopreferences->getPreferences(); @@ -109,23 +106,6 @@ $GLOBALS['egw']->common->egw_exit(); } - function changeFilter() - { - error_log(__METHOD__." called from:".function_backtrace()); - if(isset($_POST["filter"])) - { - $data['quickSearch'] = $_POST["quickSearch"]; - $data['filter'] = $_POST["filter"]; - $this->bofilter->updateFilter($data); - } - elseif(isset($_GET["filter"])) - { - $data['filter'] = $_GET["filter"]; - $this->bofilter->updateFilter($data); - } - $this->viewMainScreen(); - } - function changeFolder() { // change folder @@ -445,7 +425,6 @@ unset($_GET["message"]); #printf ("this->uifelamimail->viewMainScreen() start: %s
",date("H:i:s",mktime())); $bopreferences =& $this->bopreferences; - $bofilter =& $this->bofilter; $uiwidgets = CreateObject('felamimail.uiwidgets'); $preferences =& $bopreferences->getPreferences(); @@ -827,25 +806,12 @@ ); $this->t->set_var('url_compose_empty',"egw_openWindowCentered('".$GLOBALS['egw']->link('/index.php',$linkData)."','test',700,egw_getWindowOuterHeight());"); - - $linkData = array - ( - 'menuaction' => 'felamimail.uifilter.mainScreen' - ); - $this->t->set_var('url_filter',$GLOBALS['egw']->link('/index.php',$linkData)); - $linkData = array ( 'menuaction' => 'felamimail.uifelamimail.handleButtons' ); $this->t->set_var('url_change_folder',$GLOBALS['egw']->link('/index.php',$linkData)); - $linkData = array - ( - 'menuaction' => 'felamimail.uifelamimail.changeFilter' - ); - $this->t->set_var('url_search_settings',$GLOBALS['egw']->link('/index.php',$linkData)); - $this->t->set_var('lang_mark_messages_as',lang('mark messages as')); $this->t->set_var('lang_delete',lang('delete')); diff --git a/felamimail/js/jscode/viewMainScreen.js b/felamimail/js/jscode/viewMainScreen.js new file mode 100644 index 0000000000..cf02b20d3f --- /dev/null +++ b/felamimail/js/jscode/viewMainScreen.js @@ -0,0 +1,660 @@ +function setStatusMessage(_message) { + document.getElementById('messageCounter').innerHTML = '
 ' + _message + '
'; +} + +function sendNotifyMS (uid) { + ret = confirm(lang_sendnotify); + xajax_doXMLHTTP("felamimail.ajaxfelamimail.sendNotify",uid,ret); +} + +function changeSorting(_sort, _aNode) { + + resetMessageSelect(); + + document.getElementById('messageCounter').innerHTML = 'Change sorting ...'; + document.getElementById('divMessageList').innerHTML = ''; + aTags = document.getElementById('tableHeader').getElementsByTagName('a'); + aTags[0].style.fontWeight='normal'; + aTags[1].style.fontWeight='normal'; + aTags[2].style.fontWeight='normal'; + aTags[3].style.fontWeight='normal'; + xajax_doXMLHTTP("felamimail.ajaxfelamimail.changeSorting",_sort); + _aNode.style.fontWeight='bold'; +} + +function compressFolder() { + if (document.getElementById('messageCounter').innerHTML.search(eval('/'+lang_updating_view+'/'))<0 ) {MessageBuffer = document.getElementById('messageCounter').innerHTML;} + setStatusMessage(''+ lang_compressingFolder +''); + xajax_doXMLHTTP("felamimail.ajaxfelamimail.compressFolder"); +} + +function deleteMessages(_messageList) { + var Check = true; + var cbAllMessages = document.getElementById('selectAllMessagesCheckBox').checked; + + resetMessageSelect(); + + if (cbAllMessages == true) Check = confirm(lang_confirm_all_messages); + if (cbAllMessages == true && Check == true) + { + _messageList = 'all'; + } + if (Check == true) { + setStatusMessage('' + lang_deleting_messages + ''); + document.getElementById('divMessageList').innerHTML = ''; + xajax_doXMLHTTP("felamimail.ajaxfelamimail.deleteMessages",_messageList); + } else { + for(i=0; i< document.forms.formMessageList.elements.length; i++) { + if(document.forms.formMessageList.elements[i].checked) { + document.forms.formMessageList.elements[i].checked = false; + } + } + } +} + +function displayMessage(_url,_windowName) { + egw_openWindowCentered(_url, _windowName, 850, egw_getWindowOuterHeight()); +} + +function fm_displayHeaderLines(_url) { + egw_openWindowCentered(_url,'fm_display_headerLines','700','600',window.outerWidth/2,window.outerHeight/2); +} + +function emptyTrash() { + if (document.getElementById('messageCounter').innerHTML.search(eval('/'+lang_updating_view+'/'))<0 ) {MessageBuffer = document.getElementById('messageCounter').innerHTML;} + setStatusMessage('' + lang_emptyTrashFolder + ''); + xajax_doXMLHTTP("felamimail.ajaxfelamimail.emptyTrash"); +} + +function tellUser(message,_nodeID) { + if (_nodeID) { + alert(message+tree.getUserData(_nodeID, 'folderName')); + } else { + alert(message); + } +} + +function getTreeNodeOpenItems(_nodeID, mode) { + var z = tree.getSubItems(_nodeID).split(","); + var oS; + var PoS; + var rv; + var returnValue = ""+_nodeID; + var modetorun = "none"; + if (mode) { modetorun = mode } + PoS = tree.getOpenState(_nodeID) + if (modetorun == "forced") PoS = 1; + if (PoS == 1) { + for(var i=0;i"; + if (prefAskForMove == 2) message = message + " "; + message = message + " "; + type = 'prompt'; + autohide = 0; + showDialog(title,message,type,autohide); + Check = false; + actionPending = true; + } + if (prefAskForMove==99) actionPending = 'copy'; + if (Check == true && document.getElementById('selectAllMessagesCheckBox').checked == true) Check = confirm(lang_confirm_all_messages); + if (Check == true) + { + if (document.getElementById('messageCounter').innerHTML.search(eval('/'+lang_updating_view+'/'))<0 ) {MessageBuffer = document.getElementById('messageCounter').innerHTML;} + if (document.getElementById('selectAllMessagesCheckBox').checked == true) { + resetMessageSelect(); + formData = 'all'; + } else { + resetMessageSelect(); + formData = xajax.getFormValues('formMessageList'); + } + if (actionPending == 'copy') + { + setStatusMessage(copyingMessages +' '+ tree.getUserData(_nodeID, 'folderName') +''); + document.getElementById('divMessageList').innerHTML = ''; + xajax_doXMLHTTP("felamimail.ajaxfelamimail.copyMessages", _nodeID, formData); + } + else + { + // default: move messages + setStatusMessage(movingMessages +' '+ tree.getUserData(_nodeID, 'folderName') +''); + document.getElementById('divMessageList').innerHTML = ''; + xajax_doXMLHTTP("felamimail.ajaxfelamimail.moveMessages", _nodeID, formData); + } + } else { + if (actionPending == false) + { + resetMessageSelect(); + for(i=0; i< document.forms.formMessageList.elements.length; i++) { + if(document.forms.formMessageList.elements[i].checked) { + document.forms.formMessageList.elements[i].checked = false; + } + } + } + } + } else { + resetMessageSelect(); + setStatusMessage('' + lang_loading + ' ' + tree.getUserData(_nodeID, 'folderName') + ''); + document.getElementById('divMessageList').innerHTML = ''; + xajax_doXMLHTTP("felamimail.ajaxfelamimail.updateMessageView",_nodeID); + refreshFolderStatus(_nodeID); + } + } + CopyOrMove = true; +} + +function quickSearch() { + var searchType; + var searchString; + var status; + + resetMessageSelect(); + //disable select allMessages in Folder Checkbox, as it is not implemented for filters + document.getElementById('selectAllMessagesCheckBox').disabled = true; + setStatusMessage('' + lang_updating_view + ''); + document.getElementById('divMessageList').innerHTML = ''; + + document.getElementById('quickSearch').select(); + + searchType = document.getElementById('searchType').value; + searchString = document.getElementById('quickSearch').value; + status = document.getElementById('status').value; + if (searchString+'grrr###'+status == 'grrr###any') document.getElementById('selectAllMessagesCheckBox').disabled = false; + + xajax_doXMLHTTP('felamimail.ajaxfelamimail.quickSearch', searchType, searchString, status); +} + +function selectFolderContent(inputBox, _refreshTimeOut) { + maxMessages = 0; + + selectAll(inputBox, _refreshTimeOut); +} + +function selectAll(inputBox, _refreshTimeOut) { + maxMessages = 0; + + for (var i = 0; i < document.getElementsByTagName('input').length; i++) { + if(document.getElementsByTagName('input')[i].name == 'msg[]') { + //alert(document.getElementsByTagName('input')[i].name); + document.getElementsByTagName('input')[i].checked = inputBox.checked; + maxMessages++; + } + } + + folderFunctions = document.getElementById('folderFunction'); + + if(inputBox.checked) { + checkedCounter = maxMessages; + while (folderFunctions.hasChildNodes()) { + folderFunctions.removeChild(folderFunctions.lastChild); + } + var textNode = document.createTextNode(lang_select_target_folder); + folderFunctions.appendChild(textNode); + document.getElementsByName("folderAction")[0].value = "moveMessage"; + fm_startTimerMessageListUpdate(1800000); + } else { + checkedCounter = 0; + while (folderFunctions.hasChildNodes()) { + folderFunctions.removeChild(folderFunctions.lastChild); + } + var textNode = document.createTextNode(''); + folderFunctions.appendChild(textNode); + document.getElementsByName("folderAction")[0].value = "changeFolder"; + fm_startTimerMessageListUpdate(_refreshTimeOut); + } +} + +function toggleFolderRadio(inputBox, _refreshTimeOut) { + + folderFunctions = document.getElementById("folderFunction"); + checkedCounter += (inputBox.checked) ? 1 : -1; + if (checkedCounter > 0) { + while (folderFunctions.hasChildNodes()) { + folderFunctions.removeChild(folderFunctions.lastChild); + } + var textNode = document.createTextNode('{lang_move_message}'); + //folderFunctions.appendChild(textNode); + document.getElementById("folderFunction").innerHTML=lang_select_target_folder; + document.getElementsByName("folderAction")[0].value = "moveMessage"; + fm_startTimerMessageListUpdate(1800000); + } else { + document.getElementById('messageCheckBox').checked = false; + document.getElementById('selectAllMessagesCheckBox').checked = false; + while (folderFunctions.hasChildNodes()) { + folderFunctions.removeChild(folderFunctions.lastChild); + } + //var textNode = document.createTextNode('{lang_change_folder}'); + //folderFunctions.appendChild(textNode); + document.getElementsByName("folderAction")[0].value = "changeFolder"; + fm_startTimerMessageListUpdate(_refreshTimeOut); + } +} + +function flagMessages(_flag) +{ + var Check=true; + var _messageList; + var cbAllMessages = document.getElementById('selectAllMessagesCheckBox').checked; + resetMessageSelect(); + if (cbAllMessages == true) Check = confirm(lang_confirm_all_messages); + if (cbAllMessages == true && Check == true) + { + _messageList = 'all'; + } else { + _messageList = xajax.getFormValues('formMessageList'); + } + + //alert(_messageList); + + if (Check == true) + { + setStatusMessage('' + lang_updating_message_status + ''); + xajax_doXMLHTTP("felamimail.ajaxfelamimail.flagMessages", _flag, _messageList); + document.getElementById('divMessageList').innerHTML = ''; + fm_startTimerMessageListUpdate(refreshTimeOut); + } else { + for(i=0; i< document.forms.formMessageList.elements.length; i++) { + if(document.forms.formMessageList.elements[i].checked) { + document.forms.formMessageList.elements[i].checked = false; + } + } + } +} + +function resetMessageSelect() +{ + if (document.getElementById('messageCounter').innerHTML.search(eval('/'+lang_updating_view+'/'))<0 ) {MessageBuffer = document.getElementById('messageCounter').innerHTML;} + document.getElementById('messageCheckBox').checked = false; + document.getElementById('selectAllMessagesCheckBox').checked = false; + checkedCounter = 0; + folderFunctions = document.getElementById('folderFunction'); + + while (folderFunctions.hasChildNodes()) + folderFunctions.removeChild(folderFunctions.lastChild); + var textNode = document.createTextNode(''); + folderFunctions.appendChild(textNode); + document.getElementsByName("folderAction")[0].value = "changeFolder"; +} + +function skipForward() +{ + resetMessageSelect(); + + setStatusMessage(''+ lang_skipping_forward +''); + document.getElementById('divMessageList').innerHTML = ''; + + xajax_doXMLHTTP('felamimail.ajaxfelamimail.skipForward'); +} + +function skipPrevious() { + resetMessageSelect(); + + setStatusMessage(''+ lang_skipping_previous +''); + document.getElementById('divMessageList').innerHTML = ''; + + xajax_doXMLHTTP('felamimail.ajaxfelamimail.skipPrevious'); +} + +function jumpEnd() { + resetMessageSelect(); + + setStatusMessage(''+ lang_jumping_to_end +''); + document.getElementById('divMessageList').innerHTML = ''; + + xajax_doXMLHTTP('felamimail.ajaxfelamimail.jumpEnd'); +} + +function jumpStart() { + resetMessageSelect(); + + setStatusMessage(''+ lang_jumping_to_start +''); + document.getElementById('divMessageList').innerHTML = ''; + + xajax_doXMLHTTP('felamimail.ajaxfelamimail.jumpStart'); +} + +var searchesPending=0; + +function refresh() { + //searchesPending++; + //document.title=searchesPending; + resetMessageSelect(); + xajax_doXMLHTTP('felamimail.ajaxfelamimail.refreshMessageList'); + if (fm_previewMessageID>0) + { + //setStatusMessage(''+ lang_updating_view +''); + //xajax_doXMLHTTP("felamimail.ajaxfelamimail.refreshMessagePreview",fm_previewMessageID,fm_previewMessageFolderType); + } +} + +function refreshFolderStatus(_nodeID,mode) { + var nodeToRefresh = 0; + var mode2use = "none"; + if (document.getElementById('messageCounter')) { + if (document.getElementById('messageCounter').innerHTML.search(eval('/'+lang_updating_view+'/'))<0 ) {MessageBuffer = document.getElementById('messageCounter').innerHTML;} + } + if (_nodeID) nodeToRefresh = _nodeID; + if (mode) { + if (mode == "forced") {mode2use = mode;} + } + var activeFolders = getTreeNodeOpenItems(nodeToRefresh,mode2use); + xajax_doXMLHTTP('felamimail.ajaxfelamimail.refreshFolderList', activeFolders); +// if (fm_previewMessageID>0) +// { +// //setStatusMessage(''+ lang_updating_view +''); +// //xajax_doXMLHTTP("felamimail.ajaxfelamimail.refreshMessagePreview",fm_previewMessageID,fm_previewMessageFolderType); +// } +} + +function refreshView() { + if (document.getElementById('messageCounter').innerHTML.search(eval('/'+lang_updating_view+'/'))<0 ) {MessageBuffer = document.getElementById('messageCounter').innerHTML;} + document.mainView.submit(); + document.getElementById('messageCounter').innerHTML = MessageBuffer; +} + +function openComposeWindow(_url) { + var Check=true; + var _messageList; + var cbAllMessages = document.getElementById('selectAllMessagesCheckBox').checked; + resetMessageSelect(); + if (cbAllMessages == true) Check = confirm(lang_confirm_all_messages); + if (cbAllMessages == true && Check == true) + { + _messageList = 'all'; + } else { + _messageList = xajax.getFormValues('formMessageList'); + } + sMessageList=''; + for (var i in _messageList['msg']) { + //alert('eigenschaft:'+_messageList['msg'][i]); + sMessageList=sMessageList+_messageList['msg'][i]+','; + //sMessageList.concat(','); + } + if (sMessageList.length >0) { + sMessageList= 'AsForward&forwardmails=1&folder='+activeFolderB64+'&reply_id='+sMessageList.substring(0,sMessageList.length-1); + } + //alert(sMessageList); + if (Check == true) + { + egw_openWindowCentered(_url+sMessageList,'compose',700,egw_getWindowOuterHeight()); + } + for(i=0; i< document.forms.formMessageList.elements.length; i++) { + if(document.forms.formMessageList.elements[i].checked) { + document.forms.formMessageList.elements[i].checked = false; + } + } +} + +// timer functions +function fm_startTimerFolderStatusUpdate(_refreshTimeOut) { + if(fm_timerFolderStatus) { + window.clearTimeout(fm_timerFolderStatus); + } + if(_refreshTimeOut > 5000) { + fm_timerFolderStatus = window.setInterval("refreshFolderStatus()", _refreshTimeOut); + } +} + +function fm_startTimerMessageListUpdate(_refreshTimeOut) { + if(aktiv) { + window.clearTimeout(aktiv); + } + if(_refreshTimeOut > 5000) { + aktiv = window.setInterval("refresh()", _refreshTimeOut); + } +} + +function fm_readMessage(_url, _windowName, _node) { + var windowArray = _windowName.split('_'); + if (windowArray[0] == 'MessagePreview') + { + //document.getElementById('spanMessagePreview').innerHTML = ''; + if (document.getElementById('messageCounter').innerHTML.search(eval('/'+lang_updating_view+'/'))<0 ) {MessageBuffer = document.getElementById('messageCounter').innerHTML;} + setStatusMessage(''+ lang_updating_view +''); + fm_previewMessageID = windowArray[1]; + fm_previewMessageFolderType = windowArray[2]; + xajax_doXMLHTTP("felamimail.ajaxfelamimail.refreshMessagePreview",windowArray[1],windowArray[2]); + } else { + egw_openWindowCentered(_url, _windowName, 750, egw_getWindowOuterHeight()); + } + trElement = _node.parentNode.parentNode.parentNode; + trElement.style.fontWeight='normal'; + + aElements = trElement.getElementsByTagName("a"); + aElements[0].style.fontWeight='normal'; + aElements[1].style.fontWeight='normal'; + xajax_doXMLHTTP("felamimail.ajaxfelamimail.refreshFolder"); +} + +function fm_readAttachments(_url, _windowName, _node) { + egw_openWindowCentered(_url, _windowName, 750, 220); +} + +function fm_clearSearch() { + var inputQuickSearch = document.getElementById('quickSearch'); + var status = document.getElementById('status').value; + + //enable select allMessages in Folder Checkbox again + if (status == 'any') document.getElementById('selectAllMessagesCheckBox').disabled = false; + + if(inputQuickSearch.value != '') { + inputQuickSearch.value = ''; + quickSearch(); + } + + inputQuickSearch.focus(); + xajax_doXMLHTTP('felamimail.ajaxfelamimail.clearSearch'); +} + +function changeActiveAccount(_accountSelection) +{ + //alert(_accountSelection.value); + xajax_doXMLHTTP('felamimail.ajaxfelamimail.changeActiveAccount',_accountSelection.value); +} + +// DIALOG BOXES by Michael Leigeber +// global variables // +var TIMER = 5; +var SPEED = 10; +var WRAPPER = 'divPoweredBy'; + +// calculate the current window width // +function pageWidth() { + return window.innerWidth != null ? window.innerWidth : document.documentElement && document.documentElement.clientWidth ? document.documentElement.clientWidth : document.body != null ? document.body.clientWidth : null; +} + +// calculate the current window height // +function pageHeight() { + return window.innerHeight != null? window.innerHeight : document.documentElement && document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight : null; +} + +// calculate the current window vertical offset // +function topPosition() { + return typeof window.pageYOffset != 'undefined' ? window.pageYOffset : document.documentElement && document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop ? document.body.scrollTop : 0; +} + +// calculate the position starting at the left of the window // +function leftPosition() { + return typeof window.pageXOffset != 'undefined' ? window.pageXOffset : document.documentElement && document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft ? document.body.scrollLeft : 0; +} + +// build/show the dialog box, populate the data and call the fadeDialog function // +function showDialog(title,message,type,autohide) { + if(!type) { + type = 'error'; + } + var dialog; + var dialogheader; + var dialogclose; + var dialogtitle; + var dialogcontent; + var dialogmask; + if(!document.getElementById('dialog')) { + dialog = document.createElement('div'); + dialog.id = 'dialog'; + dialogheader = document.createElement('div'); + dialogheader.id = 'dialog-header'; + dialogtitle = document.createElement('div'); + dialogtitle.id = 'dialog-title'; + dialogclose = document.createElement('div'); + dialogclose.id = 'dialog-close' + dialogcontent = document.createElement('div'); + dialogcontent.id = 'dialog-content'; + dialogmask = document.createElement('div'); + dialogmask.id = 'dialog-mask'; + document.body.appendChild(dialogmask); + document.body.appendChild(dialog); + dialog.appendChild(dialogheader); + dialogheader.appendChild(dialogtitle); + dialogheader.appendChild(dialogclose); + dialog.appendChild(dialogcontent);; + dialogclose.setAttribute('onclick','hideDialog()'); + dialogclose.onclick = hideDialog; + } else { + dialog = document.getElementById('dialog'); + dialogheader = document.getElementById('dialog-header'); + dialogtitle = document.getElementById('dialog-title'); + dialogclose = document.getElementById('dialog-close'); + dialogcontent = document.getElementById('dialog-content'); + dialogmask = document.getElementById('dialog-mask'); + dialogmask.style.visibility = "visible"; + dialog.style.visibility = "visible"; + } + dialog.style.opacity = .00; + dialog.style.filter = 'alpha(opacity=0)'; + dialog.alpha = 0; + var width = pageWidth(); + var height = pageHeight(); + var left = leftPosition(); + var top = topPosition(); + var dialogwidth = dialog.offsetWidth; + var dialogheight = dialog.offsetHeight; + var topposition = top + (height / 3) - (dialogheight / 2); + var leftposition = left + (width / 2) - (dialogwidth / 2); + dialog.style.top = topposition + "px"; + dialog.style.left = leftposition + "px"; + dialogheader.className = type + "header"; + dialogtitle.innerHTML = title; + dialogcontent.className = type; + dialogcontent.innerHTML = message; + var content = document.getElementById(WRAPPER); + dialogmask.style.height = content.offsetHeight + 'px'; + dialog.timer = setInterval("fadeDialog(1)", TIMER); + if(autohide) { + dialogclose.style.visibility = "hidden"; + window.setTimeout("hideDialog()", (autohide * 1000)); + } else { + dialogclose.style.visibility = "visible"; + } +} + +// hide the dialog box // +function hideDialog() { + var dialog = document.getElementById('dialog'); + clearInterval(dialog.timer); + dialog.timer = setInterval("fadeDialog(0)", TIMER); +} + +// fade-in the dialog box // +function fadeDialog(flag) { + if(flag == null) { + flag = 1; + } + var dialog = document.getElementById('dialog'); + var value; + if(flag == 1) { + value = dialog.alpha + SPEED; + } else { + value = dialog.alpha - SPEED; + } + dialog.alpha = value; + dialog.style.opacity = (value / 100); + dialog.style.filter = 'alpha(opacity=' + value + ')'; + if(value >= 99) { + clearInterval(dialog.timer); + dialog.timer = null; + } else if(value <= 1) { + dialog.style.visibility = "hidden"; + document.getElementById('dialog-mask').style.visibility = "hidden"; + clearInterval(dialog.timer); + } +} +