var COOKIE_SB = "sbe";
var COOKIE_SES = "ses";
var COOKIE_IDS = "ids";
+var COOKIE_FONT = "fnt";
/* these are the actual param values - set on page load */
}
createEvt("common", "init"); /* f() : what happens on page init */
+createEvt("common", "pageRendered"); /* f() : what happens when the page is done (up to the skin to call this even)*/
createEvt("common", "unload"); /* f() : what happens on window unload (clean memory, etc.)*/
createEvt("mresult", "run"); /* f() : kick of the page*/
createEvt("mresult", "idsReceived"); /* f(ids) */
attachEvt("common", "init", loadUIObjects);
attachEvt("common", "init", initParams);
+attachEvt("common", "init", initCookies);
attachEvt("common", "init", drawOrgTree);
attachEvt("common", "unload", _tree_killer);
attachEvt("common", "unload", clearUIObjects);
function init() {
runEvt('common','init');
- scaleFont("medium");
+ setFontSize(getFontSize());
switch(findCurrentPage()) {
case MRESULT: runEvt('mresult', 'run'); break;
case RRESULT: runEvt('rresult', 'run'); break;
/* sets all of the params values ----------------------------- */
var TERM, STYPE, LOCATION, DEPTH, FORM, OFFSET, COUNT,
- HITCOUNT, RANKS, SEARCHBAR_EXTRAS;
+ HITCOUNT, RANKS, SEARCHBAR_EXTRAS, FONTSIZE;
function initParams() {
var cgi = new CGI();
if(isNaN(RID)) RID = 0;
}
+function initCookies() {
+ FONTSIZE = "medium";
+ var font = fontCookie.get(COOKIE_FONT);
+ if(font) FONTSIZE = font;
+}
+
/* URL param accessors */
function getTerm(){return TERM;}
function getStype(){return STYPE;}
function getMrid(){return MRID;};
function getRid(){return RID;};
+function getFontSize(){return FONTSIZE;};
+
/* builds an opac URL. If no page is defined, the current page is used
updateLoc(id, findOrgDepth(id));
}
-
-/* ------------------------------------------------------------------------------------------------------ */
-/* org tree utilities */
-/* ------------------------------------------------------------------------------------------------------ */
-
-/* takes an org unit or id and return the numeric depth */
-function findOrgDepth(org_id_or_node) {
- return findOrgType(findOrgUnit(org_id_or_node).ou_type()).depth();
-}
-
-/* takes the org type id from orgunit.ou_type() field and returns
- the org type object */
-function findOrgType(type_id) {
- if(typeof type_id == 'object') return type_id;
- for(var type in globalOrgTypes) {
- var t =globalOrgTypes[type];
- if( t.id() == type_id || t.id() == parseInt(type_id) )
- return t;
- }
- return null;
+var fontCookie = new cookieObject("fonts", 1, "/", COOKIE_FONT);
+function setFontSize(size) {
+ scaleFonts(size);
+ fontCookie.put(COOKIE_FONT, size);
+ fontCookie.write();
}
-/* returns an org unit by id. if an object is passed in as the id,
- then the object is assumed to be an org unit and is returned */
-function findOrgUnit(org_id) {
- return (typeof org_id == 'object') ? org_id : orgArraySearcher[org_id];
-}
-
-
-/* builds a trail from the top of the org tree to the node provide.
- basically fleshes out 'my orgs'
- Returns an array of [org0, org1, ..., myorg] */
-function orgNodeTrail(node) {
- var na = new Array();
- while( node ) {
- na.push(node);
- node = findOrgUnit(node.parent_ou());
- }
- return na.reverse();
-}
-
-
-/* returns an array of sibling org units */
-function findSiblingOrgs(node) { return findOrgUnit(node.parent_ou()).children(); }
-/* ------------------------------------------------------------------------------------------------------ */
-
function truncate(string, size) {
if(string && size != null &&
size > -1 && string.length > size)
- return string.substr(0, size) + "...";
+ return string.substr(0, size) + "... ";
return string;
}
/* style sheets must have a 'name' attribute for these functions to work */
-function setActiveStyleSheet(name) {
+function setActivateStyleSheet(name) {
var i, a, main;
for (i = 0; (a = document.getElementsByTagName ("link")[i]); i++) {
if (a.getAttribute ("rel").indexOf ("style") != -1 && a.getAttribute ("name")) {
+ a.disabled = true;
if (a.getAttribute ("name").indexOf(name) != -1)
a.disabled = false;
}
}
}
-function swapStyleSheet(newname, oldname) {
- var i, a, main;
- for (i = 0; (a = document.getElementsByTagName ("link")[i]); i++) {
- if (a.getAttribute ("rel").indexOf ("style") != -1 && a.getAttribute ("name")) {
- if (a.getAttribute ("name").indexOf(newsheet) != -1)
- a.disabled = false;
- if (a.getAttribute ("name").indexOf(oldsheet) != -1)
- a.disabled = true;
- }
+
+/* ----------------------------------------------------- */
+function scaleFonts(type) {
+
+ var size = "";
+ switch(type) {
+ case "large": size = "113%"; break;
+ case "small": size = "87%"; break;
}
+
+ document.body.style.fontSize = size;
+ for (i = 0; (a = document.getElementsByTagName ("table")[i]); i++) a.style.fontSize = size;
}
+