lots of simple web enhancements, org tree loaded and working
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 7 Aug 2005 22:20:36 +0000 (22:20 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Sun, 7 Aug 2005 22:20:36 +0000 (22:20 +0000)
added an altcanvas.xml which holds anything that may be hidden behind the page canvas
added header file for mod_xmltools

git-svn-id: svn://svn.open-ils.org/ILS/trunk@1622 dcc99617-32d9-48b4-a31d-7c20da2025e4

21 files changed:
Open-ILS/css/opac/dtree.css [new file with mode: 0644]
Open-ILS/css/opac/opac.css
Open-ILS/src/apachemods/mod_xmltools.h [new file with mode: 0644]
Open-ILS/src/javascript/lib/js/opac/config.js
Open-ILS/src/javascript/lib/js/opac/dtree.js [new file with mode: 0644]
Open-ILS/src/javascript/lib/js/opac/init.js
Open-ILS/src/javascript/lib/js/opac/opac_utils.js
Open-ILS/src/javascript/lib/js/opac/result_common.js
Open-ILS/src/javascript/lib/js/opac/search_bar.js
Open-ILS/src/webxml/advanced.xml
Open-ILS/src/webxml/altcanvas.xml [new file with mode: 0644]
Open-ILS/src/webxml/css_common.xml [new file with mode: 0644]
Open-ILS/src/webxml/index.xml
Open-ILS/src/webxml/js_common.xml
Open-ILS/src/webxml/login.xml
Open-ILS/src/webxml/mresult.xml
Open-ILS/src/webxml/myopac/index.xml
Open-ILS/src/webxml/result_common.xml
Open-ILS/src/webxml/rresult.xml
Open-ILS/src/webxml/searchbar.xml
Open-ILS/src/webxml/sidebar.xml

diff --git a/Open-ILS/css/opac/dtree.css b/Open-ILS/css/opac/dtree.css
new file mode 100644 (file)
index 0000000..b201c2f
--- /dev/null
@@ -0,0 +1,34 @@
+/*--------------------------------------------------|
+| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
+|---------------------------------------------------|
+| Copyright (c) 2002-2003 Geir Landrö               |
+|--------------------------------------------------*/
+
+.dtree {
+       font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;
+       font-size: 11px;
+       color: #666;
+       white-space: nowrap;
+}
+.dtree img {
+       border: 0px;
+       vertical-align: middle;
+}
+.dtree a {
+       color: #333;
+       text-decoration: none;
+}
+.dtree a.node, .dtree a.nodeSel {
+       white-space: nowrap;
+       padding: 1px 2px 1px 2px;
+}
+.dtree a.node:hover, .dtree a.nodeSel:hover {
+       color: #333;
+       text-decoration: underline;
+}
+.dtree a.nodeSel {
+       background-color: #c0d2ec;
+}
+.dtree .clip {
+       overflow: hidden;
+}
\ No newline at end of file
index 8c3a42a..b9982c7 100644 (file)
@@ -12,17 +12,32 @@ body table          { font-size: inherit; }
 .show_me                       {display:block; visibility: visible;}
 .show_me_inline        {display:inline; visibility: visible;}
 
+/* Our color scheme */
+
+/*
+.color_1 { background: #FFE6D4; color: #000000; }
+.color_2 { background: #FFCDAA; color: #000000; }
+.color_3 { background: #FFE6D4; color: #000000; }
+*/
+
+.color_1 { background: #A7EA9D; color: #000000; }
+.color_2 { background: #64EA4F; color: #000000; }
+.color_3 { background: #D8B4BE; color: #000000; }
+
+
 /* ---------------------------------------------------------------------- */
 .canvas { float:right; width: 80%; text-align: left;}
-#loading_div { width: 100%; background: #FFCDAA;}
+#loading_div { width: 100%;}
 
 .logo { height: 80px; width: 200px; position: absolute; top: 0px; left: 0px; }
 
+.org_tree { height: 500px; padding-left: 2px; padding-right: 2px;
+                                  overflow:-moz-scrollbars-vertical; overflow-y:scroll; overflow-x:hidden; }            
+
 /* ---------------------------------------------------------------------- */
 .sidebar_div { float: left; width: 19%; }
 .side_bar_item { padding-left: 15px; padding-right: 10px; padding-top: 5px; padding-bottom: 5px; }
-.side_bar_item_active { background: #FFCDAA; }
-.sidebar_chunk {background: #FFE6D4; border-right: 1px solid lightgrey;}
+.sidebar_chunk {border-right: 1px solid lightgrey;}
 
 /* ---------------------------------------------------------------------- */
 #searchbar { position: absolute; text-align: right; top: 2px; right: 3px; }
@@ -31,10 +46,12 @@ body table          { font-size: inherit; }
 
 .searchbar_item { text-align: center; color: black; padding: 3px; } 
 
-.searchbar_tag { font-size: 90%; text-align: right; background: #68CE76; 
+.searchbar_tag { font-size: 90%; text-align: right;  
        padding-left: 5px; padding-right: 5px; padding-bottom: 3px; } 
 
-#searchbar_main { background: #68CE76; text-align: right; 
+/*background: #68CE76; */
+
+#searchbar_main { text-align: right; 
        padding-top: 2px; padding-bottom: 3px; padding-right: 2px; padding-left: 3px; }
 
 .searchbar_extra_td { padding-top: 10px; }
@@ -42,13 +59,11 @@ body table          { font-size: inherit; }
 
 /* ---------------------------------------------------------------------- */
 
-#login_box { background: #FFE6D4; border-top: 1px solid #808080; 
-       border-bottom: 1px solid #808080; width: 60%; padding-bottom: 4px;}
+#login_box { border-top: 1px solid #808080; 
+       border-bottom: 1px solid #808080; width: 60%; padding: 5px;}
 
-.login_text { margin: 6px; }
-.login_link { margin: 10px; }
-.login_word { margin: 10px; }
-.login_links_div { padding-left: 30px; }
+.login_text { margin-left: 8px; }
+/*.login_links_div { padding-left: 30px; }*/
 
 /* ---------------------------------------------------------------------- */
 #result_table_div { text-align: left; width: 100%; }
@@ -83,6 +98,8 @@ body table            { font-size: inherit; }
 .copy_count_cell { font-size: 75%; width: 8%; text-align: center; padding: 0px; margin: 0px;}
 .copy_count_cell_even { border: 1px solid #E0E0E0; }
 
+.search_page_nav_link { margin-right: 5px; }
+
 /* ---------------------------------------------------------------------- */
 
 
diff --git a/Open-ILS/src/apachemods/mod_xmltools.h b/Open-ILS/src/apachemods/mod_xmltools.h
new file mode 100644 (file)
index 0000000..75a00f8
--- /dev/null
@@ -0,0 +1,39 @@
+#include "apachetools.h"
+#include "xmltools.h"
+
+#define MODULE_NAME            "mod_xmltools" /* our module name */
+#define PARAM_LOCALE           "locale"                        /* the URL param for the local directory */
+#define LANG_DTD                       "lang.dtd"              /* the DTD for the test entities */
+
+
+
+/* ------------------------------------------------------------------------------ */
+/* Apache config items.  These are defaults which are only  used if they are not
+       overriden by the Apache config or URL where appropriate */
+/* ------------------------------------------------------------------------------ */
+/* The default directory where the local files are stored */
+#define DEFAULT_LOCALE_DIR             "/openils/var/locale"
+#define DEFAULT_LOCALE                 "en-US"                 
+/* ------------------------------------------------------------------------------ */
+
+
+/* This module */
+module AP_MODULE_DECLARE_DATA mod_xmltools;
+
+
+/* our config structure */
+typedef struct {
+       /* directory on disk where the locale directories live */
+       char* locale_dir;
+       char* default_locale;
+} mod_xmltools_config;
+
+
+
+/* allocates a char* to hold the name of the DTD language file 
+       Prints to stderr and returns NULL if there was an error loading the file 
+       default_locale comes from the apache config and is used only if no 
+       locale is provided via URL 
+       locale_dir also comes from the apache config.
+       */
+char* get_dtd_lang_file(string_array* params, char* default_locale, char* locale_dir);
index 8af0e21..bd4e076 100644 (file)
@@ -53,10 +53,15 @@ function loadUIObjects() {
        }
 }
 
+/* try our best to free memory */
 function clearUIObjects() {
        for( var p in config.ids ) {
-               for( var o in config.ids[p] ) 
-                       G.ui[p][o] = null;
+               for( var o in config.ids[p] ) {
+                       if(G.ui[p][o]) {
+                               G.ui[p][o].onclick = null;
+                               G.ui[p][o] = null;
+                       }
+               }
                G.ui[p] = null;
        }
 }
@@ -72,13 +77,17 @@ config.text = {};
 config.ids = {};
 config.names = {};
 
-config.ids.all = {};
-config.ids.all.loading         = "loading_div";        /* generic 'loading..' message */
-config.ids.all.canvas          = "canvas";                     /* outer UI canvas that holds the main canvas and any other hidden help components*/    
-config.ids.all.canvas_main     = "canvas_main";        /* main data display canvas */
+config.ids.common = {};
+config.ids.common.loading              = "loading_div";                /* generic 'loading..' message */
+config.ids.common.canvas               = "canvas";                             /* outer UI canvas that holds the main canvas and any other hidden help components*/    
+config.ids.common.canvas_main  = "canvas_main";                /* main data display canvas */
+config.ids.common.org_tree             = "org_tree";                   /* org tree selector thingy */
 
 config.css = {};
 config.css.hide_me = "hide_me";
+config.css.color_1 = "color_1";
+config.css.color_2 = "color_2";
+config.css.color_3 = "color_3";
 
 config.page = {};
 config.page[HOME]                      = "/webxml/index.xml";
@@ -110,12 +119,15 @@ config.ids.result.current_page    = 'current_page';
 config.css.result.nav_active           = "nav_link_active";
 config.ids.result.top_div                      = "result_table_div";
 config.ids.result.nav_links            = "search_nav_links";
+config.ids.result.info                         = "result_info_div";
+
 config.names.result.item_jacket        = "item_jacket";
 config.names.result.item_title = "item_title";
 config.names.result.item_author        = "item_author";
 config.names.result.counts_row = "counts_row";
 config.names.result.count_cell = "copy_count_cell";
 
+/* login page */
 config.ids.login = {};
 config.css.login = {};
 config.ids.login.box                   = "login_box";
@@ -140,6 +152,7 @@ config.ids.searchbar.table                          = 'searchbar_table';
 config.ids.searchbar.tag                               = 'search_tag_link';
 config.ids.searchbar.tag_on                    = 'searchbar_tag_on';
 config.ids.searchbar.tag_off                   = 'searchbar_tag_off';
+config.ids.searchbar.location_tag      = 'search_location_tag_link';
 
 
 /*  sidebar */
@@ -150,7 +163,6 @@ config.ids.sidebar.home                             = 'home_link_div';
 config.ids.sidebar.advanced            = 'advanced_link_div';
 config.ids.sidebar.myopac                      = 'myopac_link_div';
 config.ids.sidebar.prefs                       = 'prefs_link_div';
-config.css.sidebar.item.active = 'side_bar_item_active';
 config.ids.sidebar.mresult                     = 'mresult_link_div';
 config.ids.sidebar.rresult                     = 'result_link_div';
 config.ids.sidebar.login                       = 'login_link';
@@ -162,4 +174,13 @@ config.ids.sidebar.username_dest   = 'username_dest';
 
 
 
+/* ---------------------------------------------------------------------------- */
+/* These are pages that may replace the canvas */
+/* ---------------------------------------------------------------------------- */
+config.ids.altcanvas = {};
+config.ids.altcanvas.login             = config.ids.login.box;
+config.ids.altcanvas.org_tree   = config.ids.common.org_tree;
+
+
+
 
diff --git a/Open-ILS/src/javascript/lib/js/opac/dtree.js b/Open-ILS/src/javascript/lib/js/opac/dtree.js
new file mode 100644 (file)
index 0000000..b8a4152
--- /dev/null
@@ -0,0 +1,347 @@
+/*--------------------------------------------------|
+| dTree 2.05 | www.destroydrop.com/javascript/tree/ |
+|---------------------------------------------------|
+| Copyright (c) 2002-2003 Geir Landrö               |
+|                                                   |
+| This script can be used freely as long as all     |
+| copyright messages are intact.                    |
+|                                                   |
+| Updated: 17.04.2003                               |
+|--------------------------------------------------*/
+
+// Node object
+function Node(id, pid, name, url, title, target, icon, iconOpen, open) {
+       this.id = id;
+       this.pid = pid;
+       this.name = name;
+       this.url = url;
+       this.title = title;
+       this.target = target;
+       this.icon = icon;
+       this.iconOpen = iconOpen;
+       this._io = open || false;
+       this._is = false;
+       this._ls = false;
+       this._hc = false;
+       this._ai = 0;
+       this._p;
+};
+
+// Tree object
+function dTree(objName) {
+       this.config = {
+               target                                  : null,
+               folderLinks                     : true,
+               useSelection            : true,
+               useCookies                      : true,
+               useLines                                : true,
+               useIcons                                : true,
+               useStatusText           : false,
+               closeSameLevel  : false,
+               inOrder                                 : false
+       }
+       this.icon = {
+               root                            : '/images/opac/img/base.gif',
+               folder                  : '/images/opac/img/folder.gif',
+               folderOpen      : '/images/opac/img/folderopen.gif',
+               node                            : '/images/opac/img/page.gif',
+               empty                           : '/images/opac/img/empty.gif',
+               line                            : '/images/opac/img/line.gif',
+               join                            : '/images/opac/img/join.gif',
+               joinBottom      : '/images/opac/img/joinbottom.gif',
+               plus                            : '/images/opac/img/plus.gif',
+               plusBottom      : '/images/opac/img/plusbottom.gif',
+               minus                           : '/images/opac/img/minus.gif',
+               minusBottom     : '/images/opac/img/minusbottom.gif',
+               nlPlus                  : '/images/opac/img/nolines_plus.gif',
+               nlMinus                 : '/images/opac/img/nolines_minus.gif'
+       };
+       this.obj = objName;
+       this.aNodes = [];
+       this.aIndent = [];
+       this.root = new Node(-1);
+       this.selectedNode = null;
+       this.selectedFound = false;
+       this.completed = false;
+};
+
+// Adds a new node to the node array
+dTree.prototype.add = function(id, pid, name, url, title, target, icon, iconOpen, open) {
+       this.aNodes[this.aNodes.length] = new Node(id, pid, name, url, title, target, icon, iconOpen, open);
+};
+
+// Open/close all nodes
+dTree.prototype.openAll = function() {
+       this.oAll(true);
+};
+dTree.prototype.closeAll = function() {
+       this.oAll(false);
+};
+
+// Outputs the tree to the page
+dTree.prototype.toString = function() {
+       var str = '<div class="dtree">\n';
+       if (document.getElementById) {
+               if (this.config.useCookies) this.selectedNode = this.getSelected();
+               str += this.addNode(this.root);
+       } else str += 'Browser not supported.';
+       str += '</div>';
+       if (!this.selectedFound) this.selectedNode = null;
+       this.completed = true;
+       return str;
+};
+
+// Creates the tree structure
+dTree.prototype.addNode = function(pNode) {
+       var str = '';
+       var n=0;
+       if (this.config.inOrder) n = pNode._ai;
+       for (n; n<this.aNodes.length; n++) {
+               if (this.aNodes[n].pid == pNode.id) {
+                       var cn = this.aNodes[n];
+                       cn._p = pNode;
+                       cn._ai = n;
+                       this.setCS(cn);
+                       if (!cn.target && this.config.target) cn.target = this.config.target;
+                       if (cn._hc && !cn._io && this.config.useCookies) cn._io = this.isOpen(cn.id);
+                       if (!this.config.folderLinks && cn._hc) cn.url = null;
+                       if (this.config.useSelection && cn.id == this.selectedNode && !this.selectedFound) {
+                                       cn._is = true;
+                                       this.selectedNode = n;
+                                       this.selectedFound = true;
+                       }
+                       str += this.node(cn, n);
+                       if (cn._ls) break;
+               }
+       }
+       return str;
+};
+
+// Creates the node icon, url and text
+dTree.prototype.node = function(node, nodeId) {
+       var str = '<div class="dTreeNode">' + this.indent(node, nodeId);
+       if (this.config.useIcons) {
+               if (!node.icon) node.icon = (this.root.id == node.pid) ? this.icon.root : ((node._hc) ? this.icon.folder : this.icon.node);
+               if (!node.iconOpen) node.iconOpen = (node._hc) ? this.icon.folderOpen : this.icon.node;
+               if (this.root.id == node.pid) {
+                       node.icon = this.icon.root;
+                       node.iconOpen = this.icon.root;
+               }
+               str += '<img id="i' + this.obj + nodeId + '" src="' + ((node._io) ? node.iconOpen : node.icon) + '" alt="" />';
+       }
+       if (node.url) {
+               str += '<a id="s' + this.obj + nodeId + '" class="' + ((this.config.useSelection) ? ((node._is ? 'nodeSel' : 'node')) : 'node') + '" href="' + node.url + '"';
+               if (node.title) str += ' title="' + node.title + '"';
+               if (node.target) str += ' target="' + node.target + '"';
+               if (this.config.useStatusText) str += ' onmouseover="window.status=\'' + node.name + '\';return true;" onmouseout="window.status=\'\';return true;" ';
+               if (this.config.useSelection && ((node._hc && this.config.folderLinks) || !node._hc))
+                       str += ' onclick="javascript: ' + this.obj + '.s(' + nodeId + ');"';
+               str += '>';
+       }
+       else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id)
+               str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');" class="node">';
+       str += node.name;
+       if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += '</a>';
+       str += '</div>';
+       if (node._hc) {
+               str += '<div id="d' + this.obj + nodeId + '" class="clip" style="display:' + ((this.root.id == node.pid || node._io) ? 'block' : 'none') + ';">';
+               str += this.addNode(node);
+               str += '</div>';
+       }
+       this.aIndent.pop();
+       return str;
+};
+
+// Adds the empty and line icons
+dTree.prototype.indent = function(node, nodeId) {
+       var str = '';
+       if (this.root.id != node.pid) {
+               for (var n=0; n<this.aIndent.length; n++)
+                       str += '<img src="' + ( (this.aIndent[n] == 1 && this.config.useLines) ? this.icon.line : this.icon.empty ) + '" alt="" />';
+               (node._ls) ? this.aIndent.push(0) : this.aIndent.push(1);
+               if (node._hc) {
+                       str += '<a href="javascript: ' + this.obj + '.o(' + nodeId + ');"><img  id="j' + this.obj + nodeId + '" src="';
+                       if (!this.config.useLines) str += (node._io) ? this.icon.nlMinus : this.icon.nlPlus;
+                       else str += ( (node._io) ? ((node._ls && this.config.useLines) ? this.icon.minusBottom : this.icon.minus) : ((node._ls && this.config.useLines) ? this.icon.plusBottom : this.icon.plus ) );
+                       str += '" alt="" /></a>';
+               } else str += '<img src="' + ( (this.config.useLines) ? ((node._ls) ? this.icon.joinBottom : this.icon.join ) : this.icon.empty) + '" alt="" />';
+       }
+       return str;
+};
+
+// Checks if a node has any children and if it is the last sibling
+dTree.prototype.setCS = function(node) {
+       var lastId;
+       for (var n=0; n<this.aNodes.length; n++) {
+               if (this.aNodes[n].pid == node.id) node._hc = true;
+               if (this.aNodes[n].pid == node.pid) lastId = this.aNodes[n].id;
+       }
+       if (lastId==node.id) node._ls = true;
+};
+
+// Returns the selected node
+dTree.prototype.getSelected = function() {
+       var sn = this.getCookie('cs' + this.obj);
+       return (sn) ? sn : null;
+};
+
+// Highlights the selected node
+dTree.prototype.s = function(id) {
+       if (!this.config.useSelection) return;
+       var cn = this.aNodes[id];
+       if (cn._hc && !this.config.folderLinks) return;
+       if (this.selectedNode != id) {
+               if (this.selectedNode || this.selectedNode==0) {
+                       eOld = document.getElementById("s" + this.obj + this.selectedNode);
+                       eOld.className = "node";
+               }
+               eNew = document.getElementById("s" + this.obj + id);
+               eNew.className = "nodeSel";
+               this.selectedNode = id;
+               if (this.config.useCookies) this.setCookie('cs' + this.obj, cn.id);
+       }
+};
+
+// Toggle Open or close
+dTree.prototype.o = function(id) {
+       var cn = this.aNodes[id];
+       this.nodeStatus(!cn._io, id, cn._ls);
+       cn._io = !cn._io;
+       if (this.config.closeSameLevel) this.closeLevel(cn);
+       if (this.config.useCookies) this.updateCookie();
+};
+
+// Open or close all nodes
+dTree.prototype.oAll = function(status) {
+       for (var n=0; n<this.aNodes.length; n++) {
+               if (this.aNodes[n]._hc && this.aNodes[n].pid != this.root.id) {
+                       this.nodeStatus(status, n, this.aNodes[n]._ls)
+                       this.aNodes[n]._io = status;
+               }
+       }
+       if (this.config.useCookies) this.updateCookie();
+};
+
+// Opens the tree to a specific node
+dTree.prototype.openTo = function(nId, bSelect, bFirst) {
+       if (!bFirst) {
+               for (var n=0; n<this.aNodes.length; n++) {
+                       if (this.aNodes[n].id == nId) {
+                               nId=n;
+                               break;
+                       }
+               }
+       }
+       var cn=this.aNodes[nId];
+       if (cn.pid==this.root.id || !cn._p) return;
+       cn._io = true;
+       cn._is = bSelect;
+       if (this.completed && cn._hc) this.nodeStatus(true, cn._ai, cn._ls);
+       if (this.completed && bSelect) this.s(cn._ai);
+       else if (bSelect) this._sn=cn._ai;
+       this.openTo(cn._p._ai, false, true);
+};
+
+// Closes all nodes on the same level as certain node
+dTree.prototype.closeLevel = function(node) {
+       for (var n=0; n<this.aNodes.length; n++) {
+               if (this.aNodes[n].pid == node.pid && this.aNodes[n].id != node.id && this.aNodes[n]._hc) {
+                       this.nodeStatus(false, n, this.aNodes[n]._ls);
+                       this.aNodes[n]._io = false;
+                       this.closeAllChildren(this.aNodes[n]);
+               }
+       }
+}
+
+// Closes all children of a node
+dTree.prototype.closeAllChildren = function(node) {
+       for (var n=0; n<this.aNodes.length; n++) {
+               if (this.aNodes[n].pid == node.id && this.aNodes[n]._hc) {
+                       if (this.aNodes[n]._io) this.nodeStatus(false, n, this.aNodes[n]._ls);
+                       this.aNodes[n]._io = false;
+                       this.closeAllChildren(this.aNodes[n]);          
+               }
+       }
+}
+
+// Change the status of a node(open or closed)
+dTree.prototype.nodeStatus = function(status, id, bottom) {
+       eDiv    = document.getElementById('d' + this.obj + id);
+       eJoin   = document.getElementById('j' + this.obj + id);
+       if (this.config.useIcons) {
+               eIcon   = document.getElementById('i' + this.obj + id);
+               eIcon.src = (status) ? this.aNodes[id].iconOpen : this.aNodes[id].icon;
+       }
+       eJoin.src = (this.config.useLines)?
+       ((status)?((bottom)?this.icon.minusBottom:this.icon.minus):((bottom)?this.icon.plusBottom:this.icon.plus)):
+       ((status)?this.icon.nlMinus:this.icon.nlPlus);
+       eDiv.style.display = (status) ? 'block': 'none';
+};
+
+
+// [Cookie] Clears a cookie
+dTree.prototype.clearCookie = function() {
+       var now = new Date();
+       var yesterday = new Date(now.getTime() - 1000 * 60 * 60 * 24);
+       this.setCookie('co'+this.obj, 'cookieValue', yesterday);
+       this.setCookie('cs'+this.obj, 'cookieValue', yesterday);
+};
+
+// [Cookie] Sets value in a cookie
+dTree.prototype.setCookie = function(cookieName, cookieValue, expires, path, domain, secure) {
+       document.cookie =
+               escape(cookieName) + '=' + escape(cookieValue)
+               + (expires ? '; expires=' + expires.toGMTString() : '')
+               + (path ? '; path=' + path : '')
+               + (domain ? '; domain=' + domain : '')
+               + (secure ? '; secure' : '');
+};
+
+// [Cookie] Gets a value from a cookie
+dTree.prototype.getCookie = function(cookieName) {
+       var cookieValue = '';
+       var posName = document.cookie.indexOf(escape(cookieName) + '=');
+       if (posName != -1) {
+               var posValue = posName + (escape(cookieName) + '=').length;
+               var endPos = document.cookie.indexOf(';', posValue);
+               if (endPos != -1) cookieValue = unescape(document.cookie.substring(posValue, endPos));
+               else cookieValue = unescape(document.cookie.substring(posValue));
+       }
+       return (cookieValue);
+};
+
+// [Cookie] Returns ids of open nodes as a string
+dTree.prototype.updateCookie = function() {
+       var str = '';
+       for (var n=0; n<this.aNodes.length; n++) {
+               if (this.aNodes[n]._io && this.aNodes[n].pid != this.root.id) {
+                       if (str) str += '.';
+                       str += this.aNodes[n].id;
+               }
+       }
+       this.setCookie('co' + this.obj, str);
+};
+
+// [Cookie] Checks if a node id is in a cookie
+dTree.prototype.isOpen = function(id) {
+       var aOpen = this.getCookie('co' + this.obj).split('.');
+       for (var n=0; n<aOpen.length; n++)
+               if (aOpen[n] == id) return true;
+       return false;
+};
+
+// If Push and pop is not implemented by the browser
+if (!Array.prototype.push) {
+       Array.prototype.push = function array_push() {
+               for(var i=0;i<arguments.length;i++)
+                       this[this.length]=arguments[i];
+               return this.length;
+       }
+};
+if (!Array.prototype.pop) {
+       Array.prototype.pop = function array_pop() {
+               lastElement = this[this.length-1];
+               this.length = Math.max(this.length-1,0);
+               return lastElement;
+       }
+};
index 43f92ac..6ef9059 100644 (file)
@@ -7,8 +7,8 @@ function init() {
        initParams();
        initSideBar();
        searchBarInit();
+       G.ui.common.org_tree.innerHTML = buildOrgSelector().toString();
 
-       var page = findCurrentPage();
        switch(findCurrentPage()) {
                case MRESULT: mresultDoSearch(); break;
                case RRESULT: rresultDoSearch(); break;
@@ -16,28 +16,11 @@ function init() {
 
 }
 
+/* free whatever memory we can */
 function unload() {
-
        _tree_killer();
-
-       if(G.ui.sidebar.login)
-               G.ui.sidebar.login.onclick              = null;
-       if(G.ui.sidebar.logout)
-               G.ui.sidebar.logout.onclick     = null;
-       if(G.ui.login.button)
-               G.ui.login.button.onclick               = null;
-       if(G.ui.login.cancel)
-               G.ui.login.cancel.onclick               = null;
-       if(G.ui.searchbar.submit)
-               G.ui.searchbar.submit.onclick = null;
-       if(G.ui.searchbar.tag)
-               G.ui.searchbar.tag.onclick              = null;
-
        clearUIObjects();
-
-       if(IE) {
-               window.CollectGarbage();
-       }
+       if(IE) window.CollectGarbage();
 }
 
 
@@ -47,11 +30,11 @@ function unload() {
 function initSideBar() {
 
        for( var p in G.ui.sidebar ) 
-               removeCSSClass(p, config.css.sidebar.item.active);
+               removeCSSClass(p, config.css.color_2);
 
        var page = findCurrentPage();
        unHideMe(G.ui.sidebar[page]);
-       addCSSClass(G.ui.sidebar[page], config.css.sidebar.item.active);
+       addCSSClass(G.ui.sidebar[page], config.css.color_2);
 
        /* if we're logged in, show it and replace the Login link with the Logout link */
        if(grabUser()) {
@@ -67,14 +50,12 @@ function initSideBar() {
 }
 
 /* sets up the login ui components */
+var loginBoxVisible = false;
 function initLogin() {
 
-       G.ui.login.button.onclick = function(){
+       var loginDance = function() {
                if(doLogin()) {
-                       unHideMe(G.ui.all.canvas_main);
-                       hideMe(G.ui.login.box);
-                       hideMe(G.ui.all.loading);
-
+                       showCanvas();
                        G.ui.sidebar.username_dest.appendChild(text(G.user.usrname()));
                        unHideMe(G.ui.sidebar.logoutbox);
                        unHideMe(G.ui.sidebar.logged_in_as);
@@ -82,14 +63,20 @@ function initLogin() {
                }
        }
 
-       hideMe(G.ui.all.canvas_main);
-       unHideMe(G.ui.login.box);
-
-       G.ui.login.cancel.onclick = function(){
-               unHideMe(G.ui.all.canvas_main);
-               hideMe(G.ui.login.box);
-               hideMe(G.ui.all.loading);
+       G.ui.login.button.onclick = loginDance;
+       G.ui.login.username.onkeydown = 
+               function(evt) {if(userPressedEnter(evt)) loginDance();};
+       G.ui.login.password.onkeydown = 
+               function(evt) {if(userPressedEnter(evt)) loginDance();};
+
+       if(loginBoxVisible) {
+               showCanvas();
+       } else {
+               swapCanvas(G.ui.login.box);
+               G.ui.login.username.focus();
        }
+       loginBoxVisible = !loginBoxVisible;
+       G.ui.login.cancel.onclick = showCanvas;
 }
 
 
index c927e28..0956b06 100644 (file)
@@ -16,6 +16,29 @@ Request.prototype.result     = function(){return this.request.getResultObject();}
 /* ----------------------------------------------------------------------- */
 
 
+/* ----------------------------------------------------------------------- */
+/* Functions for showing the canvas (and hiding any other shown stuff) */
+/* ----------------------------------------------------------------------- */
+function showCanvas() {
+       for( var x in G.ui.altcanvas ) {
+               hideMe(G.ui.altcanvas[x]);
+       }
+       hideMe(G.ui.common.loading);
+       unHideMe(G.ui.common.canvas_main);
+       G.ui.searchbar.text.focus(); /* focus the searchbar */
+}
+
+function swapCanvas(newNode) {
+       for( var x in G.ui.altcanvas ) 
+               hideMe(G.ui.altcanvas[x]);
+
+       hideMe(G.ui.common.loading);
+       hideMe(G.ui.common.canvas_main);
+       unHideMe(newNode);
+}
+/* ----------------------------------------------------------------------- */
+
+
 /* finds the name of the current page */
 function findCurrentPage() {
        for( var p in config.page ) {
@@ -239,7 +262,36 @@ function hideMe(obj) { addCSSClass(obj, config.css.hide_me); }
 function unHideMe(obj) { removeCSSClass(obj, config.css.hide_me); }
 
 
+/* ----------------------------------------------------------------------- */
+/* build the org tree */
+/* ----------------------------------------------------------------------- */
+       
+var orgTreeSelector;
+function buildOrgSelector() {
+       var tree = new dTree("orgTreeSelector"); 
+       for( var i in orgArraySearcher ) { 
+               var node = orgArraySearcher[i];
+               if( node == null ) continue;
+               if(node.parent_ou() == null)
+                       tree.add(node.id(), -1, node.name(), 
+                               "javascript:orgSelect(" + node.id() + ");", node.name());
+               else {
+                       tree.add(node.id(), node.parent_ou().id(), node.name(), 
+                               "javascript:orgSelect(" + node.id() + ");", node.name());
+               }
+       }
+       orgTreeSelector = tree;
+       return tree;
+}
 
+function orgSelect(id) {
+       showCanvas();
+       newSearchLocation = id;
+}
+
+
+
+/* ----------------------------------------------------------------------- */
 
 
 
index c162d85..be229aa 100644 (file)
@@ -37,7 +37,7 @@ function resultSetInfo() {
        G.ui.result.offset_start.appendChild(text(o + 1));
        G.ui.result.offset_end.appendChild(text(c));
        G.ui.result.result_count.appendChild(text(getHitCount()));
-
+       unHideMe(G.ui.result.info);
 
 }
 
@@ -47,7 +47,7 @@ function resultDisplayRecord(rec, rowtemplate, is_mr) {
        if(rec == null) rec = new mvr(); /* if we return we won't build some important UI components */
 
        /* hide the 'now loading...' message */
-       hideMe(G.ui.all.loading);
+       hideMe(G.ui.common.loading);
 
        var r = rowtemplate.cloneNode(true);
 
index cf93944..d78b9f6 100644 (file)
@@ -8,6 +8,11 @@ var searchBarMainRow;
 var typeSelector;
 var depthSelector;
 var formSelector;
+var orgTreeVisible = false;
+
+/* if set by the org selector, this will be the location used the
+       next time the search is submitted */
+var newSearchLocation; 
 
 function searchBarInit() {
 
@@ -40,6 +45,12 @@ function searchBarInit() {
        //formSelector.onchange = function(){searchBarSelectorChanged("form");};
 
        if(getSearchBarExtras()) searchBarToggle();
+
+       G.ui.searchbar.location_tag.onclick = function() {
+               if(orgTreeVisible) showCanvas();        
+                else swapCanvas(G.ui.common.org_tree);
+               orgTreeVisible = !orgTreeVisible;
+       }
 }
 
 /*
@@ -78,6 +89,7 @@ function searchBarSubmit() {
        args[PARAM_OFFSET] = 0;
        args[PARAM_TERM] = text;
        args[PARAM_STYPE] = type_s.options[type_s.selectedIndex].value;
+       args[PARAM_LOCATION] = newSearchLocation;
 
        args[PARAM_DEPTH] = parseInt(depthSelector.options[depthSelector.selectedIndex].value);
        args[PARAM_FORM] = formSelector.options[formSelector.selectedIndex].value;
@@ -91,8 +103,8 @@ function searchBarToggle() {
 
                hideMe(searchBarExtraRow);
                searchBarExpanded = false;
-               G.ui.searchbar.tag_off.className = "show_me_inline";
                hideMe(G.ui.searchbar.tag_on);
+               unHideMe(G.ui.searchbar.tag_off);
                //SEARCHBAR_EXTRAS = 0; set cookie...
 
        } else {
@@ -100,7 +112,7 @@ function searchBarToggle() {
                removeCSSClass(searchBarExtraRow,config.css.hide_me);
                searchBarExpanded = true;
                hideMe(G.ui.searchbar.tag_off);
-               G.ui.searchbar.tag_on.className = "show_me_inline";
+               unHideMe(G.ui.searchbar.tag_on);
                //SEARCHBAR_EXTRAS = 1; set cookie...
        }
 }
index 0b520f1..dad3f6d 100644 (file)
@@ -8,14 +8,14 @@
 
        <head>
                <title>Evergreen: Advanced Search</title>
-               <link rel='stylesheet' type='text/css' href='/css/opac/opac.css'/>
+               <xi:include href="css_common.xml#xpointer(//link)"/>
                <xi:include href="js_common.xml"/>
        </head>
 
        <body onload="init();">
                <xi:include href="header.xml"/> 
                <div id='canvas' class='canvas'>
-                       <xi:include href="login.xml"/> 
+                       <xi:include href="altcanvas.xml"/>
                        <div id='canvas_main'>Advanced Search Goes Here</div>
                </div>
        </body>
diff --git a/Open-ILS/src/webxml/altcanvas.xml b/Open-ILS/src/webxml/altcanvas.xml
new file mode 100644 (file)
index 0000000..c393fac
--- /dev/null
@@ -0,0 +1,14 @@
+<?xml version='1.0'?>
+
+<!-- These are the UI components that may be needed on any given page.  The must be
+       set to class += 'hide_me' by default -->
+
+<div id='not_the_canvas' xmlns:xi="http://www.w3.org/2001/XInclude">
+
+       <!-- the login page -->
+       <xi:include href="login.xml"/> 
+
+       <!-- the org tree -->
+       <div id='org_tree' class='org_tree hide_me'> </div>
+
+</div>
diff --git a/Open-ILS/src/webxml/css_common.xml b/Open-ILS/src/webxml/css_common.xml
new file mode 100644 (file)
index 0000000..b7fd153
--- /dev/null
@@ -0,0 +1,8 @@
+<?xml version='1.0'?>
+
+<!-- CSS shared across pages goes here --> 
+
+<css>
+       <link rel='stylesheet' type='text/css' href='/css/opac/opac.css'/>
+       <link rel='stylesheet' type='text/css' href='/css/opac/dtree.css'/>
+</css>
index bf7f553..5b81359 100644 (file)
@@ -1,21 +1,22 @@
 <?xml version='1.0'?>
 <!DOCTYPE x [ <!ENTITY % ent SYSTEM "locale/en-US/lang.dtd"> %ent; ] >
 
-<html xmlns="http://www.w3.org/1999/xhtml" 
-       xmlns:xi="http://www.w3.org/2001/XInclude" xml:lang="en" lang="en">
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude">
 
        <head>
                <title>Evergreen: Home</title>
-               <link rel='stylesheet' type='text/css' href='/css/opac/opac.css'/>
+               <xi:include href="css_common.xml#xpointer(//link)"/>
                <xi:include href="js_common.xml#xpointer(//script)"/>
        </head>
 
        <body onload="init();">
                <xi:include href="header.xml"/> 
+
                <div id='canvas' class='canvas'>
-                       <xi:include href="login.xml"/> 
+                       <xi:include href="altcanvas.xml"/>
                        <div id='canvas_main'>Home is here, show something interesting...</div>
                </div>
+
        </body>
 
 </html>
index 5000830..17e6af3 100644 (file)
@@ -9,6 +9,9 @@
        <script language='javascript' src='/lib/js/util/CGI.js'> </script>
        <script language='javascript' src='/lib/js/util/Cookie.js'> </script>
        <script language='javascript' src='/lib/js/util/md5.js'> </script>
+
+       <script language='javascript' src='/lib/js/opac/dtree.js'> </script>
+
        <script language='javascript' src='/lib/js/opac/init.js'> </script>
        <script language='javascript' src='/lib/js/opac/opac_utils.js'> </script>
        <script language='javascript' src='/lib/js/opac/RemoteRequest.js'> </script>
index 4de66ed..4bfd039 100644 (file)
@@ -2,7 +2,7 @@
 <!DOCTYPE x [ <!ENTITY % ent SYSTEM "locale/en-US/lang.dtd"> %ent; ] >
 
 
-<div id='login_box' class='hide_me'>
+<div id='login_box' class='hide_me color_1'>
 
        <div class='login_text'>
                <span> Login in with your username and password. </span>
        <br/>
        
        <div>
-               <span class='login_word'>Username</span>
-               <span class=''><input id='login_username' type='text' size='16'> </input></span>
+               <span class='login_text'><input id='login_username' type='text' size='16'> </input></span>
+               <span class='login_text'>Username</span>
        </div>
 
        <br/>
 
        <div>
-               <span class='login_word'>Password</span>
-               <span class=''><input id='login_password' type='password' size='16'> </input></span>
+               <span class='login_text'><input id='login_password' type='password' size='16'> </input></span>
+               <span class='login_text'>Password</span>
        </div>
 
        <br/>
 
        <div class='login_links_div'>
-               <span class='login_link'><a href="javascript:void(0);" id='login_button'> Login </a></span>
-               <span class=''><a href='javascript:void(0);' id='login_cancel_button'> Cancel </a></span>
+               <span class='login_text'><a href="javascript:void(0);" id='login_button'> Login </a></span>
+               <span class='login_text'><a href='javascript:void(0);' id='login_cancel_button'> Cancel </a></span>
        </div>
 
 </div>
index b1da961..c46aa1d 100644 (file)
@@ -6,7 +6,7 @@
 
        <head>
                <title>Evergreen: Title Groups</title>
-               <link rel='stylesheet' type='text/css' href='/css/opac/opac.css'/>
+               <xi:include href="css_common.xml#xpointer(//link)"/>
                <xi:include href="js_common.xml"/>
                <script language='javascript' src='/lib/js/opac/mresult.js'> </script>
                <script language='javascript' src='/lib/js/opac/result_common.js'> </script>
@@ -15,7 +15,7 @@
        <body onload="init();">
                <xi:include href="header.xml"/> 
                <div id='canvas' class='canvas'>
-                       <xi:include href="login.xml"/> 
+                       <xi:include href="altcanvas.xml"/>
                        <xi:include href="result_common.xml"/>
                </div>
        </body>
index b4d79fe..24a1522 100644 (file)
@@ -6,14 +6,14 @@
 
        <head>
                <title>Evergreen: My OPAC</title>
-               <link rel='stylesheet' type='text/css' href='/css/opac/opac.css'/>
+               <xi:include href="../css_common.xml#xpointer(//link)"/>
                <xi:include href="../js_common.xml"/>
        </head>
 
        <body onload="init();">
                <xi:include href="../header.xml"/> 
                <div id='canvas' class='canvas'>
-                       <xi:include href="../login.xml"/> 
+                       <xi:include href="../altcanvas.xml"/>
                        <div id='canvas_main'>My OPAC Goes Here</div>
                </div>
        </body>
index adca4ae..cc421eb 100644 (file)
@@ -9,29 +9,27 @@
 
                                <!-- talk about the number of hits, etc. -->
                                <td id='result_info_box'>
-                                       <span> Results </span> 
-                                       <span id='offset_start'> </span>
-                                       <span> - </span>
-                                       <span id='offset_end'> </span>
-                                       <span> of </span>
-                                       <span id='result_count'> </span>
-                                       <span> (page </span>
-                                       <span id='current_page'> </span>
-                                       <span> of </span>
-                                       <span id='num_pages'> </span>
-
+                                       <div class='hide_me' id='result_info_div'>
+                                               <span> Results </span> 
+                                               <span id='offset_start'> </span>
+                                               <span> - </span>
+                                               <span id='offset_end'> </span>
+                                               <span> of </span>
+                                               <span id='result_count'> </span>
+                                               <span> (page </span>
+                                               <span id='current_page'> </span>
+                                               <span> of </span>
+                                               <span id='num_pages'> </span>
+                                       </div>
                                </td>
                                
                                <!-- simple next/prev type navigation links -->
                                <td id='next_prev_links'>
-                                       <a id='home_link' title="First results page">Start</a>
-                                       <span> &nbsp; </span>
-                                       <a id='prev_link' title='Previus page'> &lt;&lt; </a>
-                                       <span> </span>
-                                       <span id='page_numbers'> </span>
-                                       <a id='next_link' title='Next Page'> &gt;&gt; </a>
-                                       <span> </span>
-                                       <a id='end_link' title="Last results page">End</a>
+                                       <a class='search_page_nav_link' id='home_link' title="First results page">Start</a>
+                                       <a class='search_page_nav_link' id='prev_link' title='Previus page'> &lt;&lt; </a>
+                                       <span class='search_page_nav_link' id='page_numbers'> </span>
+                                       <a  class='search_page_nav_link' id='next_link' title='Next Page'> &gt;&gt; </a>
+                                       <a  class='search_page_nav_link' id='end_link' title="Last results page">End</a>
                                </td>
 
                        </tr>
@@ -41,7 +39,7 @@
        <!-- Load the result table -->
        <xi:include href="result_table.xml"/>
 
-       <div id='loading_div'>Loading Results ...</div>
+       <div id='loading_div' class='color_1'> Loading Results... </div>
 
 </div>
 
index 18f82bd..11f4eeb 100644 (file)
@@ -6,7 +6,7 @@
 
        <head>
                <title>Evergreen: Titles</title>
-               <link rel='stylesheet' type='text/css' href='/css/opac/opac.css'/>
+               <xi:include href="css_common.xml#xpointer(//link)"/>
                <xi:include href="js_common.xml"/>
                <script language='javascript' src='/lib/js/opac/rresult.js'> </script>
                <script language='javascript' src='/lib/js/opac/result_common.js'> </script>
@@ -15,7 +15,7 @@
        <body onload="init();">
                <xi:include href="header.xml"/> 
                <div id='canvas' class='canvas'>
-                       <xi:include href="login.xml"/> 
+                       <xi:include href="altcanvas.xml"/>
                        <xi:include href="result_common.xml"/>
                </div>
        </body>
index 10c1a97..78c68ea 100644 (file)
@@ -7,7 +7,7 @@
        <!-- load my js -->
        <script language='javascript' src='/lib/js/opac/search_bar.js'> </script>
 
-       <div id='searchbar_main'>
+       <div id='searchbar_main' class='color_1'>
 
                <table>
 
        </div>
 
        <!-- Search location changer -->
-       <span class='searchbar_tag'>
-               <a id='search_location_tag_link' href='javascript:alert("boo");'>
+       <span class='searchbar_tag color_1'>
+               <a id='search_location_tag_link' href='javascript:void(0);'>
                        <span> Search Location </span>
                </a>
        </span>
        
        <!-- Link for expanding/contracting the extra search options -->
-       <span class='searchbar_tag'>
+       <span class='searchbar_tag color_1'>
                <a id='search_tag_link' href='javascript:void(0);'>
                        <span id='searchbar_tag_off'> More Options </span>
                        <span id='searchbar_tag_on' class='hide_me'> Less Options </span>
index 88a2c10..06be024 100644 (file)
@@ -5,7 +5,7 @@
 
 <div id="sidebar_div" class="sidebar_div" xmlns:xi="http://www.w3.org/2001/XInclude">
 
-       <div class='sidebar_chunk'>
+       <div class='sidebar_chunk color_1'>
 
                <div title="&navigate.home.title;" 
                        id='home_link_div' class="side_bar_item">