2006-06-15 21:34:10 +02:00
|
|
|
/*
|
|
|
|
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.
|
|
|
|
*/
|
|
|
|
/* some generic JavaScript code for SOGo */
|
|
|
|
|
|
|
|
/* generic stuff */
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
var logConsole;
|
2006-08-31 01:02:53 +02:00
|
|
|
var logWindow = null;
|
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
var queryParameters;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-05-18 18:15:01 +02:00
|
|
|
var menus = new Array();
|
2007-06-27 23:20:15 +02:00
|
|
|
var search = {};
|
2007-06-28 20:28:33 +02:00
|
|
|
var sorting = {};
|
2006-08-24 20:48:33 +02:00
|
|
|
|
2007-10-02 17:29:16 +02:00
|
|
|
var lastClickedRow = null;
|
|
|
|
|
2007-06-12 22:05:57 +02:00
|
|
|
var weekStartIsMonday = true;
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
// logArea = null;
|
|
|
|
var allDocumentElements = null;
|
|
|
|
|
2007-06-27 23:20:15 +02:00
|
|
|
var userDefaults = null;
|
|
|
|
var userSettings = null;
|
|
|
|
|
2007-10-23 16:39:29 +02:00
|
|
|
// Ajax requests counts
|
|
|
|
var activeAjaxRequests = 0;
|
|
|
|
var removeFolderRequestCount = 0;
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
/* a W3C compliant document.all */
|
2007-03-19 15:31:49 +01:00
|
|
|
function getAllScopeElements(scope) {
|
2006-07-29 00:59:11 +02:00
|
|
|
var elements = new Array();
|
|
|
|
|
|
|
|
for (var i = 0; i < scope.childNodes.length; i++)
|
|
|
|
if (typeof(scope.childNodes[i]) == "object"
|
|
|
|
&& scope.childNodes[i].tagName
|
|
|
|
&& scope.childNodes[i].tagName != '')
|
|
|
|
{
|
|
|
|
elements.push(scope.childNodes[i]);
|
|
|
|
var childElements = getAllElements(scope.childNodes[i]);
|
|
|
|
if (childElements.length > 0)
|
|
|
|
elements.push(childElements);
|
|
|
|
}
|
|
|
|
|
|
|
|
return elements;
|
|
|
|
}
|
|
|
|
|
2007-03-19 15:31:49 +01:00
|
|
|
function getAllElements(scope) {
|
2006-07-29 00:59:11 +02:00
|
|
|
var elements;
|
|
|
|
|
|
|
|
if (scope == null)
|
|
|
|
scope = document;
|
|
|
|
|
|
|
|
if (scope == document
|
|
|
|
&& allDocumentElements != null)
|
|
|
|
elements = allDocumentElements;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
elements = getAllScopeElements(scope);
|
|
|
|
if (scope == document)
|
|
|
|
allDocumentElements = elements;
|
|
|
|
}
|
|
|
|
|
|
|
|
return elements;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* from
|
|
|
|
http://www.robertnyman.com/2005/11/07/the-ultimate-getelementsbyclassname/ */
|
2006-11-09 23:55:04 +01:00
|
|
|
function getElementsByClassName2(_tag, _class, _scope) {
|
2006-07-29 00:59:11 +02:00
|
|
|
var regexp, classes, elements, element, returnElements;
|
|
|
|
|
|
|
|
_scope = _scope || document;
|
|
|
|
|
|
|
|
elements = (!_tag || _tag == "*"
|
|
|
|
? getAllElements(null)
|
|
|
|
: _scope.getElementsByTagName(_tag));
|
|
|
|
returnElements = [];
|
|
|
|
|
|
|
|
classes = _class.split(/\s+/);
|
|
|
|
regexp = new RegExp("(^|\s+)("+ classes.join("|") +")(\s+|$)","i");
|
|
|
|
|
|
|
|
if (_class) {
|
|
|
|
for(var i = 0; element = elements[i]; i++) {
|
|
|
|
if (regexp.test(element.className)) {
|
|
|
|
returnElements.push(element);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return returnElements;
|
|
|
|
} else {
|
|
|
|
return elements;
|
|
|
|
}
|
|
|
|
}
|
2006-07-13 21:13:18 +02:00
|
|
|
|
2007-06-27 23:20:15 +02:00
|
|
|
function createElement(tagName, id, classes, attributes, htmlAttributes,
|
|
|
|
parentNode) {
|
2007-10-18 19:18:53 +02:00
|
|
|
var newElement = $(document.createElement(tagName));
|
|
|
|
if (id)
|
|
|
|
newElement.setAttribute("id", id);
|
|
|
|
if (classes) {
|
|
|
|
if (typeof(classes) == "string")
|
|
|
|
newElement.addClassName(classes);
|
|
|
|
else
|
|
|
|
for (var i = 0; i < classes.length; i++)
|
|
|
|
newElement.addClassName(classes[i]);
|
|
|
|
}
|
|
|
|
if (attributes)
|
|
|
|
for (var i in attributes)
|
|
|
|
newElement[i] = attributes[i];
|
|
|
|
if (htmlAttributes)
|
|
|
|
for (var i in htmlAttributes)
|
|
|
|
newElement.setAttribute(i, htmlAttributes[i]);
|
|
|
|
if (parentNode)
|
|
|
|
parentNode.appendChild(newElement);
|
2007-06-27 23:20:15 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
return $(newElement);
|
2007-06-27 23:20:15 +02:00
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
function ml_stripActionInURL(url) {
|
|
|
|
if (url[url.length - 1] != '/') {
|
|
|
|
var i;
|
|
|
|
|
|
|
|
i = url.lastIndexOf("/");
|
|
|
|
if (i != -1) url = url.substring(0, i);
|
|
|
|
}
|
|
|
|
if (url[url.length - 1] != '/') // ensure trailing slash
|
|
|
|
url = url + "/";
|
|
|
|
return url;
|
|
|
|
}
|
|
|
|
|
2007-03-29 20:02:48 +02:00
|
|
|
function URLForFolderID(folderID) {
|
2007-10-18 19:18:53 +02:00
|
|
|
var folderInfos = folderID.split(":");
|
|
|
|
var url;
|
|
|
|
if (folderInfos.length > 1) {
|
|
|
|
url = UserFolderURL + "../" + folderInfos[0];
|
|
|
|
if (!folderInfos[1].startsWith('/'))
|
|
|
|
url += '/';
|
|
|
|
url += folderInfos[1];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
url = ApplicationBaseURL + folderInfos[0];
|
2007-03-29 20:02:48 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
if (url[url.length-1] == '/')
|
|
|
|
url = url.substr(0, url.length-1);
|
2007-03-29 20:02:48 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
return url;
|
2007-03-29 20:02:48 +02:00
|
|
|
}
|
|
|
|
|
2006-10-03 18:17:22 +02:00
|
|
|
function extractEmailAddress(mailTo) {
|
2006-07-11 20:11:54 +02:00
|
|
|
var email = "";
|
|
|
|
|
|
|
|
var emailre
|
|
|
|
= /([a-zA-Z0-9]+[a-zA-Z0-9\._-]+[a-zA-Z0-9]+@[a-zA-Z0-9]+[a-zA-Z0-9\._-]+[a-zA-Z0-9]+)/g;
|
2006-10-03 18:17:22 +02:00
|
|
|
if (emailre.test(mailTo)) {
|
|
|
|
emailre.exec(mailTo);
|
2006-07-11 20:11:54 +02:00
|
|
|
email = RegExp.$1;
|
|
|
|
}
|
|
|
|
|
2006-10-03 18:17:22 +02:00
|
|
|
return email;
|
|
|
|
}
|
|
|
|
|
|
|
|
function extractEmailName(mailTo) {
|
2006-10-06 01:30:29 +02:00
|
|
|
var emailName = "";
|
2006-10-03 18:17:22 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
var tmpMailTo = mailTo.replace("<", "<");
|
|
|
|
tmpMailTo = tmpMailTo.replace(">", ">");
|
2007-03-18 16:00:34 +01:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
var emailNamere = /([ ]+)?(.+)\ </;
|
|
|
|
if (emailNamere.test(tmpMailTo)) {
|
|
|
|
emailNamere.exec(tmpMailTo);
|
|
|
|
emailName = RegExp.$2;
|
|
|
|
}
|
2007-05-15 05:46:16 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
return emailName;
|
2006-10-03 18:17:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function sanitizeMailTo(dirtyMailTo) {
|
2007-10-18 19:18:53 +02:00
|
|
|
var emailName = extractEmailName(dirtyMailTo);
|
|
|
|
var email = "" + extractEmailAddress(dirtyMailTo);
|
2007-05-15 05:46:16 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
var mailto = "";
|
|
|
|
if (emailName && emailName.length > 0)
|
|
|
|
mailto = emailName + ' <' + email + '>';
|
|
|
|
else
|
|
|
|
mailto = email;
|
2006-07-11 20:11:54 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
return mailto;
|
2006-07-11 20:11:54 +02:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:02:48 +02:00
|
|
|
function openUserFolderSelector(callback, type) {
|
2007-10-18 19:18:53 +02:00
|
|
|
var urlstr = ApplicationBaseURL;
|
|
|
|
if (! urlstr.endsWith('/'))
|
|
|
|
urlstr += '/';
|
|
|
|
urlstr += ("../../" + UserLogin + "/Contacts/userFolders");
|
|
|
|
var w = window.open(urlstr, "_blank",
|
|
|
|
"width=322,height=250,resizable=1,scrollbars=0,location=0");
|
|
|
|
w.opener = window;
|
|
|
|
window.userFolderCallback = callback;
|
|
|
|
window.userFolderType = type;
|
|
|
|
w.focus();
|
2007-03-29 20:02:48 +02:00
|
|
|
}
|
|
|
|
|
2007-08-21 18:00:25 +02:00
|
|
|
function openContactWindow(url, wId) {
|
|
|
|
if (!wId)
|
|
|
|
wId = "" + (new Date().getTime());
|
|
|
|
var w = window.open(url, wId,
|
2007-10-18 19:18:53 +02:00
|
|
|
"width=450,height=600,resizable=0,location=0");
|
2007-08-21 18:00:25 +02:00
|
|
|
w.focus();
|
|
|
|
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
2007-09-24 23:26:23 +02:00
|
|
|
function openMailComposeWindow(url, wId) {
|
2007-10-30 20:56:50 +01:00
|
|
|
var parentWindow = this;
|
|
|
|
|
2007-08-21 18:00:25 +02:00
|
|
|
if (!wId)
|
|
|
|
wId = "" + (new Date().getTime());
|
2007-10-30 20:56:50 +01:00
|
|
|
else
|
|
|
|
if (document.body.hasClassName("popup"))
|
|
|
|
parentWindow = window.opener;
|
|
|
|
|
|
|
|
var w = parentWindow.open(url, wId,
|
2006-12-14 22:20:13 +01:00
|
|
|
"width=680,height=520,resizable=1,scrollbars=1,toolbar=0,"
|
|
|
|
+ "location=0,directories=0,status=0,menubar=0"
|
|
|
|
+ ",copyhistory=0");
|
2007-10-30 20:56:50 +01:00
|
|
|
|
2006-10-19 21:23:58 +02:00
|
|
|
w.focus();
|
|
|
|
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
2007-05-15 05:46:16 +02:00
|
|
|
function openMailTo(senderMailTo) {
|
2007-10-18 19:18:53 +02:00
|
|
|
var mailto = sanitizeMailTo(senderMailTo);
|
|
|
|
if (mailto.length > 0)
|
|
|
|
openMailComposeWindow(ApplicationBaseURL
|
|
|
|
+ "/../Mail/compose?mailto=" + mailto);
|
2006-09-16 00:27:59 +02:00
|
|
|
|
|
|
|
return false; /* stop following the link */
|
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
function createHTTPClient() {
|
|
|
|
// http://developer.apple.com/internet/webcontent/xmlhttpreq.html
|
|
|
|
if (typeof XMLHttpRequest != "undefined")
|
|
|
|
return new XMLHttpRequest();
|
2007-06-27 23:20:15 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
try { return new ActiveXObject("Msxml2.XMLHTTP"); }
|
|
|
|
catch (e) { }
|
|
|
|
try { return new ActiveXObject("Microsoft.XMLHTTP"); }
|
|
|
|
catch (e) { }
|
2006-08-24 23:14:18 +02:00
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
2007-06-06 22:52:07 +02:00
|
|
|
function appendDifferentiator(url) {
|
|
|
|
var url_nocache = url;
|
|
|
|
var position = url.indexOf('?', 0);
|
|
|
|
if (position < 0)
|
|
|
|
url_nocache += '?';
|
|
|
|
else
|
|
|
|
url_nocache += '&';
|
|
|
|
url_nocache += 'differentiator=' + Math.floor(Math.random()*50000);
|
|
|
|
|
|
|
|
return url_nocache;
|
|
|
|
}
|
|
|
|
|
2006-08-24 20:48:33 +02:00
|
|
|
function triggerAjaxRequest(url, callback, userdata) {
|
2006-08-24 23:14:18 +02:00
|
|
|
var http = createHTTPClient();
|
2006-08-24 20:48:33 +02:00
|
|
|
|
|
|
|
activeAjaxRequests += 1;
|
|
|
|
document.animTimer = setTimeout("checkAjaxRequestsState();", 200);
|
2007-06-06 22:52:07 +02:00
|
|
|
//url = appendDifferentiator(url);
|
2006-08-24 20:48:33 +02:00
|
|
|
|
|
|
|
if (http) {
|
2007-06-06 22:52:07 +02:00
|
|
|
http.open("POST", url, true);
|
|
|
|
http.url = url;
|
2006-08-24 20:48:33 +02:00
|
|
|
http.onreadystatechange
|
|
|
|
= function() {
|
2007-10-18 19:18:53 +02:00
|
|
|
//log ("state changed (" + http.readyState + "): " + url);
|
|
|
|
try {
|
|
|
|
if (http.readyState == 4
|
|
|
|
&& activeAjaxRequests > 0) {
|
|
|
|
if (!http.aborted) {
|
2007-10-30 20:56:50 +01:00
|
|
|
if (userdata)
|
|
|
|
http.callbackData = userdata;
|
2007-10-18 19:18:53 +02:00
|
|
|
callback(http);
|
|
|
|
}
|
|
|
|
activeAjaxRequests -= 1;
|
|
|
|
checkAjaxRequestsState();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch( e ) {
|
|
|
|
activeAjaxRequests -= 1;
|
|
|
|
checkAjaxRequestsState();
|
|
|
|
log("AJAX Request, Caught Exception: " + e.name);
|
|
|
|
log(e.message);
|
|
|
|
log(backtrace());
|
|
|
|
}
|
|
|
|
};
|
2007-06-06 22:52:07 +02:00
|
|
|
http.send(null);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
log("triggerAjaxRequest: error creating HTTP Client!");
|
2006-08-24 20:48:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return http;
|
|
|
|
}
|
|
|
|
|
2007-09-04 16:59:16 +02:00
|
|
|
function startAnimation(parent, nextNode) {
|
2007-09-29 02:20:57 +02:00
|
|
|
var anim = $("progressIndicator");
|
|
|
|
if (anim) return anim;
|
|
|
|
|
|
|
|
anim = document.createElement("img");
|
2007-09-04 16:59:16 +02:00
|
|
|
anim = $(anim);
|
|
|
|
anim.id = "progressIndicator";
|
|
|
|
anim.src = ResourcesURL + "/busy.gif";
|
|
|
|
anim.setStyle({ visibility: "hidden" });
|
|
|
|
if (nextNode)
|
|
|
|
parent.insertBefore(anim, nextNode);
|
|
|
|
else
|
|
|
|
parent.appendChild(anim);
|
|
|
|
anim.setStyle({ visibility: "visible" });
|
|
|
|
|
|
|
|
return anim;
|
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function checkAjaxRequestsState() {
|
|
|
|
var toolbar = document.getElementById("toolbar");
|
|
|
|
if (toolbar) {
|
|
|
|
if (activeAjaxRequests > 0
|
|
|
|
&& !document.busyAnim) {
|
2007-09-04 16:59:16 +02:00
|
|
|
document.busyAnim = startAnimation(toolbar);
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|
|
|
|
else if (activeAjaxRequests == 0
|
2007-05-25 17:49:51 +02:00
|
|
|
&& document.busyAnim
|
|
|
|
&& document.busyAnim.parentNode) {
|
2006-11-09 23:55:04 +01:00
|
|
|
document.busyAnim.parentNode.removeChild(document.busyAnim);
|
|
|
|
document.busyAnim = null;
|
|
|
|
}
|
2006-08-24 20:48:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-02 17:29:16 +02:00
|
|
|
function isSafari3() {
|
|
|
|
return (navigator.appVersion.indexOf("Version") > -1);
|
|
|
|
}
|
|
|
|
|
2007-06-07 21:21:24 +02:00
|
|
|
function isSafari() {
|
|
|
|
//var agt = navigator.userAgent.toLowerCase();
|
|
|
|
//var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
|
|
|
|
|
|
|
|
return (navigator.vendor == "Apple Computer, Inc.");
|
|
|
|
}
|
|
|
|
|
2007-06-12 16:58:15 +02:00
|
|
|
function isHttpStatus204(status) {
|
|
|
|
return (status == 204 || // Firefox
|
|
|
|
(isSafari() && typeof(status) == 'undefined') || // Safari
|
|
|
|
status == 1223); // IE
|
|
|
|
}
|
|
|
|
|
2007-05-28 23:29:07 +02:00
|
|
|
function getTarget(event) {
|
|
|
|
event = event || window.event;
|
|
|
|
if (event.target)
|
|
|
|
return event.target; // W3C DOM
|
|
|
|
else
|
|
|
|
return event.srcElement; // IE
|
|
|
|
}
|
|
|
|
|
|
|
|
function preventDefault(event) {
|
|
|
|
if (event.preventDefault)
|
|
|
|
event.preventDefault(); // W3C DOM
|
2007-09-10 20:46:05 +02:00
|
|
|
else
|
|
|
|
event.returnValue = false; // IE
|
2007-05-28 23:29:07 +02:00
|
|
|
}
|
|
|
|
|
2006-06-15 21:34:10 +02:00
|
|
|
function resetSelection(win) {
|
|
|
|
var t = "";
|
|
|
|
if (win && win.getSelection) {
|
|
|
|
t = win.getSelection().toString();
|
|
|
|
win.getSelection().removeAllRanges();
|
|
|
|
}
|
|
|
|
return t;
|
|
|
|
}
|
|
|
|
|
|
|
|
function refreshOpener() {
|
|
|
|
if (window.opener && !window.opener.closed) {
|
|
|
|
window.opener.location.reload();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* query string */
|
|
|
|
|
|
|
|
function parseQueryString() {
|
|
|
|
var queryArray, queryDict
|
2007-10-18 19:18:53 +02:00
|
|
|
var key, value, s, idx;
|
2006-06-15 21:34:10 +02:00
|
|
|
queryDict.length = 0;
|
|
|
|
|
|
|
|
queryDict = new Array();
|
|
|
|
queryArray = location.search.substr(1).split('&');
|
|
|
|
for (var i in queryArray) {
|
|
|
|
if (!queryArray[i]) continue ;
|
|
|
|
s = queryArray[i];
|
|
|
|
idx = s.indexOf("=");
|
|
|
|
if (idx == -1) {
|
|
|
|
key = s;
|
|
|
|
value = "";
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
key = s.substr(0, idx);
|
|
|
|
value = unescape(s.substr(idx + 1));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (typeof queryDict[key] == 'undefined')
|
|
|
|
queryDict.length++;
|
|
|
|
|
|
|
|
queryDict[key] = value;
|
|
|
|
}
|
|
|
|
return queryDict;
|
|
|
|
}
|
|
|
|
|
|
|
|
function generateQueryString(queryDict) {
|
|
|
|
var s = "";
|
|
|
|
for (var key in queryDict) {
|
|
|
|
if (s.length == 0)
|
|
|
|
s = "?";
|
|
|
|
else
|
|
|
|
s = s + "&";
|
|
|
|
s = s + key + "=" + escape(queryDict[key]);
|
|
|
|
}
|
|
|
|
return s;
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
/* selection mechanism */
|
|
|
|
|
2006-07-07 23:27:12 +02:00
|
|
|
function deselectAll(parent) {
|
|
|
|
for (var i = 0; i < parent.childNodes.length; i++) {
|
|
|
|
var node = parent.childNodes.item(i);
|
2006-09-07 00:26:22 +02:00
|
|
|
if (node.nodeType == 1)
|
2007-06-06 22:52:07 +02:00
|
|
|
$(node).deselect();
|
2006-07-07 23:27:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function isNodeSelected(node) {
|
2007-06-08 22:33:24 +02:00
|
|
|
return $(node).hasClassName('_selected');
|
2006-07-07 23:27:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function acceptMultiSelect(node) {
|
2007-10-18 19:18:53 +02:00
|
|
|
var response = false;
|
|
|
|
var attribute = node.getAttribute('multiselect');
|
|
|
|
if (attribute && attribute.length > 0) {
|
|
|
|
log("node '" + node.getAttribute("id")
|
|
|
|
+ "' is still using old-stylemultiselect!");
|
|
|
|
response = (attribute.toLowerCase() == 'yes');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
response = node.multiselect;
|
2006-07-07 23:27:12 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
return response;
|
2006-07-07 23:27:12 +02:00
|
|
|
}
|
|
|
|
|
2006-07-17 19:30:42 +02:00
|
|
|
function onRowClick(event) {
|
2007-05-28 23:29:07 +02:00
|
|
|
var node = getTarget(event);
|
2007-10-02 17:29:16 +02:00
|
|
|
var rowIndex = null;
|
2006-12-14 22:20:13 +01:00
|
|
|
|
2007-10-02 17:29:16 +02:00
|
|
|
if (node.tagName == 'TD') {
|
|
|
|
node = node.parentNode; // select TR
|
|
|
|
rowIndex = node.rowIndex - $(node).up('table').down('thead').getElementsByTagName('tr').length;
|
|
|
|
}
|
|
|
|
else if (node.tagName == 'LI') {
|
|
|
|
// Find index of clicked row
|
|
|
|
var list = node.parentNode;
|
|
|
|
var items = list.childNodesWithTag("li");
|
|
|
|
for (var i = 0; i < items.length; i++) {
|
|
|
|
if (items[i] == node) {
|
|
|
|
rowIndex = i;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var initialSelection = $(node.parentNode).getSelectedNodes();
|
|
|
|
if ((event.shiftKey == 1 || event.ctrlKey == 1)
|
|
|
|
&& lastClickedRow
|
2006-07-12 00:29:19 +02:00
|
|
|
&& (acceptMultiSelect(node.parentNode)
|
|
|
|
|| acceptMultiSelect(node.parentNode.parentNode))) {
|
2007-10-02 17:29:16 +02:00
|
|
|
if (event.shiftKey)
|
|
|
|
$(node.parentNode).selectRange(lastClickedRow, rowIndex);
|
|
|
|
else if (isNodeSelected(node) == true) {
|
2007-06-08 22:33:24 +02:00
|
|
|
$(node).deselect();
|
2006-07-07 23:27:12 +02:00
|
|
|
} else {
|
2007-06-08 22:33:24 +02:00
|
|
|
$(node).select();
|
2006-07-07 23:27:12 +02:00
|
|
|
}
|
2007-10-02 17:29:16 +02:00
|
|
|
// At this point, should empty content of 3-pane view
|
2006-07-07 23:27:12 +02:00
|
|
|
} else {
|
2007-10-02 17:29:16 +02:00
|
|
|
// Single line selection
|
2007-06-08 22:33:24 +02:00
|
|
|
$(node.parentNode).deselectAll();
|
|
|
|
$(node).select();
|
2007-10-02 17:29:16 +02:00
|
|
|
|
|
|
|
if (initialSelection != $(node.parentNode).getSelectedNodes()) {
|
|
|
|
// Selection has changed; fire mousedown event
|
|
|
|
var parentNode = node.parentNode;
|
|
|
|
if (parentNode.tagName == 'TBODY')
|
|
|
|
parentNode = parentNode.parentNode;
|
|
|
|
if (document.createEvent) {
|
|
|
|
var onSelectionChangeEvent;
|
|
|
|
if (isSafari())
|
|
|
|
onSelectionChangeEvent = document.createEvent("UIEvents");
|
|
|
|
else
|
|
|
|
onSelectionChangeEvent = document.createEvent("Events");
|
|
|
|
onSelectionChangeEvent.initEvent("mousedown", true, true);
|
|
|
|
parentNode.dispatchEvent(onSelectionChangeEvent);
|
|
|
|
}
|
|
|
|
else if (document.createEventObject) {
|
|
|
|
parentNode.fireEvent("onmousedown");
|
|
|
|
}
|
2007-05-25 17:49:51 +02:00
|
|
|
}
|
2006-07-07 23:27:12 +02:00
|
|
|
}
|
2007-10-02 17:29:16 +02:00
|
|
|
lastClickedRow = rowIndex;
|
|
|
|
|
2007-06-06 22:52:07 +02:00
|
|
|
return true;
|
2006-07-07 23:27:12 +02:00
|
|
|
}
|
2006-07-11 20:11:54 +02:00
|
|
|
|
|
|
|
/* popup menus */
|
|
|
|
|
2006-07-17 19:30:42 +02:00
|
|
|
// var acceptClick = false;
|
2006-07-11 20:11:54 +02:00
|
|
|
|
2007-05-18 18:15:01 +02:00
|
|
|
function popupMenu(event, menuId, target) {
|
2007-10-18 19:18:53 +02:00
|
|
|
document.menuTarget = target;
|
|
|
|
|
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(document.currentPopupMenu);
|
|
|
|
|
|
|
|
var popup = $(menuId);
|
2007-10-31 18:16:14 +01:00
|
|
|
|
|
|
|
var deltaX = 0;
|
|
|
|
var deltaY = 0;
|
|
|
|
|
|
|
|
var pageContent = $("pageContent");
|
|
|
|
if (popup.parentNode.tagName != "BODY") {
|
|
|
|
var offset = pageContent.cascadeLeftOffset();
|
|
|
|
deltaX = -($(popup.parentNode).cascadeLeftOffset() - offset);
|
|
|
|
offset = pageContent.cascadeTopOffset();
|
|
|
|
deltaY = -($(popup.parentNode).cascadeTopOffset() - offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
var menuTop = Event.pointerY(event) + deltaY;
|
|
|
|
var menuLeft = Event.pointerX(event) + deltaX;
|
2007-10-18 19:18:53 +02:00
|
|
|
var heightDiff = (window.height()
|
|
|
|
- (menuTop + popup.offsetHeight));
|
|
|
|
if (heightDiff < 0)
|
|
|
|
menuTop += heightDiff;
|
2007-05-18 18:15:01 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
var leftDiff = (window.width()
|
|
|
|
- (menuLeft + popup.offsetWidth));
|
|
|
|
if (leftDiff < 0)
|
|
|
|
menuLeft -= popup.offsetWidth;
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-10-22 23:59:20 +02:00
|
|
|
if (popup.prepareVisibility)
|
|
|
|
popup.prepareVisibility();
|
2007-10-18 19:18:53 +02:00
|
|
|
popup.setStyle({ top: menuTop + "px",
|
2007-10-22 23:59:20 +02:00
|
|
|
left: menuLeft + "px",
|
|
|
|
visibility: "visible" });
|
2006-08-01 20:05:06 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
document.currentPopupMenu = popup;
|
2007-08-15 00:09:20 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
Event.observe(document.body, "click", onBodyClickMenuHandler);
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
preventDefault(event);
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-01-03 22:08:56 +01:00
|
|
|
function getParentMenu(node) {
|
2006-07-29 00:59:11 +02:00
|
|
|
var currentNode, menuNode;
|
|
|
|
|
|
|
|
menuNode = null;
|
|
|
|
currentNode = node;
|
|
|
|
var menure = new RegExp("(^|\s+)menu(\s+|$)", "i");
|
|
|
|
|
|
|
|
while (menuNode == null
|
|
|
|
&& currentNode)
|
|
|
|
if (menure.test(currentNode.className))
|
|
|
|
menuNode = currentNode;
|
|
|
|
else
|
|
|
|
currentNode = currentNode.parentNode;
|
|
|
|
|
|
|
|
return menuNode;
|
2006-07-11 20:11:54 +02:00
|
|
|
}
|
|
|
|
|
2007-05-28 15:18:31 +02:00
|
|
|
function onBodyClickMenuHandler(event) {
|
2007-10-18 19:18:53 +02:00
|
|
|
hideMenu(document.currentPopupMenu);
|
|
|
|
Event.stopObserving(document.body, "click", onBodyClickMenuHandler);
|
2007-05-28 15:18:31 +02:00
|
|
|
|
2007-10-25 21:22:07 +02:00
|
|
|
if (event)
|
|
|
|
preventDefault(event);
|
2006-07-11 20:11:54 +02:00
|
|
|
}
|
|
|
|
|
2007-09-14 20:20:51 +02:00
|
|
|
function hideMenu(menuNode) {
|
2006-07-29 00:59:11 +02:00
|
|
|
var onHide;
|
|
|
|
|
2007-01-03 22:08:56 +01:00
|
|
|
if (menuNode.submenu) {
|
2007-07-05 21:13:59 +02:00
|
|
|
hideMenu(menuNode.submenu);
|
2007-01-03 22:08:56 +01:00
|
|
|
menuNode.submenu = null;
|
|
|
|
}
|
2006-07-13 21:13:18 +02:00
|
|
|
|
2007-05-28 15:18:31 +02:00
|
|
|
menuNode.setStyle({ visibility: "hidden" });
|
|
|
|
// menuNode.hide();
|
2007-01-03 22:08:56 +01:00
|
|
|
if (menuNode.parentMenuItem) {
|
2007-10-18 19:18:53 +02:00
|
|
|
Event.stopObserving(menuNode.parentMenuItem, "mouseover",
|
|
|
|
onMouseEnteredSubmenu);
|
|
|
|
Event.stopObserving(menuNode, "mouseover", onMouseEnteredSubmenu);
|
2007-10-17 21:08:00 +02:00
|
|
|
Event.stopObserving(menuNode.parentMenuItem, "mouseout", onMouseLeftSubmenu);
|
|
|
|
Event.stopObserving(menuNode, "mouseout", onMouseLeftSubmenu);
|
2007-10-18 19:18:53 +02:00
|
|
|
Event.stopObserving(menuNode.parentMenu, "mouseover",
|
|
|
|
onMouseEnteredParentMenu);
|
|
|
|
$(menuNode.parentMenuItem).removeClassName("submenu-selected");
|
|
|
|
menuNode.parentMenuItem.mouseInside = false;
|
2007-01-03 22:08:56 +01:00
|
|
|
menuNode.parentMenuItem = null;
|
|
|
|
menuNode.parentMenu.submenuItem = null;
|
|
|
|
menuNode.parentMenu.submenu = null;
|
|
|
|
menuNode.parentMenu = null;
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
|
2007-09-14 20:20:51 +02:00
|
|
|
if (document.createEvent) { // Safari & Mozilla
|
2007-08-15 00:09:20 +02:00
|
|
|
var onhideEvent;
|
|
|
|
if (isSafari())
|
|
|
|
onhideEvent = document.createEvent("UIEvents");
|
2007-09-14 20:20:51 +02:00
|
|
|
else
|
2007-08-15 00:09:20 +02:00
|
|
|
onhideEvent = document.createEvent("Events");
|
|
|
|
onhideEvent.initEvent("mousedown", false, true);
|
2007-05-25 17:49:51 +02:00
|
|
|
menuNode.dispatchEvent(onhideEvent);
|
|
|
|
}
|
2007-08-15 00:09:20 +02:00
|
|
|
else if (document.createEventObject) { // IE
|
|
|
|
menuNode.fireEvent("onmousedown");
|
2007-05-25 17:49:51 +02:00
|
|
|
}
|
2006-07-13 21:13:18 +02:00
|
|
|
}
|
|
|
|
|
2007-05-18 18:15:01 +02:00
|
|
|
function onMenuEntryClick(event) {
|
2006-07-29 00:59:11 +02:00
|
|
|
var node = event.target;
|
|
|
|
|
|
|
|
id = getParentMenu(node).menuTarget;
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-08-19 00:40:04 +02:00
|
|
|
function parseQueryParameters(url) {
|
|
|
|
var parameters = new Array();
|
|
|
|
|
|
|
|
var params = url.split("?")[1];
|
|
|
|
if (params) {
|
|
|
|
var pairs = params.split("&");
|
|
|
|
for (var i = 0; i < pairs.length; i++) {
|
|
|
|
var pair = pairs[i].split("=");
|
|
|
|
parameters[pair[0]] = pair[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return parameters;
|
|
|
|
}
|
|
|
|
|
2006-07-29 00:59:11 +02:00
|
|
|
function initLogConsole() {
|
2007-10-18 19:18:53 +02:00
|
|
|
var logConsole = $("logConsole");
|
|
|
|
if (logConsole) {
|
|
|
|
logConsole.highlighted = false;
|
|
|
|
Event.observe(logConsole, "dblclick", onLogDblClick, false);
|
|
|
|
logConsole.innerHTML = "";
|
|
|
|
Event.observe(window, "keydown", onBodyKeyDown);
|
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-01-03 22:08:56 +01:00
|
|
|
function onBodyKeyDown(event) {
|
2007-10-18 19:18:53 +02:00
|
|
|
if (event.keyCode == 27) {
|
|
|
|
toggleLogConsole();
|
|
|
|
preventDefault(event);
|
|
|
|
}
|
2006-08-19 00:40:04 +02:00
|
|
|
}
|
|
|
|
|
2007-01-03 22:08:56 +01:00
|
|
|
function onLogDblClick(event) {
|
2006-11-17 23:23:15 +01:00
|
|
|
var logConsole = $("logConsole");
|
2006-11-21 21:31:04 +01:00
|
|
|
logConsole.innerHTML = "";
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2006-11-17 23:23:15 +01:00
|
|
|
function toggleLogConsole(event) {
|
|
|
|
var logConsole = $("logConsole");
|
2006-11-02 23:05:03 +01:00
|
|
|
var display = '' + logConsole.style.display;
|
|
|
|
if (display.length == 0) {
|
2007-05-18 16:03:58 +02:00
|
|
|
logConsole.setStyle({ display: 'block' });
|
2006-07-29 00:59:11 +02:00
|
|
|
} else {
|
2007-05-18 16:03:58 +02:00
|
|
|
logConsole.setStyle({ display: '' });
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
2007-05-28 15:18:31 +02:00
|
|
|
if (event)
|
2007-10-18 19:18:53 +02:00
|
|
|
preventDefault(event);
|
2006-07-11 20:11:54 +02:00
|
|
|
}
|
|
|
|
|
2006-07-13 21:13:18 +02:00
|
|
|
function log(message) {
|
2006-08-31 01:02:53 +02:00
|
|
|
if (!logWindow) {
|
|
|
|
logWindow = window;
|
|
|
|
while (logWindow.opener)
|
|
|
|
logWindow = logWindow.opener;
|
|
|
|
}
|
2007-01-03 22:08:56 +01:00
|
|
|
var logConsole = logWindow.document.getElementById("logConsole");
|
2007-05-25 16:25:34 +02:00
|
|
|
if (logConsole) {
|
2007-10-18 19:18:53 +02:00
|
|
|
logConsole.highlighted = !logConsole.highlighted;
|
|
|
|
if (message == '\c') {
|
|
|
|
logConsole.innerHTML = "";
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
var logMessage = message.replace("<", "<", "g");
|
|
|
|
logMessage = logMessage.replace(" ", " ", "g");
|
|
|
|
logMessage = logMessage.replace("\r\n", "<br />\n", "g");
|
|
|
|
logMessage = logMessage.replace("\n", "<br />\n", "g");
|
|
|
|
logMessage += '<br />' + "\n";
|
|
|
|
if (logConsole.highlighted)
|
|
|
|
logMessage = '<div class="highlighted">' + logMessage + '</div>';
|
|
|
|
logConsole.innerHTML += logMessage;
|
2007-05-25 16:25:34 +02:00
|
|
|
}
|
2006-07-13 21:13:18 +02:00
|
|
|
}
|
|
|
|
|
2007-02-13 23:00:29 +01:00
|
|
|
function backtrace() {
|
2007-10-18 19:18:53 +02:00
|
|
|
var func = backtrace.caller;
|
|
|
|
var str = "backtrace:\n";
|
2007-02-13 23:00:29 +01:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
while (func)
|
|
|
|
{
|
2007-02-13 23:00:29 +01:00
|
|
|
if (func.name)
|
2007-10-18 19:18:53 +02:00
|
|
|
{
|
|
|
|
str += " " + func.name;
|
|
|
|
if (this)
|
2007-02-13 23:00:29 +01:00
|
|
|
str += " (" + this + ")";
|
2007-10-18 19:18:53 +02:00
|
|
|
}
|
2007-02-13 23:00:29 +01:00
|
|
|
else
|
2007-10-18 19:18:53 +02:00
|
|
|
str += "[anonymous]\n";
|
2007-02-13 23:00:29 +01:00
|
|
|
|
2007-05-28 15:18:31 +02:00
|
|
|
str += "\n";
|
2007-02-13 23:00:29 +01:00
|
|
|
func = func.caller;
|
2007-10-18 19:18:53 +02:00
|
|
|
}
|
|
|
|
str += "--\n";
|
2007-02-13 23:00:29 +01:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
return str;
|
2007-02-13 23:00:29 +01:00
|
|
|
}
|
|
|
|
|
2007-10-17 21:08:00 +02:00
|
|
|
function popupSubmenu(event) {
|
2007-10-18 19:18:53 +02:00
|
|
|
if (this.submenu && this.submenu != "") {
|
|
|
|
var submenuNode = $(this.submenu);
|
|
|
|
var parentNode = getParentMenu(this);
|
|
|
|
if (parentNode.submenu)
|
|
|
|
hideMenu(parentNode.submenu);
|
|
|
|
submenuNode.parentMenuItem = this;
|
|
|
|
submenuNode.parentMenu = parentNode;
|
|
|
|
parentNode.submenuItem = this;
|
|
|
|
parentNode.submenu = submenuNode;
|
|
|
|
|
2007-10-22 23:59:20 +02:00
|
|
|
if (submenuNode.prepareVisibility)
|
|
|
|
submenuNode.prepareVisibility();
|
|
|
|
|
2007-10-19 21:32:00 +02:00
|
|
|
var menuTop = (parentNode.offsetTop - 1
|
2007-10-18 19:18:53 +02:00
|
|
|
+ this.offsetTop);
|
|
|
|
if (window.height()
|
2007-10-19 21:32:00 +02:00
|
|
|
< (menuTop + submenuNode.offsetHeight)
|
|
|
|
&& submenuNode.offsetHeight < window.height())
|
|
|
|
menuTop -= submenuNode.offsetHeight - this.offsetHeight - 4;
|
2007-10-18 19:18:53 +02:00
|
|
|
var menuLeft = (parentNode.offsetLeft + parentNode.offsetWidth - 3);
|
|
|
|
if (window.width()
|
|
|
|
< (menuLeft + submenuNode.offsetWidth))
|
|
|
|
menuLeft = parentNode.offsetLeft - submenuNode.offsetWidth + 3;
|
|
|
|
|
|
|
|
this.mouseInside = true;
|
|
|
|
Event.observe(this, "mouseover",
|
|
|
|
onMouseEnteredSubmenu.bindAsEventListener(this));
|
|
|
|
Event.observe(submenuNode, "mouseover",
|
|
|
|
onMouseEnteredSubmenu.bindAsEventListener(submenuNode));
|
|
|
|
Event.observe(this, "mouseout", onMouseLeftSubmenu.bindAsEventListener(this));
|
|
|
|
Event.observe(submenuNode, "mouseout",
|
|
|
|
onMouseLeftSubmenu.bindAsEventListener(submenuNode));
|
|
|
|
Event.observe(parentNode, "mouseover",
|
|
|
|
onMouseEnteredParentMenu.bindAsEventListener(parentNode));
|
|
|
|
$(this).addClassName("submenu-selected");
|
|
|
|
submenuNode.setStyle({ top: menuTop + "px",
|
2007-10-19 21:32:00 +02:00
|
|
|
left: menuLeft + "px",
|
|
|
|
visibility: "visible" });
|
2007-10-18 19:18:53 +02:00
|
|
|
preventDefault(event);
|
|
|
|
}
|
2006-07-29 00:59:11 +02:00
|
|
|
}
|
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
function onMouseEnteredParentMenu(event) {
|
|
|
|
if (this.submenuItem && !this.submenuItem.mouseInside)
|
|
|
|
hideMenu(this.submenu);
|
2007-10-17 21:08:00 +02:00
|
|
|
}
|
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
function onMouseEnteredSubmenu(event) {
|
|
|
|
$(this).mouseInside = true;
|
2006-07-13 21:13:18 +02:00
|
|
|
}
|
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
function onMouseLeftSubmenu(event) {
|
|
|
|
$(this).mouseInside = false;
|
2007-10-17 21:08:00 +02:00
|
|
|
}
|
|
|
|
|
2006-08-22 00:36:33 +02:00
|
|
|
/* search field */
|
2007-03-22 22:14:17 +01:00
|
|
|
function popupSearchMenu(event) {
|
|
|
|
var menuId = this.getAttribute("menuid");
|
2007-08-15 00:09:20 +02:00
|
|
|
var offset = Position.cumulativeOffset(this);
|
|
|
|
|
|
|
|
relX = Event.pointerX(event) - offset[0];
|
|
|
|
relY = Event.pointerY(event) - offset[1];
|
2006-08-22 00:36:33 +02:00
|
|
|
|
|
|
|
if (event.button == 0
|
|
|
|
&& relX < 24) {
|
|
|
|
event.cancelBubble = true;
|
|
|
|
event.returnValue = false;
|
|
|
|
|
2006-08-22 21:16:12 +02:00
|
|
|
if (document.currentPopupMenu)
|
2007-07-05 21:13:59 +02:00
|
|
|
hideMenu(document.currentPopupMenu);
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-06-27 23:20:15 +02:00
|
|
|
var popup = $(menuId);
|
2007-08-15 00:09:20 +02:00
|
|
|
offset = Position.positionedOffset(this);
|
2007-06-27 23:20:15 +02:00
|
|
|
popup.setStyle({ top: this.offsetHeight + "px",
|
2007-10-18 19:18:53 +02:00
|
|
|
left: (offset[0] + 3) + "px",
|
|
|
|
visibility: "visible" });
|
2006-08-22 00:36:33 +02:00
|
|
|
|
|
|
|
document.currentPopupMenu = popup;
|
2007-05-28 15:18:31 +02:00
|
|
|
Event.observe(document.body, "click", onBodyClickMenuHandler);
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-01-03 22:08:56 +01:00
|
|
|
function setSearchCriteria(event) {
|
2007-08-15 00:09:20 +02:00
|
|
|
var searchValue = $("searchValue");
|
|
|
|
var searchCriteria = $("searchCriteria");
|
2007-05-22 16:54:46 +02:00
|
|
|
|
|
|
|
searchValue.setAttribute("ghost-phrase", this.innerHTML);
|
2007-06-27 23:20:15 +02:00
|
|
|
searchCriteria.value = this.getAttribute('id');
|
2007-09-14 20:20:51 +02:00
|
|
|
|
|
|
|
if (this.parentNode.chosenNode)
|
|
|
|
this.parentNode.chosenNode.removeClassName("_chosen");
|
|
|
|
this.addClassName("_chosen");
|
|
|
|
this.parentNode.chosenNode = this;
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2007-01-03 22:08:56 +01:00
|
|
|
function checkSearchValue(event) {
|
2006-08-22 00:36:33 +02:00
|
|
|
var form = event.target;
|
2007-01-03 22:08:56 +01:00
|
|
|
var searchValue = $("searchValue");
|
2006-08-22 00:36:33 +02:00
|
|
|
var ghostPhrase = searchValue.getAttribute('ghost-phrase');
|
|
|
|
|
|
|
|
if (searchValue.value == ghostPhrase)
|
|
|
|
searchValue.value = "";
|
|
|
|
}
|
|
|
|
|
2007-01-03 22:08:56 +01:00
|
|
|
function onSearchChange() {
|
2006-10-31 00:32:25 +01:00
|
|
|
log ("onSearchChange()...");
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2007-06-27 23:20:15 +02:00
|
|
|
function configureSearchField() {
|
2007-10-18 19:18:53 +02:00
|
|
|
var searchValue = $("searchValue");
|
|
|
|
var searchOptions = $("searchOptions");
|
|
|
|
|
|
|
|
if (!searchValue) return;
|
|
|
|
|
|
|
|
Event.observe(searchValue, "mousedown",
|
|
|
|
onSearchMouseDown.bindAsEventListener(searchValue));
|
|
|
|
Event.observe(searchValue, "click",
|
|
|
|
popupSearchMenu.bindAsEventListener(searchValue));
|
|
|
|
Event.observe(searchValue, "blur",
|
|
|
|
onSearchBlur.bindAsEventListener(searchValue));
|
|
|
|
Event.observe(searchValue, "focus",
|
|
|
|
onSearchFocus.bindAsEventListener(searchValue));
|
|
|
|
Event.observe(searchValue, "keydown",
|
|
|
|
onSearchKeyDown.bindAsEventListener(searchValue));
|
|
|
|
|
|
|
|
if (!searchOptions) return;
|
2007-09-14 20:20:51 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
// Set the checkmark to the first option
|
|
|
|
var firstOption = searchOptions.down('li');
|
|
|
|
firstOption.addClassName("_chosen");
|
|
|
|
searchOptions.chosenNode = firstOption;
|
2007-06-27 23:20:15 +02:00
|
|
|
}
|
|
|
|
|
2007-03-22 22:14:17 +01:00
|
|
|
function onSearchMouseDown(event) {
|
2007-10-18 19:18:53 +02:00
|
|
|
var superNode = this.parentNode.parentNode.parentNode;
|
|
|
|
relX = (Event.pointerX(event) - superNode.offsetLeft - this.offsetLeft);
|
|
|
|
relY = (Event.pointerY(event) - superNode.offsetTop - this.offsetTop);
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
if (relY < 24) {
|
|
|
|
event.cancelBubble = true;
|
|
|
|
event.returnValue = false;
|
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2007-03-22 22:14:17 +01:00
|
|
|
function onSearchFocus() {
|
|
|
|
ghostPhrase = this.getAttribute("ghost-phrase");
|
|
|
|
if (this.value == ghostPhrase) {
|
|
|
|
this.value = "";
|
|
|
|
this.setAttribute("modified", "");
|
2006-08-22 00:36:33 +02:00
|
|
|
} else {
|
2007-03-22 22:14:17 +01:00
|
|
|
this.select();
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2007-05-25 17:49:51 +02:00
|
|
|
this.setStyle({ color: "#000" });
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2007-03-22 22:14:17 +01:00
|
|
|
function onSearchBlur(event) {
|
2007-10-18 19:18:53 +02:00
|
|
|
var ghostPhrase = this.getAttribute("ghost-phrase");
|
2007-09-14 20:20:51 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
if (!this.value) {
|
2007-03-22 22:14:17 +01:00
|
|
|
this.setAttribute("modified", "");
|
2007-05-25 17:49:51 +02:00
|
|
|
this.setStyle({ color: "#aaa" });
|
2007-03-22 22:14:17 +01:00
|
|
|
this.value = ghostPhrase;
|
2007-08-15 00:09:20 +02:00
|
|
|
refreshCurrentFolder();
|
2007-03-22 22:14:17 +01:00
|
|
|
} else if (this.value == ghostPhrase) {
|
|
|
|
this.setAttribute("modified", "");
|
2007-05-25 17:49:51 +02:00
|
|
|
this.setStyle({ color: "#aaa" });
|
2006-08-22 00:36:33 +02:00
|
|
|
} else {
|
2007-03-22 22:14:17 +01:00
|
|
|
this.setAttribute("modified", "yes");
|
2007-05-25 17:49:51 +02:00
|
|
|
this.setStyle({ color: "#000" });
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-03-22 22:14:17 +01:00
|
|
|
function onSearchKeyDown(event) {
|
|
|
|
if (this.timer)
|
|
|
|
clearTimeout(this.timer);
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-03-22 22:14:17 +01:00
|
|
|
this.timer = setTimeout("onSearchFormSubmit()", 1000);
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
|
2007-08-15 00:09:20 +02:00
|
|
|
function onSearchFormSubmit(event) {
|
2007-10-18 19:18:53 +02:00
|
|
|
var searchValue = $("searchValue");
|
|
|
|
var searchCriteria = $("searchCriteria");
|
|
|
|
var ghostPhrase = searchValue.getAttribute('ghost-phrase');
|
2007-09-14 20:20:51 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
if (searchValue.value == ghostPhrase) return;
|
2007-06-28 22:34:35 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
search["criteria"] = searchCriteria.value;
|
|
|
|
search["value"] = searchValue.value;
|
2007-06-28 22:34:35 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
refreshCurrentFolder();
|
2007-06-28 22:34:35 +02:00
|
|
|
}
|
|
|
|
|
2007-01-03 22:08:56 +01:00
|
|
|
function initCriteria() {
|
|
|
|
var searchCriteria = $("searchCriteria");
|
|
|
|
var searchValue = $("searchValue");
|
2006-08-22 00:36:33 +02:00
|
|
|
|
2007-08-15 00:09:20 +02:00
|
|
|
if (!searchValue) return;
|
|
|
|
|
2007-06-27 23:20:15 +02:00
|
|
|
var searchOptions = $("searchOptions").childNodesWithTag("li");
|
|
|
|
if (searchOptions.length > 0) {
|
|
|
|
var firstChild = searchOptions[0];
|
|
|
|
searchCriteria.value = $(firstChild).getAttribute('id');
|
|
|
|
searchValue.setAttribute('ghost-phrase', firstChild.innerHTML);
|
2007-01-03 22:08:56 +01:00
|
|
|
if (searchValue.value == '') {
|
2007-06-27 23:20:15 +02:00
|
|
|
searchValue.value = firstChild.innerHTML;
|
2007-01-03 22:08:56 +01:00
|
|
|
searchValue.setAttribute("modified", "");
|
2007-05-25 17:49:51 +02:00
|
|
|
searchValue.setStyle({ color: "#aaa" });
|
2007-01-03 22:08:56 +01:00
|
|
|
}
|
2006-08-22 00:36:33 +02:00
|
|
|
}
|
|
|
|
}
|
2007-01-03 22:08:56 +01:00
|
|
|
|
2007-03-18 16:00:34 +01:00
|
|
|
/* toolbar buttons */
|
2007-07-05 21:13:59 +02:00
|
|
|
function popupToolbarMenu(node, menuId) {
|
2007-10-18 19:18:53 +02:00
|
|
|
if (document.currentPopupMenu)
|
|
|
|
hideMenu(document.currentPopupMenu);
|
2007-07-05 21:13:59 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
var popup = $(menuId);
|
|
|
|
var top = ($(node).getStyle('top') || 0) + node.offsetHeight - 2;
|
|
|
|
popup.setStyle({ top: top + "px",
|
|
|
|
left: $(node).cascadeLeftOffset() + "px",
|
|
|
|
visibility: "visible" });
|
2007-07-05 21:13:59 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
document.currentPopupMenu = popup;
|
|
|
|
Event.observe(document.body, "click", onBodyClickMenuHandler);
|
2007-03-18 16:00:34 +01:00
|
|
|
}
|
|
|
|
|
2006-08-14 22:31:49 +02:00
|
|
|
/* contact selector */
|
|
|
|
|
2007-03-29 20:02:48 +02:00
|
|
|
function folderSubscriptionCallback(http) {
|
2007-10-18 19:18:53 +02:00
|
|
|
if (http.readyState == 4) {
|
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
if (http.callbackData)
|
|
|
|
http.callbackData["method"](http.callbackData["data"]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
window.alert(clabels["Unable to subscribe to that folder!"]);
|
|
|
|
document.subscriptionAjaxRequest = null;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
log ("folderSubscriptionCallback Ajax error");
|
2007-03-29 20:02:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function subscribeToFolder(refreshCallback, refreshCallbackData) {
|
2007-10-18 19:18:53 +02:00
|
|
|
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();
|
|
|
|
}
|
2007-09-15 00:01:02 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
var rfCbData = { method: refreshCallback, data: refreshCallbackData };
|
|
|
|
document.subscriptionAjaxRequest = triggerAjaxRequest(url,
|
|
|
|
folderSubscriptionCallback,
|
|
|
|
rfCbData);
|
|
|
|
}
|
|
|
|
else
|
2007-10-23 16:39:29 +02:00
|
|
|
refreshCallbackData["window"].alert(clabels["You cannot subscribe to a folder that you own!"]);
|
2006-08-14 22:31:49 +02:00
|
|
|
}
|
|
|
|
|
2007-03-29 20:02:48 +02:00
|
|
|
function folderUnsubscriptionCallback(http) {
|
2007-10-18 19:18:53 +02:00
|
|
|
if (http.readyState == 4) {
|
2007-10-23 16:39:29 +02:00
|
|
|
removeFolderRequestCount--;
|
2007-10-18 19:18:53 +02:00
|
|
|
if (isHttpStatus204(http.status)) {
|
|
|
|
if (http.callbackData)
|
|
|
|
http.callbackData["method"](http.callbackData["data"]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
window.alert(clabels["Unable to unsubscribe from that folder!"]);
|
|
|
|
}
|
2007-03-29 20:02:48 +02:00
|
|
|
}
|
2006-10-14 01:35:10 +02:00
|
|
|
|
2007-03-29 20:02:48 +02:00
|
|
|
function unsubscribeFromFolder(folder, refreshCallback, refreshCallbackData) {
|
2007-09-15 00:01:02 +02:00
|
|
|
if (document.body.hasClassName("popup")) {
|
|
|
|
window.opener.unsubscribeFromFolder(folder, refreshCallback,
|
|
|
|
refreshCallbackData);
|
|
|
|
}
|
|
|
|
else {
|
2007-10-23 16:39:29 +02:00
|
|
|
var folderData = folder.split("_");
|
2007-09-15 00:01:02 +02:00
|
|
|
var username = folderData[0];
|
|
|
|
var folderPath = folderData[1];
|
2007-10-23 16:39:29 +02:00
|
|
|
if (username.startsWith('/'))
|
|
|
|
username = username.substring(1);
|
2007-09-15 00:01:02 +02:00
|
|
|
if (username != UserLogin) {
|
|
|
|
var url = (ApplicationBaseURL + folder + "/unsubscribe");
|
2007-10-23 16:39:29 +02:00
|
|
|
removeFolderRequestCount++;
|
2007-09-15 00:01:02 +02:00
|
|
|
var rfCbData = { method: refreshCallback, data: refreshCallbackData };
|
2007-10-23 16:39:29 +02:00
|
|
|
triggerAjaxRequest(url, folderUnsubscriptionCallback, rfCbData);
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
else
|
2007-10-18 16:44:58 +02:00
|
|
|
window.alert(clabels["You cannot unsubscribe from a folder that you own!"]);
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function accessToSubscribedFolder(serverFolder) {
|
|
|
|
var folder;
|
|
|
|
|
|
|
|
var parts = serverFolder.split(":");
|
|
|
|
if (parts.length > 1) {
|
|
|
|
var paths = parts[1].split("/");
|
|
|
|
folder = "/" + parts[0] + "_" + paths[2];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
folder = serverFolder;
|
|
|
|
|
|
|
|
return folder;
|
2006-08-31 01:02:53 +02:00
|
|
|
}
|
|
|
|
|
2007-10-23 16:39:29 +02:00
|
|
|
function getSubscribedFolderOwner(serverFolder) {
|
|
|
|
var owner;
|
|
|
|
|
|
|
|
var parts = serverFolder.split(":");
|
|
|
|
if (parts.length > 1) {
|
|
|
|
owner = parts[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
return owner;
|
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function listRowMouseDownHandler(event) {
|
2007-09-24 23:26:23 +02:00
|
|
|
preventDefault(event);
|
|
|
|
//Event.stop(event);
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|
|
|
|
|
2006-08-25 22:46:29 +02:00
|
|
|
/* tabs */
|
2007-03-19 15:31:49 +01:00
|
|
|
function initTabs() {
|
2006-08-25 22:46:29 +02:00
|
|
|
var containers = document.getElementsByClassName("tabsContainer");
|
|
|
|
for (var x = 0; x < containers.length; x++) {
|
|
|
|
var container = containers[x];
|
2007-05-25 17:49:51 +02:00
|
|
|
var firstTab = null;
|
|
|
|
for (var i = 0; i < container.childNodes.length; i++) {
|
|
|
|
if (container.childNodes[i].tagName == 'UL') {
|
|
|
|
if (!firstTab)
|
|
|
|
firstTab = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var nodes = container.childNodes[firstTab].childNodes;
|
|
|
|
|
|
|
|
firstTab = null;
|
2006-08-25 22:46:29 +02:00
|
|
|
for (var i = 0; i < nodes.length; i++) {
|
2007-10-18 19:18:53 +02:00
|
|
|
var currentNode = nodes[i];
|
|
|
|
if (currentNode.tagName == 'LI') {
|
|
|
|
if (!firstTab)
|
|
|
|
firstTab = i;
|
|
|
|
Event.observe(currentNode, "mousedown",
|
|
|
|
onTabMouseDown.bindAsEventListener(currentNode));
|
|
|
|
Event.observe(currentNode, "click",
|
|
|
|
onTabClick.bindAsEventListener(currentNode));
|
|
|
|
//$(currentNode.getAttribute("target")).hide();
|
|
|
|
}
|
2006-08-25 22:46:29 +02:00
|
|
|
}
|
|
|
|
|
2007-05-09 23:27:55 +02:00
|
|
|
nodes[firstTab].addClassName("first");
|
|
|
|
nodes[firstTab].addClassName("active");
|
|
|
|
container.activeTab = nodes[firstTab];
|
2006-08-25 22:46:29 +02:00
|
|
|
|
2007-05-09 23:27:55 +02:00
|
|
|
var target = $(nodes[firstTab].getAttribute("target"));
|
2006-10-27 00:00:54 +02:00
|
|
|
target.addClassName("active");
|
2007-06-08 22:33:24 +02:00
|
|
|
//target.show();
|
2006-08-25 22:46:29 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-18 18:15:01 +02:00
|
|
|
function initMenus() {
|
2007-10-18 19:18:53 +02:00
|
|
|
var menus = getMenus();
|
|
|
|
if (menus) {
|
|
|
|
for (var menuID in menus) {
|
|
|
|
var menuDIV = $(menuID);
|
|
|
|
if (menuDIV)
|
|
|
|
initMenu(menuDIV, menus[menuID]);
|
|
|
|
}
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2007-05-18 18:15:01 +02:00
|
|
|
function initMenu(menuDIV, callbacks) {
|
2007-10-18 19:18:53 +02:00
|
|
|
var lis = $(menuDIV.childNodesWithTag("ul")[0]).childNodesWithTag("li");
|
|
|
|
for (var j = 0; j < lis.length; j++) {
|
|
|
|
var node = $(lis[j]);
|
|
|
|
Event.observe(node, "mousedown",
|
|
|
|
listRowMouseDownHandler.bindAsEventListener(node),
|
|
|
|
false);
|
|
|
|
var callback = callbacks[j];
|
|
|
|
if (callback) {
|
|
|
|
if (typeof(callback) == "string") {
|
|
|
|
if (callback == "-")
|
|
|
|
node.addClassName("separator");
|
|
|
|
else {
|
|
|
|
node.submenu = callback;
|
|
|
|
node.addClassName("submenu");
|
|
|
|
Event.observe(node, "mouseover",
|
|
|
|
popupSubmenu.bindAsEventListener(node));
|
|
|
|
}
|
2007-05-18 18:15:01 +02:00
|
|
|
}
|
2007-10-25 21:22:07 +02:00
|
|
|
else {
|
2007-10-18 19:18:53 +02:00
|
|
|
Event.observe(node, "mouseup",
|
2007-10-25 21:22:07 +02:00
|
|
|
onBodyClickMenuHandler);
|
|
|
|
Event.observe(node, "click",
|
2007-10-18 19:18:53 +02:00
|
|
|
$(callback).bindAsEventListener(node));
|
2007-10-25 21:22:07 +02:00
|
|
|
}
|
2007-10-18 19:18:53 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
node.addClassName("disabled");
|
|
|
|
}
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2006-08-25 22:46:29 +02:00
|
|
|
function onTabMouseDown(event) {
|
|
|
|
event.cancelBubble = true;
|
2007-05-28 23:29:07 +02:00
|
|
|
preventDefault(event);
|
2006-08-25 22:46:29 +02:00
|
|
|
}
|
|
|
|
|
2006-09-16 00:27:59 +02:00
|
|
|
function openExternalLink(anchor) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-03-29 20:02:48 +02:00
|
|
|
function openAclWindow(url) {
|
2006-12-14 22:20:13 +01:00
|
|
|
var w = window.open(url, "aclWindow",
|
2007-05-18 01:13:28 +02:00
|
|
|
"width=420,height=300,resizable=1,scrollbars=1,toolbar=0,"
|
2006-12-14 22:20:13 +01:00
|
|
|
+ "location=0,directories=0,status=0,menubar=0"
|
|
|
|
+ ",copyhistory=0");
|
2007-03-29 20:02:48 +02:00
|
|
|
w.opener = window;
|
2006-12-14 22:20:13 +01:00
|
|
|
w.focus();
|
|
|
|
|
|
|
|
return w;
|
|
|
|
}
|
|
|
|
|
2007-04-28 00:06:58 +02:00
|
|
|
function getUsersRightsWindowHeight() {
|
2007-10-18 19:18:53 +02:00
|
|
|
return usersRightsWindowHeight;
|
2007-04-28 00:06:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getUsersRightsWindowWidth() {
|
2007-10-18 19:18:53 +02:00
|
|
|
return usersRightsWindowWidth;
|
2007-04-28 00:06:58 +02:00
|
|
|
}
|
|
|
|
|
2007-05-04 17:57:23 +02:00
|
|
|
function getTopWindow() {
|
2007-10-18 19:18:53 +02:00
|
|
|
var topWindow = null;
|
|
|
|
var currentWindow = window;
|
|
|
|
while (!topWindow) {
|
|
|
|
if (currentWindow.document.body.hasClassName("popup")
|
|
|
|
&& currentWindow.opener)
|
|
|
|
currentWindow = currentWindow.opener;
|
|
|
|
else
|
|
|
|
topWindow = currentWindow;
|
|
|
|
}
|
2007-05-04 17:57:23 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
return topWindow;
|
2007-05-04 17:57:23 +02:00
|
|
|
}
|
|
|
|
|
2006-08-25 22:46:29 +02:00
|
|
|
function onTabClick(event) {
|
2007-06-08 22:33:24 +02:00
|
|
|
var node = getTarget(event); // LI element
|
2006-08-25 22:46:29 +02:00
|
|
|
|
|
|
|
var target = node.getAttribute("target");
|
2006-10-27 00:00:54 +02:00
|
|
|
|
2006-08-25 22:46:29 +02:00
|
|
|
var container = node.parentNode.parentNode;
|
|
|
|
var oldTarget = container.activeTab.getAttribute("target");
|
|
|
|
var content = $(target);
|
|
|
|
var oldContent = $(oldTarget);
|
|
|
|
|
2006-10-27 00:00:54 +02:00
|
|
|
oldContent.removeClassName("active");
|
2007-06-08 22:33:24 +02:00
|
|
|
container.activeTab.removeClassName("active"); // previous LI
|
2006-08-25 22:46:29 +02:00
|
|
|
container.activeTab = node;
|
2007-06-08 22:33:24 +02:00
|
|
|
container.activeTab.addClassName("active"); // current LI
|
2006-10-27 00:00:54 +02:00
|
|
|
content.addClassName("active");
|
2007-06-08 22:33:24 +02:00
|
|
|
|
|
|
|
// 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();
|
2006-08-25 22:46:29 +02:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-10-23 23:37:22 +02:00
|
|
|
function enableAnchor(anchor) {
|
|
|
|
var classStr = '' + anchor.getAttribute("class");
|
|
|
|
var position = classStr.indexOf("_disabled", 0);
|
|
|
|
if (position > -1) {
|
|
|
|
var disabledHref = anchor.getAttribute("disabled-href");
|
|
|
|
if (disabledHref)
|
|
|
|
anchor.setAttribute("href", disabledHref);
|
|
|
|
var disabledOnclick = anchor.getAttribute("disabled-onclick");
|
|
|
|
if (disabledOnclick)
|
|
|
|
anchor.setAttribute("onclick", disabledOnclick);
|
|
|
|
anchor.removeClassName("_disabled");
|
|
|
|
anchor.setAttribute("disabled-href", null);
|
|
|
|
anchor.setAttribute("disabled-onclick", null);
|
|
|
|
anchor.disabled = 0;
|
|
|
|
anchor.enabled = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function disableAnchor(anchor) {
|
|
|
|
var classStr = '' + anchor.getAttribute("class");
|
|
|
|
var position = classStr.indexOf("_disabled", 0);
|
|
|
|
if (position < 0) {
|
|
|
|
var href = anchor.getAttribute("href");
|
|
|
|
if (href)
|
|
|
|
anchor.setAttribute("disabled-href", href);
|
|
|
|
var onclick = anchor.getAttribute("onclick");
|
|
|
|
if (onclick)
|
|
|
|
anchor.setAttribute("disabled-onclick", onclick);
|
|
|
|
anchor.addClassName("_disabled");
|
2006-10-27 00:00:54 +02:00
|
|
|
anchor.setAttribute("href", "#");
|
|
|
|
anchor.setAttribute("onclick", "return false;");
|
2006-10-23 23:37:22 +02:00
|
|
|
anchor.disabled = 1;
|
|
|
|
anchor.enabled = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-10-17 00:34:11 +02:00
|
|
|
function d2h(d) {
|
|
|
|
var hD = "0123456789abcdef";
|
2007-01-30 22:41:24 +01:00
|
|
|
var h = hD.substr(d & 15, 1);
|
|
|
|
|
|
|
|
while (d > 15) {
|
|
|
|
d >>= 4;
|
|
|
|
h = hD.substr(d & 15, 1) + h;
|
2006-10-17 00:34:11 +02:00
|
|
|
}
|
2007-01-30 22:41:24 +01:00
|
|
|
|
2006-10-17 00:34:11 +02:00
|
|
|
return h;
|
|
|
|
}
|
|
|
|
|
|
|
|
function indexColor(number) {
|
2006-12-20 17:45:52 +01:00
|
|
|
var color;
|
2006-10-17 00:34:11 +02:00
|
|
|
|
2006-12-20 17:45:52 +01:00
|
|
|
if (number == 0)
|
|
|
|
color = "#ccf";
|
|
|
|
else {
|
|
|
|
var colorTable = new Array(1, 1, 1);
|
|
|
|
|
|
|
|
var currentValue = number;
|
|
|
|
var index = 0;
|
2007-04-28 00:06:58 +02:00
|
|
|
while (currentValue) {
|
2007-10-18 19:18:53 +02:00
|
|
|
if (currentValue & 1)
|
|
|
|
colorTable[index]++;
|
|
|
|
if (index == 3)
|
|
|
|
index = 0;
|
|
|
|
currentValue >>= 1;
|
|
|
|
index++;
|
2007-04-28 00:06:58 +02:00
|
|
|
}
|
2006-12-20 17:45:52 +01:00
|
|
|
|
|
|
|
color = ("#"
|
|
|
|
+ d2h((256 / colorTable[2]) - 1)
|
|
|
|
+ d2h((256 / colorTable[1]) - 1)
|
|
|
|
+ d2h((256 / colorTable[0]) - 1));
|
|
|
|
}
|
2006-10-17 00:34:11 +02:00
|
|
|
|
2006-12-20 17:45:52 +01:00
|
|
|
return color;
|
2006-10-17 00:34:11 +02:00
|
|
|
}
|
2006-11-09 00:48:11 +01:00
|
|
|
|
2007-06-27 23:20:15 +02:00
|
|
|
function loadPreferences() {
|
2007-10-18 19:18:53 +02:00
|
|
|
var url = UserFolderURL + "jsonDefaults";
|
|
|
|
var http = createHTTPClient();
|
|
|
|
http.open("GET", url, false);
|
|
|
|
http.send("");
|
2007-11-01 16:04:45 +01:00
|
|
|
if (http.status == 200) {
|
|
|
|
if (http.responseText.length > 0)
|
|
|
|
userDefaults = http.responseText.evalJSON(true);
|
|
|
|
else
|
|
|
|
userDefaults = {};
|
|
|
|
}
|
2007-06-27 23:20:15 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
url = UserFolderURL + "jsonSettings";
|
|
|
|
http.open("GET", url, false);
|
|
|
|
http.send("");
|
2007-11-01 16:04:45 +01:00
|
|
|
if (http.status == 200) {
|
|
|
|
if (http.responseText.length > 0)
|
|
|
|
userSettings = http.responseText.evalJSON(true);
|
|
|
|
else
|
|
|
|
userSettings = {};
|
|
|
|
}
|
2007-06-27 23:20:15 +02:00
|
|
|
}
|
|
|
|
|
2007-05-28 15:18:31 +02:00
|
|
|
function onLoadHandler(event) {
|
2007-09-08 00:26:42 +02:00
|
|
|
if (typeof UserLogin != "undefined")
|
|
|
|
loadPreferences();
|
|
|
|
queryParameters = parseQueryParameters('' + window.location);
|
|
|
|
if (!$(document.body).hasClassName("popup")) {
|
|
|
|
initLogConsole();
|
|
|
|
}
|
|
|
|
initCriteria();
|
|
|
|
configureSearchField();
|
|
|
|
initMenus();
|
|
|
|
initTabs();
|
|
|
|
configureDragHandles();
|
|
|
|
configureLinkBanner();
|
|
|
|
var progressImage = $("progressIndicator");
|
|
|
|
if (progressImage)
|
|
|
|
progressImage.parentNode.removeChild(progressImage);
|
|
|
|
Event.observe(document.body, "contextmenu", onBodyClickContextMenu);
|
2007-05-28 15:18:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function onBodyClickContextMenu(event) {
|
2007-10-18 19:18:53 +02:00
|
|
|
preventDefault(event);
|
2006-11-09 00:48:11 +01:00
|
|
|
}
|
|
|
|
|
2007-09-24 23:26:23 +02:00
|
|
|
function configureSortableTableHeaders(table) {
|
2007-10-18 19:18:53 +02:00
|
|
|
var headers = $(table).getElementsByClassName("sortableTableHeader");
|
|
|
|
for (var i = 0; i < headers.length; i++) {
|
|
|
|
var header = headers[i];
|
|
|
|
Event.observe(header, "click", onHeaderClick.bindAsEventListener(header))
|
|
|
|
}
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|
|
|
|
|
2006-11-15 23:52:41 +01:00
|
|
|
function onLinkBannerClick() {
|
|
|
|
activeAjaxRequests++;
|
|
|
|
checkAjaxRequestsState();
|
|
|
|
}
|
|
|
|
|
2007-06-19 19:59:59 +02:00
|
|
|
function onPreferencesClick(event) {
|
2007-10-18 19:18:53 +02:00
|
|
|
var urlstr = UserFolderURL + "preferences";
|
|
|
|
var w = window.open(urlstr, "_blank",
|
|
|
|
"width=430,height=250,resizable=0,scrollbars=0,location=0");
|
|
|
|
w.opener = window;
|
|
|
|
w.focus();
|
2007-06-19 19:59:59 +02:00
|
|
|
|
2007-10-18 19:18:53 +02:00
|
|
|
preventDefault(event);
|
2007-06-19 19:59:59 +02:00
|
|
|
}
|
|
|
|
|
2006-11-15 23:52:41 +01:00
|
|
|
function configureLinkBanner() {
|
|
|
|
var linkBanner = $("linkBanner");
|
|
|
|
if (linkBanner) {
|
|
|
|
var anchors = linkBanner.childNodesWithTag("a");
|
2007-09-04 17:41:25 +02:00
|
|
|
for (var i = 1; i < 3; i++) {
|
2007-10-18 19:18:53 +02:00
|
|
|
Event.observe(anchors[i], "mousedown", listRowMouseDownHandler);
|
|
|
|
Event.observe(anchors[i], "click", onLinkBannerClick);
|
2006-11-15 23:52:41 +01:00
|
|
|
}
|
2007-09-04 17:41:25 +02:00
|
|
|
Event.observe(anchors[4], "mousedown", listRowMouseDownHandler);
|
|
|
|
Event.observe(anchors[4], "click", onPreferencesClick);
|
|
|
|
if (anchors.length > 5)
|
2007-10-18 19:18:53 +02:00
|
|
|
Event.observe(anchors[5], "click", toggleLogConsole);
|
2006-11-15 23:52:41 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-15 00:01:02 +02:00
|
|
|
/* folder creation */
|
|
|
|
function createFolder(name, okCB, notOkCB) {
|
|
|
|
if (name) {
|
|
|
|
if (document.newFolderAjaxRequest) {
|
|
|
|
document.newFolderAjaxRequest.aborted = true;
|
|
|
|
document.newFolderAjaxRequest.abort();
|
|
|
|
}
|
|
|
|
var url = ApplicationBaseURL + "/createFolder?name=" + name;
|
|
|
|
document.newFolderAjaxRequest
|
2007-10-18 19:18:53 +02:00
|
|
|
= triggerAjaxRequest(url, createFolderCallback,
|
|
|
|
{name: name,
|
|
|
|
okCB: okCB,
|
|
|
|
notOkCB: notOkCB});
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function createFolderCallback(http) {
|
|
|
|
if (http.readyState == 4) {
|
|
|
|
var data = http.callbackData;
|
|
|
|
if (http.status == 201) {
|
|
|
|
if (data.okCB)
|
2007-10-23 16:39:29 +02:00
|
|
|
data.okCB(data.name, "/" + http.responseText, UserLogin);
|
2007-09-15 00:01:02 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
if (data.notOkCB)
|
|
|
|
data.notOkCB(name);
|
|
|
|
else
|
|
|
|
log("ajax problem:" + http.status);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-05-28 23:29:07 +02:00
|
|
|
addEvent(window, 'load', onLoadHandler);
|
2006-11-09 00:48:11 +01:00
|
|
|
|
2007-06-28 22:34:35 +02:00
|
|
|
function parent$(element) {
|
2007-10-18 19:18:53 +02:00
|
|
|
return this.opener.document.getElementById(element);
|
2007-06-28 22:34:35 +02:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
/* stubs */
|
2007-06-28 22:34:35 +02:00
|
|
|
function refreshCurrentFolder() {
|
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function configureDragHandles() {
|
|
|
|
}
|
|
|
|
|
2007-05-28 21:19:17 +02:00
|
|
|
function getMenus() {
|
2006-12-14 22:20:13 +01:00
|
|
|
}
|
|
|
|
|
2006-11-09 23:55:04 +01:00
|
|
|
function onHeaderClick(event) {
|
2007-10-18 19:18:53 +02:00
|
|
|
window.alert("generic headerClick");
|
2006-11-09 23:55:04 +01:00
|
|
|
}
|