diff --git a/UI/WebServerResources/HTMLElement.js b/UI/WebServerResources/HTMLElement.js
index b4616bde6..13ac40c55 100644
--- a/UI/WebServerResources/HTMLElement.js
+++ b/UI/WebServerResources/HTMLElement.js
@@ -1,297 +1,296 @@
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* custom extensions to the DOM api */
-Element.addMethods(
-{
- addInterface: function(element, objectInterface) {
- element = $(element);
- Object.extend(element, objectInterface);
- if (element.bind)
- element.bind();
- },
+Element.addMethods({
+ addInterface: function(element, objectInterface) {
+ element = $(element);
+ Object.extend(element, objectInterface);
+ if (element.bind)
+ element.bind();
+ },
- childNodesWithTag: function(element, tagName) {
- element = $(element);
+ childNodesWithTag: function(element, tagName) {
+ element = $(element);
- var matchingNodes = new Array();
- var tagName = tagName.toUpperCase();
+ var matchingNodes = new Array();
+ var 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);
- }
+ 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;
- },
+ return matchingNodes;
+ },
- getParentWithTagName: function(element, tagName) {
- element = $(element);
- var currentElement = element;
- tagName = tagName.toUpperCase();
+ getParentWithTagName: function(element, tagName) {
+ element = $(element);
+ var currentElement = element;
+ tagName = tagName.toUpperCase();
- currentElement = currentElement.parentNode;
- while (currentElement
- && currentElement.tagName != tagName) {
- currentElement = currentElement.parentNode;
- }
+ currentElement = currentElement.parentNode;
+ while (currentElement
+ && currentElement.tagName != tagName) {
+ currentElement = currentElement.parentNode;
+ }
- return currentElement;
- },
+ return currentElement;
+ },
- cascadeLeftOffset: function(element) {
- element = $(element);
- var currentElement = element;
+ cascadeLeftOffset: function(element) {
+ element = $(element);
+ var currentElement = element;
- var offset = 0;
- while (currentElement) {
- offset += currentElement.offsetLeft;
- currentElement = $(currentElement).getParentWithTagName("div");
- }
+ var offset = 0;
+ while (currentElement) {
+ offset += currentElement.offsetLeft;
+ currentElement = $(currentElement).getParentWithTagName("div");
+ }
- return offset;
- },
+ return offset;
+ },
- cascadeTopOffset: function(element) {
- element = $(element);
- var currentElement = element;
- var offset = 0;
+ cascadeTopOffset: function(element) {
+ element = $(element);
+ var currentElement = element;
+ var offset = 0;
- var i = 0;
+ var i = 0;
- while (currentElement && currentElement.tagName) {
- offset += currentElement.offsetTop;
- currentElement = currentElement.parentNode;
- i++;
- }
+ while (currentElement && currentElement.tagName) {
+ offset += currentElement.offsetTop;
+ currentElement = currentElement.parentNode;
+ i++;
+ }
- return offset;
- },
+ return offset;
+ },
- dump: function(element, additionalInfo, additionalKeys) {
- element = $(element);
- var id = element.getAttribute("id");
- var nclass = element.getAttribute("class");
+ 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;
+ var str = element.tagName;
+ if (id)
+ str += "; id = " + id;
+ if (nclass)
+ str += "; class = " + nclass;
- if (additionalInfo)
- str += "; " + additionalInfo;
+ if (additionalInfo)
+ str += "; " + additionalInfo;
- if (additionalKeys)
- for (var i = 0; i < additionalKeys.length; i++) {
- var value = element.getAttribute(additionalKeys[i]);
- if (value)
- str += "; " + additionalKeys[i] + " = " + value;
- }
+ if (additionalKeys)
+ for (var i = 0; i < additionalKeys.length; i++) {
+ var value = element.getAttribute(additionalKeys[i]);
+ if (value)
+ str += "; " + additionalKeys[i] + " = " + value;
+ }
- log (str);
- },
+ log (str);
+ },
- getSelectedNodes: function(element) {
- element = $(element);
+ getSelectedNodes: function(element) {
+ element = $(element);
- if (!element.selectedElements)
- element.selectedElements = new Array();
+ if (!element.selectedElements)
+ element.selectedElements = new Array();
- return element.selectedElements;
- },
+ return element.selectedElements;
+ },
- getSelectedNodesId: function(element) {
- element = $(element);
+ getSelectedNodesId: function(element) {
+ element = $(element);
- var selArray = new Array();
- if (element.selectedElements) {
- for (var i = 0; i < element.selectedElements.length; i++) {
- var node = element.selectedElements[i];
- selArray.push(node.getAttribute("id"));
- }
- }
- else
- element.selectedElements = new Array();
+ var selArray = new Array();
+ if (element.selectedElements) {
+ for (var i = 0; i < element.selectedElements.length; i++) {
+ var node = element.selectedElements[i];
+ selArray.push(node.getAttribute("id"));
+ }
+ }
+ else
+ element.selectedElements = new Array();
- return selArray;
- },
+ return selArray;
+ },
- onContextMenu: function(element, event) {
- element = $(element);
-
- if (document.currentPopupMenu)
- hideMenu(document.currentPopupMenu);
+ onContextMenu: function(element, event) {
+ element = $(element);
+ Event.stop(event);
+ 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 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 leftDiff = (window.width()
+ - (menuLeft + popup.offsetWidth));
+ if (leftDiff < 0)
+ menuLeft -= popup.offsetWidth;
- var isVisible = true;
- if (popup.prepareVisibility)
- isVisible = popup.prepareVisibility();
+ var isVisible = true;
+ if (popup.prepareVisibility)
+ isVisible = popup.prepareVisibility();
- if (isVisible) {
- popup.setStyle( { top: menuTop + "px",
- left: menuLeft + "px",
- visibility: "visible" } );
+ if (isVisible) {
+ popup.setStyle( { top: menuTop + "px",
+ left: menuLeft + "px",
+ visibility: "visible" } );
- document.currentPopupMenu = popup;
- document.body.observe("click", onBodyClickMenuHandler);
- }
- else
- log ("Warning: not showing the contextual menu " + element.id);
- },
+ document.currentPopupMenu = popup;
+ document.body.observe("click", onBodyClickMenuHandler);
+ }
+ else
+ log ("Warning: not showing the contextual menu " + element.id);
+ },
- attachMenu: function(element, menuName) {
- element = $(element);
- element.sogoContextMenu = $(menuName);
- element.observe("contextmenu",
- element.onContextMenu.bindAsEventListener(element));
- },
+ attachMenu: function(element, menuName) {
+ element = $(element);
+ element.sogoContextMenu = $(menuName);
+ element.observe("contextmenu",
+ element.onContextMenu.bindAsEventListener(element));
+ },
- selectElement: function(element) {
- element = $(element);
- element.addClassName('_selected');
+ selectElement: function(element) {
+ element = $(element);
+ element.addClassName('_selected');
- var parent = element.up();
- if (!parent.selectedElements)
- // Selected nodes are kept in a array at the
- // container level.
- parent.selectedElements = new Array();
- for (var i = 0; i < parent.selectedElements.length; i++)
- if (parent.selectedElements[i] == element) return;
- parent.selectedElements.push(element); // use index instead ?
- },
+ var parent = element.up();
+ if (!parent.selectedElements)
+ // Selected nodes are kept in a array at the
+ // container level.
+ parent.selectedElements = new Array();
+ for (var i = 0; i < parent.selectedElements.length; i++)
+ if (parent.selectedElements[i] == element) return;
+ parent.selectedElements.push(element); // use index instead ?
+ },
- selectRange: function(element, startIndex, endIndex) {
- element = $(element);
- var s;
- var e;
- var rows;
+ 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++;
- }
- },
+ 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++;
+ }
+ },
- deselect: function(element) {
- element = $(element);
- element.removeClassName('_selected');
+ deselect: function(element) {
+ element = $(element);
+ element.removeClassName('_selected');
- var parent = element.up();
- if (parent && parent.selectedElements)
- parent.selectedElements = parent.selectedElements.without(element);
- },
+ var parent = element.up();
+ if (parent && parent.selectedElements)
+ parent.selectedElements = parent.selectedElements.without(element);
+ },
- deselectAll: function(element) {
- element = $(element);
- if (element.selectedElements) {
- for (var i = 0; i < element.selectedElements.length; i++)
- element.selectedElements[i].removeClassName('_selected');
- element.selectedElements = null;
- }
- },
+ deselectAll: function(element) {
+ element = $(element);
+ if (element.selectedElements) {
+ for (var i = 0; i < element.selectedElements.length; i++)
+ element.selectedElements[i].removeClassName('_selected');
+ element.selectedElements = null;
+ }
+ },
- 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();
- }
- },
+ 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();
- }
- },
+ 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;
- },
+ 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;
+ 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++;
- });
- },
+ 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;
+ 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);
+ Form.getInputs(element, 'checkbox', checkboxName).each(function(input) {
+ if (input.checked)
+ values.push(i+1);
- i++;
- });
- return values.join(",");
- },
+ i++;
+ });
+ return values.join(",");
+ },
- setCheckBoxListValues: function(element, checkboxName, values) {
- element = $(element);
- var v = values.split(',');
- var i = 1;
+ setCheckBoxListValues: function(element, checkboxName, values) {
+ element = $(element);
+ var v = values.split(',');
+ var i = 1;
- Form.getInputs(element, 'checkbox', checkboxName).each(function(input) {
+ Form.getInputs(element, 'checkbox', checkboxName).each(function(input) {
- if ($(v).indexOf(i+"") != -1)
- input.checked = 1;
- i++;
- });
- }
- });
+ if ($(v).indexOf(i+"") != -1)
+ input.checked = 1;
+ i++;
+ });
+ }
+ });
diff --git a/UI/WebServerResources/generic.js b/UI/WebServerResources/generic.js
index 47356ba2f..a938130c9 100644
--- a/UI/WebServerResources/generic.js
+++ b/UI/WebServerResources/generic.js
@@ -2,24 +2,24 @@
/*
- Copyright (C) 2005 SKYRIX Software AG
+ Copyright (C) 2005 SKYRIX Software AG
- This file is part of OpenGroupware.org.
+ 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 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.
+ 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.
+ 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 */
@@ -49,1633 +49,1633 @@ var removeFolderRequestCount = 0;
/* a W3C compliant document.all */
function getAllScopeElements(scope) {
- var elements = new Array();
+ 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);
- }
+ 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;
+ return elements;
}
function getAllElements(scope) {
- var elements;
+ var elements;
- if (scope == null)
- scope = document;
+ if (scope == null)
+ scope = document;
- if (scope == document
- && allDocumentElements != null)
- elements = allDocumentElements;
- else
- {
- elements = getAllScopeElements(scope);
- if (scope == document)
- allDocumentElements = elements;
- }
+ if (scope == document
+ && allDocumentElements != null)
+ elements = allDocumentElements;
+ else
+ {
+ elements = getAllScopeElements(scope);
+ if (scope == document)
+ allDocumentElements = elements;
+ }
- return elements;
+ return elements;
}
function createElement(tagName, id, classes,
- attributes, htmlAttributes,
- parentNode) {
- 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);
+ attributes, htmlAttributes,
+ parentNode) {
+ 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);
- return $(newElement);
+ return $(newElement);
}
function ml_stripActionInURL(url) {
- if (url[url.length - 1] != '/') {
- var i;
+ 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;
+ i = url.lastIndexOf("/");
+ if (i != -1) url = url.substring(0, i);
+ }
+ if (url[url.length - 1] != '/') // ensure trailing slash
+ url = url + "/";
+ return url;
}
function URLForFolderID(folderID) {
- var folderInfos = folderID.split(":");
- var url;
- if (folderInfos.length > 1) {
- url = UserFolderURL + "../" + encodeURI(folderInfos[0]);
- if (!(folderInfos[0].endsWith('/')
- || folderInfos[1].startsWith('/')))
- url += '/';
- url += folderInfos[1];
- }
- else
- url = ApplicationBaseURL + encodeURI(folderInfos[0]);
+ var folderInfos = folderID.split(":");
+ var url;
+ if (folderInfos.length > 1) {
+ url = UserFolderURL + "../" + encodeURI(folderInfos[0]);
+ if (!(folderInfos[0].endsWith('/')
+ || folderInfos[1].startsWith('/')))
+ url += '/';
+ url += folderInfos[1];
+ }
+ else
+ url = ApplicationBaseURL + encodeURI(folderInfos[0]);
- if (url[url.length-1] == '/')
- url = url.substr(0, url.length-1);
+ if (url[url.length-1] == '/')
+ url = url.substr(0, url.length-1);
- return url;
+ return url;
}
function extractEmailAddress(mailTo) {
- var email = "";
+ var email = "";
- var emailre
- = /(([a-zA-Z0-9\._-]+)*[a-zA-Z0-9_-]+@([a-zA-Z0-9\._-]+)*[a-zA-Z0-9_-]+)/;
- if (emailre.test(mailTo)) {
- emailre.exec(mailTo);
- email = RegExp.$1;
- }
+ var emailre
+ = /(([a-zA-Z0-9\._-]+)*[a-zA-Z0-9_-]+@([a-zA-Z0-9\._-]+)*[a-zA-Z0-9_-]+)/;
+ if (emailre.test(mailTo)) {
+ emailre.exec(mailTo);
+ email = RegExp.$1;
+ }
- return email;
+ return email;
}
function extractEmailName(mailTo) {
- var emailName = "";
+ var emailName = "";
- var tmpMailTo = mailTo.replace("<", "<");
- tmpMailTo = tmpMailTo.replace(">", ">");
+ var tmpMailTo = mailTo.replace("<", "<");
+ tmpMailTo = tmpMailTo.replace(">", ">");
- var emailNamere = /([ ]+)?(.+)\ ;
- if (emailNamere.test(tmpMailTo)) {
- emailNamere.exec(tmpMailTo);
- emailName = RegExp.$2;
- }
+ var emailNamere = /([ ]+)?(.+)\ ;
+ if (emailNamere.test(tmpMailTo)) {
+ emailNamere.exec(tmpMailTo);
+ emailName = RegExp.$2;
+ }
- return emailName;
+ return emailName;
}
function extractSubject(mailTo) {
- var subject = "";
+ var subject = "";
- var subjectre = /\?subject=([^&]+)/;
- if (subjectre.test(mailTo)) {
- subjectre.exec(mailTo);
- subject = RegExp.$1;
- }
+ var subjectre = /\?subject=([^&]+)/;
+ if (subjectre.test(mailTo)) {
+ subjectre.exec(mailTo);
+ subject = RegExp.$1;
+ }
- return subject;
+ return subject;
}
function sanitizeMailTo(dirtyMailTo) {
- var emailName = extractEmailName(dirtyMailTo);
- var email = extractEmailAddress(dirtyMailTo);
+ var emailName = extractEmailName(dirtyMailTo);
+ var email = extractEmailAddress(dirtyMailTo);
- var mailto = "";
- if (emailName && emailName.length > 0)
- mailto = emailName + ' <' + email + '>';
- else
- mailto = email;
+ var mailto = "";
+ if (emailName && emailName.length > 0)
+ mailto = emailName + ' <' + email + '>';
+ else
+ mailto = email;
- return mailto;
+ return mailto;
}
function sanitizeWindowName(dirtyWindowName) {
- // IE is picky about the characters used for the window name.
- return dirtyWindowName.replace(/[\s\.\/\-\@]/g, "_");
+ // IE is picky about the characters used for the window name.
+ return dirtyWindowName.replace(/[\s\.\/\-\@]/g, "_");
}
function openUserFolderSelector(callback, type) {
- 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();
+ 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();
}
function openContactWindow(url, wId) {
- if (!wId)
- wId = "_blank";
- else {
- wId = sanitizeWindowName(wId);
- }
+ if (!wId)
+ wId = "_blank";
+ else {
+ wId = sanitizeWindowName(wId);
+ }
- var w = window.open(url, wId,
- "width=450,height=600,resizable=0,location=0");
- w.focus();
+ var w = window.open(url, wId,
+ "width=450,height=600,resizable=0,location=0");
+ w.focus();
- return w;
+ return w;
}
function openMailComposeWindow(url, wId) {
- var parentWindow = this;
+ var parentWindow = this;
- if (!wId)
- wId = "_blank";
- else {
- wId = sanitizeWindowName(wId);
- }
+ if (!wId)
+ wId = "_blank";
+ else {
+ wId = sanitizeWindowName(wId);
+ }
- if (document.body.hasClassName("popup"))
- parentWindow = window.opener;
+ if (document.body.hasClassName("popup"))
+ parentWindow = window.opener;
- var w = parentWindow.open(url, wId,
- "width=680,height=520,resizable=1,scrollbars=1,toolbar=0,"
- + "location=0,directories=0,status=0,menubar=0"
- + ",copyhistory=0");
+ var w = parentWindow.open(url, wId,
+ "width=680,height=520,resizable=1,scrollbars=1,toolbar=0,"
+ + "location=0,directories=0,status=0,menubar=0"
+ + ",copyhistory=0");
- w.focus();
+ w.focus();
- return w;
+ return w;
}
function openMailTo(senderMailTo) {
- var addresses = senderMailTo.split(",");
- var sanitizedAddresses = new Array();
- var subject = extractSubject(senderMailTo);
- for (var i = 0; i < addresses.length; i++) {
- var sanitizedAddress = sanitizeMailTo(addresses[i]);
- if (sanitizedAddress.length > 0)
- sanitizedAddresses.push(sanitizedAddress);
- }
+ var addresses = senderMailTo.split(",");
+ var sanitizedAddresses = new Array();
+ var subject = extractSubject(senderMailTo);
+ for (var i = 0; i < addresses.length; i++) {
+ var sanitizedAddress = sanitizeMailTo(addresses[i]);
+ if (sanitizedAddress.length > 0)
+ sanitizedAddresses.push(sanitizedAddress);
+ }
- var mailto = sanitizedAddresses.join(",");
+ var mailto = sanitizedAddresses.join(",");
- if (mailto.length > 0)
- openMailComposeWindow(ApplicationBaseURL
- + "../Mail/compose?mailto=" + encodeURI(mailto)
- + ((subject.length > 0)?"?subject=" + encodeURI(subject):""));
+ if (mailto.length > 0)
+ openMailComposeWindow(ApplicationBaseURL
+ + "../Mail/compose?mailto=" + encodeURI(mailto)
+ + ((subject.length > 0)?"?subject=" + encodeURI(subject):""));
- return false; /* stop following the link */
+ return false; /* stop following the link */
}
function deleteDraft(url) {
- /* this is called by UIxMailEditor with window.opener */
- new Ajax.Request(url, {
- asynchronous: false,
- method: 'post',
- onFailure: function(transport) {
- log("draftDeleteCallback: problem during ajax request: " + transport.status);
- }
- });
+ /* this is called by UIxMailEditor with window.opener */
+ new Ajax.Request(url, {
+ asynchronous: false,
+ method: 'post',
+ onFailure: function(transport) {
+ log("draftDeleteCallback: problem during ajax request: " + transport.status);
+ }
+ });
}
function refreshFolderByType(type) {
- /* this is called by UIxMailEditor with window.opener */
- if (Mailer && Mailer.currentMailboxType == type)
- refreshCurrentFolder();
+ /* this is called by UIxMailEditor with window.opener */
+ if (Mailer && Mailer.currentMailboxType == type)
+ refreshCurrentFolder();
}
function createHTTPClient() {
- // http://developer.apple.com/internet/webcontent/xmlhttpreq.html
- if (typeof XMLHttpRequest != "undefined")
- return new XMLHttpRequest();
+ // http://developer.apple.com/internet/webcontent/xmlhttpreq.html
+ if (typeof XMLHttpRequest != "undefined")
+ return new XMLHttpRequest();
- try { return new ActiveXObject("Msxml2.XMLHTTP"); }
- catch (e) { }
- try { return new ActiveXObject("Microsoft.XMLHTTP"); }
- catch (e) { }
+ try { return new ActiveXObject("Msxml2.XMLHTTP"); }
+ catch (e) { }
+ try { return new ActiveXObject("Microsoft.XMLHTTP"); }
+ catch (e) { }
- return null;
+ return null;
}
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);
+ 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;
+ return url_nocache;
}
function onAjaxRequestStateChange(http) {
- try {
- if (http.readyState == 4
- && activeAjaxRequests > 0) {
- if (!http.aborted)
- http.callback(http);
- activeAjaxRequests--;
- checkAjaxRequestsState();
- http.onreadystatechange = Prototype.emptyFunction;
- http.callback = Prototype.emptyFunction;
- http.callbackData = null;
- }
- }
- catch(e) {
- activeAjaxRequests--;
- checkAjaxRequestsState();
- http.onreadystatechange = Prototype.emptyFunction;
- http.callback = Prototype.emptyFunction;
- http.callbackData = null;
- log("AJAX Request, Caught Exception: " + e.name);
- log(e.message);
- if (e.fileName) {
- if (e.lineNumber)
- log("at " + e.fileName + ": " + e.lineNumber);
- else
- log("in " + e.fileName);
- }
- log(backtrace());
- log("request url was '" + http.url + "'");
- }
+ try {
+ if (http.readyState == 4
+ && activeAjaxRequests > 0) {
+ if (!http.aborted)
+ http.callback(http);
+ activeAjaxRequests--;
+ checkAjaxRequestsState();
+ http.onreadystatechange = Prototype.emptyFunction;
+ http.callback = Prototype.emptyFunction;
+ http.callbackData = null;
+ }
+ }
+ catch(e) {
+ activeAjaxRequests--;
+ checkAjaxRequestsState();
+ http.onreadystatechange = Prototype.emptyFunction;
+ http.callback = Prototype.emptyFunction;
+ http.callbackData = null;
+ log("AJAX Request, Caught Exception: " + e.name);
+ log(e.message);
+ if (e.fileName) {
+ if (e.lineNumber)
+ log("at " + e.fileName + ": " + e.lineNumber);
+ else
+ log("in " + e.fileName);
+ }
+ log(backtrace());
+ log("request url was '" + http.url + "'");
+ }
}
/* taken from Lightning */
function getContrastingTextColor(bgColor) {
- var calcColor = bgColor.substring(1);
- var red = parseInt(calcColor.substring(0, 2), 16);
- var green = parseInt(calcColor.substring(2, 4), 16);
- var blue = parseInt(calcColor.substring(4, 6), 16);
+ var calcColor = bgColor.substring(1);
+ var red = parseInt(calcColor.substring(0, 2), 16);
+ var green = parseInt(calcColor.substring(2, 4), 16);
+ var blue = parseInt(calcColor.substring(4, 6), 16);
- // Calculate the brightness (Y) value using the YUV color system.
- var brightness = (0.299 * red) + (0.587 * green) + (0.114 * blue);
+ // Calculate the brightness (Y) value using the YUV color system.
+ var brightness = (0.299 * red) + (0.587 * green) + (0.114 * blue);
- // Consider all colors with less than 56% brightness as dark colors and
- // use white as the foreground color, otherwise use black.
- return ((brightness < 144) ? "white" : "black");
+ // Consider all colors with less than 56% brightness as dark colors and
+ // use white as the foreground color, otherwise use black.
+ return ((brightness < 144) ? "white" : "black");
}
function triggerAjaxRequest(url, callback, userdata, content, headers) {
- //url = appendDifferentiator(url);
+ //url = appendDifferentiator(url);
- var http = createHTTPClient();
- if (http) {
- activeAjaxRequests++;
- document.animTimer = setTimeout("checkAjaxRequestsState();", 250);
+ var http = createHTTPClient();
+ if (http) {
+ activeAjaxRequests++;
+ document.animTimer = setTimeout("checkAjaxRequestsState();", 250);
- http.open("POST", url, true);
- http.url = url;
- http.callback = callback;
- http.callbackData = userdata;
- http.onreadystatechange = function() { onAjaxRequestStateChange(http) };
- // = function() {
- // // log ("state changed (" + http.readyState + "): " + url);
- // };
- var hasContentLength = false;
- if (headers) {
- for (var i in headers) {
- if (i.toLowerCase() == "content-length")
- hasContentLength = true;
- http.setRequestHeader(i, headers[i]);
- }
- } /*
- if (!hasContentLength) {
- var cLength = "0";
- if (content)
- cLength = "" + content.length;
- http.setRequestHeader("Content-Length", "" + cLength);
- } */
- http.send(content ? content : "");
- }
- else {
- log("triggerAjaxRequest: error creating HTTP Client!");
- }
+ http.open("POST", url, true);
+ http.url = url;
+ http.callback = callback;
+ http.callbackData = userdata;
+ http.onreadystatechange = function() { onAjaxRequestStateChange(http) };
+ // = function() {
+ // // log ("state changed (" + http.readyState + "): " + url);
+ // };
+ var hasContentLength = false;
+ if (headers) {
+ for (var i in headers) {
+ if (i.toLowerCase() == "content-length")
+ hasContentLength = true;
+ http.setRequestHeader(i, headers[i]);
+ }
+ } /*
+ if (!hasContentLength) {
+ var cLength = "0";
+ if (content)
+ cLength = "" + content.length;
+ http.setRequestHeader("Content-Length", "" + cLength);
+ } */
+ http.send(content ? content : "");
+ }
+ else {
+ log("triggerAjaxRequest: error creating HTTP Client!");
+ }
- return http;
+ return http;
}
function startAnimation(parent, nextNode) {
- var anim = $("progressIndicator");
- if (!anim) {
- anim = createElement("img", "progressIndicator", null,
- {src: ResourcesURL + "/busy.gif"});
- anim.setStyle({ visibility: "hidden" });
- if (nextNode)
- parent.insertBefore(anim, nextNode);
- else
- parent.appendChild(anim);
- anim.setStyle({ visibility: "visible" });
- }
+ var anim = $("progressIndicator");
+ if (!anim) {
+ anim = createElement("img", "progressIndicator", null,
+ {src: ResourcesURL + "/busy.gif"});
+ anim.setStyle({ visibility: "hidden" });
+ if (nextNode)
+ parent.insertBefore(anim, nextNode);
+ else
+ parent.appendChild(anim);
+ anim.setStyle({ visibility: "visible" });
+ }
- return anim;
+ return anim;
}
function checkAjaxRequestsState() {
- var progressImage = $("progressIndicator");
- if (activeAjaxRequests > 0
- && !progressImage) {
- var toolbar = $("toolbar");
- if (toolbar)
- startAnimation(toolbar);
- }
- else if (!activeAjaxRequests
- && progressImage)
- progressImage.parentNode.removeChild(progressImage);
+ var progressImage = $("progressIndicator");
+ if (activeAjaxRequests > 0
+ && !progressImage) {
+ var toolbar = $("toolbar");
+ if (toolbar)
+ startAnimation(toolbar);
+ }
+ else if (!activeAjaxRequests
+ && progressImage)
+ progressImage.parentNode.removeChild(progressImage);
}
function isMac() {
- return (navigator.platform.indexOf('Mac') > -1);
+ return (navigator.platform.indexOf('Mac') > -1);
}
function isWindows() {
- return (navigator.platform.indexOf('Win') > -1);
+ return (navigator.platform.indexOf('Win') > -1);
}
function isSafari3() {
- return (navigator.appVersion.indexOf("Version") > -1);
+ return (navigator.appVersion.indexOf("Version") > -1);
}
function isSafari() {
- //var agt = navigator.userAgent.toLowerCase();
- //var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
+ //var agt = navigator.userAgent.toLowerCase();
+ //var is_safari = ((agt.indexOf('safari')!=-1)&&(agt.indexOf('mac')!=-1))?true:false;
- return (navigator.vendor == "Apple Computer, Inc.") || (navigator.userAgent.toLowerCase().indexOf('konqueror') != -1);
+ return (navigator.vendor == "Apple Computer, Inc.") || (navigator.userAgent.toLowerCase().indexOf('konqueror') != -1);
}
function isHttpStatus204(status) {
- return (status == 204 || // Firefox
- (isSafari() && typeof(status) == 'undefined') || // Safari
- status == 1223); // IE
+ return (status == 204 || // Firefox
+ (isSafari() && typeof(status) == 'undefined') || // Safari
+ status == 1223); // IE
}
function getTarget(event) {
- event = event || window.event;
- if (event.target)
- return event.target; // W3C DOM
- else
- return event.srcElement; // IE
+ event = event || window.event;
+ if (event.target)
+ return event.target; // W3C DOM
+ else
+ return event.srcElement; // IE
}
function preventDefault(event) {
- if (event)
- if (event.preventDefault)
- event.preventDefault(); // W3C DOM
- else
- event.returnValue = false; // IE
+ if (event)
+ if (event.preventDefault)
+ event.preventDefault(); // W3C DOM
+ else
+ event.returnValue = false; // IE
}
function resetSelection(win) {
- var t = "";
- if (win && win.getSelection) {
- t = win.getSelection().toString();
- win.getSelection().removeAllRanges();
- }
- return t;
+ 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();
- }
+ if (window.opener && !window.opener.closed) {
+ window.opener.location.reload();
+ }
}
/* query string */
function parseQueryString() {
- var queryArray, queryDict
- var key, value, s, idx;
- queryDict.length = 0;
+ var queryArray, queryDict
+ var key, value, s, idx;
+ 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));
- }
+ 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++;
+ if (typeof queryDict[key] == 'undefined')
+ queryDict.length++;
- queryDict[key] = value;
- }
- return queryDict;
+ 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;
+ var s = "";
+ for (var key in queryDict) {
+ if (s.length == 0)
+ s = "?";
+ else
+ s = s + "&";
+ s = s + key + "=" + escape(queryDict[key]);
+ }
+ return s;
}
/* selection mechanism */
function deselectAll(parent) {
- for (var i = 0; i < parent.childNodes.length; i++) {
- var node = parent.childNodes.item(i);
- if (node.nodeType == 1)
- $(node).deselect();
- }
+ for (var i = 0; i < parent.childNodes.length; i++) {
+ var node = parent.childNodes.item(i);
+ if (node.nodeType == 1)
+ $(node).deselect();
+ }
}
function isNodeSelected(node) {
- return $(node).hasClassName('_selected');
+ return $(node).hasClassName('_selected');
}
function acceptMultiSelect(node) {
- 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;
+ 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;
- return response;
+ return response;
}
function onRowClick(event) {
- var node = Event.element(event);
- var rowIndex = null;
+ var node = Event.element(event);
+ var rowIndex = null;
- if (node.tagName != 'TD' && node.tagName != 'LI')
- node = this;
+ if (node.tagName != 'TD' && node.tagName != 'LI')
+ node = this;
- if (node.tagName == 'TD') {
- node = node.parentNode; // select TR
- }
- if (node.tagName == '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;
- if (list) {
- var items = list.childNodesWithTag("li");
- for (var i = 0; i < items.length; i++) {
- if (items[i] == node) {
- rowIndex = i;
- break;
- }
- }
- }
- else
- // No parent; stop here
- return true;
- }
+ if (node.tagName == 'TD') {
+ node = node.parentNode; // select TR
+ }
+ if (node.tagName == '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;
+ if (list) {
+ var items = list.childNodesWithTag("li");
+ for (var i = 0; i < items.length; i++) {
+ if (items[i] == node) {
+ rowIndex = i;
+ break;
+ }
+ }
+ }
+ else
+ // No parent; stop here
+ return true;
+ }
- var initialSelection = $(node.parentNode).getSelectedNodes();
- var isLeftClick = true;
- if (isMac() && isSafari())
- if (event.ctrlKey == 1)
- isLeftClick = false; // Control-click is equivalent to right-click under Mac OS X
- else if (event.metaKey == 1) // Command-click
- isLeftClick = true;
- else
- isLeftClick = Event.isLeftClick(event);
- else
- isLeftClick = Event.isLeftClick(event);
+ var initialSelection = $(node.parentNode).getSelectedNodes();
+ var isLeftClick = true;
+ if (isMac() && isSafari())
+ if (event.ctrlKey == 1)
+ isLeftClick = false; // Control-click is equivalent to right-click under Mac OS X
+ else if (event.metaKey == 1) // Command-click
+ isLeftClick = true;
+ else
+ isLeftClick = Event.isLeftClick(event);
+ else
+ isLeftClick = Event.isLeftClick(event);
- if (initialSelection.length > 0
- && initialSelection.indexOf(node) >= 0
- && !isLeftClick)
- // Ignore non primary-click (ie right-click) inside current selection
- return true;
+ if (initialSelection.length > 0
+ && initialSelection.indexOf(node) >= 0
+ && !isLeftClick)
+ // Ignore non primary-click (ie right-click) inside current selection
+ return true;
- if ((event.shiftKey == 1 || isMac() && event.metaKey == 1 || isWindows() && event.ctrlKey == 1)
- && (lastClickedRow >= 0)
- && (acceptMultiSelect(node.parentNode)
- || acceptMultiSelect(node.parentNode.parentNode))) {
- if (event.shiftKey) {
- $(node.parentNode).selectRange(lastClickedRow, rowIndex);
- } else if (isNodeSelected(node)) {
- $(node).deselect();
- rowIndex = null;
- } else {
- $(node).selectElement();
- }
- // At this point, should empty content of 3-pane view
- } else {
- // Single line selection
- $(node.parentNode).deselectAll();
- $(node).selectElement();
+ if ((event.shiftKey == 1 || isMac() && event.metaKey == 1 || isWindows() && event.ctrlKey == 1)
+ && (lastClickedRow >= 0)
+ && (acceptMultiSelect(node.parentNode)
+ || acceptMultiSelect(node.parentNode.parentNode))) {
+ if (event.shiftKey) {
+ $(node.parentNode).selectRange(lastClickedRow, rowIndex);
+ } else if (isNodeSelected(node)) {
+ $(node).deselect();
+ rowIndex = null;
+ } else {
+ $(node).selectElement();
+ }
+ // At this point, should empty content of 3-pane view
+ } else {
+ // Single line selection
+ $(node.parentNode).deselectAll();
+ $(node).selectElement();
- if (initialSelection != $(node.parentNode).getSelectedNodes()) {
- // Selection has changed; fire mousedown event
- var parentNode = node.parentNode;
- if (parentNode.tagName == 'TBODY')
- parentNode = parentNode.parentNode;
- parentNode.fire("mousedown");
- }
- }
- if (rowIndex)
- lastClickedRow = rowIndex;
+ if (initialSelection != $(node.parentNode).getSelectedNodes()) {
+ // Selection has changed; fire mousedown event
+ var parentNode = node.parentNode;
+ if (parentNode.tagName == 'TBODY')
+ parentNode = parentNode.parentNode;
+ parentNode.fire("mousedown");
+ }
+ }
+ if (rowIndex)
+ lastClickedRow = rowIndex;
- return true;
+ return true;
}
/* popup menus */
function popupMenu(event, menuId, target) {
- document.menuTarget = target;
+ document.menuTarget = target;
- if (document.currentPopupMenu)
- hideMenu(document.currentPopupMenu);
+ if (document.currentPopupMenu)
+ hideMenu(document.currentPopupMenu);
- var popup = $(menuId);
+ var popup = $(menuId);
- var deltaX = 0;
- var deltaY = 0;
+ 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 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;
- var heightDiff = (window.height()
- - (menuTop + popup.offsetHeight));
- if (heightDiff < 0)
- menuTop += heightDiff;
+ var menuTop = Event.pointerY(event) + deltaY;
+ var menuLeft = Event.pointerX(event) + deltaX;
+ 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 leftDiff = (window.width()
+ - (menuLeft + popup.offsetWidth));
+ if (leftDiff < 0)
+ menuLeft -= popup.offsetWidth;
- var isVisible = true;
- if (popup.prepareVisibility)
- if (!popup.prepareVisibility())
- isVisible = false;
+ var isVisible = true;
+ if (popup.prepareVisibility)
+ if (!popup.prepareVisibility())
+ isVisible = false;
- if (isVisible) {
- popup.setStyle({ top: menuTop + "px",
- left: menuLeft + "px",
- visibility: "visible" });
+ Event.stop(event);
+ if (isVisible) {
+ popup.setStyle({ top: menuTop + "px",
+ left: menuLeft + "px",
+ visibility: "visible" });
- document.currentPopupMenu = popup;
+ document.currentPopupMenu = popup;
- $(document.body).observe("click", onBodyClickMenuHandler);
- }
+ $(document.body).observe("click", onBodyClickMenuHandler);
+ }
- Event.stop(event);
}
function getParentMenu(node) {
- var currentNode, menuNode;
+ var currentNode, menuNode;
- menuNode = null;
- currentNode = node;
- var menure = new RegExp("(^|\s+)menu(\s+|$)", "i");
+ 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;
+ while (menuNode == null
+ && currentNode)
+ if (menure.test(currentNode.className))
+ menuNode = currentNode;
+ else
+ currentNode = currentNode.parentNode;
- return menuNode;
+ return menuNode;
}
function onBodyClickMenuHandler(event) {
- hideMenu(document.currentPopupMenu);
- document.body.stopObserving("click", onBodyClickMenuHandler);
- document.body.stopObserving("mouseup", onBodyClickMenuHandler);
- document.currentPopupMenu = null;
+ hideMenu(document.currentPopupMenu);
+ document.body.stopObserving("click", onBodyClickMenuHandler);
+ document.body.stopObserving("mouseup", onBodyClickMenuHandler);
+ document.currentPopupMenu = null;
- if (event)
- preventDefault(event);
+ if (event)
+ preventDefault(event);
}
function onMenuClickHandler(event) {
- if (!this.hasClassName("disabled"))
- this.menuCallback.apply(this, [event]);
+ if (!this.hasClassName("disabled"))
+ this.menuCallback.apply(this, [event]);
}
function hideMenu(menuNode) {
- var onHide;
+ var onHide;
- if (!menuNode)
- return;
+ if (!menuNode)
+ return;
- if (menuNode.submenu) {
- hideMenu(menuNode.submenu);
- menuNode.submenu = null;
- }
+ if (menuNode.submenu) {
+ hideMenu(menuNode.submenu);
+ menuNode.submenu = null;
+ }
- menuNode.setStyle({ visibility: "hidden" });
- if (menuNode.parentMenuItem) {
- menuNode.parentMenuItem.stopObserving("mouseover",onMouseEnteredSubmenu);
- menuNode.stopObserving("mouseover", onMouseEnteredSubmenu);
- menuNode.parentMenuItem.stopObserving("mouseout", onMouseLeftSubmenu);
- menuNode.stopObserving("mouseout", onMouseLeftSubmenu);
- menuNode.parentMenu.stopObserving("mouseover", onMouseEnteredParentMenu);
- $(menuNode.parentMenuItem).removeClassName("submenu-selected");
- menuNode.parentMenuItem.mouseInside = false;
- menuNode.parentMenuItem = null;
- menuNode.parentMenu.submenuItem = null;
- menuNode.parentMenu.submenu = null;
- menuNode.parentMenu = null;
- }
+ menuNode.setStyle({ visibility: "hidden" });
+ if (menuNode.parentMenuItem) {
+ menuNode.parentMenuItem.stopObserving("mouseover",onMouseEnteredSubmenu);
+ menuNode.stopObserving("mouseover", onMouseEnteredSubmenu);
+ menuNode.parentMenuItem.stopObserving("mouseout", onMouseLeftSubmenu);
+ menuNode.stopObserving("mouseout", onMouseLeftSubmenu);
+ menuNode.parentMenu.stopObserving("mouseover", onMouseEnteredParentMenu);
+ $(menuNode.parentMenuItem).removeClassName("submenu-selected");
+ menuNode.parentMenuItem.mouseInside = false;
+ menuNode.parentMenuItem = null;
+ menuNode.parentMenu.submenuItem = null;
+ menuNode.parentMenu.submenu = null;
+ menuNode.parentMenu = null;
+ }
- $(menuNode).fire("mousedown");
+ $(menuNode).fire("mousedown");
}
function onMenuEntryClick(event) {
- var node = event.target;
+ var node = event.target;
- id = getParentMenu(node).menuTarget;
+ id = getParentMenu(node).menuTarget;
- return false;
+ return false;
}
function parseQueryParameters(url) {
- var parameters = new Array();
+ 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];
- }
- }
+ 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;
+ return parameters;
}
function initLogConsole() {
- var logConsole = $("logConsole");
- if (logConsole) {
- logConsole.highlighted = false;
- logConsole.observe("dblclick", onLogDblClick, false);
- logConsole.update();
- Event.observe(window, "keydown", onBodyKeyDown);
- }
+ var logConsole = $("logConsole");
+ if (logConsole) {
+ logConsole.highlighted = false;
+ logConsole.observe("dblclick", onLogDblClick, false);
+ logConsole.update();
+ Event.observe(window, "keydown", onBodyKeyDown);
+ }
}
function onBodyKeyDown(event) {
- if (event.keyCode == Event.KEY_ESC) {
- toggleLogConsole();
- preventDefault(event);
- }
+ if (event.keyCode == Event.KEY_ESC) {
+ toggleLogConsole();
+ preventDefault(event);
+ }
}
function onLogDblClick(event) {
- var logConsole = $("logConsole");
- logConsole.innerHTML = "";
+ var logConsole = $("logConsole");
+ logConsole.innerHTML = "";
}
function toggleLogConsole(event) {
- var logConsole = $("logConsole");
- var display = '' + logConsole.style.display;
- if (display.length == 0) {
- logConsole.setStyle({ display: 'block' });
- } else {
- logConsole.setStyle({ display: '' });
- }
- if (event)
- preventDefault(event);
+ var logConsole = $("logConsole");
+ var display = '' + logConsole.style.display;
+ if (display.length == 0) {
+ logConsole.setStyle({ display: 'block' });
+ } else {
+ logConsole.setStyle({ display: '' });
+ }
+ if (event)
+ preventDefault(event);
}
function log(message) {
- if (!logWindow) {
- logWindow = window;
- while (logWindow.opener)
- logWindow = logWindow.opener;
- }
- var logConsole = logWindow.document.getElementById("logConsole");
- if (logConsole) {
- logConsole.highlighted = !logConsole.highlighted;
- if (message == '\c') {
- logConsole.innerHTML = "";
- return;
- }
- var logMessage = message.replace("<", "<", "g");
- logMessage = logMessage.replace(" ", " ", "g");
- logMessage = logMessage.replace("\r\n", "
\n", "g");
- logMessage = logMessage.replace("\n", "
\n", "g");
- logMessage += '
' + "\n";
- if (logConsole.highlighted)
- logMessage = '