diff --git a/UI/WebServerResources/AdministrationUI.css b/UI/WebServerResources/AdministrationUI.css deleted file mode 100644 index 46e787a1a..000000000 --- a/UI/WebServerResources/AdministrationUI.css +++ /dev/null @@ -1,136 +0,0 @@ -DIV#helpDialog -{ - width: 300px; -} - -DIV#helpDialog H3 -{ - font-size: 1.2em; - margin: 0; - padding: 0; -} - -DIV#helpDialog DIV DIV -{ - border: 0; - margin: 0; - padding: 0; -} - -DIV#helpDialog P.button -{ - margin: 0; - padding: 0 0 5px 0; - text-align: right; -} - -DIV#verticalDragHandle -{ - cursor: e-resize; - top: 6em; - left: 15em; - width: 5px; - bottom: 0px; -} - -.titlediv -{ - vertical-align: bottom; - padding-top: 14px; - padding-left: 6px; -} - -DIV#administrationModules -{ - position: absolute; - top: 9em; - left: 0; - width: 15em; - bottom: 2px; - margin: 0px; - padding: 0px; - overflow: hidden; -} - -DIV#administrationModules UL -{ - display: block; - list-style-type: none; - list-style-image: none; - clear: both; - cursor: default; - color: #000; - position: absolute; /* required for Safari & IE */ - top: 0px; - bottom: 0px; - left: 0; - right: 0; - width: auto; - margin: 0px; - padding: 0px; - overflow: auto; - overflow-x: hidden; - border-top: 1px solid #909090; - border-left: 1px solid #909090; - border-bottom: 1px solid #FFFFFF; - border-right: 1px solid #FFFFFF; - -moz-user-select: none; - -khtml-user-select: none; -} -DIV#administrationModules -{ background: #CCDDEC; } - -DIV#administrationModules UL LI -{ - cursor: pointer; - line-height: 20px; - height: 20px; - padding-left: 0.5em; - margin: 0px; - width: auto; - white-space: nowrap; -} - -DIV#rightPanel -{ - position: absolute; - top: 80px; - left: 15em; - margin-left: 5px; - right: 0px; - bottom: 0px; - overflow: hidden; -} - -DIV#rightPanel > SPAN -{ - float: left; -} - -DIV#rightPanel H1 -{ - font-size: 14px; - margin: 0.5em 0 5px 0; -} - -DIV#filterPanel -{ - n0padding-top: 5px; - width: auto; -} - -DIV#administrationContent -{ - position: absolute; - left: 0; - right: 1em; - top: 3em; - bottom: 2px; - background-color: #fff; - padding: .5em; - overflow: auto; - border-top: 1px solid #909090; - border-left: 1px solid #909090; - border-bottom: 1px solid #FFFFFF; - border-right: 1px solid #FFFFFF; -} diff --git a/UI/WebServerResources/AdministrationUI.js b/UI/WebServerResources/AdministrationUI.js deleted file mode 100644 index 961beedf9..000000000 --- a/UI/WebServerResources/AdministrationUI.js +++ /dev/null @@ -1,221 +0,0 @@ -/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -var d; -var usersRightsWindowHeight = 220; -var usersRightsWindowWidth = 450; - -/* ACLs module */ - -function onSearchFormSubmit(panel) { - var searchValue = panel.down('[name="search"]'); - var encodedValue = encodeURI(searchValue.value); - - if (encodedValue.blank()) { - checkAjaxRequestsState(); - } - else { - var url = (UserFolderURL - + "usersSearch?search=" + encodedValue); - if (document.userFoldersRequest) { - document.userFoldersRequest.aborted = true; - document.userFoldersRequest.abort(); - } - document.userFoldersRequest - = triggerAjaxRequest(url, usersSearchCallback); - } - - return false; -} - -function usersSearchCallback(http) { - document.userFoldersRequest = null; - var div = $("administrationContent"); - if (http.status == 200) { - var response = http.responseText.evalJSON(); - buildUsersTree(div, response) - } - else if (http.status == 404) - div.update(); -} - -function buildUsersTree(treeDiv, response) { - d = new dTree("d"); - d.config.hideRoot = true; - d.icon.root = ResourcesURL + '/tbtv_account_17x17.gif'; - d.icon.folder = ResourcesURL + '/tbtv_leaf_corner_17x17.png'; - d.icon.folderOpen = ResourcesURL + '/tbtv_leaf_corner_17x17.png'; - d.icon.node = ResourcesURL + '/tbtv_leaf_corner_17x17.png'; - d.icon.line = ResourcesURL + '/tbtv_line_17x22.png'; - d.icon.join = ResourcesURL + '/tbtv_junction_17x22.png'; - d.icon.joinBottom = ResourcesURL + '/tbtv_corner_17x22.png'; - d.icon.plus = ResourcesURL + '/tbtv_plus_17x22.png'; - d.icon.plusBottom = ResourcesURL + '/tbtv_corner_plus_17x22.png'; - d.icon.minus = ResourcesURL + '/tbtv_minus_17x22.png'; - d.icon.minusBottom = ResourcesURL + '/tbtv_corner_minus_17x22.png'; - d.icon.nlPlus = ResourcesURL + '/tbtv_corner_plus_17x22.png'; - d.icon.nlMinus = ResourcesURL + '/tbtv_corner_minus_17x22.png'; - d.icon.empty = ResourcesURL + '/empty.gif'; - d.preload (); - d.add(0, -1, ''); - - var isUserDialog = false; - var multiplier = ((isUserDialog) ? 1 : 2); - - for (var i = 0; i < response.length; i++) - addUserLineToTree(d, 1 + i * multiplier, response[i]); - treeDiv.innerHTML = ""; - treeDiv.appendChild(d.domObject()); - treeDiv.clean = false; - for (var i = 0; i < response.length; i++) { - if (!isUserDialog) { - var toggle = $("tgd" + (1 + i * 2)); - toggle.observe ("click", onUserNodeToggle); - } - var sd = $("sd" + (1 + i * multiplier)); - sd.observe("click", onTreeItemClick); - } -} - -function addUserLineToTree(tree, parent, line) { - var icon = ResourcesURL + '/busy.gif'; - - var email = line[1] + " <" + line[2] + ">"; - if (line[4] && !line[4].empty()) - email += ", " + line[4]; // extra contact info - tree.add(parent, 0, email, 0, '#', line[0], 'person', - '', '', - ResourcesURL + '/abcard.png', - ResourcesURL + '/abcard.png'); - tree.add(parent + 1, parent, _("Please wait..."), 0, '#', null, - null, '', '', icon, icon); -} - -function onTreeItemClick(event) { - preventDefault(event); - - var topNode = $("d"); - if (topNode.selectedEntry) - topNode.selectedEntry.deselect(); - this.selectElement(); - topNode.selectedEntry = this; -} - -function onUserNodeToggle(event) { - this.stopObserving("click", onUserNodeToggle); - - var person = this.parentNode.getAttribute("dataname"); - var url = (UserFolderURLForUser(person) + "foldersSearch"); - var nodeId = this.getAttribute("id").substr(3); - triggerAjaxRequest(url, foldersSearchCallback, - { nodeId: nodeId, user: person }); -} - -function foldersSearchCallback(http) { - if (http.status == 200) { - var response = http.responseText; - var nodeId = parseInt(http.callbackData["nodeId"]); - - var dd = $("dd" + (nodeId + 2)); - var indentValue = (dd ? 1 : 0); - d.aIndent.push(indentValue); - - var dd = $("dd" + nodeId); - if (response.length) { - var folders = response.evalJSON(); - var user = http.callbackData["user"]; - - dd.innerHTML = ''; - for (var i = 0; i < folders.length - 1; i++) - dd.appendChild(addFolderBranchToTree (d, user, folders[i], nodeId, i+1, false)); - dd.appendChild (addFolderBranchToTree (d, user, folders[folders.length-1], nodeId, - (folders.length), true)); - for (var i = 0; i < folders.length; i++) { - var sd = $("sd" + (nodeId + i + 1)); - sd.observe("click", onTreeItemClick); - sd.observe("dblclick", onFolderOpen); - } - } - else { - dd.innerHTML = ''; - dd.appendChild (addFolderNotFoundNode (d, nodeId, null)); - var sd = $("sd" + (nodeId + 1)); - sd.observe("click", onTreeItemClick); - } - - d.aIndent.pop(); - } -} - -function addFolderBranchToTree(tree, user, folder, nodeId, subId, isLast) { - var icon = ResourcesURL + '/'; - if (folder.type == 'Contact') - icon += 'tb-mail-addressbook-flat-16x16.png'; - else - icon += 'calendar-folder-16x16.png'; - var folderId = user + ":" + folder.name.substr(1); - var name = folder.displayName.escapeHTML(); - var node = new dTreeNode(subId, nodeId, name, 0, '#', folderId, - folder.type + '-folder', '', '', icon, icon); - node._ls = isLast; - var content = tree.node(node, (nodeId + subId), null); - - return content; -} - -function addFolderNotFoundNode (tree, nodeId) { - var icon = ResourcesURL + '/icon_unread.gif'; - var node = new dTreeNode(1, nodeId, _("No possible subscription"), 0, '#', - null, null, '', '', icon, icon); - node._ls = true; - return tree.node(node, (nodeId + 1), null); -} - -function onFolderOpen(event) { - var obj = Event.element(event); - var node = obj.up("div.dTreeNode"); - var folderID = node.readAttribute("dataname"); - var urlstr = URLForFolderID(folderID) + "/acls"; - openAclWindow(urlstr); -} - -/* Common functions */ - -function configureDragHandles() { - var handle = $("verticalDragHandle"); - if (handle) { - handle.addInterface(SOGoDragHandlesInterface); - handle.leftBlock = $("administrationModules"); - handle.rightBlock = $("rightPanel"); - handle.leftMargin = 100; - } -} - -function help() { - var div = $("helpDialog"); - var title = div.select('H3').first(); - var description = div.select('DIV DIV')[0]; - var module = $$("#administrationModules LI._selected").first(); - - var cellPosition = module.cumulativeOffset(); - var cellDimensions = module.getDimensions(); - var left = cellDimensions.width - 20; - var top = cellPosition.top + 3; - - div.setStyle({ top: top + 'px', - left: left + 'px' }); - title.update($("moduleTitle").innerHTML); - description.update($("moduleDescription").innerHTML); - - div.show(); -} - -function initAdministration() { - $("helpDialogClose").observe("click", function(event) { - $("helpDialog").hide(); - }); - - var searchValue = $$('[data-search="admin"] [name="search"]').first(); - searchValue.focus(); -} - -document.observe("dom:loaded", initAdministration); diff --git a/UI/WebServerResources/COPYING-thunderbird.txt b/UI/WebServerResources/COPYING-thunderbird.txt deleted file mode 100644 index 74925c7d0..000000000 --- a/UI/WebServerResources/COPYING-thunderbird.txt +++ /dev/null @@ -1,5 +0,0 @@ -The default theme icons are derived from the icons provided as -part of the Mozilla Thunderbird application. -The licensing terms of Mozilla Thunderbird are available in the -LICENSE-thunderbird.txt file. - diff --git a/UI/WebServerResources/ContactsUI.css b/UI/WebServerResources/ContactsUI.css deleted file mode 100644 index e1423ccb4..000000000 --- a/UI/WebServerResources/ContactsUI.css +++ /dev/null @@ -1,426 +0,0 @@ -/* - Copyright (C) 2005 SKYRIX Software AG - - This file is part of OpenGroupware.org. - - OGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - OGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write to the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -DIV#rightPanel -{ position: absolute; - top: 80px; - left: 15em; - margin-left: 5px; - right: 0px; - bottom: 0px; - overflow: hidden; } - -/* top list */ -DIV#contactsListContent -{ cursor: default; - position: absolute; - background-color: #FFFFFF; - top: 27px; - left: 0px; - right: 0px; - height: 15.5em; - border-left: 1px solid #9B9B9B; - overflow: auto; - overflow-x: hidden; } - -.aptview_text -{ - color: #000000; -} - -.apt_other -{ - color: #000000; -} - -.apt_other_print -{ - font-style: italic; -} - -.foldercell -{ - width: 25%; -} - -.titlediv -{ line-height: 18px; - vertical-align: middle; - padding-top: 8px; - padding-left: 6px; } - -TABLE.titletable -{ - height: 24px; - vertical-align: middle; - padding-top: 6px; - padding-left: 6px; -} - -TD.titlecell -{ - height: 22px; - vertical-align: middle; - padding-bottom: 2px; - white-space: nowrap; -} - -TABLE.titletable TD.titlecell SELECT -{ - display: -moz-popup; - border-top: 1px solid #fff; - border-left: 1px solid #fff; - border-right: 2px solid #222; - border-bottom: 2px solid #222; - -moz-border-bottom-colors: #000 #9c9a94 transparent; - -moz-border-right-colors: #000 #9c9a94 transparent; - background-color: #DCDAD5; -} - -.whitesec_title -{ - background-color: #DCDAD5; - padding: 4px; -} - -DIV#contactFoldersList -{ position: absolute; - top: 82px; - left: 0px; - width: 15em; - background-color: #CCDDEC; - bottom: 0px; - margin: 0px; - padding: 0px; - overflow: auto; - overflow-x: hidden; } - -DIV#abToolbar -{ padding-left: 6px; } - -SPAN.toolbarButton -{ float: none; - padding: 14px 2px 0px 2px; } - -A.toolbarButton -{ text-decoration: none; } - -UL#contactFolders -{ list-style-type: none; - list-style-image: none; - clear: left; - cursor: default; - color: #000; - margin: 0px; - padding: 0px; - overflow: auto; - overflow-x: hidden; - -moz-user-select: none; - -khtml-user-select: none; -} - -UL#contactFolders LI -{ - background-repeat: no-repeat; - background-position: 14px 2px; - cursor: pointer; - line-height: 2em; - padding-left: 34px; - margin: 0px; - width: auto; - white-space: nowrap; -} - -DIV#contactFoldersList LI.local -{ - background-image: url('addrbook.png'); -} - -DIV#contactFoldersList LI.remote -{ - background-image: url('remote-addrbook.png'); -} - -.treecell -{ - color: black; - vertical-align: bottom; - padding-left: 4px; /* move away from the icon */ - padding-right: 2px; /* move away from the right border */ - white-space: nowrap; -} - -DIV#folderTreeContent TABLE TD -{ height: 2em; - border-top: 1px solid #fff; - margin: 0px; - padding: 0px; } - -TABLE#contactsList -{ -moz-user-select: none; - -khtml-user-select: none; - width: 100%; } - -TABLE#contactsList TBODY TD -{ cursor: pointer; } - -TABLE#contactsList TD, -TABLE#contactsList TH -{ overflow: hidden; - line-height: 16px; - height: 18px; - text-overflow: ellipsis; - white-space: nowrap; } /* pre, normal, nowrap */ - -TABLE#contactsList TH -{ white-space: pre; } - -TABLE#contactsList TR._deleted TD -{ - text-decoration: line-through; -} - -TABLE#contactsList TD.displayName -{ background-repeat: no-repeat; - background-position: 4px 1px; - padding-left: 24px; } - -TABLE#contactsList TR.vcard TD.displayName -{ - background-image: url('abcard.png'); -} - -TABLE#contactsList TR.vlist TD.displayName -{ - background-image: url('ablist.png'); -} - -DIV#contactView -{ - position: absolute; - background: #fff; - padding: .5em; - top: 18em; - left: 0px; - right: 0px; - bottom: 0px; - overflow: auto; - margin-top: 5px; - border-top: 1px solid #aaa; - border-left: 1px solid #aaa; - line-height: 1em; -} - -DIV#contactView A -{ color: #00f; - text-decoration: none; } - -DIV#contactView H3.contactCardTitle -{ margin: 0px; - padding: .2em 0px; - font-size: large; - font-weight: bold; - text-decoration: underline; } - -DIV.contactColumn -{ width: 50%; - margin: 0; - padding: 0; - float: left; } - -DIV.contactColumn DIV -{ margin: 1em; } - -DIV.contactColumn H4 -{ margin: .2em 0px; - margin-left: 0; - font-size: 10pt; - font-weight: bold; - background: #9ABCD8; - color: #fff; - width: 100%; - padding: .1em .2em; } - -dt { - color: #666; - line-height: 13px; -} -dd { - line-height: 14px; -} -.dl-horizontal dt { - width: 100px; -} -.dl-horizontal dd { - margin-left: 110px; -} - -SPAN.photoFrame -{ cursor: pointer; - float: left; - background-color: #fff; - border: 1px solid #999; - padding: 8px; - margin: 8px; - box-shadow: 0px 1px 1px rgba(0, 0, 0, 0.2); - -moz-transform: rotate(-2deg); - -webkit-transform: rotate(-2deg); - -ms-transform: rotate(-2deg); - -moz-transition: all 0.2s ease-in-out; - -webkit-transition: all 0.2s ease-in-out; } - -SPAN.photoFrame IMG.contactPhoto -{ max-width: 120px; - max-height: 120px;} - -SPAN.photoFrame:hover { - -moz-transform: scale(3.0, 3.0) rotate(0deg) translate(33%, 33%); - -webkit-transform: scale(3.0, 3.0) rotate(0deg) translate(33%, 33%); - -ms-transform: rotate(0deg) scale(3.0, 3.0); } - -/* drag handles */ -DIV#dragHandle -{ cursor: e-resize; - border: 0px; - top: 81px; - left: 15em; - width: 5px; - bottom: 0px; } - -DIV#rightDragHandle -{ - cursor: n-resize; - top: 18em; - left: 0px; - right: 0px; - height: 5px; -} - -DIV.contactSelector -{ - position: absolute; - top: 0px; - bottom: 0px; - right: 0px; - left: 0px; -} - -BODY.popup DIV#rightPanel -{ top: 4em; } - -BODY.popup DIV#dragHandle -{ top: 7em; } - -BODY.popup DIV#contactsListContent -{ height: 7em; - top: 34px; } - -BODY.popup DIV#contactFoldersList -{ top: 50px; } - -BODY.popup DIV#rightDragHandle -{ top: 10.2em; } - -BODY.popup DIV#contactView -{ top: 10.2em; } - -BODY.popup DIV#filterPanel -{ position: relative; - top: 7px; -} - -DIV.contactSelection -{ - z-index: 10; - background: inherit; - position: absolute; - bottom: 0em; - padding: 1em; - left: 0px; - right: 0px; - height: 90px; - text-align: right; - background: #E6E7E6; - border-top: 1px solid #fff; - border-left: 0px; - border-right: 0px; - border-bottom: 0px; -} - -DIV.contactSelection > DIV.calendar -{ text-align: center; } - -DIV.contactSelection INPUT.button -{ font-size: 8pt; - margin-top: .25em; - padding: 0px; } - -DIV.contactSelection SPAN#selectionLabel -{ float: left; } - -DIV#dragDropVisual -{ - background-image: url(abcard.png); - background-repeat: no-repeat; - background-position: 4px 2px; - width: 5px; - height: 20px; - padding-left: 24px; - padding-top: 5px; -} - -DIV.copy -{ - background-image: url(add-contact.gif) !important; - background-position: 1px -2px !important; -} - -@media print -{ - div#linkBanner, - div#contactFoldersList, - div#dragHandle, - div#rightDragHandle, - div.menu, - div#filterPanel, - div#contactsListContent - { - display: none; - } - - div#contactView, - div#rightPanel - { - color: black; - top: 0px; - left: 0px; - margin: 0px; - border: none; - display: block; - visibility: visible; - width: 100%; - height: 100%; - } - - div.contactColumn h4 { - background: none; - } -} diff --git a/UI/WebServerResources/ContactsUI.js b/UI/WebServerResources/ContactsUI.js deleted file mode 100644 index 3386bff6e..000000000 --- a/UI/WebServerResources/ContactsUI.js +++ /dev/null @@ -1,1649 +0,0 @@ -/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ -/* JavaScript for SOGoContacts */ - -var cachedContacts = {}; - -var usersRightsWindowHeight = 194; -var usersRightsWindowWidth = 450; - -var Contact = { - currentAddressBook: "/personal", - currentContactId: null -}; - -var refreshViewCheckTimer; - -function openContactsFolder(contactsFolder, reload, idx) { - if ((contactsFolder && contactsFolder != Contact.currentAddressBook) - || reload) { - Contact.currentAddressBook = contactsFolder; - var url = URLForFolderID(Contact.currentAddressBook, "Contacts") + - "/view?noframe=1"; - - var searchValue = search["contacts"]["value"]; - if (searchValue && searchValue.length > 0) - url += ("&search=" + search["contacts"]["criteria"] - + "&value=" + escape(searchValue.utf8encode())); - var sortAttribute = sorting["attribute"]; - if (sortAttribute && sortAttribute.length > 0) - url += ("&sort=" + sorting["attribute"] - + "&asc=" + sorting["ascending"]); - - var selection; - if (idx) { - selection = [idx.asCSSIdentifier()]; - } - else if (contactsFolder == Contact.currentAddressBook) { - var contactsList = $("contactsList"); - if (contactsList) - selection = contactsList.getSelectedRowsId(); - } - else - selection = null; - - if (document.contactsListAjaxRequest) { - document.contactsListAjaxRequest.aborted = true; - document.contactsListAjaxRequest.abort(); - } - - document.contactsListAjaxRequest - = triggerAjaxRequest(url, contactsListCallback, selection); - } -} - -function contactsListCallback(http) { - if (http.readyState == 4) { - if (http.status == 200) { - document.contactsListAjaxRequest = null; - - var div = $("contactsListContent"); - var table = $("contactsList"); - var tbody = table.tBodies[0]; - var rows = tbody.getElementsByTagName("TR"); - var fullView = (table.tHead.rows[0].cells.length > 2); - var data = []; - if (http.responseText.length > 0) - data = http.responseText.evalJSON(true); - - tbody.deselectAll(); - - div.scrollTop = 0; - if (data.length > 0) { - // Replace existing rows - for (var i = 0; i < data.length && i < rows.length; i++) { - var contact = data[i]; - var row = rows[i]; - row.className = contact["c_component"]; - row.setAttribute("id", contact["c_name"].asCSSIdentifier()); - row.setAttribute("categories", contact["c_categories"]); - row.setAttribute("contactname", contact["c_cn"]); - var cells = row.getElementsByTagName("TD"); - if (contact["c_cn"]) - $(cells[0]).update(contact["c_cn"].escapeHTML()); - else - $(cells[0]).update(); - cells[0].title = contact["c_cn"]; - log('mail ' + contact["c_mail"]); - if (contact["c_mail"]) - $(cells[1]).update(contact["c_mail"].escapeHTML()); - else - $(cells[1]).update(); - cells[1].title = contact["c_mail"]; - if (fullView) { - if (contact["c_screenname"]) - $(cells[2]).update(contact["c_screenname"].escapeHTML()); - else - $(cells[2]).update(); - - if (contact["c_o"]) - $(cells[3]).update(contact["c_o"].escapeHTML()); - else - $(cells[3]).update(); - - if (contact["c_telephonenumber"]) - $(cells[4]).update(contact["c_telephonenumber"].escapeHTML()); - else - $(cells[4]).update(); - } - } - - // Add extra rows - for (var j = i; j < data.length; j++) { - var contact = data[j]; - var row = createElement("tr", - contact["c_name"].asCSSIdentifier(), - contact["c_component"], - null, - { categories: contact["c_categories"], - contactname: contact["c_cn"] }, - tbody); - var cell = createElement("td", - null, - ( "displayName" ), - null, - null, - row); - - if (contact["c_cn"]) { - $(cell).update(contact["c_cn"].escapeHTML()); - cell.title = contact["c_cn"]; - } - - cell = document.createElement("td"); - row.appendChild(cell); - - if (contact["c_mail"]) { - $(cell).update(contact["c_mail"].escapeHTML()); - cell.title = contact["c_mail"]; - } - - if (fullView) { - cell = document.createElement("td"); - row.appendChild(cell); - if (contact["c_screenname"]) - $(cell).update(contact["c_screenname"].escapeHTML()); - - cell = document.createElement("td"); - row.appendChild(cell); - if (contact["c_o"]) - $(cell).update(contact["c_o"].escapeHTML()); - - cell = document.createElement("td"); - row.appendChild(cell); - if (contact["c_telephonenumber"]) - $(cell).update(contact["c_telephonenumber"].escapeHTML()); - } - } - } - - // Remove unnecessary rows - for (i = rows.length - 1; i >= data.length; i--) { - tbody.removeChild(rows[i]); - } - - if (sorting["attribute"] && sorting["attribute"].length > 0) { - var sortHeader; - if (sorting["attribute"] == "c_cn") - sortHeader = $("nameHeader"); - else if (sorting["attribute"] == "c_mail") - sortHeader = $("mailHeader"); - else if (sorting["attribute"] == "c_screenname") - sortHeader = $("screenNameHeader"); - else if (sorting["attribute"] == "c_o") - sortHeader = $("orgHeader"); - else if (sorting["attribute"] == "c_telephonenumber") - sortHeader = $("phoneHeader"); - else - sortHeader = null; - - if (sortHeader) { - var sortImages = $(table.tHead).select(".sortImage"); - $(sortImages).each(function(item) { - item.remove(); - }); - - var sortImage = createElement("img", "messageSortImage", "sortImage"); - sortHeader.insertBefore(sortImage, sortHeader.firstChild); - if (sorting["ascending"]) - sortImage.src = ResourcesURL + "/arrow-up.png"; - else - sortImage.src = ResourcesURL + "/arrow-down.png"; - } - } - - // Restore selection and scroll to first selected node - var selection = http.callbackData; - if (selection && tbody.refreshSelectionByIds(selection) > 0) { - for (var i = 0; i < selection.length; i++) { - var row = $(selection[i]); - if (row) { - var rowPosition = row.rowIndex * row.getHeight(); - if (div.getHeight() < rowPosition) - div.scrollTop = rowPosition; // scroll to selected contact - row.selectElement(); - break; - } - } - } - else - tbody.deselectAll(); - } - else { - // No more access to this address book; empty the list - var table = $("contactsList"); - if (table) { - var sortImages = $(table.tHead).select(".sortImage"); - $(sortImages).each(function(item) { - item.remove(); - }); - var tBody = $(table.tBodies[0]); - var length = tBody.rows.length; - for (var i = length - 1; i > -1; i--) - tBody.removeChild(tBody.rows[i]); - } - } - - configureDraggables(); - } - else - log ("ajax problem 1: status = " + http.status); -} - -function onContactContextMenu(event) { - var target = Event.element(event); - var contact = target.up('TR'); - var contactsList = $("contactsList"); - var contacts = contactsList.getSelectedRows(); - - if (contacts.indexOf(contact) < 0) { - onRowClick(event, target); - contacts = contactsList.getSelectedRows(); - } - - if (contactsList) { - var menu = $("contactMenu"); - menu.observe("contextmenu:hide", onContactContextMenuHide); - popupMenu(event, "contactMenu", contacts); - } -} - -function onContactContextMenuHide(event) { - var topNode = $("contactsList"); - - if (topNode.menuSelectedEntry) { - $(topNode.menuSelectedEntry).deselect(); - topNode.menuSelectedEntry = null; - } - if (topNode.menuSelectedRows) { - var nodes = topNode.menuSelectedRows; - for (var i = 0; i < nodes.length; i++) - $(nodes[i]).selectElement(); - topNode.menuSelectedRows = null; - } - - this.stopObserving("contextmenu:hide", onContactContextMenuHide); -} - -function _onContactMenuAction(folderItem, action, refresh) { - var selectedFolders = $("contactFolders").getSelectedNodes(); - var folderId = $(folderItem).readAttribute("folderId"); - if (folderId) - folderId = folderId.substring(1); - if (Object.isArray(document.menuTarget) && selectedFolders.length > 0) { - var selectedFolderId = $(selectedFolders[0]).readAttribute("id"); - var contactIds = $(document.menuTarget).collect(function(row) { - return row.getAttribute("id").fromCSSIdentifier(); - }); - - for (var i = 0; i < contactIds.length; i++) { - if (contactIds[i].endsWith ("vlf")) { - showAlertDialog(_("Lists can't be moved or copied.")); - return false; - } - } - - var url = ApplicationBaseURL + "/" + selectedFolderId + "/" + action; - var uids = contactIds.collect(encodeURIComponent).join('&uid='); - if (refresh) - triggerAjaxRequest(url, actionContactCallback, selectedFolderId, - ('folder='+ folderId + '&uid=' + uids), - { "Content-type": "application/x-www-form-urlencoded" }); - - else - triggerAjaxRequest(url, actionContactCallback, null, - ('folder='+ folderId + '&uid=' + uids), - { "Content-type": "application/x-www-form-urlencoded" }); - } -} - -function onContactMenuCopy(event) { - _onContactMenuAction(this, "copy", false); -} - -function onContactMenuMove(event) { - _onContactMenuAction(this, "move", true); -} - -function onMenuExportContact (event) { - var selectedFolders = $("contactFolders").getSelectedNodes(); - var canExport = (selectedFolders[0].getAttribute("owner") != "nobody"); - if (canExport) { - var selectedFolderId = $(selectedFolders[0]).readAttribute("id"); - var contactIds = document.menuTarget.collect(function(row) { - return row.readAttribute("id").fromCSSIdentifier(); - }); - var url = ApplicationBaseURL + "/" + selectedFolderId + "/export" - + "?uid=" + contactIds.collect(encodeURIComponent).join("&uid="); - window.location.href = url; - } -} - -function onMenuRawContact (event) { - var cname = document.menuTarget.collect(function(row) { - return row.readAttribute("id").fromCSSIdentifier(); - }); - - $(function() { - openGenericWindow(URLForFolderID(Contact.currentAddressBook) - + "/" + encodeURIComponent(cname) + "/raw"); - }).delay(0.1); -} - -function actionContactCallback(http) { - if (http.readyState == 4) - if (isHttpStatus204(http.status)) { - var refreshFolderId = http.callbackData; - if (refreshFolderId) - openContactsFolder(refreshFolderId, true); - } - else { - var html = new Element("div").update(http.responseText); - var error = html.select("p").first().firstChild.nodeValue.trim(); - log("actionContactCallback failed: error " + http.status + " (" + error + ")"); - if (parseInt(http.status) == 403) - showAlertDialog(_("You don't have the required privileges to perform the operation.")); - else if (error) - showAlertDialog(_(error)); - refreshCurrentFolder(); - } -} - -function loadContact(cname) { - if (document.contactAjaxRequest) { - document.contactAjaxRequest.aborted = true; - document.contactAjaxRequest.abort(); - } - - if (cachedContacts[Contact.currentAddressBook + "/" + cname]) { - var div = $('contactView'); - Contact.currentContactId = cname; - div.innerHTML = cachedContacts[Contact.currentAddressBook + "/" + cname]; - } - else { - var url = (URLForFolderID(Contact.currentAddressBook) - + "/" + encodeURIComponent(cname) + "/view?noframe=1"); - document.contactAjaxRequest - = triggerAjaxRequest(url, contactLoadCallback, cname); - } -} - -function contactLoadCallback(http) { - var div = $('contactView'); - - if (http.readyState == 4 - && http.status == 200) { - document.contactAjaxRequest = null; - var content = http.responseText; - cachedContacts[Contact.currentAddressBook + "/" + http.callbackData] = content; - Contact.currentContactId = http.callbackData; - div.innerHTML = content; - } - else { - log ("ajax problem 2: " + http.status); - refreshCurrentFolder(); - } -} - -var rowSelectionCount = 0; - -validateControls(); - -function showElement(e, shouldShow) { - e.style.display = shouldShow ? "" : "none"; -} - -function enableElement(e, shouldEnable) { - if(!e) - return; - if(shouldEnable) { - if(e.hasAttribute("disabled")) - e.removeAttribute("disabled"); - } - else { - e.setAttribute("disabled", "1"); - } -} - -function validateControls() { - var e = $("moveto"); - this.enableElement(e, rowSelectionCount > 0); -} - -function moveTo(uri) { - alert("MoveTo: " + uri); -} - -/* contact menu entries */ -function onContactRowDblClick(event) { - var t = getTarget(event); - var cname = t.parentNode.getAttribute('id').fromCSSIdentifier(); - - cname = encodeURIComponent(cname); - openContactWindow(URLForFolderID(Contact.currentAddressBook) - + "/" + cname + "/edit", cname); - - return false; -} - -function onContactSelectionChange(event) { - var contactView = $("contactView"); - if (event) { - // Update rows selection - var t = getTarget(event); - onRowClick(event, t); - } - if (contactView) { - var rows = this.parentNode.getSelectedRowsId(); - - if (rows.length == 1) { - var node = $(rows[0]); - loadContact(node.getAttribute('id').fromCSSIdentifier()); - } - else if (rows.length > 1) { - $('contactView').update(); - Contact.currentContactId = null; - } - } -} - -function onMenuEditContact(event) { - onToolbarEditSelectedContacts(event); -} - -function onMenuWriteToContact(event) { - onToolbarWriteToSelectedContacts(event); - - if (document.body.hasClassName("popup")) - window.close(); -} - -function onMenuAIMContact(event) { - var contactRow = $(document.menuTarget.getAttribute('id')); - var aimCell = contactRow.down('td', 2); - - window.location.href = "aim:goim?ScreenName=" + aimCell.firstChild.nodeValue; -} - -function onMenuDeleteContact(event) { - onToolbarDeleteSelectedContacts(event); -} - -function onToolbarEditSelectedContacts(event) { - var contactsList = $('contactsList'); - var rows = contactsList.getSelectedRowsId(); - - if (rows.length == 0) { - showAlertDialog(_("Please select a contact.")); - return false; - } - - for (var i = 0; i < rows.length; i++) { - var id = encodeURIComponent(rows[i].fromCSSIdentifier()); - openContactWindow(URLForFolderID(Contact.currentAddressBook) - + "/" + id + "/edit", rows[i]); - } - - return false; -} - -function onToolbarWriteToSelectedContacts(event) { - var contactsList = $('contactsList'); - var rowIds = contactsList.getSelectedRowsId(); - - if (rowIds.length == 0) { - showAlertDialog(_("Please select a contact.")); - } - else { - openMailComposeWindow(ApplicationBaseURL + "/../Mail/compose" - + "?folder=" + Contact.currentAddressBook.substring(1) - + "&uid=" + rowIds.collect(function(id) { - return encodeURIComponent(id.fromCSSIdentifier()); - }).join("&uid=")); - if (document.body.hasClassName("popup")) - window.close(); - } - - return false; -} - -function onToolbarDeleteSelectedContacts(event) { - var contactsList = $('contactsList'); - var rows = contactsList.getSelectedRowsId(); - - if (rows && rows.length) - showConfirmDialog(_("Confirmation"), - _("Are you sure you want to delete the selected contacts?"), - onToolbarDeleteSelectedContactsConfirm); - else if (!onAddressBookRemove(event)) - showAlertDialog(_("Please select a contact.")); - - return false; -} - -function onToolbarDeleteSelectedContactsConfirm(dialogId) { - disposeDialog(); - var contactsList = $('contactsList'); - var rowIds = contactsList.getSelectedRowsId(); - var urlstr = (URLForFolderID(Contact.currentAddressBook) + "/batchDelete"); - - for (var i = 0; i < rowIds.length; i++) - $(rowIds[i]).hide(); - triggerAjaxRequest(urlstr, onContactDeleteEventCallback, rowIds, - ('ids=' + rowIds.collect(function(id) { - return encodeURIComponent(id.fromCSSIdentifier()); - }).join(",")), - { "Content-type": "application/x-www-form-urlencoded" }); -} - -function onContactDeleteEventCallback(http) { - if (http.readyState == 4) { - if (isHttpStatus204(http.status)) { - var rowIds = http.callbackData; - var row; - var nextRow = null; - for (var i = 0; i < rowIds.length; i++) { - var id = rowIds[i].fromCSSIdentifier(); - delete cachedContacts[Contact.currentAddressBook + "/" + id]; - row = $(rowIds[i]); - var displayName = row.readAttribute("contactname"); - if (Contact.currentContactId == id) { - Contact.currentContactId = null; - } - var nextRow = row.next("tr"); - if (!nextRow) - nextRow = row.previous("tr"); - if (row) { - row.deselect(); - row.parentNode.removeChild(row); - } - } - if (nextRow) { - Contact.currentContactId = nextRow.getAttribute("id").fromCSSIdentifier(); - nextRow.selectElement(); - loadContact(Contact.currentContactId); - } - - $("contactView").update(); - } - else if (parseInt(http.status) == 403) { - for (var i = 0; i < rowIds.length; i++) { - var row = $(rowIds[i]); - row.show(); - } - var displayName = row.readAttribute("contactname"); - showAlertDialog(_("You cannot delete the card of \"%{0}\".").formatted(displayName)); - } - } -} - -function newEmailTo(sender) { - var mailto = sanitizeMailTo(sender.parentNode.parentNode.menuTarget.innerHTML); - - if (mailto.length > 0) - openMailComposeWindow("compose?mailto=" + mailto); - - return false; /* stop following the link */ -} - -function onHeaderClick(event) { - var headerId = this.getAttribute("id"); - var newSortAttribute; - if (headerId == "nameHeader") - newSortAttribute = "c_cn"; - else if (headerId == "mailHeader") - newSortAttribute = "c_mail"; - else if (headerId == "screenNameHeader") - newSortAttribute = "c_screenname"; - else if (headerId == "orgHeader") - newSortAttribute = "c_o"; - else if (headerId == "phoneHeader") - newSortAttribute = "c_telephonenumber"; - - if (sorting["attribute"] == newSortAttribute) - sorting["ascending"] = !sorting["ascending"]; - else { - sorting["attribute"] = newSortAttribute; - sorting["ascending"] = true; - } - - refreshCurrentFolder(); - - Event.stop(event); -} - -function newContact(sender) { - openContactWindow(URLForFolderID(Contact.currentAddressBook) + "/newcontact"); - - return false; /* stop following the link */ -} - -function newList(sender) { - var li = $(Contact.currentAddressBook); - var listEditing = li.getAttribute("list-editing"); - if (listEditing && listEditing == "available") - openContactWindow(URLForFolderID(Contact.currentAddressBook) + "/newlist"); - else - showAlertDialog(_("You cannot create a list in a shared address book.")); - - return false; -} - -function onFolderSelectionChange(event) { - var folderList = $("contactFolders"); - - if (event) { - var node = getTarget(event); - if (node.tagName == 'UL') - return; - if (node.tagName == "SPAN") - node = node.parentNode; - - // Update rows selection - onRowClick(event, node); - } - - var nodes = folderList.getSelectedNodes(); - $("contactView").update(); - Contact.currentContactId = null; - - if (nodes[0].hasClassName("denied")) { - var div = $("contactsListContent"); - div.update(); - } - else { - search = {}; - $$('[name="search"]').each(function(input) { input.value = "" }); - initCriteria(); - openContactsFolder(nodes[0].getAttribute("id")); - } -} - -function refreshCurrentFolder() { - openContactsFolder(Contact.currentAddressBook, true); -} - -/* Only used in UIxMailEditor */ -function onConfirmContactSelection(event) { - var tag = this.getAttribute("name"); - var folder = $("contactFolder"); - var currentAddressBookName = folder.textContent; - var selectorList = null; - var initialValues = null; - - var contactsList = $("contactsList"); - var rows = contactsList.getSelectedRows(); - for (i = 0; i < rows.length; i++) { - var cid = rows[i].getAttribute("id").fromCSSIdentifier(); - if (cid.endsWith(".vlf")) { - addListToOpener(tag, Contact.currentAddressBook, currentAddressBookName, cid); - } - else { - var cname = '' + rows[i].readAttribute("contactname"); - var email = '' + rows[i].cells[1].innerHTML; - addContact(tag, currentAddressBookName + '/' + cname, cid, cname, email); - } - } - - this.blur(); // required by IE - Event.stop(event); - - return false; -} - -function addListToOpener (tag, aBookId, aBookName, listId) { - var url = UserFolderURL + "Contacts/" + aBookId + "/" + listId + "/properties"; - triggerAjaxRequest (url, addListToOpenerCallback, { - "aBookId": aBookId, - "aBookName": aBookName, - "tag": tag - }); -} - -function addListToOpenerCallback (http) { - var data = http.callbackData; - var received = http.responseText.evalJSON (true); - for (var i = 0; i < received.length; i++) { - var contact = received[i]; - addContact(data.tag, data.aBookName + '/' + contact[1], - contact[0], contact[1], contact[2]); - } -} - -function refreshContacts(cname) { - openContactsFolder(Contact.currentAddressBook, true, cname); - delete cachedContacts[Contact.currentAddressBook + "/" + cname]; - loadContact(cname); - - return false; -} - -function onAddressBookNew(event) { - showPromptDialog(_("New Addressbook..."), _("Name of the Address Book"), onAddressBookNewConfirm); - preventDefault(event); -} - -function onAddressBookNewConfirm() { - if (this.value.length > 0) - createFolder(this.value, appendAddressBook); - disposeDialog(); -} - -function appendAddressBook(name, folder) { - var owner; - var result = true; - - if (folder) { - owner = getSubscribedFolderOwner(folder); - folder = accessToSubscribedFolder(folder); - } - else - folder = "/" + name; - - if (!owner) - owner = UserLogin; - - if ($(folder)) - result = false; - else { - var contactFolders = $("contactFolders"); - var items = contactFolders.childNodesWithTag("li"); - var li = document.createElement("li"); - li = Element.extend(li); - - // Add the calendar to the proper place - var i = getListIndexForFolder(items, owner, name); - if (i != items.length) // User is subscribed to other calendars of the same owner - contactFolders.insertBefore(li, items[i]); - else - contactFolders.appendChild(li); - - li.setAttribute("id", folder); - li.setAttribute("owner", owner); - li.setAttribute("list-editing", "available"); - li.setAttribute("acl-editing", "available"); - li.addClassName("local"); - - var displayName = document.createElement("span"); - displayName.appendChild(document.createTextNode(name - .replace("<", "<", "g") - .replace(">", ">", "g"))); - li.appendChild(displayName); - - updateAddressBooksMenus(); - configureDroppables(); - } - - return result; -} - -function newUserFolderCallback(folderData) { - var folder = $(folderData["folder"]); - if (!folder) - appendAddressBook(folderData["folderName"], folderData["folder"]); -} - -function onAddressBookAdd(event) { - openUserFolderSelector(newUserFolderCallback, "contact"); - - preventDefault(event); -} - -function onFolderUnsubscribeCB(folderId) { - var node = $(folderId); - node.deselect(); - node.parentNode.removeChild(node); - - var personal = $("/personal"); - personal.selectElement(); - onFolderSelectionChange(); -} - -function onAddressBookExport(event) { - var node = $("contactFolders").getSelectedNodes().first(); - var folderID = node.getAttribute("id"); - var url = URLForFolderID(folderID) + "/exportFolder"; - window.location.href = url; - - event.stop(); - hideMenu(document.currentPopupMenu); -} - -function onAddressBookImport(event) { - var node = $("contactFolders").getSelectedNodes().first(); - var folderId = node.getAttribute("id"); - - var url = ApplicationBaseURL + "/" + folderId + "/import"; - $("uploadForm").action = url; - $("contactsFile").value = ""; - - var cellPosition = node.cumulativeOffset(); - var cellDimensions = node.getDimensions(); - var left = cellDimensions['width'] - 20; - var top = cellPosition[1]; - - var div = $("uploadDialog"); - var res = $("uploadResults"); - res.setStyle({ top: top + "px", left: left + "px" }); - div.setStyle({ top: top + "px", left: left + "px" }); - div.show(); -} - -function hideContactsImport(event) { - $("uploadDialog").hide(); -} - -function hideImportResults () { - $("uploadResults").hide(); -} - -function validateUploadForm () { - rc = false; - if ($("contactsFile").value.length) { - var btn = jQuery('#uploadSubmit'); - jQuery('#uploadCancel').fadeOut('fast'); - btn.addClass("disabled"); - btn.children('span').text(_('Uploading')); - rc = true; - } - return rc; -} - -function uploadCompleted(response) { - jQuery('#uploadCancel').show(); - var btn = jQuery('#uploadSubmit'); - btn.removeClass("disabled"); - btn.children('span').text(_('Upload')); - var div = $("uploadResults"); - - try { - data = response.evalJSON(true); - - if (data.imported <= 0) - $("uploadResultsContent").update(_("An error occured while importing contacts.")); - else if (data.imported == 0) - $("uploadResultsContent").update(_("No card was imported.")); - else { - $("uploadResultsContent").update(_("A total of %{0} cards were imported in the addressbook.").formatted(data.imported)); - refreshCurrentFolder(); - } - } catch (e) { - $("uploadResultsContent").update(_("An error occured while importing contacts.")); - } - - hideContactsImport(); - $("uploadResults").show(); -} - -function onAddressBookRemove(event) { - var selector = $("contactFolders"); - var nodes = selector.getSelectedNodes(); - if (nodes.length > 0) { - var node = $(nodes[0]); - var owner = node.getAttribute("owner"); - if (owner == "nobody") { - var label = _("You cannot remove nor unsubscribe from a public addressbook."); - showAlertDialog(label); - } - else if (owner == UserLogin) { - var folderIdElements = node.getAttribute("id").split(":"); - var abId = folderIdElements[0].substr(1); - deletePersonalAddressBook(abId); - } - else { - var folderId = node.getAttribute("id"); - var folderUrl = ApplicationBaseURL + "/" + folderId; - unsubscribeFromFolder(folderUrl, owner, onFolderUnsubscribeCB, folderId); - } - } - - preventDefault(event); - - return (nodes.length > 0); -} - -function deletePersonalAddressBook(folderId) { - if (folderId == "personal") - showAlertDialog(_("You cannot remove nor unsubscribe from your personal addressbook.")); - else - showConfirmDialog(_("Confirmation"), - _("Are you sure you want to delete the selected address book?"), - deletePersonalAddressBookConfirm.bind(this, folderId)); - - return false; -} - -function deletePersonalAddressBookConfirm(folderId) { - if (document.deletePersonalABAjaxRequest) { - document.deletePersonalABAjaxRequest.aborted = true; - document.deletePersonalABAjaxRequest.abort(); - } - var url = ApplicationBaseURL + "/" + folderId + "/delete"; - document.deletePersonalABAjaxRequest - = triggerAjaxRequest(url, deletePersonalAddressBookCallback, folderId); - - disposeDialog(); -} - - -function deletePersonalAddressBookCallback(http) { - if (http.readyState == 4) { - if (isHttpStatus204(http.status)) { - var ul = $("contactFolders"); - - var children = ul.childNodesWithTag("li"); - var i = 0; - var done = false; - while (!done && i < children.length) { - var currentFolderId = children[i].getAttribute("id").substr(1); - if (currentFolderId == http.callbackData) { - children[i].deselect(); - ul.removeChild(children[i]); - done = true; - } - else - i++; - } - var personal = $("/personal"); - personal.selectElement(); - onFolderSelectionChange(); - } - document.deletePersonalABAjaxRequest = null; - } - else - log ("ajax problem 5: " + http.status); -} - -function configureDragHandles() { - var handle = $("dragHandle"); - if (handle) { - handle.addInterface(SOGoDragHandlesInterface); - handle.leftBlock = $("contactFoldersList"); - handle.rightBlock = $("rightPanel"); - handle.leftMargin = 100; - } - - handle = $("rightDragHandle"); - if (handle) { - handle.addInterface(SOGoDragHandlesInterface); - handle.upperBlock = $("contactsListContent"); - handle.lowerBlock = $("contactView"); - } -} - -function lookupDeniedFolders() { - var list = $("contactFolders").childNodesWithTag("li"); - for (var i = 0; i < list.length; i++) { - var folderID = list[i].getAttribute("id"); - var url = URLForFolderID(folderID) + "/canAccessContent"; - triggerAjaxRequest(url, deniedFoldersLookupCallback, folderID); - } -} - -function deniedFoldersLookupCallback(http) { - if (http.readyState == 4) { - var denied = ! isHttpStatus204(http.status); - var entry = $(http.callbackData); - if (denied) - entry.addClassName("denied"); - else - entry.removeClassName("denied"); - } -} - -function configureAbToolbar() { - var toolbar = $("abToolbar"); - if (toolbar) { - var links = toolbar.childNodesWithTag("a"); - $(links[0]).observe("click", onAddressBookNew); - $(links[1]).observe("click", onAddressBookAdd); - $(links[2]).observe("click", onAddressBookRemove); - } -} - -function configureAddressBooks() { - var contactFolders = $("contactFolders"); - if (contactFolders) { - contactFolders.on("mousedown", onFolderSelectionChange); - contactFolders.on("dblclick", onAddressBookModify); - contactFolders.on("selectstart", listRowMouseDownHandler); - contactFolders.attachMenu("contactFoldersMenu"); - - lookupDeniedFolders(); - configureDroppables(); - - // Select initial addressbook - $(Contact.currentAddressBook).selectElement(); - } -} - -function onAddressBookMenuPrepareVisibility() { - var selectedFolder = $("contactFolders").getSelectedNodes()[0]; - if (selectedFolder) { - var selectedFolderId = selectedFolder.readAttribute("id"); - $(this).select("li").each(function(menuEntry) { - if (menuEntry.readAttribute("folderId") == selectedFolderId) - menuEntry.addClassName("disabled"); - else - menuEntry.removeClassName("disabled"); - }); - } - - return true; -} - -function updateAddressBooksMenus() { - var contactFoldersList = $("contactFolders"); - if (contactFoldersList) { - var pageContent = $("pageContent"); - var contactFolders = contactFoldersList.select("li"); - var contactActions = new Hash({ move: onContactMenuMove, - copy: onContactMenuCopy }); - var actions = contactActions.keys(); - for (var j = 0; j < actions.size(); j++) { - var key = actions[j]; - var callbacks = new Array(); - var menuId = key + "ContactMenu"; - var menuDIV = $(menuId); - if (menuDIV) - menuDIV.parentNode.removeChild(menuDIV); - - menuDIV = document.createElement("div"); - pageContent.appendChild(menuDIV); - - var menu = document.createElement("ul"); - menuDIV.appendChild(menu); - - $(menuDIV).addClassName("menu"); - menuDIV.setAttribute("id", menuId); - - var submenuIds = new Array(); - for (var i = 0; i < contactFolders.length; i++) { - if (contactFolders[i].hasClassName("local")) { - var menuEntry = new Element("li", - { folderId: contactFolders[i].readAttribute("id"), - owner: contactFolders[i].readAttribute("owner") } - ).update(contactFolders[i].innerHTML); - menu.appendChild(menuEntry); - callbacks.push(contactActions.get(key)); - } - } - menuDIV.prepareVisibility = onAddressBookMenuPrepareVisibility; - initMenu(menuDIV, callbacks); - } - } -} - -function onAddressBookModify(event) { - var folders = $("contactFolders"); - var selected = folders.getSelectedNodes()[0]; - if (selected.getAttribute("list-editing") == "available") { - var addressBookID = selected.getAttribute("id"); - var url = ApplicationBaseURL + addressBookID + "/properties"; - var windowID = sanitizeWindowName(addressBookID + " properties"); - var width = 410; - var height = 410; - - $(function() { - var properties = window.open(url, windowID, "width="+width+",height="+height+",resizable=0"); - properties.focus(); - }).delay(0.1); - } -} - -function onMenuSharing(event) { - if ($(this).hasClassName("disabled")) - return; - - var folders = $("contactFolders"); - var selected = folders.getSelectedNodes()[0]; - var aclEditing = selected.getAttribute("acl-editing"); - if (aclEditing && aclEditing == "available") { - var title = this.innerHTML; - var url = URLForFolderID(selected.getAttribute("id")); - - openAclWindow(url + "/acls", title); - } - else - showAlertDialog(_("The user rights cannot be edited for this object!")); -} - -function onAddressBooksMenuPrepareVisibility() { - var folders = $("contactFolders"); - var selected = folders.getSelectedNodes(); - - if (selected.length > 0) { - var folderOwner = selected[0].getAttribute("owner"); - - var menu = $("contactFoldersMenu").down("ul");; - var listElements = menu.childNodesWithTag("li"); - var newListOption = listElements[3]; - var removeOption = listElements[5]; - var exportOption = listElements[7]; - var importOption = listElements[8]; - var sharingOption = listElements[listElements.length - 1]; - - // Disable the "Sharing" option when address book is not owned by user - if (folderOwner == UserLogin || IsSuperUser) { - var aclEditing = selected[0].getAttribute("acl-editing"); - if (aclEditing && aclEditing == "available") { - sharingOption.removeClassName("disabled"); - } - else { - sharingOption.addClassName("disabled"); - } - } - else { - modifyOption.addClassName("disabled"); - sharingOption.addClassName("disabled"); - } - - var listEditing = selected[0].getAttribute("list-editing"); - if (listEditing && listEditing == "available") { - newListOption.removeClassName("disabled"); - } - else { - newListOption.addClassName("disabled"); - } - - // Disable the "remove" and "export ab" options when address book is public - if (folderOwner == "nobody") { - exportOption.addClassName("disabled"); - importOption.addClassName("disabled"); - removeOption.addClassName("disabled"); - } - else { - exportOption.removeClassName("disabled"); - importOption.removeClassName("disabled"); - if (selected[0].getAttribute("id") == "/personal") { - removeOption.addClassName("disabled"); - } - else { - removeOption.removeClassName("disabled"); - } - } - - return true; - } - - return false; -} - -function onContactMenuPrepareVisibility() { - var contactRows = document.menuTarget; - var selectedFolder = $("contactFolders").getSelectedNodes().first(); - var options = { write: false, - aim: false }; - - var elements = $(this).down("ul").childElements(); - - var categoriesOption = elements[1]; - if (selectedFolder.getAttribute("owner") == UserLogin) { - categoriesOption.removeClassName("disabled"); - } - else { - categoriesOption.addClassName("disabled"); - } - - $A(contactRows).each(function(contactRow) { - var cells = contactRow.getElementsByTagName('td'); - var emailCell = cells[1]; - options.write |= (emailCell.firstChild != null); - var aimCell = cells[2]; - options.aim |= (aimCell.firstChild != null); - }); - - var writeOption = elements[3]; - if (options.write) - writeOption.removeClassName("disabled"); - else - writeOption.addClassName("disabled"); - - var aimOption = elements[4]; - if (options.aim) - aimOption.removeClassName("disabled"); - else - aimOption.addClassName("disabled"); - - var deleteOption = elements[6]; - var moveOption = elements[8]; - if ($(selectedFolder).hasClassName("remote")) { - // Remote address books are always read-only - deleteOption.addClassName("disabled"); - moveOption.addClassName("disabled"); - } - else { - deleteOption.removeClassName("disabled"); - moveOption.removeClassName("disabled"); - } - - var exportOption = elements[10]; - var rawOption = elements[11]; - if ($(selectedFolder).getAttribute("owner") == "nobody") { - // public folders (ldap) cannot export or show raw contacts - exportOption.addClassName("disabled"); - rawOption.addClassName("disabled"); - } - else { - exportOption.removeClassName("disabled"); - rawOption.removeClassName("disabled"); - } - - if (contactRows.length != 1) - rawOption.addClassName("disabled"); - - return true; -} - -var originalGetMenus = null; -if (typeof getMenus == 'function') { - originalGetMenus = getMenus; -} -getMenus = function() { - var menus = {}; - menus["contactFoldersMenu"] = new Array(onAddressBookModify, "-", newContact, - newList, "-", - onAddressBookRemove, "-", - onAddressBookExport, onAddressBookImport, "-", - onMenuSharing); - menus["contactMenu"] = new Array(onMenuEditContact, - "categoriesMenu", - "-", - onMenuWriteToContact, onMenuAIMContact, - "-", onMenuDeleteContact, "-", - "moveContactMenu", "copyContactMenu", - onMenuExportContact, onMenuRawContact); - menus["searchMenu"] = new Array(setSearchCriteria, setSearchCriteria, setSearchCriteria); - - var contactFoldersMenu = $("contactFoldersMenu"); - if (contactFoldersMenu) - contactFoldersMenu.prepareVisibility = onAddressBooksMenuPrepareVisibility; - var contactMenu = $("contactMenu"); - if (contactMenu) - contactMenu.prepareVisibility = onContactMenuPrepareVisibility; - - if (originalGetMenus) { - var originalMenus = originalGetMenus(); - if (originalMenus) - menus = Object.extend(menus, originalMenus); - } - - return menus; -} - - function configureSelectionButtons() { - var container = $("contactSelectionButtons"); - if (container) { - var buttons = container.select("A.button"); - for (var i = 0; i < buttons.length; i++) { - $(buttons[i]).observe("click", onConfirmContactSelection); - } - } - } - -function onDocumentKeydown(event) { - var target = Event.element(event); - if (target.tagName != "INPUT" && target.tagName != "TEXTAREA") { - var keyCode = event.keyCode; - if (!keyCode) { - keyCode = event.charCode; - if (keyCode == "a".charCodeAt(0)) { - keyCode = "A".charCodeAt(0); - } - } - if (keyCode == Event.KEY_DELETE || - keyCode == Event.KEY_BACKSPACE && isMac()) { - onToolbarDeleteSelectedContacts(); - Event.stop(event); - } - else if (keyCode == Event.KEY_DOWN || - keyCode == Event.KEY_UP) { - if (Contact.currentContactId) { - var row = $(Contact.currentContactId.asCSSIdentifier()); - var nextRow; - if (keyCode == Event.KEY_DOWN) - nextRow = row.next("tr"); - else - nextRow = row.previous("tr"); - if (nextRow) { - row.up().deselectAll(); - - // Adjust the scollbar - var viewPort = $("contactsListContent"); - var divDimensions = viewPort.getDimensions(); - var rowScrollOffset = nextRow.cumulativeScrollOffset(); - var rowPosition = nextRow.positionedOffset(); - var divBottom = divDimensions.height + rowScrollOffset.top; - var rowBottom = rowPosition.top + nextRow.getHeight(); - - if (divBottom < rowBottom) - viewPort.scrollTop += rowBottom - divBottom; - else if (rowScrollOffset.top > rowPosition.top) - viewPort.scrollTop -= rowScrollOffset.top - rowPosition.top; - - // Select and load the next message - nextRow.selectElement(); - loadContact(nextRow.readAttribute("id").fromCSSIdentifier()); - } - Event.stop(event); - } - } - else if (((isMac() && event.metaKey == 1) || (!isMac() && event.ctrlKey == 1)) - && keyCode == "A".charCodeAt(0)) { // Ctrl-A - $("contactsList").selectAll(); - Event.stop(event); - } - } -} - -/*function fixSearchFieldPosition () { - var panel = $("filterPanel"); - if (panel) { - panel.style.position = "relative"; - panel.style.top = "7px"; - } - }*/ - -function initContacts(event) { - if ($(document.body).hasClassName("popup")) { - configureSelectionButtons(); - } - - var foldersList = $("contactFoldersList"); - if (foldersList) { - configureAbToolbar(); - - // Addressbook import form - $("uploadCancel").observe("click", hideContactsImport); - $("uploadOK").observe("click", hideImportResults); - } - - Event.observe(document, "keydown", onDocumentKeydown); - - configureAddressBooks(); - configureDraggables(); - updateAddressBooksMenus(); - initRefreshViewCheckTimer(); - - var table = $("contactsList"); - if (table) { - // Initialize event delegation on contacts table - table.multiselect = true; - var tbody = $(table.tBodies[0]); - tbody.on("click", onContactSelectionChange); - if ($("contactView")) { - tbody.on("dblclick", onContactRowDblClick); - tbody.on("selectstart", listRowMouseDownHandler); - tbody.on("contextmenu", onContactContextMenu); - resetCategoriesMenu(); - TableKit.Resizable.init(table, {'trueResize' : true, 'keepWidth' : true}); - } - configureSortableTableHeaders(table); - } - - if (typeof onWindowResize != 'function') { - // When loaded from the mail editor, onWindowResize is - // already registered - onWindowResize = onContactsWindowResize; - onWindowResize.defer(); - Event.observe(window, "resize", onWindowResize); - } - // Default sort options - sorting["attribute"] = "c_cn"; - sorting["ascending"] = true; -} - -onContactsWindowResize = function (event) { - var handle = $("dragHandle"); - if (handle) - handle.adjust(); - handle = $("rightDragHandle"); - if (handle) - handle.adjust(); -} - - function resetCategoriesMenu() { - var menu = $("categoriesMenu"); - if (menu) { - menu.parentNode.removeChild(menu); - } - - menu = createElement("div", "categoriesMenu", "menu"); - var menuUL = createElement("ul", null, "choiceMenu"); - menu.appendChild(menuUL); - if (UserDefaults && UserDefaults["SOGoContactsCategories"]) { - for (var i = 0; - i < UserDefaults["SOGoContactsCategories"].length; - i++) { - var catName = UserDefaults["SOGoContactsCategories"][i]; - if (catName.length > 0) { - var menuLI = createElement("li"); - menuLI.observe("mousedown", onCategoriesMenuItemClick); - menuLI.category = catName; - menuLI.appendChild(document.createTextNode(catName)); - menuUL.appendChild(menuLI); - } - } - } - - menu.prepareVisibility = onCategoriesMenuPrepareVisibility; - - var pageContent = $("pageContent"); - pageContent.appendChild(menu); - } - -function onCategoriesMenuPrepareVisibility() { - var contactsList = $("contactsList"); - if (contactsList) { - var rows = contactsList.getSelectedRows(); - if (rows.length > 0) { - var catList = rows[0].readAttribute("categories"); - var catsArray; - if (catList && catList.length > 0) { - catsArray = catList.split(","); - } - else { - catsArray = []; - } - var menu = $("categoriesMenu"); - var ul = menu.down("ul"); - var listElements = ul.select("li"); - for (var i = 0; i < listElements.length; i++) { - var li = listElements[i]; - if (catsArray.indexOf(li.category) > -1) { - li.addClassName("_chosen"); - } - else { - li.removeClassName("_chosen"); - } - } - } - } - return true; -} - -function onCategoriesMenuItemClick() { - var set = !this.hasClassName("_chosen"); - var method = (set ? "setCategory" : "unsetCategory"); - var contactsList = $("contactsList"); - var rowIds = contactsList.getSelectedRowsId(); - if (rowIds.length > 0) { - for (var i = 0; i < rowIds.length; i++) { - var id = rowIds[i].fromCSSIdentifier(); - var url = (URLForFolderID(Contact.currentAddressBook) - + "/" + encodeURIComponent(id) + "/" + method); - url += "?category=" + encodeURIComponent(this.category); - triggerAjaxRequest(url, onCategoriesMenuItemCallback, - { 'addressBook' : Contact.currentAddressBook, 'id' : id }); - if (set) { - setCategoryOnNode($(rowIds[i]), this.category); - } - else { - unsetCategoryOnNode($(rowIds[i]), this.category); - } - } - } -} - -function onCategoriesMenuItemCallback(http) { - if (http.readyState == 4) - if (isHttpStatus204(http.status)) { - var contact = http.callbackData; - if (cachedContacts[contact.addressBook + "/" + contact.id]) - delete cachedContacts[contact.addressBook + "/" + contact.id]; - if (contact.addressBook == Contact.currentAddressBook - && contact.id == Contact.currentContactId) - loadContact(Contact.currentContactId); - } - else if (parseInt(http.status) == 403) { - log("onCategoriesMenuItemCallback failed: error " + http.status + " (" + http.responseText + ")"); - } -} - -function setCategoryOnNode(contactNode, category) { - var catList = contactNode.getAttribute("categories"); - var catsArray = catList? catList.split(",") : []; - if (catsArray.indexOf(category) == -1) { - catsArray.push(category); - contactNode.setAttribute("categories", catsArray.join(",")); - } -} - -function unsetCategoryOnNode(contactNode, category) { - var catList = contactNode.getAttribute("categories"); - var catsArray = catList.split(","); - var catIdx = catsArray.indexOf(category); - if (catsArray.indexOf(category) > -1) { - catsArray.splice(catIdx, 1); - contactNode.setAttribute("categories", catsArray.join(",")); - } -} - -function configureDraggables() { - if ($("contactFolders")) { - var rows = jQuery("tr.vcard"); - try { rows.draggable("destroy"); } catch (e) {} - rows.draggable({ - helper: function (event) { return '
'; }, - start: startDragging, - drag: whileDragging, - stop: stopDragging, - appendTo: 'body', - cursorAt: { right: 25 }, - scroll: false, - distance: 4, - zIndex: 20 - }); - } -} - -function configureDroppables() { - jQuery("li.local").droppable({ - hoverClass: 'genericHoverClass', - drop: dropAction }); -} - -function currentFolderIsRemote() { - rc = false; - var selectedFolders = $("contactFolders").getSelectedNodes(); - if (selectedFolders.length > 0) { - var fromObject = $(selectedFolders[0]); - rc = fromObject.hasClassName("remote"); - } - return rc; -} - -function startDragging(event, ui) { - var row = event.target; - var handle = ui.helper; - var contacts = $('contactsList').getSelectedRowsId(); - var count = contacts.length; - - if (count == 0 || contacts.indexOf(row.id) < 0) { - onRowClick(event, $(row.id)); - contacts = $("contactsList").getSelectedRowsId(); - count = contacts.length; - } - handle.html(count); - - if (event.shiftKey || currentFolderIsRemote()) { - handle.addClass("copy"); - } - handle.show(); -} - -function whileDragging(event, ui) { - if (event) { - var handle = ui.helper; - if (event.shiftKey || currentFolderIsRemote()) - handle.addClass("copy"); - else if (handle.hasClass("copy")) - handle.removeClass("copy"); - } -} - -function stopDragging(event, ui) { - var handle = ui.helper; - handle.hide(); - if (handle.hasClass("copy")) - handle.removeClass("copy"); -} - -function dropAction(event, ui) { - var action = "move"; - if (ui.helper.hasClass("copy")) - action = "copy"; - else - $('contactView').update(); - dropSelectedContacts(action, this.id.substr(1)); -} - -function dropSelectedContacts(action, toId) { - var selectedFolders = $("contactFolders").getSelectedNodes(); - if (selectedFolders.length > 0) { - var contactIds = $('contactsList').getSelectedRowsId(); - for (var i = 0; i < contactIds.length; i++) { - if (contactIds[i].endsWith("vlf")) { - showAlertDialog(_("Lists can't be moved or copied.")); - return false; - } - } - var fromId = $(selectedFolders[0]).id; - if ((!currentFolderIsRemote() || action != "move") - && fromId.substring(1) != toId) { - - var url = ApplicationBaseURL + fromId + "/" + action; - var uids = contactIds.collect(function(id) { - return encodeURIComponent(id.fromCSSIdentifier()); - }).join('&uid='); - triggerAjaxRequest(url, actionContactCallback, fromId, - ('folder='+ toId + '&uid=' + uids), - { "Content-type": "application/x-www-form-urlencoded" }); - } - } -} - -function onContactsReload () { - openContactsFolder(Contact.currentAddressBook, true); -} - -function initRefreshViewCheckTimer() { - var refreshViewCheck = typeof UserDefaults == 'undefined' ? false : UserDefaults["SOGoRefreshViewCheck"]; - if (refreshViewCheck && refreshViewCheck != "manually") { - var interval; - if (refreshViewCheck == "once_per_hour") - interval = 3600; - else if (refreshViewCheck == "every_minute") - interval = 60; - else { - interval = parseInt(refreshViewCheck.substr(6)) * 60; - } - refreshViewCheckTimer = window.setInterval(onRefreshViewCheckCallback, - interval * 1000); - } -} - -function onRefreshViewCheckCallback(event) { - onContactsReload(); -} - -document.observe("dom:loaded", initContacts); diff --git a/UI/WebServerResources/HTMLElement.js b/UI/WebServerResources/HTMLElement.js deleted file mode 100644 index 4ae8c60c0..000000000 --- a/UI/WebServerResources/HTMLElement.js +++ /dev/null @@ -1,383 +0,0 @@ -/* -*- Mode: js-mode; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -["HTMLCollection", "NodeList"].each( - function (className) { - if (className in window) { - var contClass = window[className]; - var _each = contClass.prototype.forEach; - if (!_each) { - _each = function HTMLElement_each(iterator, context) { - for (var i = 0, length = this.length >>> 0; i < length; i++) { - if (i in this) iterator.call(context, this[i], i, this); - } - }; - } - contClass.prototype._each = _each; - Object.extend(contClass.prototype, Enumerable); - } - } -); - -/* custom extensions to the DOM api */ -Element.addMethods({ - addInterface: function(element, objectInterface) { - element = $(element); - Object.extend(element, objectInterface); - if (element.bind) - element.bind(); - }, - - allTextContent: function(element) { - var content = ""; - for (var i = 0; i < element.childNodes.length; i++) { - var node = $(element.childNodes[i]); - if (node.nodeType == Node.TEXT_NODE) { - content += node.nodeValue; - } - else if (node.nodeType === Node.ELEMENT_NODE) { - content += Element.allTextContent(node); - } - } - - return content; - }, - - childNodesWithTag: function(element, tagName) { - element = $(element); - - var matchingNodes = new Array(); - tagName = tagName.toUpperCase(); - - for (var i = 0; i < element.childNodes.length; i++) { - var childNode = $(element.childNodes[i]); - if (Object.isElement(childNode) - && childNode.tagName - && childNode.tagName.toUpperCase() == tagName) - matchingNodes.push(childNode); - } - - return matchingNodes; - }, - - getParentWithTagName: function(element, tagName) { - element = $(element); - var currentElement = element; - tagName = tagName.toUpperCase(); - - currentElement = currentElement.parentNode; - while (currentElement - && currentElement.tagName != tagName) { - currentElement = currentElement.parentNode; - } - - return currentElement; - }, - - cascadeLeftOffset: function(element) { - element = $(element); - var currentElement = element; - - var offset = 0; - while (currentElement) { - offset += currentElement.offsetLeft; - currentElement = $(currentElement).getParentWithTagName("div"); - } - - return offset; - }, - - cascadeTopOffset: function(element) { - element = $(element); - var currentElement = element; - var offset = 0; - - var i = 0; - - while (currentElement && currentElement.tagName) { - offset += currentElement.offsetTop; - currentElement = currentElement.parentNode; - i++; - } - - return offset; - }, - - dump: function(element, additionalInfo, additionalKeys) { - element = $(element); - var id = element.getAttribute("id"); - var nclass = element.getAttribute("class"); - - var str = element.tagName; - if (id) - str += "; id = " + id; - if (nclass) - str += "; class = " + nclass; - - if (additionalInfo) - str += "; " + additionalInfo; - - if (additionalKeys) - for (var i = 0; i < additionalKeys.length; i++) { - var value = element.readAttribute(additionalKeys[i]); - if (value) - str += "; " + additionalKeys[i] + " = " + value; - } - - log (str); - }, - - getSelectedNodes: function(element) { - element = $(element); - - if (!element.selectedElements) - element.selectedElements = new Array(); - - return element.selectedElements; - }, - - getSelectedNodesId: function(element) { - element = $(element); - - var selArray = null; - if (element.selectedIds) { - selArray = element.selectedIds; - } - else { - selArray = []; - if (element.selectedElements) { - for (var i = 0; i < element.selectedElements.length; i++) { - var node = element.selectedElements[i]; - selArray.push(node.getAttribute("id")); - } - } - } - - return selArray; - }, - - onContextMenu: function(element, event) { - element = $(element); - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); - - var popup = element.sogoContextMenu; - var menuTop = Event.pointerY(event); - var menuLeft = Event.pointerX(event); - var heightDiff = (window.height() - - (menuTop + popup.offsetHeight)); - if (heightDiff < 0) - menuTop += heightDiff; - - var leftDiff = (window.width() - - (menuLeft + popup.offsetWidth)); - if (leftDiff < 0) - menuLeft -= popup.offsetWidth; - - var isVisible = true; - if (popup.prepareVisibility) - isVisible = popup.prepareVisibility(); - - Event.stop(event); - - if (isVisible) { - popup.setStyle( { top: menuTop + "px", - left: menuLeft + "px", - visibility: "visible" } ); - document.currentPopupMenu = popup; - $(document.body).on("mousedown", onBodyClickMenuHandler); - } - else - log ("Warning: not showing the contextual menu " + element.id); - }, - - attachMenu: function(element, menuName) { - element = $(element); - element.sogoContextMenu = $(menuName); - element.on("contextmenu", element.onContextMenu); - }, - - selectElement: function(element) { - element = $(element); - element.addClassName('_selected'); - var parent = element.up(); - if (!parent.selectedElements || !parent.selectedIds) { - // Selected nodes are kept in a array at the - // container level. - parent.selectedElements = new Array(); - parent.selectedIds = new Array(); - } - for (var i = 0; i < parent.selectedElements.length; i++) - if (parent.selectedElements[i] == element) return; - parent.selectedElements.push(element); // use index instead ? - if (element.id) { - for (var i = 0; i < parent.selectedIds.length; i++) - if (parent.selectedIds[i] == element.id) return; - parent.selectedIds.push(element.id); - } - }, - - selectRange: function(element, startIndex, endIndex) { - element = $(element); - var s; - var e; - var rows; - - if (startIndex > endIndex) { - s = endIndex; - e = startIndex; - } - else { - s = startIndex; - e = endIndex; - } - if (element.tagName == 'UL') - rows = element.getElementsByTagName('LI'); - else - rows = element.getElementsByTagName('TR'); - while (s <= e) { - if (rows[s].nodeType == 1) - $(rows[s]).selectElement(); - s++; - } - }, - - selectAll: function(element) { - element = $(element); - if (element.tagName == 'UL') - rows = element.getElementsByTagName('LI'); - else - rows = element.select('TBODY TR'); - for (var i = 0; i < rows.length; i++) { - if (rows[i].nodeType == 1) - $(rows[i]).selectElement(); - } - }, - - deselect: function(element) { - element = $(element); - element.removeClassName('_selected'); - var parent = element.parentNode; - if (parent) { - if (parent.selectedElements) - parent.selectedElements = parent.selectedElements.without(element); - if (parent.selectedIds) - parent.selectedIds = parent.selectedIds.without(element.id); - } - }, - - deselectAll: function(element) { - if (element.tagName == 'TABLE') { - var tbody = element.tBodies[0]; - if (tbody) - element = tbody; - } - element = $(element); - var s = element.select("._selected"); - for (var i = 0; i < s.length; i++) - s[i].removeClassName("_selected"); - - element.selectedElements = null; - element.selectedIds = null; - }, - - refreshSelectionByIds: function(element, selectedIds) { - element = $(element); - var selectedCount = 0; - if (selectedIds) - element.selectedIds = selectedIds; - if (element.selectedIds) { - for (var i = 0; i < element.selectedIds.length; i++) { - //var e = element.down('#'+element.selectedIds[i]); // buggy with IE - var e = $(element.selectedIds[i]); - if (e) { - if (!e.hasClassName('_selected')) - e.addClassName('_selected'); - selectedCount++; - } - else { - log ("refreshSelectionByIds Error: " + element.tagName - + " select by ID " + element.selectedIds[i] - + " not found (" + element.childNodes.length + " children)"); - } - } - } - return selectedCount; - }, - - setCaretTo: function(element, pos) { - element = $(element); - if (element.setSelectionRange) { // For Mozilla and Safari - element.focus(); - element.setSelectionRange(pos, pos); - } - else if (element.createTextRange) { // For IE - var range = element.createTextRange(); - range.move("character", pos); - range.select(); - } - }, - - selectText: function(element, start, end) { - element = $(element); - if (element.setSelectionRange) { // For Mozilla and Safari - element.setSelectionRange(start, end); - } - else if (element.createTextRange) { // For IE - var textRange = element.createTextRange(); - textRange.moveStart("character", start); - textRange.moveEnd("character", end-element.value.length); - textRange.select(); - } - else { - element.select(); - } - }, - - getRadioValue: function(element, radioName) { - element = $(element); - var radioValue; - Form.getInputs(element, 'radio', radioName).each(function(input) { - if (input.checked) - radioValue = input.value; - }); - return radioValue; - }, - - setRadioValue: function(element, radioName, value) { - element = $(element); - var i = 0; - - Form.getInputs(element, 'radio', radioName).each(function(input) { - if (i == value) - input.checked = 1; - i++; - }); - }, - - getCheckBoxListValues: function(element, checkboxName) { - element = $(element); - var values = new Array(); - var i = 0; - - Form.getInputs(element, 'checkbox', checkboxName).each(function(input) { - if (input.checked) - values.push(i+1); - - i++; - }); - return values.join(","); - }, - - setCheckBoxListValues: function(element, checkboxName, values) { - element = $(element); - var v = values.split(','); - var i = 1; - - Form.getInputs(element, 'checkbox', checkboxName).each(function(input) { - - if ($(v).indexOf(i+"") != -1) - input.checked = 1; - i++; - }); - } -}); diff --git a/UI/WebServerResources/HTMLInputElement.js b/UI/WebServerResources/HTMLInputElement.js deleted file mode 100644 index 618b8065f..000000000 --- a/UI/WebServerResources/HTMLInputElement.js +++ /dev/null @@ -1,63 +0,0 @@ -/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -Form.Element.Methods._replicate = function(element) { - element = $(element); - if (element.replica) { - element.replica.value = $F(element); - var onReplicaChangeEvent = document.createEvent("UIEvents"); - onReplicaChangeEvent.initEvent("change", true, true); - element.replica.dispatchEvent(onReplicaChangeEvent); - } -}; - -Form.Element.Methods.assignReplica = function(element, otherInput) { - element = $(element); - if (!element._onChangeBound) { - element.observe("change", element._replicate, false); - element._onChangeBound = true; - } - element.replica = otherInput; -}; - -Form.Element.Methods.inputAsDate = function(element) { - return $F(element).asDate(); -}; - -Form.Element.Methods.setInputAsDate = function(element, dateValue) { - element = $(element); - if (!element.dateSeparator) - element._detectDateSeparator(); - element.value = dateValue.stringWithSeparator(element.dateSeparator); -}; - -Form.Element.Methods.updateShadowValue = function(element) { - element = $(element); - element.setAttribute("shadow-value", $F(element)); -}; - -Form.Element.Methods._detectDateSeparator = function(element) { - element = $(element); - var date = $F(element).split("/"); - if (date.length == 3) - element.dateSeparator = "/"; - else - element.dateSeparator = "-"; -}; - -Form.Element.Methods.valueAsShortDateString = function(element) { - element = $(element); - var dateStr = ''; - - if (!element.dateSeparator) - element._detectDateSeparator(); - - var date = $F(element).split(element.dateSeparator); - if (element.dateSeparator == '/') - dateStr += date[2] + date[1] + date[0]; - else - dateStr += date[0] + date[1] + date[2]; - - return dateStr; -}; - -Element.addMethods(); diff --git a/UI/WebServerResources/HTMLTableElement.js b/UI/WebServerResources/HTMLTableElement.js deleted file mode 100644 index 979887332..000000000 --- a/UI/WebServerResources/HTMLTableElement.js +++ /dev/null @@ -1,46 +0,0 @@ -/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -Element.addMethods({ - getSelectedRows: function(element) { - element = $(element); - if (element.tagName == 'TABLE') { - var tbody = (element.getElementsByTagName('tbody'))[0]; - - return $(tbody).getSelectedNodes(); - } - else if (element.tagName == 'TBODY') { - return element.getSelectedNodes(); - } - else if (element.tagName == 'UL') { - return element.getSelectedNodes(); - } - }, - - getSelectedRowsId: function(element) { - element = $(element); - var rowsId = null; - if (element.tagName == 'TABLE') { - var tbody = (element.getElementsByTagName('tbody'))[0]; - rowsId = $(tbody).getSelectedNodesId(); - } - else if (element.tagName == 'UL') { - rowsId = element.getSelectedNodesId(); - } - - return rowsId; - }, - - selectRowsMatchingClass: function(element, className) { - element = $(element); - if (element.tagName == 'TABLE') { - var tbody = (element.getElementsByTagName('tbody'))[0]; - var nodes = tbody.childNodes; - for (var i = 0; i < nodes.length; i++) { - var node = nodes.item(i); - if (node.tagName && node.hasClassName(className)) - node.selectElement(); - } - } - } - -}); // Element.addMethods diff --git a/UI/WebServerResources/JavascriptAPIExtensions.js b/UI/WebServerResources/JavascriptAPIExtensions.js deleted file mode 100644 index 12db867bd..000000000 --- a/UI/WebServerResources/JavascriptAPIExtensions.js +++ /dev/null @@ -1,438 +0,0 @@ -/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -String.prototype.trim = function() { - return this.replace(/(^\s+|\s+$)/g, ''); -}; - -String.prototype.formatted = function() { - var newString = this; - - for (var i = 0; i < arguments.length; i++) { - newString = newString.replace("%{" + i + "}", arguments[i], "g"); - } - - return newString; -}; - -String.prototype.formatTime = function(hours, minutes) { - var newString = this; - - // See http://www.gnustep.org/resources/documentation/Developer/Base/Reference/NSCalendarDate.html#method$NSCalendarDate-descriptionWithCalendarFormat$ - var p = 'am', i = hours, m = minutes; - if (hours > 12) { - p = 'pm'; - i = hours % 12; - } - if (minutes < 10) { - m = '0' + minutes; - } - - // %H : hour as a decimal number using 24-hour clock - newString = newString.replace("%H", hours < 10 ? '0' + hours : hours); - // %I : hour as a decimal number using 12-hour clock - newString = newString.replace("%I", i < 10 ? '0' + i : i); - // %M : minute as decimal number - newString = newString.replace("%M", m); - // %p : 'am' or 'pm' - newString = newString.replace("%p", p); - - return newString; -}; - -String.prototype.repeat = function(count) { - var newString = ""; - for (var i = 0; i < count; i++) { - newString += this; - } - - return newString; -}; - -String.prototype.capitalize = function() { - return this.replace(/\w+/g, - function(a) { - return ( a.charAt(0).toUpperCase() - + a.substr(1).toLowerCase() ); - }); -}; - -String.prototype.cssIdToHungarianId = function() { - var parts = this.split("-"); - var newId = parts[0]; - for (var i = 1; i < parts.length; i++) { - newId += parts[i].capitalize(); - } - - return newId; -} - -String.prototype.decodeEntities = function() { - return this.replace(/(\d+);/g, - function(wholematch, parenmatch1) { - return String.fromCharCode(+parenmatch1); - }); -}; - -String.prototype.unescapeHTMLEntities = function() { - return this.unescapeHTML().replace(/"/g,'"'); -}; - -String.prototype.asDate = function () { - var newDate; - var date = this.split("/"); - if (date.length == 3) - newDate = new Date(date[2], date[1] - 1, date[0]); // dd/mm/yyyy - else { - date = this.split("-"); - if (date.length == 3) - newDate = new Date(date[0], date[1] - 1, date[2]); // yyyy-mm-dd - else { - if (this.length == 8) { - newDate = new Date(this.substring(0, 4), - this.substring(4, 6) - 1, - this.substring(6, 8)); - } - } - } - - return newDate; -}; - -RegExp.escape = function(text) { - return text.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&"); -} - -var css_invalid_characters = [ '_' , '.', '#' , '@' , '*', ':' , ';' , ',' , ' ', - '(', ')', '[', ']', '{', '}', - "'", '"', '&', '+' ]; -var css_escape_characters = [ '_U_', '_D_', '_H_', '_A_', '_S_', '_C_', '_SC_', '_CO_', '_SP_', - '_LP_', '_RP_', '_LS_', '_RQ_', '_LC_', '_RC_', - '_SQ_', '_DQ_', '_AM_', '_P_' ]; - -String.prototype.asCSSIdentifier = function() { - var newString = this; - for (var i = 0; i < css_invalid_characters.length; i++) { - var re = new RegExp(RegExp.escape(css_invalid_characters[i]), 'g'); - newString = newString.replace(re, css_escape_characters[i]); - } - - if (/^\d/.test(newString)) - newString = '_' + newString; - - return newString; -}; - -String.prototype.fromCSSIdentifier = function() { - var newString = this; - - if (/^_\d/.test(newString)) - newString = newString.substring(1); - - for (var i = 0; i < css_escape_characters.length; i++) { - var re = new RegExp(css_escape_characters[i], 'g'); - newString = newString.replace(re, css_invalid_characters[i]); - } - - return newString; -}; - -Date.prototype.clone = function() { - var newDate = new Date(); - - newDate.setTime(this.getTime()); - - return newDate; -}; - -Date.prototype.deltaDays = function(otherDate) { - var day1 = this.getTime(); - var day2 = otherDate.getTime(); - if (day1 > day2) { - var tmp = day2; - day2 = day1; - day1 = tmp; - } - - return Math.round((day2 - day1) / 86400000); -}; - -Date.prototype.daysUpTo = function(otherDate) { - var days = new Array(); - - var day1 = this.getTime(); - var day2 = otherDate.getTime(); - if (day1 > day2) { - var tmp = day1; - day1 = day2; - day2 = tmp; - } - // var day1Date = new Date(); - // day1Date.setTime(this.getTime()); - // day1Date.setHours(0, 0, 0, 0); - // var day2Date = new Date(); - // day2Date.setTime(otherDate.getTime()); - // day2Date.setHours(23, 59, 59, 999); - // var day1 = day1Date.getTime(); - // var day2 = day2Date.getTime(); - - var nbrDays = Math.round((day2 - day1) / 86400000) + 1; - for (var i = 0; i < nbrDays; i++) { - var newDate = new Date(); - newDate.setTime(day1 + (i * 86400000)); - days.push(newDate); - } - - return days; -}; - -Date.prototype.getDayString = function() { - var newString = this.getYear(); - if (newString < 1000) newString += 1900; - var month = '' + (this.getMonth() + 1); - if (month.length == 1) - month = '0' + month; - newString += month; - var day = '' + this.getDate(); - if (day.length == 1) - day = '0' + day; - newString += day; - - return newString; -}; - -Date.prototype.getHourString = function() { - var newString = this.getHours() + '00'; - if (newString.length == 3) - newString = '0' + newString; - - return newString; -}; - -Date.prototype.getDisplayHoursString = function() { - var hoursString = "" + this.getHours(); - if (hoursString.length == 1) - hoursString = '0' + hoursString; - - var minutesString = "" + this.getMinutes(); - if (minutesString.length == 1) - minutesString = '0' + minutesString; - - return hoursString + ":" + minutesString; -}; - -Date.prototype.stringWithSeparator = function(separator) { - var month = '' + (this.getMonth() + 1); - var day = '' + this.getDate(); - var year = this.getYear(); - if (year < 1000) - year = '' + (year + 1900); - if (month.length == 1) - month = '0' + month; - if (day.length == 1) - day = '0' + day; - - if (separator == '-') - str = year + '-' + month + '-' + day; - else - str = day + '/' + month + '/' + year; - - return str; -}; - -Date.prototype.addDays = function(nbrDays) { - var dat = new Date(this.valueOf()); - this.setDate(dat.getDate() + Math.round(nbrDays)); -}; - -Date.prototype.earlierDate = function(otherDate) { - var workDate = new Date(); - workDate.setTime(otherDate.getTime()); - workDate.setHours(0); - return ((this.getTime() < workDate.getTime()) - ? this : otherDate); -}; - -Date.prototype.laterDate = function(otherDate) { - var workDate = new Date(); - workDate.setTime(otherDate.getTime()); - workDate.setHours(23); - workDate.setMinutes(59); - workDate.setSeconds(59); - workDate.setMilliseconds(999); - return ((this.getTime() < workDate.getTime()) - ? otherDate : this); -}; - -Date.prototype.beginOfDay = function() { - var beginOfDay = new Date(this.getTime()); - beginOfDay.setHours(0); - beginOfDay.setMinutes(0); - beginOfDay.setSeconds(0); - beginOfDay.setMilliseconds(0); - - return beginOfDay; -}; - -Date.prototype.beginOfWeek = function() { - var offset = firstDayOfWeek - this.getDay(); - if (offset > 0) - offset -= 7; - - var beginOfWeek = this.beginOfDay(); - beginOfWeek.setHours(12); - beginOfWeek.addDays(offset); - - return beginOfWeek; -}; - -Date.prototype.endOfWeek = function() { - var endOfWeek = this.beginOfWeek(); - endOfWeek.addDays(6); - - endOfWeek.setHours(23); - endOfWeek.setMinutes(59); - endOfWeek.setSeconds(59); - endOfWeek.setMilliseconds(999); - - return endOfWeek; -}; - -String.prototype._base64_keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; -String.prototype.base64encode = function () { - var output = ""; - var chr1, chr2, chr3, enc1, enc2, enc3, enc4; - var i = 0; - - var input = this.utf8encode(); - - while (i < input.length) { - chr1 = input.charCodeAt(i++); - chr2 = input.charCodeAt(i++); - chr3 = input.charCodeAt(i++); - - enc1 = chr1 >> 2; - enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); - enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); - enc4 = chr3 & 63; - - if (isNaN(chr2)) { - enc3 = enc4 = 64; - } else if (isNaN(chr3)) { - enc4 = 64; - } - - output = output + - this._base64_keyStr.charAt(enc1) + this._base64_keyStr.charAt(enc2) + - this._base64_keyStr.charAt(enc3) + this._base64_keyStr.charAt(enc4); - } - - return output; -}; - -String.prototype.base64decode = function() { - var output = ""; - var chr1, chr2, chr3; - var enc1, enc2, enc3, enc4; - var i = 0; - - var input = "" + this; // .replace(/[^A-Za-z0-9\+\/\=]/g, "") - while (i < input.length) { - enc1 = this._base64_keyStr.indexOf(input.charAt(i++)); - enc2 = this._base64_keyStr.indexOf(input.charAt(i++)); - enc3 = this._base64_keyStr.indexOf(input.charAt(i++)); - enc4 = this._base64_keyStr.indexOf(input.charAt(i++)); - - chr1 = (enc1 << 2) | (enc2 >> 4); - chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); - chr3 = ((enc3 & 3) << 6) | enc4; - - output = output + String.fromCharCode(chr1); - - if (enc3 != 64) { - output = output + String.fromCharCode(chr2); - } - if (enc4 != 64) { - output = output + String.fromCharCode(chr3); - } - } - - return output; -}; - -String.prototype.utf8encode = function() { - var string = this.replace(/\r\n/g,"\n"); - var utftext = ""; - - for (var n = 0; n < this.length; n++) { - var c = this.charCodeAt(n); - - if (c < 128) { - utftext += String.fromCharCode(c); - } - else if((c > 127) && (c < 2048)) { - utftext += String.fromCharCode((c >> 6) | 192); - utftext += String.fromCharCode((c & 63) | 128); - } - else { - utftext += String.fromCharCode((c >> 12) | 224); - utftext += String.fromCharCode(((c >> 6) & 63) | 128); - utftext += String.fromCharCode((c & 63) | 128); - } - } - - return utftext; -}; - -String.prototype.utf8decode = function() { - var string = ""; - var i = 0; - var c = c1 = c2 = 0; - - while (i < string.length) { - c = utftext.charCodeAt(i); - - if (c < 128) { - string += String.fromCharCode(c); - i++; - } - else if((c > 191) && (c < 224)) { - c2 = this.charCodeAt(i+1); - string += String.fromCharCode(((c & 31) << 6) | (c2 & 63)); - i += 2; - } - else { - c2 = this.charCodeAt(i+1); - c3 = this.charCodeAt(i+2); - string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63)); - i += 3; - } - } - - return string; -}; - -String.prototype.cssSafeString = function() { - var newString = this.replace("#", "_", "g"); - newString = newString.replace(".", "_", "g"); - newString = newString.replace("@", "_", "g"); - - return newString; -}; - -window.width = function() { - if (window.innerWidth) - return window.innerWidth; - else if (document.body && document.body.offsetWidth) - return document.body.offsetWidth; - else - return 0; -}; - -window.height = function() { - if (window.innerHeight) - return window.innerHeight; - else if (document.body && document.body.offsetHeight) - return document.body.offsetHeight; - else - return 0; -}; diff --git a/UI/WebServerResources/LICENSE-thunderbird.txt b/UI/WebServerResources/LICENSE-thunderbird.txt deleted file mode 100644 index 18f8109b7..000000000 --- a/UI/WebServerResources/LICENSE-thunderbird.txt +++ /dev/null @@ -1,567 +0,0 @@ - MOZILLA PUBLIC LICENSE - Version 1.1 - - --------------- - -1. Definitions. - - 1.0.1. "Commercial Use" means distribution or otherwise making the - Covered Code available to a third party. - - 1.1. "Contributor" means each entity that creates or contributes to - the creation of Modifications. - - 1.2. "Contributor Version" means the combination of the Original - Code, prior Modifications used by a Contributor, and the Modifications - made by that particular Contributor. - - 1.3. "Covered Code" means the Original Code or Modifications or the - combination of the Original Code and Modifications, in each case - including portions thereof. - - 1.4. "Electronic Distribution Mechanism" means a mechanism generally - accepted in the software development community for the electronic - transfer of data. - - 1.5. "Executable" means Covered Code in any form other than Source - Code. - - 1.6. "Initial Developer" means the individual or entity identified - as the Initial Developer in the Source Code notice required by Exhibit - A. - - 1.7. "Larger Work" means a work which combines Covered Code or - portions thereof with code not governed by the terms of this License. - - 1.8. "License" means this document. - - 1.8.1. "Licensable" means having the right to grant, to the maximum - extent possible, whether at the time of the initial grant or - subsequently acquired, any and all of the rights conveyed herein. - - 1.9. "Modifications" means any addition to or deletion from the - substance or structure of either the Original Code or any previous - Modifications. When Covered Code is released as a series of files, a - Modification is: - A. Any addition to or deletion from the contents of a file - containing Original Code or previous Modifications. - - B. Any new file that contains any part of the Original Code or - previous Modifications. - - 1.10. "Original Code" means Source Code of computer software code - which is described in the Source Code notice required by Exhibit A as - Original Code, and which, at the time of its release under this - License is not already Covered Code governed by this License. - - 1.10.1. "Patent Claims" means any patent claim(s), now owned or - hereafter acquired, including without limitation, method, process, - and apparatus claims, in any patent Licensable by grantor. - - 1.11. "Source Code" means the preferred form of the Covered Code for - making modifications to it, including all modules it contains, plus - any associated interface definition files, scripts used to control - compilation and installation of an Executable, or source code - differential comparisons against either the Original Code or another - well known, available Covered Code of the Contributor's choice. The - Source Code can be in a compressed or archival form, provided the - appropriate decompression or de-archiving software is widely available - for no charge. - - 1.12. "You" (or "Your") means an individual or a legal entity - exercising rights under, and complying with all of the terms of, this - License or a future version of this License issued under Section 6.1. - For legal entities, "You" includes any entity which controls, is - controlled by, or is under common control with You. For purposes of - this definition, "control" means (a) the power, direct or indirect, - to cause the direction or management of such entity, whether by - contract or otherwise, or (b) ownership of more than fifty percent - (50%) of the outstanding shares or beneficial ownership of such - entity. - -2. Source Code License. - - 2.1. The Initial Developer Grant. - The Initial Developer hereby grants You a world-wide, royalty-free, - non-exclusive license, subject to third party intellectual property - claims: - (a) under intellectual property rights (other than patent or - trademark) Licensable by Initial Developer to use, reproduce, - modify, display, perform, sublicense and distribute the Original - Code (or portions thereof) with or without Modifications, and/or - as part of a Larger Work; and - - (b) under Patents Claims infringed by the making, using or - selling of Original Code, to make, have made, use, practice, - sell, and offer for sale, and/or otherwise dispose of the - Original Code (or portions thereof). - - (c) the licenses granted in this Section 2.1(a) and (b) are - effective on the date Initial Developer first distributes - Original Code under the terms of this License. - - (d) Notwithstanding Section 2.1(b) above, no patent license is - granted: 1) for code that You delete from the Original Code; 2) - separate from the Original Code; or 3) for infringements caused - by: i) the modification of the Original Code or ii) the - combination of the Original Code with other software or devices. - - 2.2. Contributor Grant. - Subject to third party intellectual property claims, each Contributor - hereby grants You a world-wide, royalty-free, non-exclusive license - - (a) under intellectual property rights (other than patent or - trademark) Licensable by Contributor, to use, reproduce, modify, - display, perform, sublicense and distribute the Modifications - created by such Contributor (or portions thereof) either on an - unmodified basis, with other Modifications, as Covered Code - and/or as part of a Larger Work; and - - (b) under Patent Claims infringed by the making, using, or - selling of Modifications made by that Contributor either alone - and/or in combination with its Contributor Version (or portions - of such combination), to make, use, sell, offer for sale, have - made, and/or otherwise dispose of: 1) Modifications made by that - Contributor (or portions thereof); and 2) the combination of - Modifications made by that Contributor with its Contributor - Version (or portions of such combination). - - (c) the licenses granted in Sections 2.2(a) and 2.2(b) are - effective on the date Contributor first makes Commercial Use of - the Covered Code. - - (d) Notwithstanding Section 2.2(b) above, no patent license is - granted: 1) for any code that Contributor has deleted from the - Contributor Version; 2) separate from the Contributor Version; - 3) for infringements caused by: i) third party modifications of - Contributor Version or ii) the combination of Modifications made - by that Contributor with other software (except as part of the - Contributor Version) or other devices; or 4) under Patent Claims - infringed by Covered Code in the absence of Modifications made by - that Contributor. - -3. Distribution Obligations. - - 3.1. Application of License. - The Modifications which You create or to which You contribute are - governed by the terms of this License, including without limitation - Section 2.2. The Source Code version of Covered Code may be - distributed only under the terms of this License or a future version - of this License released under Section 6.1, and You must include a - copy of this License with every copy of the Source Code You - distribute. You may not offer or impose any terms on any Source Code - version that alters or restricts the applicable version of this - License or the recipients' rights hereunder. However, You may include - an additional document offering the additional rights described in - Section 3.5. - - 3.2. Availability of Source Code. - Any Modification which You create or to which You contribute must be - made available in Source Code form under the terms of this License - either on the same media as an Executable version or via an accepted - Electronic Distribution Mechanism to anyone to whom you made an - Executable version available; and if made available via Electronic - Distribution Mechanism, must remain available for at least twelve (12) - months after the date it initially became available, or at least six - (6) months after a subsequent version of that particular Modification - has been made available to such recipients. You are responsible for - ensuring that the Source Code version remains available even if the - Electronic Distribution Mechanism is maintained by a third party. - - 3.3. Description of Modifications. - You must cause all Covered Code to which You contribute to contain a - file documenting the changes You made to create that Covered Code and - the date of any change. You must include a prominent statement that - the Modification is derived, directly or indirectly, from Original - Code provided by the Initial Developer and including the name of the - Initial Developer in (a) the Source Code, and (b) in any notice in an - Executable version or related documentation in which You describe the - origin or ownership of the Covered Code. - - 3.4. Intellectual Property Matters - (a) Third Party Claims. - If Contributor has knowledge that a license under a third party's - intellectual property rights is required to exercise the rights - granted by such Contributor under Sections 2.1 or 2.2, - Contributor must include a text file with the Source Code - distribution titled "LEGAL" which describes the claim and the - party making the claim in sufficient detail that a recipient will - know whom to contact. If Contributor obtains such knowledge after - the Modification is made available as described in Section 3.2, - Contributor shall promptly modify the LEGAL file in all copies - Contributor makes available thereafter and shall take other steps - (such as notifying appropriate mailing lists or newsgroups) - reasonably calculated to inform those who received the Covered - Code that new knowledge has been obtained. - - (b) Contributor APIs. - If Contributor's Modifications include an application programming - interface and Contributor has knowledge of patent licenses which - are reasonably necessary to implement that API, Contributor must - also include this information in the LEGAL file. - - (c) Representations. - Contributor represents that, except as disclosed pursuant to - Section 3.4(a) above, Contributor believes that Contributor's - Modifications are Contributor's original creation(s) and/or - Contributor has sufficient rights to grant the rights conveyed by - this License. - - 3.5. Required Notices. - You must duplicate the notice in Exhibit A in each file of the Source - Code. If it is not possible to put such notice in a particular Source - Code file due to its structure, then You must include such notice in a - location (such as a relevant directory) where a user would be likely - to look for such a notice. If You created one or more Modification(s) - You may add your name as a Contributor to the notice described in - Exhibit A. You must also duplicate this License in any documentation - for the Source Code where You describe recipients' rights or ownership - rights relating to Covered Code. You may choose to offer, and to - charge a fee for, warranty, support, indemnity or liability - obligations to one or more recipients of Covered Code. However, You - may do so only on Your own behalf, and not on behalf of the Initial - Developer or any Contributor. You must make it absolutely clear than - any such warranty, support, indemnity or liability obligation is - offered by You alone, and You hereby agree to indemnify the Initial - Developer and every Contributor for any liability incurred by the - Initial Developer or such Contributor as a result of warranty, - support, indemnity or liability terms You offer. - - 3.6. Distribution of Executable Versions. - You may distribute Covered Code in Executable form only if the - requirements of Section 3.1-3.5 have been met for that Covered Code, - and if You include a notice stating that the Source Code version of - the Covered Code is available under the terms of this License, - including a description of how and where You have fulfilled the - obligations of Section 3.2. The notice must be conspicuously included - in any notice in an Executable version, related documentation or - collateral in which You describe recipients' rights relating to the - Covered Code. You may distribute the Executable version of Covered - Code or ownership rights under a license of Your choice, which may - contain terms different from this License, provided that You are in - compliance with the terms of this License and that the license for the - Executable version does not attempt to limit or alter the recipient's - rights in the Source Code version from the rights set forth in this - License. If You distribute the Executable version under a different - license You must make it absolutely clear that any terms which differ - from this License are offered by You alone, not by the Initial - Developer or any Contributor. You hereby agree to indemnify the - Initial Developer and every Contributor for any liability incurred by - the Initial Developer or such Contributor as a result of any such - terms You offer. - - 3.7. Larger Works. - You may create a Larger Work by combining Covered Code with other code - not governed by the terms of this License and distribute the Larger - Work as a single product. In such a case, You must make sure the - requirements of this License are fulfilled for the Covered Code. - -4. Inability to Comply Due to Statute or Regulation. - - If it is impossible for You to comply with any of the terms of this - License with respect to some or all of the Covered Code due to - statute, judicial order, or regulation then You must: (a) comply with - the terms of this License to the maximum extent possible; and (b) - describe the limitations and the code they affect. Such description - must be included in the LEGAL file described in Section 3.4 and must - be included with all distributions of the Source Code. Except to the - extent prohibited by statute or regulation, such description must be - sufficiently detailed for a recipient of ordinary skill to be able to - understand it. - -5. Application of this License. - - This License applies to code to which the Initial Developer has - attached the notice in Exhibit A and to related Covered Code. - -6. Versions of the License. - - 6.1. New Versions. - Netscape Communications Corporation ("Netscape") may publish revised - and/or new versions of the License from time to time. Each version - will be given a distinguishing version number. - - 6.2. Effect of New Versions. - Once Covered Code has been published under a particular version of the - License, You may always continue to use it under the terms of that - version. You may also choose to use such Covered Code under the terms - of any subsequent version of the License published by Netscape. No one - other than Netscape has the right to modify the terms applicable to - Covered Code created under this License. - - 6.3. Derivative Works. - If You create or use a modified version of this License (which you may - only do in order to apply it to code which is not already Covered Code - governed by this License), You must (a) rename Your license so that - the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape", - "MPL", "NPL" or any confusingly similar phrase do not appear in your - license (except to note that your license differs from this License) - and (b) otherwise make it clear that Your version of the license - contains terms which differ from the Mozilla Public License and - Netscape Public License. (Filling in the name of the Initial - Developer, Original Code or Contributor in the notice described in - Exhibit A shall not of themselves be deemed to be modifications of - this License.) - -7. DISCLAIMER OF WARRANTY. - - COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, - WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF - DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. - THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE - IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT, - YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE - COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER - OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF - ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. - -8. TERMINATION. - - 8.1. This License and the rights granted hereunder will terminate - automatically if You fail to comply with terms herein and fail to cure - such breach within 30 days of becoming aware of the breach. All - sublicenses to the Covered Code which are properly granted shall - survive any termination of this License. Provisions which, by their - nature, must remain in effect beyond the termination of this License - shall survive. - - 8.2. If You initiate litigation by asserting a patent infringement - claim (excluding declatory judgment actions) against Initial Developer - or a Contributor (the Initial Developer or Contributor against whom - You file such action is referred to as "Participant") alleging that: - - (a) such Participant's Contributor Version directly or indirectly - infringes any patent, then any and all rights granted by such - Participant to You under Sections 2.1 and/or 2.2 of this License - shall, upon 60 days notice from Participant terminate prospectively, - unless if within 60 days after receipt of notice You either: (i) - agree in writing to pay Participant a mutually agreeable reasonable - royalty for Your past and future use of Modifications made by such - Participant, or (ii) withdraw Your litigation claim with respect to - the Contributor Version against such Participant. If within 60 days - of notice, a reasonable royalty and payment arrangement are not - mutually agreed upon in writing by the parties or the litigation claim - is not withdrawn, the rights granted by Participant to You under - Sections 2.1 and/or 2.2 automatically terminate at the expiration of - the 60 day notice period specified above. - - (b) any software, hardware, or device, other than such Participant's - Contributor Version, directly or indirectly infringes any patent, then - any rights granted to You by such Participant under Sections 2.1(b) - and 2.2(b) are revoked effective as of the date You first made, used, - sold, distributed, or had made, Modifications made by that - Participant. - - 8.3. If You assert a patent infringement claim against Participant - alleging that such Participant's Contributor Version directly or - indirectly infringes any patent where such claim is resolved (such as - by license or settlement) prior to the initiation of patent - infringement litigation, then the reasonable value of the licenses - granted by such Participant under Sections 2.1 or 2.2 shall be taken - into account in determining the amount or value of any payment or - license. - - 8.4. In the event of termination under Sections 8.1 or 8.2 above, - all end user license agreements (excluding distributors and resellers) - which have been validly granted by You or any distributor hereunder - prior to termination shall survive termination. - -9. LIMITATION OF LIABILITY. - - UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT - (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL - DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE, - OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR - ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY - CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, - WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER - COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN - INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF - LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY - RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW - PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE - EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO - THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. - -10. U.S. GOVERNMENT END USERS. - - The Covered Code is a "commercial item," as that term is defined in - 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer - software" and "commercial computer software documentation," as such - terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 - C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), - all U.S. Government End Users acquire Covered Code with only those - rights set forth herein. - -11. MISCELLANEOUS. - - This License represents the complete agreement concerning subject - matter hereof. If any provision of this License is held to be - unenforceable, such provision shall be reformed only to the extent - necessary to make it enforceable. This License shall be governed by - California law provisions (except to the extent applicable law, if - any, provides otherwise), excluding its conflict-of-law provisions. - With respect to disputes in which at least one party is a citizen of, - or an entity chartered or registered to do business in the United - States of America, any litigation relating to this License shall be - subject to the jurisdiction of the Federal Courts of the Northern - District of California, with venue lying in Santa Clara County, - California, with the losing party responsible for costs, including - without limitation, court costs and reasonable attorneys' fees and - expenses. The application of the United Nations Convention on - Contracts for the International Sale of Goods is expressly excluded. - Any law or regulation which provides that the language of a contract - shall be construed against the drafter shall not apply to this - License. - -12. RESPONSIBILITY FOR CLAIMS. - - As between Initial Developer and the Contributors, each party is - responsible for claims and damages arising, directly or indirectly, - out of its utilization of rights under this License and You agree to - work with Initial Developer and Contributors to distribute such - responsibility on an equitable basis. Nothing herein is intended or - shall be deemed to constitute any admission of liability. - -13. MULTIPLE-LICENSED CODE. - - Initial Developer may designate portions of the Covered Code as - "Multiple-Licensed". "Multiple-Licensed" means that the Initial - Developer permits you to utilize portions of the Covered Code under - Your choice of the NPL or the alternative licenses, if any, specified - by the Initial Developer in the file described in Exhibit A. - -EXHIBIT A -Mozilla Public License. - - ``The contents of this file are subject to the Mozilla Public License - Version 1.1 (the "License"); you may not use this file except in - compliance with the License. You may obtain a copy of the License at - http://www.mozilla.org/MPL/ - - Software distributed under the License is distributed on an "AS IS" - basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the - License for the specific language governing rights and limitations - under the License. - - The Original Code is ______________________________________. - - The Initial Developer of the Original Code is ________________________. - Portions created by ______________________ are Copyright (C) ______ - _______________________. All Rights Reserved. - - Contributor(s): ______________________________________. - - Alternatively, the contents of this file may be used under the terms - of the _____ license (the "[___] License"), in which case the - provisions of [______] License are applicable instead of those - above. If you wish to allow use of your version of this file only - under the terms of the [____] License and not to allow others to use - your version of this file under the MPL, indicate your decision by - deleting the provisions above and replace them with the notice and - other provisions required by the [___] License. If you do not delete - the provisions above, a recipient may use your version of this file - under either the MPL or the [___] License." - - [NOTE: The text of this Exhibit A may differ slightly from the text of - the notices in the Source Code files of the Original Code. You should - use the text of this Exhibit A rather than the text found in the - Original Code Source Code for Your Modifications.] - - ---------------------------------------------------------------------- - - AMENDMENTS - - The Netscape Public License Version 1.1 ("NPL") consists of the - Mozilla Public License Version 1.1 with the following Amendments, - including Exhibit A-Netscape Public License. Files identified with - "Exhibit A-Netscape Public License" are governed by the Netscape - Public License Version 1.1. - - Additional Terms applicable to the Netscape Public License. - I. Effect. - These additional terms described in this Netscape Public - License -- Amendments shall apply to the Mozilla Communicator - client code and to all Covered Code under this License. - - II. "Netscape's Branded Code" means Covered Code that Netscape - distributes and/or permits others to distribute under one or more - trademark(s) which are controlled by Netscape but which are not - licensed for use under this License. - - III. Netscape and logo. - This License does not grant any rights to use the trademarks - "Netscape", the "Netscape N and horizon" logo or the "Netscape - lighthouse" logo, "Netcenter", "Gecko", "Java" or "JavaScript", - "Smart Browsing" even if such marks are included in the Original - Code or Modifications. - - IV. Inability to Comply Due to Contractual Obligation. - Prior to licensing the Original Code under this License, Netscape - has licensed third party code for use in Netscape's Branded Code. - To the extent that Netscape is limited contractually from making - such third party code available under this License, Netscape may - choose to reintegrate such code into Covered Code without being - required to distribute such code in Source Code form, even if - such code would otherwise be considered "Modifications" under - this License. - - V. Use of Modifications and Covered Code by Initial Developer. - V.1. In General. - The obligations of Section 3 apply to Netscape, except to - the extent specified in this Amendment, Section V.2 and V.3. - - V.2. Other Products. - Netscape may include Covered Code in products other than the - Netscape's Branded Code which are released by Netscape - during the two (2) years following the release date of the - Original Code, without such additional products becoming - subject to the terms of this License, and may license such - additional products on different terms from those contained - in this License. - - V.3. Alternative Licensing. - Netscape may license the Source Code of Netscape's Branded - Code, including Modifications incorporated therein, without - such Netscape Branded Code becoming subject to the terms of - this License, and may license such Netscape Branded Code on - different terms from those contained in this License. - - VI. Litigation. - Notwithstanding the limitations of Section 11 above, the - provisions regarding litigation in Section 11(a), (b) and (c) of - the License shall apply to all disputes relating to this License. - - EXHIBIT A-Netscape Public License. - - "The contents of this file are subject to the Netscape Public - License Version 1.1 (the "License"); you may not use this file - except in compliance with the License. You may obtain a copy of - the License at http://www.mozilla.org/NPL/ - - Software distributed under the License is distributed on an "AS - IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or - implied. See the License for the specific language governing - rights and limitations under the License. - - The Original Code is Mozilla Communicator client code, released - March 31, 1998. - - The Initial Developer of the Original Code is Netscape - Communications Corporation. Portions created by Netscape are - Copyright (C) 1998-1999 Netscape Communications Corporation. All - Rights Reserved. - - Contributor(s): ______________________________________. - - Alternatively, the contents of this file may be used under the - terms of the _____ license (the "[___] License"), in which case - the provisions of [______] License are applicable instead of - those above. If you wish to allow use of your version of this - file only under the terms of the [____] License and not to allow - others to use your version of this file under the NPL, indicate - your decision by deleting the provisions above and replace them - with the notice and other provisions required by the [___] - License. If you do not delete the provisions above, a recipient - may use your version of this file under either the NPL or the - [___] License." diff --git a/UI/WebServerResources/MailerUI.css b/UI/WebServerResources/MailerUI.css deleted file mode 100644 index 61c8750b2..000000000 --- a/UI/WebServerResources/MailerUI.css +++ /dev/null @@ -1,897 +0,0 @@ -/* - Copyright (C) 2005-2013 Inverse inc. - Copyright (C) 2005 SKYRIX Software AG - - This file is part of SOGo. - - SOGo is free software; you can redistribute it and/or modify it under - the terms of the GNU Lesser General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any - later version. - - SOGo is distributed in the hope that it will be useful, but WITHOUT ANY - WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public - License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with OGo; see the file COPYING. If not, write toge the - Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA - 02111-1307, USA. -*/ - -DIV#leftPanel -{ - position: absolute; - top: 85px; - left: 0px; - width: 15em; - bottom: 0px; - margin: 0px; - padding: 0px; - overflow: hidden; -} - -DIV#rightPanel -{ position: absolute; - top: 80px; - left: 15em; - right: 0px; - bottom: 0px; - margin: 0px; - margin-left: 5px; - padding: 0px; - overflow: hidden; } - -/* top list */ -DIV#mailboxContent -{ cursor: default; - position: absolute; - background-color: #FFFFFF; - top: 2.5em; - left: 0px; - right: 0px; - height: 15.5em; - border-left: 1px solid #9B9B9B; - overflow: hidden; } - -DIV#mailboxList -{ overflow: auto; - overflow-x: hidden; } - -DIV#messageContent -{ position: absolute; - overflow: hidden; - top: 18em; - bottom: 0px; - left: 0px; - right: 0px; - margin: 0px; - margin-top: 5px; - padding: 0px; - border: 0px; - border-top: 1px solid #aaa; - border-left: 1px solid #aaa; - background: #fff; } - -DIV#messageContent P IMG -{ border: 0px; - vertical-align: middle; - margin-right: 1em; } - -DIV#folderTreeContent -{ border-top: 1px solid #909090; - border-left: 1px solid #909090; - border-bottom: 1px solid #FFFFFF; - border-right: 1px solid #FFFFFF; - position: absolute; - background: #CCDDEC; - color: #535D6D; - width: auto; - top: 2em; - bottom: 0px; - left: 0px; - right: 0px; - overflow: auto; } - -.aptview_title -{ - color: #000000; - font-weight: bold; -} - -.aptview_text -{ - color: #000000; -} - -.apt_other -{ - color: #000000; -} - -.apt_other_print -{ - font-style: italic; -} - -/* new stuff for Thunderbird like mailer */ - -.vertframerow -{ - border-top-color: white; - border-top-width: 1px; - border-top-style: solid; - border-bottom-color: #808080; - border-bottom-width: 1px; - border-bottom-style: solid; - background-color: #dcdad5; -} - -.foldercell -{ - width: 25%; -} - -.contentcell -{ -} - -.embedwhite_out -{ - border-width: 1px; - border-style: solid; - border-top-color: #808080; - border-left-color: #808080; - border-bottom-color: white; - border-right-color: white; -} - -.embedwhite_in -{ - border-width: 1px; - border-style: solid; - border-top-color: #808080; /* TODO */ - border-left-color: #808080; /* TODO */ - border-bottom-color: #808080; - border-right-color: #808080; - - background-color: white; - /* height: 300px; */ - /* height: 100%; */ -} - -.titlediv -{ - height: 2em; - line-height: 18px; - vertical-align: middle; - padding-top: 0px; - padding-left: 6px; } - -TABLE.titletable -{ - height: 24px; - vertical-align: middle; - padding-top: 6px; - padding-left: 6px; -} - -TABLE.titletable TD.titlecell SELECT -{ - display: -moz-popup; - border-top: 1px solid #fff; - border-left: 1px solid #fff; - border-right: 2px solid #222; - border-bottom: 2px solid #222; - -moz-border-bottom-colors: #000 #9c9a94 transparent; - -moz-border-right-colors: #000 #9c9a94 transparent; - background: #dcdad5; -} - -.whitesec_title -{ - background-color: #dcdad5; - padding: 4px; -} - -.treecell -{ - color: black; - vertical-align: bottom; - padding-left: 4px; /* move away from the icon */ - padding-right: 2px; /* move away from the right border */ - white-space: nowrap; -} - -DIV#folderTreeContent -{ -khtml-user-select: none;} - -/* mailbox tree (dtree) */ -DIV.dTreeNode SPAN.unseen -{ font-weight: bold; } - -/* mail tableview */ - -/* messages table with fixed headers */ - -TABLE.messageList -{ width: 100%; - -moz-user-select: none; - -khtml-user-select: none; } - -TABLE.messageList TH, -TABLE.messageList TD -{ height: 20px; - min-height: 20px; - text-overflow: ellipsis; - overflow: hidden; - padding: 0px 3px; - min-width: 22px; - margin: 0; - white-space: nowrap; } - -TABLE.messageList TH, -TR#messageCountHeader TH -{ height: 22px; - min-height: 22px; } - -TR#messageCountHeader TH -{ border-top: 0px; } - -TABLE.messageList TD -{ border-right: 1px solid transparent; } - -TABLE.messageList .messageThreadColumn, -TABLE.messageList .messageFlagColumn, -TABLE.messageList .messageAttachmentColumn, -TABLE.messageList .messageUnreadColumn -{ width: 22px; - max-width: 22px; - text-align: center; } - -TABLE.messageList .messageSubjectColumn -{ max-width: 30%; - width: 30%; } - -TABLE.messageList .messageSubjectColumn SPAN -{ padding-left: 20px; } - -TABLE.messageList TR.openedThread TD, -TABLE.messageList TR.closedThread TD, -TABLE.messageList TR.thread .messageThreadColumn -{ background-color: #DDD; } - -TABLE.messageList TR.thread TD -{ background-color: #EEE; } - -TABLE.messageList TR.thread1 .messageSubjectColumn -{ background-position: 20px 0px !important; - padding-left: 20px; } -TABLE.messageList TR.thread2 .messageSubjectColumn -{ background-position: 40px 0px !important; - padding-left: 40px; } -TABLE.messageList TR.thread3 .messageSubjectColumn -{ background-position: 60px 0px !important; - padding-left: 60px; } -TABLE.messageList TR.thread4 .messageSubjectColumn -{ background-position: 80px 0px !important; - padding-left: 80px; } -TABLE.messageList TR.thread5 .messageSubjectColumn -{ background-position: 100px 0px !important; - padding-left: 100px; } -TABLE.messageList TR.thread6 .messageSubjectColumn -{ background-position: 120px 0px !important; - padding-left: 120px; } -TABLE.messageList TR.thread7 .messageSubjectColumn -{ background-position: 140px 0px !important; - padding-left: 140px; } -TABLE.messageList TR.thread8 .messageSubjectColumn -{ background-position: 160px 0px !important; - padding-left: 160px; } -TABLE.messageList TR.thread9 .messageSubjectColumn -{ background-position: 180px 0px !important; - padding-left: 180px; } -TABLE.messageList TR.thread10 .messageSubjectColumn -{ background-position: 200px 0px !important; - padding-left: 200px; } - -TABLE.messageList .messageAddressColumn -{ max-width: 18%; - width: 18%; } - -TABLE.messageList .messageDateColumn -{ max-width: 22%; - width: 22%; } - -TABLE.messageList .messagePriorityColumn -{ width: 60px; - max-width: 60px; } - -TABLE.messageList .messageSizeColumn -{ min-width: 40px; } - -TR#rowTop TD -{ height: 0; - min-height: 0; - padding-top: 0; - padding-bottom: 0; } - -TABLE.messageList TR._selected TD -{ background-color: #9ABCD8; - color: #fff; } - -TABLE.messageList TR._deleted TD -{ text-decoration: line-through; } - -TABLE.messageList TR.mailer_unreadmail TD, -TR.mailer_unreadmail TD.messageSubjectColumn -{ font-weight: bold !important; } - -TR.mailer_repliedmailsubject TD.messageSubjectColumn -{ background-image: url(icon-replied.png) !important; - background-repeat: no-repeat !important; - background-position: 0px 0px !important; } - -TR.mailer_forwardedmailsubject TD.messageSubjectColumn -{ background-image: url(icon-forwarded.png) !important; - background-repeat: no-repeat !important; - background-position: 0px 0px !important; } - -TR.mailer_forwardedrepliedmailsubject TD.messageSubjectColumn -{ - background-image: url(icon-forwarded-replied.png) !important; - background-repeat: no-repeat !important; - background-position: 0px 0px !important; } - -TR.mailer_deletedmailsubject TD.messageSubjectColumn -{ - background-image: url(icon-deleted.png) !important; - background-repeat: no-repeat !important; - background-position: 0px 0px !important; } - -TD.mailer_readmailsubject A -{ - color: black; - text-decoration: none; -} - -TD.mailer_unreadmailsubject A -{ - color: black; - text-decoration: none; -} - -TR.mailer_listcell_deleted TD -{ - text-decoration: line-through; -} - -TR.mailer_listcell_regular TD A -{ - color: black; - text-decoration: none; -} - -/* mail viewer */ -#actionButtons -{ - position: absolute; - top: 2.5em; - right: 1em; -} - -.popup #actionButtons -{ - top: 7.0em; -} - -#editDraftButton, -#loadImagesButton -{ - float: right; -} - - -#signedImage -{ - position: absolute; - top: 5px; - right: 5px; -} - -.popup #signedImage -{ - top: 54px; - right: 5px; -} - -TABLE.mailer_fieldtable -{ top: 0px; - left: 0px; - padding-top: .5em; - padding-bottom: .5em; - overflow-y: auto; - overflow-x: hidden; - border-bottom: 1px solid #808080; - background: #DDDDDD; - width: 100%; } - -DIV.mailer_mailcontent -{ background-color: #fff; - padding: .5em; - position: absolute; - top: 7.5em; - left: 0px; - right: 0px; - bottom: 0px; - overflow: auto; } - -DIV.mailer_mailcontent TABLE -{ - table-layout: auto; -} - -/* collapsable header */ -TD.mailer_fieldname IMG.collapse, -TD.mailer_fieldname IMG.expand -{ cursor: pointer; - padding-right: 5px; } -TD.mailer_fieldvalue SPAN.collapse -{ white-space: nowrap; } -TD.mailer_fieldvalue SPAN.expand -{ white-space: normal; } - -TD.mailer_fieldname -{ - white-space: nowrap; - padding: 0 1em; - text-align: right; - font-weight: bold; - vertical-align: top; - width: 9em; -} - -TD.mailer_fieldvalue -{ vertical-align: top; } - -TD.mailer_subjectfieldvalue -{ - font-weight: bold; - white-space: pre; - white-space: pre-wrap; /* css-3 */ - white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ - white-space: -pre-wrap; /* Opera 4-6 */ - white-space: -o-pre-wrap; /* Opera 7 */ - white-space: pre-wrap; -} - -TD.mailer_fieldvalue a -{ - text-decoration: underline; - vertical-align: top; -} - -TR.deleted TD -{ /* text-decoration: line-through; -- alternative display */ } - -img.mailer_imagecontent -{ - border: 0px; -} - -DIV.mailer_plaincontent -{ - position: relative; - clear: left; - font-family: monospace, fixed; - white-space: pre; - white-space: pre-wrap; /* css-3 */ - white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ - white-space: -pre-wrap; /* Opera 4-6 */ - white-space: -o-pre-wrap; /* Opera 7 */ - word-wrap: break-word; /* Internet Explorer 5.5+ */ - width: 99%; - font-size: inherit; - margin: 0px; - padding: 0px; -} - -DIV.mailer_plaincontent P -{ - line-height: 3em; - height: auto; - margin: 0px; - padding: 0px; -} - -DIV.mailer_htmlcontent P -{ - white-space: normal; - font-family: sans-serif; - font-size: inherit; - padding: 0px; -} - -/* attachment editor */ - -form#attachment_form -{ - background-color: #dcdad5; - padding: 1px; -} - -div#attachment_list -{ - border-top-color: white; - border-top-width: 1px; - border-top-style: solid; -} - -div#attachment_upload -{ - border-bottom-color: #808080; - border-bottom-width: 1px; - border-bottom-style: solid; - padding: 4px; -} - -TD.attachment_uplabel -{ - width: 15%; - text-align: left; -} - -/* attachment link viewer */ - -DIV.linked_attachment_frame -{ - border: 0px; - clear: left; - margin: 0px; - margin-top: 10px; - padding: 5px; - /*background: #F0F0F0;*/ -} - -DIV.linked_attachment_frame fieldset -{ - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; -} - -DIV.linked_attachment_frame.file -{ display: inline; - clear: none; - float: left; } - -DIV.linked_attachment_body -{ - border: 0px; - text-align: center; -} - -DIV.linked_attachment_meta -{ - color: #444444; - border-width: 0; - padding: 2px 4px; -} - -TABLE.linked_attachment_meta -{ - color: #444444; -} - -.linked_attachment_body a:hover -{ - text-decoration: none; -} - -.linked_attachment_body a:hover .linked_attachment_meta -{ - background-color: #9ABCD8; - color: #fff; - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - border-radius: 5px; -} - -.linked_attachment_body a:hover .muted -{ - color: #fff !important; -} - -DIV.linked_attachment_body HR -{ - border: 0px; - border-top: 1px solid #ddd; -} - -DIV.bodyFields -{ - background: #eee; - line-height: 1.5em; - margin: 0.5em 0px; - padding-bottom: 0.5em; - padding-top: 0.5em; - text-align: left; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; -} - -DIV.bodyFields SPAN.fieldName -{ - float: left; - font-weight: bold; - padding-right: 1em; - text-align: right; - width: 9em; -} - -DIV.bodyAdditionalFields -{ - color: #777; -} - -DIV.bodyMailContent -{ margin: 0.5em; - text-align: left; } - -DIV[datatype~="additional"] > A.node > SPAN.nodeName -{ color: #777; - font-style: italic; } - -DIV[datatype~="additional"] > A.node._selected > SPAN.nodeName -{ color: #fff; } - -/* drag-n-drop */ -IMG.dragMessage -{ position: absolute; - visibility: hidden; - border: 0px; - -moz-opacity: 0.7; - opacity: 0.7; } - -TABLE#addr_table -{ - margin-left: 30%; - width: 100%; -} - -/* quota indicator */ -DIV.quota -{ border-bottom: 1px solid #ccc; - margin: 2px 4px 2px 2px; } -DIV.quota DIV.level -{ background-image: url(quota-level.png); - background-repeat: repeat-x; - background-position: 25% 0; - border-left: 1px solid #999; - border-right: 1px solid #999; - /*height: 20px;*/ } -DIV.quota DIV.marks DIV -{ float: left; - margin: 0; - padding: 0; - width: 25%; - border: 0; - border-right: 1px solid #999; - height: 3px; } -DIV.quota DIV.level DIV.value -{ background-repeat: repeat-x; - border-left: 1px solid transparent; - height: 9px; - margin: 0; - position: relative; } -DIV.quota DIV.level DIV.value.ok -{ background-image: url(quota-level-ok.png); } -DIV.quota DIV.level DIV.value.warn -{ background-image: url(quota-level-warn.png); } -DIV.quota DIV.level DIV.value.alert -{ background-image: url(quota-level-alert.png); } -DIV.quota DIV.level P -{ margin: 0; - padding: 0; - clear: both; - color: #555; - font-size: 1em; - text-align: center; -} -DIV#quotaDialog -{ background-image: url("dialog-left.png"); - background-repeat: no-repeat; - background-position: top left; - position: absolute; - top: 100px; - left: 75px; - width: 200px; - z-index: 50; } -DIV#quotaDialog DIV -{ border: 1px solid #444; - background-color: #fff; - padding: 5px; } -DIV#quotaDialog DIV -{ border-left: 0; - margin-left: 19px; - text-align: left; } -DIV#quotaDialog H1, -DIV#quotaDialog P -{ font-size: 10px; - margin: 0; - padding: 0; } - -/* drag handles */ -DIV#verticalDragHandle -{ cursor: e-resize; - border: 0px; - top: 81px; - left: 15em; - width: 5px; - bottom: 0px; } - -DIV#rightDragHandle -{ cursor: n-resize; - top: 18em; - left: 0px; - right: 0px; - height: 5px; } - -@media print -{ - DIV#leftPanel, - DIV#verticalDragHandle, - DIV#filterPanel, - DIV#mailboxContent, - DIV.dragHandle - { display: none; } - - DIV#rightPanel - { position: static; - overflow: visible; - margin: 0px; } - - DIV#messageContent - { position: static; - border: 0px; - margin: 0px; - overflow: visible; } - - TABLE.mailer_fieldtable - { border: 0px; - font-family: serif; - height: auto; - overflow: visible; } - - TD.mailer_fieldname - { text-align: left; } - - TD.mailer_fieldname IMG - { display: none; } - - TD.mailer_fieldvalue, - TD.mailer_fieldvalue SPAN.collapse - { white-space: normal; } - - TD.mailer_fieldvalue A - { text-decoration: none; - white-space: nowrap; - color: #000; } - - A:visited - { color: #00f; } - - DIV.mailer_mailcontent - { position: static; - overflow: visible; } -} - -DIV#dragDropVisual -{ - background-image: url(message.gif); - background-repeat: no-repeat; - background-position: 4px 2px; - width: 5px; - height: 20px; - padding-left: 24px; - padding-top: 5px; -} - -DIV.copy -{ - background-image: url(message-copy.gif) !important; - background-position: 1px -2px !important; -} - -DIV#signatureFlagMessage DIV -{ text-align: left !important; } - -DIV#signatureFlagMessage H1, -DIV#signatureFlagMessage P -{ font-size: 10px; - margin: 0; - padding: 0; } - -TR#messageCountHeader TD -{ border-top: none; } - -/* UIxMailPartICalViewer */ -#iCalAttendees -{ padding: 0; } - -#iCalAttendees dt -{ font-weight: bold; } - -#iCalAttendees SPAN -{ line-height: 19px; } - -#iCalAttendees DIV.status-icon -{ background-repeat: no-repeat; - float: left; - padding: 0px; - clear: both; - width: 12px; - height: 18px; - margin-top: 1px; - margin-left: 4px; - margin-right: 4px; - background-image: url("attendee-partstats.png"); } - -#iCalAttendees .accepted DIV.status-icon -{ background-position: 0px 0px; } - -#iCalAttendees .declined DIV.status-icon -{ background-position: -12px 0px; } - -#iCalAttendees .needs-action DIV.status-icon -{ background-position: -24px 0px; } - -#iCalAttendees .tentative DIV.status-icon -{ background-position: -36px 0px; } - -#iCalAttendees .delegated DIV.status-icon -{ background-position: -48px 0px; } - -#iCalAttendees .attendeeUser, -#iCalAttendees .attendeeUser A -{ font-weight: bold; } - -#delegateEditor -{ padding-left: 5px; } - -#delegatedTo -{ width: 220px; } - -#delegatedTo -{ background-image: url("abcard.png"); - background-repeat: no-repeat; - background-position: 4px center; - padding: 2px 2px 2px 24px; - width: 220px; } - -DIV#iCalendarToolbar A.button -{ float: left; - vertical-align: middle;} - -DIV#iCalendarToolbar -{ padding: 0; } - -SPAN#delegateEditor -{ line-height: 23px; - vertical-align: middle; } - -INPUT#delegatedTo -{ float: left; } - -SPAN.floatLeft -{ float: left; - padding: 0 5px; } - -A#iCalendarDeleteFromCalendar -{ float: left; } - -A#iCalendarAddToCalendar -{ border-left: 2px solid #E6E7E6; - margin-left: 5px;} \ No newline at end of file diff --git a/UI/WebServerResources/MailerUI.js b/UI/WebServerResources/MailerUI.js deleted file mode 100644 index c0b319b14..000000000 --- a/UI/WebServerResources/MailerUI.js +++ /dev/null @@ -1,3131 +0,0 @@ -/* -*- Mode: js2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -/* JavaScript for SOGoMail */ -var accounts = []; -var mailboxTree; - -var Mailer = { - defaultWindowTitle: null, - currentMailbox: null, - currentMailboxType: "", - currentMessages: {}, - unseenCountMailboxes: [], - maxCachedMessages: 20, - cachedMessages: new Array(), - foldersStateTimer: false, - popups: new Array(), - - dataTable: null, - dataSources: new Hash(), - - drops: new Array(), - - columnsOrder: null, - sortByThread: false -}; - -var usersRightsWindowHeight = 335; -var usersRightsWindowWidth = 400; - -var pageContent = $("pageContent"); - -var deleteMessageRequestCount = 0; - -var refreshViewCheckTimer; - -// Variables for feature threadsCollapsing -var displayThreadElement = false; -var cachedThreadsCollapsed = []; - -// Variables for feature threadsCollapsing -var displayThreadElement = false; -var cachedThreadsCollapsed = UserSettings.Mail.threadsCollapsed; - -/* We need to override this method since it is adapted to GCS-based folder - references, which we do not use here */ -function URLForFolderID(folderID, application) { - if (application) - application = UserFolderURL + application + "/"; - else - application = ApplicationBaseURL; - - var url = application + encodeURI(folderID); - - if (url[url.length-1] == '/') - url = url.substr(0, url.length-1); - - return url; -} - -/* mail list */ - -function openMessageWindow(msguid, url) { - var wId = ''; - if (msguid) { - wId += "SOGo_msg" + Mailer.currentMailbox + "/" + msguid; - mailListToggleMessagesRead($("row_" + msguid), true); - } - var msgWin = openMailComposeWindow(url, wId); - - msgWin.focus(); - Mailer.popups.push(msgWin); - - return false; -} - -function onMessageDoubleClick(event) { - var action; - - if (Mailer.currentMailboxType == "draft") - action = "edit"; - else - action = "popupview"; - - return openMessageWindowsForSelection(action, true); -} - -function toggleMailSelect(sender) { - var row; - row = $(sender.name); - row.className = sender.checked ? "tableview_selected" : "tableview"; -} - -function openAddressbook(sender) { - var urlstr; - - urlstr = ApplicationBaseURL + "../Contacts/?popup=YES"; - var w = window.open(urlstr, "Addressbook", - "width=640,height=400,resizable=1,scrollbars=1,toolbar=0," - + "location=no,directories=0,status=0,menubar=0,copyhistory=0"); - w.focus(); - - return false; -} - -function onMenuSharing(event) { - var folderID = document.menuTarget.getAttribute("dataname"); - var type = document.menuTarget.getAttribute("datatype"); - - if (type == "additional") - showAlertDialog(clabels["The user rights cannot be" - + " edited for this object!"]); - else { - var urlstr = URLForFolderID(folderID) + "/acls"; - openAclWindow(urlstr); - } -} - -/* mail list DOM changes */ - -/* Update the messages list when flagging/unflagging a message. - * No AJAX is triggered here. */ -function flagMailInWindow (win, msguid, flagged) { - var row = win.$("row_" + msguid); - - if (row) { - var col = row.down("TD.messageFlagColumn"); - var img = col.down("img"); - if (flagged) { - img.setAttribute("src", ResourcesURL + "/flag.png"); - img.addClassName("messageIsFlagged"); - } - else { - img.setAttribute("src", ResourcesURL + "/dot.png"); - img.removeClassName ("messageIsFlagged"); - } - } -} - -/* Update the messages list when setting the unread/read flag of a message. - * No AJAX is triggered here. See mailListToggleMessagesRead */ -function markMailInWindow(win, msguid, markread) { - var row = win.$("row_" + msguid); - var unseenCount = 0; - - if (row) { - if (markread) { - if (row.hasClassName("mailer_unreadmail")) { - row.removeClassName("mailer_unreadmail"); - var img = win.$("readdiv_" + msguid); - if (img) { - img.setAttribute("src", ResourcesURL + "/dot.png"); - var title = img.getAttribute("title-markunread"); - if (title) - img.setAttribute("title", title); - } - else { - log ("No IMG found for " + msguid); - } - unseenCount = -1; - } - } - else { - if (!row.hasClassName("mailer_unreadmail")) { - row.addClassName("mailer_unreadmail"); - var img = win.$("readdiv_" + msguid); - if (img) { - img.setAttribute("src", ResourcesURL + "/unread.png"); - var title = img.getAttribute("title-markread"); - if (title) - img.setAttribute("title", title); - } - else { - log ("No IMG found for message " + msguid); - } - unseenCount = 1; - } - } - - if (unseenCount != 0) { - var node = mailboxTree.getMailboxNode(Mailer.currentMailbox); - if (node) { - updateUnseenCount(node, unseenCount, true); - } - } - } - else { - log ("No row found for message " + msguid); - } - - return (unseenCount != 0); -} - -/** - * This is called by UIxMailView with window.opener. - */ -function markMailReadInWindow(win, msguid) { - return markMailInWindow(win, msguid, true); -} - -/* mail list reply */ - -function openMessageWindowsForSelection(action, firstOnly) { - if ($(document.body).hasClassName("popup")) { - var url = window.location.href; - var parts = url.split("/"); - parts[parts.length-1] = action; - window.name += "_" + action; - window.location.href = parts.join("/"); - } - else { - var messageList = $("messageListBody"); - var rowsId = messageList.getSelectedRowsId(); - if (rowsId.length > 0) { - for (var i = 0; i < rowsId.length; i++) { - openMessageWindow(rowsId[i].substr(4), - ApplicationBaseURL + encodeURI(Mailer.currentMailbox) - + "/" + rowsId[i].substr(4) - + "/" + action); - if (firstOnly) - break; - } - } else { - showAlertDialog(_("Please select a message.")); - } - } - - return false; -} - - -function mailListToggleMessageThread(row, cell) { - var show = row.hasClassName('closedThread'); - var msguid = row.id.split("_")[1]; - var action = "markMessageCollapse"; - $(cell).down('img').remove(); - if (show) { - row.removeClassName('closedThread'); - row.addClassName('openedThread'); - action = "markMessageUncollapse"; - var img = createElement("img", null, null, { src: ResourcesURL + '/arrow-down.png' }); - cell.insertBefore(img, cell.firstChild); - } - else { - row.removeClassName('openedThread'); - row.addClassName('closedThread'); - var img = createElement("img", null, null, { src: ResourcesURL + '/arrow-right.png' }); - cell.insertBefore(img, cell.firstChild); - } - while ((row = row.next()) && row.hasClassName('thread')) { - if (show) - row.show(); - else - row.hide(); - } - - // Update the dictionary of the collapsed threads - var mailbox = Mailer.currentMailbox; - var url = ApplicationBaseURL + encodeURI(mailbox) + "/" + msguid + "/" + action; - var callbackData = { "currentMailbox": Mailer.currentMailbox, "msguid": msguid, "action": action}; - var content = {"currentMailbox": Mailer.currentMailbox, "msguid": msguid}; - - triggerAjaxRequest(url, mailListToggleMessageCollapseCallback, callbackData, Object.toJSON(content)); -} - -function mailListToggleMessageCollapseCallback(http) { - var data = http.callbackData; - if (isHttpStatus204(http.status)) - triggerAjaxRequest(UserFolderURL + "/preferences/jsonSettings", refreshUserSettingsCallback); - else { - log("Message Collapse Failed (" + http.status + "): " + http.statusText); - } -} - - -/* Triggered when clicking on the read/unread dot of a message row or - * through the contextual menu. */ -function mailListToggleMessagesRead(row, force_mark_as_read) { - var selectedRowsId = []; - if (row) { - selectedRowsId = [row.id]; - } - else { - var messageList = $("messageListBody"); - if (messageList) { - var selectedRows = messageList.getSelectedRows(); - row = selectedRows[0]; - selectedRowsId = messageList.getSelectedRowsId(); - } - } - if (selectedRowsId.length > 0) { - var action; - var markread; - if (row.hasClassName("mailer_unreadmail")) { - action = 'markMessageRead'; - markread = true; - } - else if (!force_mark_as_read) { - action = 'markMessageUnread'; - markread = false; - } - else { - return; - } - - for (var i = 0; i < selectedRowsId.length; i++) { - var msguid = selectedRowsId[i].split('_')[1]; - // Assume ajax request will succeed and change message flag in table - markMailInWindow(window, msguid, markread); - - var url = ApplicationBaseURL + encodeURI(Mailer.currentMailbox) + "/" - + msguid + "/" + action; - - var data = { "msguid": msguid }; - triggerAjaxRequest(url, mailListMarkMessageCallback, data); - } - } -} - -/* - function mailListMarkMessage(event) { - mailListToggleMessagesRead(); - - preventDefault(event); - - return false; - } - */ - -function mailListMarkMessageCallback(http) { - var data = http.callbackData; - if (isHttpStatus204(http.status)) { - Mailer.dataTable.invalidate(data["msguid"], true); - } - else { - log("Message Mark Failed (" + http.status + "): " + http.statusText); - Mailer.dataTable.invalidate(data["msguid"], false); - } -} - -function mailListFlagMessageToggle(e) { - mailListToggleMessagesFlagged(); -} - -/* Triggered when clicking on the flag/unflag dot of a message row */ -function mailListToggleMessagesFlagged(row) { - var selectedRowsId = []; - if (row) { - selectedRowsId = [row.id]; - } - else { - var messageList = $("messageListBody"); - if (messageList) { - var selectedRows = messageList.getSelectedRows(); - row = selectedRows[0]; - selectedRowsId = messageList.getSelectedRowsId(); - } - } - if (selectedRowsId.length > 0) { - var td = row.down("td.messageFlagColumn"); - var img = td.childElements().first(); - - var action = "markMessageFlagged"; - var flagged = true; - if (img.hasClassName("messageIsFlagged")) { - action = "markMessageUnflagged"; - flagged = false; - } - - for (var i = 0; i < selectedRowsId.length; i++) { - var msguid = selectedRowsId[i].split("_")[1]; - flagMailInWindow(window, msguid, flagged); - - var url = ApplicationBaseURL + encodeURI(Mailer.currentMailbox) + "/" - + msguid + "/" + action; - var data = { "msguid": msguid }; - - triggerAjaxRequest(url, mailListToggleMessageFlaggedCallback, data); - } - } -} - -function mailListToggleMessageFlaggedCallback(http) { - var data = http.callbackData; - if (!isHttpStatus204(http.status)) { - log("Message Mark Failed (" + http.status + "): " + http.statusText); - } - Mailer.dataTable.invalidate(data["msguid"], true); -} - -function onUnload(event) { - var url = ApplicationBaseURL + encodeURI(Mailer.currentMailbox) + "/expunge"; - - new Ajax.Request(url, { - asynchronous: false, - method: 'get', - onFailure: function(transport) { - log("Can't expunge current folder: " + transport.status); - } - }); - - return true; -} - -function onDocumentKeydown(event) { - var target = Event.element(event); - if (target.tagName != "INPUT") { - var keyCode = event.keyCode; - if (!keyCode) { - keyCode = event.charCode; - if (keyCode == "a".charCodeAt(0)) { - keyCode = "A".charCodeAt(0); - } - } - if (keyCode == Event.KEY_DELETE || - keyCode == Event.KEY_BACKSPACE) { - deleteSelectedMessages(); - Event.stop(event); - } - else if (keyCode == Event.KEY_DOWN || - keyCode == Event.KEY_UP) { - if (Mailer.currentMessages[Mailer.currentMailbox]) { - var row = $("row_" + Mailer.currentMessages[Mailer.currentMailbox]); - var nextRow; - if (keyCode == Event.KEY_DOWN) - nextRow = row.next("tr"); - else - nextRow = row.previous("tr"); - if (nextRow && nextRow.id != 'rowTop' && nextRow.id != 'rowBottom') { - Mailer.currentMessages[Mailer.currentMailbox] = nextRow.getAttribute("id").substr(4); - row.parentNode.deselectAll(); - - // Adjust the scollbar - var viewPort = $("mailboxList"); - var divDimensions = viewPort.getDimensions(); - var centerOffset = divDimensions.height/2; - var rowScrollOffset = nextRow.cumulativeScrollOffset(); - var divBottom = divDimensions.height + rowScrollOffset.top; - var rowBottom = nextRow.offsetTop + nextRow.getHeight(); - - if (divBottom < rowBottom) - viewPort.scrollTop += rowBottom - divBottom + centerOffset; - else if (viewPort.scrollTop > nextRow.offsetTop) - viewPort.scrollTop -= rowScrollOffset.top - nextRow.offsetTop + centerOffset; - - // Select and load the next message - nextRow.selectElement(); - loadMessage(Mailer.currentMessages[Mailer.currentMailbox]); - // from generic.js - lastClickedRow = nextRow.rowIndex; - lastClickedRowId = nextRow.id; - } - Event.stop(event); - } - } - else if (((isMac() && event.metaKey == 1) || (!isMac() && event.ctrlKey == 1)) - && keyCode == "A".charCodeAt(0)) { // Ctrl-A - $("messageListBody").down("TBODY").selectAll(); - Event.stop(event); - } - } -} - -/* Search mail, call the template and open inside a dialog windoÆ’w */ -function onSearchMail(event) { - Event.stop(event); - var element = Event.findElement(event); - if (element.disabled == false || element.disabled == undefined) { - element.disabled = true; - element.writeAttribute("id", "toolbarSearchButton"); - if ($("searchMailView")) { - $("searchMailView").style.display = "block"; - $("bgDialogDiv").style.display = "block"; - initSearchMailView(); - } - else { - var urlstr = ApplicationBaseURL + "/search"; - - // Return the template for the searchMail feature - triggerAjaxRequest(urlstr, displaySearchMailCallback); - } - } - return false; -} - -function displaySearchMailCallback(http) { - if (http.readyState == 4 && http.status == 200) { - var fields = createElement("div", null); // (tagName, id, classes, attributes, htmlAttributes, parentNode) - var title = _("Search multiple mailboxes"); - var id = _("searchMailView"); - fields.innerHTML = http.responseText; - - var dialog = createDialog(id, title, null, fields, "searchMail"); // (id, title, legend, content, positionClass) - document.body.appendChild(dialog); - - if (Prototype.Browser.IE) - jQuery('#bgDialogDiv').css('opacity', 0.4); - jQuery(dialog).fadeIn('fast'); - initSearchMailView(); - } -} - -/* bulk delete of messages */ - -function deleteSelectedMessages(sender) { - if (Mailer.currentMailboxType == "account" || Mailer.currentMailboxType == "additional") - return false; - - var messageList = $("messageListBody").down("TBODY"); - var messageContent = $("messageContent"); - var rowIds = messageList.getSelectedNodesId(); - var uids = new Array(); // message IDs - var paths = new Array(); // row IDs - var unseenCount = 0; - var refreshFolder = false; - - if (rowIds && rowIds.length > 0) { - messageList.deselectAll(); - for (var i = 0; i < rowIds.length; i++) { - if (unseenCount < 1) { - var rows = messageList.select('#' + rowIds[i]); - if (rows.length > 0) { - var row = rows.first(); - row.hide(); - if (row.hasClassName("mailer_unreadmail")) - unseenCount--; - } - else { - unseenCount = 1; - } - } - var uid = rowIds[i].substr(4); // drop "row_" - var path = Mailer.currentMailbox + "/" + uid; - uids.push(uid); - paths.push(path); - deleteMessageRequestCount++; - - deleteCachedMessage(path); - if (Mailer.currentMessages[Mailer.currentMailbox] == uid) { - if (messageContent) messageContent.innerHTML = ''; - Mailer.currentMessages[Mailer.currentMailbox] = null; - } - - if (i+1 == rowIds.length) { - // Select next message - var row = $("row_" + uid); - var nextRow = false; - if (row) { - //row.addClassName("deleted"); // when we'll offer "mark as deleted" - nextRow = row.next("tr"); - if (!nextRow.id.startsWith('row_')) - nextRow = row.previous("tr"); - else if (row.hasClassName('openedThread') || row.hasClassName('closedThread')) { - // Thread root deleted -- must refresh folder - refreshFolder = true; - // New row will be the new thread root -- mark it as first mail of the thread - var nextUid = nextRow.id.substr(4); - var nextIndex = Mailer.dataTable.dataSource.indexOf(nextUid); - Mailer.dataTable.dataSource.uids[nextIndex][2] = 1; // mark it as "first" - Mailer.dataTable.dataSource.invalidate(nextUid); // next refresh will reload headers for row - } - if (nextRow.id.startsWith('row_')) { - Mailer.currentMessages[Mailer.currentMailbox] = nextRow.id.substr(4); - nextRow.selectElement(); - if (loadMessage(Mailer.currentMessages[Mailer.currentMailbox]) && !refreshFolder) { - // Seen state has changed - Mailer.dataTable.dataSource.invalidate(Mailer.currentMessages[Mailer.currentMailbox]); - refreshFolder = true; - } - } - } - else if (messageContent) { - messageContent.innerHTML = ''; - } - Mailer.dataTable.remove(uid); - if (nextRow) { - // from generic.js - lastClickedRow = nextRow.rowIndex; - lastClickedRowId = nextRow.id; - } - if (Mailer.currentMailboxType != "trash") - deleteCachedMailboxByType("trash"); - } - else { - Mailer.dataTable.remove(uid); - } - } - updateMessageListCounter(0 - rowIds.length, true); - if (unseenCount < 0) { - var node = mailboxTree.getMailboxNode(Mailer.currentMailbox); - if (node) { - updateUnseenCount(node, unseenCount, true); - } - } - var url = ApplicationBaseURL + encodeURI(Mailer.currentMailbox) + "/batchDelete"; - var parameters = "uid=" + uids.join(","); - var data = { "id": uids, "mailbox": Mailer.currentMailbox, "path": paths, "refreshUnseenCount": (unseenCount > 0), "refreshFolder": refreshFolder }; - triggerAjaxRequest(url, deleteSelectedMessagesCallback, data, parameters, - { "Content-type": "application/x-www-form-urlencoded" }); - } - if (uids.length == 0) - showAlertDialog(_("Please select a message.")); - - return false; -} - -function deleteSelectedMessagesCallback(http) { - if (isHttpStatus204(http.status) || http.status == 200) { - var data = http.callbackData; - if (http.status == 200) { - // The answer contains quota information - var rdata = http.responseText.evalJSON(true); - if (rdata.quotas && data["mailbox"].startsWith('/0/')) - updateQuotas(rdata.quotas); - } - if (data["refreshUnseenCount"]) - // TODO : the unseen count should be returned when calling the batchDelete remote action, - // in order to avoid this extra AJAX call. - getUnseenCountForFolder(data["mailbox"]); - if (data["refreshFolder"]) - Mailer.dataTable.refresh(); - } - else if (!http.callbackData["withoutTrash"]) { - showConfirmDialog(_("Warning"), - _("The messages could not be moved to the trash folder. Would you like to delete them immediately?"), - deleteMessagesWithoutTrash.bind(document, http.callbackData), - function() { refreshCurrentFolder(); disposeDialog(); }); - } - else { - var html = new Element('div').update(http.responseText); - log ("Messages deletion failed (" + http.status + ") : "); - log (html.down('p').innerHTML); - showAlertDialog(_("Operation failed")); - refreshCurrentFolder(); - } -} - -function deleteMessagesWithoutTrash(data) { - var url = ApplicationBaseURL + encodeURI(data["mailbox"]) + "/batchDelete"; - var parameters = "uid=" + data["id"].join(",") + '&withoutTrash=1'; - data["withoutTrash"] = true; - triggerAjaxRequest(url, deleteSelectedMessagesCallback, data, parameters, - { "Content-type": "application/x-www-form-urlencoded" }); - disposeDialog(); -} - -function onMenuDeleteMessage(event) { - deleteSelectedMessages(); - preventDefault(event); -} - -/** - * The following two functions are called from UIxMailPopupView - * with window.opener. - */ -function deleteMessageWithDelay(url, id, mailbox, messageId) { - var row = $("row_" + id); - if (row) row.hide(); - setTimeout("deleteMessage('" + - url + "', '" + - id + "', '" + - mailbox + "', '" + - messageId + "')", - 50); -} - -function deleteMessage(url, id, mailbox, messageId) { - var data = { "id": new Array(id), "mailbox": mailbox, "path": new Array(messageId) }; - var parameters = "uid=" + id; - deleteMessageRequestCount++; - triggerAjaxRequest(url, deleteSelectedMessagesCallback, data, parameters, - { "Content-type": "application/x-www-form-urlencoded" }); -} - -function onPrintCurrentMessage(event) { - var messageList = $("messageListBody").down("TBODY"); - var rows = messageList.getSelectedNodesId(); - if (rows.length == 0) { - showAlertDialog(_("Please select a message to print.")); - } - else if (rows.length > 1) { - showAlertDialog(_("Please select only one message to print.")); - } - else - window.print(); - - preventDefault(event); -} - -function onMailboxTreeItemClick(event) { - var topNode = $("mailboxTree"); - var mailbox = this.parentNode.getAttribute("dataname"); - if (topNode.selectedEntry) - topNode.selectedEntry.deselect(); - this.selectElement(); - topNode.selectedEntry = this; - - search = {}; - $$('[name="search"]').first().value = ""; - initCriteria(); - - Mailer.currentMailboxType = this.parentNode.getAttribute("datatype"); - if (Mailer.currentMailboxType == "account" || Mailer.currentMailboxType == "additional") { - Mailer.currentMailbox = mailbox; - var messageContent = $("messageContent"); - if (messageContent) messageContent.innerHTML = ''; - $("messageCountHeader").childNodes[0].innerHTML = ' '; - Mailer.dataTable._emptyTable(); - updateWindowTitle(); - } - else { - var datatype = this.parentNode.getAttribute("datatype"); - if (datatype == 'draft' || datatype == 'sent') - toggleAddressColumn("from", "to"); - else - toggleAddressColumn("to", "from"); - - updateWindowTitle(this.childNodesWithTag("span")[0]); - openMailbox(mailbox); - } - - Event.stop(event); -} - -function toggleAddressColumn(search, replace) { - var header = $(search + "Header"); - if (header) { - header.id = replace + "Header"; - header.update(_(replace.capitalize())); - var i = Mailer.columnsOrder.indexOf(search.capitalize()); - if (i >= 0) - Mailer.columnsOrder[i] = replace.capitalize(); - } - if (sorting["attribute"] == search) - sorting["attribute"] = replace; -} - -function onMailboxMenuMove(event) { - var targetMailbox; - var messageList = $("messageListBody").down("TBODY"); - var rowIds = messageList.getSelectedNodesId(); - var uids = new Array(); // message IDs - var paths = new Array(); // row IDs - - Mailer.currentMessages[Mailer.currentMailbox] = null; - $('messageContent').update(); - - if (this.tagName == 'LI') // from contextual menu - targetMailbox = this.mailbox.fullName(); - else // from DnD - targetMailbox = this.readAttribute("dataname"); - - for (var i = 0; i < rowIds.length; i++) { - var uid = rowIds[i].substr(4); - var path = Mailer.currentMailbox + "/" + uid; - var rows = messageList.select('#' + rowIds[i]); - if (rows.length > 0) - rows.first().hide(); - uids.push(uid); - paths.push(path); - // Remove references to closed popups - for (var j = Mailer.popups.length - 1; j > -1; j--) - if (!Mailer.popups[j].open || Mailer.popups[j].closed) - Mailer.popups.splice(j,1); - // Close message popup if opened - for (var j = 0; j < Mailer.popups.length; j++) - if (Mailer.popups[j].messageUID == path) { - Mailer.popups[j].close(); - Mailer.popups.splice(j,1); - break; - } - } - - // Remove cache of target data source - deleteCachedMailbox(targetMailbox); - - var url = ApplicationBaseURL + encodeURI(Mailer.currentMailbox) + "/moveMessages"; - var parameters = "uid=" + uids.join(",") + "&folder=" + encodeURIComponent(targetMailbox); - var data = { "id": uids, "mailbox": Mailer.currentMailbox, "path": paths, "folder": targetMailbox, "refresh": true }; - triggerAjaxRequest(url, folderRefreshCallback, data, parameters, - { "Content-type": "application/x-www-form-urlencoded" }); - - return false; -} - -function onMailboxMenuCopy(event) { - var messageList = $("messageListBody").down("TBODY"); - var rowIds = messageList.getSelectedNodesId(); - var uids = new Array(); // message IDs - var paths = new Array(); // row IDs - - var targetMailbox; - if (this.tagName == 'LI') // from contextual menu - targetMailbox = this.mailbox.fullName(); - else // from DnD - targetMailbox = this.readAttribute("dataname"); - for (var i = 0; i < rowIds.length; i++) { - var uid = rowIds[i].substr(4); - var path = Mailer.currentMailbox + "/" + uid; - uids.push(uid); - paths.push(path); - } - - // Remove cache of target data source - deleteCachedMailbox(targetMailbox); - - var url = ApplicationBaseURL + encodeURI(Mailer.currentMailbox) + "/copyMessages"; - var parameters = "uid=" + uids.join(",") + "&folder=" + encodeURIComponent(targetMailbox); - var data = { "id": uids, "mailbox": Mailer.currentMailbox, "path": paths, "folder": targetMailbox, "refresh": false }; - triggerAjaxRequest(url, folderRefreshCallback, data, parameters, - { "Content-type": "application/x-www-form-urlencoded" }); - - return false; -} - -function refreshMailbox() { - var topWindow = getTopWindow(); - if (topWindow) { - topWindow.refreshCurrentFolder(); - topWindow.refreshUnseenCounts(); - } - - return false; -} - -function onComposeMessage() { - var topWindow = getTopWindow(); - if (topWindow) - topWindow.composeNewMessage(); - - return false; -} - -function composeNewMessage() { - var account; - if (Mailer.currentMailbox) - account = Mailer.currentMailbox.split("/")[1]; - else if (mailAccounts.length) - account = "0"; - else - account = null; - if (account) { - var url = ApplicationBaseURL + encodeURI("/" + account) + "/compose"; - openMailComposeWindow(url); - } -} - -function openMailbox(mailbox, reload) { - if (mailbox != Mailer.currentMailbox || reload) { - var url = ApplicationBaseURL + encodeURI(mailbox.unescapeHTML()); - var urlParams = {filters: [], sortingAttributes: {}}; - - if (!reload) { - var messageContent = $("messageContent"); - if (messageContent) messageContent.innerHTML = ''; - $("messageCountHeader").childNodes[0].innerHTML = ' '; - lastClickedRow = -1; // from generic.js - } - - var searchValue = search["mail"]["value"]; - if (searchValue && searchValue.length > 0) { - var searchCriteria = []; - if (search["mail"]["criteria"] == "subject") - searchCriteria.push("subject"); - else if (search["mail"]["criteria"] == "sender") - searchCriteria.push("from"); - else if (search["mail"]["criteria"] == "subject_or_sender") - searchCriteria.push("subject", "from"); - else if (search["mail"]["criteria"] == "to_or_cc") - searchCriteria.push("to", "cc"); - else if (search["mail"]["criteria"] == "entire_message") - searchCriteria.push("body"); - - var filters = []; - for (i = 0; i < searchCriteria.length; i++) - filters.push({"searchBy": searchCriteria[i], "searchArgument": "doesContain", "searchInput": searchValue}); - - urlParams.filters = filters; - } - var sortAttribute = sorting["attribute"]; - if (sortAttribute && sortAttribute.length > 0) { - var sortingAttributes = {"sort":sorting["attribute"], "asc":sorting["ascending"], "match":"OR"}; - urlParams.sortingAttributes = sortingAttributes; - - var sortHeader = $(sorting["attribute"] + "Header"); - if (sortHeader) { - var sortImages = sortHeader.up('THEAD').select(".sortImage"); - $(sortImages).each(function(item) { - item.remove(); - }); - var sortImage = createElement("img", "messageSortImage", "sortImage"); - sortHeader.insertBefore(sortImage, sortHeader.firstChild); - if (sorting["ascending"]) - sortImage.src = ResourcesURL + "/arrow-up.png"; - else - sortImage.src = ResourcesURL + "/arrow-down.png"; - } - } - - var messageList = $("messageListBody").down('TBODY'); - var key = mailbox; - - if (reload) { - // Don't change data source, only query UIDs from server and refresh - // the view. Cases that end up here: - // - performed a search - // - clicked on Get Mail button - urlParams.sortingAttributes.no_headers= "1"; - var content = Object.toJSON(urlParams); - Mailer.dataTable.load(content); - Mailer.dataTable.refresh(); - } - else { - var dataSource = Mailer.dataSources.get(key); - if (!dataSource) { - // Data source is not cached - dataSource = new SOGoMailDataSource(Mailer.dataTable, url); - if (inboxData) { - // Use UIDs and headers from the WOX template; this only - // happens once and only with the inbox - dataSource.init(inboxData['uids'], inboxData['threaded'], inboxData['headers'], inboxData['quotas']); - inboxData = null; // invalidate this initial lookup - } - else { - // Fetch UIDs and headers from server - var content = Object.toJSON(urlParams); - dataSource.load(content); - } - // Cache data source - Mailer.dataSources.set(key, dataSource); - // Update unseen count - getUnseenCountForFolder(mailbox); - } - else { - // Data source is cached, query only UIDs from server - urlParams.sortingAttributes.no_headers= "1"; - var content = Object.toJSON(urlParams); - dataSource.load(content); - } - // Associate data source with data table and render the view - Mailer.dataTable.setSource(dataSource); - Mailer.dataTable.render(); - } - - Mailer.currentMailbox = mailbox; - - if (Mailer.unseenCountMailboxes.indexOf(mailbox) == -1) { - Mailer.unseenCountMailboxes.push(mailbox); - } - - // Restore previous selection - var currentMessage = Mailer.currentMessages[mailbox]; - if (currentMessage) { - if (!reload) { - loadMessage(currentMessage); - } - } - } -} - -/* - * Called from SOGoDataTable.render() - */ - -function messageListCallback(row, data, isNew) { - var currentMessages = []; - if (!Object.isArray(document.menuTarget)) { - // Menu called from one selection in message list view - currentMessages.push(Mailer.currentMessages[Mailer.currentMailbox]); - } - else { - // Menu called from multiple selection in messages list view - var rows = $(document.menuTarget); - for (var i = 0; i < rows.length; i++) { - var _row = $(rows[i]); - if (_row) { - currentMessages.push(rows[i].substr(4)); - } - } - } - row.id = data['rowID']; - row.writeAttribute('labels', (data['labels']?data['labels']:"")); - row.className = data['rowClasses']; - row.show(); // make sure the row is visible - - // Restore previous selection - if (currentMessages.indexOf(String(data['uid'])) != -1) - row.addClassName('_selected'); - - if (data['Thread']) { - if (cachedThreadsCollapsed) { - var mailbox = Mailer.currentMailbox; - var collapsedList = cachedThreadsCollapsed[mailbox]; - if (collapsedList != undefined && collapsedList.indexOf(row.id.split("_")[1]) != -1) { - row.addClassName('closedThread'); - displayThreadElement = true; - } - else { - row.addClassName('openedThread'); - } - } - } - - else if (data['ThreadLevel'] > 0) { - if (data['ThreadLevel'] > 10) data['ThreadLevel'] = 10; - row.addClassName('thread'); - row.addClassName('thread' + data['ThreadLevel']); - - if (displayThreadElement) - row.hide(); - } - - else - displayThreadElement = false; - - var cells = row.childElements(); - for (var j = 0; j < cells.length; j++) { - var cell = cells[j]; - var cellType = Mailer.columnsOrder[j]; - if (data[cellType]) cell.innerHTML = data[cellType]; - else cell.innerHTML = ' '; - } -} - -function refreshUnseenCounts() { - for (var i = 0; i < Mailer.unseenCountMailboxes.length; i++) { - var mailboxPath = Mailer.unseenCountMailboxes[i]; - var node = mailboxTree.getMailboxNode(mailboxPath); - if (node) { - getUnseenCountForFolder(mailboxPath); - } - } -} - -function getUnseenCountForFolder(mailbox) { - var url = URLForFolderID(mailbox) + '/unseenCount'; - triggerAjaxRequest(url, unseenCountCallback, mailbox); -} - -function unseenCountCallback(http) { - var div = $('mailboxContent'); - var table = $('messageList'); - - if (http.status == 200) { - document.unseenCountAjaxRequest = null; - var data = http.responseText.evalJSON(true); - var node = mailboxTree.getMailboxNode(http.callbackData); - if (node) - updateUnseenCount(node, data.unseen, false); - } -} - -function updateUnseenCount(node, count, isDelta) { - var unseenSpan = null; - var counterSpan = null; - - var spans = node.select("SPAN.unseenCount"); - if (spans.length > 0) { - counterSpan = spans[0]; - unseenSpan = counterSpan.parentNode; - } - if (counterSpan) { - if (typeof(count) == "undefined" || isDelta) { - if (typeof(count) == "undefined") { - count = 0; - } - var content = ""; - for (var i = 0; i < counterSpan.childNodes.length; i++) { - var cNode = counterSpan.childNodes[i]; - if (cNode.nodeType == 3) { - content += cNode.nodeValue; - } - } - var digits = ""; - for (var i = 0; i < content.length; i++) { - var code = content.charCodeAt(i); - if (code > 47 && code < 58) { - digits += content.charAt(i); - } - } - count += parseInt(digits); - } - while (counterSpan.firstChild) { - counterSpan.removeChild(counterSpan.firstChild); - } - counterSpan.appendChild(document.createTextNode(" (" + count + ")")); - if (count > 0) { - counterSpan.removeClassName("hidden"); - unseenSpan.addClassName("unseen"); - } - else { - counterSpan.addClassName("hidden"); - unseenSpan.removeClassName("unseen"); - } - if (node.getAttribute("dataname") == Mailer.currentMailbox) - updateWindowTitle(unseenSpan); - } -} - -function updateMessageListCounter(count, isDelta) { - var cell = $("messageCountHeader").down(); - - if (isDelta) { - var value = parseInt(cell.innerHTML); - count += value; - } - - if (count > 0) - cell.update(count + " " + _("messages")); - else - cell.update(_("No message")); -} - -function updateWindowTitle(span) { - if (!Mailer.defaultWindowTitle) - Mailer.defaultWindowTitle = document.title || "SOGo"; - else if (!span) - document.title = Mailer.defaultWindowTitle; - if (span) { - var title = Mailer.defaultWindowTitle + " - "; - if (span.hasClassName("unseen")) { - var subtitle = span.innerHTML.stripTags(); - var idx = subtitle.lastIndexOf("("); - var len = subtitle.length-idx-2; - title += "(" + subtitle.substr(idx+1, len) + ") " + subtitle.substring(0, idx); - } - else - title += span.childNodes[0].nodeValue; - document.title = title; - } -} - -/* Function is called when the event datatable:rendered is fired from SOGoDataTable. */ -function onMessageListRender(event) { - // Restore previous selection - var currentMessage = Mailer.currentMessages[Mailer.currentMailbox]; - if (currentMessage) { - var rows = this.select("TR#row_" + currentMessage); - if (rows.length == 1) - rows[0].selectElement(); - } - // Update message counter in folder name - updateMessageListCounter(event.memo, false); -} - -function onMessageContextMenu(event) { - var target = Event.element(event); - var menu = $('messageListMenu'); - var topNode = $('messageListBody'); - var selectedNodes = topNode.getSelectedRowsId(); - var row = target.up('TR'); - - if (selectedNodes.indexOf(row.id) < 0) { - if (target.tagName != 'TD') - target = target.up('TD'); - onRowClick(event, target); - selectedNodes = topNode.getSelectedRowsId(); - } - - if (selectedNodes.length > 1) - popupMenu(event, "messagesListMenu", selectedNodes); - else if (selectedNodes.length == 1) - popupMenu(event, "messageListMenu", row); -} - -function onFolderMenuClick(event) { - var onhide, menuName; - - var menutype = this.parentNode.getAttribute("datatype"); - if (menutype) { - if (menutype == "inbox") { - menuName = "inboxIconMenu"; - } else if (menutype == "account") { - menuName = "accountIconMenu"; - } else if (menutype == "trash") { - menuName = "trashIconMenu"; - } else { - menuName = "mailboxIconMenu"; - } - } else { - menuName = "mailboxIconMenu"; - } - - var menu = $(menuName); - menu.on("contextmenu:hide", onFolderMenuHide); - popupMenu(event, menuName, this.parentNode); - - var topNode = $("mailboxTree"); - if (topNode.selectedEntry) - topNode.selectedEntry.deselect(); - if (topNode.menuSelectedEntry) - topNode.menuSelectedEntry.deselect(); - topNode.menuSelectedEntry = this; - this.selectElement(); - - preventDefault(event); -} - -function onFolderMenuHide(event) { - var topNode = $("mailboxTree"); - - if (topNode.menuSelectedEntry) { - topNode.menuSelectedEntry.deselect(); - topNode.menuSelectedEntry = null; - } - if (topNode.selectedEntry) - topNode.selectedEntry.selectElement(); - - this.stopObserving("contextmenu:hide", onFolderMenuHide); -} - -function deleteCachedMailboxByType(type) { - var nodes = $("mailboxTree").select("DIV[datatype=" + type + "]"); - if (nodes.length == 1) - deleteCachedMailbox(nodes[0].readAttribute("dataname")); - - if (Mailer.currentMailboxType == type) - refreshCurrentFolder(); -} - -function deleteCachedMailbox(mailboxPath) { - var keys = Mailer.dataSources.keys(); - for (var i = 0; i < keys.length; i++) { - if (keys[i] == mailboxPath || keys[i].startsWith(mailboxPath + "?")) - Mailer.dataSources.unset(keys[i]); - } -} - -function deleteCachedMessage(messageId) { - var done = false; - var counter = 0; - - while (counter < Mailer.cachedMessages.length - && !done) - if (Mailer.cachedMessages[counter] - && Mailer.cachedMessages[counter]['idx'] == messageId) { - Mailer.cachedMessages.splice(counter, 1); - done = true; - } - else - counter++; -} - -function getCachedMessage(idx) { - var message = null; - var counter = 0; - - while (counter < Mailer.cachedMessages.length - && message == null) - if (Mailer.cachedMessages[counter] - && Mailer.cachedMessages[counter]['idx'] == Mailer.currentMailbox + '/' + idx) - message = Mailer.cachedMessages[counter]; - else - counter++; - - return message; -} - -function storeCachedMessage(cachedMessage) { - var oldest = -1; - var timeOldest = -1; - var counter = 0; - - if (Mailer.cachedMessages.length < Mailer.maxCachedMessages) - oldest = Mailer.cachedMessages.length; - else { - while (Mailer.cachedMessages[counter]) { - if (oldest == -1 - || Mailer.cachedMessages[counter]['time'] < timeOldest) { - oldest = counter; - timeOldest = Mailer.cachedMessages[counter]['time']; - } - counter++; - } - - if (oldest == -1) - oldest = 0; - } - - Mailer.cachedMessages[oldest] = cachedMessage; -} - -function onMessageSelectionChange(event) { - var t = getTarget(event); - - if (t.tagName == 'IMG') { - t = t.parentNode; - if (t.tagName == 'TD') { - if (t.className == 'messageThreadColumn') { - mailListToggleMessageThread(t.parentNode, t); - } - else if (t.className == 'messageUnreadColumn') { - mailListToggleMessagesRead(t.parentNode); - return false; - } - else if (t.className == 'messageFlagColumn') { - mailListToggleMessagesFlagged(t.parentNode); - return false; - } - } - } - if (t.tagName == 'SPAN') - t = t.parentNode; - - // Update rows selection - onRowClick(event, t); - - var messageContent = $("messageContent"); - var rows = this.getSelectedRowsId(); - if (rows.length == 1) { - var idx = rows[0].substr(4); - if (Mailer.currentMessages[Mailer.currentMailbox] != idx) { - Mailer.currentMessages[Mailer.currentMailbox] = idx; - if (messageContent) loadMessage(idx); - } - } - else if (rows.length > 1 && messageContent) - $('messageContent').innerHTML = ''; - - return true; -} - -function loadMessage(msguid) { - if (document.messageAjaxRequest) { - document.messageAjaxRequest.aborted = true; - document.messageAjaxRequest.abort(); - } - - var div = $('messageContent'); - if (div == null) - // Single-window mode - return false; - - var cachedMessage = getCachedMessage(msguid); - var row = $("row_" + msguid); - var seenStateHasChanged = row && row.hasClassName('mailer_unreadmail'); - if (cachedMessage == null) { - var url = (ApplicationBaseURL + encodeURI(Mailer.currentMailbox) + "/" - + msguid + "/view?noframe=1"); - div.innerHTML = ''; - document.messageAjaxRequest = triggerAjaxRequest(url, - loadMessageCallback, - { 'mailbox': Mailer.currentMailbox, - 'msguid': msguid, - 'seenStateHasChanged': seenStateHasChanged }); - } - else { - div.innerHTML = cachedMessage['text']; - cachedMessage['time'] = (new Date()).getTime(); - document.messageAjaxRequest = null; - configureLinksInMessage(); - resizeMailContent(); - if (seenStateHasChanged) { - // Mark message as read on server - mailListToggleMessagesRead(); - } - } - - configureLoadImagesButton(); - configureSignatureFlagImage(); - - if (UserDefaults["SOGoMailDisplayRemoteInlineImages"] == 'always') - loadRemoteImages(); - - return seenStateHasChanged; -} - -/** - * Hide the "Load Images" button when there's no unsafe content - */ -function configureLoadImagesButton() { - var loadImagesButton = $("loadImagesButton"); - if (typeof(loadImagesButton) == "undefined" || - loadImagesButton == null ) { - return; - } - var content = $("messageContent"); - var unsafeElements = content.select('[unsafe-src], [unsafe-data], [unsafe-classid], [unsafe-background], [unsafe-style]'); - if (unsafeElements.length == 0) { - loadImagesButton.setStyle({ display: 'none' }); - } - else { - content.hiddenElements = unsafeElements; - } -} - -function configureSignatureFlagImage() { - var signedPart = $("signedMessage"); - if (signedPart) { - var supportsSMIME - = parseInt(signedPart.getAttribute("supports-smime")); - - if (supportsSMIME) { - var loadImagesButton = $("loadImagesButton"); - var parentNode = loadImagesButton.parentNode; - - var valid = parseInt(signedPart.getAttribute("valid")); - var flagImage; - - if (valid) - flagImage = "signature-ok.png"; - else - flagImage = "signature-not-ok.png"; - - var error = signedPart.getAttribute("error"); - var newImg = createElement("img", "signedImage", null, null, - { src: ResourcesURL + "/" + flagImage }); - - var msgDiv = $("signatureFlagMessage"); - if (msgDiv && error) { - // First line in a h1, others each in a p - var formattedMessage = ""); - formattedMessage = formattedMessage.replace(/\n/g, "
") + "
"; - msgDiv.innerHTML = "((.*\n)*.*)<\/p>(.*\n)*.*$/, "$2"); - for (var i = 0; i < Mailer.popups.length; i++) { - if (Mailer.popups[i].messageUID == oldMsg) { - // Show the alert in the proper popup window - Mailer.popups[i].alert(_(msg)); - break; - } - } - if (i == Mailer.popups.length) - showAlertDialog(_(msg)); - } - else - showAlertDialog("received code: " + http.status + "\nerror: " + http.responseText); - } -} - -function resizeMailContent() { - var headerTable = document.getElementsByClassName('mailer_fieldtable')[0]; - var contentDiv = document.getElementsByClassName('mailer_mailcontent')[0]; - - contentDiv.setStyle({ 'top': - (Element.getHeight(headerTable) + headerTable.offsetTop) + 'px' }); - - // Show expand buttons if necessary - var spans = $$("TABLE TR.mailer_fieldrow TD.mailer_fieldvalue SPAN"); - spans.each(function(span) { - var row = span.up("TR"); - if (span.getWidth() > row.getWidth()) { - var cell = row.select("TD.mailer_fieldname").first(); - var link = cell.down("img"); - link.show(); - link.observe("click", toggleDisplayHeader); - } - }); -} - -function toggleDisplayHeader(event) { - var row = this.up("TR"); - var span = row.down("SPAN"); - - if (this.hasClassName("collapse")) { - this.writeAttribute("src", ResourcesURL + '/minus.png'); - this.writeAttribute("class", "expand"); - span.writeAttribute("class", "expand"); - } - else { - this.writeAttribute("src", ResourcesURL + '/plus.png'); - this.writeAttribute("class", "collapse"); - span.writeAttribute("class", "collapse"); - } - resizeMailContent(); - - preventDefault(event); - return false; -} - -function onMessageContentMenu(event) { - var element = getTarget(event); - if ((element.tagName == 'A' && element.href.substring(0,7) == "mailto:") - || element.tagName == 'IMG') - // Don't show the default contextual menu; let the click propagate to - // other observers - return true; - popupMenu(event, 'messageContentMenu', this); -} - -function onMessageEditDraft(event) { - Event.stop(event); - return openMessageWindowsForSelection("edit", true); -} - -function onMessageLoadImages(event) { - Event.stop(event); - loadRemoteImages(); -} - -function loadRemoteImages() { - var content = $("messageContent"); - if (content.hiddenElements) { - $(content.hiddenElements).each(function(element) { - ['src', 'data', 'classid', 'background', 'style'].each(function(attr) { - var unsafeAttr = element.readAttribute('unsafe-' + attr); - if (unsafeAttr) { - log ('unsafe ' + attr + ': ' + unsafeAttr); - element.writeAttribute(attr, unsafeAttr); - } - }); - }); - content.hiddenElements = null; - } - var loadImagesButton = $("loadImagesButton"); - if (loadImagesButton) - loadImagesButton.setStyle({ display: 'none' }); -} - -function onEmailAddressClick(event) { - popupMenu(event, 'addressMenu', this); - preventDefault(event); - return false; -} - -function onImageClick(event) { - popupMenu(event, 'imageMenu', this); - preventDefault(event); - return false; -} - -function handleReturnReceipt() { - var input = $("shouldAskReceipt"); - if (input) { - if (eval(input.value)) { - showConfirmDialog(_("Return Receipt"), - _("The sender of this message has asked to be notified when you read this message. " - + "Do you with to notify the sender?"), - onReadMessageConfirmMDN); - } - } -} - -function onReadMessageConfirmMDN(event) { - var messageURL; - if (window.opener && window.opener.Mailer) { - /* from UIxMailPopupView */ - messageURL = (ApplicationBaseURL + encodeURI("/" + mailboxName) - + "/" + messageName); - } - else { - /* from main window */ - messageURL = (ApplicationBaseURL + encodeURI(Mailer.currentMailbox) + "/" - + Mailer.currentMessages[Mailer.currentMailbox]); - } - disposeDialog(); - var url = messageURL + "/sendMDN"; - triggerAjaxRequest(url); -} - -function loadMessageCallback(http) { - var div = $('messageContent'); - - if (http.status == 200) { - if (http.callbackData) { - document.messageAjaxRequest = null; - var msguid = http.callbackData.msguid; - var mailbox = http.callbackData.mailbox; - if (Mailer.currentMailbox == mailbox && - Mailer.currentMessages[Mailer.currentMailbox] == msguid) { - div.innerHTML = http.responseText; - configureLinksInMessage(); - resizeMailContent(); - configureLoadImagesButton(); - if (UserDefaults["SOGoMailDisplayRemoteInlineImages"] == 'always') - loadRemoteImages(); - configureSignatureFlagImage(); - handleReturnReceipt(); - } - var cachedMessage = new Array(); - cachedMessage['idx'] = Mailer.currentMailbox + '/' + msguid; - cachedMessage['time'] = (new Date()).getTime(); - cachedMessage['text'] = http.responseText; - if (cachedMessage['text'].length < 30000) - storeCachedMessage(cachedMessage); - // Mark the mail as read - mailListToggleMessagesRead($("row_" + msguid), true); - } - } - else if (http.status == 404) { - showAlertDialog (_("The message you have selected doesn't exist anymore.")); - Mailer.dataTable.remove(http.callbackData.msguid); - Mailer.currentMessages[Mailer.currentMailbox] = null; - } - else - log("messageCallback: problem during ajax request: " + http.status); -} - -function processMailboxMenuAction(mailbox) { - var currentNode, upperNode; - var mailboxName; - var action; - - mailboxName = mailbox.getAttribute('mailboxname'); - currentNode = mailbox; - upperNode = null; - - while (currentNode - && !currentNode.hasAttribute('mailboxaction')) - currentNode = currentNode.parentNode.parentNode.parentMenuItem; - - if (currentNode) { - action = currentNode.getAttribute('mailboxaction'); - } -} - -var rowSelectionCount = 0; - -validateControls(); - -function showElement(e, shouldShow) { - e.style.display = shouldShow ? "" : "none"; -} - -function enableElement(e, shouldEnable) { - if(!e) - return; - if(shouldEnable) { - if(e.hasAttribute("disabled")) - e.removeAttribute("disabled"); - } - else { - e.setAttribute("disabled", "1"); - } -} - -function validateControls() { - var e = $("moveto"); - this.enableElement(e, rowSelectionCount > 0); -} - -function moveTo(uri) { - alert("MoveTo: " + uri); -} - -/* message menu entries */ -function onMenuOpenMessage(event) { - return openMessageWindowsForSelection('popupview'); -} - -function onMenuReplyToSender(event) { - return openMessageWindowsForSelection('reply'); -} - -function onMenuReplyToAll(event) { - return openMessageWindowsForSelection('replyall'); -} - -function onMenuForwardMessage(event) { - return openMessageWindowsForSelection('forward'); -} - -function onMenuViewMessageSource(event) { - var messageList = $("messageListBody"); - var rows = messageList.getSelectedRowsId(); - - if (rows.length > 0) { - var url = (ApplicationBaseURL + encodeURI(Mailer.currentMailbox) + "/" - + rows[0].substr(4) + "/viewsource"); - $(function() { - openMailComposeWindow(url); - }).delay(0.1); - } - - preventDefault(event); -} - -function saveImage(event) { - var img = document.menuTarget; - var url = img.getAttribute("src"); - var urlAsAttachment = url.replace(/(\/[^\/]*)$/,"/asAttachment$1"); - - window.location.href = urlAsAttachment; -} - -/* Download a file using a temporary iframe that we delete once the download is started */ -function download(url) { - var form = createElement('form', null, 'hidden', { action: url, method: 'GET'}); - $(document.body).appendChild(form); - var div = AIM.submit(form); - form.submit(); - setTimeout(function () { - form.remove(); - div.remove(); - }, 20000); -} - -function saveAttachment(event) { - var url = $(this).readAttribute('data-url'); - if (url) { - download(url); - } - else { - $(this).up('ul').select('li[data-url]').each(function (item) { - url = $(item).readAttribute('data-url'); - download(url); - }); - } -} - -/* contacts */ -function newContactFromEmail(event) { - var mailto = document.menuTarget.innerHTML; - - var email = extractEmailAddress(mailto); - var c_name = extractEmailName(mailto); - if (email.length > 0) { - var url = (UserFolderURL + "Contacts/personal/newcontact?contactEmail=" - + encodeURI(email)); - if (c_name) - url += "&contactFN=" + c_name; - openContactWindow(url); - } - - return false; /* stop following the link */ -} - -function newEmailTo(sender) { - return openMailTo(document.menuTarget.innerHTML); -} - -function expandUpperTree(node) { - var currentNode = node.parentNode; - - while (currentNode.className != "dtree") { - if (currentNode.className == 'clip') { - var id = currentNode.getAttribute("id"); - var number = parseInt(id.substr(2)); - if (number > 0) { - var cn = mailboxTree.aNodes[number]; - mailboxTree.nodeStatus(1, number, cn._ls); - } - } - currentNode = currentNode.parentNode; - } -} - -function onHeaderClick(event) { - if (SOGoResizableTable._onHandle) - return; - - var headerId = this.getAttribute("id"); - var newSortAttribute; - if (headerId == "subjectHeader") - newSortAttribute = "subject"; - else if (headerId == "fromHeader") - newSortAttribute = "from"; - else if (headerId == "toHeader") - newSortAttribute = "to"; - else if (headerId == "dateHeader") - newSortAttribute = "date"; - else if (headerId == "sizeHeader") - newSortAttribute = "size"; - else - newSortAttribute = "arrival"; - - if (sorting["attribute"] == newSortAttribute) - sorting["ascending"] = !sorting["ascending"]; - else { - sorting["attribute"] = newSortAttribute; - sorting["ascending"] = true; - } - - refreshCurrentFolder(); - - Event.stop(event); -} - -function refreshCurrentFolder() { - if (Mailer.currentMailboxType != "account" && Mailer.currentMailboxType != "additional") - openMailbox(Mailer.currentMailbox, true); -} - -/* Called after sending an email */ -function refreshMessage(mailbox, messageUID) { - if (Mailer.currentMailboxType == 'sent' || Mailer.currentMailboxType == 'draft') - refreshCurrentFolder(); - else if (mailbox == Mailer.currentMailbox) { - Mailer.dataTable.invalidate(messageUID); - } -} - -function configureMessageListEvents() { - var headerTable = $("messageListHeader"); - var dataTable = $("messageListBody"); - var messageContent = $("messageContent"); - - if (headerTable) - // Sortable columns - configureSortableTableHeaders(headerTable); - - if (dataTable) { - dataTable.multiselect = true; - if (messageContent) { - dataTable.observe("click", onMessageSelectionChange); - dataTable.observe("dblclick", onMessageDoubleClick); - } - else { - // Single-window mode - dataTable.observe("click", function(e) { - onMessageSelectionChange.bind(this)(e) && - onMessageDoubleClick.bind(this)(e); }); - } - dataTable.observe("selectstart", listRowMouseDownHandler); - dataTable.observe("contextmenu", onMessageContextMenu); - } -} - -function configureDragHandles() { - var handle = $("verticalDragHandle"); - if (handle) { - handle.addInterface(SOGoDragHandlesInterface); - handle.leftMargin = 50; - handle.leftBlock=$("leftPanel"); - handle.rightBlock=$("rightPanel"); - } - - handle = $("rightDragHandle"); - if (handle) { - handle.addInterface(SOGoDragHandlesInterface); - handle.upperBlock=$("mailboxContent"); - handle.lowerBlock=$("messageContent"); - handle.observe("handle:dragged", onMessageListResize); - } -} - -function onMessageListResize(event) { - var h = $("mailboxContent").getHeight() - $("messageListHeader").getHeight(); - $("mailboxList").setStyle({'height': h + 'px'}); -} - -function onWindowResize(event) { - var handle = $("verticalDragHandle"); - if (handle) - handle.adjust(); - handle = $("rightDragHandle"); - if (handle) - handle.adjust(); -} - -/* stub */ - -function refreshContacts() { -} - -function openInbox(node) { - var done = false; - openMailbox(node.parentNode.getAttribute("dataname"), false); - mailboxTree.o(1); - mailboxTree.s(2); -} - -function initMailer(event) { - if (!$(document.body).hasClassName("popup")) { - Mailer.columnsOrder = UserDefaults["SOGoMailListViewColumnsOrder"]; - Mailer.sortByThread = UserDefaults["SOGoMailSortByThreads"] != null && parseInt(UserDefaults["SOGoMailSortByThreads"]) > 0; - if (Mailer.sortByThread && Mailer.columnsOrder[0] != "Thread") - Mailer.columnsOrder = ["Thread"].concat(Mailer.columnsOrder); - else if (!Mailer.sortByThread && Mailer.columnsOrder[0] == "Thread") - Mailer.columnsOrder.shift(); // drop the thread column - - if (UserSettings && UserSettings.Mail) { - // Restore threads - cachedThreadsCollapsed = UserSettings.Mail.threadsCollapsed; - - // Restore sorting from user settings - if (UserSettings.Mail.SortingState) { - sorting["attribute"] = UserSettings["Mail"]["SortingState"][0]; - sorting["ascending"] = parseInt(UserSettings["Mail"]["SortingState"][1]) > 0; - if (sorting["attribute"] == 'to') sorting["attribute"] = 'from'; // initial mailbox is always the inbox - } - else { - sorting["attribute"] = "date"; - sorting["ascending"] = false; - } - } - - Mailer.dataTable = $("mailboxList"); - Mailer.dataTable.addInterface(SOGoDataTableInterface); - Mailer.dataTable.setRowRenderCallback(messageListCallback); - Mailer.dataTable.observe("datatable:rendered", onMessageListRender); - - var messageListHeader = $("messageListHeader"); - messageListHeader.addInterface(SOGoResizableTableInterface); - if (UserSettings["Mail"] && UserSettings["Mail"]["ColumnsState"]) { - messageListHeader.restore($H(UserSettings["Mail"]["ColumnsState"])); - } - else { - messageListHeader.restore(); - } - - configureDraggables(); - configureMessageListEvents(); - - initMailboxTree(); - initRefreshViewCheckTimer(); - - Event.observe(document, "keydown", onDocumentKeydown); - - /* Perform an expunge when leaving the webmail */ - // if (isSafari()) { - // $('calendarBannerLink').observe("click", onUnload); - // $('contactsBannerLink').observe("click", onUnload); - // $('logoff').observe("click", onUnload); - // } - // else - Event.observe(window, "beforeunload", onUnload); - - onMessageListResize(); - } - - onWindowResize.defer(); - Event.observe(window, "resize", onWindowResize); -} - -function initRefreshViewCheckTimer() { - // TEMPORARY : to be erase - var refreshViewCheck = UserDefaults["SOGoMailMessageCheck"]; - if (refreshViewCheck == null) - refreshViewCheck = UserDefaults["SOGoRefreshViewCheck"]; - - if (refreshViewCheck && refreshViewCheck != "manually") { - var interval; - if (refreshViewCheck == "once_per_hour") - interval = 3600; - else if (refreshViewCheck == "every_minute") - interval = 60; - else { - interval = parseInt(refreshViewCheck.substr(6)) * 60; - } - refreshViewCheckTimer = window.setInterval(onRefreshViewCheckCallback, - interval * 1000); - } -} - -function onRefreshViewCheckCallback(event) { - refreshMailbox(); -} - -function initMailboxTree() { - var node = $("mailboxTree"); - if (node) - node.parentNode.removeChild(node); - mailboxTree = new dTree("mailboxTree"); - mailboxTree.config.hideRoot = true; - mailboxTree.icon.root = ResourcesURL + "/tbtv_account_17x17.png"; - mailboxTree.icon.folder = ResourcesURL + "/tbtv_leaf_corner_17x17.png"; - mailboxTree.icon.folderOpen = ResourcesURL + "/tbtv_leaf_corner_17x17.png"; - mailboxTree.icon.node = ResourcesURL + "/tbtv_leaf_corner_17x17.png"; - mailboxTree.icon.line = ResourcesURL + "/tbtv_line_17x22.png"; - mailboxTree.icon.join = ResourcesURL + "/tbtv_junction_17x22.png"; - mailboxTree.icon.joinBottom = ResourcesURL + "/tbtv_corner_17x22.png"; - mailboxTree.icon.plus = ResourcesURL + "/tbtv_plus_17x22.png"; - mailboxTree.icon.plusBottom = ResourcesURL + "/tbtv_corner_plus_17x22.png"; - mailboxTree.icon.minus = ResourcesURL + "/tbtv_minus_17x22.png"; - mailboxTree.icon.minusBottom = ResourcesURL + "/tbtv_corner_minus_17x22.png"; - mailboxTree.icon.nlPlus = ResourcesURL + "/tbtv_corner_plus_17x22.png"; - mailboxTree.icon.nlMinus = ResourcesURL + "/tbtv_corner_minus_17x22.png"; - mailboxTree.icon.empty = ResourcesURL + "/empty.gif"; - mailboxTree.preload (); - - mailboxTree.add(0, -1, ''); - - var chainRq = new AjaxRequestsChain(initMailboxTreeCB); - for (var i = 0; i < mailAccounts.length; i++) { - var url = ApplicationBaseURL + "/" + i + "/mailboxes"; - chainRq.requests.push([url, onLoadMailboxesCallback, i]); - } - chainRq.start(); -} - -function initMailboxTreeCB() { - updateMailboxTreeInPage(); - updateMailboxMenus(); - checkAjaxRequestsState(); - getFoldersState(); - configureDroppables(); - if (unseenCountFolders.length > 0) { - for (var i = 0; i < unseenCountFolders.length; i++) { - Mailer.unseenCountMailboxes.push(unseenCountFolders[i]); - } - refreshUnseenCounts(); - } -} - -function onLoadMailboxesCallback(http) { - if (http.status == 200) { - checkAjaxRequestsState(); - if (http.responseText.length > 0) { - var accountIdx = http.callbackData; - var newAccount = buildMailboxes(accountIdx, http.responseText); - accounts[accountIdx] = newAccount; - mailboxTree.addMailAccount(newAccount); - } - else { - log ("onLoadMailboxesCallback " + http.status); - } - } -} - -function updateMailboxTreeInPage() { - var treeContent = $("folderTreeContent"); - //treeContent.update(mailboxTree.toString ()); - treeContent.appendChild(mailboxTree.domObject ()); - - var inboxFound = false; - var tree = $("mailboxTree"); - var nodes = document.getElementsByClassName("node", tree); - for (i = 0; i < nodes.length; i++) { - nodes[i].observe("click", - onMailboxTreeItemClick.bindAsEventListener(nodes[i])); - nodes[i].observe("contextmenu", - onFolderMenuClick.bindAsEventListener(nodes[i])); - if (!inboxFound - && nodes[i].parentNode.getAttribute("datatype") == "inbox") { - Mailer.currentMailboxType = "inbox"; - openInbox(nodes[i]); - inboxFound = true; - } - } -} - -function updateQuotas(quotas) { - if (quotas && parseInt(quotas.maxQuota) > 0) { - log ("updating quotas " + quotas.usedSpace + "/" + quotas.maxQuota); - var treeContent = $("folderTreeContent"); - var tree = $("mailboxTree"); - var quotaDiv = $("quotaIndicator"); - if (quotaDiv) { - treeContent.removeChild(quotaDiv); - } - // Build quota indicator, show values in MB - var percents = (Math.round(quotas.usedSpace * 10000 - / quotas.maxQuota) - / 100); - var level = (percents > 85)? "alert" : (percents > 70)? "warn" : "ok"; - var format = _("quotasFormat"); - var text = format.formatted(percents, - Math.round(quotas.maxQuota/10.24)/100); - quotaDiv = new Element('div', { 'id': 'quotaIndicator', - 'class': 'quota', - 'info': text }); - var levelDiv = new Element('div', { 'class': 'level' }); - var valueDiv = new Element('div', { 'class': 'value ' + level, 'style': 'width: ' + ((percents > 100)?100:percents) + '%' }); - var marksDiv = new Element('div', { 'class': 'marks' }); - var textP = new Element('p').update(text); - marksDiv.insert(new Element('div')); - marksDiv.insert(new Element('div')); - marksDiv.insert(new Element('div')); - levelDiv.insert(valueDiv); - levelDiv.insert(marksDiv); - levelDiv.insert(textP); - quotaDiv.insert(levelDiv); - treeContent.insertBefore(quotaDiv, tree); - } -} - -function mailboxMenuNode(type, displayName) { - var newNode = document.createElement("li"); - var icon = MailerUIdTreeExtension.folderIcons[type]; - if (!icon) - icon = "tbtv_leaf_corner_17x17.png"; - var image = document.createElement("img"); - image.src = ResourcesURL + "/" + icon; - newNode.appendChild(image); - var dnOverride = MailerUIdTreeExtension.folderNames[type]; - if (dnOverride) - displayName = dnOverride; - newNode.appendChild(document.createTextNode(" " + displayName)); - - return newNode; -} - -function generateMenuForMailbox(mailbox, prefix, callback) { - var menuDIV = document.createElement("div"); - $(menuDIV).addClassName("menu"); - var menuID = prefix + "Submenu"; - var previousMenuDIV = $(menuID); - if (previousMenuDIV) - previousMenuDIV.parentNode.removeChild(previousMenuDIV); - menuDIV.setAttribute("id", menuID); - var menu = document.createElement("ul"); - menu.style.cssFloat="left"; - menu.style.styleFloat="left"; - menuDIV.appendChild(menu); - pageContent.appendChild(menuDIV); - - var windowHeight = 0; - if ( typeof(window.innerHeight) != "undefined" && window.innerHeight != 0 ) { - windowHeight = window.innerHeight; - } - else { - windowHeight = document.body.clientHeight; - } - var offset = 70; - if ( navigator.appVersion.indexOf("Safari") >= 0 ) { - offset = 140; - } - - var callbacks = new Array(); - if (mailbox.type != "account") { - var newNode = document.createElement("li"); - newNode.mailbox = mailbox; - newNode.appendChild(document.createTextNode(_("This Folder"))); - menu.appendChild(newNode); - menu.appendChild(document.createElement("li")); - callbacks.push(callback); - callbacks.push("-"); - } - - var submenuCount = 0; - var newNode; - for (var i = 0; i < mailbox.children.length; i++) { - if (menu.offsetHeight > windowHeight-offset) { - // Split menu to fit screen - var menuWidth = (parseInt(menu.offsetWidth) + 15) + "px"; - menu.style.width = menuWidth; - menu = document.createElement("ul"); - menu.style.cssFloat="left"; - menu.style.styleFloat="left"; - menuDIV.appendChild(menu); - } - var child = mailbox.children[i]; - newNode = mailboxMenuNode(child.type, child.displayName); - newNode.style.width = "auto"; - menu.appendChild(newNode); - if (child.children.length > 0) { - var newPrefix = prefix + submenuCount; - var newSubmenuId = generateMenuForMailbox(child, newPrefix, callback); - callbacks.push(newSubmenuId); - submenuCount++; - } - else { - newNode.mailbox = child; - callbacks.push(callback); - } - } - menu.style.width = (parseInt(menu.offsetWidth) + 15) + "px"; - - initMenu(menuDIV, callbacks); - - return menuDIV.getAttribute("id"); -} - -function updateMailboxMenus() { - var mailboxActions = { move: onMailboxMenuMove, - copy: onMailboxMenuCopy }; - var accountsMenus = { move: $$('#moveMailboxMenu li'), - copy: $$('#copyMailboxMenu li') }; - - for (var key in mailboxActions) { - for (var i = 0; i < mailAccounts.length; i++) { - var mailbox = accounts[i]; - var id = generateMenuForMailbox(mailbox, key + "-" + i, - mailboxActions[key]); - accountsMenus[key][i].submenu = id; - } - } -} - -function buildMailboxes(accountIdx, encoded) { - var account = new Mailbox("account", "" + accountIdx, - undefined, //necessary, null will cause issues - mailAccounts[accountIdx]); - var data = encoded.evalJSON(true); - var mailboxes = data.mailboxes; - var unseen = (data.status? data.status.unseen : 0); - - for (var i = 0; i < mailboxes.length; i++) { - var currentNode = account; - var names = mailboxes[i].path.split("/"); - var displayNames = mailboxes[i].displayName.split("/"); - - for (var j = 1; j < (names.length - 1); j++) { - var name = names[j]; - var node = currentNode.findMailboxByName(name); - if (!node) { - node = new Mailbox("additional", name, 0, displayNames[j]); - currentNode.addMailbox(node); - } - currentNode = node; - } - var basename = names[names.length-1]; - var leaf = currentNode.findMailboxByName(basename); - if (leaf) - leaf.type = mailboxes[i].type; - else { - if (mailboxes[i].type == 'inbox') - leaf = new Mailbox(mailboxes[i].type, basename, unseen, displayNames[names.length-1]); - else - leaf = new Mailbox(mailboxes[i].type, basename, 0, displayNames[names.length-1]); - currentNode.addMailbox(leaf); - } - } - - return account; -} - -function getFoldersState() { - if (mailAccounts.length > 0) { - var urlstr = ApplicationBaseURL + "/foldersState"; - triggerAjaxRequest(urlstr, getFoldersStateCallback); - } -} - -function getFoldersStateCallback(http) { - if (http.status == 200) { - if (http.responseText.length > 0) { - // The response text is a JSON array - // of the folders that were left opened. - var data = http.responseText.evalJSON(true); - for (var i = 1; i < mailboxTree.aNodes.length; i++) { - if ($(data).indexOf(mailboxTree.aNodes[i].dataname) > 0) - // If the folder is found, open it - mailboxTree.o(i); - } - } - mailboxTree.autoSync(); - } -} - -function saveFoldersState() { - if (mailAccounts.length > 0) { - var foldersState = mailboxTree.getFoldersState(); - var urlstr = ApplicationBaseURL + "/saveFoldersState"; - var parameters = "expandedFolders=" + foldersState; - triggerAjaxRequest(urlstr, saveFoldersStateCallback, null, parameters, - { "Content-type": "application/x-www-form-urlencoded" }); - } -} - -function saveFoldersStateCallback(http) { - if (isHttpStatus204(http.status)) { - log ("folders state saved"); - } -} - -function onMenuCreateFolder(event) { - showPromptDialog(_("New Folder..."), _("Name :"), onMenuCreateFolderConfirm); -} - -function onMenuCreateFolderConfirm(event) { - var name = this.value; - if (name && name.length > 0) { - var folderID = document.menuTarget.getAttribute("dataname"); - var urlstr = URLForFolderID(folderID) + "/createFolder?name=" + encodeURIComponent(name); - var errorLabel = labels["The folder with name \"%{0}\" could not be created."]; - triggerAjaxRequest(urlstr, folderOperationCallback, - errorLabel.formatted(name)); - } - disposeDialog(); -} - -function onMenuRenameFolder(event) { - var folderName = document.menuTarget.down('.nodeName').childNodes[0].nodeValue; - showPromptDialog(_("Rename Folder..."), _("Enter the new name of your folder :"), onMenuRenameFolderConfirm, folderName); -} - -function onMenuRenameFolderConfirm() { - var name = this.value; - if (name && name.length > 0) { - var folderID = document.menuTarget.getAttribute("dataname"); - var urlstr = URLForFolderID(folderID) + "/renameFolder?name=" + encodeURIComponent(name); - var errorLabel = labels["This folder could not be renamed to \"%{0}\"."]; - triggerAjaxRequest(urlstr, folderOperationCallback, - errorLabel.formatted(name)); - } - disposeDialog(); -} - -function onMenuDeleteFolder(event) { - var folderID = document.menuTarget.getAttribute("dataname"); - var urlstr = URLForFolderID(folderID) + "/delete"; - var errorLabel = _("The folder could not be deleted."); - showConfirmDialog(_("Confirmation"), - _("Do you really want to move this folder into the trash ?"), - function(event) { - triggerAjaxRequest(urlstr, folderOperationCallback, errorLabel); - disposeDialog(); - }); -} - -function onMenuMarkFolderRead(event) { - var folderID = document.menuTarget.getAttribute("dataname"); - var urlstr = URLForFolderID(folderID) + "/markRead"; - - // Delete the associated data sources - deleteCachedMailbox(folderID); - - if (folderID == Mailer.currentMailbox) { - // Reset the data source so the message headers are reloaded in the callback function - Mailer.dataTable.dataSource.destroy(); - } - else { - // Reset the unseen count of the mailbox - var node = mailboxTree.getMailboxNode(folderID); - if (node) { - updateUnseenCount(node, 0, false); - } - } - - triggerAjaxRequest(urlstr, folderRefreshCallback, { "mailbox": folderID, "refresh": true }); -} - -function onMenuExpungeFolder(event) { - var folderID = document.menuTarget.getAttribute("dataname"); - var urlstr = URLForFolderID(folderID) + "/expunge"; - triggerAjaxRequest(urlstr, folderRefreshCallback, { "mailbox": folderID, "refresh": false }); -} - -function onMenuEmptyTrash(event) { - var folderID = document.menuTarget.getAttribute("dataname"); - var urlstr = URLForFolderID(folderID) + "/emptyTrash"; - triggerAjaxRequest(urlstr, onMenuEmptyTrashCallback, { "mailbox" : folderID }); - - if (folderID == Mailer.currentMailbox) { - $('messageContent').innerHTML = ''; - } - var msgID = Mailer.currentMessages[folderID]; - if (msgID) { - delete Mailer.currentMessages[folderID]; - deleteCachedMessage(folderID + "/" + msgID); - } -} - -function onMenuEmptyTrashCallback(http) { - if (http.readyState == 4 - && http.status == 200) { - deleteCachedMailboxByType('trash'); - // Reload the folder tree if there was folders in the trash - var reloaded = false; - var nodes = $("mailboxTree").select("DIV[datatype=trash]"); - for (var i = 0; i < nodes.length; i++) { - if (http.callbackData.mailbox == nodes[i].readAttribute('dataname')) { - // Reset the unread message count - updateUnseenCount(nodes[i], 0); - var sibling = nodes[i].next(); - if (sibling && sibling.hasClassName("clip")) { - initMailboxTree(); - reloaded = true; - break; - } - } - } - if (!reloaded) { - var data = http.responseText.evalJSON(true); - // We currently only show the quota for the first account (0). - if (data.quotas && http.callbackData.mailbox.startsWith('/0/')) - updateQuotas(data.quotas); - } - } - else - showAlertDialog(_("The trash could not be emptied.")); -} - -function _onMenuChangeToXXXFolder(event, folder) { - var type = document.menuTarget.getAttribute("datatype"); - if (type == "additional") - showAlertDialog(_("You need to choose a non-virtual folder!")); - else { - var folderID = document.menuTarget.getAttribute("dataname"); - var urlstr = URLForFolderID(folderID) + "/setAs" + folder + "Folder"; - var errorLabel = _("The folder functionality could not be changed."); - triggerAjaxRequest(urlstr, folderOperationCallback, errorLabel); - } -} - -function onMenuChangeToDraftsFolder(event) { - return _onMenuChangeToXXXFolder(event, "Drafts"); -} - -function onMenuChangeToSentFolder(event) { - return _onMenuChangeToXXXFolder(event, "Sent"); -} - -function onMenuChangeToTrashFolder(event) { - return _onMenuChangeToXXXFolder(event, "Trash"); -} - -function onMenuToggleMessageRead(event) { - mailListToggleMessagesRead(); -} - -function onMenuLabelNone() { - var msgUIDs = []; - var url = ApplicationBaseURL + encodeURI(Mailer.currentMailbox); - - if (!Object.isArray(document.menuTarget)) { - if (document.menuTarget.tagName == "DIV") - // Menu called from message content view - msgUIDs.push(Mailer.currentMessages[Mailer.currentMailbox]); - - else - // Menu called from one selection in message list view - msgUIDs.push(document.menuTarget.getAttribute("id").substr(4)); - } - else { - // Menu called from multiple selection in messages list view - var rows = $(document.menuTarget); - for (var i = 0; i < rows.length; i++) { - var row = $(rows[i]); - if (row) { - msgUIDs.push(rows[i].substr(4)); - } - } - } - - var callbackData = { mailbox: Mailer.currentMailbox, msgUIDs: msgUIDs }; - var content = { mailbox: Mailer.currentMailbox, msgUIDs: msgUIDs }; - content = Object.toJSON(content); - triggerAjaxRequest(url + "/removeAllLabels", messageFlagCallback, callbackData, content); -} - -function onMenuLabelFlag() { - var flag = this.readAttribute("data-name"); - var url = ApplicationBaseURL + encodeURI(Mailer.currentMailbox); - var operation = "add"; - var msgUIDs = []; - var msgLabels; - - if (!Object.isArray(document.menuTarget)) { - msgUIDs.push(Mailer.currentMessages[Mailer.currentMailbox]); - if (document.menuTarget.tagName == "DIV") - // Menu called from message content view - msgLabels = $('row_' + msgUIDs[0]).getAttribute("labels"); - else - // Menu called from one selection in messages list view - msgLabels = document.menuTarget.getAttribute("labels"); - - var flags = msgLabels.split(" "); - if (flags.indexOf(flag) > -1) - operation = "remove"; - } - else { - // Menu called from multiple selection in messages list view - var rows = $(document.menuTarget); - var blockedOperation = false; - for (var i = 0; i < rows.length; i++) { - var row = $(rows[i]); - if (row) { - msgUIDs.push(rows[i].substr(4)); - msgLabels = row.getAttribute("labels"); - - var flags = msgLabels.split(" "); - if (flags.indexOf(flag) > -1 && !blockedOperation) { - operation = "remove"; - } - else { - blockedOperation = true; - operation = "add"; - } - } - } - } - - var callbackData = { mailbox: Mailer.currentMailbox, operation: operation, flag: flag, msgUIDs: msgUIDs}; - var content = {flags: flag.asCSSIdentifier(), msgUIDs: msgUIDs, operation: operation}; - content = Object.toJSON(content); - triggerAjaxRequest(url + "/addOrRemoveLabel", messageFlagCallback, callbackData, content); -} - -function messageFlagCallback(http) { - if (http.readyState == 4 - && isHttpStatus204(http.status)) { - var data = http.callbackData; - if (data["mailbox"] == Mailer.currentMailbox) { - var msgUIDs = data["msgUIDs"]; - for (var i = 0; i < msgUIDs.length; i++) { - Mailer.dataTable.invalidate(msgUIDs[i]); - var row = $("row_" + msgUIDs[i]); - var operation = data["operation"]; - if (operation) { - var labels = row.getAttribute("labels"); - var flags = []; - if (labels.length > 0) - flags = labels.split(" "); - if (operation == "add") { - if (flags.indexOf(data["flag"]) == -1) - flags.push(data["flag"]); - } - else { - // Remove flag - var flag = data["flag"]; - var idx = flags.indexOf(flag); - flags.splice(idx, 1); - } - row.writeAttribute("labels", flags.join(" ")); - } - else - row.writeAttribute("labels", ""); - } - } - } -} - -function onMenuToggleMessageFlag(event) { - mailListToggleMessagesFlagged(); -} - -function refreshUserSettingsCallback(http) { - var allUserSettings = http.response.evalJSON(); - if (UserSettings.Mail) { - UserSettings.Mail = allUserSettings.Mail; - cachedThreadsCollapsed = UserSettings.Mail.threadsCollapsed; - } - refreshMailbox(); -} - -function folderOperationCallback(http) { - if (http.readyState == 4 && isHttpStatus204(http.status)) { - initMailboxTree(); - triggerAjaxRequest(UserFolderURL + "/preferences/jsonSettings", refreshUserSettingsCallback); - } - else - showAlertDialog(http.callbackData); -} - -function folderRefreshCallback(http) { - if (http.readyState == 4 - && (http.status == 200 || isHttpStatus204(http.status))) { - var oldMailbox = http.callbackData.mailbox; - if (http.callbackData.refresh - && oldMailbox == Mailer.currentMailbox) { - getUnseenCountForFolder(oldMailbox); - if (http.callbackData.id) { - var s = http.callbackData.id + ""; - var uids = s.split(","); - for (var i = 0; i < uids.length; i++) - Mailer.dataTable.remove(uids[i]); - Mailer.dataTable.refresh(); - } - else - refreshCurrentFolder(); - } - if (http.status == 200) { - var data = http.responseText.evalJSON(true); - if (data.quotas && http.callbackData.mailbox.startsWith('/0/')) - updateQuotas(data.quotas); - } - } - else { - if (http.callbackData.id) { - // Display hidden rows from move operation - var s = http.callbackData.id + ""; - var uids = s.split(","); - log ("folderRefreshCallback failed for UIDs " + s); - for (var i = 0; i < uids.length; i++) { - var row = $("row_" + uids[i]); - if (row) - row.show(); - } - } - var msg = /
(.*)<\/p>/m.exec(http.responseText); - showAlertDialog(_("Operation failed") + ": " + msg[1]); - } -} - -function onMessageListMenuPrepareVisibility() { - /* This method attaches the right mailbox-menu to the generic message list - menu. */ - var indexes = { "messageListMenu": 7, - "messagesListMenu": 2, - "messageContentMenu": 4 }; - if (document.menuTarget) { - var mbx = Mailer.currentMailbox; - if (mbx) { - var lis = this.getElementsByTagName("li"); - var idx = indexes[this.id]; - var parts = mbx.split("/"); - var acctNbr = parseInt(parts[1]); - lis[idx].submenu = "move-" + acctNbr + "Submenu"; - lis[idx+1].submenu = "copy-" + acctNbr + "Submenu"; - } - } - - return true; -} - -function onAccountIconMenuPrepareVisibility() { - /* This methods disables or enables the "Delegation..." menu option on - mail accounts. */ - if (document.menuTarget) { - var mbx = document.menuTarget.getAttribute("dataname"); - if (mbx) { - var lis = this.getElementsByTagName("li"); - var li = lis[lis.length - 1]; - var parts = mbx.split("/"); - var acctNbr = parseInt(parts[1]); - if (acctNbr > 0) { - li.addClassName("disabled"); - } - else { - li.removeClassName("disabled"); - } - } - } - - return true; -} - -function onFolderMenuPrepareVisibility() { - /* This methods disables or enables the "Sharing" menu option on - mailboxes. */ - if (document.menuTarget) { - var mbx = document.menuTarget.getAttribute("dataname"); - if (mbx) { - var lis = this.getElementsByTagName("li"); - var li = lis[lis.length - 1]; - var parts = mbx.split("/"); - var acctNbr = parseInt(parts[1]); - if (acctNbr > 0) { - li.addClassName("disabled"); - } - else { - li.removeClassName("disabled"); - } - } - } - - return true; -} - -function onLabelMenuPrepareVisibility() { - var messageList = $("messageListBody"); - var flags = {}; - - if (messageList) { - var rows = messageList.getSelectedRows(); - for (var i = 0; i < rows.length; i++) { - $w(rows[i].getAttribute("labels")).each(function(flag) { - flags[flag] = true; - }); - } - } - - var lis = this.childNodesWithTag("ul")[0].childNodesWithTag("li"); - var isFlagged = false; - - // lis is our array of labels, ex: - // li - // li.seperator - // li.label1 - // li.broccoli - // ... - for (var i = 2; i < lis.length; i++) { - - // We bind the event handlers if we need to - if (lis[i].menuCallback == null) { - lis[i].menuCallback = onMenuLabelFlag; - lis[i].on("mousedown", onMenuClickHandler); - lis[i].removeClassName("disabled"); - } - - var flag = lis[i].readAttribute("data-name"); - - if (flags[flag]) { - isFlagged = true; - lis[i].addClassName("_chosen"); - } - else { - lis[i].removeClassName("_chosen"); - } - } - - if (isFlagged) - lis[0].removeClassName("_chosen"); - else - lis[0].addClassName("_chosen"); -} - -function onMarkMenuPrepareVisibility() { - var messageList = $("messageListBody"); - if (messageList) { - var nodes = messageList.down("TBODY").getSelectedNodesId(); - - var isRead = false; - var isFlagged = false; - - if (nodes.length > 0) { - var row = null; - for (var i = 0; row == null && i < nodes.length; i++) - row = $(nodes[i]); - var img = row.down('img'); - isFlagged = img.hasClassName ("messageIsFlagged"); - isRead = !row.hasClassName("mailer_unreadmail"); - } - - var menuUL = this.down(); - var menuLIS = menuUL.childElements(); - - if (isRead) { - menuLIS[0].addClassName("_chosen"); - } - else { - menuLIS[0].removeClassName("_chosen"); - } - if (isFlagged) { - menuLIS[5].addClassName("_chosen"); - } - else { - menuLIS[5].removeClassName("_chosen"); - } - } -} - -function saveAs(event) { - var messageList = $("messageListBody").down("TBODY"); - - var uids = messageList.getSelectedNodesId(); - if (uids.length > 0) { - for (var i = 0; i < uids.length; i++) - uids[i] = uids[i].substr(4); - var url = ApplicationBaseURL + encodeURI(Mailer.currentMailbox) + "/saveMessages"; - window.location.href = url + "?uid=" + uids.join(","); - } - else - showAlertDialog(_("Please select a message.")); - - return false; -} - -function onMenuArchiveFolder(event) { - var folderID = document.menuTarget.getAttribute("dataname"); - var url = URLForFolderID(folderID) + "/exportFolder"; - window.location.href = url; -} - -function onMenuAccountDelegation(event) { - var folderID = document.menuTarget.getAttribute("dataname"); - var urlstr = ApplicationBaseURL + folderID + "/delegation"; - openAclWindow(urlstr); -} - -function getMenus() { - var menus = { - accountIconMenu: [ null, null, onMenuCreateFolder, null, null, onMenuAccountDelegation ], - inboxIconMenu: [ null, null, null, "-", onMenuMarkFolderRead, - onMenuCreateFolder, onMenuExpungeFolder, - onMenuArchiveFolder, "-", null, - onMenuSharing ], - trashIconMenu: [ null, null, null, "-", onMenuMarkFolderRead, - onMenuCreateFolder, onMenuExpungeFolder, - onMenuArchiveFolder, onMenuEmptyTrash, - "-", null, - onMenuSharing ], - mailboxIconMenu: [ null, null, null, "-", onMenuMarkFolderRead, - onMenuCreateFolder, onMenuRenameFolder, - onMenuExpungeFolder, onMenuArchiveFolder, - onMenuDeleteFolder, "folderTypeMenu", - "-", null, - onMenuSharing ], - addressMenu: [ newContactFromEmail, newEmailTo ], - messageListMenu: [ onMenuOpenMessage, "-", - onMenuReplyToSender, - onMenuReplyToAll, - onMenuForwardMessage, null, - "-", "moveMailboxMenu", - "copyMailboxMenu", "label-menu", - "mark-menu", "-", saveAs, - onMenuViewMessageSource, null, - null, onMenuDeleteMessage ], - messagesListMenu: [ onMenuForwardMessage, - "-", "moveMailboxMenu", - "copyMailboxMenu", "label-menu", - "mark-menu", "-", - saveAs, null, null, - onMenuDeleteMessage ], - imageMenu: [ saveImage ], - messageContentMenu: [ onMenuReplyToSender, - onMenuReplyToAll, - onMenuForwardMessage, - null, "moveMailboxMenu", - "copyMailboxMenu", - "-", "label-menu", "mark-menu", - "-", - saveAs, onMenuViewMessageSource, - null, onPrintCurrentMessage, - onMenuDeleteMessage ], - folderTypeMenu: [ onMenuChangeToSentFolder, - onMenuChangeToDraftsFolder, - onMenuChangeToTrashFolder ], - - "label-menu": [ onMenuLabelNone, "-" ], - - "mark-menu": [ onMenuToggleMessageRead, null, null, null, "-", onMenuToggleMessageFlag ], - - searchMenu: [ setSearchCriteria, setSearchCriteria, - setSearchCriteria, setSearchCriteria, - setSearchCriteria ] - }; - - - if (typeof mailAccounts != 'undefined') { - menus['moveMailboxMenu'] = mailAccounts.collect(function (account) { return account.asCSSIdentifier() }); - menus['copyMailboxMenu'] = mailAccounts.collect(function (account) { return account.asCSSIdentifier() }); - } - - var labelMenu = $("label-menu"); - if (labelMenu) { - labelMenu.prepareVisibility = onLabelMenuPrepareVisibility; - } - - var markMenu = $("mark-menu"); - if (markMenu) { - markMenu.prepareVisibility = onMarkMenuPrepareVisibility; - } - - var accountIconMenu = $("accountIconMenu"); - if (accountIconMenu) { - accountIconMenu.prepareVisibility = onAccountIconMenuPrepareVisibility; - } - - var folderMenus = [ "inboxIconMenu", "trashIconMenu", "mailboxIconMenu" ]; - for (var i = 0; i < folderMenus.length; i++) { - var menu = $(folderMenus[i]); - if (menu) { - menu.prepareVisibility = onFolderMenuPrepareVisibility; - } - } - - return menus; -} - -document.observe("dom:loaded", initMailer); - -function Mailbox(type, name, unseen, displayName) { - this.type = type; - if (displayName) - this.displayName = displayName; - else - this.displayName = name; - // log("name: " + name + "; dn: " + displayName); - this.name = name; - this.unseen = unseen; - this.parentFolder = null; - this.children = new Array(); - return this; -} - -Mailbox.prototype = { - dump: function(indent) { - if (!indent) - indent = 0; - log(" ".repeat(indent) + this.name); - for (var i = 0; i < this.children.length; i++) { - this.children[i].dump(indent + 2); - } - }, - fullName: function() { - var fullName = ""; - - var currentFolder = this; - while (currentFolder.parentFolder) { - fullName = ("/folder" + currentFolder.name).asCSSIdentifier() + fullName; - currentFolder = currentFolder.parentFolder; - } - - return "/" + currentFolder.name + fullName; - }, - findMailboxByName: function(name) { - var mailbox = null; - - var i = 0; - while (!mailbox && i < this.children.length) - if (this.children[i].name == name - || this.children[i].displayName == name) - mailbox = this.children[i]; - else - i++; - - return mailbox; - }, - addMailbox: function(mailbox) { - mailbox.parentFolder = this; - this.children.push(mailbox); - } -}; - -function configureDraggables() { - var table = jQuery("#messageListBody"); - table.draggable({ - addClasses: false, - helper: function (event) { return '
'; }, - start: startDragging, - drag: whileDragging, - stop: stopDragging, - appendTo: 'body', - cursorAt: { top: 15, right: 15 }, - scroll: false, - distance: 4, - zIndex: 20 - }); -} - -function configureDroppables() { - jQuery('#mailboxTree .dTreeNode[datatype!="account"][datatype!="additional"] .node .nodeName').droppable({ - hoverClass: 'genericHoverClass', - drop: dropAction }); -} - -function startDragging(event, ui) { - var handle = ui.helper; - var count = $('messageListBody').getSelectedRowsId().length; - - if (count == 0) { - jQuery(this).trigger("stop"); - return false; - } - handle.html(count); - - if (event.shiftKey) { - handle.addClass("copy"); - } - handle.show(); -} - -function whileDragging(event, ui) { - if (event) { - var handle = ui.helper; - if (event.shiftKey) - handle.addClass("copy"); - else if (handle.hasClass("copy")) - handle.removeClass("copy"); - } -} - -function stopDragging(event, ui) { - var handle = ui.helper; - handle.hide(); - if (handle.hasClass("copy")) - handle.removeClass("copy"); - for (var i = 0; i < accounts.length; i++) { - handle.removeClass("account" + i); - } -} - -function dropAction(event, ui) { - var destination = $(this).up("div.dTreeNode"); - var f; - if (ui.helper.hasClass("copy")) { - // Message(s) copied - f = onMailboxMenuCopy.bind(destination); - } - else { - // Message(s) moved - f = onMailboxMenuMove.bind(destination); - } - f(); -} diff --git a/UI/WebServerResources/MailerUIdTree.js b/UI/WebServerResources/MailerUIdTree.js deleted file mode 100644 index d37149a64..000000000 --- a/UI/WebServerResources/MailerUIdTree.js +++ /dev/null @@ -1,71 +0,0 @@ -var MailerUIdTreeExtension = { - elementCounter: 1, - folderIcons: { account: "tbtv_account_17x17.png", - inbox: "tbtv_inbox_17x17.png", - sent: "tbtv_sent_17x17.png", - draft: "tbtv_drafts_17x17.png", - trash: "tbtv_trash_17x17.png" }, - folderNames: { inbox: _("InboxFolderName"), - sent: _("SentFolderName"), - draft: _("DraftsFolderName"), - trash: _("TrashFolderName") }, - _addFolderNode: function (parent, name, fullName, type, unseen) { - var icon = this.folderIcons[type]; - if (icon) - icon = ResourcesURL + "/" + icon; - else - icon = ""; - var displayName = this.folderNames[type]; - if (!displayName) - displayName = name; - displayName += " (" + parseInt(unseen) + ")"; - this.add(this.elementCounter, parent, displayName, 1, '#', fullName, - type, '', '', icon, icon, true); - this.elementCounter++; - }, - _addFolder: function (parent, folder) { - var thisCounter = this.elementCounter; - this._addFolderNode(parent, folder.displayName, folder.fullName(), folder.type, folder.unseen); - for (var i = 0; i < folder.children.length; i++) - this._addFolder(thisCounter, folder.children[i]); - }, - addMailAccount: function (mailAccount) { - this._addFolder(0, mailAccount); - }, - setCookie: function(cookieName, cookieValue, expires, path, domain, secure) { - - }, - getCookie: function(cookieName) { - return (""); - }, - updateCookie: function () { - if (Mailer.foldersStateTimer) - clearTimeout(Mailer.foldersStateTimer); - Mailer.foldersStateTimer = setTimeout('saveFoldersState()', 3000); // 3 seconds - }, - getFoldersState: function () { - var expandedFolders = new Array(); - for (var n = 0; n < this.aNodes.length; n++) { - if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) { - expandedFolders.push(this.aNodes[n].dataname); - } - } - return Object.toJSON(expandedFolders); - }, - autoSync: function() { - this.config.useCookies = true; - }, - getMailboxNode: function(mailbox) { - var childNode = null; - for (var i = 0; (childNode == null) && (i < this.aNodes.length); i++) { - var aNode = this.aNodes[i]; - if (aNode.dataname == mailbox) { - childNode = $("smailboxTree" + aNode.id); - } - } - - return ((childNode) ? childNode.parentNode : null); - } -}; - -Object.extend(dTree.prototype, MailerUIdTreeExtension); diff --git a/UI/WebServerResources/PasswordPolicy.js b/UI/WebServerResources/PasswordPolicy.js deleted file mode 100644 index 440a4bf7c..000000000 --- a/UI/WebServerResources/PasswordPolicy.js +++ /dev/null @@ -1,98 +0,0 @@ -var PolicyPasswordChangeUnsupported = -3; -var PolicyPasswordSystemUnknown = -2; -var PolicyPasswordUnknown = -1; -var PolicyPasswordExpired = 0; -var PolicyAccountLocked = 1; -var PolicyChangeAfterReset = 2; -var PolicyPasswordModNotAllowed = 3; -var PolicyMustSupplyOldPassword = 4; -var PolicyInsufficientPasswordQuality = 5; -var PolicyPasswordTooShort = 6; -var PolicyPasswordTooYoung = 7; -var PolicyPasswordInHistory = 8; -var PolicyNoError = 65535; - -function _passwordPolicyAjaxCallback(http) { - if (http.readyState == 4) { - var policy = http.callbackData; - policy.callback(http); - } -} - -function PasswordPolicy(userName, password) { - this.userName = userName; - this.password = password; -} - -PasswordPolicy.prototype = { - userName: null, - password: null, - successCallback: null, - failureCallback: null, - - setCallbacks: function(successCallback, failureCallback) { - this.successCallback = successCallback; - this.failureCallback = failureCallback; - }, - - changePassword: function (newPassword) { - var content = Object.toJSON({ userName: this.userName, - password: this.password, - newPassword: newPassword }); - var urlParts = ApplicationBaseURL.split("/"); - var url = "/" + urlParts[1] + "/so/changePassword"; - triggerAjaxRequest(url, _passwordPolicyAjaxCallback, this, - content, {"content-type": "application/json"} ); - }, - - callback: function(http) { - if (isHttpStatus204(http.status)) { - if (this.successCallback) - this.successCallback(_("The password was changed successfully.")); - } else { - if (this.failureCallback) { - var perr = PolicyPasswordUnknown; - var error = ""; - switch (http.status) { - case 403: - if (http.getResponseHeader("content-type") - == "application/json") { - var jsonResponse = http.responseText.evalJSON(false); - perr = jsonResponse["LDAPPasswordPolicyError"]; - - // Normal password change failed - if (perr == PolicyNoError) { - error = _("Password change failed"); - } else if (perr == PolicyPasswordModNotAllowed) { - error = _("Password change failed - Permission denied"); - } else if (perr == PolicyInsufficientPasswordQuality) { - error = _("Password change failed - Insufficient password quality"); - } else if (perr == PolicyPasswordTooShort) { - error = _("Password change failed - Password is too short"); - } else if (perr == PolicyPasswordTooYoung) { - error = _("Password change failed - Password is too young"); - } else if (perr == PolicyPasswordInHistory) { - error = _("Password change failed - Password is in history"); - } else { - error = _("Unhandled policy error: %{0}").formatted(perr); - perr = PolicyPasswordUnknown; - } - } else { - perr = PolicyPasswordSystemUnknown; - error = _("Unhandled error response"); - } - break; - case 404: - perr = PolicyPasswordChangeUnsupported; - error = _("Password change is not supported."); - break; - default: - perr = PolicyPasswordSystemUnknown; - error = _("Unhandled HTTP error code: %{0}").formatted(http.status); - } - this.failureCallback(perr, error); - // showPasswordMessage(error); - } - } - } -}; diff --git a/UI/WebServerResources/RowEditionController.js b/UI/WebServerResources/RowEditionController.js deleted file mode 100644 index 04524141d..000000000 --- a/UI/WebServerResources/RowEditionController.js +++ /dev/null @@ -1,130 +0,0 @@ -/* bind method: attachToRowElement(row: TD or LI) - * callback methods: - notifyStartEditingCallback(this) - notifyEndEditingCallback(this) - notifyNewValueCallback(this, newValue), - */ - -function RowEditionController() { -} - -RowEditionController.prototype = { - initialValue: null, - rowElement: null, - textField: null, - - /* notification callbacks */ - notifyStartEditingCallback: null, - notifyEndEditingCallback: null, - notifyNewValueCallback: null, - - /* bind method */ - attachToRowElement: function REC_attachToRowElement(rowElement) { - var onRowDblClickBound = this.onRowDblClick.bindAsEventListener(this); - rowElement.observe("dblclick", onRowDblClickBound); - this.rowElement = rowElement; - rowElement.editionController = this; - }, - - /* internal */ - emptyRow: function REC_emptyRow() { - var rowElement = this.rowElement; - while (rowElement.firstChild) { - rowElement.removeChild(rowElement.firstChild); - } - }, - - startEditing: function REC_startEditing() { - var rowElement = this.rowElement; - rowElement.addClassName("editing"); - - var value = ""; - for (var i = 0; i < rowElement.childNodes.length; i++) { - var child = rowElement.childNodes[i]; - if (child.nodeType == Node.TEXT_NODE) { - value += child.nodeValue; - } - } - this.initialValue = value; - this.emptyRow(); - - this.showInputField(value); - - this.onBodyMouseDownBound = this.onBodyMouseDown.bindAsEventListener(this); - $(document.body).observe("mousedown", this.onBodyMouseDownBound); - - if (this.notifyStartEditingCallback) { - this.notifyStartEditingCallback(this); - } - }, - showInputField: function REC_showInputField(value) { - var textField = createElement("input", null, null, {"type": "text"}); - this.textField = textField; - if (value) { - textField.value = value; - } - this.rowElement.appendChild(textField); - var onInputKeyDownBound = this.onInputKeyDown.bindAsEventListener(this); - textField.observe("keydown", onInputKeyDownBound); - textField.focus(); - textField.select(); - }, - - stopEditing: function REC_stopEditing(accept) { - var displayValue = (accept ? this.textField.value : this.initialValue); - this.textField = null; - this.emptyRow(); - var rowElement = this.rowElement; - rowElement.removeClassName("editing"); - rowElement.appendChild(document.createTextNode(displayValue)); - this.initialValue = null; - - $(document.body).stopObserving("mousedown", this.onBodyMouseDownBound); - this.onBodyMouseDownBound = null; - - if (this.notifyEndEditingCallback) { - this.notifyEndEditingCallback(this); - } - }, - - acceptEdition: function REC_acceptEdition() { - var newValue = this.textField.value; - var isValid = (newValue && newValue.length > 0); - if (this.initialValue != newValue - && isValid - && this.notifyNewValueCallback) { - this.notifyNewValueCallback(this, newValue); - } - this.stopEditing(isValid); - }, - cancelEdition: function REC_acceptEdition() { - this.stopEditing(false); - }, - - /* event handlers */ - onRowDblClick: function REC_onRowDblClick(event) { - if (!this.textField) { - this.startEditing(); - event.stop(); - } - }, - - onInputKeyDown: function REC_onInputKeyDown(event) { - if (event.keyCode == Event.KEY_ESC) { - this.cancelEdition(); - event.stop(); - } - else if (event.keyCode == Event.KEY_RETURN) { - this.acceptEdition(); - event.stop(); - } - else if (event.keyCode == Event.KEY_TAB) { - this.acceptEdition(); - } - }, - onBodyMouseDown: function REC_onBodyMouseDown(event) { - if (event.target != this.textField) { - this.acceptEdition(); - } - } -}; diff --git a/UI/WebServerResources/SOGoAutoCompletion.js b/UI/WebServerResources/SOGoAutoCompletion.js deleted file mode 100644 index 0434f2175..000000000 --- a/UI/WebServerResources/SOGoAutoCompletion.js +++ /dev/null @@ -1,385 +0,0 @@ -/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -// NOTE: The popup menu with id "contactsMenu" must exist before -// using this interface. -// -// This interface fires two events: -// - autocompletion:changed : fired when a new contact is selected -// - autocompletion:changedlist : fired when a new list is selected -// -var SOGoAutoCompletionInterface = { - - // Attributes that could be changed from the object - // inheriting the inteface -uidField: "c_name", -addressBook: null, -SOGoUsersSearch: false, -excludeGroups: false, -excludeLists: false, - - // Internal attributes -animationParent: null, -selectedIndex: -1, -delay: 0.750, -delayedSearch: false, -menu: null, - -bind: function () { - this.menu = $('contactsMenu'); - this.writeAttribute("autocomplete", "off"); - this.writeAttribute("container", null); - this.confirmedValue = null; - this.observe("keydown", this.onKeydown.bindAsEventListener(this)); - this.observe("blur", this.onBlur.bindAsEventListener(this)); -}, - -onKeydown: function (event) { - if (event.ctrlKey || event.metaKey) { - this.focussed = true; - return; - } - if (event.keyCode == Event.KEY_TAB) { - if (this.confirmedValue) - this.value = this.confirmedValue; - else - this.writeAttribute("uid", null); - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); - } - else if (event.keyCode == 0 - || event.keyCode == Event.KEY_BACKSPACE - || event.keyCode == Event.KEY_DELETE - || event.keyCode == 32 // Space - || event.keyCode > 47) { - this.confirmedValue = null; - this.selectedIndex = -1; - if (this.delayedSearch) - window.clearTimeout(this.delayedSearch); - this.delayedSearch = this.performSearch.delay(this.delay, this); - } - else if (event.keyCode == Event.KEY_RETURN) { - preventDefault(event); - if (this.confirmedValue) - this.value = this.confirmedValue; - else - this.writeAttribute("uid", null); - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); - this.selectedIndex = -1; - if (this.readAttribute("container")) { - this.confirmedValue = null; - this.fire("autocompletion:changedlist", this.readAttribute("container")); - } - else - this.fire("autocompletion:changed", event.keyCode); - } - else if (this.menu.getStyle('visibility') == 'visible') { - if (event.keyCode == Event.KEY_UP) { // Up arrow - if (this.selectedIndex > 0) { - var contacts = this.menu.select("li"); - contacts[this.selectedIndex--].removeClassName("selected"); - this.value = contacts[this.selectedIndex].readAttribute("address"); - this.confirmedValue = this.value; - this.writeAttribute("uid", contacts[this.selectedIndex].readAttribute("uid")); - contacts[this.selectedIndex].addClassName("selected"); - var container = contacts[this.selectedIndex].readAttribute("container"); - if (container) - this.writeAttribute("container", container); - } - } - else if (event.keyCode == Event.KEY_DOWN) { // Down arrow - var contacts = this.menu.select("li"); - if (contacts.size() - 1 > this.selectedIndex) { - if (this.selectedIndex >= 0) - contacts[this.selectedIndex].removeClassName("selected"); - this.selectedIndex++; - this.value = contacts[this.selectedIndex].readAttribute("address"); - this.confirmedValue = this.value; - this.writeAttribute("uid", contacts[this.selectedIndex].readAttribute("uid")); - contacts[this.selectedIndex].addClassName("selected"); - var container = contacts[this.selectedIndex].readAttribute("container"); - if (container) - this.writeAttribute("container", container); - } - } - } -}, - -onBlur: function (event) { - if (this.delayedSearch) - window.clearTimeout(this.delayedSearch); - if (this.confirmedValue) { - this.value = this.confirmedValue; - if (this.readAttribute("container")) - this.fire("autocompletion:changedlist", this.readAttribute("container")); - else - this.fire("autocompletion:changed", event.keyCode); - } - else - this.writeAttribute("uid", null); -}, - -performSearch: function (input) { - // Perform address completion - if (document.contactLookupAjaxRequest) { - // Abort any pending request - document.contactLookupAjaxRequest.aborted = true; - document.contactLookupAjaxRequest.abort(); - } - if (input.value.trim().length > minimumSearchLength) { - if (input.SOGoUsersSearch) { - var urlstr = UserFolderURL + "usersSearch?search=" + encodeURIComponent(input.value); - document.contactLookupAjaxRequest = - triggerAjaxRequest(urlstr, input.performUsersSearchCallback.bind(input), input); - } - else { - var urlstr = UserFolderURL + "Contacts/"; - if (input.addressBook) - urlstr += input.addressBook + "/contact"; - else - urlstr += "allContact"; - urlstr += "Search?search=" + encodeURIComponent(input.value); - if (input.excludeGroups) - urlstr += "&excludeGroups=1"; - if (input.excludeLists) - urlstr += "&excludeLists=1"; - if (input.animationParent) - startAnimation(input.animationParent); - document.contactLookupAjaxRequest = - triggerAjaxRequest(urlstr, input.performSearchCallback.bind(input), input); - } - } - else { - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); - } -}, - -performSearchCallback: function (http) { - if (http.readyState == 4) { - var list = this.menu.down("ul"); - - var input = http.callbackData; - - if (http.status == 200) { - var start = input.value.length; - var data = http.responseText.evalJSON(true); - - if (data.contacts.length > 1) { - list.select("li").each(function(item) { - item.stopObserving("mousedown"); - item.remove(); - }); - - // Populate popup menu - for (var i = 0; i < data.contacts.length; i++) { - var contact = data.contacts[i]; - var completeEmail = contact["c_cn"]; - var uid = "" + contact[this.uidField]; - var c_name = "" + contact['c_name']; - if (contact["c_mail"]) - completeEmail += " <" + contact["c_mail"] + ">"; - var node = new Element('li', { 'address': completeEmail, - 'uid': uid }); - var matchPosition = completeEmail.toLowerCase().indexOf(data.searchText.toLowerCase()); - if (matchPosition > -1) { - var matchBefore = completeEmail.substring(0, matchPosition); - var matchText = completeEmail.substring(matchPosition, matchPosition + data.searchText.length); - var matchAfter = completeEmail.substring(matchPosition + data.searchText.length); - node.appendChild(document.createTextNode(matchBefore)); - node.appendChild(new Element('strong').update(matchText)); - node.appendChild(document.createTextNode(matchAfter)); - } - else { - node.appendChild(document.createTextNode(completeEmail)); - } - list.appendChild(node); - if (c_name.endsWith(".vlf")) { - // Keep track of list containers - node.writeAttribute("container", contact['container']); - } - if (contact["contactInfo"]) - node.appendChild(document.createTextNode(" (" + contact["contactInfo"] + ")")); - $(node).observe("mousedown", this.onAddressResultClick.bindAsEventListener(this)); - } - - // Show popup menu - var offsetScroll = Element.cumulativeScrollOffset(input); - var offset = Element.positionedOffset(input); - if ($(document.body).hasClassName("popup") && typeof initPopupMailer == 'undefined') - // Hack for some situations where the offset must be computed differently - offset = Element.cumulativeOffset(input); - var top = offset.top - offsetScroll.top + node.offsetHeight + 3; - var height = 'auto'; - var heightDiff = window.height() - offset[1]; - var nodeHeight = node.getHeight(); - - if ((data.contacts.length * nodeHeight) > heightDiff) - // Limit the size of the popup to the window height, minus 12 pixels - height = parseInt(heightDiff/nodeHeight) * nodeHeight - 12 + 'px'; - - this.menu.setStyle({ top: top + "px", - left: offset[0] + "px", - height: height, - maxWidth: (window.width() - offset[0] - 12) + "px", - visibility: "visible" }); - this.menu.scrollTop = 0; - - document.currentPopupMenu = this.menu; - $(document.body).stopObserving("click"); - $(document.body).observe("click", onBodyClickMenuHandler); - } - else { - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); - - if (data.contacts.length == 1) { - // Single result - var contact = data.contacts[0]; - var uid = "" + contact[this.uidField]; - var c_name = "" + contact['c_name']; - input.writeAttribute("uid", uid); - if (c_name.endsWith(".vlf")) { - this.writeAttribute("container", contact['container']); - } - var completeEmail = contact["c_cn"]; - if (contact["c_mail"]) - completeEmail += " <" + contact["c_mail"] + ">"; - if (contact["c_cn"].substring(0, input.value.length).toUpperCase() - == input.value.toUpperCase()) - input.value = completeEmail; - else - // The result matches email address, not user name - input.value += ' >> ' + completeEmail; - input.confirmedValue = completeEmail; - - var end = input.value.length; - $(input).selectText(start, end); - - this.selectedIndex = -1; - } - } - } - else - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); - document.contactLookupAjaxRequest = null; - } -}, - -performUsersSearchCallback: function (http) { - if (http.readyState == 4) { - var list = this.menu.down("ul"); - var input = http.callbackData; - if (http.status == 200) { - var response = http.responseText.evalJSON(); - - if (response.length > 1) { - list.select("li").each(function(item) { - item.stopObserving("mousedown"); - item.remove(); - }); - - // Populate popup menu - for (var i = 0; i < response.length; i++) { - var c_name = response[i][1]; - var completeEmail = c_name; - var c_mail = response[i][2]; - var uid = response[i][3]; - if (c_mail) - completeEmail += " <" + c_mail + ">"; - var node = new Element('li', { 'address': completeEmail, - 'uid': uid }); - var matchPosition = completeEmail.toLowerCase().indexOf(input.getValue().toLowerCase()); - if (matchPosition > -1) { - var matchBefore = completeEmail.substring(0, matchPosition); - var matchText = completeEmail.substring(matchPosition, matchPosition + input.getValue().length); - var matchAfter = completeEmail.substring(matchPosition + input.getValue().length); - node.appendChild(document.createTextNode(matchBefore)); - node.appendChild(new Element('strong').update(matchText)); - node.appendChild(document.createTextNode(matchAfter)); - } - else { - node.appendChild(document.createTextNode(completeEmail)); - } - list.appendChild(node); - $(node).observe("mousedown", this.onAddressResultClick.bindAsEventListener(this)); - } - - // Show popup menu - var offsetScroll = Element.cumulativeScrollOffset(input); - var offset = Element.positionedOffset(input); - if ($(document.body).hasClassName("popup") && typeof initPopupMailer == 'undefined') - // Hack for some situations where the offset must be computed differently - offset = Element.cumulativeOffset(input); - var top = offset.top - offsetScroll.top + node.offsetHeight + 3; - var height = 'auto'; - var heightDiff = window.height() - offset[1]; - var nodeHeight = node.getHeight(); - - if ((response.length * nodeHeight) > heightDiff) - // Limit the size of the popup to the window height, minus 12 pixels - height = parseInt(heightDiff/nodeHeight) * nodeHeight - 12 + 'px'; - - this.menu.setStyle({ top: top + "px", - left: offset[0] + "px", - height: height, - maxWidth: (window.width() - offset[0] - 12) + "px", - visibility: "visible" }); - this.menu.scrollTop = 0; - - document.currentPopupMenu = this.menu; - $(document.body).stopObserving("click"); - $(document.body).observe("click", onBodyClickMenuHandler); - } - else { - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); - - if (response.length == 1) { - // Single result - var c_name = response[0][1]; - var completeEmail = c_name; - var c_mail = response[0][2]; - var c_uid = response[0][0]; - input.writeAttribute("uid", c_uid); - if (c_mail) - completeEmail += " <" + c_mail + ">"; - if (c_uid.substring(0, input.getValue().length).toUpperCase() == input.getValue().toUpperCase()) - input.value = completeEmail; - else - // The result matches email address, not user name - input.value += ' >> ' + completeEmail; - input.confirmedValue = completeEmail; - - var end = input.getValue().length; - $(input).selectText(start, end); - - this.selectedIndex = -1; - } - } - } - else - if (document.currentPopupMenu) - hideMenu(document.currentPopupMenu); - document.contactLookupAjaxRequest = null; - } -}, - -onAddressResultClick: function(event) { - var e = Event.element(event); - if (e.tagName != 'LI') - e = e.up('LI'); - if (e) { - preventDefault(event); - this.value = e.readAttribute("address"); - this.writeAttribute("uid", e.readAttribute("uid")); - if (e.readAttribute("container")) - this.fire("autocompletion:changedlist", e.readAttribute("container")); - else { - this.confirmedValue = this.value; - this.fire("autocompletion:changed", Event.KEY_RETURN); - } - } -} -}; diff --git a/UI/WebServerResources/SOGoDataTable.js b/UI/WebServerResources/SOGoDataTable.js deleted file mode 100644 index 8cb0a94f0..000000000 --- a/UI/WebServerResources/SOGoDataTable.js +++ /dev/null @@ -1,345 +0,0 @@ -/* -*- Mode: js2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -/* - * Data table interface to be added to a DIV (this!) - * - * Available events: - * datatable:rendered -- fired once the view rendering is completed - * - */ -var SOGoDataTableInterface = { - - // Object variables initialized with "bind" - columnsCount: null, - rowModel: null, - rowHeight: 0, - body: null, - - // Object variables - dataSource: null, - rowTop: null, - rowBottom: null, - renderedIndex: -1, - renderedCount: 0, - rowRenderCallback: null, - - // Constants - overflow: 30, // must be lower than the overflow of the data source class - renderDelay: 0.1, // delay (in seconds) before which the table is rendered upon scrolling - - bind: function() { - this.observe("scroll" , this.render.bind(this)); - - this.body = this.down("tbody"); - this.rowModel = this.body.down("tr"); - - /** - * Overrided methods from HTMLElement.js - * Handle selection based on rows ID. - */ - this.body.selectRange = function(startIndex, endIndex) { - var s; - var e; - var rows; - var div = this.up('div'); - var uid = lastClickedRowId.substr(4); - - startIndex = div.dataSource.indexOf(uid); - uid = div.down('tr', endIndex).id.substr(4); - endIndex = div.dataSource.indexOf(uid); - - if (startIndex > endIndex) { - s = endIndex; - e = startIndex; - } - else { - s = startIndex; - e = endIndex; - } - - while (s <= e) { - uid = "row_" + div.dataSource.uidAtIndex(s); - if (this.selectedIds.indexOf(uid) < 0) - this.selectedIds.push(uid); - s++; - } - this.refreshSelectionByIds(); - }; - - this.body.selectAll = function() { - var div = this.up('div'); - this.selectedIds = new Array(); - for (var i = 0; i < div.dataSource.uids.length; i++) - this.selectedIds.push("row_" + div.dataSource.uidAtIndex(i)); - this.refreshSelectionByIds(); - }, - - // Since we use the fixed table layout, the first row must have the - // proper CSS classes that will define the columns width. - this.rowTop = new Element('tr', {'id': 'rowTop'}); - this.body.insertBefore(this.rowTop, this.rowModel); // IE requires the element to be inside the DOM before appending new children - var cells = this.rowModel.select('TD'); - for (var i = 0; i < cells.length; i++) { - var cell = cells[i]; - var td = new Element('td', {'class': cell.className}); - this.rowTop.appendChild(td); - } - - this.rowBottom = new Element('tr', {'id': 'rowBottom'}).update(new Element('td')); - this.body.insertBefore(this.rowBottom, this.rowModel); - - this.columnsCount = this.rowModel.select("td").length; - this.rowHeight = this.rowModel.getHeight(); -// log ("DataTable.bind() row height = " + this.rowHeight + "px"); - }, - - setRowRenderCallback: function(callbackFunction) { - // Each time a row is created or updated with new data, this callback - // function will be called. - this.rowRenderCallback = callbackFunction; - }, - - setSource: function(ds) { - this.dataSource = ds; - this.currentRenderID = ""; - this._emptyTable(); - this.scrollTop = 0; - }, - - initSource: function(dataSourceClass, url, params) { -// log ("DataTable.setSource() " + url); - if (this.dataSource) this.dataSource.destroy(); - this._emptyTable(); - this.dataSource = new window[dataSourceClass](this, url); - this.scrollTop = 0; - this.load(params); - }, - - load: function(urlParams) { - if (!this.dataSource) return; -// log ("DataTable.load() with parameters [" + urlParams.keys().join(' ') + "]"); - this.dataSource.load(urlParams); - }, - - visibleRowCount: function() { - var divHeight = this.getHeight(); - var visibleRowCount = Math.ceil(divHeight/this.rowHeight); - - return visibleRowCount; - }, - - firstVisibleRowIndex: function() { - var firstRowIndex = Math.floor(this.scrollTop/this.rowHeight); - - return firstRowIndex; - }, - - refresh: function() { - this.render(true); - }, - - render: function(refresh) { - // Setting "refresh" to true will force the call to getData which - // recomputes the top and bottom padding with respect to the total - // number of rows. - var index = this.firstVisibleRowIndex(); - var count = this.visibleRowCount(); - // Overflow the query to the maximum defined in the class variable overflow - var start = index - (this.overflow/2); - if (start < 0) start = 0; - var end = index + count + this.overflow - (index - start); -// log ("DataTable.render() from " + index + " to " + (index + count) + " boosted from " + start + " to " + end); - - // Don't overflow above the maximum number of entries from the data source - //if (this.dataSource.uids && this.dataSource.uids.length < end) end = this.dataSource.uids.length; - - index = start; - count = end - start; - - this.currentRenderID = this.dataSource.id + "/" + index + "-" + count; - - // Query the data source only if at least one row is not loaded - if (refresh === true || - this.renderedIndex < 0 || - this.renderedIndex > index || - this.renderedCount < count || - (index + count) > (this.renderedIndex + this.renderedCount)) { - this.dataSource.getData(this.currentRenderID, - index, - count, - (refresh === true)?this._refresh.bind(this):this._render.bind(this), - this.renderDelay); - } - }, - - _refresh: function(renderID, start, max, data) { - this._render(renderID, start, max, data, true); - }, - - _render: function(renderID, start, max, data, refresh) { - if (this.currentRenderID != renderID) { -// log ("DataTable._render() ignore render for " + renderID + " (current is " + this.currentRenderID + ")"); - return; - } -// log("DataTable._render() for " + data.length + " uids (from " + start + ", max " + max + ")"); - - var h, i, j; - var rows = this.body.select("tr"); - var scroll; - - scroll = this.scrollTop; - - h = start * this.rowHeight; - if (Prototype.Browser.IE) - this.rowTop.setStyle({ 'height': h + 'px', 'line-height': h + 'px' }); - this.rowTop.firstChild.setStyle({ 'height': h + 'px', 'line-height': h + 'px' }); - - h = (max - start - data.length) * this.rowHeight; - if (Prototype.Browser.IE) - this.rowBottom.setStyle({ 'height': h + 'px', 'line-height': h + 'px' }); - this.rowBottom.firstChild.setStyle({ 'height': h + 'px', 'line-height': h + 'px' }); - - if (this.renderedIndex < 0) { - this.renderedIndex = 0; - this.renderedCount = 0; - } - - if (refresh === true || - start > (this.renderedIndex + this.renderedCount) || - start + data.length < this.renderedIndex) { - // No reusable row in the viewport; - // refresh the complete view port - for (i = 0, j = start; - i < this.renderedCount && i < data.length; - i++, j++) { - // Render all existing rows with new data - var row = rows[i+1]; // must skip the first row (this.rowTop) - this.rowRenderCallback(row, data[i], false); - } - - for (i = this.renderedCount; - i < data.length; - i++, j++) { - // Add new rows, if necessary - var row = this.rowModel.cloneNode(true); - this.rowRenderCallback(row, data[i], true); - row.show(); - this.body.insertBefore(row, this.rowBottom); - } - - for (i = this.renderedCount; - i > data.length; - i--) { - // Delete extra rows, if necessary - this.body.removeChild(rows[i]); - } - } - else if (start >= this.renderedIndex) { - // Scrolling down - - // Delete top rows - for (i = start; i > this.renderedIndex; i--) { - this.body.removeChild(rows[i - this.renderedIndex]); - } - - // Add bottom rows - for (j = this.renderedIndex + this.renderedCount - start, i = this.renderedIndex + this.renderedCount; - j < data.length; - j++, i++) { - var row = this.rowModel.cloneNode(true); - this.rowRenderCallback(row, data[j], true); - this.body.insertBefore(row, this.rowBottom); - } - } - else { - // Scrolling up - - // Delete bottom rows - for (i = this.renderedIndex + this.renderedCount, j = this.renderedCount; - i > (start + data.length); - i--, j--) { - this.body.removeChild(rows[j]); - } - - // Add top rows - for (i = 0, j = start; - j < this.renderedIndex; - i++, j++) { - var row = this.rowModel.cloneNode(true); - this.rowRenderCallback(row, data[i], true); - row.show(); - this.body.insertBefore(row, rows[1]); - } - } - - // Update references to selected rows - this.body.refreshSelectionByIds(); -// log ("DataTable._render() top gap/bottom gap/total rows = " + this.rowTop.getStyle('height') + "/" + this.rowBottom.getStyle('height') + "/" + this.body.select("tr").length + " (height = " + this.down("table").getHeight() + "px)"); - - // Save current rendered view index and count - this.renderedIndex = start; - this.renderedCount = data.length; - - // Restore scroll position (necessary in certain cases) - this.scrollTop = scroll; - - Event.fire(this, "datatable:rendered", max); - }, - - invalidate: function(uid, withoutRefresh) { - // Refetch the data for uid. Only refresh the data table if - // necessary. -// log ("DataTable.invalidate(" + uid + ", with" + (withoutRefresh?"out":"") + " refresh)"); - var index = this.dataSource.invalidate(uid); - this.currentRenderID = index + "-" + 1; - this.dataSource.getData(this.currentRenderID, - index, - 1, - (withoutRefresh?false:this._invalidate.bind(this)), - 0); - }, - - _invalidate: function(renderID, start, max, data) { - if (renderID == this.currentRenderID) { - var rows = this.body.select("TR#" + data[0]['rowID']); - if (rows.length > 0) - this.rowRenderCallback(rows[0], data[0], false); - } - }, - - remove: function(uid) { - var rows = this.body.select("TR#row_" + uid); - if (rows.length == 1) { - var row = rows.first(); - row.deselect(); - row.parentNode.removeChild(row); - } - var index = this.dataSource.remove(uid); -// log ("DataTable.remove(" + uid + ") at index " + index); - if (index >= 0) { - if (this.renderedIndex > index) - this.renderedIndex--; - else if ((this.renderedIndex + this.renderedCount) > index) - this.renderedCount--; - } - return index; - }, - - _emptyTable: function() { - var rows = this.body.select("tr"); - var currentCount = rows.length; - - for (var i = currentCount - 1; i >= 0; i--) { - if (rows[i] != this.rowModel && - rows[i] != this.rowTop && - rows[i] != this.rowBottom) - this.body.removeChild(rows[i]); - } - - this.body.deselectAll(); - this.renderedIndex = -1; - this.renderedCount = 0; - this.rowTop.firstChild.setStyle({ 'height': '0px', 'line-height': '0px' }); - this.rowBottom.firstChild.setStyle({ 'height': '0px', 'line-height': '0px' }); - } -}; diff --git a/UI/WebServerResources/SOGoDragHandles.js b/UI/WebServerResources/SOGoDragHandles.js deleted file mode 100644 index 882c38517..000000000 --- a/UI/WebServerResources/SOGoDragHandles.js +++ /dev/null @@ -1,203 +0,0 @@ -/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -/* - * Drag handle widget interface to be added to a DIV (the drag handle) - * - * Available events: - * handle:dragged -- fired once the handle has been dropped - * - */ -var SOGoDragHandlesInterface = { - leftMargin: 180, - topMargin: 180, - dhType: null, - dhLimit: -1, - origX: -1, - origLeft: -1, - origRight: -1, - origY: -1, - origUpper: -1, - origLower: -1, - delta: -1, - btn: null, - leftBlock: null, - rightBlock: null, - upperBlock: null, - lowerBlock: null, - rightSafetyBlock: null, - startHandleDraggingBound: null, - stopHandleDraggingBound: null, - moveBound: null, - delayedSave: null, - bind: function () { - this.startHandleDraggingBound = this.startHandleDragging.bindAsEventListener(this); - this.observe("mousedown", this.startHandleDraggingBound, false); - }, - enableRightSafety: function () { - this.rightSafetyBlock = new Element('div', {'class': 'safetyBlock'}); - this.rightSafetyBlock.hide(); - document.body.appendChild(this.rightSafetyBlock); - }, - adjust: function () { - if (!this.dhType) - this._determineType(); - if (this.dhType == 'horizontal') { - this.dhLimit = window.width() - 20; - if (parseInt(this.getStyle("left")) > this.dhLimit) { - this.setStyle({ left: this.dhLimit + "px" }); - this.rightBlock.setStyle({ left: (this.dhLimit) + 'px' }); - this.leftBlock.setStyle({ width: (this.dhLimit) + 'px' }); - if (this.delayedSave) window.clearTimeout(this.delayedSave); - this.delayedSave = this.saveDragHandleState.delay(3, this.dhType, this.dhLimit, this.saveDragHandleStateCallback); - } - } - else if (this.dhType == 'vertical') { - var windowHeight = window.height(); - this.dhLimit = windowHeight - 20 - this.upperBlock.cumulativeOffset().top + this.upperBlock.offsetTop; - if (parseInt(this.getStyle("top")) > this.dhLimit && - windowHeight > this.topMargin) { - this.setStyle({ top: this.dhLimit + 'px' }); - this.lowerBlock.setStyle({ top: this.dhLimit + 'px' }); - this.upperBlock.setStyle({ height: (this.dhLimit - this.upperBlock.offsetTop) + 'px' }); - if (this.delayedSave) window.clearTimeout(this.delayedSave); - this.delayedSave = this.saveDragHandleState.delay(3, this.dhType, this.dhLimit, this.saveDragHandleStateCallback); - } - } - }, - _determineType: function () { - if (this.leftBlock && this.rightBlock) - this.dhType = 'horizontal'; - else if (this.upperBlock && this.lowerBlock) - this.dhType = 'vertical'; - }, - startHandleDragging: function (event) { - this.btn = event.button; - if (!this.dhType) - this._determineType(); - var targ = getTarget(event); - if (targ.nodeType == 1) { - if (this.dhType == 'horizontal') { - this.dhLimit = window.width() - 20; - this.origX = this.offsetLeft; - this.origLeft = this.leftBlock.offsetWidth; - this.delta = 0; - this.origRight = this.rightBlock.offsetLeft - 5; - document.body.setStyle({ cursor: "e-resize" }); - if (this.rightSafetyBlock) { - this.rightSafetyBlock.setStyle({ - top: this.rightBlock.getStyle('top'), - left: this.rightBlock.getStyle('left') }); - this.rightSafetyBlock.show(); - } - } else if (this.dhType == 'vertical') { - this.dhLimit = window.height() - 20; - this.origY = this.offsetTop; - this.origUpper = this.upperBlock.offsetHeight; - var pointY = Event.pointerY(event); - this.delta = pointY - this.offsetTop - 5; - this.origLower = this.lowerBlock.offsetTop - 5; - document.body.setStyle({ cursor: "n-resize" }); - } - this.stopHandleDraggingBound = this.stopHandleDragging.bindAsEventListener(this); - if (Prototype.Browser.IE) - Event.observe(document.body, "mouseup", this.stopHandleDraggingBound); - else - Event.observe(window, "mouseup", this.stopHandleDraggingBound); - this.moveBound = this.move.bindAsEventListener(this); - Event.observe(document.body, "mousemove", this.moveBound); - this.move(event); - } - - return false; - }, - stopHandleDragging: function (event) { - if (!this.dhType) - this._determineType(); - if (this.dhType == 'horizontal') { - var pointerX = Event.pointerX(event); - if (pointerX <= this.leftMargin) { - this.rightBlock.setStyle({ left: (this.leftMargin) + 'px' }); - this.leftBlock.setStyle({ width: (this.leftMargin) + 'px' }); - } - else if (pointerX >= this.dhLimit) { - this.rightBlock.setStyle({ left: (this.dhLimit) + 'px' }); - this.leftBlock.setStyle({ width: (this.dhLimit) + 'px' }); - } - else { - var deltaX = Math.floor(pointerX - this.origX - (this.offsetWidth / 2)); - this.rightBlock.setStyle({ left: (this.origRight + deltaX) + 'px' }); - this.leftBlock.setStyle({ width: (this.origLeft + deltaX) + 'px' }); - } - this.saveDragHandleState(this.dhType, parseInt(this.leftBlock.getStyle("width"))); - if (this.rightSafetyBlock) - this.rightSafetyBlock.hide(); - } - else if (this.dhType == 'vertical') { - var pointerY = Event.pointerY(event); - var deltaY; - if (pointerY <= this.topMargin) - deltaY = Math.floor(this.topMargin - this.origY - (this.offsetHeight / 2)); - else if (pointerY >= this.dhLimit) - deltaY = Math.floor(this.dhLimit - this.origY - (this.offsetHeight / 2)); - else - deltaY = Math.floor(pointerY - this.origY - (this.offsetHeight / 2)); - this.lowerBlock.setStyle({ top: (this.origLower + deltaY - this.delta) + 'px' }); - this.upperBlock.setStyle({ height: (this.origUpper + deltaY - this.delta) + 'px' }); - this.saveDragHandleState(this.dhType, parseInt(this.lowerBlock.getStyle("top"))); - } - if (Prototype.Browser.IE) - Event.stopObserving(document.body, "mouseup", this.stopHandleDraggingBound); - else - Event.stopObserving(window, "mouseup", this.stopHandleDraggingBound); - Event.stopObserving(document.body, "mousemove", this.moveBound); - - document.body.setAttribute('style', ''); - document.body.setStyle({ cursor: "default" }); - this.fire("handle:dragged"); - - Event.stop(event); - }, - move: function (event) { - if (!this.dhType) - this._determineType(); - if (this.dhType == 'horizontal') { - var hX = Event.pointerX(event); - var width = this.offsetWidth; - if (hX < this.leftMargin) - hX = this.leftMargin + Math.floor(width / 2); - else if (hX > this.dhLimit) - hX = this.dhLimit + Math.floor(width / 2); - var newLeft = Math.floor(hX - (width / 2)); - this.setStyle({ left: newLeft + 'px' }); - } else if (this.dhType == 'vertical') { - var hY = Event.pointerY(event); - var height = this.offsetHeight; - if (hY < this.topMargin) - hY = this.topMargin; - else if (hY > this.dhLimit) - hY = this.dhLimit; - - var newTop = Math.floor(hY - (height / 2)) - this.delta; - this.setStyle({ top: newTop + 'px' }); - } - Event.stop(event); - if (Prototype.Browser.IE && event.button != this.btn) - this.stopHandleDragging(event); - }, - saveDragHandleState: function (type, position, fcn) { - if (!$(document.body).hasClassName("popup")) { - var urlstr = ApplicationBaseURL + "/saveDragHandleState" - + "?" + type + "=" + position; - var callbackFunction = fcn || this.saveDragHandleStateCallback; - triggerAjaxRequest(urlstr, callbackFunction); - } - }, - saveDragHandleStateCallback: function (http) { - if (isHttpStatus204(http.status)) { - log ("Drag handle state saved"); - } - else if (http.readyState == 4) { - log ("Can't save handle state"); - } - } -}; diff --git a/UI/WebServerResources/SOGoMailDataSource.js b/UI/WebServerResources/SOGoMailDataSource.js deleted file mode 100644 index b6758e559..000000000 --- a/UI/WebServerResources/SOGoMailDataSource.js +++ /dev/null @@ -1,244 +0,0 @@ -/* -*- Mode: js2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -SOGoMailDataSource = Class.create({ - - initialize: function(dataTable, url) { - // Instance variables - this.dataTable = dataTable; - this.id = url; - this.url = url; - - this.uids = new Array(); - this.threaded = false; - this.cache = new Hash(); - - this.loaded = false; - this.delayedGetData = false; - this.ajaxGetData = false; - - // Constants - this.overflow = 50; // must be higher or equal to the overflow of the data table class - }, - - destroy: function() { - this.uids.clear(); - var keys = this.cache.keys(); - for (var i = 0; i < keys.length; i++) - this.cache.unset(keys[i]); - }, - - invalidate: function(uid) { - this.cache.unset(uid); - var index = this.indexOf(uid); -// log ("MailDataSource.invalidate(" + uid + ") at index " + index); - - return index; - }, - - remove: function(uid) { -// log ("MailDataSource.remove(" + uid + ")"); - var index = this.invalidate(uid); - if (index >= 0) { - this.uids.splice(index, 1); - } - - return index; - }, - - init: function(uids, threaded, headers, quotas) { - this.uids = uids; - if (typeof threaded != "undefined") { - this.threaded = threaded; - if (threaded) - this.uids.shift(); // drop key fields - } -// log ("MailDataSource.init() " + this.uids.length + " uids loaded"); - - if (quotas && Object.isFunction(updateQuotas)) - updateQuotas(quotas); - - if (headers) { - var keys = headers[0]; - for (var i = 1; i < headers.length; i++) { - var header = []; - for (var j = 0; j < keys.length; j++) - header[keys[j]] = headers[i][j]; - this.cache.set(header["uid"], header); - } -// log ("MailDataSource.init() " + this.cache.keys().length + " headers loaded"); - } - - this.loaded = true; -// log ("MailDataSource.init() " + this.uids.length + " UIDs, " + this.cache.keys().length + " headers"); - }, - - load: function(content) { - this.loaded = false; - triggerAjaxRequest(this.url + "/uids", - this._loadCallback.bind(this), - null, - content, - { "content-type": "application/json" }); - }, - - _loadCallback: function(http) { - if (http.status == 200) { - if (http.responseText.length > 0) { - var data = http.responseText.evalJSON(true); - if (data.uids) - this.init(data.uids, data.threaded, data.headers, data.quotas); - else - this.init(data); - if (this.delayedGetData) { - this.delayedGetData(); - this.delayedGetData = false; - } - } - } - else { - log("SOGoMailDataSource._loadCallback Error " + http.status + ": " + http.responseText); - } - }, - - getData: function(id, index, count, callbackFunction, delay) { - if (this.loaded == false) { - // UIDs are not yet loaded -- delay the call until loading the data is completed. -// log ("MailDataSource.getData() delaying data fetching while waiting for UIDs"); - this.delayedGetData = this.getData.bind(this, id, index, count, callbackFunction, delay); - return; - } - - var start, end; - - if (count > 1) { - // Compute last index depending on number of UIDs - start = index - (this.overflow/2); - if (start < 0) start = 0; - end = index + count + this.overflow - (index - start); - if (end > this.uids.length) { - start -= end - this.uids.length; - end = this.uids.length; - if (start < 0) start = 0; - } - } - else { - // Count is 1; don't fetch more data since the caller is - // SOGoDataTable.invalide() and asks for only one data row. - start = index; - end = index + count; - } -// log ("MailDataSource._getData() from " + index + " to " + (index + count) + " boosted from " + start + " to " + end); - - var missingUids = []; - for (var j = start; j < end; j++) { - var uid = this.threaded? this.uids[j][0] : this.uids[j]; - if (!this.cache.get(uid)) { -// log ("MailDataSource._getData missing headers of uid " + uid + " at index " + j + (this.threaded? " (":" (non-") + "threaded)"); - missingUids.push(uid); - } - } - - if (this.delayed_getRemoteData) window.clearTimeout(this.delayed_getRemoteData); - if (missingUids.length > 0) { - var params = "uids=" + missingUids.join(","); - this.delayed_getRemoteData = this._getRemoteData.bind(this, - { callbackFunction: callbackFunction, - start: start, end: end, - id: id }, - params).delay(delay); - } - else if (callbackFunction) - this._returnData(callbackFunction, id, start, end); - }, - - _getRemoteData: function(callbackData, urlParams) { - if (this.ajaxGetData) { - this.ajaxGetData.aborted = true; - this.ajaxGetData.abort(); -// log ("MailDataSource._getRemoteData() aborted previous AJAX request"); - } -// log ("MailDataSource._getRemoteData() fetching headers of " + urlParams); - this.ajaxGetData = triggerAjaxRequest(this.url + "/headers", - this._getRemoteDataCallback.bind(this), - callbackData, - urlParams, - { "Content-type": "application/x-www-form-urlencoded" }); - }, - - _getRemoteDataCallback: function(http) { - if (http.status == 200) { - if (http.responseText.length > 0) { - // We receives an array of hashes - var headers = $A(http.responseText.evalJSON(true)); - var data = http.callbackData; - var keys = headers[0]; - for (var i = 1; i < headers.length; i++) { - var header = []; - for (var j = 0; j < keys.length; j++) - header[keys[j]] = headers[i][j]; - this.cache.set(header["uid"], header); - } - - if (data["callbackFunction"]) - this._returnData(data["callbackFunction"], data["id"], data["start"], data["end"]); - } - } - else { - log("SOGoMailDataSource._getRemoteDataCallback Error " + http.status + ": " + http.responseText); - } - }, - - _returnData: function(callbackFunction, id, start, end) { - var i, j; - var data = new Array(); - for (i = start, j = 0; i < end; i++, j++) { - if (this.threaded) { - data[j] = this.cache.get(this.uids[i][0]); - - // Add thread-related data - if (parseInt(this.uids[i][2]) > 0) { - var mailbox = Mailer.currentMailbox; - if ((UserSettings.Mail.threadsCollapsed != undefined) && - (UserSettings.Mail.threadsCollapsed[Mailer.currentMailbox] != undefined) && - (UserSettings.Mail.threadsCollapsed[Mailer.currentMailbox].indexOf((this.uids[i][0]).toString())) != -1) { - data[j]['Thread'] = ' '; - } - else - data[j]['Thread'] = ' '; - } - else if (data[j]['Thread']) - delete data[j]['Thread']; - if (parseInt(this.uids[i][1]) > -1) - data[j]['ThreadLevel'] = this.uids[i][1]; - else - delete data[j]['ThreadLevel']; - } - else { - data[j] = this.cache.get(this.uids[i]); - } - } - callbackFunction(id, start, this.uids.length, data); - }, - - indexOf: function(uid) { - var index = -1; - if (this.threaded) { - for (var i = 0; i < this.uids.length; i++) - if (this.uids[i][0] == uid) { - index = i; - break; - } - } - else - index = this.uids.indexOf(parseInt(uid)); - - return index; - }, - - uidAtIndex: function(index) { - if (this.threaded) - return this.uids[index][0]; - else - return this.uids[index]; - } -}); diff --git a/UI/WebServerResources/SOGoResizableTable.js b/UI/WebServerResources/SOGoResizableTable.js deleted file mode 100644 index 10694296f..000000000 --- a/UI/WebServerResources/SOGoResizableTable.js +++ /dev/null @@ -1,286 +0,0 @@ -/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -/* - * Resizable table interface to be added to a TABLE (this!) - * - * Columns with the class resizable will be .. resizable. - * - */ -var SOGoResizableTableInterface = { - - delayedResize: null, - ratios: null, - - bind: function() { - var i; - var cells = $(this).down('tr').childElements(); - for (i = 0; i < cells.length; i++) { - var cell = cells[i]; - if (Prototype.Browser.IE) - cell.observe("selectstart", Event.stop); - if (cell.hasClassName('resizable')) { - Event.observe(cell, 'mouseover', SOGoResizableTable.initDetect); - Event.observe(cell, 'mouseout', SOGoResizableTable.killDetect); - } - SOGoResizableTable._resize(this, $(cell), i, null, cell.getWidth()); - } - this.computeColumnsWidths(); - Event.observe(window, "resize", this.resize.bind(this)); - }, - - resize: function(e) { - // Only resize the columns after a certain delay, otherwise it slows - // down the interface. - if (this.delayedResize) window.clearTimeout(this.delayedResize); - this.delayedResize = this._resize.bind(this).delay(0.2); - }, - - _resize: function() { - this.restore(); - }, - - restore: function(relativeWidths) { - if (SOGoResizableTable._stylesheet != null) - if (Prototype.Browser.IE) - while (SOGoResizableTable._stylesheet.styleSheet.rules.length) - SOGoResizableTable._stylesheet.styleSheet.removeRule(0); - else - while (SOGoResizableTable._stylesheet.firstChild) - SOGoResizableTable._stylesheet.removeChild(SOGoResizableTable._stylesheet.firstChild); - - if (relativeWidths) - this.ratios = relativeWidths; - var tableWidth = this.getWidth()/100; - var cells = $(this).down('tr').select('.resizable'); - for (i = 0; i < cells.length; i++) { - var cell = cells[i]; - var ratio = this.ratios.get(cell.id); - SOGoResizableTable._resize(this, $(cell), i, null, ratio*tableWidth); - } - }, - - computeColumnsWidths: function() { - this.ratios = new Hash(); - var tableWidth = 100/this.getWidth(); - var cells = $(this).down('tr').childElements(); - for (i = 0; i < cells.length; i++) { - var cell = cells[i]; - if (cell.hasClassName('resizable')) - this.ratios.set(cell.id, Math.round(cell.getWidth()*tableWidth)); - } - }, - - saveColumnsState: function() { - this.computeColumnsWidths(); - if (!$(document.body).hasClassName("popup")) { - var url = ApplicationBaseURL + "/saveColumnsState"; - var data = this.ratios; - var columns = data.keys(); - var params = "columns=" + columns.join(",") - + "&widths=" + columns.collect(function(c) { return data.get(c); }).join(","); - triggerAjaxRequest(url, - this.saveColumnsStateCallback, - null, - params, - { "Content-type": "application/x-www-form-urlencoded" }); - } - }, - - saveColumnsStateCallback: function(http) { - if (isHttpStatus204(http.status)) { - log ("ResizableTable.saveColumnsStateCallback() Columns state saved"); - } - else if (http.readyState == 4) { - log ("ResizableTable.saveColumnsStateCallback() Can't save columns state"); - } - } - -}; - -SOGoResizableTable = { - - _onHandle: false, - _cell: null, - _tbl: null, - _handle: null, - _stylesheet: null, - - resize: function(table, index, w) { - var cell; - if (typeof index === 'number') { - if (!table || (table.tagName && table.tagName !== "TABLE")) { return; } - table = $(table); - index = Math.min(table.rows[0].cells.length, index); - index = Math.max(1, index); - index -= 1; - cell = $(table.rows[0].cells[index]); - } - else { - cell = $(index); - table = table ? $(table) : cell.up('table'); - index = SOGoResizableTable.getCellIndex(cell); - } - - var cells = table.down('tr').childElements(); - var nextResizableCell = null; - for (var i = index + 1; i < cells.length; i++) { - var c = cells[i]; - if (c.hasClassName('resizable')) { - nextResizableCell = c; - break; - } - } - - var delta = SOGoResizableTable._resize(table, cell, index, nextResizableCell, w, false); - if (delta != 0 && nextResizableCell != null) { - var w = nextResizableCell.getWidth() - delta; - SOGoResizableTable._resize(table, nextResizableCell, i, null, w, true); - } - - table.saveColumnsState(); - }, - - _resize: function(table, cell, index, nextResizableCell, w, isAdjustment) { - var pad = 0; - if (!Prototype.Browser.WebKit) { - pad = parseInt(cell.getStyle('paddingLeft'),10) + parseInt(cell.getStyle('paddingRight'),10); - pad += parseInt(cell.getStyle('borderLeftWidth'),10) + parseInt(cell.getStyle('borderRightWidth'),10); - } - - var cells = table.down('tr').childElements(); - if ((index + 1) == cells.length) { - return 0; - } - - if (!isAdjustment && cell.getWidth() < w) { - if (nextResizableCell == null && (index + 2) == cells.length) - // The next cell is the last cell; respect its minimum width - // event if it's not resizable. - nextResizableCell = cells[index + 1]; - if (nextResizableCell != null) { - // Respect the minimum width of the next resizable cell. - var max = cells[index].getWidth() - + nextResizableCell.getWidth() - - parseInt(nextResizableCell.getStyle('minWidth')) - - pad; - w = Math.min(max, w); - } - } - - // Respect the minimum width of the cell. - w = Math.max(Math.round(w) - pad, parseInt(cell.getStyle('minWidth'))); - - var delta = w - cell.getWidth() + pad; - - var cssSelector = ' TABLE.' + $w(table.className).first() + ' .' + $w(cell.className).first(); - - if (SOGoResizableTable._stylesheet == null) { - SOGoResizableTable._stylesheet = document.createElement("style"); - SOGoResizableTable._stylesheet.type = "text/css"; - document.getElementsByTagName("head")[0].appendChild(SOGoResizableTable._stylesheet); - } - - if (SOGoResizableTable._stylesheet.styleSheet && SOGoResizableTable._stylesheet.styleSheet.addRule) { - // IE - SOGoResizableTable._stylesheet.styleSheet.addRule(cssSelector, - ' { width: ' + w + 'px; max-width: ' + w + 'px; }'); - } - else { - // Mozilla + Safari - SOGoResizableTable._stylesheet.appendChild(document.createTextNode(cssSelector + - ' { width: ' + w + 'px; max-width: ' + w + 'px; }')); - } - - return delta; - }, - - initDetect: function(e) { - var cell = Event.element(e); - if (cell.tagName != "TH") { return; } - Event.observe(cell, 'mousemove', SOGoResizableTable.detectHandle); - Event.observe(cell, 'mousedown', SOGoResizableTable.startResize); - }, - - detectHandle: function(e) { - var cell = Event.element(e); - if (SOGoResizableTable.pointerPos(cell, Event.pointerX(e), Event.pointerY(e))) { - cell.addClassName('resize-handle-active'); - SOGoResizableTable._onHandle = true; - } - else { - cell.removeClassName('resize-handle-active'); - SOGoResizableTable._onHandle = false; - } - }, - - killDetect: function(e) { - SOGoResizableTable._onHandle = false; - var cell = Event.element(e); - Event.stopObserving(cell, 'mousemove', SOGoResizableTable.detectHandle); - Event.stopObserving(cell, 'mousedown', SOGoResizableTable.startResize); - cell.removeClassName('resize-handle-active'); - }, - - startResize: function(e) { - if (!SOGoResizableTable._onHandle) { return; } - var cell = Event.element(e); - Event.stopObserving(cell, 'mousemove', SOGoResizableTable.detectHandle); - Event.stopObserving(cell, 'mousedown', SOGoResizableTable.startResize); - Event.stopObserving(cell, 'mouseout', SOGoResizableTable.killDetect); - SOGoResizableTable._cell = cell; - var table = cell.up('table'); - SOGoResizableTable._tbl = table; - SOGoResizableTable._handle = $(document.createElement('div')).addClassName('resize-handle').setStyle({ - 'top' : table.cumulativeOffset()[1] + 'px', - 'left' : Event.pointerX(e) + 'px', - 'height' : table.getHeight() + 'px', - 'max-height' : table.getHeight() + 'px' - }); - document.body.appendChild(SOGoResizableTable._handle); - - Event.observe(document, 'mousemove', SOGoResizableTable.drag); - Event.observe(document, 'mouseup', SOGoResizableTable.endResize); - Event.stop(e); - }, - - endResize: function(e) { - var cell = SOGoResizableTable._cell; - if (!cell) { return; } - SOGoResizableTable.resize(null, cell, (Event.pointerX(e) - cell.cumulativeOffset()[0])); - Event.stopObserving(document, 'mousemove', SOGoResizableTable.drag); - Event.stopObserving(document, 'mouseup', SOGoResizableTable.endResize); - $$('div.resize-handle').each(function(elm){ - document.body.removeChild(elm); - }); - Event.observe(cell, 'mouseout', SOGoResizableTable.killDetect); - SOGoResizableTable._tbl = SOGoResizableTable._handle = SOGoResizableTable._cell = null; - Event.stop(e); - }, - - drag: function(e) { - e = $(e); - if (SOGoResizableTable._handle === null) { - try { - SOGoResizableTable.resize(SOGoResizableTable._tbl, SOGoResizableTable._cell, (Event.pointerX(e) - SOGoResizableTable._cell.cumulativeOffset()[0])); - } - catch(e) {} - } - else { - SOGoResizableTable._handle.setStyle({'left' : Event.pointerX(e) + 'px'}); - } - return false; - }, - - pointerPos: function(element, x, y) { - var offset = $(element).cumulativeOffset(); - return (y >= offset[1] && - y < offset[1] + element.offsetHeight && - x >= offset[0] + element.offsetWidth - 5 && - x < offset[0] + element.offsetWidth); - }, - - getCellIndex : function(cell) { - return $A(cell.parentNode.cells).indexOf(cell); - } - -}; \ No newline at end of file diff --git a/UI/WebServerResources/SOGoRootPage.css b/UI/WebServerResources/SOGoRootPage.css deleted file mode 100644 index a8aa75659..000000000 --- a/UI/WebServerResources/SOGoRootPage.css +++ /dev/null @@ -1,138 +0,0 @@ -BODY -{ background-color: #E6E7E6; - text-align: center; } - -IMG#preparedAnimation -{ width: 0px; - height: 0px; } - -DIV.linkbanner A#about -{ float: right; - margin: 0px; - padding: 0px .5em; } - -DIV#aboutBox -{ position: absolute; - z-index: 1000; - left: 0px; - top: 30px; - width: 100%; - text-align: center; } - -DIV#aboutBox DIV -{ background-color: #fff; - border: 1px solid #222; - margin: auto; - padding-bottom: 20px; - width: 550px; } - -DIV#aboutBox SPAN.buildDate -{ color: #666; } - -A#aboutClose -{ position: relative; - margin-right: 10px; - top: -10px; } - -A, -A:link, -A:visited -{ color: #54b948; } - -DIV A.button -{ color: #000; } - -DIV#aboutBox P.logo -{ background-color: #222; - margin-top: 0; - margin-bottom: 10px; } - -DIV#aboutBox P.scroll -{ border: 1px solid #222; - height: 120px; - margin: auto; - padding: 5px; - width: 350px; - text-align: left; - overflow-y: auto; } - -DIV#aboutBox P.links -{ margin: 0 0 20px 0; } - -DIV.linkbanner -{ text-align: right; } - -DIV.linkbanner A -{ padding-right: .5em; } - -DIV#loginScreen -{ clear: both; - margin: 0px auto; - padding-top: 5em; - border: 2px solid transparent; - text-align: center; -} - -DIV#loginScreen TABLE -{ margin: auto; } - -DIV#loginScreen TABLE TD -{ text-align: right; } - -DIV#loginScreen TABLE TD#loginCell -{ border-left: 1px solid #fff; - padding-left: 10px; - vertical-align: top; } - -LABEL -{ display: inline-block; - padding: 10px; } - -DIV#loginScreen LABEL -{ display: block; - padding: 5px; } - -#animation -{ margin: 0px auto; - padding: 0px; } - -IMG#splash -{ border: 0; - margin: 0px; - padding: 0px 0px 0px 0px; } - -DIV#loginScreen INPUT.textField -{ width: 187px; } - -DIV#loginScreen A#submit, -DIV#loginScreen A#submit SPAN -{ color: #535D6D; } - -IMG#progressIndicator -{ width: 16px; - height: 16px; - margin-top: 20px; - margin-left: 5px; } - -#errorMessage -{ color: #f00; - width: 400px; - margin: 0px auto; - text-align: center; } - -P.browser -{ background-color: #fff; - border-top: 1px solid #888; - border-left: 1px solid #888; - border-right: 1px solid #eee; - border-bottom: 1px solid #eee; - line-height: 32px; - padding-right: 5px; } - -P.browser IMG -{ padding: 0 2px; - margin: 0; - vertical-align: middle; } - -#passwordChangeDialog INPUT -{ width: 150px; } diff --git a/UI/WebServerResources/SOGoRootPage.js b/UI/WebServerResources/SOGoRootPage.js deleted file mode 100644 index a2300ee62..000000000 --- a/UI/WebServerResources/SOGoRootPage.js +++ /dev/null @@ -1,350 +0,0 @@ -/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -var dialogs = {}; - -function initLogin() { - var date = new Date(); - date.setTime(date.getTime() - 86400000); - - var href = $("connectForm").action.split("/"); - var appName = href[href.length-2]; - - document.cookie = ("0xHIGHFLYxSOGo=discarded" - + "; expires=" + date.toGMTString() - + "; path=/" + appName + "/"); - - var about = $("about"); - if (about) { - about.observe("click", function(event) { - jQuery('#aboutBox').slideToggle('fast'); - event.stop(); }); - var aboutClose = $("aboutClose"); - aboutClose.observe("click", function(event) { - jQuery('#aboutBox').slideUp('fast'); - event.stop() }); - } - - var submit = $("submit"); - submit.observe("click", onLoginClick); - - var userName = $("userName"); - userName.observe("keydown", onFieldKeyDown); - - var passw = $("password"); - passw.observe("keydown", onFieldKeyDown); - - var image = $("preparedAnimation"); - image.parentNode.removeChild(image); - - var submitBtn = $("submit"); - submitBtn.disabled = false; - - if (userName.value.empty()) - userName.focus(); - else - passw.focus(); -} - -function onFieldKeyDown(event) { - if (event.keyCode == Event.KEY_RETURN) { - if ($("password").value.length > 0 - && $("userName").value.length > 0) - return onLoginClick(event); - else - Event.stop(event); - } else if (IsCharacterKey(event.keyCode) - || event.keyCode == Event.KEY_BACKSPACE) { - SetLogMessage("errorMessage", null); - } -} - -function onLoginClick(event) { - var userNameField = $("userName"); - var userName = userNameField.value; - var password = $("password").value; - var language = $("language"); - var domain = $("domain"); - - SetLogMessage("errorMessage"); - - if (userName.length > 0 && password.length > 0) { - this.disabled = true; - startAnimation($("animation")); - - if (typeof(loginSuffix) != "undefined" - && loginSuffix.length > 0 - && !userName.endsWith(loginSuffix)) - userName += loginSuffix; - - var url = $("connectForm").getAttribute("action"); - var parameters = ("userName=" + encodeURIComponent(userName) - + "&password=" + encodeURIComponent(password)); - if (language) - parameters += ((language.value == "WONoSelectionString") - ? "" - : ("&language=" + language.value)); - if (domain) - parameters += "&domain=" + domain.value; - var rememberLogin = $("rememberLogin"); - if (rememberLogin && rememberLogin.checked) - parameters += "&rememberLogin=1"; - - /// Discarded as it seems to create a cookie for nothing. To discard - // a cookie in JS, have a look here: http://www.quirksmode.org/js/cookies.html - //document.cookie = "";\ - triggerAjaxRequest(url, onLoginCallback, null, (parameters), - { "Content-type": "application/x-www-form-urlencoded", - "Content-length": parameters.length, - "Connection": "close" }); - } - else - userNameField.focus(); - - preventDefault(event); -} - -function onLoginCallback(http) { - if (http.readyState == 4) { - var submitBtn = $("submit"); - - if (http.status == 200) { - // Make sure browser's cookies are enabled - var loginCookie = readLoginCookie(); - - if (!loginCookie) { - SetLogMessage("errorMessage", _("cookiesNotEnabled")); - submitBtn.disabled = false; - return; - } - - var jsonResponse = http.responseText.evalJSON(false); - if (jsonResponse - && typeof(jsonResponse["expire"]) != "undefined" - && typeof(jsonResponse["grace"]) != "undefined") { - - if (jsonResponse["expire"] < 0 && jsonResponse["grace"] > 0) - showPasswordDialog("grace", createPasswordGraceDialog, jsonResponse["grace"]); - else if (jsonResponse["expire"] > 0 && jsonResponse["grace"] == -1) - showPasswordDialog("expiration", createPasswordExpirationDialog, jsonResponse["expire"]); - else { - redirectToUserPage(); - } - } - else - redirectToUserPage(); - } - else { - if (http.status == 403 - && http.getResponseHeader("content-type") - == "application/json") { - var jsonResponse = http.responseText.evalJSON(false); - handlePasswordError(jsonResponse); - } else { - SetLogMessage("errorMessage", _("An unhandled error occurred.")); - } - submitBtn.disabled = false; - } - } -} - -function redirectToUserPage() { - // Redirect to proper page - var userName = $("userName").value; - var domain = $("domain"); - if (domain) - userName += '@' + domain.value; - else if (typeof(loginSuffix) != "undefined" - && loginSuffix.length > 0 - && !userName.endsWith(loginSuffix)) - userName += loginSuffix; - var address = "" + window.location.href; - var baseAddress = ApplicationBaseURL + "/" + encodeURIComponent(userName); - var altBaseAddress; - if (baseAddress[0] == "/") { - var parts = address.split("/"); - var hostpart = parts[2]; - var protocol = parts[0]; - baseAddress = protocol + "//" + hostpart + baseAddress; - } - var altBaseAddress; - var parts = baseAddress.split("/"); - parts.splice(3, 0); - altBaseAddress = parts.join("/"); - - var newAddress; - if ((address.startsWith(baseAddress) - || address.startsWith(altBaseAddress)) - && !address.endsWith("/logoff")) - newAddress = address; - else - newAddress = baseAddress; - window.location.href = newAddress; -} - -function handlePasswordError(jsonResponse) { - var perr = jsonResponse["LDAPPasswordPolicyError"]; - if (perr == PolicyNoError) { - SetLogMessage("errorMessage", _("Wrong username or password.")); - } else if (perr == PolicyAccountLocked) { - SetLogMessage("errorMessage", - _("Your account was locked due to too many failed attempts.")); - } else if (perr == PolicyChangeAfterReset) { - showPasswordDialog("change", createPasswordChangeDialog, 5); - } else if (perr == PolicyPasswordExpired) { - SetLogMessage("errorMessage", - _("Your account was locked due to an expired password.")); - } - else - SetLogMessage("errorMessage", - _("Login failed due to unhandled error case: " + perr)); -} - -function showPasswordDialog(dialogType, constructor, parameters) { - var dialog = dialogs[dialogType]; - if (!dialog) { - dialog = constructor(parameters); - var form = $("connectForm"); - form.appendChild(dialog); - dialogs[dialogType] = dialog; - } - var password = $("password"); - var offsets = password.positionedOffset(); - dialog.show(); - var top = offsets[1] - 2; - var left = offsets[0] + 10 - dialog.clientWidth; - dialog.setStyle({ "top": top + "px", "left": left + "px"}); -} - -function createPasswordChangeDialog() { - var fields = createElement("p"); - createElement("span", "passwordError", null, null, null, fields); - - var fieldNames = [ "newPassword", "newPassword2" ]; - var fieldLabels = [ _("New password:"), _("Confirmation:") ]; - for (var i = 0; i < fieldNames.length; i++) { - var label = createElement("label", null, null, null, null, fields); - label.appendChild(document.createTextNode(fieldLabels[i])); - createElement("input", fieldNames[i], "textField", - { "name": fieldNames[i], "type": "password" }, - null, label); - createElement("br", null, null, null, null, fields); - } - - var button = createButton("passwordOKButton", _("OK"), passwordDialogOK); - button.addClassName("actionButton"); - fields.appendChild(button); - fields.appendChild(document.createTextNode(" ")); - button = createButton("passwordCancelButton", - _("Cancel"), passwordDialogCancel); - fields.appendChild(button); - - var dialog = createDialog("passwordChangeDialog", - _("Change your Password"), - _("Your password has expired, please enter a new one below:"), - fields, - "right"); - - return dialog; -} - -function passwordDialogOK(event) { - var field = $("newPassword"); - var confirmationField = $("newPassword2"); - if (field && confirmationField) { - var newPassword = field.value; - if (newPassword == confirmationField.value) { - if (newPassword.length > 0) { - var userName = $("userName"); - var password = $("password"); - var policy = new PasswordPolicy(userName.value, - password.value); - policy.setCallbacks(onPasswordChangeSuccess, - onPasswordChangeFailure); - policy.changePassword(newPassword); - } - else - SetLogMessage("passwordError", - _("Password must not be empty.")); - } - else { - SetLogMessage("passwordError", - _("The passwords do not match. Please try again.")); - field.focus(); - field.select(); - } - } - event.stop(); -} - -function onPasswordChangeSuccess() { - SetLogMessage("passwordError", _("Please wait...")); - redirectToUserPage(); -} - -function onPasswordChangeFailure(code, message) { - SetLogMessage("passwordError", message); -} - -function passwordDialogCancel(event) { - var dialog = $("passwordChangeDialog"); - dialog.hide(); - event.stop(); -} - -function createPasswordGraceDialog(tries) { - var button = createButton("graceOKButton", _("OK")); - button.observe("click", passwordGraceDialogOK); - button.addClassName("actionButton"); - - return createDialog("passwordGraceDialog", - _("Password Grace Period"), - _("You have %{0} logins remaining before your account is locked. Please change your password in the preference dialog.").formatted(tries), - button, - "right"); -} - -function passwordGraceDialogOK(event) { - var dialog = $("passwordGraceDialog"); - dialog.hide(); - event.stop(); - redirectToUserPage(); -} - -function createPasswordExpirationDialog(expire) { - var button = createButton("expirationOKButton", _("OK")); - button.observe("click", passwordExpirationDialogOK); - button.addClassName("actionButton"); - - var value, string; - - if (expire > 86400) { - value = Math.round(expire/86400); - string = _("days"); - } - else if (expire > 3600) { - value = Math.round(expire/3600); - string = _("hours"); - } - else if (expire > 60) { - value = Math.round(expire/60); - string = _("minutes"); - } - else { - value = expire; - string = _("seconds"); - } - return createDialog("passwordExpirationDialog", - _("Password about to expire"), - _("Your password is going to expire in %{0} %{1}.").formatted(value, string), - button, - "right"); -} - -function passwordExpirationDialogOK(event) { - var dialog = $("passwordExpirationDialog"); - dialog.hide(); - event.stop(); - redirectToUserPage(); -} - -document.observe("dom:loaded", initLogin); diff --git a/UI/WebServerResources/SOGoTabsController.js b/UI/WebServerResources/SOGoTabsController.js deleted file mode 100644 index b523836b3..000000000 --- a/UI/WebServerResources/SOGoTabsController.js +++ /dev/null @@ -1,169 +0,0 @@ -/* -*- Mode: java; tab-width: 2; c-label-minimum-indentation: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -function SOGoTabsController() { -} - -SOGoTabsController.prototype = { - container: null, - firstTab: null, - activeTab: null, - - list: null, - offset: 0, - - createScrollButtons: function STC_createScrollButtons() { - var scrollToolbar = createElement("div", null, "scrollToolbar"); - scrollToolbar.hide(); - var lnk = createElement("a", null, - [ "leftScrollButton", - "scrollButton", "smallToolbarButton"], - { href: "#" }, - null, scrollToolbar); - var span = createElement("span"); - lnk.appendChild(span); - span.appendChild(document.createTextNode("<")); - this.onScrollLeftBound = this.onScrollLeft.bindAsEventListener(this); - lnk.observe("click", this.onScrollLeftBound, false); - - var lnk = createElement("a", null, - [ "rightScrollButton", - "scrollButton", "smallToolbarButton"], - { href: "#" }, - null, scrollToolbar); - var span = createElement("span"); - lnk.appendChild(span); - span.appendChild(document.createTextNode(">")); - this.onScrollRightBound = this.onScrollRight.bindAsEventListener(this); - lnk.observe("click", this.onScrollRightBound, false); - - this.container.appendChild(scrollToolbar); - this.scrollToolbar = scrollToolbar; - }, - - onScrollLeft: function(event) { - if (this.offset < 0) { - var offset = this.offset + 20; - if (offset > 0) { - offset = 0; - } - this.list.setStyle("margin-left: " + offset + "px;"); - // log("offset: " + offset); - this.offset = offset; - } - event.stop(); - }, - onScrollRight: function(event) { - if (this.offset > this.minOffset) { - var offset = this.offset - 20; - if (offset < this.minOffset) { - offset = this.minOffset; - } - this.list.setStyle("margin-left: " + offset + "px;"); - // log("offset: " + offset); - this.offset = offset; - } - event.stop(); - }, - - attachToTabsContainer: function STC_attachToTabsContainer(container) { - this.container = container; - container.controller = this; - this.onTabMouseDownBound = this.onTabMouseDown.bindAsEventListener(this); - this.onTabClickBound = this.onTabClick.bindAsEventListener(this); - - var list = container.childNodesWithTag("ul"); - if (list.length > 0) { - this.list = $(list[0]); - var nodes = this.list.childNodesWithTag("li"); - if (nodes.length > 0) { - this.firstTab = $(nodes[0]); - for (var i = 0; i < nodes.length; i++) { - var currentNode = $(nodes[i]); - currentNode.observe("mousedown", this.onTabMouseDownBound, false); - currentNode.observe("click", this.onTabClickBound, false); - if (currentNode.hasClassName("active")) - this.activeTab = currentNode; - //$(currentNode.getAttribute("target")).hide(); - } - - this.firstTab.addClassName("first"); - if (this.activeTab == null) { - this.activeTab = this.firstTab; - this.activeTab.addClassName("active"); - } - var last = nodes.length - 1; - this.lastTab = $(nodes[last]); - - var target = $(this.activeTab.getAttribute("target")); - target.addClassName("active"); - } - this.onWindowResizeBound = this.onWindowResize.bindAsEventListener(this); - Event.observe(window, "resize", this.onWindowResizeBound, false); - } - - this.createScrollButtons(); - this.recomputeMinOffset(); - }, - - onWindowResize: function STC_onWindowResize(event) { - this.recomputeMinOffset(); - }, - - recomputeMinOffset: function() { - var tabsWidth = (this.lastTab.offsetLeft + this.lastTab.clientWidth - - this.firstTab.offsetLeft - + 4); - this.minOffset = (this.container.clientWidth - tabsWidth - 40); - if (this.minOffset < -40) { - this.scrollToolbar.show(); - } else { - this.scrollToolbar.hide(); - if (this.offset < 0) { - this.list.setStyle("margin-left: 0px;"); - this.offset = 0; - } - } - }, - - onTabMouseDown: function STC_onTabMouseDown(event) { - event.stop(); - }, - - onTabClick: function STC_onTabClick(event) { - var clickedTab = getTarget(event); - if (clickedTab.nodeType == 1) { - while (clickedTab.tagName.toLowerCase() != "li") { - clickedTab = $(clickedTab.parentNode); - } - var content = $(clickedTab.getAttribute("target")); - var oldContent = $(this.activeTab.getAttribute("target")); - oldContent.removeClassName("active"); - this.activeTab.removeClassName("active"); // previous LI - this.activeTab = $(clickedTab); - this.activeTab.addClassName("active"); // current LI - content.addClassName("active"); - this.activeTab.fire("tabs:click", content.id); - - content.select('.tabsContainer').each(function(c) { - // When the tab contains an inner tabs container, - // show or hide the tabs navigation arrows of this - // inner container - c.controller.recomputeMinOffset(); - }); - - // Prototype alternative - - //oldContent.removeClassName("active"); - //container.activeTab.removeClassName("active"); // previous LI - //container.activeTab = node; - //container.activeTab.addClassName("active"); // current LI - - //container.activeTab.hide(); - //oldContent.hide(); - //content.show(); - - //container.activeTab = node; - //container.activeTab.show(); - } - } -} diff --git a/UI/WebServerResources/SOGoTimePicker.css b/UI/WebServerResources/SOGoTimePicker.css deleted file mode 100644 index b69a4e4d8..000000000 --- a/UI/WebServerResources/SOGoTimePicker.css +++ /dev/null @@ -1,134 +0,0 @@ -.SOGoTimePickerMenu -{ position: absolute; - z-index: 1000; - background-color: #fff; - border: 1px solid #ccc; - border: 1px solid rgba(0, 0, 0, 0.2); - -webkit-border-radius: 5px; - -moz-border-radius: 5px; - border-radius: 5px; - -webkit-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); - -moz-box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); - box-shadow: 0 5px 10px rgba(0, 0, 0, 0.2); - -webkit-background-clip: padding-box; - -moz-background-clip: padding; - background-clip: padding-box; - *border-right-width: 2px; - *border-bottom-width: 2px; - color: #000; - font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; - font-size: 11px; - line-height: 18px; - text-align: center; } - -.SOGoTimePickerMenu > DIV -{ padding: 5px; } - -.SOGoTimePickerMenu.bellow > DIV:before { - content: ''; - display: inline-block; - border-left: 7px solid transparent; - border-right: 7px solid transparent; - border-bottom: 7px solid #ccc; - border-bottom-color: rgba(0, 0, 0, 0.2); - position: absolute; - top: -7px; - left: 6px; - left: 35px; -} -.SOGoTimePickerMenu.bellow > DIV:after { - content: ''; - display: inline-block; - border-left: 6px solid transparent; - border-right: 6px solid transparent; - border-bottom: 6px solid #ffffff; - position: absolute; - top: -6px; - left: 7px; - left: 36px; -} - -.SOGoTimePickerMenu.above > DIV:before { - content: ''; - display: inline-block; - border-left: 7px solid transparent; - border-right: 7px solid transparent; - border-top: 7px solid #ccc; - border-top-color: rgba(0, 0, 0, 0.2); - position: absolute; - bottom: -7px; - right: 35px; -} -.SOGoTimePickerMenu.above > DIV:after { - content: ''; - display: inline-block; - border-left: 6px solid transparent; - border-right: 6px solid transparent; - border-top: 6px solid #ffffff; - position: absolute; - bottom: -6px; - right: 36px; -} - -.SOGoTimePickerMenu .hours, -.SOGoTimePickerMenu .minutes, -.SOGoTimePickerMenu .button -{ clear: both; /* Opera fix */ } - -.SOGoTimePickerMenu SPAN DIV -{ padding: 2px; } - -.SOGoTimePickerMenu DIV.hours SPAN -{ float: left; - width: 25px; } - -.SOGoTimePickerMenu DIV.hours SPAN DIV -{ -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; } - -.SOGoTimePickerMenu DIV.min5 SPAN -{ float: left; - width: 50px; } - -.SOGoTimePickerMenu DIV.min1 SPAN -{ float: left; - width: 60px; } - -.SOGoTimePickerMenu DIV.minutes SPAN DIV -{ -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; } - -.SOGoTimePickerMenu DIV.hours SPAN DIV:hover, -.SOGoTimePickerMenu DIV.minutes SPAN DIV:hover -{ background-color: #eee; - color: #333; - cursor: pointer; } - -.SOGoTimePickerMenu DIV.hours SPAN DIV.selected, -.SOGoTimePickerMenu DIV.minutes SPAN DIV.selected, -.SOGoTimePickerMenu DIV.hours SPAN DIV.selected:hover, -.SOGoTimePickerMenu DIV.minutes SPAN DIV.selected:hover -{ background-color: #006dcc; - background-image: -moz-linear-gradient(top, #0088cc, #0044cc); - background-image: -ms-linear-gradient(top, #0088cc, #0044cc); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0044cc)); - background-image: -webkit-linear-gradient(top, #0088cc, #0044cc); - background-image: -o-linear-gradient(top, #0088cc, #0044cc); - background-image: linear-gradient(top, #0088cc, #0044cc); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0088cc', endColorstr='#0044cc', GradientType=0); - border-color: #0044cc #0044cc #002a80; - border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25); - filter: progid:dximagetransform.microsoft.gradient(enabled=false); - color: #fff; - text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.25); } - -.SOGoTimePickerMenu HR -{ clear: both; - height: 0px; - margin: 0px; - padding: 0px; - color: #fff; - border: 0px; } \ No newline at end of file diff --git a/UI/WebServerResources/SOGoTimePicker.js b/UI/WebServerResources/SOGoTimePicker.js deleted file mode 100644 index 18efc19cc..000000000 --- a/UI/WebServerResources/SOGoTimePicker.js +++ /dev/null @@ -1,241 +0,0 @@ -/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ - -/* - * Time picker widget interface to be added to an INPUT (this!) - * - * Available events: - * time:change -- fired once the value of the input has changed - * - */ -var SOGoTimePickerInterface = { - - div: null, - extendedButton: null, - - pos: 'bellow', - - minutes: '00', - hours: '00', - extended: false, - - mouseInside: false, - disposeHandler: null, - - bind: function () { - // Build widget - this.div = new Element("div", {'class': 'SOGoTimePickerMenu ' + this.pos}); - this.div.hide(); - document.body.appendChild(this.div); - var inner = new Element("div"); - this.div.appendChild(inner); - - var hours = new Element("div", {'class': 'hours'}); - inner.appendChild(hours); - for (var i = 0; i < 24; i++) { - var v = (i < 10)? '0' + i : i; - var content = new Element("div", {'class': 'SOGoTimePickerHour_'+v}).update(v); - content.on("click", this.onHourClick.bindAsEventListener(this)); - var span = new Element("span", {'class': 'cell'}); - span.appendChild(content); - hours.appendChild(span); - if (i == 11) { - hours = new Element("div", {'class': 'hours'}); - inner.appendChild(hours); - } - } - - var minutes = new Element("div", {'class': 'minutes min5'}); - inner.appendChild(minutes); - for (var i = 0; i < 60; i += 5) { - var v = (i < 10)? '0' + i : i; - var content = new Element("div", {'class': 'SOGoTimePickerMinute_'+v}).update(":"+v); - content.on("click", this.onMinuteClick.bindAsEventListener(this)); - var span = new Element("span", {'class': 'cell'}); - span.appendChild(content); - minutes.appendChild(span); - if (i == 25) { - minutes = new Element("div", {'class': 'minutes min5'}); - inner.appendChild(minutes); - } - } - - var minutes = new Element("div", {'class': 'minutes min1'}); - minutes.hide(); - inner.appendChild(minutes); - for (var i = 0; i < 60;) { - var v = (i < 10)? '0' + i : i; - var content = new Element("div", {'class': 'SOGoTimePickerMinute_'+v}).update(":"+v); - content.on("click", this.onMinuteClick.bindAsEventListener(this)); - var span = new Element("span", {'class': 'cell'}); - span.appendChild(content); - minutes.appendChild(span); - i++; - if (i % 5 == 0) { - minutes = new Element("div", {'class': 'minutes min1'}); - minutes.hide(); - inner.appendChild(minutes); - } - } - - var a = new Element("a", {'class': 'button'}); - a.on("click", this.toggleExtendedView.bindAsEventListener(this)); - this.extendedButton = new Element("span").update('>>'); - a.appendChild(this.extendedButton); - inner.appendChild(a); - - inner.appendChild(new Element("hr")); - - // Compute position - this.position(); - - // Register observers - this.on("click", this.toggleVisibility.bindAsEventListener(this)); - this.on("change", this.onChange.bindAsEventListener(this)); - this.on("keydown", this.onKeydown.bindAsEventListener(this)); - this.div.on("mouseenter", this.onEnter.bindAsEventListener(this)); - this.div.on("mouseleave", this.onLeave.bindAsEventListener(this)); - this.disposeHandler = $(document.body).on("click", this.onDispose.bindAsEventListener(this)); - this.disposeHandler.stop(); - - // Apply current input value if defined - this.onChange(); - }, - - setPosition: function (newPos) { - if (newPos == 'bellow' || newPos == 'above') { - this.div.removeClassName(this.pos); - this.div.addClassName(newPos); - this.pos = newPos; - this.position(); - } - }, - - position: function () { - var inputPosition = this.cumulativeOffset(); - var inputDimensions = this.getDimensions(); - var divWidth = this.div.getWidth(); - var windowWidth = window.width(); - var left = inputPosition[0]; - var arrow = -1000 + inputDimensions['width'] - 10; - if (left + divWidth > windowWidth) { - left = windowWidth - divWidth - 4; - arrow += (inputPosition[0] - left); - } - var top = inputPosition[1]; - if (this.pos == 'bellow') - top += 22; - else - top -= this.div.getHeight(); - this.div.setStyle({ top: top+"px", - left: left+"px", - backgroundPosition: arrow+'px top'}); - }, - - onHourClick: function (event) { - this.div.down('.SOGoTimePickerHour_' + this.hours).removeClassName("selected"); - this.hours = Event.findElement(event).className.substring(19); - this.div.down('.SOGoTimePickerHour_' + this.hours).addClassName("selected"); - this._updateValue(); - }, - - onMinuteClick: function (event) { - this.div.select('.SOGoTimePickerMinute_' + this.minutes).each(function(e) { e.removeClassName("selected") }); - this.minutes = Event.findElement(event).className.substring(21); - this.div.select('.SOGoTimePickerMinute_' + this.minutes).each(function(e) { e.addClassName("selected") }); - this._updateValue(); - this.div.hide(); - }, - - toggleExtendedView: function (event) { - this.extended = !this.extended; - if (this.extended) { - this.extendedButton.update('<<'); - this.div.select("DIV.min5").invoke('hide'); - this.div.select("DIV.min1").invoke('show'); - } - else { - this.extendedButton.update('>>'); - this.div.select("DIV.min1").invoke('hide'); - this.div.select("DIV.min5").invoke('show'); - } - if (this.pos == 'above') - this.position(); - }, - - toggleVisibility: function (event) { - if (this.div.visible()) - this.div.hide(); - else { - $$('DIV.SOGoTimePickerMenu').invoke('hide'); - this.div.show(); - this.disposeHandler.start(); - } - Event.stop(event); - }, - - onChange: function (event) { - this.div.down('.SOGoTimePickerHour_' + this.hours).removeClassName("selected"); - this.div.select('.SOGoTimePickerMinute_' + this.minutes).each(function(e) { e.removeClassName("selected") }); - - var matches = this.value.match(/([0-9]{1,2}):?([0-9]{2})/); - if (matches) { - this.hours = matches[1]; - this.minutes = matches[2] || '0'; - if (parseInt(this.hours, 10) > 23) this.hours = 23; - if (parseInt(this.minutes, 10) > 59) this.minutes = 59; - if (this.minutes % 5 == 0) { - if (this.extended) - this.toggleExtendedView(); - } - else if (!this.extended) - this.toggleExtendedView(); - - if (this.hours.length < 2) this.hours = '0' + this.hours; - if (this.minutes.length < 2) this.minutes = '0' + this.minutes; - this.div.down('.SOGoTimePickerHour_' + this.hours).addClassName("selected"); - this.div.select('.SOGoTimePickerMinute_' + this.minutes).each(function(e) { e.addClassName("selected") }); - } - - this._updateValue(true); - }, - - onKeydown: function (event) { - this.div.hide(); - this.disposeHandler.stop(); - if (event.metaKey == 1 || event.ctrlKey == 1 || - event.keyCode == Event.KEY_TAB || - event.keyCode == Event.KEY_BACKSPACE) - return true; - if (event.keyCode > 57 && // ignore non-numeric characters - (event.keyCode < 96 || event.keyCode > 105) && // but allow entries from keypad - event.keyCode != 186 && event.keyCode != 59 || - (event.keyCode == 186 || event.keyCode == 59) && this.value.indexOf(":") >= 0) - Event.stop(event); - }, - - onEnter: function (event) { - this.mouseInside = true; - this.disposeHandler.stop(); - }, - - onLeave: function (event) { - this.mouseInside = false; - this.disposeHandler.start(); - }, - - onDispose: function (event) { - if (!this.mouseInside) { - this.div.hide(); - this.disposeHandler.stop(); - Event.stop(event); - } - }, - - _updateValue: function (force) { - var value = this.hours + ':' + this.minutes; - if (force || value != this.value) { - this.value = value; - this.fire("time:change"); - } - } -}; diff --git a/UI/WebServerResources/SchedulerUI.css b/UI/WebServerResources/SchedulerUI.css deleted file mode 100644 index 6a03ffbc0..000000000 --- a/UI/WebServerResources/SchedulerUI.css +++ /dev/null @@ -1,1562 +0,0 @@ -DIV#leftPanel -{ position: absolute; - top: 80px; - left: 0px; - width: 19.25em; - bottom: 0px; - background-color: #CCDDEC; - overflow: auto; - overflow-x: hidden; } - -DIV#schedulerTabs -{ position: absolute; - top: 4px; - left: 1px; - right: 0px; - height: 186px; } - -DIV#schedulerTabs .tabs -{ right: 5px; } - -DIV#schedulerTabs .tab -{ left: 0px; - right: 0px; } - -DIV#calendarSelectorButtons -{ padding-left: 6px; } - -DIV.colorBox -{ display: inline-block; } - -TD DIV.colorBox, TD DIV.colorBox:hover -{ border-color: #fff; } - -UL#calendarList -{ cursor: default; - clear: left; - margin: 0px; - padding: 0px; - list-style-type: none; - list-style-image: none; - -moz-user-select: none; - -khtml-user-select: none; } - -UL#calendarList LI -{ cursor: pointer; - width: 100%; - white-space: nowrap; - line-height: 2em; - padding-left: 10px; } - -#calendarList .badge -{ margin-left: 4px; } - -#tasksList .duelater, -#tasksList .duetoday, -#tasksList .overdue -{ font-weight: bold; } - -#tasksList .overdue, -#tasksList .important -{ color: #f00 !important; } - -#tasksList .low -{ color: #666 !important; } - -#tasksList .duetoday -{ color: #00f !important; } - -#tasksList .completed span -{ text-decoration: line-through; - color: #000; } - -#tasksList .important SPAN -{ background-image: url(important.png); - background-repeat: no-repeat; - background-position: 3px 2px; - padding-left: 10px; -} -#tasksList SPAN -{ padding-left: 2px; } - -#tasksList ._selected.overdue -{ color: #fff !important; - background-color: #f00 !important; } - -#tasksList ._selected.duetoday -{ color: #fff !important; - background-color: #00f !important; } - -#tasksList ._selected.duelater, -#tasksList ._selected.completed -{ color: #fff !important; - background-color: #9ABCD8 !important; } - -DIV#rightPanel -{ position: absolute; - top: 80px; - left: 19.25em; - right: 0px; - bottom: 0px; - margin-left: 5px; - overflow: hidden; } - -/* top lists in tabs */ -DIV#eventsListView, -DIV#tasksListView -{ cursor: default; - background-color: #FFFFFF; - overflow: hidden; - overflow-y: auto; } - -DIV#calendarView -{ position: absolute; - background-color: #fff; - top: 18em; - margin-top: 5px; - bottom: 0px; - width: 100%; - border-top: 1px solid #aaa; - border-left: 1px solid #aaa; - -moz-user-select: none; - -khtml-user-select: none; } - -DIV#calendarView A -{ text-decoration: none; - font: inherit; - color: inherit; } - -#verticalDragHandle -{ cursor: e-resize; - border: 0px; - top: 81px; - bottom: 0px; - left: 19.25em; - width: 5px; } - -#rightDragHandle -{ cursor: n-resize; - top: 18em; - left: 0px; - right: 0px; - height: 5px; } - -DIV#dateSelectorView -{ overflow: hidden; } - -#dateSelector -{ margin: 0px auto; - background-color: #fff; - border-top: 1px solid #909090 !important; - border-left: 1px solid #FFFFFF !important; - border-bottom: 1px solid #909090 !important; - border-right: 1px solid #909090 !important; } - -#dateSelector > .header -{ background-color: #efefef; - width: 100%; - white-space: nowrap; - vertical-align: middle; - text-align: center; - padding: .2em 0px; - margin: 0px; - border: 0px; } - -#dateSelector > .header #leftArrow -{ float: left; - margin-top: 3px; } - -#dateSelector > .header #rightArrow -{ float: right; - margin-top: 3px; - margin-right: 2px; } - -#dateSelector > .header SPAN -{ cursor: default; - font-size: medium; - vertical-align: middle; - font-weight: bold; - border: 1px solid transparent; } - -#dateSelector > .header SPAN:hover -{ border-left: 1px solid #fff; - border-top: 1px solid #fff; - border-right: 1px solid #ccc; - border-bottom: 1px solid #ccc; } - -#dateSelector .dayOfWeek -{ color: #00f; } - -#dateSelector TABLE, -#dateSelector TABLE TABLE -{ border-collapse: collapse; - text-align: center; - margin: 0px auto; - width: 100%; } - -TABLE#dateSelectorTable -{ margin-bottom: 5px; } - -TABLE#dateSelectorTable TD TABLE TD -{ width: 5px; /* temp hack */ } - -TABLE#dateSelectorTable TD TABLE TD.activeDay, -TABLE#dateSelectorTable TD TABLE TD.inactiveDay, -TABLE#dateSelectorTable TD TABLE TD.dayOfToday -{ width: 100%; } - -#dateSelector TABLE TABLE TD.activeDay, -#dateSelector TABLE TABLE TD.inactiveDay, -#dateSelector TABLE TABLE TD.dayOfToday -{ cursor: pointer; - margin: 0px; - padding: 0px; - border: 1px solid #fff; } - -#dateSelectorTable TABLE TD.activeDay:hover, -#dateSelectorTable TABLE TD.inactiveDay:hover -{ border: 1px solid #CCDDEC; } - -#dateSelectorTable TABLE TD.activeDay:active, -#dateSelectorTable TABLE TD.inactiveDay:active -{ background-color: #ddd; } - -#dateSelectorTable TD SPAN -{ display: block; - color: #000; - background: inherit; } - -#dateSelector TD.inactiveDay SPAN -{ color: #dedfde; } - -#dateSelector TD.dayOfToday -{ background-color: #CCDDEC; - border: 1px solid #CCDDEC; } - -#dateSelectorTable TABLE TD._selected SPAN -{ color: #fff; } - -#dateSelectorTable TD.activeDay + TD, -#dateSelectorTable TD.inactiveDay + TD, -#dateSelectorTable TD.dayOfToday + TD -{ visibility: hidden; - display: none; } - -TABLE#eventsList, -TABLE#tasksList -{ width: 100%; } - -TABLE#eventsList .colorBox -{ margin-right: 4px; } - -#eventsList TD.headerTitle, -#eventsList TD.headerDateTime -{ width: 30%; } - -#tasksList .headerPriority -{ width: 80px;} - -TABLE#eventsList TD, -TABLE#eventsList TH, -TABLE#tasksList TD, -TABLE#tasksList TH -{ overflow: hidden; - line-height: 1.5em; - white-space: nowrap; } /* pre, normal, nowrap */ - -TABLE#eventsList TH, -TABLE#tasksList TH -{ white-space: pre; } - -TABLE#tasksList TD#taskCompletedHeader -{ text-align: center; - width: 20px; } - -TABLE#eventsList THEAD TD:last-child, -TABLE#tasksList THEAD TD:last-child -{ border-right: 0px; } - -.filterPanel, -#schedulerTabs .tab label -{ display: block; - margin: 0; - padding: 0 0 5px 5px; - background-color: #eee; - background-color: #E6E7E6; } - -DIV#eventDialog -{ width: 200px; } - -DIV#eventDialog H1, -DIV#eventDialog P -{ font-size: 13px; - margin: 0; - padding: 0; } - -DIV#eventDialog SPAN.label -{ color: #444; } - -DIV#eventDialog .description -{ margin-top: 1em; - font-size: 11px; - max-height: 125px; - overflow: auto; - border-top: 1px solid #eee; } - -._unfocused#dateSelector TD._selected, -UL._unfocused > LI._selected, -TABLE._unfocused#eventsList TR._selected TD -{ background-color: #B3CCE2 !important; - color: #fff !important; } - -SPAN.dayCellLabel -{ color: #77a; - font-weight: bold; } - -SPAN.daysHeader, -SPAN.weeksHeader, -SPAN.monthsHeader -{ display: block; - white-space: nowrap; - text-align: center; - background-color: #DFDFDF; - overflow: hidden; - width: 100%; - margin: 0px; - height: 3em; - padding: 2px 0px; - border-bottom: 1px solid #ccc; } - -SPAN.daysHeader SPAN, -SPAN.weeksHeader SPAN, -SPAN.monthsHeader SPAN -{ font-size: large; - margin: .1em; - padding: 6px 12px; - text-align: center; - line-height: 1.5em; - border: 1px solid transparent; - vertical-align: top; } - -SPAN.daysHeader A, -SPAN.weeksHeader A, -SPAN.monthsHeader A -{ border: 1px solid transparent; - line-height: 1.5em; - padding: 0px 0.7em; } - -.day1 A:hover, -.week1 A:hover, -.month1 A:hover -{ border-top: 1px solid #fff; - border-left: 1px solid #fff; - border-bottom: 1px solid #828482; - border-right: 1px solid #828482; } - -.day1 A:active, -.week1 A:active, -.month1 A:active -{ border-top: 1px solid #828482; - border-left: 1px solid #828482; - border-bottom: 1px solid #fff; - border-right: 1px solid #fff; } - -#listCollapse -{ position: absolute; - top: .2em; - right: 0; - margin: 0.5em 1em; } - -#listCollapse img -{ position: absolute; } - -#listCollapse img.collapse -{ clip: rect(0 18px 18px 0); - left: 0; - top: 0; } - -#listCollapse img.collapse:hover -{ clip: rect(0 36px 18px 18px); - left: -18px; } - -#listCollapse img.rise -{ clip: rect(18px 18px 36px 0); - left: 0; - top: -18px; } - -#listCollapse img.rise:hover -{ clip: rect(18px 36px 36px 18px); - left: -18px; } - -DIV#calendarHeader, -DIV#daysView -{ position: absolute; - top: 0px; - left: 0px; } - -DIV#daysView -{ top: 97px; - bottom: 0px; - border-top: 1px solid #ccc; - overflow: auto; - overflow-x: hidden; - right: 0px; } - -DIV#calendarHeader -{ top: 25px; - border: 0px; - height: 85px; - right: 0px; } - -DIV#calendarHeader DIV.calendarLabels, -DIV#calendarHeader DIV.dayLabels, -DIV#calendarHeader DIV.days -{ position: absolute; - border-right: 1px solid #ccc; - border-top: 1px solid #ccc; - left: 50px; - /* 'right' is computed from JS code when daysView is first drawn */ - overflow: hidden; } - -DIV#calendarHeader DIV.calendarLabels -{ top: 11px; - height: 20px; - border-left: 1px solid #ccc; - text-align: center; - font-size:150%; -} -.calendarsToDisplay -{ border-top: 2px solid #fff; } -DIV#calendarHeader DIV.dayLabels -{ top: 32px; - height: 35px; } - -DIV#calendarHeader DIV.dayLabels DIV.day -{ text-align: center; - color: #666; - background-color: #E7E7E7; } - -DIV#calendarHeader SPAN.dayOfWeek -{ font-size: medium; } - -DIV#calendarHeader DIV.dayLabels -{ cursor: default; } - -DIV#calendarHeader DIV.days -{ cursor: pointer; - bottom: 0px; - top: 67px; - z-index:0; - border-bottom:1px solid #ccc; - background:white; - } - -DIV#calendarHeader DIV.day, -DIV#daysView DIV.day -{ position: absolute; - border-left: 1px solid #ccc; } - -DIV#calendarHeader DIV.day -{ height: 100%; } - -DIV#calendarHeader DIV.days DIV.day -{ overflow: auto; - overflow-x: hidden; } - -.menu LI.currentMonth, -.menu LI.currentYear -{ border-top: 1px solid #aaa; - border-left: 1px solid #aaa; - border-bottom: 1px solid #fff; - border-right: 1px solid #fff; - background-color: #ccc; - color: #222; } - -DIV.eventView -{ display: block; - overflow: hidden; - white-space: nowrap; - border: 1px solid #000; } - -/* new draggable presentation */ - -DIV#daysView DIV.hours -{ display: inline-block; - position: relative; - float: left; - top: 0px; - left: 0; - height: 960px; - width: 50px; } - -DIV#daysView DIV.hour -{ position: relative; - left: 0px; - top: 0px; - padding-top: 2px; - padding-right: 2px; - text-align: right; - right: 0px; - height: 37px; - font-weight: bold; - border-bottom: 1px solid #ccc; } - -DIV#daysView DIV.days -{ position: relative; - left: 0; - right: 0; - top: 0; - margin-left: 50px; } - -DIV.multicolumnDayView DIV.lastDayUser -{ border-right: 1px solid #ccc; } - -DIV.monthView -{ position: absolute; - left: .5em; - top: 40px; - right: 1em; - bottom: 1em; - min-width: 20em; - min-height: 25em; } - -DIV.monthView > DIV, -DIV.monthView > DIV.days > DIV -{ position: absolute; } - -DIV.monthView > DIV.headerDay -{ text-align: center; - cursor: default; - padding-top: .5em; - border-left: 1px solid #909090 !important; - border-top: 1px solid #909090 !important; - top: 0px; - color: #666; - height: 1.5em; - font-weight: bold; - background-color: #E7E7E7; } - -DIV.dayOfAnotherMonth -{ background-color: #e7efef; } - -DIV.monthView DIV.dayHeader -{ margin-right: 0px; - height: 20px; - padding-top: 2px; - padding-right: 2px; - text-align: right; - cursor: pointer; - color: #666; - -moz-user-select: none; - } - -DIV#monthDaysView DIV.selectedDay DIV.dayHeader -{ font-weight: bold; } - -DIV.monthView DIV.days -{ top: 2em; - cursor: pointer; - bottom: 0px; - left: 0px; - right: 0px; - } - -DIV.monthView DIV.day -{ position: absolute; - border-left: 1px solid #909090; - border-top: 1px solid #909090; - min-height: 40px; - overflow: auto; - overflow-x: hidden; } - -DIV#daysView DIV.day DIV.clickableHourCell -{ cursor: pointer; - height: 39px; - background-color: #fff; - border-bottom: 1px solid #ccc; } - -DIV#calendarHeader DIV.days DIV.weekEndDay, -DIV#daysView DIV.day DIV.clickableHourCell.outOfDay, -DIV#daysView DIV.weekEndDay DIV.clickableHourCell, -DIV#daysView DIV.weekEndDay DIV.clickableHourCell.outOfDay -{ background-color: #e6e7e6; } - -DIV#monthDaysView DIV.dayOfToday, -DIV.daysViewFor7Days#calendarHeader DIV.days DIV.dayOfToday, -DIV.daysViewFor7Days#daysView DIV.dayOfToday DIV.clickableHourCell -{ background-color: #d6dfe9; } - -DIV.daysViewFor7Days#daysView DIV.dayOfToday DIV.clickableHourCell.outOfDay -{ background-color: #ccddec; } - -DIV.daysViewFor7Days#calendarHeader DIV.days DIV.selectedDay, -DIV.daysViewFor7Days#daysView DIV.selectedDay DIV.clickableHourCell, -DIV#monthDaysView DIV.selectedDay -{ background-color: #ffe79c; } - -DIV.daysViewFor7Days#calendarHeader DIV.days DIV.selectedDay.weekEndDay, -DIV.daysViewFor7Days#daysView DIV.selectedDay.weekEndDay DIV.clickableHourCell, -DIV.daysViewFor7Days#daysView DIV.selectedDay DIV.clickableHourCell.outOfDay -{ background-color: #f5dd92; } - -.minutes15, .minutes30, .minutes45 -{ display: block; - height: 9px; - border-bottom: 1px dotted #eee; } - -.minutes30 -{ border-bottom: 1px dotted #ccc; } - -DIV.weekOf4 -{ height: 25%; } - -DIV.weekOf5 -{ height: 20%; } - -DIV.weekOf6 -{ height: 16.666667%; } - -DIV.monthView DIV.week0of4, -DIV.monthView DIV.week0of5, -DIV.monthView DIV.week0of6 -{ top: 0px; } - -DIV.monthView DIV.week1of4 -{ top: 25%; } - -DIV.monthView DIV.week2of4 -{ top: 50%; } - -DIV.monthView DIV.week3of4 -{ top: 75%; } - -DIV.monthView DIV.week1of5 -{ top: 20%; } - -DIV.monthView DIV.week2of5 -{ top: 40%; } - -DIV.monthView DIV.week3of5 -{ top: 60%; } - -DIV.monthView DIV.week4of5 -{ top: 80%; } - -DIV.monthView DIV.week1of6 -{ top: 16.666667%; } - -DIV.monthView DIV.week2of6 -{ top: 33.333333%; } - -DIV.monthView DIV.week3of6 -{ top: 50%; } - -DIV.monthView DIV.week4of6 -{ top: 66.666667%; } - -DIV.monthView DIV.week5of6 -{ top: 83.333333%; } - -DIV.monthView DIV.week3 -{ top: 45%; } - -DIV.monthView DIV.week4 -{ top: 60%; } - -DIV.monthView DIV.week5 -{ top: 75%; } - -DIV.monthView DIV.week6 -{ top: 90%; } - -DIV.monthView DIV.week3of4, -DIV.monthView DIV.week4of5, -DIV.monthView DIV.week5of6 -{ border-bottom: 2px solid #909090 !important; } - -DIV.daysViewFor1Days DIV.day -{ width: 100%; } - -DIV.monthView DIV.headerDay, -DIV.monthView DIV.day, -DIV.daysViewFor7Days DIV.day -{ width: 14.2857%; } - -DIV.monthView DIV.day0, -DIV.daysViewFor7Days DIV.day0 -{ left: 0px; } - -DIV.monthView DIV.day1, -DIV.daysViewFor7Days DIV.day1 -{ left: 14.2857%; } - -DIV.monthView DIV.day2, -DIV.daysViewFor7Days DIV.day2 -{ left: 28.5714%; } - -DIV.monthView DIV.day3, -DIV.daysViewFor7Days DIV.day3 -{ left: 42.8571%; } - -DIV.monthView DIV.day4, -DIV.daysViewFor7Days DIV.day4 -{ left: 57.1428%; } - -DIV.monthView DIV.day5, -DIV.daysViewFor7Days DIV.day5 -{ left: 71.4285%; } - -DIV.monthView DIV.day6, -DIV.daysViewFor7Days DIV.day6 -{ left: 85.7142%; } - -/* "left" and "width" for #daysView DIV.event are computed in JS code */ -#daysView DIV.event -{ cursor: default; - margin-right: 1px; - position: absolute; } - -DIV#daysView DIV.event.starts0 -{ top: 0px; } - -DIV#daysView DIV.event.starts1 -{ top: 10px; } - -DIV#daysView DIV.event.starts2 -{ top: 20px; } - -DIV#daysView DIV.event.starts3 -{ top: 30px; } - -DIV#daysView DIV.event.starts4 -{ top: 40px; } - -DIV#daysView DIV.event.starts5 -{ top: 50px; } - -DIV#daysView DIV.event.starts6 -{ top: 60px; } - -DIV#daysView DIV.event.starts7 -{ top: 70px; } - -DIV#daysView DIV.event.starts8 -{ top: 80px; } - -DIV#daysView DIV.event.starts9 -{ top: 90px; } - -DIV#daysView DIV.event.starts10 -{ top: 100px; } - -DIV#daysView DIV.event.starts11 -{ top: 110px; } - -DIV#daysView DIV.event.starts12 -{ top: 120px; } - -DIV#daysView DIV.event.starts13 -{ top: 130px; } - -DIV#daysView DIV.event.starts14 -{ top: 140px; } - -DIV#daysView DIV.event.starts15 -{ top: 150px; } - -DIV#daysView DIV.event.starts16 -{ top: 160px; } - -DIV#daysView DIV.event.starts17 -{ top: 170px; } - -DIV#daysView DIV.event.starts18 -{ top: 180px; } - -DIV#daysView DIV.event.starts19 -{ top: 190px; } - -DIV#daysView DIV.event.starts20 -{ top: 200px; } - -DIV#daysView DIV.event.starts21 -{ top: 210px; } - -DIV#daysView DIV.event.starts22 -{ top: 220px; } - -DIV#daysView DIV.event.starts23 -{ top: 230px; } - -DIV#daysView DIV.event.starts24 -{ top: 240px; } - -DIV#daysView DIV.event.starts25 -{ top: 250px; } - -DIV#daysView DIV.event.starts26 -{ top: 260px; } - -DIV#daysView DIV.event.starts27 -{ top: 270px; } - -DIV#daysView DIV.event.starts28 -{ top: 280px; } - -DIV#daysView DIV.event.starts29 -{ top: 290px; } - -DIV#daysView DIV.event.starts30 -{ top: 300px; } - -DIV#daysView DIV.event.starts31 -{ top: 310px; } - -DIV#daysView DIV.event.starts32 -{ top: 320px; } - -DIV#daysView DIV.event.starts33 -{ top: 330px; } - -DIV#daysView DIV.event.starts34 -{ top: 340px; } - -DIV#daysView DIV.event.starts35 -{ top: 350px; } - -DIV#daysView DIV.event.starts36 -{ top: 360px; } - -DIV#daysView DIV.event.starts37 -{ top: 370px; } - -DIV#daysView DIV.event.starts38 -{ top: 380px; } - -DIV#daysView DIV.event.starts39 -{ top: 390px; } - -DIV#daysView DIV.event.starts40 -{ top: 400px; } - -DIV#daysView DIV.event.starts41 -{ top: 410px; } - -DIV#daysView DIV.event.starts42 -{ top: 420px; } - -DIV#daysView DIV.event.starts43 -{ top: 430px; } - -DIV#daysView DIV.event.starts44 -{ top: 440px; } - -DIV#daysView DIV.event.starts45 -{ top: 450px; } - -DIV#daysView DIV.event.starts46 -{ top: 460px; } - -DIV#daysView DIV.event.starts47 -{ top: 470px; } - -DIV#daysView DIV.event.starts48 -{ top: 480px; } - -DIV#daysView DIV.event.starts49 -{ top: 490px; } - -DIV#daysView DIV.event.starts50 -{ top: 500px; } - -DIV#daysView DIV.event.starts51 -{ top: 510px; } - -DIV#daysView DIV.event.starts52 -{ top: 520px; } - -DIV#daysView DIV.event.starts53 -{ top: 530px; } - -DIV#daysView DIV.event.starts54 -{ top: 540px; } - -DIV#daysView DIV.event.starts55 -{ top: 550px; } - -DIV#daysView DIV.event.starts56 -{ top: 560px; } - -DIV#daysView DIV.event.starts57 -{ top: 570px; } - -DIV#daysView DIV.event.starts58 -{ top: 580px; } - -DIV#daysView DIV.event.starts59 -{ top: 590px; } - -DIV#daysView DIV.event.starts60 -{ top: 600px; } - -DIV#daysView DIV.event.starts61 -{ top: 610px; } - -DIV#daysView DIV.event.starts62 -{ top: 620px; } - -DIV#daysView DIV.event.starts63 -{ top: 630px; } - -DIV#daysView DIV.event.starts64 -{ top: 640px; } - -DIV#daysView DIV.event.starts65 -{ top: 650px; } - -DIV#daysView DIV.event.starts66 -{ top: 660px; } - -DIV#daysView DIV.event.starts67 -{ top: 670px; } - -DIV#daysView DIV.event.starts68 -{ top: 680px; } - -DIV#daysView DIV.event.starts69 -{ top: 690px; } - -DIV#daysView DIV.event.starts70 -{ top: 700px; } - -DIV#daysView DIV.event.starts71 -{ top: 710px; } - -DIV#daysView DIV.event.starts72 -{ top: 720px; } - -DIV#daysView DIV.event.starts73 -{ top: 730px; } - -DIV#daysView DIV.event.starts74 -{ top: 740px; } - -DIV#daysView DIV.event.starts75 -{ top: 750px; } - -DIV#daysView DIV.event.starts76 -{ top: 760px; } - -DIV#daysView DIV.event.starts77 -{ top: 770px; } - -DIV#daysView DIV.event.starts78 -{ top: 780px; } - -DIV#daysView DIV.event.starts79 -{ top: 790px; } - -DIV#daysView DIV.event.starts80 -{ top: 800px; } - -DIV#daysView DIV.event.starts81 -{ top: 810px; } - -DIV#daysView DIV.event.starts82 -{ top: 820px; } - -DIV#daysView DIV.event.starts83 -{ top: 830px; } - -DIV#daysView DIV.event.starts84 -{ top: 840px; } - -DIV#daysView DIV.event.starts85 -{ top: 850px; } - -DIV#daysView DIV.event.starts86 -{ top: 860px; } - -DIV#daysView DIV.event.starts87 -{ top: 870px; } - -DIV#daysView DIV.event.starts88 -{ top: 880px; } - -DIV#daysView DIV.event.starts89 -{ top: 890px; } - -DIV#daysView DIV.event.starts90 -{ top: 900px; } - -DIV#daysView DIV.event.starts91 -{ top: 910px; } - -DIV#daysView DIV.event.starts92 -{ top: 920px; } - -DIV#daysView DIV.event.starts93 -{ top: 930px; } - -DIV#daysView DIV.event.starts94 -{ top: 940px; } - -DIV#daysView DIV.event.starts95 -{ top: 950px; } - -DIV#daysView DIV.event.lasts0 -{ height: 0px; } - -DIV#daysView DIV.event.lasts1 -{ height: 10px; } - -DIV#daysView DIV.event.lasts2 -{ height: 20px; } - -DIV#daysView DIV.event.lasts3 -{ height: 30px; } - -DIV#daysView DIV.event.lasts4 -{ height: 40px; } - -DIV#daysView DIV.event.lasts5 -{ height: 50px; } - -DIV#daysView DIV.event.lasts6 -{ height: 60px; } - -DIV#daysView DIV.event.lasts7 -{ height: 70px; } - -DIV#daysView DIV.event.lasts8 -{ height: 80px; } - -DIV#daysView DIV.event.lasts9 -{ height: 90px; } - -DIV#daysView DIV.event.lasts10 -{ height: 100px; } - -DIV#daysView DIV.event.lasts11 -{ height: 110px; } - -DIV#daysView DIV.event.lasts12 -{ height: 120px; } - -DIV#daysView DIV.event.lasts13 -{ height: 130px; } - -DIV#daysView DIV.event.lasts14 -{ height: 140px; } - -DIV#daysView DIV.event.lasts15 -{ height: 150px; } - -DIV#daysView DIV.event.lasts16 -{ height: 160px; } - -DIV#daysView DIV.event.lasts17 -{ height: 170px; } - -DIV#daysView DIV.event.lasts18 -{ height: 180px; } - -DIV#daysView DIV.event.lasts19 -{ height: 190px; } - -DIV#daysView DIV.event.lasts20 -{ height: 200px; } - -DIV#daysView DIV.event.lasts21 -{ height: 210px; } - -DIV#daysView DIV.event.lasts22 -{ height: 220px; } - -DIV#daysView DIV.event.lasts23 -{ height: 230px; } - -DIV#daysView DIV.event.lasts24 -{ height: 240px; } - -DIV#daysView DIV.event.lasts25 -{ height: 250px; } - -DIV#daysView DIV.event.lasts26 -{ height: 260px; } - -DIV#daysView DIV.event.lasts27 -{ height: 270px; } - -DIV#daysView DIV.event.lasts28 -{ height: 280px; } - -DIV#daysView DIV.event.lasts29 -{ height: 290px; } - -DIV#daysView DIV.event.lasts30 -{ height: 300px; } - -DIV#daysView DIV.event.lasts31 -{ height: 310px; } - -DIV#daysView DIV.event.lasts32 -{ height: 320px; } - -DIV#daysView DIV.event.lasts33 -{ height: 330px; } - -DIV#daysView DIV.event.lasts34 -{ height: 340px; } - -DIV#daysView DIV.event.lasts35 -{ height: 350px; } - -DIV#daysView DIV.event.lasts36 -{ height: 360px; } - -DIV#daysView DIV.event.lasts37 -{ height: 370px; } - -DIV#daysView DIV.event.lasts38 -{ height: 380px; } - -DIV#daysView DIV.event.lasts39 -{ height: 390px; } - -DIV#daysView DIV.event.lasts40 -{ height: 400px; } - -DIV#daysView DIV.event.lasts41 -{ height: 410px; } - -DIV#daysView DIV.event.lasts42 -{ height: 420px; } - -DIV#daysView DIV.event.lasts43 -{ height: 430px; } - -DIV#daysView DIV.event.lasts44 -{ height: 440px; } - -DIV#daysView DIV.event.lasts45 -{ height: 450px; } - -DIV#daysView DIV.event.lasts46 -{ height: 460px; } - -DIV#daysView DIV.event.lasts47 -{ height: 470px; } - -DIV#daysView DIV.event.lasts48 -{ height: 480px; } - -DIV#daysView DIV.event.lasts49 -{ height: 490px; } - -DIV#daysView DIV.event.lasts50 -{ height: 500px; } - -DIV#daysView DIV.event.lasts51 -{ height: 510px; } - -DIV#daysView DIV.event.lasts52 -{ height: 520px; } - -DIV#daysView DIV.event.lasts53 -{ height: 530px; } - -DIV#daysView DIV.event.lasts54 -{ height: 540px; } - -DIV#daysView DIV.event.lasts55 -{ height: 550px; } - -DIV#daysView DIV.event.lasts56 -{ height: 560px; } - -DIV#daysView DIV.event.lasts57 -{ height: 570px; } - -DIV#daysView DIV.event.lasts58 -{ height: 580px; } - -DIV#daysView DIV.event.lasts59 -{ height: 590px; } - -DIV#daysView DIV.event.lasts60 -{ height: 600px; } - -DIV#daysView DIV.event.lasts61 -{ height: 610px; } - -DIV#daysView DIV.event.lasts62 -{ height: 620px; } - -DIV#daysView DIV.event.lasts63 -{ height: 630px; } - -DIV#daysView DIV.event.lasts64 -{ height: 640px; } - -DIV#daysView DIV.event.lasts65 -{ height: 650px; } - -DIV#daysView DIV.event.lasts66 -{ height: 660px; } - -DIV#daysView DIV.event.lasts67 -{ height: 670px; } - -DIV#daysView DIV.event.lasts68 -{ height: 680px; } - -DIV#daysView DIV.event.lasts69 -{ height: 690px; } - -DIV#daysView DIV.event.lasts70 -{ height: 700px; } - -DIV#daysView DIV.event.lasts71 -{ height: 710px; } - -DIV#daysView DIV.event.lasts72 -{ height: 720px; } - -DIV#daysView DIV.event.lasts73 -{ height: 730px; } - -DIV#daysView DIV.event.lasts74 -{ height: 740px; } - -DIV#daysView DIV.event.lasts75 -{ height: 750px; } - -DIV#daysView DIV.event.lasts76 -{ height: 760px; } - -DIV#daysView DIV.event.lasts77 -{ height: 770px; } - -DIV#daysView DIV.event.lasts78 -{ height: 780px; } - -DIV#daysView DIV.event.lasts79 -{ height: 790px; } - -DIV#daysView DIV.event.lasts80 -{ height: 800px; } - -DIV#daysView DIV.event.lasts81 -{ height: 810px; } - -DIV#daysView DIV.event.lasts82 -{ height: 820px; } - -DIV#daysView DIV.event.lasts83 -{ height: 830px; } - -DIV#daysView DIV.event.lasts84 -{ height: 840px; } - -DIV#daysView DIV.event.lasts85 -{ height: 850px; } - -DIV#daysView DIV.event.lasts86 -{ height: 860px; } - -DIV#daysView DIV.event.lasts87 -{ height: 870px; } - -DIV#daysView DIV.event.lasts88 -{ height: 880px; } - -DIV#daysView DIV.event.lasts89 -{ height: 890px; } - -DIV#daysView DIV.event.lasts90 -{ height: 900px; } - -DIV#daysView DIV.event.lasts91 -{ height: 910px; } - -DIV#daysView DIV.event.lasts92 -{ height: 920px; } - -DIV#daysView DIV.event.lasts93 -{ height: 930px; } - -DIV#daysView DIV.event.lasts94 -{ height: 940px; } - -DIV#daysView DIV.event.lasts95 -{ height: 950px; } - -DIV#daysView DIV.event.lasts96 -{ height: 960px; } - -DIV.event > DIV.eventInside -{ position: absolute; - overflow: hidden; - top: 0px; - bottom: 0px; - left: 0px; - right: 0px; - -webkit-border-radius: 2px; - border-radius: 2px; - cursor:move; } - -DIV.eventInside SPAN.location -{ font-size: smaller; } - -DIV.gradient, DIV.text -{ position: absolute; - top: 1px; - left: 1px; - right: 1px; - bottom: 1px; - overflow: hidden; } - -DIV.gradient > IMG -{ position: absolute; - top: 0; - bottom: 0; - left: 0; - right: 0; - height: 100%; - min-height: 15px; /* for 15-minute events */ - width: 100%; } - -DIV.event._selected > DIV.eventInside > DIV.gradient -{ display: none; } - -DIV.text SPAN.icons -{ float: right; } - -DIV.text SPAN IMG -{ vertical-align: middle; } - -DIV#calendarHeader DIV.event, -DIV.monthView DIV.event -{ position: relative; - cursor: default; - margin-right: 0px; - left: 0px; - right: 0px; - margin-right: 1px; - white-space: nowrap; - height: 20px; } - -DIV.eventInside.tentative, -DIV.eventInside.needs-action -{ -moz-opacity: 0.7; - opacity: 0.7; } - -DIV.eventInside.needs-action -{ border: 2px dotted #000; } - -DIV.eventInside.tentative DIV.text, -DIV.eventInside.needs-action DIV.text -{ top: 0px; - left: 2px; } - -DIV.eventInside.delegated, -DIV.eventInside.declined -{ -moz-opacity: 0.4; - opacity: 0.4; } - -/* event DnD */ -DIV.event DIV.topDragGrip, -DIV.event DIV.bottomDragGrip -{ position: absolute; - border: 0px; - left: 1px; - right: 1px; - height: 5px; - background-repeat: no-repeat; - background-position: center; } - -DIV.event DIV.topDragGrip -{ top: 1px; } - -DIV.event DIV.bottomDragGrip -{ bottom: 1px; } - -DIV.event DIV.leftDragGrip, -DIV.event DIV.rightDragGrip -{ position: absolute; - border: 0px; - top: 4px; - height: 11px; - width: 3px; - background-repeat: no-repeat; - background-position: center; } - -DIV.event DIV.leftDragGrip -{ left: 1px; } - -DIV.event DIV.rightDragGrip -{ right: 1px; } - -#daysView DIV.event.dragging -{ left: 0px !important; - right: 0px !important; } - -DIV.event.dragging > DIV.eventInside -{ -moz-opacity: 1 !important; - border: 1px dashed #555; - opacity: 1 !important; - background-color: transparent !important; } - -DIV.event.dragging DIV.text -{ color: #555; - top: 0px; - left: 0px; } - -DIV.event.dragging IMG, -DIV.event.dragging DIV.topDragGrip, -DIV.event.dragging DIV.bottomDragGrip, -DIV.event.dragging DIV.leftDragGrip, -DIV.event.dragging DIV.rightDragGrip -{ display: none; } - -DIV.event.draggable:hover DIV.topDragGrip -{ cursor: n-resize; - background-image: url(event-grippy-top.png); } - -DIV.event.draggable:hover DIV.bottomDragGrip -{ cursor: s-resize; - background-image: url(event-grippy-bottom.png); } - -DIV.event.draggable:hover DIV.leftDragGrip -{ cursor: w-resize; - background-image: url(event-grippy-vertical.png); } - -DIV.event.draggable:hover DIV.rightDragGrip -{ cursor: e-resize; - background-image: url(event-grippy-vertical.png); } - -#daysView DIV.eventDragGhost -{ left: 0px; right: 0px; } - -#daysView DIV.eventDragGhost > DIV.eventInside -{ padding: 0px; - border-left: 1px solid #555; - border-right: 1px solid #555; -} - -#daysView DIV.eventDragGhost.startGhost > DIV.eventInside -{ border-top: 1px solid #555; } - -#daysView DIV.eventDragGhost.endGhost > DIV.eventInside -{ border-bottom: 1px solid #555; } - -#monthDaysView DIV.eventDragGhost, -#calendarHeader DIV.eventDragGhost -{ position: absolute !important; - color: #fff; - left: 0px; - right: 0px; - margin-right: 1px; - border-top: 1px solid #555; - border-bottom: 1px solid #555; } - -#monthDaysView DIV.eventDragGhost -{ top: 21px; } - -#calendarHeader DIV.eventDragGhost -{ top: 0px; } - -#monthDaysView DIV.eventDragGhost.startGhost, -#calendarHeader DIV.eventDragGhost.startGhost -{ border-left: 1px solid #555; } - -#monthDaysView DIV.eventDragGhost.endGhost, -#calendarHeader DIV.eventDragGhost.endGhost -{ border-right: 1px solid #555; } - -#ghostStartHour, -#ghostEndHour -{ position: absolute; - width: 100%; - vertical-align: baseline; - height: 14px; - left: 0px; - color: #222; - text-align: center; } - -#ghostStartHour -{ top: -14px; } - -#ghostEndHour -{ bottom: -14px; } - -DIV.nowLineDisplay -{ position: relative; - width: 100%; - height: 2px; - background: red; - z-index: 49; } - -DIV#freeBusyReplicas INPUT.textField -{ width: 7em; } -DIV#freeBusyReplicas a.calendarButton -{ right: 0px; } -DIV#freeBusyReplicas DIV -{ display: inline-block; height: 2em; } -TD.attendees A.button -{ float: left; left: 19px; margin-top: 5px; } - -DIV#calendarContent .alert-box { - color:#555; - border-radius:10px; - font-family:Tahoma,Geneva,Arial,sans-serif;font-size:11px; - padding:10px 10px 10px 36px; - margin:10px; -} - -DIV#calendarContent .alert-box span { - font-weight:bold; - text-transform:uppercase; -} - -.error { - background:#ffecec url('error.png') no-repeat 10px 50%; - border:1px solid #f5aca6; -} -.success { - background:#e9ffd9 url('success.png') no-repeat 10px 50%; - border:1px solid #a6ca8a; -} -.warning { - background:#fff8c4 url('warning.png') no-repeat 10px 50%; - border:1px solid #f2c779; -} -.notice { - background:#e3f7fc url('notice.png') no-repeat 10px 50%; - border:1px solid #8ed9f6; -} - -DIV#DnDVisualEvents -{ background-image: url(event7.png); } - -DIV#DnDVisualTasks -{ background-image: url(task.png); } - -DIV#DnDVisualEvents, DIV#DnDVisualTasks -{ - background-repeat: no-repeat; - background-position: 4px 2px; - width: 5px; - height: 20px; - padding-left: 24px; - padding-top: 5px; -} - -#DnDLeftPanelImage -{ - position:absolute; - z-index:1; - left:0; - top:0; -} diff --git a/UI/WebServerResources/SchedulerUI.js b/UI/WebServerResources/SchedulerUI.js deleted file mode 100644 index 22ba2f8c2..000000000 --- a/UI/WebServerResources/SchedulerUI.js +++ /dev/null @@ -1,3943 +0,0 @@ -var eventListFilter = 'view_today'; -var taskListFilter = 'view_today'; - -var listOfSelection = null; -var selectedCalendarCell = null; - -var showCompletedTasks; - -var currentDay = ''; -var selectedDayNumber = -1; -var selectedDayDate = ''; - -var cachedDateSelectors = []; - -var contactSelectorAction = 'calendars-contacts'; - -var eventsToDelete = []; -var calendarsOfEventsToDelete = []; - -var usersRightsWindowHeight = 215; -var usersRightsWindowWidth = 502; - -var calendarEvents = null; - -var preventAutoScroll = false; - -var userStates = [ "needs-action", "accepted", "declined", "tentative", "delegated" ]; - -var calendarHeaderAdjusted = false; -var recurrenceBool = false; - -var categoriesStyles = new Hash(); -var categoriesStyleSheet = null; - -var clipboard = null; -var eventsToCopy = []; - -var refreshViewCheckTimer; - -// This should probably go in the generic.js -function printView() { - var flag = false; - var calendarsList = $("calendarList").children; - for (var i = 0; i < calendarsList.length; i++) { - if (calendarsList[i].down("input").checked) { - flag = true; - break; - } - } - if (flag) - window.open("printView","","width=660,height=470"); - - else - showAlertDialog("Please select at least one calendar"); - - - return false; -} - -function newEvent(type, day, hour, duration) { - var folder = null; - /* if (currentView == "multicolumndayview") { - Need to find where the click register is saved - }*/ - if (UserDefaults['SOGoDefaultCalendar'] == 'personal') - folder = $("calendarList").down("li"); - else if (UserDefaults['SOGoDefaultCalendar'] == 'first') { - var list = $("calendarList"); - var inputs = list.select("input"); - for (var i = 0; i < inputs.length; i++) { - var input = inputs[i]; - if (input.checked) { - folder = input.up(); - break; - } - } - if (!folder) - folder = list.down("li"); - } - else - folder = getSelectedFolder(); - var folderID = folder.readAttribute("id"); - var urlstr = ApplicationBaseURL + folderID + "/new" + type; - var params = []; - if (!day) - day = currentDay; - params.push("day=" + day); - if (hour) - params.push("hm=" + hour); - if (duration) - params.push("duration=" + duration); - if (params.length > 0) - urlstr += "?" + params.join("&"); - - window.open(urlstr, "", "width=490,height=470,resizable=0"); - - return false; /* stop following the link */ -} - -function newEventFromWidget(sender, type) { - var day = $(sender).readAttribute("day"); - var hour = sender.readAttribute("hour"); - - newEvent.delay(0.1, type, day, hour); -} - -function minutesToHM(minutes) { - var hours = Math.floor(minutes / 60); - if (hours < 10) - hours = "0" + hours; - var mins = minutes % 60; - if (mins < 10) - mins = "0" + mins; - - return "" + hours + mins; -} - -function newEventFromDragging(controller, day, coordinates) { - var startHm; - if (controller.eventType == "multiday") - startHm = minutesToHM(coordinates.start * 15); - else - startHm = "allday"; - var lengthHm = minutesToHM(coordinates.duration * 15); - newEvent("event", day, startHm, lengthHm); -} - -function updateEventFromDragging(controller, eventCells, eventDelta, calendarID) { - if (eventDelta.dayNumber || eventDelta.start || eventDelta.duration || calendarID != 0) { - if (calendarID != 0) - var params = ("destination=" + calendarID[1] - + "&days=" + 0 - + "&start=" + eventDelta.start * 15 - + "&duration=" + eventDelta.duration * 15); - else - var params = ("destination=" + 0 - + "&days=" + eventDelta.dayNumber - + "&start=" + eventDelta.start * 15 - + "&duration=" + eventDelta.duration * 15); - // log("eventCells: " + eventCells.length); - var eventCell = eventCells[0]; - // log(" time: " + eventCell.recurrenceTime); - // log(" exception: " + eventCell.isException); - recurrenceBool = false; - if (calendarID == 0) { - recurrenceBool = true; - } - if (eventCell.recurrenceTime && !eventCell.isException) - _editRecurrenceDialog(eventCell, "confirmAdjustment", params); - else { - var urlstr = (ApplicationBaseURL + "/" + eventCell.calendar + "/" + eventCell.cname); - if (eventCell.recurrenceTime && recurrenceBool) - urlstr += "/occurence" + eventCell.recurrenceTime; - urlstr += ("/adjust?" + params); - // log(" urlstr: " + urlstr); - triggerAjaxRequest(urlstr, updateEventFromDraggingCallback); - } - } -} - -function performEventAdjustment(folder, event, recurrence, params) { - var urlstr = ApplicationBaseURL + "/" + folder + "/" + event; - if (recurrence && recurrenceBool) - urlstr += "/" + recurrence; - urlstr += "/adjust" + generateQueryString(params); - triggerAjaxRequest(urlstr, updateEventFromDraggingCallback); -} - -function updateEventFromDraggingCallback(http) { - if (http.readyState == 4) { - if (isHttpStatus204(http.status)) { - refreshEventsAndDisplay(); - } - else { - var response = http.responseText.evalJSON(true); - showAlertDialog(response['message']); - } - } -} - -function updateTaskFromDraggingCallback(http) { - if (http.readyState == 4) { - if (http.status == 200) { - refreshTasks(); - } - } -} - -function getSelectedFolder() { - var folder; - var list = $("calendarList"); - var nodes = list.getSelectedRows(); - if (nodes.length > 0) - folder = nodes[0]; - else - folder = list.down("li"); // personal calendar - - return folder; -} - -function onMenuNewEventClick(event) { - var target = document.menuTarget; - if (target) { - if (/(minutes\d{2}|dayHeader)/.test(target.className)) - target = target.parentNode; - newEventFromWidget(target, "event"); - } - else { - newEvent('event'); - } -} - -function onMenuNewTaskClick(event) { - var target = document.menuTarget; - if (target) { - if (/(minutes\d{2}|dayHeader)/.test(target.className)) - target = target.parentNode; - newEventFromWidget(target, "task"); - } - else { - newEvent('task'); - } -} - -function _editEventId(id, calendar, recurrence) { - var targetname = "SOGo_edit_" + id; - var urlstr = ApplicationBaseURL + "/" + calendar + "/" + id; - if (recurrence) { - urlstr += "/" + recurrence; - targetname += recurrence; - } - urlstr += "/edit"; - var win = window.open(urlstr, "_blank", - "width=490,height=470,resizable=0"); - if (win) - win.focus(); -} - -function editEvent() { - if (listOfSelection) { - var nodes = listOfSelection.getSelectedRows(); - - if (nodes.length == 0) { - showAlertDialog(_("Please select an event or a task.")); - return false; - } - - for (var i = 0; i < nodes.length; i++) - _editEventId.delay(0.1, - nodes[i].cname, - nodes[i].calendar); - } else if (selectedCalendarCell) { - if (selectedCalendarCell[0].recurrenceTime && !selectedCalendarCell[0].isException) - _editRecurrenceDialog.delay(0.1, - selectedCalendarCell[0], - "confirmEditing"); - else - _editEventId.delay(0.1, - selectedCalendarCell[0].cname, - selectedCalendarCell[0].calendar); - } else { - showAlertDialog(_("Please select an event or a task.")); - } - - return false; /* stop following the link */ -} - -function _batchDeleteEvents() { - // Delete the events of the next calendar - var calendar = calendarsOfEventsToDelete.shift(); - var events = eventsToDelete.shift(); - var urlstr = (ApplicationBaseURL + "/" + calendar - + "/batchDelete?ids=" + events.join(',')); - document.deleteEventAjaxRequest = triggerAjaxRequest(urlstr, - deleteEventCallback, - { calendar: calendar, events: events }); -} - -function deleteEvent() { - var label = ""; - var events = []; - if (listOfSelection) { - var nodes = listOfSelection.getSelectedRows(); - if (nodes.length > 0) { - if (listOfSelection.parentNode == $("tasksList")) - label = _("taskDeleteConfirmation"); - else - label = _("eventDeleteConfirmation"); - - if (nodes.length == 1 - && nodes[0].recurrenceTime) { - if (nodes[0].erasable) - _editRecurrenceDialog(nodes[0], "confirmDeletion"); - else - showAlertDialog(_("You don't have the required privileges to perform the operation.")); - } - else { - var canDelete; - var sortedNodes = []; - var calendars = []; - for (var i = 0; i < nodes.length; i++) { - canDelete = nodes[i].erasable; - if (canDelete) { - var calendar = nodes[i].calendar; - var cname = nodes[i].cname; - if (nodes[i].recurrenceTime) { - cname += '/occurence' + nodes[i].recurrenceTime; - } - if (!sortedNodes[calendar]) { - sortedNodes[calendar] = []; - calendars.push(calendar); - } - if (sortedNodes[calendar].indexOf(cname) < 0) { - // Build list item element for confirmation dialog - var itemElement = new Element('li'); - var colorBox = new Element('div', {'class': 'colorBox calendarFolder' + nodes[i].calendar}); - var content = ''; - if (nodes[i].tagName == 'TR') { - var cell = nodes[i].down('td span'); - content = cell.allTextContent(); // extract the first column only - } - else { - content = nodes[i].allTextContent(); - } - itemElement.appendChild(colorBox); - itemElement.appendChild(new Element('span').update(content.escapeHTML())); - if (nodes[i].startDate) { - var startDate = new Date(nodes[i].startDate*1000); - var dateElement = new Element('div', {'class': 'muted'}); - var date; - if (typeof nodes[i].hour == 'undefined') - date = startDate.toLocaleDateString(localeCode); - else - date = startDate.toLocaleString(localeCode); - dateElement.update(date); - itemElement.appendChild(dateElement); - } - events.push(itemElement); - sortedNodes[calendar].push(cname); - } - } - } - // Update global arrays - for (i = 0; i < calendars.length; i++) { - calendarsOfEventsToDelete.push(calendars[i]); - eventsToDelete.push(sortedNodes[calendars[i]]); - } - if (i == 0) - showAlertDialog(_("You don't have the required privileges to perform the operation.")); - } - } - else - showAlertDialog(_("Please select an event or a task.")); - } - else if (selectedCalendarCell) { - if (selectedCalendarCell.length == 1 - && selectedCalendarCell[0].recurrenceTime) { - if (selectedCalendarCell[0].erasable) - _editRecurrenceDialog(selectedCalendarCell[0], "confirmDeletion"); - else - showAlertDialog(_("You don't have the required privileges to perform the operation.")); - } - else { - var canDelete; - var sortedNodes = []; - var calendars = []; - var cname; - for (var i = 0; i < selectedCalendarCell.length; i++) { - canDelete = selectedCalendarCell[i].erasable; - if (canDelete) { - var calendar = selectedCalendarCell[i].calendar; - var cname = selectedCalendarCell[i].cname; - if (selectedCalendarCell[i].recurrenceTime) { - cname += '/occurence' + selectedCalendarCell[i].recurrenceTime; - } - if (!sortedNodes[calendar]) { - sortedNodes[calendar] = []; - calendars.push(calendar); - } - if (sortedNodes[calendar].indexOf(cname) < 0) { - // Build list item element for confirmation dialog - var itemElement = new Element('li'); - var colorBox = new Element('div', {'class': 'colorBox calendarFolder' + selectedCalendarCell[i].calendar}); - var content = ''; - var event = $(selectedCalendarCell[i]).down("DIV.text"); - for (var j = 0; j < event.childNodes.length; j++) { - var node = event.childNodes[j]; - if (node.nodeType == Node.TEXT_NODE) { - content += node.nodeValue; - } - } - itemElement.appendChild(colorBox); - itemElement.appendChild(new Element('span').update(content.escapeHTML())); - if (selectedCalendarCell[i].startDate) { - var startDate = new Date(selectedCalendarCell[i].startDate*1000); - var dateElement = new Element('div', {'class': 'muted'}); - var date; - if (selectedCalendarCell[i].readAttribute('hour') == 'allday') - date = startDate.toLocaleDateString(localeCode); - else - date = startDate.toLocaleString(localeCode); - dateElement.update(date); - itemElement.appendChild(dateElement); - } - events.push(itemElement); - sortedNodes[calendar].push(cname); - } - } - } - // Update global arrays - for (i = 0; i < calendars.length; i++) { - calendarsOfEventsToDelete.push(calendars[i]); - eventsToDelete.push(sortedNodes[calendars[i]]); - } - if (i == 0) - showAlertDialog(_("You don't have the required privileges to perform the operation.")); - } - } - else - showAlertDialog(_("Please select an event or a task.")); - - if (events.length > 0) { - // Show confirmation dialog - var p = new Element('p'); - p.appendChild(document.createTextNode(label)); - var list = new Element('ul'); - for (i = 0; i < events.length; i++) { - list.appendChild(events[i]); - } - p.appendChild(list); - p.appendChild(document.createTextNode(_("Would you like to continue?"))); - showConfirmDialog(_("Warning"), p, deleteEventFromListConfirm, deleteEventCancel); - } - - return false; -} - -function deleteEventFromListConfirm() { - if (document.deleteEventAjaxRequest) { - document.deleteEventAjaxRequest.aborted = true; - document.deleteEventAjaxRequest.abort(); - } - - _batchDeleteEvents(); - refreshTasks(); - disposeDialog(); -} - -function deleteEventFromViewConfirm() { - if (document.deleteEventAjaxRequest) { - document.deleteEventAjaxRequest.aborted = true; - document.deleteEventAjaxRequest.abort(); - } - - selectedCalendarCell = null; - _batchDeleteEvents(); - disposeDialog(); -} - -function deleteEventCancel(event) { - calendarsOfEventsToDelete = []; - eventsToDelete = []; - disposeDialog(); -} - -function copyEventToClipboard() { - if (listOfSelection) { - clipboard = new Array(); - var nodes = listOfSelection.getSelectedRows(); - for (var i = 0; i < nodes.length; i++) - clipboard.push(nodes[i].calendar + "/" + nodes[i].cname); - } - else if (selectedCalendarCell) { - clipboard = new Array(); - for (var i = 0; i < selectedCalendarCell.length; i++) - clipboard.push(selectedCalendarCell[i].calendar + "/" + selectedCalendarCell[i].cname); - } - log ("clipboard : " + clipboard.join(", ")); -} - -function copyEventFromClipboard() { - if (clipboard && clipboard.length > 0) { - var folder = getSelectedFolder(); - var folderID = folder.readAttribute("id").substr(1); - eventsToCopy = []; - for (var i = 0; i < clipboard.length; i++) - eventsToCopy[i] = clipboard[i] + "/copy?destination=" + folderID; - copyEvents(); - } -} - -function copyEventToPersonalCalendar(event) { - var calendar = selectedCalendarCell[0].calendar; - var cname = selectedCalendarCell[0].cname; - eventsToCopy = [calendar + "/" + cname + "/copy"]; - copyEvents(); -} - -function copyEvents() { - var path = eventsToCopy.shift(); - var urlstr = ApplicationBaseURL + "/" + path; log (urlstr); - triggerAjaxRequest(urlstr, - copyEventCallback); -} - -function copyEventCallback(http) { - if (http.readyState == 4) { - if (isHttpStatus204(http.status)) { - if (eventsToCopy.length) - copyEvents(); - else - refreshEventsAndDisplay(); - } - else if (parseInt(http.status) == 403) - showAlertDialog(_("You don't have the required privileges to perform the operation.")); - else if (parseInt(http.status) == 400) - showAlertDialog(_("DestinationCalendarError")); - else - showAlertDialog(_("EventCopyError")); - } -} - -function onMenuRawEvent(event) { - if (selectedCalendarCell.length != 1) { - return; - } - - var calendar = selectedCalendarCell[0].calendar; - var cname = selectedCalendarCell[0].cname; - - var url = ApplicationBaseURL + "/" + calendar + "/" + cname + "/raw"; - openGenericWindow.delay(0.1, url); -} - -function closeInvitationWindow() { - var closeDiv = document.createElement("div"); - document.body.appendChild(closeDiv); - closeDiv.addClassName("javascriptPopupBackground"); - - var closePseudoWin = document.createElement("div"); - document.body.appendChild(closePseudoWin); - closePseudoWin.addClassName("javascriptMessagePseudoTopWindow"); - closePseudoWin.style.top = "0px;"; - closePseudoWin.style.left = "0px;"; - closePseudoWin.style.right = "0px;"; - closePseudoWin.appendChild(document.createTextNode(_("closeThisWindowMessage"))); - - var calLink = document.createElement("a"); - closePseudoWin.appendChild(calLink); - calLink.href = ApplicationBaseURL; - calLink.appendChild(document.createTextNode(_("Calendar").toLowerCase())); -} - -function modifyEventCallback(http) { - if (http.readyState == 4) { - if (isHttpStatus204(http.status) || http.status == 200) { - var mailInvitation = queryParameters["mail-invitation"]; - if (mailInvitation && mailInvitation.toLowerCase() == "yes") - closeInvitationWindow(); - else { - window.opener.setTimeout("refreshEventsAndDisplay();", 100); - window.setTimeout("window.close();", 100); - } - } - else if (http.status == 403) { - var data = http.responseText; - var msg; - if (data.indexOf("An error occurred during object publishing") > - -1) { - msg = data.replace(/^(.*\n)*.*((.*\n)*.*)<\/p>(.*\n)*.*$/, "$2");
- } else {
- msg = "delegate is a participant";
- }
- showAlertDialog(_(msg));
- }
- else {
- showAlertDialog(_("eventPartStatModificationError"));
- }
- document.modifyEventAjaxRequest = null;
- }
-}
-
-function _deleteCalendarEventBlocks(calendar, cname, occurenceTime) {
- // Delete event (or occurence) from the specified calendar
- var ownerIsOrganizer = false;
- var events = calendarEvents[calendar];
- if (events) {
- var occurences = events[cname];
- if (occurences) {
- for (var i = 0; i < occurences.length; i++) {
- var nodes = occurences[i].blocks;
- for (var j = 0; j < nodes.length; j++) {
- var node = nodes[j];
- if (occurenceTime == null
- || occurenceTime == node.recurrenceTime) {
- ownerIsOrganizer = node.ownerIsOrganizer;
- node.parentNode.removeChild(node);
- }
- }
- }
- if (ownerIsOrganizer)
- // Search for the same event in other calendars (using the cache)
- // only if the delete operation is triggered from the organizer's
- // calendar.
- for (var otherCalendar in calendarEvents) {
- if (calendar != otherCalendar) {
- occurences = calendarEvents[otherCalendar][cname];
- if (occurences) {
- for (var i = 0; i < occurences.length; i++) {
- var occurence = occurences[i];
- if (occurenceTime == null || occurenceTime == occurence[15]) {
- var nodes = occurence.blocks;
- for (var j = 0; j < nodes.length; j++) {
- var node = nodes[j];
- if (node.parentNode)
- node.parentNode.removeChild(node);
- }
- }
- }
- }
- }
- }
- }
- }
-
- resizeCalendarHeaderDIV();
-}
-
-function _deleteEventFromTables(calendar, cname, occurenceTime) {
- var basename = "-" + cname;
- if (occurenceTime) {
- basename = basename + "-" + occurenceTime;
- }
- if (calendarEvents[calendar]) {
- var occurences = calendarEvents[calendar][cname];
- if (occurences) {
- var occurence = occurences.first();
- var ownerIsOrganizer = occurence[19];
-
- // Delete event from events list
- var table = $("eventsList");
- var rows = table.tBodies[0].rows;
- for (var j = rows.length; j > 0; j--) {
- var row = $(rows[j - 1]);
- var id = row.getAttribute("id");
- var pos = id.indexOf(basename);
- if (pos > 0) {
- var otherCalendar = id.substr(0, pos);
- occurences = calendarEvents[otherCalendar][cname];
- if (occurences) {
- for (var k = 0; k < occurences.length; k++) {
- var occurence = occurences[k];
- if (calendar == otherCalendar || ownerIsOrganizer) {
- // This is the specified event or the same event in another
- // calendar. In this case, remove it only if the delete
- // operation is triggered from the organizer's calendar.
- if (occurenceTime == null || occurenceTime == occurence[15]) {
- row.parentNode.removeChild(row);
- break;
- }
- }
- }
- }
- }
- }
- }
- }
-
- // Delete task from tasks list
- var rows = $$("tr[id^='" + calendar + basename + "']");
- rows.each(function(row) {
- row.parentNode.removeChild(row);
- });
-}
-
-function _deleteCalendarEventCache(calendar, cname, occurenceTime) {
- var ownerIsOrganizer = false;
- if (calendarEvents[calendar]) {
- var occurences = calendarEvents[calendar][cname];
- if (occurences)
- ownerIsOrganizer = occurences[0][19];
- }
-
- for (var otherCalendar in calendarEvents) {
- if (calendarEvents[otherCalendar]) {
- var occurences = calendarEvents[otherCalendar][cname];
- if (occurences) {
- var newOccurences = [];
- for (var i = 0; i < occurences.length; i++) {
- var occurence = occurences[i];
- if (calendar == otherCalendar || ownerIsOrganizer) {
- // This is the specified event or the same event in another
- // calendar. In this case, remove it only if the delete
- // operation is triggered from the organizer's calendar.
- if (occurenceTime == null) {
- delete calendarEvents[otherCalendar][cname];
- }
- else if (occurenceTime != occurence[15]) {
- // || occurenceTime == occurence[15]) {
- newOccurences.push(occurence);
- }
- }
- }
- if (occurenceTime)
- calendarEvents[otherCalendar][cname] = newOccurences;
- }
- }
- }
-}
-
-/**
- * This is the Ajax callback function for _batchDeleteEvents.
- */
-function deleteEventCallback(http) {
- if (http.readyState == 4) {
- if (isHttpStatus204(http.status)) {
- var calendar = http.callbackData.calendar;
- var events = http.callbackData.events;
- for (var i = 0; i < events.length; i++) {
- var cname = /(.+)\/occurence([0-9]+)/.exec(events[i]) || [null, events[i]];
- _deleteCalendarEventBlocks(calendar, cname[1], cname[2]);
- _deleteEventFromTables(calendar, cname[1], cname[2]);
- _deleteCalendarEventCache(calendar, cname[1], cname[2]);
- }
- if (eventsToDelete.length)
- _batchDeleteEvents();
- else
- document.deleteEventAjaxRequest = null;
- }
- else if (parseInt(http.status) == 403)
- showAlertDialog(_("You don't have the required privileges to perform the operation."));
- else
- log ("deleteEventCallback Ajax error (" + http.status + ")");
- }
-}
-
-function getEventById(cname, owner) {
- var event = null;
-
- if (calendarEvents) {
- if (!owner)
- owner = UserLogin;
- var userEvents = calendarEvents[owner];
- if (userEvents)
- event = userEvents[cname];
- }
-
- return event;
-}
-
-function _editRecurrenceDialog(eventCell, method, params) {
- var targetname = "SOGo_edit_" + eventCell.cname + eventCell.recurrenceTime;
- var urlstr = (ApplicationBaseURL + "/" + eventCell.calendar + "/" + eventCell.cname
- + "/occurence" + eventCell.recurrenceTime + "/" + method);
- if (params && params.length) {
- urlstr += "?" + params;
- }
- var win = window.open(urlstr, "_blank",
- "width=490,height=70,resizable=0");
- if (win)
- win.focus();
-}
-
-function onViewEvent(event) {
- if (event.detail == 2) return;
- var url = ApplicationBaseURL + "/" + this.calendar + "/" + this.cname;
-
- if (typeof this.recurrenceTime != "undefined")
- url += "/occurence" + this.recurrenceTime;
- url += "/view";
- if (document.viewEventAjaxRequest) {
- document.viewEventAjaxRequest.aborted = true;
- document.viewEventAjaxRequest.abort();
- }
- document.viewEventAjaxRequest = triggerAjaxRequest(url, onViewEventCallback, this);
-}
-
-function onViewEventCallback(http) {
- if (http.readyState == 4 && http.status == 200) {
- if (http.responseText.length > 0) {
- var data = http.responseText.evalJSON(true);
- // $H(data).keys().each(function(key) {
- // log (key + " = " + data[key]);
- // });
- var cell = http.callbackData;
- var cellPosition = cell.cumulativeOffset();
- var cellDimensions = cell.getDimensions();
- var div = $("eventDialog");
- var divDimensions = div.getDimensions();
- var view;
- var left;
- var top = cellPosition[1] - 5;
-
- if (currentView != "monthview") {
- view = $("daysView");
- var viewPosition = view.cumulativeOffset();
-
- if (parseInt(data["isAllDay"]) == 0) {
- top -= view.scrollTop;
- if (viewPosition[1] > top + 2) {
- view.stopObserving("scroll", onBodyClickHandler);
- view.scrollTop = cell.offsetTop;
- top = viewPosition[1];
- Event.observe.delay(0.1, view, "scroll", onBodyClickHandler);
- }
- }
- }
- else {
- top -= cell.up("DIV.day").scrollTop;
- }
-
- left = cellPosition[0] + cellDimensions["width"] + 4;
- if (left + divDimensions["width"] > window.width()) {
- left = cellPosition[0] - divDimensions["width"];
- div.removeClassName("left");
- div.addClassName("right");
- }
- else {
- div.removeClassName("right");
- div.addClassName("left");
- }
-
- // Put the event's data in the DIV
- div.down("h1").update(data["summary"].replace(/\r?\n/g, "
"));
-
- var paras = div.getElementsByTagName("p");
- var para = $(paras[0]);
- if (parseInt(data["isAllDay"]) == 0) {
- para.down("SPAN").update(data["startTime"] + " - " + data["endTime"]);
- para.show();
- } else
- para.hide();
-
- para = $(paras[1]);
- if (data["calendar"].length) {
- para.down("SPAN", 1).update(data["calendar"]);
- para.show();
- } else
- para.hide();
-
- para = $(paras[2]);
- if (data["location"].length) {
- para.down("SPAN", 1).update(data["location"]);
- para.show();
- } else
- para.hide();
-
- para = $(paras[3]);
- if (data["created_by"].length) {
- para.down("SPAN", 1).update(data["created_by"]);
- para.show();
- } else
- para.hide();
-
- para = $(paras[4]);
- if (data["description"].length) {
- para.update(data["description"].replace(/\r?\n/g, "
"));
- para.show();
- } else
- para.hide();
-
- div.setStyle({ left: left + "px", top: top + "px" });
- div.show();
- configureLinks(div);
- }
- }
- else {
- log("onViewEventCallback ajax error (" + http.status + "): " + http.url);
- }
-}
-
-function editDoubleClickedEvent(event) {
- if (this.isException && this.recurrenceTime)
- _editEventId(this.cname, this.calendar, "occurence" + this.recurrenceTime);
- else if (this.recurrenceTime)
- _editRecurrenceDialog(this, "confirmEditing");
- else
- _editEventId(this.cname, this.calendar);
-
- Event.stop(event);
-}
-
-function performEventEdition(folder, event, recurrence) {
- _editEventId(event, folder, recurrence);
-}
-
-function performEventDeletion(folder, event, recurrence) {
- if (calendarEvents) {
- if (recurrence) {
- // Only one recurrence
- var occurenceTime = recurrence.substring(9);
- //var nodes = _eventBlocksMatching(folder, event, occurenceTime);
- var urlstr = ApplicationBaseURL + "/" + folder + "/" + event + "/" + recurrence + "/delete";
-
- document.deleteEventAjaxRequest = triggerAjaxRequest(urlstr,
- performDeleteEventCallback,
- { calendar: folder,
- cname: event,
- occurence: occurenceTime });
- }
- else {
- // All recurrences
- if (document.deleteEventAjaxRequest) {
- document.deleteEventAjaxRequest.aborted = true;
- document.deleteEventAjaxRequest.abort();
- }
- eventsToDelete.push([event]);
- calendarsOfEventsToDelete.push(folder);
- _batchDeleteEvents();
- }
- }
-}
-
-function performDeleteEventCallback(http) {
- if (http.readyState == 4) {
- if (isHttpStatus204(http.status)) {
-
- var occurenceTime = http.callbackData.occurence;
- var cname = http.callbackData.cname;
- var calendar = http.callbackData.calendar;
-
- _deleteCalendarEventBlocks(calendar, cname, occurenceTime);
- _deleteEventFromTables(calendar, cname, occurenceTime);
- _deleteCalendarEventCache(calendar, cname, occurenceTime);
- }
- }
-}
-
-/* in dateselector */
-function onDaySelect(node) {
- var day = node.getAttribute('day');
- var needRefresh = (eventListFilter == 'view_selectedday'
- && day != currentDay);
-
- var td = $(node).getParentWithTagName("td");
-
- // var table = $(td).getParentWithTagName("table");
- // log ("table.selected: " + table.selected);
-
- if (document.selectedDate)
- document.selectedDate.deselect();
-
- td.selectElement();
- document.selectedDate = td;
-
- changeCalendarDisplay( { "day": day } );
- currentDay = day;
- selectedDayDate = day;
- if (needRefresh)
- refreshEvents();
-
- return false;
-}
-
-function onDateSelectorGotoMonth(event) {
- var day = this.getAttribute("date");
-
- changeDateSelectorDisplay(day, true);
-
- Event.stop(event);
-}
-
-function onCalendarGotoDay(node) {
- var day = node.getAttribute("date");
- var needRefresh = (eventListFilter == 'view_selectedday' && day != currentDay);
-
- changeDateSelectorDisplay(day);
- changeCalendarDisplay( { "day": day } );
- if (needRefresh)
- refreshEvents();
-
- return false;
-}
-
-function gotoToday() {
- var todayDate = new Date();
- selectedDayDate = todayDate.getDayString();
- changeDateSelectorDisplay('');
- changeCalendarDisplay();
-
- return false;
-}
-
-function setDateSelectorContent(content) {
- var div = $("dateSelectorView");
-
- div.update(content);
- if (currentDay.length > 0)
- restoreCurrentDaySelection(div);
-
- initDateSelectorEvents();
-}
-
-function dateSelectorCallback(http) {
- if (http.readyState == 4
- && http.status == 200) {
- document.dateSelectorAjaxRequest = null;
- var content = http.responseText;
- setDateSelectorContent(content);
- cachedDateSelectors[http.callbackData] = content;
- }
- else
- log ("dateSelectorCallback Ajax error");
-}
-
-function eventsListCallback(http) {
- if (http.readyState == 4
- && http.status == 200) {
- var div = $("eventsListView");
- document.eventsListAjaxRequest = null;
- var table = $("eventsList");
- lastClickedRow = -1; // from generic.js
-
- var rows = table.select("TBODY TR");
- rows.each(function(e) {
- e.remove();
- });
-
- if (http.responseText.length > 0) {
- var data = http.responseText.evalJSON(true);
- for (var i = 0; i < data.length; i++) {
- var row = createElement("tr");
- table.tBodies[0].appendChild(row);
- row.addClassName("eventRow");
- var calendar = escape(data[i][1]);
- var rTime = data[i][16];
- var id = escape(data[i][1] + "-" + data[i][0]);
- if (rTime)
- id += "-" + escape(rTime);
- row.setAttribute("id", id);
- row.cname = escape(data[i][0]);
- row.calendar = calendar;
- if (rTime)
- row.recurrenceTime = escape(rTime);
- row.isException = data[i][17];
- row.editable = data[i][18] || IsSuperUser;
- row.erasable = data[i][19] || IsSuperUser;
- row.startDate = data[i][5];
- var startDate = new Date(data[i][5]*1000);
- row.day = startDate.getDayString();
- if (!data[i][8])
- row.hour = startDate.getHourString(); // event is not all day
- row.observe("mousedown", onRowClick);
- row.observe("selectstart", listRowMouseDownHandler);
- if (data[i][3] != null)
- // Status is defined -- event is readable
- row.observe("dblclick", editDoubleClickedEvent);
-
- var td = createElement("td");
- row.appendChild(td);
- td.observe("mousedown", listRowMouseDownHandler, true);
- var colorDiv = createElement("div", false, "colorBox calendarFolder" + calendar);
- td.appendChild(colorDiv);
- colorDiv.update(' ');
- var span = createElement("span");
- td.appendChild(span);
- span.update(data[i][4]); // title
-
- td = createElement("td");
- row.appendChild(td);
- td.observe("mousedown", listRowMouseDownHandler, true);
- td.update(data[i][21]); // start date
-
- td = createElement("td");
- row.appendChild(td);
- td.observe("mousedown", listRowMouseDownHandler, true);
- td.update(data[i][22]); // end date
-
- td = createElement("td");
- row.appendChild(td);
- td.observe("mousedown", listRowMouseDownHandler, true);
- if (data[i][7])
- td.update(data[i][7]); // location
-
- td = createElement("td");
- row.appendChild(td);
- td.observe("mousedown", listRowMouseDownHandler, true);
- if (data[i][10])
- td.update(data[i][10]); // category
-
- td = createElement("td");
- row.appendChild(td);
- td.observe("mousedown", listRowMouseDownHandler, true);
- td.update(data[i][2]); // calendar
- }
-
- if (sorting["event-header"] && sorting["event-header"].length > 0) {
- var sortHeader = $(sorting["event-header"]);
-
- if (sortHeader) {
- var sortImages = $(table.tHead).select(".sortImage");
- $(sortImages).each(function(item) {
- item.remove();
- });
-
- var sortImage = createElement("img", "messageSortImage", "sortImage");
- sortHeader.insertBefore(sortImage, sortHeader.firstChild);
- if (sorting["event-ascending"])
- sortImage.src = ResourcesURL + "/arrow-up.png";
- else
- sortImage.src = ResourcesURL + "/arrow-down.png";
- }
- }
- }
- configureEventsDraggables();
- }
- else
- log ("eventsListCallback Ajax error");
-}
-
-function activeTasksCallback(http) {
- if (http.readyState == 4 && http.status == 200) {
- if (http.responseText.length > 0) {
- document.activeTasksAjaxRequest = null;
- var data = http.responseText.evalJSON(true);
- var list = $("calendarList");
- var items = list.childNodesWithTag("li");
- for (var i = 0; i < items.length; i++) {
- var id = items[i].getAttribute("id").substr(1);
- var number = parseInt(data[id]);
- var input = items[i].childNodesWithTag("input")[0];
- var activeTasks = items[i].childNodesWithTag("span")[1];
- if (typeof activeTasks == "undefined") {
- if (number > 0) {
- activeTasks = createElement("span", null, "badge");
- items[i].appendChild(activeTasks);
- }
- }
- else if (number == 0) {
- items[i].removeChild(activeTasks);
- }
- if (number > 0) {
- activeTasks.innerHTML = number;
- }
- }
- }
- }
-}
-
-function tasksListCallback(http) {
- if (http.readyState == 4
- && http.status == 200) {
- var div = $("tasksListView");
- document.tasksListAjaxRequest = null;
- var table = $("tasksList");
- lastClickedRow = -1; // from generic.js
-
- var rows = table.select("TBODY TR");
- rows.each(function(e) {
- e.remove();
- });
-
- if (http.responseText.length > 0) {
- var data = http.responseText.evalJSON(true);
-
- // [0] Task ID
- // [1] Calendar ID
- // [2] Calendar name
- // [3] Status (0, 1 = completed, 2)
- // [4] Title
- // [5] Due date (int)
- // [6] Classification (0 = public, 1, = private, 2 = confidential)
- // [7] Location
- // [8] Category
- // [9] Editable?
- // [10] Erasable?
- // [11] Priority (0, 1 = important, 9 = low)
- // [12] Owner
- // [13] recurrence-id
- // [14] isException
- // [15] Status CSS class (duelater, completed, etc)
- // [16] Due date (formatted)
-
- for (var i = 0; i < data.length; i++) {
- var row = createElement("tr");
- table.tBodies[0].appendChild(row);
-
- row.on("dblclick", editDoubleClickedEvent);
-
- var calendar = escape(data[i][1]);
- var cname = escape(data[i][0]);
-
- var rTime = data[i][13];
- var id = escape(data[i][1] + "-" + data[i][0]);
- if (rTime)
- id += "-" + escape(rTime);
- row.setAttribute("id", id);
- //row.cname = escape(data[i][0]);
- //row.calendar = calendar;
- if (rTime)
- row.recurrenceTime = escape(rTime);
- row.isException = data[i][14];
-
-
- //row.setAttribute("id", calendar + "-" + cname);
- //listItem.addClassName(data[i][5]); // Classification
- //row.addClassName(data[i][14]); // status
- row.addClassName("taskRow");
- row.calendar = calendar;
- row.cname = cname;
- row.erasable = data[i][10] || IsSuperUser;
- if (parseInt(data[i][11]) == 1) {
- row.addClassName("important");
- }
- else if (parseInt(data[i][11]) == 9) {
- row.addClassName("low");
- }
-
- var cell = createElement("td");
- row.appendChild(cell);
- var input = createElement("input");
- input.setAttribute("type", "checkbox");
- cell.appendChild(input);
- input.setAttribute("value", "1");
- if (parseInt(data[i][9]) == 0) // editable?
- input.setAttribute("disabled", true);
- input.addClassName("checkBox");
- if (parseInt(data[i][3]) == 1) // completed?
- input.setAttribute("checked", "checked");
- input.observe("click", updateTaskStatus, true);
-
- cell = createElement("td");
- row.appendChild(cell);
- if (data[i][11] != null) {
- cell.update(_("prio_" + data[i][11])); // Priority
- }
- else {
- cell.update(""); // Priority
- }
-
- cell = createElement("td");
- row.appendChild(cell);
- var colorDiv = createElement("div", false, "colorBox calendarFolder" + calendar);
- cell.appendChild(colorDiv);
- colorDiv.update(' ');
- var t = new Element ("span");
- cell.appendChild(t);
- t.update(data[i][4]); // title
-
- cell = createElement("td");
- row.appendChild(cell);
- if (data[i][16])
- cell.update(data[i][16]); // end date
-
- cell = createElement("td");
- row.appendChild(cell);
- cell.update(data[i][7]); // location
-
- cell = createElement("td");
- row.appendChild(cell);
- cell.update(data[i][8]); // category
-
- cell = createElement("td");
- row.appendChild(cell);
- cell.update(data[i][2]); // calendar name
- }
-
- table.scrollTop = table.previousScroll;
-
- if (sorting["task-attribute"] && sorting["task-attribute"].length > 0) {
- var sortHeader = $(sorting["task-header"]);
-
- if (sortHeader) {
- var sortImages = $(table.tHead).select(".sortImage");
- $(sortImages).each(function(item) {
- item.remove();
- });
-
- var sortImage = createElement("img", "messageSortImage", "sortImage");
- sortHeader.insertBefore(sortImage, sortHeader.firstChild);
- if (sorting["task-ascending"])
- sortImage.src = ResourcesURL + "/arrow-up.png";
- else
- sortImage.src = ResourcesURL + "/arrow-down.png";
- }
- }
- if (http.callbackData) {
- var selectedNodesId = http.callbackData;
- for (var i = 0; i < selectedNodesId.length; i++) {
- // log(selectedNodesId[i] + " (" + i + ") is selected");
- var node = $(selectedNodesId[i]);
- if (node) {
- node.selectElement();
- }
- }
- }
- else
- log ("tasksListCallback: no data");
-
-
- }
- configureTasksDraggables();
- }
- }
- else
- log ("tasksListCallback Ajax error");
-}
-
-/* in dateselector */
-function restoreCurrentDaySelection(div) {
- var elements = $(div).select("TD.activeDay SPAN");
- if (elements.size()) {
- var day = elements[0].readAttribute('day');
- if (day.substr(0, 6) == currentDay.substr(0, 6)) {
- for (var i = 0; i < elements.length; i++) {
- day = elements[i].readAttribute('day');
- if (day && day == currentDay) {
- var td = $(elements[i]).getParentWithTagName("td");
- if (document.selectedDate)
- document.selectedDate.deselect();
- $(td).selectElement();
- document.selectedDate = td;
- }
- }
- }
- }
-}
-
-function loadPreviousView(event) {
- onCalendarGotoDay($("leftNavigationArrow"));
-}
-
-function loadNextView(event) {
- onCalendarGotoDay($("rightNavigationArrow"));
-}
-
-function changeDateSelectorDisplay(day, keepCurrentDay) {
- var url = ApplicationBaseURL + "/dateselector";
- if (day) {
- if (day.length < 8)
- day += "01";
- url += "?day=" + day;
- }
-
- if (!keepCurrentDay)
- currentDay = day;
-
- var month = day.substr(0, 6);
- if (cachedDateSelectors[month]) {
- // log ("restoring cached selector for month: " + month);
- setDateSelectorContent(cachedDateSelectors[month]);
- }
- else {
- // log ("loading selector for month: " + month);
- if (document.dateSelectorAjaxRequest) {
- document.dateSelectorAjaxRequest.aborted = true;
- document.dateSelectorAjaxRequest.abort();
- }
- document.dateSelectorAjaxRequest
- = triggerAjaxRequest(url,
- dateSelectorCallback,
- month);
- }
-}
-
-function changeCalendarDisplay(data, newView) {
- newView = ((newView) ? newView : currentView);
- var url = ApplicationBaseURL + "/" + newView;
- var day = null;
- var scrollEvent = null;
- if (data) {
- day = data['day'];
- scrollEvent = data['scrollEvent'];
- }
-
- if (!day)
- day = currentDay;
-
- if (day) {
- if (data) {
- var dayDiv = $("day"+day);
- if (dayDiv) {
- // Don't reload the view if the event is present in current view
-
- // Deselect day in date selector
- if (document.selectedDate)
- document.selectedDate.deselect();
-
- // Select day in date selector
- var selectedLink = $$('table#dateSelectorTable span[day='+day+']');
- if (selectedLink.length > 0) {
- selectedCell = selectedLink[0].getParentWithTagName("td");
- $(selectedCell).selectElement();
- document.selectedDate = selectedCell;
- } else
- document.selectedDate = null;
-
- // Scroll to event
- if (scrollEvent) {
- preventAutoScroll = false;
- scrollDayView(scrollEvent);
- }
-
- setSelectedDayDate(day);
-
- return false;
- }
- else if (day.length == 6) {
- day += "01";
- }
- }
- url += "?day=" + day;
- }
-
- selectedCalendarCell = null;
-
- if (document.dayDisplayAjaxRequest) {
- document.dayDisplayAjaxRequest.aborted = true;
- document.dayDisplayAjaxRequest.abort();
- }
- document.dayDisplayAjaxRequest
- = triggerAjaxRequest(url, calendarDisplayCallback,
- { "view": newView,
- "day": day,
- "scrollEvent": scrollEvent });
-
- return false;
-}
-
-function _ensureView(view) {
- if (currentView != view)
- changeCalendarDisplay(null, view);
-
- return false;
-}
-
-function onDayOverview() {
- return _ensureView("dayview");
-}
-
-function onMulticolumnDayOverview() {
- return _ensureView("multicolumndayview");
-}
-
-function onWeekOverview() {
- return _ensureView("weekview");
-}
-
-function onMonthOverview() {
- return _ensureView("monthview");
-}
-
-function refreshEventsAndTasks() {
- refreshEvents();
- refreshTasks();
-}
-
-function initRefreshViewCheckTimer() {
- var refreshViewCheck = UserDefaults["SOGoRefreshViewCheck"];
- if (refreshViewCheck && refreshViewCheck != "manually") {
- var interval;
- if (refreshViewCheck == "once_per_hour")
- interval = 3600;
- else if (refreshViewCheck == "every_minute")
- interval = 60;
- else {
- interval = parseInt(refreshViewCheck.substr(6)) * 60;
- }
- refreshViewCheckTimer = window.setInterval(onRefreshViewCheckCallback,
- interval * 1000);
- }
-}
-
-function onRefreshViewCheckCallback(event) {
- onCalendarReload();
-}
-
-function onCalendarReload() {
- if (!reloadWebCalendars()) {
- refreshEventsAndTasks();
- changeCalendarDisplay();
- }
-
- return false;
-}
-
-function reloadWebCalendars() {
- var remaining = [];
- var refreshOperations = { "remaining": remaining };
- if (UserSettings['Calendar']
- && UserSettings['Calendar']['WebCalendars']) {
- var webCalendars = UserSettings['Calendar']['WebCalendars'];
-
- var folders = $("calendarList");
- var calendarNodes = folders.childNodesWithTag("li");
- for (var i = 0; i < calendarNodes.length; i++) {
- var current = calendarNodes[i];
- var calendarID = current.getAttribute("id");
- var owner = current.getAttribute("owner");
- var realID = owner + ":Calendar/" + calendarID.substr(1);
- if (webCalendars[realID]) { /* is web calendar ? */
- remaining.push(realID);
- reloadWebCalendar(realID, refreshOperations);
- }
- }
- }
-
- return (remaining.length > 0);
-}
-
-var calendarReloadErrors = { "invalid-calendar-content":
- _("the returned content was not valid calendar"
- + " data"),
- "http-error": _("an unknown http error occurred"
- + " during the load operation"),
- "bad-url": _("the url in use is invalid or the"
- + " host is currently unreachable"),
- "invalid-url": _("the url being used is invalid"
- + " or not handled") };
-
-function reloadWebCalendar(folderID, refreshOperations) {
- var url = URLForFolderID(folderID) + "/reload";
- var cbData = { "folderID": folderID };
- if (refreshOperations) {
- cbData["refreshOperations"] = refreshOperations;
- }
- triggerAjaxRequest(url, reloadWebCalendarCallback, cbData);
-}
-
-function reloadWebCalendarCallback(http) {
- var cbData = http.callbackData;
- if (http.status == 200) {
- var result = http.responseText.evalJSON(true);
- var requireAuth = false;
- var success = false;
- if (result.status) {
- if (result.status == 401) {
- requireAuth = true;
- }
- else {
- if (result.status == 200) {
- success = true;
- }
- else {
- var errorMessage = _("An error occurred while importing calendar.");
- if (result["error"]) {
- var message = calendarReloadErrors[result["error"]];
- errorMessage = (_("An error occurred while loading remote"
- + " calendar: %{0}.").formatted(message));
- }
- showAlertDialog (errorMessage);
- }
- }
- }
- else {
- var errorMessage = _("An error occurred while importing calendar.");
- if (result["error"]) {
- var message = calendarReloadErrors[result["error"]];
- errorMessage = (_("An error occurred while loading remote"
- + " calendar: %{0}.").formatted(message));
- }
- showAlertDialog (errorMessage);
- }
-
- if (requireAuth) {
- reauthenticateWebCalendar(cbData["folderID"], cbData);
- }
- else {
- var refreshOperations = cbData["refreshOperations"];
- if (refreshOperations) {
- var remaining = refreshOperations["remaining"];
- var calIdx = remaining.indexOf(cbData["folderID"]);
- remaining.splice(calIdx, 1);
- if (remaining.length == 0) {
- refreshEventsAndTasks();
- changeCalendarDisplay();
- }
- }
- else {
- if (success) {
- refreshEventsAndTasks();
- changeCalendarDisplay();
- }
- }
- }
- }
- else {
- showAlertDialog(_("An error occurred while importing calendar."));
- var refreshOperations = cbData["refreshOperations"];
- if (refreshOperations) {
- var remaining = refreshOperations["remaining"];
- var calIdx = remaining.indexOf(cbData["folderID"]);
- remaining.splice(calIdx, 1);
- if (remaining.length > 0) {
- var newFolderID = remaining[0];
- reloadWebCalendar(newFolderID, refreshOperations);
- }
- }
- }
-}
-
-function reauthenticateWebCalendar(folderID, refreshCBData) {
- var remoteURL = null;
- if (UserSettings['Calendar'] && UserSettings['Calendar']['WebCalendars']) {
- var webCalendars = UserSettings['Calendar']['WebCalendars'];
- remoteURL = webCalendars[folderID];
- }
- var parts = remoteURL.split("/");
- var hostname = parts[2];
- function authenticate(username, password) {
- disposeDialog();
- var url = URLForFolderID(folderID) + "/set-credentials";
- var parameters = ("username=" + encodeURIComponent(username)
- + "&password=" + encodeURIComponent(password));
- triggerAjaxRequest(url, authenticateWebCalendarCallback, refreshCBData, parameters,
- { "Content-type": "application/x-www-form-urlencoded" });
- }
- showAuthenticationDialog(_("Please identify yourself to %{0}")
- .formatted(hostname),
- authenticate);
-}
-
-function authenticateWebCalendarCallback(http) {
- var cbData = http.callbackData;
- var folderID = cbData["folderID"];
- var refreshOperations = cbData["refreshOperations"];
- if (isHttpStatus204(http.status)) {
- reloadWebCalendar(folderID, refreshOperations);
- }
- else {
- if (refreshOperations) {
- var remaining = refreshOperations["remaining"];
- var calIdx = remaining.indexOf(folderID);
- remaining.splice(calIdx, 1);
- if (remaining.length > 0) {
- var newFolderID = remaining[0];
- reloadWebCalendar(newFolderID, refreshOperations);
- }
- }
- }
-}
-
-function scrollDayView(scrollEvent) {
- if (!preventAutoScroll) {
- if (scrollEvent) {
- var contentView;
- var eventRow = $(scrollEvent);
- if (eventRow) {
- var eventBlocks = selectCalendarEvent(eventRow.calendar, eventRow.cname, eventRow.recurrenceTime);
- if (eventBlocks) {
- var firstEvent = eventBlocks.first();
-
- if (currentView == "monthview")
- contentView = firstEvent.up("DIV.day");
- else
- contentView = $("daysView");
-
- // Don't scroll to an all-day event
- if (typeof eventRow.hour != "undefined") {
- var top = firstEvent.cumulativeOffset()[1] - contentView.scrollTop;
- // Don't scroll if the event is visible to the user
- if (top < contentView.cumulativeOffset()[1])
- contentView.scrollTop = firstEvent.cumulativeOffset()[1] - contentView.cumulativeOffset()[1];
- else if (top > contentView.cumulativeOffset()[1] + contentView.getHeight() - firstEvent.getHeight())
- contentView.scrollTop = firstEvent.cumulativeOffset()[1] - contentView.cumulativeOffset()[1];
- }
- }
- }
- }
- else if (currentView != "monthview") {
- var contentView = $("daysView");
- var hours = (contentView.childNodesWithTag("div")[0]).childNodesWithTag("div");
- contentView.scrollTop = hours[dayStartHour].offsetTop;
- }
- }
-}
-
-function onClickableCellsDblClick(event) {
- var target = getTarget(event);
- // Hack to ignore double-click in the scrollbar
- if (target.hasClassName("dayHeader") || (this.scrollHeight - this.clientHeight <= 1)) {
- newEventFromWidget(this, 'event');
- Event.stop(event);
- }
-}
-
-function refreshCalendarEvents(scrollEvent) {
- var todayDate = new Date();
- var sd;
- var ed;
-
- if (!currentDay)
- currentDay = todayDate.getDayString();
-
- if (currentView == "dayview" || currentView == "multicolumndayview") {
- sd = currentDay;
- ed = sd;
- }
- else if (currentView == "weekview") {
- var startDate;
- startDate = currentDay.asDate();
- startDate = startDate.beginOfWeek();
- sd = startDate.getDayString();
- var endDate = new Date();
- endDate.setTime(startDate.getTime());
- endDate.addDays(6);
- ed = endDate.getDayString();
- }
- else {
- var monthDate;
- monthDate = currentDay.asDate();
- monthDate.setDate(1);
- sd = monthDate.beginOfWeek().getDayString();
-
- var lastMonthDate = new Date();
- lastMonthDate.setTime(monthDate.getTime());
- lastMonthDate.setMonth(monthDate.getMonth() + 1);
- lastMonthDate.addDays(-1);
- ed = lastMonthDate.endOfWeek().getDayString();
- }
- if (document.refreshCalendarEventsAjaxRequest) {
- document.refreshCalendarEventsAjaxRequest.aborted = true;
- document.refreshCalendarEventsAjaxRequest.abort();
- }
- var url = (ApplicationBaseURL + "/eventsblocks?sd=" + sd + "&ed=" + ed
- + "&view=" + currentView);
- document.refreshCalendarEventsAjaxRequest
- = triggerAjaxRequest(url, refreshCalendarEventsCallback,
- {"startDate": sd, "endDate": ed,
- "scrollEvent": scrollEvent});
-}
-
-function _parseEvents(list, calendars) {
- var newCalendarEvents = {};
-
- if (currentView == "multicolumndayview") {
- var list;
- for (var i = 0; i < calendars.length; i++) {
- list = calendars[i][0];
- for (var j = 0; j < list.length; j++) {
- var event = list[j];
- var cname = event[0];
- var calendar = event[1];
- // log("parsed cname: " + cname + "; calendar: " + calendar);
- var calendarDict = newCalendarEvents[calendar];
- if (!calendarDict) {
- calendarDict = {};
- newCalendarEvents[calendar] = calendarDict;
- }
- var occurences = calendarDict[cname];
- if (!occurences) {
- occurences = [];
- calendarDict[cname] = occurences;
- }
- event.blocks = [];
- occurences.push(event);
- }
- }
- }
- else {
- for (var i = 0; i < list.length; i++) {
- var event = list[i];
- var cname = event[0];
- var calendar = event[1];
- // log("parsed cname: " + cname + "; calendar: " + calendar);
- var calendarDict = newCalendarEvents[calendar];
- if (!calendarDict) {
- calendarDict = {};
- newCalendarEvents[calendar] = calendarDict;
- }
- var occurences = calendarDict[cname];
- if (!occurences) {
- occurences = [];
- calendarDict[cname] = occurences;
- }
- event.blocks = [];
- occurences.push(event);
- }
-
- }
- return newCalendarEvents;
-}
-
-function _setupEventsDragAndDrop(events) {
- /* We setup the drag controllers for all the events.
- Since the same events may be listed more than once per calendar
- (repeating events), we must keep account of those that have already
- been setup. */
- var setupFlags = {};
-
- for (var i = 0; i < events.length; i++) {
- var cname = events[i][0];
- var calendar = events[i][1];
- var setupId = calendar + "_" + cname;
- if (!setupFlags[setupId]) {
- var occurrences = calendarEvents[calendar][cname];
- for (var j = 0; j < occurrences.length; j++) {
- var blocks = occurrences[j].blocks;
- var dragController = new SOGoEventDragController();
- dragController.updateDropCallback = updateEventFromDragging;
- if (blocks.length > 0)
- // Ignore events that have no visible blocks
- dragController.attachToEventCells(blocks);
- }
- setupFlags[setupId] = true;
- }
- }
-}
-
-function refreshCalendarEventsCallback(http) {
- if (http.readyState == 4
- && http.status == 200) {
- if (http.responseText.length > 0) {
- var eventsBlocks = http.responseText.evalJSON(true);
-
- if (currentView == "multicolumndayview") {
- calendarEvents = _parseEvents(null, eventsBlocks);
- _drawCalendarAllDayEvents(null, null, eventsBlocks);
- _drawCalendarEvents(null, null, eventsBlocks);
- for (var i = 0 ; i < eventsBlocks.length; i++) {
- _setupEventsDragAndDrop(eventsBlocks[i][0]);
- }
- }
- else {
- calendarEvents = _parseEvents(eventsBlocks[0], null);
- allDayEventsList = eventsBlocks[1];
- eventsList = eventsBlocks[2];
- if (currentView == "monthview")
- _drawMonthCalendarEvents(eventsList, eventsBlocks[0], null);
- else {
- _drawCalendarAllDayEvents(allDayEventsList, eventsBlocks[0], null);
- _drawCalendarEvents(eventsList, eventsBlocks[0], null);
- }
- _setupEventsDragAndDrop(eventsBlocks[0]);
- }
- resetCategoriesStyles();
- onWindowResize(null);
- }
- if (http.callbackData["scrollEvent"])
- preventAutoScroll = false;
- scrollDayView(http.callbackData["scrollEvent"]);
- }
- else
- log("AJAX error when refreshing calendar events");
-}
-
-function resetCategoriesStyles() {
- if (categoriesStyleSheet == null) {
- categoriesStyleSheet = document.createElement("style");
- categoriesStyleSheet.type = "text/css";
- document.getElementsByTagName("head")[0].appendChild(categoriesStyleSheet);
- }
- else {
- if (Prototype.Browser.IE)
- while (categoriesStyleSheet.styleSheet.rules.length)
- categoriesStyleSheet.styleSheet.removeRule();
- else
- while (categoriesStyleSheet.firstChild)
- categoriesStyleSheet.removeChild(categoriesStyleSheet.firstChild);
- }
-
- if (UserDefaults['SOGoCalendarCategoriesColors']) {
- // Update stylesheet with new categories colors
- var selectors = [];
- var rules = [];
- categoriesStyles.keys().each(function(category) {
- var color = UserDefaults['SOGoCalendarCategoriesColors'][category];
- if (color) {
- rules.push('border-right: 8px solid ' + color);
- selectors.push('DIV.' + categoriesStyles.get(category));
- }
- });
-
- if (selectors.length > 0) {
- if (categoriesStyleSheet.styleSheet && categoriesStyleSheet.styleSheet.addRule) {
- // IE
- for (var i = 0; i < selectors.length; i++) {
- categoriesStyleSheet.styleSheet.addRule(selectors[i],
- rules[i]);
- }
- }
- else {
- // Mozilla + Safari
- for (var i = 0; i < selectors.length; i++) {
- categoriesStyleSheet.appendChild(document.createTextNode(selectors[i] +
- ' { ' + rules[i] + '; }'));
- }
- }
- }
- }
-}
-
-function newBaseEventDIV(eventRep, event, eventText) {
- // log ("0 cname = " + event[0]);
- // log ("1 calendar = " + event[1]);
- // log ("2 calendar name = " + event[2]);
- // log ("3 status = " + event[3]);
- // log ("4 title = " + event[4]);
- // log ("5 start = " + event[5]);
- // log ("6 end = " + event[6]);
- // log ("7 location = " + event[7]);
- // log ("8 isallday = " + event[8]);
- // log ("9 classification = " + event[9]); // 0 = public, 1 = private, 2 = confidential
- // log ("10 category = " + event[10]);
- // log ("11 participants emails = " + event[11]);
- // log ("12 participants states = " + event[12]);
- // log ("13 owner = " + event[13]);
- // log ("14 iscycle = " + event[14]);
- // log ("15 nextalarm = " + event[15]);
- // log ("16 recurrenceid = " + event[16]);
- // log ("17 isexception = " + event[17]);
- // log ("18 editable = " + event[18]);
- // log ("19 erasable = " + event[19]);
- // log ("20 ownerisorganizer = " + event[20]);
-
- var eventCell = createElement("div");
- eventCell.cname = event[0];
- eventCell.calendar = event[1];
- var startDate = new Date(event[5]*1000);
- if (startDate) {
- eventCell.startDate = event[5];
- eventCell.writeAttribute('day', startDate.getDayString());
- eventCell.writeAttribute('hour', event[8]? 'allday' : startDate.getHourString());
- }
- // if (event[8] == 1)
- // eventCell.addClassName("private");
- // else if (event[8] == 2)
- // eventCell.addClassName("confidential");
- if (eventRep.recurrenceTime)
- eventCell.recurrenceTime = eventRep.recurrenceTime;
- //eventCell.owner = event[12];
- eventCell.isException = event[17];
- eventCell.editable = event[18];
- eventCell.erasable = event[19] || IsSuperUser;
- eventCell.ownerIsOrganizer = event[20];
- eventCell.addClassName("event");
- // if (event[14] > 0)
- // eventCell.addClassName("alarm");
-
- var innerDiv = createElement("div");
- eventCell.appendChild(innerDiv);
- innerDiv.addClassName("eventInside");
- innerDiv.addClassName("calendarFolder" + event[1]);
- if (eventRep.userState >= 0 && userStates[eventRep.userState])
- innerDiv.addClassName(userStates[eventRep.userState]);
-
- var gradientDiv = createElement("div");
- innerDiv.appendChild(gradientDiv);
- gradientDiv.addClassName("gradient");
-
- var gradientImg = createElement("img");
- gradientDiv.appendChild(gradientImg);
- gradientImg.src = ResourcesURL + "/event-gradient.png";
-
- var textDiv = createElement("div");
- innerDiv.appendChild(textDiv);
- textDiv.addClassName("text");
- var iconSpan = createElement("span", null, "icons");
- textDiv.update(eventText.replace(/(\\r)?\\n/g, "
"));
- textDiv.appendChild(iconSpan);
-
- // Add alarm and classification icons
- if (event[9] == 1)
- createElement("img", null, null, {src: ResourcesURL + "/private.png"}, null, iconSpan);
- else if (event[9] == 2)
- createElement("img", null, null, {src: ResourcesURL + "/confidential.png"}, null, iconSpan);
- if (event[15] > 0)
- createElement("img", null, null, {src: ResourcesURL + "/alarm.png"}, null, iconSpan);
-
- if (event[10] != null) {
- var category = event[10].decodeEntities();
- var categoryStyle = categoriesStyles.get(category);
- if (!categoryStyle) {
- categoryStyle = 'category_' + categoriesStyles.keys().length;
- categoriesStyles.set([category], categoryStyle);
- }
- innerDiv.addClassName(categoryStyle);
- }
- eventCell.observe("contextmenu", onMenuCurrentView);
-
- if (event[3] == null) {
- // Status field is not defined -- user can't read event
- eventCell.observe("selectstart", listRowMouseDownHandler);
- eventCell.observe("click", onCalendarSelectEvent);
- eventCell.observe("dblclick", Event.stop);
- }
- else {
- // Status field is defined -- user can read event
- eventCell.observe("mousedown", listRowMouseDownHandler);
- eventCell.observe("click", onCalendarSelectEvent);
- eventCell.observe("dblclick", editDoubleClickedEvent);
- eventCell.observe("click", onViewEvent);
- }
-
- event.blocks.push(eventCell);
-
- return eventCell;
-}
-
-function _drawCalendarAllDayEvents(events, eventsData, columnsData) {
- var headerView = $("calendarHeader");
- var subdivs = headerView.childNodesWithTag("div");
-
- if (currentView == "multicolumndayview"){
- var days = subdivs[2].childNodesWithTag("div");
- for (var i = 0; i < days.length; i++) {
- var parentDiv = days[i];
- var calendar = columnsData[i];
- var calendarAllDayEvents = calendar[1][0];
- var calendarAllDayEventsData = calendar[0];
- for (var j = 0; j < calendarAllDayEvents.length; j++) {
- var eventRep = calendarAllDayEvents[j];
- var nbr = eventRep.nbr;
- var eventCell = newAllDayEventDIV(eventRep, calendarAllDayEventsData[nbr]);
- parentDiv.appendChild(eventCell);
- }
- }
- }
- else {
- var days = subdivs[1].childNodesWithTag("div");
- for (var i = 0; i < days.length; i++) {
- var parentDiv = days[i];
- for (var j = 0; j < events[i].length; j++) {
- var eventRep = events[i][j];
- var nbr = eventRep.nbr;
- var eventCell = newAllDayEventDIV(eventRep, eventsData[nbr]);
- parentDiv.appendChild(eventCell);
- }
- }
- }
- resizeCalendarHeaderDIV();
-}
-
-/* When the list of all day events overflows, we resize it in order to contain
- at least 6 or 7 items. Afterwards we restore the regular scrollbar
- mechanism. */
-function resizeCalendarHeaderDIV() {
- var headerView = $("calendarHeader");
- var daysView = $("daysView");
- if (headerView && daysView) {
- /* consts */
- var headerViewBaseHeight = 90;
- var daysViewBaseTop = 95;
- /* /consts */
-
- var maxEventPerDay = 0;
-
- var subdivs = headerView.childNodesWithTag("div");
- if (currentView == "multicolumndayview")
- var days = subdivs[2].childNodesWithTag("div");
- else
- var days = subdivs[1].childNodesWithTag("div");
- for (var i = 0; i < days.length; i++) {
- var parentDiv = days[i];
- var divs = parentDiv.childNodesWithTag("div");
- if (divs.length > maxEventPerDay) {
- maxEventPerDay = divs.length;
- }
- }
- if (maxEventPerDay > 0 && maxEventPerDay <= 4) {
- var moveDaysView = (maxEventPerDay * 19.5);
- var expendHeaderHeight = ((maxEventPerDay - 1) * 20);
- var deltaMax = 60;
- if (expendHeaderHeight > deltaMax){
- expendHeaderHeight = deltaMax;
- moveDaysView = deltaMax;
- }
- daysView.style.top = String(daysViewBaseTop + moveDaysView) + "px";
- headerView.style.height = String(headerViewBaseHeight + expendHeaderHeight) + "px";
- }
-
- else if (maxEventPerDay > 4) {
- var deltaMax = 60;
- daysView.style.top = String(daysViewBaseTop + deltaMax + 19) + "px";
- headerView.style.height = String(headerViewBaseHeight + deltaMax) + "px";
- }
- else {
- var headerDays = document.getElementsByClassName("days")[0];
- headerDays.observe("mouseenter", function(event){
- headerDays.style.zIndex = "1";
- });
- headerDays.observe("mouseleave", function(event){
- headerDays.style.zIndex = "0";
- });
- daysView.style.top = null;
- headerView.style.height = null;
- }
- }
-}
-
-function newAllDayEventDIV(eventRep, event) {
- // cname, calendar, starts, lasts,
- // startHour, endHour, title) {
- var eventCell = newBaseEventDIV(eventRep, event, event[4]);
-
- return eventCell;
-}
-
-function _drawCalendarEvents(events, eventsData, columnsData) {
- var daysView = $("daysView");
- var subdivs = daysView.childNodesWithTag("div");
- for (var i = 0; i < subdivs.length; i++) {
- var subdiv = subdivs[i];
- if (subdiv.hasClassName("days")) {
- var days = subdiv.childNodesWithTag("div");
- if (currentView == "multicolumndayview") {
- for (var j = 0; j < days.length; j++) {
- var parentDiv = days[j].childNodesWithTag("div")[0];
- var calendar = columnsData[j];
- var calendarEvents = calendar[2][0];
- var calendarEventsData = calendar[0];
- for (var k = 0; k < calendarEvents.length; k++) {
- var eventRep = calendarEvents[k];
- var nbr = eventRep.nbr;
- var eventCell = newEventDIV(eventRep, calendarEventsData[nbr]);
- parentDiv.appendChild(eventCell);
- }
- }
- }
- else {
- for (var j = 0; j < days.length; j++) {
- var parentDiv = days[j].childNodesWithTag("div")[0];
- for (var k = 0; k < events[j].length; k++) {
- var eventRep = events[j][k];
- var nbr = eventRep.nbr;
- var eventCell = newEventDIV(eventRep, eventsData[nbr]);
- parentDiv.appendChild(eventCell);
- }
- }
- }
- }
- }
- }
-}
-
-function newEventDIV(eventRep, event) {
- var eventCell = newBaseEventDIV(eventRep, event, event[4]);
-
- var pc = 100 / eventRep.siblings;
- var left = eventRep.position * pc;
- eventCell.style.left = left + "%";
- var right = 100 - (eventRep.position + 1) * pc;
-
- eventCell.style.right = right + "%";
- eventCell.addClassName("starts" + eventRep.start);
- eventCell.addClassName("lasts" + eventRep.length);
-
- if (event[7]) {
- var inside = eventCell.childNodesWithTag("div")[0];
- var textDiv = inside.childNodesWithTag("div")[1];
- textDiv.appendChild(createElement("br"));
- var span = createElement("span", null, "location");
- var text = _("Location:") + " " + event[7];
- span.update(text);
- textDiv.appendChild(span);
- }
-
- return eventCell;
-}
-
-function _drawMonthCalendarEvents(events, eventsData) {
- var daysView = $("monthDaysView");
- var days = daysView.childNodesWithTag("div");
- for (var i = 0; i < days.length; i++) {
- var parentDiv = days[i];
- for (var j = 0; j < events[i].length; j++) {
- var eventRep = events[i][j];
- var nbr = eventRep.nbr;
- var eventCell = newMonthEventDIV(eventRep, eventsData[nbr]);
- parentDiv.appendChild(eventCell);
- }
- }
-}
-
-function newMonthEventDIV(eventRep, event) {
- var eventText;
- if (event[8]) // all-day event
- eventText = event[4];
- else
- eventText = eventRep.starthour + " - " + event[4];
-
- var eventCell = newBaseEventDIV(eventRep, event,
- eventText);
-
- return eventCell;
-}
-
-function attachDragControllers(contentView) {
- var dayNodes = contentView.select("DIV.days DIV.day");
- for (var j = 0; j < dayNodes.length; j++) {
- var dayNode = dayNodes[j];
- if (dayNode.hasClassName("day")) {
- var dragController = new SOGoEventDragController();
- dragController.createDropCallback = newEventFromDragging;
- dragController.attachToDayNode(dayNode);
- }
- }
-}
-
-/* On IE, the scroll bar is part of the last element. For other browsers, we
- execute this method so that the "right" style attribute of the
- "calendarHeader" element can be computed. This is execute only once. */
-function adjustCalendarHeaderDIV() {
- var dv = $("daysView");
- if (dv) {
- var ch = $("calendarHeader");
- var delta = ch.clientWidth - dv.clientWidth - 1;
- var styleElement = document.createElement("style");
- styleElement.type = "text/css";
- var selectors = ["DIV#calendarHeader DIV.calendarLabels",
- "DIV#calendarHeader DIV.dayLabels",
- "DIV#calendarHeader DIV.days"];
- var rule = ("right: " + delta + "px");
- if (styleElement.styleSheet && styleElement.styleSheet.addRule) {
- // IE
- for (var i = 0; i < selectors.length; i++) {
- styleElement.styleSheet.addRule(selectors[i], rule);
- }
- } else {
- // Mozilla + Firefox
- var styleText = selectors.join(",") + " { " + rule + "; }";
- styleElement.appendChild(document.createTextNode(styleText));
- }
- document.getElementsByTagName("head")[0].appendChild(styleElement);
- calendarHeaderAdjusted = true;
- }
-}
-
-function adjustMultiColumnCalendarHeaderDIV() {
- var ch = $("calendarHeader");
- var calendarLabels = ch.getElementsByClassName("calendarLabels")[0];
- var calendarsToDisplay = calendarLabels.getElementsByClassName("calendarsToDisplay");
- var dayLabels = ch.getElementsByClassName("dayLabels")[0].getElementsByClassName("dayColumn")[0];
- var days = ch.getElementsByClassName("days")[0].getElementsByClassName("dayColumn");
- var daysView = $("daysView").getElementsByClassName("dayColumn");
-
- var nbCalendars = calendarsToDisplay.length;
-
- if (nbCalendars > 0) {
- var width = 100/nbCalendars;
- var left = 0;
- var position = "absolute";
- for(var i=0; i < nbCalendars; i++){
- calendarsToDisplay[i].setStyle({ width: width + '%', left: left + '%', position: position}).show();
- days[i].setStyle({ width: width + '%', left: left + '%'}).show();
- daysView[i].setStyle({ width: width + '%', left: left + '%'}).show();
- left += width;
- }
- dayLabels.setStyle({ width: '100%'}).show();
- }
- else {
- $("calendarHeader").remove();
- $("daysView").remove();
- $("calendarContent").style.height = "100%";
- $("calendarContent").style.background = "#E7E7E7";
- }
-}
-
-function calendarDisplayCallback(http) {
- var div = $("calendarView");
- var daysView = $("daysView");
- var position = -1;
-
- // Check the previous view to restore the scrolling position
- if (daysView)
- position = daysView.scrollTop;
- preventAutoScroll = (position != -1);
-
- if (http.readyState == 4
- && http.status == 200) {
- document.dayDisplayAjaxRequest = null;
- div.update(http.responseText);
-
- // DOM has changed
- daysView = $("daysView");
- if (daysView) {
- if (preventAutoScroll)
- daysView.scrollTop = position;
- if (!calendarHeaderAdjusted)
- adjustCalendarHeaderDIV();
- }
-
- if (http.callbackData["view"])
- currentView = http.callbackData["view"];
- if (http.callbackData["day"])
- currentDay = http.callbackData["day"];
-
- if (currentView == "multicolumndayview")
- adjustMultiColumnCalendarHeaderDIV();
-
- if (currentView == "multicolumndayview")
- adjustMultiColumnCalendarHeaderDIV();
-
- // Initialize contextual menu
- var menu = new Array(onMenuNewEventClick,
- onMenuNewTaskClick,
- "-",
- loadPreviousView,
- loadNextView,
- "-",
- deleteEvent,
- copyEventToPersonalCalendar,
- onMenuRawEvent
- );
- var observer;
- if (currentView == 'dayview' || currentView == 'weekview' || currentView == 'multicolumndayview') {
- observer = $("daysView");
- }
- else {
- observer = $("monthDaysView");
- }
-
- var contentView;
- if (currentView == "monthview")
- contentView = $("calendarContent");
- else {
- contentView = $("daysView");
- contentView.observe("scroll", onBodyClickHandler);
- attachDragControllers($("calendarHeader"));
-
- // Create a clone of the contextual menu for the all-day
- // events area
- var allDayViewMenu = Element.clone($("currentViewMenu"), true);
- allDayViewMenu.id = "allDayViewMenu";
- var newEventMenuItem = allDayViewMenu.select("LI").first();
- newEventMenuItem.writeAttribute("hour", "allday");
- $("currentViewMenu").parentNode.appendChild(allDayViewMenu);
- initMenu($("allDayViewMenu"), menu);
- var allDayArea = $$("DIV#calendarHeader DIV.days").first();
- allDayArea.observe("contextmenu", onMenuAllDayView);
- }
- attachDragControllers(contentView);
-
- // Attach contextual menu
- var currentViewMenu = $("currentViewMenu");
- initMenu(currentViewMenu, menu);
- observer.observe("contextmenu", onMenuCurrentView);
- currentViewMenu.prepareVisibility = onMenuCurrentViewPrepareVisibility;
-
- restoreSelectedDay();
-
- refreshCalendarEvents(http.callbackData.scrollEvent);
-
- var days = contentView.select("DIV.day");
-
- if (currentView == "monthview")
- for (var i = 0; i < days.length; i++) {
- days[i].observe("click", onCalendarSelectDay);
- days[i].observe("dblclick", onClickableCellsDblClick);
- days[i].observe("selectstart", listRowMouseDownHandler);
- //days[i].down(".dayHeader").observe("selectstart", listRowMouseDownHandler);
- if (currentView == "monthview")
- days[i].observe("scroll", onBodyClickHandler);
- }
- else if (currentView == "multicolumndayview") {
- var calendarHeader = $("calendarHeader");
- var headerCalendarsLabels = calendarHeader.select("DIV.calendarLabels DIV.calendarsToDisplay");
- var headerDays = calendarHeader.select("DIV.days DIV.day");
- for (var i = 0; i < days.length; i++) {
- headerDays[i].hour = "allday";
- headerCalendarsLabels[i].observe("mousedown", listRowMouseDownHandler);
- headerDays[i].observe("click", onCalendarSelectDay);
- headerDays[i].observe("dblclick", onClickableCellsDblClick);
- Event.on(days[i], "mousedown", onCalendarSelectDay);
-
- var clickableCells = days[i].select("DIV.clickableHourCell");
- for (var j = 0; j < clickableCells.length; j++)
- clickableCells[j].observe("dblclick", onClickableCellsDblClick);
- }
- }
- else {
- var calendarHeader = $("calendarHeader");
- var headerDaysLabels = calendarHeader.select("DIV.dayLabels DIV.day");
- var headerDays = calendarHeader.select("DIV.days DIV.day");
- for (var i = 0; i < days.length; i++) {
- headerDays[i].hour = "allday";
- headerDaysLabels[i].observe("mousedown", listRowMouseDownHandler);
- headerDays[i].observe("click", onCalendarSelectDay);
- headerDays[i].observe("dblclick", onClickableCellsDblClick);
- days[i].observe("click", onCalendarSelectDay);
-
- var clickableCells = days[i].select("DIV.clickableHourCell");
- for (var j = 0; j < clickableCells.length; j++)
- clickableCells[j].observe("dblclick", onClickableCellsDblClick);
- }
- }
- }
- else
- log ("calendarDisplayCallback Ajax error ("
- + http.readyState + "/" + http.status + ")");
-}
-
-function onEventsSelectionChange() {
- listOfSelection = this;
- this.removeClassName("_unfocused");
-
- var tasksList = $("tasksList");
- tasksList.addClassName("_unfocused");
- deselectAll(tasksList);
-
- var rows = $(this).getSelectedNodes();
- if (rows.length == 1) {
- var row = rows[0];
- changeCalendarDisplay( { "day": row.day,
- "scrollEvent": row.getAttribute("id") } );
- changeDateSelectorDisplay(row.day, true);
- }
- else {
- // Select visible events cells
- for (var i = 0; i < rows.length; i++) {
- var row = rows[i];
- selectCalendarEvent(row.calendar, row.cname, row.recurrenceTime);
- }
- }
-}
-
-function onTasksSelectionChange(event) {
- listOfSelection = this;
- this.removeClassName("_unfocused");
-
- var target = Event.element(event);
- if (target.tagName == 'SPAN')
- target = target.parentNode;
- // Update selection
- onRowClick(event, target);
-
- var eventsList = $("eventsList");
- eventsList.addClassName("_unfocused");
- eventsList.deselectAll();
-}
-
-function _loadEventHref(href) {
- if (document.eventsListAjaxRequest) {
- document.eventsListAjaxRequest.aborted = true;
- document.eventsListAjaxRequest.abort();
- }
- var url = ApplicationBaseURL + "/" + href;
- document.eventsListAjaxRequest
- = triggerAjaxRequest(url, eventsListCallback, href);
-
- return false;
-}
-
-function _loadTasksHref(href) {
- if (document.tasksListAjaxRequest) {
- document.tasksListAjaxRequest.aborted = true;
- document.tasksListAjaxRequest.abort();
- }
- if (document.activeTasksAjaxRequest) {
- document.activeTasksAjaxRequest.aborted = true;
- document.activeTasksAjaxRequest.abort();
- }
- url = ApplicationBaseURL + "/" + href;
- urlActiveTasks = ApplicationBaseURL + "/activeTasks";
-
- var tasksList = $("tasksList");
- var selectedIds;
- if (tasksList)
- selectedIds = tasksList.getSelectedNodesId();
- else
- selectedIds = null;
-
- document.tasksListAjaxRequest = triggerAjaxRequest(url, tasksListCallback, selectedIds);
-
- document.activeTasksAjaxRequest = triggerAjaxRequest(urlActiveTasks, activeTasksCallback);
-
- return true;
-}
-
-function onHeaderClick(event) {
- var newSortAttribute;
- var headerId;
-
- headerId = this.getAttribute("id");
-
- if (headerId.startsWith('event'))
- {
- // This is needed to get the dom object and flip the triangle
- sorting["event-header"] = headerId;
- // Take away the 'events' and 'Header' and lowercase the result
- newSortAttribute = headerId.sub("Header", "").sub("event", "").toLowerCase();
- if (sorting["event-attribute"] == newSortAttribute)
- sorting["event-ascending"] = !sorting["event-ascending"];
- else
- sorting["event-ascending"] = true;
- sorting["event-attribute"] = newSortAttribute;
- refreshEvents();
- }
- else // Tasks
- {
- // This is needed to get the dom object and flip the triangle
- sorting["task-header"] = headerId;
- // Take away the 'tasks' and 'Header' and lowercase the result
- newSortAttribute = headerId.sub("Header", "").sub("task", "").toLowerCase();
- if (sorting["task-attribute"] == newSortAttribute)
- sorting["task-ascending"] = !sorting["task-ascending"];
- else
- sorting["task-ascending"] = true;
- sorting["task-attribute"] = newSortAttribute;
- refreshTasks();
- }
-
- Event.stop(event);
-}
-
-function refreshCurrentFolder(id) {
- if (id == 'tasks')
- refreshTasks();
- else
- refreshEvents();
-}
-
-/* refreshes the "unifinder" list */
-function refreshEvents() {
- var specificSearch;
- var value = search["events"]["value"];
-
- if (value && value.length)
- specificSearch = ("&search=" + search["events"]["criteria"]
- + "&value=" + escape(value.utf8encode()));
- else
- specificSearch = "";
-
- refreshAlarms();
-
- return _loadEventHref("eventslist?asc=" + sorting["event-ascending"]
- + "&sort=" + sorting["event-attribute"]
- + "&day=" + currentDay
- + specificSearch
- + "&filterpopup=" + eventListFilter);
-}
-
-function refreshTasks(setUserDefault) {
- var specificSearch;
- var value = search["tasks"]["value"];
-
- if (value && value.length)
- specificSearch = ("&search=" + search["tasks"]["criteria"]
- + "&value=" + escape(value.utf8encode()));
- else
- specificSearch = "";
-
- if (setUserDefault == 1)
- specificSearch += "&setud=1";
-
- refreshAlarms();
-
- return _loadTasksHref("taskslist?show-completed=" + showCompletedTasks
- + "&asc=" + sorting["task-ascending"]
- + "&sort=" + sorting["task-attribute"]
- + specificSearch
- + "&filterpopup=" + taskListFilter);
-}
-
-function refreshEventsAndDisplay() {
- refreshEvents();
- changeCalendarDisplay();
-}
-
-function onEventsListFilterChange() {
- var node = $("filterpopup");
-
- eventListFilter = node.value;
-
- return refreshEvents();
-}
-
-function onTasksListFilterChange() {
- var node = $("tasksFilterpopup");
-
- taskListFilter = node.value;
-
- $("showHideCompletedTasks").disabled = taskListFilter == "view_overdue" ||
- taskListFilter == "view_incomplete" ||
- taskListFilter == "view_not_started";
-
- return refreshTasks();
-}
-
-function selectMonthInMenu(menu, month) {
- var entries = $(menu).select("LI");
- for (i = 0; i < entries.length; i++) {
- var entry = entries[i];
- var entryMonth = entry.getAttribute("month");
- if (entryMonth == month)
- entry.addClassName("currentMonth");
- else
- entry.removeClassName("currentMonth");
- }
-}
-
-function selectYearInMenu(menu, year) {
- var entries = $(menu).select("LI");
- for (i = 0; i < entries.length; i++) {
- var entry = entries[i];
- var entryYear = entry.innerHTML.strip();
- if (entryYear == year)
- entry.addClassName("currentMonth");
- else
- entry.removeClassName("currentMonth");
- }
-}
-
-function popupMonthMenu(event) {
- if (event.button == 0) {
- var id = this.getAttribute("id");
- if (id == "monthLabel")
- menuId = "monthListMenu";
- else
- menuId = "yearListMenu";
-
- var popup = $(menuId);
- if (id == "monthLabel")
- selectMonthInMenu(popup, this.getAttribute("month"));
- else
- selectYearInMenu(popup, this.innerHTML);
-
- popupToolbarMenu(this, menuId);
- Event.stop(event);
- }
-}
-
-function onMonthMenuItemClick(event) {
- var month = '' + this.getAttribute("month");
- var year = '' + $("yearLabel").innerHTML.strip();
-
- changeDateSelectorDisplay(year + month + "01", true);
-}
-
-function onYearMenuItemClick(event) {
- var month = '' + $("monthLabel").getAttribute("month");;
- var year = '' + this.innerHTML.strip();
-
- changeDateSelectorDisplay(year + month + "01", true);
-}
-
-function _eventBlocksMatching(calendar, cname, recurrenceTime) {
- var blocks = null;
- var events = calendarEvents[calendar];
- if (events) {
- var occurences = events[cname];
- if (occurences) {
- if (recurrenceTime) {
- for (var i = 0; i < occurences.length; i++) {
- var occurence = occurences[i];
- if (occurence[16] == recurrenceTime)
- blocks = occurence.blocks;
- }
- }
- else {
- blocks = [];
- for (var i = 0; i < occurences.length; i++) {
- var occurence = occurences[i];
- blocks = blocks.concat(occurence.blocks);
- }
- }
- }
- }
-
- return blocks;
-}
-
-/** Select event in calendar view */
-function selectCalendarEvent(calendar, cname, recurrenceTime) {
- var selection = _eventBlocksMatching(calendar, cname, recurrenceTime);
- if (selection) {
- for (var i = 0; i < selection.length; i++)
- selection[i].selectElement();
- if (selectedCalendarCell) {
- selectedCalendarCell = selectedCalendarCell.concat(selection);
- }
- else
- selectedCalendarCell = selection;
- }
-
- return selection;
-}
-
-function onSelectAll(event) {
- if (listOfSelection)
- listOfSelection.selectAll();
- else {
- // Select events cells
- var selectedBlocks = [];
- for (var c in calendarEvents) {
- var events = calendarEvents[c];
- for (var e in events) {
- var occurrences = events[e];
- for (var i = 0; i < occurrences.length; i++)
- selectedBlocks = selectedBlocks.concat(occurrences[i].blocks);
- }
- }
- for (var i = 0; i < selectedBlocks.length; i++)
- selectedBlocks[i].selectElement();
-
- selectedCalendarCell = selectedBlocks;
- }
-
- return false;
-}
-
-function deselectAll(list) {
- if (list) {
- list.deselectAll();
- }
- else {
- $("eventsList").deselectAll();
- $("tasksList").deselectAll();
- }
- if (selectedCalendarCell) {
- for (var i = 0; i < selectedCalendarCell.length; i++)
- selectedCalendarCell[i].deselect();
- selectedCalendarCell = null;
- }
-}
-
-/** Click on an event in the calendar view */
-function onCalendarSelectEvent(event, willShowContextualMenu) {
- var alreadySelected = false;
-
- // Look for event in events list
- // TODO: event will likely not be found if an Ajax query is refreshing
- // the events list.
- var rowID = this.calendar + "-" + this.cname;
- if (this.recurrenceTime)
- rowID += "-" + this.recurrenceTime;
- var row = $(rowID);
-
- // Check if event is already selected
- if (selectedCalendarCell)
- for (var i = 0; i < selectedCalendarCell.length; i++)
- if (selectedCalendarCell[i] == this) {
- alreadySelected = true;
- break;
- }
-
- if ((isMac() && event.metaKey == 1) || (!isMac() && event.ctrlKey == 1)) {
- // If meta or ctrl key is pressed, inverse the selection
- if (alreadySelected) {
- this.deselect();
- selectedCalendarCell.splice(i, 1);
- if (row)
- row.deselect();
-
- return true;
- }
- }
- else if (!(alreadySelected && willShowContextualMenu)
- && event.shiftKey == 0) {
- // Unselect entries in events list and calendar view, unless :
- // - Shift key is pressed;
- // - Or right button is clicked and event is already selected.
- deselectAll();
- listOfSelection = null;
- this.selectElement();
- if (alreadySelected)
- selectedCalendarCell = [this];
- }
-
- if (!alreadySelected) {
- // Select event in calendar view
- selectCalendarEvent(this.calendar, this.cname, this.recurrenceTime);
- }
- // Select event in events list
- if (row) {
- var div = row.parentNode.parentNode.parentNode;
- div.scrollTop = row.offsetTop - (div.offsetHeight / 2);
- row.selectElement();
- }
-}
-
-function onCalendarSelectDay(event) {
- var day = this.getAttribute("day");
- var needRefresh = (eventListFilter == 'view_selectedday' && day != currentDay);
-
- setSelectedDayDate(day);
- changeDateSelectorDisplay(day);
-
- if (needRefresh)
- refreshEvents();
-
- var target = Event.findElement(event);
- var div = target.up('div');
-
- // Select the calendar associated with the day clicked
- if (currentView == "multicolumndayview") {
- if (target.getAttribute("calendar"))
- var calendar = "[id='/" + target.getAttribute("calendar") + "']";
- else
- var calendar = "[id='/" + target.up("[calendar]").getAttribute("calendar") + "']";
- var list = $("calendarList");
- var selectedCalendar = list.down(calendar);
-
- onRowClick(event, selectedCalendar);
- }
-
- if (div && !div.hasClassName('event') && !div.hasClassName('eventInside') && !div.hasClassName('text') && !div.hasClassName('gradient')) {
- // Target is not an event -- unselect all events.
- listOfSelection = $("eventsList");
- deselectAll();
- return true;
- }
-
- if (listOfSelection) {
- listOfSelection.addClassName("_unfocused");
- }
-
- changeCalendarDisplay( { "day": currentDay } );
-}
-
-function setSelectedDayDate(dayDate) {
- if (selectedDayDate != dayDate) {
- var day = $("day" + selectedDayDate);
- if (day)
- day.removeClassName("selectedDay");
- var allDay = $("allDay" + selectedDayDate);
- if (allDay)
- allDay.removeClassName("selectedDay");
-
- selectedDayDate = dayDate;
-
- day = $("day" + selectedDayDate);
- day.addClassName("selectedDay");
- selectedDayNumber = day.readAttribute("day-number");
- allDay = $("allDay" + selectedDayDate);
- if (allDay)
- allDay.addClassName("selectedDay");
- }
-}
-
-/* after loading a new view, to reselect the currently selected day */
-function restoreSelectedDay() {
- var day = null;
- if (selectedDayDate.length > 0)
- day = $("day" + selectedDayDate);
- if (!day) {
- if (selectedDayNumber > -1)
- selectedDayDate = findDateFromDayNumber(selectedDayNumber);
- else
- selectedDayDate = currentDay;
- if (selectedDayDate && selectedDayDate.length > 0)
- day = $("day" + selectedDayDate);
- }
- if (day) {
- selectedDayDate = null;
- setSelectedDayDate(day.id.substr(3));
- }
-}
-
-function findDateFromDayNumber(dayNumber) {
- var view;
- if (currentView == "monthview")
- view = $("monthDaysView");
- else
- view = $("daysView");
- var days = view.select(".day");
- return (dayNumber < days.size()) ? days[dayNumber].readAttribute("day") : null;
-}
-
-function onShowCompletedTasks(event) {
- showCompletedTasks = (this.checked ? 1 : 0);
-
- return refreshTasks(1);
-}
-
-function updateTaskStatus(event) {
- var newStatus = (this.checked ? 1 : 0);
- _updateTaskCompletion (this.up("tr"), newStatus);
- return false;
-}
-
-function updateCalendarStatus(event) {
- var list = [];
- var newStatus = (this.checked ? 1 : 0);
-
- var nodes = $("calendarList").childNodesWithTag("li");
- for (var i = 0; i < nodes.length; i++) {
- var input = $(nodes[i]).childNodesWithTag("input")[0];
- if (input.checked) {
- var folderId = nodes[i].getAttribute("id");
- var elems = folderId.split(":");
- if (elems.length > 1)
- list.push(elems[0]);
- else
- list.push(UserLogin);
- }
- }
-
- // if (!list.length) {
- // list.push(UserLogin);
- // nodes[0].childNodesWithTag("input")[0].checked = true;
- // }
-
- // ApplicationBaseURL = (UserFolderURL + "Groups/_custom_"
- // + list.join(",") + "/Calendar/");
-
- if (event) {
- var folderID = this.parentNode.getAttribute("id");
- var urlstr = URLForFolderID(folderID);
- if (newStatus)
- urlstr += "/activateFolder";
- else
- urlstr += "/deactivateFolder";
- //log("updateCalendarStatus: ajax request = " + urlstr + ", folderID = " + folderID);
- triggerAjaxRequest(urlstr, calendarStatusCallback, folderID);
- }
- else {
- updateCalendarsList();
- refreshEvents();
- refreshTasks();
- changeCalendarDisplay();
- }
-
- if (event) {
- event.returnValue = true;
- }
-}
-
-function calendarStatusCallback(http) {
- if (http.readyState == 4) {
- if (isHttpStatus204(http.status)) {
- refreshEvents();
- refreshTasks();
- changeCalendarDisplay();
- }
- else {
- var folder = $(http.callbackData);
- var input = folder.childNodesWithTag("input")[0];
- input.checked = (!input.checked);
- }
- }
- else
- log("calendarStatusCallback Ajax error");
-}
-
-function calendarEntryCallback(http) {
- if (http.readyState == 4) {
- var denied = !isHttpStatus204(http.status);
- var entry = $(http.callbackData);
- if (denied)
- entry.addClassName("denied");
- else
- entry.removeClassName("denied");
- }
-}
-
-function updateCalendarsList(method) {
- var list = $("calendarList").childNodesWithTag("li");
- for (var i = 0; i < list.length; i++) {
- var folderID = list[i].getAttribute("id");
- var url = URLForFolderID(folderID) + "/canAccessContent";
- triggerAjaxRequest(url, calendarEntryCallback, folderID);
- }
- configureDroppables();
-}
-
-//function validateBrowseURL(input) {
-// var button = $("browseURLBtn");
-//
-// if (input.value.length) {
-// if (!button.enabled)
-// enableAnchor(button);
-// } else if (!button.disabled)
-// disableAnchor(button);
-//}
-
-//function browseURL(anchor, event) {
-// if (event.button == 0) {
-// var input = $("url");
-// var url = input.value;
-// if (url.length)
-// window.open(url, '_blank');
-// }
-//
-// return false;
-//}
-
-function onCalendarsMenuPrepareVisibility() {
- var folders = $("calendarList");
- var selected = folders.getSelectedNodes();
- if (selected.length > 0) {
- var folderOwner = selected[0].getAttribute("owner");
-
- var lis = $(this).down("ul").childElements();
-
- /* distance: sharing = length - 1, export = length - 7 */
- var endDists = [ 1, 7 ];
- for (var i = 0; i < endDists.length; i++) {
- var dist = lis.length - endDists[i];
- var option = $(lis[dist]);
- if (folderOwner == UserLogin || IsSuperUser)
- option.removeClassName("disabled");
- else
- option.addClassName("disabled");
- }
-
- var deleteCalendarOption = $("deleteCalendarMenuItem");
- // Swith between Delete and Unsubscribe
- if (folderOwner == UserLogin)
- deleteCalendarOption.update(_("Delete Calendar"));
- else
- deleteCalendarOption.update(_("Unsubscribe Calendar"));
-
- return true;
- }
- return false;
-}
-
-function onMenuCurrentViewPrepareVisibility() {
- var options = $(this).down("ul");
- var deleteOption = options.down("li", 6);
- var copyOption = options.down("li", 7);
- var rawOption = options.down("li", 8);
- if (!selectedCalendarCell) {
- deleteOption.addClassName("disabled");
- copyOption.addClassName("disabled");
- rawOption.addClassName("disabled");
- }
- else {
- deleteOption.removeClassName("disabled");
- var calendarEntry = $("/" + selectedCalendarCell[0].calendar);
- if (calendarEntry.getAttribute("owner") == UserLogin)
- copyOption.addClassName("disabled");
- else
- copyOption.removeClassName("disabled");
- if (selectedCalendarCell.length == 1) {
- // show raw content is only allowed for single event
- rawOption.removeClassName("disabled");
- }
- else
- rawOption.addClassName("disabled");
- }
-
- return true;
-}
-
-function onTasksListMenuPrepareVisibility() {
- var options = $(this).down("ul");
- var rawOption = options.down("li", 6);
-
- var selectedTasks = $$("#tasksList ._selected");
- if (selectedTasks.length == 1)
- rawOption.removeClassName("disabled");
- else
- rawOption.addClassName("disabled");
-
- return true;
-}
-
-function getMenus() {
- var menus = {};
-
- var dateMenu = [];
- for (var i = 0; i < 12; i++)
- dateMenu.push(onMonthMenuItemClick);
- menus["monthListMenu"] = dateMenu;
-
- dateMenu = [];
- for (var i = 0; i < 11; i++)
- dateMenu.push(onYearMenuItemClick);
- menus["yearListMenu"] = dateMenu;
-
- menus["eventsListMenu"] = new Array(onMenuNewEventClick,
- onMenuNewTaskClick, "-",
- editEvent, deleteEvent, "-",
- onSelectAll, "-",
- null, null);
- menus["calendarsMenu"] = new Array(onCalendarModify,
- "-",
- onCalendarNew, onCalendarRemove,
- "-", onCalendarExport, onCalendarImport,
- null, "-", null, "-", onMenuSharing);
- menus["eventSearchMenu"] = new Array(setSearchCriteria, setSearchCriteria, setSearchCriteria);
-
- menus["tasksListMenu"] = new Array (editEvent, newTask, "-",
- marksTasksAsCompleted, deleteEvent, "-",
- onMenuRawTask);
- menus["taskSearchMenu"] = new Array(setSearchCriteria, setSearchCriteria, setSearchCriteria);
-
- var calendarsMenu = $("calendarsMenu");
- if (calendarsMenu)
- calendarsMenu.prepareVisibility = onCalendarsMenuPrepareVisibility;
-
- var tasksListMenu = $("tasksListMenu");
- if (tasksListMenu)
- tasksListMenu.prepareVisibility = onTasksListMenuPrepareVisibility;
-
- return menus;
-}
-
-function newTask () {
- newEventFromWidget.delay(0.1, this, 'task');
-}
-
-function marksTasksAsCompleted () {
- var selectedTasks = $$("#tasksList ._selected");
-
- for (var i = 0; i < selectedTasks.length; i++) {
- var task = selectedTasks[i];
- _updateTaskCompletion (task, 1);
- }
-}
-
-function _updateTaskCompletion (task, value) {
- url = (ApplicationBaseURL + "/" + task.calendar
- + "/" + task.cname);
-
- if (task.recurrenceTime)
- url += ("/occurence" + task.recurrenceTime);
-
- url += ("/changeStatus?status=" + value);
-
- triggerAjaxRequest(url, refreshTasks, null);
-
- return false;
-}
-
-function onMenuRawTask(event) {
- var selectedTasks = $$("#tasksList ._selected");
- if (selectedTasks.length != 1) {
- return;
- }
-
- var url = ApplicationBaseURL + "/" + selectedTasks[0].calendar + "/" + selectedTasks[0].cname + "/raw"
- openGenericWindow.delay(0.1, url);
-}
-
-function onMenuSharing(event) {
- if ($(this).hasClassName("disabled"))
- return;
-
- var folders = $("calendarList");
- var selected = folders.getSelectedNodes()[0];
- /* FIXME: activation of the context menu should preferably select the entry
- above which the event has occurred */
- if (selected) {
- var folderID = selected.getAttribute("id");
- var urlstr = URLForFolderID(folderID) + "/acls";
-
- openAclWindow(urlstr);
- }
-}
-
-function multicolumndayviewCalendarSelector(event, target) {
- // Select the calendar associated with the day clicked
- if (currentView == "multicolumndayview") {
- if (target.getAttribute("calendar"))
- var calendar = "[id='/" + target.getAttribute("calendar") + "']";
- else
- var calendar = "[id='/" + target.up("[calendar]").getAttribute("calendar") + "']";
- var list = $("calendarList");
- var selectedCalendar = list.down(calendar);
-
- onRowClick(event, selectedCalendar);
- }
-}
-
-function onMenuCurrentView(event) {
- var target = getTarget(event);
- $("eventDialog").hide();
- if (this.hasClassName('event')) {
- // Select event cell
- var onClick = onCalendarSelectEvent.bind(this);
- onClick(event, true);
- target = this;
- }
- multicolumndayviewCalendarSelector(event, target);
- popupMenu(event, 'currentViewMenu', target);
-}
-
-function onMenuAllDayView(event) {
- $("eventDialog").hide();
- multicolumndayviewCalendarSelector(event, getTarget(event));
- popupMenu(event, 'allDayViewMenu', getTarget(event));
-}
-
-function configureEventsDraggables() {
- if ($("eventsList")) {
- var rows = jQuery("tr.eventRow");
- try { rows.draggable("destroy"); } catch (e) {}
- rows.draggable({
- helper: function (event) { return '
t |