From 57e4c22be804b4878b238e95577b026b6301ef3d Mon Sep 17 00:00:00 2001
From: Robert Tansley
Date: Wed, 24 Mar 2004 17:22:44 +0000
Subject: [PATCH] - Added JSP tag, similar-ish to HTML
-
+
diff --git a/dspace/jsp/layout/header-default.jsp b/dspace/jsp/layout/header-default.jsp
index d1c9fffb78..ce8aefbd4c 100644
--- a/dspace/jsp/layout/header-default.jsp
+++ b/dspace/jsp/layout/header-default.jsp
@@ -63,63 +63,7 @@
-
+
<%-- HACK: leftmargin, topmargin: for non-CSS compliant Microsoft IE browser --%>
diff --git a/dspace/jsp/dspace-admin/eperson-list.jsp b/dspace/jsp/tools/eperson-list.jsp
similarity index 87%
rename from dspace/jsp/dspace-admin/eperson-list.jsp
rename to dspace/jsp/tools/eperson-list.jsp
index eb6a7f5aa7..b3556e5eab 100644
--- a/dspace/jsp/dspace-admin/eperson-list.jsp
+++ b/dspace/jsp/tools/eperson-list.jsp
@@ -47,6 +47,7 @@
- epeople - EPerson[] - all epeople to browse
- sortby - Integer - field to sort by (constant from EPerson.java)
- first - Integer - index of first eperson to display
+ - multiple - if non-null, this is for selecting multiple epeople
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
@@ -62,6 +63,7 @@
(EPerson[]) request.getAttribute("epeople");
int sortBy = ((Integer)request.getAttribute("sortby" )).intValue();
int first = ((Integer)request.getAttribute("first")).intValue();
+ boolean multiple = (request.getAttribute("multiple") != null);
// Make sure we won't run over end of list
int last = first + PAGESIZE;
@@ -87,9 +89,9 @@
String sortByParam = "lastname";
if (sortBy == EPerson.EMAIL) sortByParam = "email";
if (sortBy == EPerson.ID) sortByParam = "id";
-
- String jumpLink = request.getContextPath() + "/dspace-admin/eperson-list?sortby=" + sortByParam + "&first=";
- String sortLink = request.getContextPath() + "/dspace-admin/eperson-list?first=" + first + "&sortby=";
+
+ String jumpLink = request.getContextPath() + "/dspace-admin/eperson-list?multiple=" + multiple + "&sortby=" + sortByParam + "&first=";
+ String sortLink = request.getContextPath() + "/dspace-admin/eperson-list?multiple=" + multiple + "&first=" + first + "&sortby=";
%>
@@ -108,6 +110,17 @@ function addEPerson(id, email, name)
{
self.opener.addEPerson(id, email, name);
}
+
+// Clear selected items from main e-people list
+function clearEPeople()
+{
+ var list = self.opener.document.forms[0].eperson_id;
+ while (list.options.length > 0)
+ {
+ list.options[0] = null;
+ }
+}
+
// End -->
@@ -140,6 +153,15 @@ function addEPerson(id, email, name)
<%
String row = "even";
+
+ String buttonText = (multiple ? "Add" : "Select");
+ // If this is a dialogue to select a *single* e-person, we want
+ // to clear any existing entry in the e-person list, and
+ // to close this window when a 'select' button is clicked
+ String clearList = (multiple ? "" : "clearEPeople();");
+ String closeWindow = (multiple ? "" : "window.close();");
+
+
for (int i = first; i <= last; i++)
{
EPerson e = epeople[i];
@@ -147,7 +169,7 @@ function addEPerson(id, email, name)
String fullname = e.getFullName().replace('\'', ' ');
%>
-
+
<%= e.getID() %>
<%= e.getEmail() %>
diff --git a/dspace/jsp/utils.js b/dspace/jsp/utils.js
new file mode 100644
index 0000000000..baa77569e7
--- /dev/null
+++ b/dspace/jsp/utils.js
@@ -0,0 +1,116 @@
+/*
+ * utils.js
+ *
+ * Version: $Revision$
+ *
+ * Date: $Date$
+ *
+ * Copyright (c) 2004, Hewlett-Packard Company and Massachusetts
+ * Institute of Technology. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of the Hewlett-Packard Company nor the name of the
+ * Massachusetts Institute of Technology nor the names of their
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+
+/*
+ * Utility Javascript methods for DSpace
+ */
+
+// Popup window - here so it can be referred to by several methods
+var popupWindow;
+
+// =========================================================
+// Methods for e-person popup window
+// =========================================================
+
+// Add to list of e-people on this page -- invoked by eperson popup window
+function addEPerson(id, email, name)
+{
+ var newplace = window.document.forms[0].eperson_id.options.length;
+
+ // First we check to see if e-person is already there
+ for (var i = 0; i < window.document.forms[0].eperson_id.options.length; i++)
+ {
+ if (window.document.forms[0].eperson_id.options[i].value == id)
+ {
+ newplace = -1;
+ }
+ }
+
+ if (newplace > -1)
+ {
+ window.document.forms[0].eperson_id.options[newplace] = new Option(name + " (" + email + ")", id);
+ }
+}
+
+// This needs to be invoked in the 'onClick' javascript event for buttons
+// on pages with a dspace:selecteperson element in them
+function finishEPerson()
+{
+ selectAll(window.document.forms[0].eperson_id);
+ popupWindow.close();
+}
+
+
+// =========================================================
+// Miscellaneous utility methods
+// =========================================================
+
+// Open a popup window (or bring to front if already open)
+function popup_window(winURL, winName)
+{
+ var props = 'scrollBars=yes,resizable=yes,toolbar=no,menubar=no,location=no,directories=no,width=640,height=480';
+ popupWindow = window.open(winURL, winName, props);
+ popupWindow.focus();
+}
+
+
+// Select all options in a