X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=UI%2FWebServerResources%2Fgeneric.js;h=cd7923d24d466bcc4b074ced944cdc4c70ac2fb5;hb=035a30162fc300798dba0244be4e540e39a9bd57;hp=479b08d084f43a59c59fccb5e049d76e275dafbd;hpb=babc5d2d6913443e4c780651fed156e67e47f12f;p=scalable-opengroupware.org diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js index 479b08d0..cd7923d2 100644 --- a/UI/WebServerResources/generic.js +++ b/UI/WebServerResources/generic.js @@ -35,8 +35,7 @@ var activeAjaxRequests = 0; var allDocumentElements = null; /* a W3C compliant document.all */ -function getAllScopeElements(scope) -{ +function getAllScopeElements(scope) { var elements = new Array(); for (var i = 0; i < scope.childNodes.length; i++) @@ -53,8 +52,7 @@ function getAllScopeElements(scope) return elements; } -function getAllElements(scope) -{ +function getAllElements(scope) { var elements; if (scope == null) @@ -112,6 +110,24 @@ function ml_stripActionInURL(url) { return url; } +function URLForFolderID(folderID) { + var folderInfos = folderID.split(":"); + var url; + if (folderInfos.length > 1) { + url = UserFolderURL + "../" + folderInfos[0]; + if (folderInfos[1][0] != '/') + url += '/'; + url += folderInfos[1]; + } + else + url = ApplicationBaseURL + folderInfos[0]; + + if (url[url.length-1] == '/') + url = url.substr(0, url.length-1); + + return url; +} + function extractEmailAddress(mailTo) { var email = ""; @@ -128,11 +144,13 @@ function extractEmailAddress(mailTo) { function extractEmailName(mailTo) { var emailName = ""; - var emailNamere = /(\w[\w\ _-]+)\ (<|<)/; + var emailNamere = /(.+)\ ' + "\n"; } +function backtrace() { + var func = backtrace.caller; + var str = "backtrace:
"; + + while (func) + { + if (func.name) + { + str += " " + func.name; + if (this) + str += " (" + this + ")"; + } + else + str += "[anonymous]\n"; + + str += "
"; + func = func.caller; + } + str += "--\n"; + + return str; +} + function dropDownSubmenu(event) { var node = event.target; var submenu = node.getAttribute("submenu"); @@ -610,8 +664,10 @@ function checkDropDown(event) { } /* search field */ -function popupSearchMenu(event, menuId) { +function popupSearchMenu(event) { var node = event.target; + + var menuId = this.getAttribute("menuid"); relX = event.pageX - node.cascadeLeftOffset(); relY = event.pageY - node.cascadeTopOffset(); @@ -656,50 +712,50 @@ function onSearchChange() { log ("onSearchChange()..."); } -function onSearchMouseDown(event, searchValue) { - superNode = searchValue.parentNode.parentNode.parentNode; - relX = (event.pageX - superNode.offsetLeft - searchValue.offsetLeft); - relY = (event.pageY - superNode.offsetTop - searchValue.offsetTop); +function onSearchMouseDown(event) { + var superNode = this.parentNode.parentNode.parentNode; + relX = (event.pageX - superNode.offsetLeft - this.offsetLeft); + relY = (event.pageY - superNode.offsetTop - this.offsetTop); - if (relY < 24) { - event.cancelBubble = true; - event.returnValue = false; - } + if (relY < 24) { + event.cancelBubble = true; + event.returnValue = false; + } } -function onSearchFocus(searchValue) { - ghostPhrase = searchValue.getAttribute("ghost-phrase"); - if (searchValue.value == ghostPhrase) { - searchValue.value = ""; - searchValue.setAttribute("modified", ""); +function onSearchFocus() { + ghostPhrase = this.getAttribute("ghost-phrase"); + if (this.value == ghostPhrase) { + this.value = ""; + this.setAttribute("modified", ""); } else { - searchValue.select(); + this.select(); } - searchValue.style.color = "#000"; + this.style.color = "#000"; } -function onSearchBlur(searchValue) { - var ghostPhrase = searchValue.getAttribute("ghost-phrase"); -// log ("search blur: '" + searchValue.value + "'"); - if (!searchValue.value) { - searchValue.setAttribute("modified", ""); - searchValue.style.color = "#aaa"; - searchValue.value = ghostPhrase; - } else if (searchValue.value == ghostPhrase) { - searchValue.setAttribute("modified", ""); - searchValue.style.color = "#aaa"; +function onSearchBlur(event) { + var ghostPhrase = this.getAttribute("ghost-phrase"); +// log ("search blur: '" + this.value + "'"); + if (!this.value) { + this.setAttribute("modified", ""); + this.style.color = "#aaa"; + this.value = ghostPhrase; + } else if (this.value == ghostPhrase) { + this.setAttribute("modified", ""); + this.style.color = "#aaa"; } else { - searchValue.setAttribute("modified", "yes"); - searchValue.style.color = "#000"; + this.setAttribute("modified", "yes"); + this.style.color = "#000"; } } -function onSearchKeyDown(searchValue) { - if (searchValue.timer) - clearTimeout(searchValue.timer); +function onSearchKeyDown(event) { + if (this.timer) + clearTimeout(this.timer); - searchValue.timer = setTimeout("onSearchFormSubmit()", 1000); + this.timer = setTimeout("onSearchFormSubmit()", 1000); } function initCriteria() { @@ -720,57 +776,104 @@ function initCriteria() { } } -/* contact selector */ - -function onContactAdd(node) -{ - var selector = null; - var selectorURL = '?popup=YES'; - if (node) { - selector = node.parentNode.parentNode; - selectorURL += ("&selectorId=" + selector.getAttribute("id")); - } - - urlstr = ApplicationBaseURL; - if (urlstr[urlstr.length-1] != '/') - urlstr += '/'; - urlstr += ("../../" + UserLogin + "/Contacts/" - + contactSelectorAction + selectorURL); -// log (urlstr); - var w = window.open(urlstr, "Addressbook", - "width=640,height=400,resizable=1,scrollbars=0"); - w.selector = selector; - w.opener = this; - w.focus(); - - return false; +/* toolbar buttons */ +function popupToolbarMenu(event, menuId) { + var toolbar = $("toolbar"); + var node = event.target; + if (node.tagName != 'A') + node = node.getParentWithTagName("a"); + node = node.childNodesWithTag("span")[0]; + + if (event.button == 0) { + event.cancelBubble = true; + event.returnValue = false; + + if (document.currentPopupMenu) + hideMenu(event, document.currentPopupMenu); + + var popup = document.getElementById(menuId); + var top = node.offsetTop + node.offsetHeight - 2; + popup.style.top = top + "px"; + popup.style.left = node.cascadeLeftOffset() + "px"; + popup.style.visibility = "visible"; + + bodyOnClick = "" + document.body.getAttribute("onclick"); + document.body.setAttribute("onclick", "onBodyClick('" + menuId + "');"); + document.currentPopupMenu = popup; + } } -function onContactRemove(node) { - var selector = node.parentNode.parentNode; - var selectorId = selector.getAttribute("id"); - var hasChanged = false; - - var names = $('uixselector-' + selectorId + '-display'); - var nodes = names.getSelectedNodes(); - hasChanged = (nodes.length > 0); - for (var i = 0; i < nodes.length; i++) { - var currentNode = nodes[i]; - currentNode.parentNode.removeChild(currentNode); - } - - var uids = $('uixselector-' + selectorId + '-uidList'); - nodes = node.parentNode.childNodes; - var ids = new Array(); - for (var i = 0; i < nodes.length; i++) - if (nodes[i] instanceof HTMLLIElement) - ids.push(nodes[i].getAttribute("uid")); - uids.value = ids.join(","); - - if (selector.changeNotification && hasChanged) - selector.changeNotification("removal"); +/* contact selector */ - return false; +function folderSubscriptionCallback(http) { + if (http.readyState == 4) { + if (http.status == 204) { + if (http.callbackData) + http.callbackData["method"](http.callbackData["data"]); + } + else + window.alert(labels["Unable to subscribe to that folder!"].decodeEntities()); + document.subscriptionAjaxRequest = null; + } + else + log ("ajax fuckage"); +} + +function subscribeToFolder(refreshCallback, refreshCallbackData) { + var folderData = refreshCallbackData["folder"].split(":"); + var username = folderData[0]; + var folderPath = folderData[1]; + if (username != UserLogin) { + var url = (UserFolderURL + "../" + username + + "/" + folderPath + "/subscribe"); + if (document.subscriptionAjaxRequest) { + document.subscriptionAjaxRequest.aborted = true; + document.subscriptionAjaxRequest.abort(); + } + var rfCbData = { method: refreshCallback, data: refreshCallbackData }; + document.subscriptionAjaxRequest = triggerAjaxRequest(url, + folderSubscriptionCallback, + rfCbData); + } + else + window.alert(labels["You cannot subscribe to a folder that you own!"].decodeEntities()); +} + +function folderUnsubscriptionCallback(http) { + if (http.readyState == 4) { + if (http.status == 204) { + if (http.callbackData) + http.callbackData["method"](http.callbackData["data"]); + } + else + window.alert(labels["Unable to unsubscribe from that folder!"].decodeEntities()); + document.unsubscriptionAjaxRequest = null; + } +} + +function unsubscribeFromFolder(folder, refreshCallback, refreshCallbackData) { + if (document.body.hasClassName("popup")) { + window.opener.unsubscribeFromFolder(folder, refreshCallback, refreshCallbackData); + } + else { + var folderData = folder.split(":"); + var username = folderData[0]; + var folderPath = folderData[1]; + if (username != UserLogin) { + var url = (UserFolderURL + "../" + username + + "/" + folderPath + "/unsubscribe"); + if (document.unsubscriptionAjaxRequest) { + document.unsubscriptionAjaxRequest.aborted = true; + document.unsubscriptionAjaxRequest.abort(); + } + var rfCbData = { method: refreshCallback, data: refreshCallbackData }; + document.unsubscriptionAjaxRequest = triggerAjaxRequest(url, + folderUnsubscriptionCallback, + rfCbData); + } + else + window.alert(labels["You cannot unsubscribe from a folder that you own!"].decodeEntities()); + } } function listRowMouseDownHandler(event) { @@ -778,8 +881,7 @@ function listRowMouseDownHandler(event) { } /* tabs */ -function initTabs() -{ +function initTabs() { var containers = document.getElementsByClassName("tabsContainer"); for (var x = 0; x < containers.length; x++) { var container = containers[x]; @@ -833,13 +935,13 @@ function openExternalLink(anchor) { return false; } -function openAclWindow(url, objectTitle) { +function openAclWindow(url) { var w = window.open(url, "aclWindow", "width=300,height=300,resizable=1,scrollbars=1,toolbar=0," + "location=0,directories=0,status=0,menubar=0" + ",copyhistory=0"); + w.opener = window; w.focus(); - w.title = "Poil: " + objectTitle; return w; } @@ -901,11 +1003,13 @@ function disableAnchor(anchor) { function d2h(d) { var hD = "0123456789abcdef"; - var h = hD.substr(d&15,1); - while (d>15) { - d>>=4; - h=hD.substr(d&15,1)+h; + var h = hD.substr(d & 15, 1); + + while (d > 15) { + d >>= 4; + h = hD.substr(d & 15, 1) + h; } + return h; } @@ -977,13 +1081,13 @@ function configureLinkBanner() { var linkBanner = $("linkBanner"); if (linkBanner) { var anchors = linkBanner.childNodesWithTag("a"); - for (var i = 0; i < 4; i++) { + for (var i = 0; i < 2; i++) { anchors[i].addEventListener("mousedown", listRowMouseDownHandler, false); anchors[i].addEventListener("click", onLinkBannerClick, false); } - if (anchors.length > 5) - anchors[5].addEventListener("click", toggleLogConsole, true); + if (anchors.length > 3) + anchors[3].addEventListener("click", toggleLogConsole, true); } } @@ -999,3 +1103,7 @@ function initializeMenus() { function onHeaderClick(event) { window.alert("generic headerClick"); } + +function parent$(element) { + return window.opener.document.getElementById(element); +}