]> err.no Git - scalable-opengroupware.org/blobdiff - UI/WebServerResources/UIxComponentEditor.js
git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1261 d1b88da0-ebda-0310...
[scalable-opengroupware.org] / UI / WebServerResources / UIxComponentEditor.js
index 632d1f865cfd9a6b25fcce9c4fcd3aeb6f166d22..8aa9c1124bb95c85430e2cdc59f6eedfe3b45527 100644 (file)
@@ -1,38 +1,44 @@
 function onPopupAttendeesWindow(event) {
    if (event)
-      event.preventDefault();
-   window.open(ApplicationBaseURL + "editAttendees", null, 
+      preventDefault(event);
+   window.open(ApplicationBaseURL + "/editAttendees", null, 
                "width=803,height=573");
 
    return false;
 }
 
 function onSelectPrivacy(event) {
-   popupToolbarMenu(event, "privacy-menu");
-
-   return false;
+   if (event.button == 0 || (isSafari() && event.button == 1)) {
+      var node = getTarget(event);
+      if (node.tagName != 'A')
+       node = $(node).getParentWithTagName("a");
+      node = $(node).childNodesWithTag("span")[0];
+      popupToolbarMenu(node, "privacy-menu");
+      Event.stop(event);
+//       preventDefault(event);
+   }
 }
 
 function onPopupUrlWindow(event) {
    if (event)
-      event.preventDefault();
+      preventDefault(event);
 
    var urlInput = document.getElementById("url");
-   var newUrl = window.prompt(labels["Target:"].decodeEntities(), urlInput.value);
+   var newUrl = window.prompt(labels["Target:"], urlInput.value);
    if (newUrl != null) {
       var documentHref = $("documentHref");
       var documentLabel = $("documentLabel");
       if (documentHref.childNodes.length > 0) {
         documentHref.childNodes[0].nodeValue = newUrl;
         if (newUrl.length > 0)
-           documentLabel.style.display = "block;";
+           documentLabel.setStyle({ display: "block" });
         else
-           documentLabel.style.display = "none;";
+           documentLabel.setStyle({ display: "none" });
       }
       else {
         documentHref.appendChild(document.createTextNode(newUrl)); 
         if (newUrl.length > 0)
-           documentLabel.style.display = "block;";
+           documentLabel.setStyle({ display: "block" });
       }
       urlInput.value = newUrl;
    }
@@ -43,7 +49,7 @@ function onPopupUrlWindow(event) {
 function onPopupDocumentWindow(event) {
    var documentUrl = $("url");
 
-   event.preventDefault();
+   preventDefault(event);
    window.open(documentUrl.value, "SOGo_Document");
 
    return false;
@@ -58,7 +64,7 @@ function onMenuSetClassification(event) {
    this.addClassName("_chosen");
    this.parentNode.chosenNode = this;
 
-   log("classification: " + classification);
+//    log("classification: " + classification);
    var privacyInput = document.getElementById("privacy");
    privacyInput.value = classification;
 }
@@ -68,13 +74,7 @@ function onChangeCalendar(event) {
    var form = document.forms["editform"];
    var urlElems = form.getAttribute("action").split("/");
    var choice = calendars[this.value];
-   var ownerLogin;
-   if (choice.indexOf(":") > -1)
-      ownerLogin = choice.split(":")[0];
-   else
-      ownerLogin = UserLogin;
-   urlElems[urlElems.length-4] = ownerLogin;
-
+   urlElems[urlElems.length-3] = choice;
    form.setAttribute("action", urlElems.join("/"));
 }
 
@@ -88,10 +88,10 @@ function refreshAttendees() {
 
    if (attendeesNames.value.length > 0) {
       attendeesHref.appendChild(document.createTextNode(attendeesNames.value));
-      attendeesLabel.style.display = "block;";
+      attendeesLabel.setStyle({ display: "block" });
    }
    else
-      attendeesLabel.style.display = "none;";
+      attendeesLabel.setStyle({ display: "none" });
 }
 
 function initializeAttendeesHref() {
@@ -99,12 +99,11 @@ function initializeAttendeesHref() {
    var attendeesLabel = $("attendeesLabel");
    var attendeesNames = $("attendeesNames");
 
-   attendeesHref.addEventListener("click", onPopupAttendeesWindow, false);
+   Event.observe(attendeesHref, "click", onPopupAttendeesWindow, false);
    if (attendeesNames.value.length > 0) {
-      attendeesHref.style.textDecoration = "underline;";
-      attendeesHref.style.color = "#00f;";
+      attendeesHref.setStyle({ textDecoration: "underline", color: "#00f" });
       attendeesHref.appendChild(document.createTextNode(attendeesNames.value));
-      attendeesLabel.style.display = "block;";
+      attendeesLabel.setStyle({ display: "block" });
    }
 }
 
@@ -113,24 +112,22 @@ function initializeDocumentHref() {
    var documentLabel = $("documentLabel");
    var documentUrl = $("url");
 
-   documentHref.addEventListener("click", onPopupDocumentWindow, false);
-   documentHref.style.textDecoration = "underline;";
-   documentHref.style.color = "#00f;";
+   Event.observe(documentHref, "click", onPopupDocumentWindow, false);
+   documentHref.setStyle({ textDecoration: "underline", color: "#00f" });
    if (documentUrl.value.length > 0) {
       documentHref.appendChild(document.createTextNode(documentUrl.value));
-      documentLabel.style.display = "block;";
+      documentLabel.setStyle({ display: "block" });
    }
 
    var changeUrlButton = $("changeUrlButton");
-   changeUrlButton.addEventListener("click", onPopupUrlWindow, false);
+   Event.observe(changeUrlButton, "click", onPopupUrlWindow, false);
 }
 
 function initializePrivacyMenu() {
    var privacy = $("privacy").value.toUpperCase();
-   log("privacy: " + privacy);
    if (privacy.length > 0) {
       var privacyMenu = $("privacy-menu").childNodesWithTag("ul")[0];
-      var menuEntries = privacyMenu.childNodesWithTag("li");
+      var menuEntries = $(privacyMenu).childNodesWithTag("li");
       var chosenNode;
       if (privacy == "CONFIDENTIAL")
         chosenNode = menuEntries[1];
@@ -139,7 +136,7 @@ function initializePrivacyMenu() {
       else
         chosenNode = menuEntries[0];
       privacyMenu.chosenNode = chosenNode;
-      chosenNode.addClassName("_chosen");
+      $(chosenNode).addClassName("_chosen");
    }
 }
 
@@ -149,14 +146,27 @@ function onComponentEditorLoad(event) {
    initializeDocumentHref();
    initializePrivacyMenu();
    var list = $("calendarList");
-   list.addEventListener("change", onChangeCalendar, false);
-   var onSelectionChangeEvent = document.createEvent("Event");
-   onSelectionChangeEvent.initEvent("change", false, false);
-   list.dispatchEvent(onSelectionChangeEvent);
+   Event.observe(list, "mousedown",
+                onChangeCalendar.bindAsEventListener(list),
+                false);
+   if (document.createEvent) {
+     var onSelectionChangeEvent;
+      if (isSafari())
+       onSelectionChangeEvent = document.createEvent("UIEvents");
+      else
+       onSelectionChangeEvent = document.createEvent("Events");
+      onSelectionChangeEvent.initEvent("mousedown", false, false);
+     list.dispatchEvent(onSelectionChangeEvent);
+   }
+   else {
+     list.fireEvent("onmousedown"); // IE
+   }
 
    var menuItems = $("itemPrivacyList").childNodesWithTag("li");
    for (var i = 0; i < menuItems.length; i++)
-      menuItems[i].addEventListener("mouseup", onMenuSetClassification, false);
+      Event.observe(menuItems[i], "mousedown",
+                   onMenuSetClassification.bindAsEventListener(menuItems[i]),
+                   false);
 }
 
-window.addEventListener("load", onComponentEditorLoad, false);
+addEvent(window, 'load', onComponentEditorLoad);