lastTokenPos)
lastTokenPos = thisTokenPos;
}
return lastTokenPos;
}
}
Ajax.Autocompleter = Class.create();
Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), {
initialize: function(element, update, url, options) {
this.baseInitialize(element, update, options);
this.options.asynchronous = true;
this.options.onComplete = this.onComplete.bind(this);
this.options.defaultParams = this.options.parameters || null;
this.url = url;
},
getUpdatedChoices: function() {
this.startIndicator();
var entry = encodeURIComponent(this.options.paramName) + '=' +
encodeURIComponent(this.getToken());
this.options.parameters = this.options.callback ?
this.options.callback(this.element, entry) : entry;
if(this.options.defaultParams)
this.options.parameters += '&' + this.options.defaultParams;
new Ajax.Request(this.url, this.options);
},
onComplete: function(request) {
this.updateChoices(request.responseText);
}
});
// The local array autocompleter. Used when you'd prefer to
// inject an array of autocompletion options into the page, rather
// than sending out Ajax queries, which can be quite slow sometimes.
//
// The constructor takes four parameters. The first two are, as usual,
// the id of the monitored textbox, and id of the autocompletion menu.
// The third is the array you want to autocomplete from, and the fourth
// is the options block.
//
// Extra local autocompletion options:
// - choices - How many autocompletion choices to offer
//
// - partialSearch - If false, the autocompleter will match entered
// text only at the beginning of strings in the
// autocomplete array. Defaults to true, which will
// match text at the beginning of any *word* in the
// strings in the autocomplete array. If you want to
// search anywhere in the string, additionally set
// the option fullSearch to true (default: off).
//
// - fullSsearch - Search anywhere in autocomplete array strings.
//
// - partialChars - How many characters to enter before triggering
// a partial match (unlike minChars, which defines
// how many characters are required to do any match
// at all). Defaults to 2.
//
// - ignoreCase - Whether to ignore case when autocompleting.
// Defaults to true.
//
// It's possible to pass in a custom function as the 'selector'
// option, if you prefer to write your own autocompletion logic.
// In that case, the other options above will not apply unless
// you support them.
Autocompleter.Local = Class.create();
Autocompleter.Local.prototype = Object.extend(new Autocompleter.Base(), {
initialize: function(element, update, array, options) {
this.baseInitialize(element, update, options);
this.options.array = array;
},
getUpdatedChoices: function() {
this.updateChoices(this.options.selector(this));
},
setOptions: function(options) {
this.options = Object.extend({
choices: 10,
partialSearch: true,
partialChars: 2,
ignoreCase: true,
fullSearch: false,
selector: function(instance) {
var ret = []; // Beginning matches
var partial = []; // Inside matches
var entry = instance.getToken();
var count = 0;
for (var i = 0; i < instance.options.array.length &&
ret.length < instance.options.choices ; i++) {
var elem = instance.options.array[i];
var foundPos = instance.options.ignoreCase ?
elem.toLowerCase().indexOf(entry.toLowerCase()) :
elem.indexOf(entry);
while (foundPos != -1) {
if (foundPos == 0 && elem.length != entry.length) {
ret.push("" + elem.substr(0, entry.length) + "" +
elem.substr(entry.length) + "");
break;
} else if (entry.length >= instance.options.partialChars &&
instance.options.partialSearch && foundPos != -1) {
if (instance.options.fullSearch || /\s/.test(elem.substr(foundPos-1,1))) {
partial.push("" + elem.substr(0, foundPos) + "" +
elem.substr(foundPos, entry.length) + "" + elem.substr(
foundPos + entry.length) + "");
break;
}
}
foundPos = instance.options.ignoreCase ?
elem.toLowerCase().indexOf(entry.toLowerCase(), foundPos + 1) :
elem.indexOf(entry, foundPos + 1);
}
}
if (partial.length)
ret = ret.concat(partial.slice(0, instance.options.choices - ret.length))
return "";
}
}, options || {});
}
});
// AJAX in-place editor
//
// see documentation on http://wiki.script.aculo.us/scriptaculous/show/Ajax.InPlaceEditor
// Use this if you notice weird scrolling problems on some browsers,
// the DOM might be a bit confused when this gets called so do this
// waits 1 ms (with setTimeout) until it does the activation
Field.scrollFreeActivate = function(field) {
setTimeout(function() {
Field.activate(field);
}, 1);
}
Ajax.InPlaceEditor = Class.create();
Ajax.InPlaceEditor.defaultHighlightColor = "#FFFF99";
Ajax.InPlaceEditor.prototype = {
initialize: function(element, url, options) {
this.url = url;
this.element = $(element);
this.options = Object.extend({
paramName: "value",
okButton: true,
okLink: false,
okText: "ok",
cancelButton: false,
cancelLink: true,
cancelText: "cancel",
textBeforeControls: '',
textBetweenControls: '',
textAfterControls: '',
savingText: "Saving...",
clickToEditText: "Click to edit",
okText: "ok",
rows: 1,
onComplete: function(transport, element) {
new Effect.Highlight(element, {startcolor: this.options.highlightcolor});
},
onFailure: function(transport) {
alert("Error communicating with the server: " + transport.responseText.stripTags());
},
callback: function(form) {
return Form.serialize(form);
},
handleLineBreaks: true,
loadingText: 'Loading...',
savingClassName: 'inplaceeditor-saving',
loadingClassName: 'inplaceeditor-loading',
formClassName: 'inplaceeditor-form',
highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor,
highlightendcolor: "#FFFFFF",
externalControl: null,
submitOnBlur: false,
ajaxOptions: {},
evalScripts: false
}, options || {});
if(!this.options.formId && this.element.id) {
this.options.formId = this.element.id + "-inplaceeditor";
if ($(this.options.formId)) {
// there's already a form with that name, don't specify an id
this.options.formId = null;
}
}
if (this.options.externalControl) {
this.options.externalControl = $(this.options.externalControl);
}
this.originalBackground = Element.getStyle(this.element, 'background-color');
if (!this.originalBackground) {
this.originalBackground = "transparent";
}
this.element.title = this.options.clickToEditText;
this.onclickListener = this.enterEditMode.bindAsEventListener(this);
this.mouseoverListener = this.enterHover.bindAsEventListener(this);
this.mouseoutListener = this.leaveHover.bindAsEventListener(this);
Event.observe(this.element, 'click', this.onclickListener);
Event.observe(this.element, 'mouseover', this.mouseoverListener);
Event.observe(this.element, 'mouseout', this.mouseoutListener);
if (this.options.externalControl) {
Event.observe(this.options.externalControl, 'click', this.onclickListener);
Event.observe(this.options.externalControl, 'mouseover', this.mouseoverListener);
Event.observe(this.options.externalControl, 'mouseout', this.mouseoutListener);
}
},
enterEditMode: function(evt) {
if (this.saving) return;
if (this.editing) return;
this.editing = true;
this.onEnterEditMode();
if (this.options.externalControl) {
Element.hide(this.options.externalControl);
}
Element.hide(this.element);
this.createForm();
this.element.parentNode.insertBefore(this.form, this.element);
if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField);
// stop the event to avoid a page refresh in Safari
if (evt) {
Event.stop(evt);
}
return false;
},
createForm: function() {
this.form = document.createElement("form");
this.form.id = this.options.formId;
Element.addClassName(this.form, this.options.formClassName)
this.form.onsubmit = this.onSubmit.bind(this);
this.createEditField();
if (this.options.textarea) {
var br = document.createElement("br");
this.form.appendChild(br);
}
if (this.options.textBeforeControls)
this.form.appendChild(document.createTextNode(this.options.textBeforeControls));
if (this.options.okButton) {
var okButton = document.createElement("input");
okButton.type = "submit";
okButton.value = this.options.okText;
okButton.className = 'editor_ok_button';
this.form.appendChild(okButton);
}
if (this.options.okLink) {
var okLink = document.createElement("a");
okLink.href="http://anonymouse.org/cgi-bin/anon-www.cgi/http://www.oprah.com/community/resources/merge|global|;jsessionid=ac11087930d5c357f3c3e9a04348a426b4452b947645.e38KbxqSbxiNe34KaO0#";
okLink.appendChild(document.createTextNode(this.options.okText));
okLink.onclick = this.onSubmit.bind(this);
okLink.className = 'editor_ok_link';
this.form.appendChild(okLink);
}
if (this.options.textBetweenControls &&
(this.options.okLink || this.options.okButton) &&
(this.options.cancelLink || this.options.cancelButton))
this.form.appendChild(document.createTextNode(this.options.textBetweenControls));
if (this.options.cancelButton) {
var cancelButton = document.createElement("input");
cancelButton.type = "submit";
cancelButton.value = this.options.cancelText;
cancelButton.onclick = this.onclickCancel.bind(this);
cancelButton.className = 'editor_cancel_button';
this.form.appendChild(cancelButton);
}
if (this.options.cancelLink) {
var cancelLink = document.createElement("a");
cancelLink.href="http://anonymouse.org/cgi-bin/anon-www.cgi/http://www.oprah.com/community/resources/merge|global|;jsessionid=ac11087930d5c357f3c3e9a04348a426b4452b947645.e38KbxqSbxiNe34KaO0#";
cancelLink.appendChild(document.createTextNode(this.options.cancelText));
cancelLink.onclick = this.onclickCancel.bind(this);
cancelLink.className = 'editor_cancel editor_cancel_link';
this.form.appendChild(cancelLink);
}
if (this.options.textAfterControls)
this.form.appendChild(document.createTextNode(this.options.textAfterControls));
},
hasHTMLLineBreaks: function(string) {
if (!this.options.handleLineBreaks) return false;
return string.match(/
/i);
},
convertHTMLLineBreaks: function(string) {
return string.replace(/
/gi, "\n").replace(/
/gi, "\n").replace(/<\/p>/gi, "\n").replace(//gi, "");
},
createEditField: function() {
var text;
if(this.options.loadTextURL) {
text = this.options.loadingText;
} else {
text = this.getText();
}
var obj = this;
if (this.options.rows == 1 && !this.hasHTMLLineBreaks(text)) {
this.options.textarea = false;
var textField = document.createElement("input");
textField.obj = this;
textField.type = "text";
textField.name = this.options.paramName;
textField.value = text;
textField.style.backgroundColor = this.options.highlightcolor;
textField.className = 'editor_field';
var size = this.options.size || this.options.cols || 0;
if (size != 0) textField.size = size;
if (this.options.submitOnBlur)
textField.onblur = this.onSubmit.bind(this);
this.editField = textField;
} else {
this.options.textarea = true;
var textArea = document.createElement("textarea");
textArea.obj = this;
textArea.name = this.options.paramName;
textArea.value = this.convertHTMLLineBreaks(text);
textArea.rows = this.options.rows;
textArea.cols = this.options.cols || 40;
textArea.className = 'editor_field';
if (this.options.submitOnBlur)
textArea.onblur = this.onSubmit.bind(this);
this.editField = textArea;
}
if(this.options.loadTextURL) {
this.loadExternalText();
}
this.form.appendChild(this.editField);
},
getText: function() {
return this.element.innerHTML;
},
loadExternalText: function() {
Element.addClassName(this.form, this.options.loadingClassName);
this.editField.disabled = true;
new Ajax.Request(
this.options.loadTextURL,
Object.extend({
asynchronous: true,
onComplete: this.onLoadedExternalText.bind(this)
}, this.options.ajaxOptions)
);
},
onLoadedExternalText: function(transport) {
Element.removeClassName(this.form, this.options.loadingClassName);
this.editField.disabled = false;
this.editField.value = transport.responseText.stripTags();
Field.scrollFreeActivate(this.editField);
},
onclickCancel: function() {
this.onComplete();
this.leaveEditMode();
return false;
},
onFailure: function(transport) {
this.options.onFailure(transport);
if (this.oldInnerHTML) {
this.element.innerHTML = this.oldInnerHTML;
this.oldInnerHTML = null;
}
return false;
},
onSubmit: function() {
// onLoading resets these so we need to save them away for the Ajax call
var form = this.form;
var value = this.editField.value;
// do this first, sometimes the ajax call returns before we get a chance to switch on Saving...
// which means this will actually switch on Saving... *after* we've left edit mode causing Saving...
// to be displayed indefinitely
this.onLoading();
if (this.options.evalScripts) {
new Ajax.Request(
this.url, Object.extend({
parameters: this.options.callback(form, value),
onComplete: this.onComplete.bind(this),
onFailure: this.onFailure.bind(this),
asynchronous:true,
evalScripts:true
}, this.options.ajaxOptions));
} else {
new Ajax.Updater(
{ success: this.element,
// don't update on failure (this could be an option)
failure: null },
this.url, Object.extend({
parameters: this.options.callback(form, value),
onComplete: this.onComplete.bind(this),
onFailure: this.onFailure.bind(this)
}, this.options.ajaxOptions));
}
// stop the event to avoid a page refresh in Safari
if (arguments.length > 1) {
Event.stop(arguments[0]);
}
return false;
},
onLoading: function() {
this.saving = true;
this.removeForm();
this.leaveHover();
this.showSaving();
},
showSaving: function() {
this.oldInnerHTML = this.element.innerHTML;
this.element.innerHTML = this.options.savingText;
Element.addClassName(this.element, this.options.savingClassName);
this.element.style.backgroundColor = this.originalBackground;
Element.show(this.element);
},
removeForm: function() {
if(this.form) {
if (this.form.parentNode) Element.remove(this.form);
this.form = null;
}
},
enterHover: function() {
if (this.saving) return;
this.element.style.backgroundColor = this.options.highlightcolor;
if (this.effect) {
this.effect.cancel();
}
Element.addClassName(this.element, this.options.hoverClassName)
},
leaveHover: function() {
if (this.options.backgroundColor) {
this.element.style.backgroundColor = this.oldBackground;
}
Element.removeClassName(this.element, this.options.hoverClassName)
if (this.saving) return;
this.effect = new Effect.Highlight(this.element, {
startcolor: this.options.highlightcolor,
endcolor: this.options.highlightendcolor,
restorecolor: this.originalBackground
});
},
leaveEditMode: function() {
Element.removeClassName(this.element, this.options.savingClassName);
this.removeForm();
this.leaveHover();
this.element.style.backgroundColor = this.originalBackground;
Element.show(this.element);
if (this.options.externalControl) {
Element.show(this.options.externalControl);
}
this.editing = false;
this.saving = false;
this.oldInnerHTML = null;
this.onLeaveEditMode();
},
onComplete: function(transport) {
this.leaveEditMode();
this.options.onComplete.bind(this)(transport, this.element);
},
onEnterEditMode: function() {},
onLeaveEditMode: function() {},
dispose: function() {
if (this.oldInnerHTML) {
this.element.innerHTML = this.oldInnerHTML;
}
this.leaveEditMode();
Event.stopObserving(this.element, 'click', this.onclickListener);
Event.stopObserving(this.element, 'mouseover', this.mouseoverListener);
Event.stopObserving(this.element, 'mouseout', this.mouseoutListener);
if (this.options.externalControl) {
Event.stopObserving(this.options.externalControl, 'click', this.onclickListener);
Event.stopObserving(this.options.externalControl, 'mouseover', this.mouseoverListener);
Event.stopObserving(this.options.externalControl, 'mouseout', this.mouseoutListener);
}
}
};
Ajax.InPlaceCollectionEditor = Class.create();
Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype);
Object.extend(Ajax.InPlaceCollectionEditor.prototype, {
createEditField: function() {
if (!this.cached_selectTag) {
var selectTag = document.createElement("select");
var collection = this.options.collection || [];
var optionTag;
collection.each(function(e,i) {
optionTag = document.createElement("option");
optionTag.value = (e instanceof Array) ? e[0] : e;
if((typeof this.options.value == 'undefined') &&
((e instanceof Array) ? this.element.innerHTML == e[1] : e == optionTag.value)) optionTag.selected = true;
if(this.options.value==optionTag.value) optionTag.selected = true;
optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e));
selectTag.appendChild(optionTag);
}.bind(this));
this.cached_selectTag = selectTag;
}
this.editField = this.cached_selectTag;
if(this.options.loadTextURL) this.loadExternalText();
this.form.appendChild(this.editField);
this.options.callback = function(form, value) {
return "value=" + encodeURIComponent(value);
}
}
});
// Delayed observer, like Form.Element.Observer,
// but waits for delay after last key input
// Ideal for live-search fields
Form.Element.DelayedObserver = Class.create();
Form.Element.DelayedObserver.prototype = {
initialize: function(element, delay, callback) {
this.delay = delay || 0.5;
this.element = $(element);
this.callback = callback;
this.timer = null;
this.lastValue = $F(this.element);
Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this));
},
delayedListener: function(event) {
if(this.lastValue == $F(this.element)) return;
if(this.timer) clearTimeout(this.timer);
this.timer = setTimeout(this.onTimerEvent.bind(this), this.delay * 1000);
this.lastValue = $F(this.element);
},
onTimerEvent: function() {
this.timer = null;
this.callback(this.element, $F(this.element));
}
};
/** $Id: domLib.js 2321 2006-06-12 06:45:41Z dallen $ */
// {{{ license
/*
* Copyright 2002-2005 Dan Allen, Mojavelinux.com (dan.allen@mojavelinux.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// }}}
// {{{ intro
/**
* Title: DOM Library Core
* Version: 0.70
*
* Summary:
* A set of commonly used functions that make it easier to create javascript
* applications that rely on the DOM.
*
* Updated: 2005/05/17
*
* Maintainer: Dan Allen
* Maintainer: Jason Rust
*
* License: Apache 2.0
*/
// }}}
// {{{ global constants (DO NOT EDIT)
// -- Browser Detection --
var domLib_userAgent = navigator.userAgent.toLowerCase();
var domLib_isMac = navigator.appVersion.indexOf('Mac') != -1;
var domLib_isWin = domLib_userAgent.indexOf('windows') != -1;
// NOTE: could use window.opera for detecting Opera
var domLib_isOpera = domLib_userAgent.indexOf('opera') != -1;
var domLib_isOpera7up = domLib_userAgent.match(/opera.(7|8)/i);
var domLib_isSafari = domLib_userAgent.indexOf('safari') != -1;
var domLib_isKonq = domLib_userAgent.indexOf('konqueror') != -1;
// Both konqueror and safari use the khtml rendering engine
var domLib_isKHTML = (domLib_isKonq || domLib_isSafari || domLib_userAgent.indexOf('khtml') != -1);
var domLib_isIE = (!domLib_isKHTML && !domLib_isOpera && (domLib_userAgent.indexOf('msie 5') != -1 || domLib_userAgent.indexOf('msie 6') != -1 || domLib_userAgent.indexOf('msie 7') != -1));
var domLib_isIE5up = domLib_isIE;
var domLib_isIE50 = (domLib_isIE && domLib_userAgent.indexOf('msie 5.0') != -1);
var domLib_isIE55 = (domLib_isIE && domLib_userAgent.indexOf('msie 5.5') != -1);
var domLib_isIE5 = (domLib_isIE50 || domLib_isIE55);
// safari and konq may use string "khtml, like gecko", so check for destinctive /
var domLib_isGecko = domLib_userAgent.indexOf('gecko/') != -1;
var domLib_isMacIE = (domLib_isIE && domLib_isMac);
var domLib_isIE55up = domLib_isIE5up && !domLib_isIE50 && !domLib_isMacIE;
var domLib_isIE6up = domLib_isIE55up && !domLib_isIE55;
// -- Browser Abilities --
var domLib_standardsMode = (document.compatMode && document.compatMode == 'CSS1Compat');
var domLib_useLibrary = (domLib_isOpera7up || domLib_isKHTML || domLib_isIE5up || domLib_isGecko || domLib_isMacIE || document.defaultView);
// fixed in Konq3.2
var domLib_hasBrokenTimeout = (domLib_isMacIE || (domLib_isKonq && domLib_userAgent.match(/konqueror\/3.([2-9])/) == null));
var domLib_canFade = (domLib_isGecko || domLib_isIE || domLib_isSafari || domLib_isOpera);
var domLib_canDrawOverSelect = (domLib_isMac || domLib_isOpera || domLib_isGecko);
var domLib_canDrawOverFlash = (domLib_isMac || domLib_isWin);
// -- Event Variables --
var domLib_eventTarget = domLib_isIE ? 'srcElement' : 'currentTarget';
var domLib_eventButton = domLib_isIE ? 'button' : 'which';
var domLib_eventTo = domLib_isIE ? 'toElement' : 'relatedTarget';
var domLib_stylePointer = domLib_isIE ? 'hand' : 'pointer';
// NOTE: a bug exists in Opera that prevents maxWidth from being set to 'none', so we make it huge
var domLib_styleNoMaxWidth = domLib_isOpera ? '10000px' : 'none';
var domLib_hidePosition = '-1000px';
var domLib_scrollbarWidth = 14;
var domLib_autoId = 1;
var domLib_zIndex = 100;
// -- Detection --
var domLib_collisionElements;
var domLib_collisionsCached = false;
var domLib_timeoutStateId = 0;
var domLib_timeoutStates = new DomLibHash();
// }}}
// {{{ DOM enhancements
if (!document.ELEMENT_NODE)
{
document.ELEMENT_NODE = 1;
document.ATTRIBUTE_NODE = 2;
document.TEXT_NODE = 3;
document.DOCUMENT_NODE = 9;
document.DOCUMENT_FRAGMENT_NODE = 11;
}
function domLib_clone(obj)
{
var copy = {};
for (var i in obj)
{
var value = obj[i];
try
{
if (value != null && typeof(value) == 'object' && value != window && !value.nodeType)
{
copy[i] = domLib_clone(value);
}
else
{
copy[i] = value;
}
}
catch(e)
{
copy[i] = value;
}
}
return copy;
}
// }}}
// {{{ class DomLibHash()
function DomLibHash()
{
this.length = 0;
this.numericLength = 0;
this.elementData = [];
for (var i = 0; i < arguments.length; i += 2)
{
if (typeof(arguments[i + 1]) != 'undefined')
{
this.elementData[arguments[i]] = arguments[i + 1];
this.length++;
if (arguments[i] == parseInt(arguments[i]))
{
this.numericLength++;
}
}
}
}
// using prototype as opposed to inner functions saves on memory
DomLibHash.prototype.get = function(in_key)
{
if (typeof(this.elementData[in_key]) != 'undefined') {
return this.elementData[in_key];
}
return null;
}
DomLibHash.prototype.set = function(in_key, in_value)
{
if (typeof(in_value) != 'undefined')
{
if (typeof(this.elementData[in_key]) == 'undefined')
{
this.length++;
if (in_key == parseInt(in_key))
{
this.numericLength++;
}
}
return this.elementData[in_key] = in_value;
}
return false;
}
DomLibHash.prototype.remove = function(in_key)
{
var tmp_value;
if (typeof(this.elementData[in_key]) != 'undefined')
{
this.length--;
if (in_key == parseInt(in_key))
{
this.numericLength--;
}
tmp_value = this.elementData[in_key];
delete this.elementData[in_key];
}
return tmp_value;
}
DomLibHash.prototype.size = function()
{
return this.length;
}
DomLibHash.prototype.has = function(in_key)
{
return typeof(this.elementData[in_key]) != 'undefined';
}
DomLibHash.prototype.find = function(in_obj)
{
for (var tmp_key in this.elementData)
{
if (this.elementData[tmp_key] == in_obj)
{
return tmp_key;
}
}
return null;
}
DomLibHash.prototype.merge = function(in_hash)
{
for (var tmp_key in in_hash.elementData)
{
if (typeof(this.elementData[tmp_key]) == 'undefined')
{
this.length++;
if (tmp_key == parseInt(tmp_key))
{
this.numericLength++;
}
}
this.elementData[tmp_key] = in_hash.elementData[tmp_key];
}
}
DomLibHash.prototype.compare = function(in_hash)
{
if (this.length != in_hash.length)
{
return false;
}
for (var tmp_key in this.elementData)
{
if (this.elementData[tmp_key] != in_hash.elementData[tmp_key])
{
return false;
}
}
return true;
}
// }}}
// {{{ domLib_isDescendantOf()
function domLib_isDescendantOf(in_object, in_ancestor, in_bannedTags)
{
if (in_object == null)
{
return false;
}
if (in_object == in_ancestor)
{
return true;
}
if (typeof(in_bannedTags) != 'undefined' &&
(',' + in_bannedTags.join(',') + ',').indexOf(',' + in_object.tagName + ',') != -1)
{
return false;
}
while (in_object != document.documentElement)
{
try
{
if ((tmp_object = in_object.offsetParent) && tmp_object == in_ancestor)
{
return true;
}
else if ((tmp_object = in_object.parentNode) == in_ancestor)
{
return true;
}
else
{
in_object = tmp_object;
}
}
// in case we get some wierd error, assume we left the building
catch(e)
{
return false;
}
}
return false;
}
// }}}
// {{{ domLib_detectCollisions()
/**
* For any given target element, determine if elements on the page
* are colliding with it that do not obey the rules of z-index.
*/
function domLib_detectCollisions(in_object, in_recover, in_useCache)
{
// the reason for the cache is that if the root menu is built before
// the page is done loading, then it might not find all the elements.
// so really the only time you don't use cache is when building the
// menu as part of the page load
if (!domLib_collisionsCached)
{
var tags = [];
if (!domLib_canDrawOverFlash)
{
tags[tags.length] = 'object';
}
if (!domLib_canDrawOverSelect)
{
tags[tags.length] = 'select';
}
domLib_collisionElements = domLib_getElementsByTagNames(tags, true);
domLib_collisionsCached = in_useCache;
}
// if we don't have a tip, then unhide selects
if (in_recover)
{
for (var cnt = 0; cnt < domLib_collisionElements.length; cnt++)
{
var thisElement = domLib_collisionElements[cnt];
if (!thisElement.hideList)
{
thisElement.hideList = new DomLibHash();
}
thisElement.hideList.remove(in_object.id);
if (!thisElement.hideList.length)
{
domLib_collisionElements[cnt].style.visibility = 'visible';
if (domLib_isKonq)
{
domLib_collisionElements[cnt].style.display = '';
}
}
}
return;
}
else if (domLib_collisionElements.length == 0)
{
return;
}
// okay, we have a tip, so hunt and destroy
var objectOffsets = domLib_getOffsets(in_object);
for (var cnt = 0; cnt < domLib_collisionElements.length; cnt++)
{
var thisElement = domLib_collisionElements[cnt];
// if collision element is in active element, move on
// WARNING: is this too costly?
if (domLib_isDescendantOf(thisElement, in_object))
{
continue;
}
// konqueror only has trouble with multirow selects
if (domLib_isKonq &&
thisElement.tagName == 'SELECT' &&
(thisElement.size <= 1 && !thisElement.multiple))
{
continue;
}
if (!thisElement.hideList)
{
thisElement.hideList = new DomLibHash();
}
var selectOffsets = domLib_getOffsets(thisElement);
var center2centerDistance = Math.sqrt(Math.pow(selectOffsets.get('leftCenter') - objectOffsets.get('leftCenter'), 2) + Math.pow(selectOffsets.get('topCenter') - objectOffsets.get('topCenter'), 2));
var radiusSum = selectOffsets.get('radius') + objectOffsets.get('radius');
// the encompassing circles are overlapping, get in for a closer look
if (center2centerDistance < radiusSum)
{
// tip is left of select
if ((objectOffsets.get('leftCenter') <= selectOffsets.get('leftCenter') && objectOffsets.get('right') < selectOffsets.get('left')) ||
// tip is right of select
(objectOffsets.get('leftCenter') > selectOffsets.get('leftCenter') && objectOffsets.get('left') > selectOffsets.get('right')) ||
// tip is above select
(objectOffsets.get('topCenter') <= selectOffsets.get('topCenter') && objectOffsets.get('bottom') < selectOffsets.get('top')) ||
// tip is below select
(objectOffsets.get('topCenter') > selectOffsets.get('topCenter') && objectOffsets.get('top') > selectOffsets.get('bottom')))
{
thisElement.hideList.remove(in_object.id);
if (!thisElement.hideList.length)
{
thisElement.style.visibility = 'visible';
if (domLib_isKonq)
{
thisElement.style.display = '';
}
}
}
else
{
thisElement.hideList.set(in_object.id, true);
thisElement.style.visibility = 'hidden';
if (domLib_isKonq)
{
thisElement.style.display = 'none';
}
}
}
}
}
// }}}
// {{{ domLib_getOffsets()
function domLib_getOffsets(in_object, in_preserveScroll)
{
if (typeof(in_preserveScroll) == 'undefined') {
in_preserveScroll = false;
}
var originalObject = in_object;
var originalWidth = in_object.offsetWidth;
var originalHeight = in_object.offsetHeight;
var offsetLeft = 0;
var offsetTop = 0;
while (in_object)
{
offsetLeft += in_object.offsetLeft;
offsetTop += in_object.offsetTop;
in_object = in_object.offsetParent;
// consider scroll offset of parent elements
if (in_object && !in_preserveScroll)
{
offsetLeft -= in_object.scrollLeft;
offsetTop -= in_object.scrollTop;
}
}
// MacIE misreports the offsets (even with margin: 0 in body{}), still not perfect
if (domLib_isMacIE) {
offsetLeft += 10;
offsetTop += 10;
}
return new DomLibHash(
'left', offsetLeft,
'top', offsetTop,
'right', offsetLeft + originalWidth,
'bottom', offsetTop + originalHeight,
'leftCenter', offsetLeft + originalWidth/2,
'topCenter', offsetTop + originalHeight/2,
'radius', Math.max(originalWidth, originalHeight)
);
}
// }}}
// {{{ domLib_setTimeout()
function domLib_setTimeout(in_function, in_timeout, in_args)
{
if (typeof(in_args) == 'undefined')
{
in_args = [];
}
if (in_timeout == -1)
{
// timeout event is disabled
return 0;
}
else if (in_timeout == 0)
{
in_function(in_args);
return 0;
}
// must make a copy of the arguments so that we release the reference
var args = domLib_clone(in_args);
if (!domLib_hasBrokenTimeout)
{
return setTimeout(function() { in_function(args); }, in_timeout);
}
else
{
var id = domLib_timeoutStateId++;
var data=http://anonymouse.org/cgi-bin/anon-www.cgi/http://www.oprah.com/community/resources/new DomLibHash();
data.set('function', in_function);
data.set('args', args);
domLib_timeoutStates.set(id, data);
data.set('timeoutId', setTimeout('domLib_timeoutStates.get(' + id + ').get(\'function\')(domLib_timeoutStates.get(' + id + ').get(\'args\')); domLib_timeoutStates.remove(' + id + ');', in_timeout));
return id;
}
}
// }}}
// {{{ domLib_clearTimeout()
function domLib_clearTimeout(in_id)
{
if (!domLib_hasBrokenTimeout)
{
if (in_id > 0) {
clearTimeout(in_id);
}
}
else
{
if (domLib_timeoutStates.has(in_id))
{
clearTimeout(domLib_timeoutStates.get(in_id).get('timeoutId'))
domLib_timeoutStates.remove(in_id);
}
}
}
// }}}
// {{{ domLib_getEventPosition()
function domLib_getEventPosition(in_eventObj)
{
var eventPosition = new DomLibHash('x', 0, 'y', 0, 'scrollX', 0, 'scrollY', 0);
// IE varies depending on standard compliance mode
if (domLib_isIE)
{
var doc = (domLib_standardsMode ? document.documentElement : document.body);
// NOTE: events may fire before the body has been loaded
if (doc)
{
eventPosition.set('x', in_eventObj.clientX + doc.scrollLeft);
eventPosition.set('y', in_eventObj.clientY + doc.scrollTop);
eventPosition.set('scrollX', doc.scrollLeft);
eventPosition.set('scrollY', doc.scrollTop);
}
}
else
{
eventPosition.set('x', in_eventObj.pageX);
eventPosition.set('y', in_eventObj.pageY);
eventPosition.set('scrollX', in_eventObj.pageX - in_eventObj.clientX);
eventPosition.set('scrollY', in_eventObj.pageY - in_eventObj.clientY);
}
return eventPosition;
}
// }}}
// {{{ domLib_cancelBubble()
function domLib_cancelBubble(in_event)
{
var eventObj = in_event ? in_event : window.event;
eventObj.cancelBubble = true;
}
// }}}
// {{{ domLib_getIFrameReference()
function domLib_getIFrameReference(in_frame)
{
if (domLib_isGecko || domLib_isIE)
{
return in_frame.frameElement;
}
else
{
// we could either do it this way or require an id on the frame
// equivalent to the name
var name = in_frame.name;
if (!name || !in_frame.parent)
{
return null;
}
var candidates = in_frame.parent.document.getElementsByTagName('iframe');
for (var i = 0; i < candidates.length; i++)
{
if (candidates[i].name == name)
{
return candidates[i];
}
}
return null;
}
}
// }}}
// {{{ domLib_getElementsByClass()
function domLib_getElementsByClass(in_class)
{
var elements = domLib_isIE5 ? document.all : document.getElementsByTagName('*');
var matches = [];
var cnt = 0;
for (var i = 0; i < elements.length; i++)
{
if ((" " + elements[i].className + " ").indexOf(" " + in_class + " ") != -1)
{
matches[cnt++] = elements[i];
}
}
return matches;
}
// }}}
// {{{ domLib_getElementsByTagNames()
function domLib_getElementsByTagNames(in_list, in_excludeHidden)
{
var elements = [];
for (var i = 0; i < in_list.length; i++)
{
var matches = document.getElementsByTagName(in_list[i]);
for (var j = 0; j < matches.length; j++)
{
// skip objects that have nested embeds, or else we get "flashing"
if (matches[j].tagName == 'OBJECT' && domLib_isGecko)
{
var kids = matches[j].childNodes;
var skip = false;
for (var k = 0; k < kids.length; k++)
{
if (kids[k].tagName == 'EMBED')
{
skip = true;
break;
}
}
if (skip) continue;
}
if (in_excludeHidden && domLib_getComputedStyle(matches[j], 'visibility') == 'hidden')
{
continue;
}
elements[elements.length] = matches[j];
}
}
return elements;
}
// }}}
// {{{ domLib_getComputedStyle()
function domLib_getComputedStyle(in_obj, in_property)
{
if (domLib_isIE)
{
var humpBackProp = in_property.replace(/-(.)/, function (a, b) { return b.toUpperCase(); });
return eval('in_obj.currentStyle.' + humpBackProp);
}
// getComputedStyle() is broken in konqueror, so let's go for the style object
else if (domLib_isKonq)
{
//var humpBackProp = in_property.replace(/-(.)/, function (a, b) { return b.toUpperCase(); });
return eval('in_obj.style.' + in_property);
}
else
{
return document.defaultView.getComputedStyle(in_obj, null).getPropertyValue(in_property);
}
}
// }}}
// {{{ makeTrue()
function makeTrue()
{
return true;
}
// }}}
// {{{ makeFalse()
function makeFalse()
{
return false;
}
// }}}
/** $Id: domTT.js 2324 2006-06-12 07:06:39Z dallen $ */
// {{{ license
/*
* Copyright 2002-2005 Dan Allen, Mojavelinux.com (dan.allen@mojavelinux.com)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// }}}
// {{{ intro
/**
* Title: DOM Tooltip Library
* Version: 0.7.3
*
* Summary:
* Allows developers to add custom tooltips to the webpages. Tooltips are
* generated using the domTT_activate() function and customized by setting
* a handful of options.
*
* Maintainer: Dan Allen
* Contributors:
* Josh Gross
* Jason Rust
*
* License: Apache 2.0
* However, if you use this library, you earn the position of official bug
* reporter :) Please post questions or problem reports to the newsgroup:
*
* http://groups-beta.google.com/group/dom-tooltip
*
* If you are doing this for commercial work, perhaps you could send me a few
* Starbucks Coffee gift dollars or PayPal bucks to encourage future
* developement (NOT REQUIRED). E-mail me for my snail mail address.
*
* Homepage: http://www.mojavelinux.com/projects/domtooltip/
*
* Newsgroup: http://groups-beta.google.com/group/dom-tooltip
*
* Freshmeat Project: http://freshmeat.net/projects/domtt/?topic_id=92
*
* Updated: 2005/07/16
*
* Supported Browsers:
* Mozilla (Gecko), IE 5.5+, IE on Mac, Safari, Konqueror, Opera 7
*
* Usage:
* Please see the HOWTO documentation.
**/
// }}}
// {{{ settings (editable)
// IE mouse events seem to be off by 2 pixels
var domTT_offsetX = (domLib_isIE ? -2 : 0);
var domTT_offsetY = (domLib_isIE ? 4 : 2);
var domTT_direction = 'southeast';
var domTT_mouseHeight = domLib_isIE ? 13 : 19;
var domTT_closeLink = 'X';
var domTT_closeAction = 'hide';
var domTT_activateDelay = 500;
var domTT_maxWidth = false;
var domTT_styleClass = 'domTT';
var domTT_fade = 'neither';
var domTT_lifetime = 0;
var domTT_grid = 0;
var domTT_trailDelay = 200;
var domTT_useGlobalMousePosition = true;
var domTT_postponeActivation = false;
var domTT_tooltipIdPrefix = '[domTT]';
var domTT_screenEdgeDetection = true;
var domTT_screenEdgePadding = 4;
var domTT_oneOnly = false;
var domTT_cloneNodes = false;
var domTT_detectCollisions = true;
var domTT_bannedTags = ['OPTION'];
var domTT_draggable = false;
if (typeof(domTT_dragEnabled) == 'undefined')
{
domTT_dragEnabled = false;
}
// }}}
// {{{ globals (DO NOT EDIT)
var domTT_predefined = new DomLibHash();
// tooltips are keyed on both the tip id and the owner id,
// since events can originate on either object
var domTT_tooltips = new DomLibHash();
var domTT_lastOpened = 0;
var domTT_documentLoaded = false;
var domTT_mousePosition = null;
// }}}
// {{{ document.onmousemove
if (domLib_useLibrary && domTT_useGlobalMousePosition)
{
document.onmousemove = function(in_event)
{
if (typeof(in_event) == 'undefined') { in_event = window.event; }
domTT_mousePosition = domLib_getEventPosition(in_event);
if (domTT_dragEnabled && domTT_dragMouseDown)
{
domTT_dragUpdate(in_event);
}
}
}
// }}}
// {{{ domTT_activate()
function domTT_activate(in_this, in_event)
{
if (!domLib_useLibrary || (domTT_postponeActivation && !domTT_documentLoaded)) { return false; }
// make sure in_event is set (for IE, some cases we have to use window.event)
if (typeof(in_event) == 'undefined') { in_event = window.event; }
// don't allow tooltips on banned tags (such as OPTION)
if (in_event != null) {
var target = in_event.srcElement ? in_event.srcElement : in_event.target;
if (target != null && (',' + domTT_bannedTags.join(',') + ',').indexOf(',' + target.tagName + ',') != -1)
{
return false;
}
}
var owner = document.body;
// we have an active event so get the owner
if (in_event != null && in_event.type.match(/key|mouse|click|contextmenu/i))
{
// make sure we have nothing higher than the body element
if (in_this.nodeType && in_this.nodeType != document.DOCUMENT_NODE)
{
owner = in_this;
}
}
// non active event (make sure we were passed a string id)
else
{
if (typeof(in_this) != 'object' && !(owner = domTT_tooltips.get(in_this)))
{
// NOTE: two steps to avoid "flashing" in gecko
var embryo = document.createElement('div');
owner = document.body.appendChild(embryo);
owner.style.display = 'none';
owner.id = in_this;
}
}
// make sure the owner has a unique id
if (!owner.id)
{
owner.id = '__autoId' + domLib_autoId++;
}
// see if we should only be opening one tip at a time
// NOTE: this is not "perfect" yet since it really steps on any other
// tip working on fade out or delayed close, but it get's the job done
if (domTT_oneOnly && domTT_lastOpened)
{
domTT_deactivate(domTT_lastOpened);
}
domTT_lastOpened = owner.id;
var tooltip = domTT_tooltips.get(owner.id);
if (tooltip)
{
if (tooltip.get('eventType') != in_event.type)
{
if (tooltip.get('type') == 'greasy')
{
tooltip.set('closeAction', 'destroy');
domTT_deactivate(owner.id);
}
else if (tooltip.get('status') != 'inactive')
{
return owner.id;
}
}
else
{
if (tooltip.get('status') == 'inactive')
{
tooltip.set('status', 'pending');
tooltip.set('activateTimeout', domLib_setTimeout(domTT_runShow, tooltip.get('delay'), [owner.id, in_event]));
return owner.id;
}
// either pending or active, let it be
else
{
return owner.id;
}
}
}
// setup the default options hash
var options = new DomLibHash(
'caption', '',
'content', '',
'clearMouse', true,
'closeAction', domTT_closeAction,
'closeLink', domTT_closeLink,
'delay', domTT_activateDelay,
'direction', domTT_direction,
'draggable', domTT_draggable,
'fade', domTT_fade,
'fadeMax', 100,
'grid', domTT_grid,
'id', domTT_tooltipIdPrefix + owner.id,
'inframe', false,
'lifetime', domTT_lifetime,
'offsetX', domTT_offsetX,
'offsetY', domTT_offsetY,
'parent', document.body,
'position', 'absolute',
'styleClass', domTT_styleClass,
'type', 'greasy',
'trail', false,
'lazy', false
);
// load in the options from the function call
for (var i = 2; i < arguments.length; i += 2)
{
// load in predefined
if (arguments[i] == 'predefined')
{
var predefinedOptions = domTT_predefined.get(arguments[i + 1]);
for (var j in predefinedOptions.elementData)
{
options.set(j, predefinedOptions.get(j));
}
}
// set option
else
{
options.set(arguments[i], arguments[i + 1]);
}
}
options.set('eventType', in_event != null ? in_event.type : null);
// immediately set the status text if provided
if (options.has('statusText'))
{
try { window.status = options.get('statusText'); } catch(e) {}
}
// if we didn't give content...assume we just wanted to change the status and return
if (!options.has('content') || options.get('content') == '' || options.get('content') == null)
{
if (typeof(owner.onmouseout) != 'function')
{
owner.onmouseout = function(in_event) { domTT_mouseout(this, in_event); };
}
return owner.id;
}
options.set('owner', owner);
domTT_create(options);
// determine the show delay
options.set('delay', (in_event != null && in_event.type.match(/click|mousedown|contextmenu/i)) ? 0 : parseInt(options.get('delay')));
domTT_tooltips.set(owner.id, options);
domTT_tooltips.set(options.get('id'), options);
options.set('status', 'pending');
options.set('activateTimeout', domLib_setTimeout(domTT_runShow, options.get('delay'), [owner.id, in_event]));
return owner.id;
}
// }}}
// {{{ domTT_create()
function domTT_create(in_options)
{
var tipOwner = in_options.get('owner');
var parentObj = in_options.get('parent');
var parentDoc = parentObj.ownerDocument || parentObj.document;
// create the tooltip and hide it
// NOTE: two steps to avoid "flashing" in gecko
var embryo = parentDoc.createElement('div');
var tipObj = parentObj.appendChild(embryo);
tipObj.style.position = 'absolute';
tipObj.style.left = '0px';
tipObj.style.top = '0px';
tipObj.style.visibility = 'hidden';
tipObj.id = in_options.get('id');
tipObj.className = in_options.get('styleClass');
var contentBlock;
var tableLayout = false;
if (in_options.get('caption') || (in_options.get('type') == 'sticky' && in_options.get('caption') !== false))
{
tableLayout = true;
// layout the tip with a hidden formatting table
var tipLayoutTable = tipObj.appendChild(parentDoc.createElement('table'));
tipLayoutTable.style.borderCollapse = 'collapse';
if (domLib_isKHTML)
{
tipLayoutTable.cellSpacing = 0;
}
var tipLayoutTbody = tipLayoutTable.appendChild(parentDoc.createElement('tbody'));
var numCaptionCells = 0;
var captionRow = tipLayoutTbody.appendChild(parentDoc.createElement('tr'));
var captionCell = captionRow.appendChild(parentDoc.createElement('td'));
captionCell.style.padding = '0px';
var caption = captionCell.appendChild(parentDoc.createElement('div'));
caption.className = 'caption';
if (domLib_isIE50)
{
caption.style.height = '100%';
}
if (in_options.get('caption').nodeType)
{
caption.appendChild(domTT_cloneNodes ? in_options.get('caption').cloneNode(1) : in_options.get('caption'));
}
else
{
caption.innerHTML = in_options.get('caption');
}
if (in_options.get('type') == 'sticky')
{
var numCaptionCells = 2;
var closeLinkCell = captionRow.appendChild(parentDoc.createElement('td'));
closeLinkCell.style.padding = '0px';
var closeLink = closeLinkCell.appendChild(parentDoc.createElement('div'));
closeLink.className = 'caption';
if (domLib_isIE50)
{
closeLink.style.height = '100%';
}
closeLink.style.textAlign = 'right';
closeLink.style.cursor = domLib_stylePointer;
// merge the styles of the two cells
closeLink.style.borderLeftWidth = caption.style.borderRightWidth = '0px';
closeLink.style.paddingLeft = caption.style.paddingRight = '0px';
closeLink.style.marginLeft = caption.style.marginRight = '0px';
if (in_options.get('closeLink').nodeType)
{
closeLink.appendChild(in_options.get('closeLink').cloneNode(1));
}
else
{
closeLink.innerHTML = in_options.get('closeLink');
}
closeLink.onclick = function()
{
domTT_deactivate(tipOwner.id);
};
closeLink.onmousedown = function(in_event)
{
if (typeof(in_event) == 'undefined') { in_event = window.event; }
in_event.cancelBubble = true;
};
// MacIE has to have a newline at the end and must be made with createTextNode()
if (domLib_isMacIE)
{
closeLinkCell.appendChild(parentDoc.createTextNode("\n"));
}
}
// MacIE has to have a newline at the end and must be made with createTextNode()
if (domLib_isMacIE)
{
captionCell.appendChild(parentDoc.createTextNode("\n"));
}
var contentRow = tipLayoutTbody.appendChild(parentDoc.createElement('tr'));
var contentCell = contentRow.appendChild(parentDoc.createElement('td'));
contentCell.style.padding = '0px';
if (numCaptionCells)
{
if (domLib_isIE || domLib_isOpera)
{
contentCell.colSpan = numCaptionCells;
}
else
{
contentCell.setAttribute('colspan', numCaptionCells);
}
}
contentBlock = contentCell.appendChild(parentDoc.createElement('div'));
if (domLib_isIE50)
{
contentBlock.style.height = '100%';
}
}
else
{
contentBlock = tipObj.appendChild(parentDoc.createElement('div'));
}
contentBlock.className = 'contents';
var content = in_options.get('content');
// allow content has a function to return the actual content
if (typeof(content) == 'function') {
content = content(in_options.get('id'));
}
if (content != null && content.nodeType)
{
contentBlock.appendChild(domTT_cloneNodes ? content.cloneNode(1) : content);
}
else
{
contentBlock.innerHTML = content;
}
// adjust the width if specified
if (in_options.has('width'))
{
tipObj.style.width = parseInt(in_options.get('width')) + 'px';
}
// check if we are overridding the maxWidth
// if the browser supports maxWidth, the global setting will be ignored (assume stylesheet)
var maxWidth = domTT_maxWidth;
if (in_options.has('maxWidth'))
{
if ((maxWidth = in_options.get('maxWidth')) === false)
{
tipObj.style.maxWidth = domLib_styleNoMaxWidth;
}
else
{
maxWidth = parseInt(in_options.get('maxWidth'));
tipObj.style.maxWidth = maxWidth + 'px';
}
}
// HACK: fix lack of maxWidth in CSS for KHTML and IE
if (maxWidth !== false && (domLib_isIE || domLib_isKHTML) && tipObj.offsetWidth > maxWidth)
{
tipObj.style.width = maxWidth + 'px';
}
in_options.set('offsetWidth', tipObj.offsetWidth);
in_options.set('offsetHeight', tipObj.offsetHeight);
// konqueror miscalcuates the width of the containing div when using the layout table based on the
// border size of the containing div
if (domLib_isKonq && tableLayout && !tipObj.style.width)
{
var left = document.defaultView.getComputedStyle(tipObj, '').getPropertyValue('border-left-width');
var right = document.defaultView.getComputedStyle(tipObj, '').getPropertyValue('border-right-width');
left = left.substring(left.indexOf(':') + 2, left.indexOf(';'));
right = right.substring(right.indexOf(':') + 2, right.indexOf(';'));
var correction = 2 * ((left ? parseInt(left) : 0) + (right ? parseInt(right) : 0));
tipObj.style.width = (tipObj.offsetWidth - correction) + 'px';
}
// if a width is not set on an absolutely positioned object, both IE and Opera
// will attempt to wrap when it spills outside of body...we cannot have that
if (domLib_isIE || domLib_isOpera)
{
if (!tipObj.style.width)
{
// HACK: the correction here is for a border
tipObj.style.width = (tipObj.offsetWidth - 2) + 'px';
}
// HACK: the correction here is for a border
tipObj.style.height = (tipObj.offsetHeight - 2) + 'px';
}
// store placement offsets from event position
var offsetX, offsetY;
// tooltip floats
if (in_options.get('position') == 'absolute' && !(in_options.has('x') && in_options.has('y')))
{
// determine the offset relative to the pointer
switch (in_options.get('direction'))
{
case 'northeast':
offsetX = in_options.get('offsetX');
offsetY = 0 - tipObj.offsetHeight - in_options.get('offsetY');
break;
case 'northwest':
offsetX = 0 - tipObj.offsetWidth - in_options.get('offsetX');
offsetY = 0 - tipObj.offsetHeight - in_options.get('offsetY');
break;
case 'north':
offsetX = 0 - parseInt(tipObj.offsetWidth/2);
offsetY = 0 - tipObj.offsetHeight - in_options.get('offsetY');
break;
case 'southwest':
offsetX = 0 - tipObj.offsetWidth - in_options.get('offsetX');
offsetY = in_options.get('offsetY');
break;
case 'southeast':
offsetX = in_options.get('offsetX');
offsetY = in_options.get('offsetY');
break;
case 'south':
offsetX = 0 - parseInt(tipObj.offsetWidth/2);
offsetY = in_options.get('offsetY');
break;
}
// if we are in an iframe, get the offsets of the iframe in the parent document
if (in_options.get('inframe'))
{
var iframeObj = domLib_getIFrameReference(window);
if (iframeObj)
{
var frameOffsets = domLib_getOffsets(iframeObj);
offsetX += frameOffsets.get('left');
offsetY += frameOffsets.get('top');
}
}
}
// tooltip is fixed
else
{
offsetX = 0;
offsetY = 0;
in_options.set('trail', false);
}
// set the direction-specific offsetX/Y
in_options.set('offsetX', offsetX);
in_options.set('offsetY', offsetY);
if (in_options.get('clearMouse') && in_options.get('direction').indexOf('south') != -1)
{
in_options.set('mouseOffset', domTT_mouseHeight);
}
else
{
in_options.set('mouseOffset', 0);
}
if (domLib_canFade && typeof(Fadomatic) == 'function')
{
if (in_options.get('fade') != 'neither')
{
var fadeHandler = new Fadomatic(tipObj, 10, 0, 0, in_options.get('fadeMax'));
in_options.set('fadeHandler', fadeHandler);
}
}
else
{
in_options.set('fade', 'neither');
}
// setup mouse events
if (in_options.get('trail') && typeof(tipOwner.onmousemove) != 'function')
{
tipOwner.onmousemove = function(in_event) { domTT_mousemove(this, in_event); };
}
if (typeof(tipOwner.onmouseout) != 'function')
{
tipOwner.onmouseout = function(in_event) { domTT_mouseout(this, in_event); };
}
if (in_options.get('type') == 'sticky')
{
if (in_options.get('position') == 'absolute' && domTT_dragEnabled && in_options.get('draggable'))
{
if (domLib_isIE)
{
captionRow.onselectstart = function() { return false; };
}
// setup drag
captionRow.onmousedown = function(in_event) { domTT_dragStart(tipObj, in_event); };
captionRow.onmousemove = function(in_event) { domTT_dragUpdate(in_event); };
captionRow.onmouseup = function() { domTT_dragStop(); };
}
}
else if (in_options.get('type') == 'velcro')
{
/* can use once we have deactivateDelay
tipObj.onmouseover = function(in_event)
{
if (typeof(in_event) == 'undefined') { in_event = window.event; }
var tooltip = domTT_tooltips.get(tipObj.id);
if (in_options.get('lifetime')) {
domLib_clearTimeout(in_options.get('lifetimeTimeout');
}
};
*/
tipObj.onmouseout = function(in_event)
{
if (typeof(in_event) == 'undefined') { in_event = window.event; }
if (!domLib_isDescendantOf(in_event[domLib_eventTo], tipObj, domTT_bannedTags)) {
domTT_deactivate(tipOwner.id);
}
};
// NOTE: this might interfere with links in the tip
tipObj.onclick = function(in_event)
{
domTT_deactivate(tipOwner.id);
};
}
if (in_options.get('position') == 'relative')
{
tipObj.style.position = 'relative';
}
in_options.set('node', tipObj);
in_options.set('status', 'inactive');
}
// }}}
// {{{ domTT_show()
// in_id is either tip id or the owner id
function domTT_show(in_id, in_event)
{
// should always find one since this call would be cancelled if tip was killed
var tooltip = domTT_tooltips.get(in_id);
var status = tooltip.get('status');
var tipObj = tooltip.get('node');
if (tooltip.get('position') == 'absolute')
{
var mouseX, mouseY;
if (tooltip.has('x') && tooltip.has('y'))
{
mouseX = tooltip.get('x');
mouseY = tooltip.get('y');
}
else if (!domTT_useGlobalMousePosition || domTT_mousePosition == null || status == 'active' || tooltip.get('delay') == 0)
{
var eventPosition = domLib_getEventPosition(in_event);
var eventX = eventPosition.get('x');
var eventY = eventPosition.get('y');
if (tooltip.get('inframe'))
{
eventX -= eventPosition.get('scrollX');
eventY -= eventPosition.get('scrollY');
}
// only move tip along requested trail axis when updating position
if (status == 'active' && tooltip.get('trail') !== true)
{
var trail = tooltip.get('trail');
if (trail == 'x')
{
mouseX = eventX;
mouseY = tooltip.get('mouseY');
}
else if (trail == 'y')
{
mouseX = tooltip.get('mouseX');
mouseY = eventY;
}
}
else
{
mouseX = eventX;
mouseY = eventY;
}
}
else
{
mouseX = domTT_mousePosition.get('x');
mouseY = domTT_mousePosition.get('y');
if (tooltip.get('inframe'))
{
mouseX -= domTT_mousePosition.get('scrollX');
mouseY -= domTT_mousePosition.get('scrollY');
}
}
// we are using a grid for updates
if (tooltip.get('grid'))
{
// if this is not a mousemove event or it is a mousemove event on an active tip and
// the movement is bigger than the grid
if (in_event.type != 'mousemove' || (status == 'active' && (Math.abs(tooltip.get('lastX') - mouseX) > tooltip.get('grid') || Math.abs(tooltip.get('lastY') - mouseY) > tooltip.get('grid'))))
{
tooltip.set('lastX', mouseX);
tooltip.set('lastY', mouseY);
}
// did not satisfy the grid movement requirement
else
{
return false;
}
}
// mouseX and mouseY store the last acknowleged mouse position,
// good for trailing on one axis
tooltip.set('mouseX', mouseX);
tooltip.set('mouseY', mouseY);
var coordinates;
if (domTT_screenEdgeDetection)
{
coordinates = domTT_correctEdgeBleed(
tooltip.get('offsetWidth'),
tooltip.get('offsetHeight'),
mouseX,
mouseY,
tooltip.get('offsetX'),
tooltip.get('offsetY'),
tooltip.get('mouseOffset'),
tooltip.get('inframe') ? window.parent : window
);
}
else
{
coordinates = {
'x' : mouseX + tooltip.get('offsetX'),
'y' : mouseY + tooltip.get('offsetY') + tooltip.get('mouseOffset')
};
}
// update the position
tipObj.style.left = coordinates.x + 'px';
tipObj.style.top = coordinates.y + 'px';
// increase the tip zIndex so it goes over previously shown tips
tipObj.style.zIndex = domLib_zIndex++;
}
// if tip is not active, active it now and check for a fade in
if (status == 'pending')
{
// unhide the tooltip
tooltip.set('status', 'active');
tipObj.style.display = '';
tipObj.style.visibility = 'visible';
var fade = tooltip.get('fade');
if (fade != 'neither')
{
var fadeHandler = tooltip.get('fadeHandler');
if (fade == 'out' || fade == 'both')
{
fadeHandler.haltFade();
if (fade == 'out')
{
fadeHandler.halt();
}
}
if (fade == 'in' || fade == 'both')
{
fadeHandler.fadeIn();
}
}
if (tooltip.get('type') == 'greasy' && tooltip.get('lifetime') != 0)
{
tooltip.set('lifetimeTimeout', domLib_setTimeout(domTT_runDeactivate, tooltip.get('lifetime'), [tipObj.id]));
}
}
if (tooltip.get('position') == 'absolute' && domTT_detectCollisions)
{
// utilize original collision element cache
domLib_detectCollisions(tipObj, false, true);
}
}
// }}}
// {{{ domTT_close()
// in_handle can either be an child object of the tip, the tip id or the owner id
function domTT_close(in_handle)
{
var id;
if (typeof(in_handle) == 'object' && in_handle.nodeType)
{
var obj = in_handle;
while (!obj.id || !domTT_tooltips.get(obj.id))
{
obj = obj.parentNode;
if (obj.nodeType != document.ELEMENT_NODE) { return; }
}
id = obj.id;
}
else
{
id = in_handle;
}
domTT_deactivate(id);
}
// }}}
// {{{ domTT_closeAll()
// run through the tooltips and close them all
function domTT_closeAll()
{
// NOTE: this will iterate 2x # of tooltips
for (var id in domTT_tooltips.elementData) {
domTT_close(id);
}
}
// }}}
// {{{ domTT_deactivate()
// in_id is either the tip id or the owner id
function domTT_deactivate(in_id)
{
var tooltip = domTT_tooltips.get(in_id);
if (tooltip)
{
var status = tooltip.get('status');
if (status == 'pending')
{
// cancel the creation of this tip if it is still pending
domLib_clearTimeout(tooltip.get('activateTimeout'));
tooltip.set('status', 'inactive');
}
else if (status == 'active')
{
if (tooltip.get('lifetime'))
{
domLib_clearTimeout(tooltip.get('lifetimeTimeout'));
}
var tipObj = tooltip.get('node');
if (tooltip.get('closeAction') == 'hide')
{
var fade = tooltip.get('fade');
if (fade != 'neither')
{
var fadeHandler = tooltip.get('fadeHandler');
if (fade == 'out' || fade == 'both')
{
fadeHandler.fadeOut();
}
else
{
fadeHandler.hide();
}
}
else
{
tipObj.style.display = 'none';
}
}
else
{
tooltip.get('parent').removeChild(tipObj);
domTT_tooltips.remove(tooltip.get('owner').id);
domTT_tooltips.remove(tooltip.get('id'));
}
tooltip.set('status', 'inactive');
if (domTT_detectCollisions) {
// unhide all of the selects that are owned by this object
// utilize original collision element cache
domLib_detectCollisions(tipObj, true, true);
}
}
}
}
// }}}
// {{{ domTT_mouseout()
function domTT_mouseout(in_owner, in_event)
{
if (!domLib_useLibrary) { return false; }
if (typeof(in_event) == 'undefined') { in_event = window.event; }
var toChild = domLib_isDescendantOf(in_event[domLib_eventTo], in_owner, domTT_bannedTags);
var tooltip = domTT_tooltips.get(in_owner.id);
if (tooltip && (tooltip.get('type') == 'greasy' || tooltip.get('status') != 'active'))
{
// deactivate tip if exists and we moved away from the owner
if (!toChild)
{
domTT_deactivate(in_owner.id);
try { window.status = window.defaultStatus; } catch(e) {}
}
}
else if (!toChild)
{
try { window.status = window.defaultStatus; } catch(e) {}
}
}
// }}}
// {{{ domTT_mousemove()
function domTT_mousemove(in_owner, in_event)
{
if (!domLib_useLibrary) { return false; }
if (typeof(in_event) == 'undefined') { in_event = window.event; }
var tooltip = domTT_tooltips.get(in_owner.id);
if (tooltip && tooltip.get('trail') && tooltip.get('status') == 'active')
{
// see if we are trailing lazy
if (tooltip.get('lazy'))
{
domLib_setTimeout(domTT_runShow, domTT_trailDelay, [in_owner.id, in_event]);
}
else
{
domTT_show(in_owner.id, in_event);
}
}
}
// }}}
// {{{ domTT_addPredefined()
function domTT_addPredefined(in_id)
{
var options = new DomLibHash();
for (var i = 1; i < arguments.length; i += 2)
{
options.set(arguments[i], arguments[i + 1]);
}
domTT_predefined.set(in_id, options);
}
// }}}
// {{{ domTT_correctEdgeBleed()
function domTT_correctEdgeBleed(in_width, in_height, in_x, in_y, in_offsetX, in_offsetY, in_mouseOffset, in_window)
{
var win, doc;
var bleedRight, bleedBottom;
var pageHeight, pageWidth, pageYOffset, pageXOffset;
var x = in_x + in_offsetX;
var y = in_y + in_offsetY + in_mouseOffset;
win = (typeof(in_window) == 'undefined' ? window : in_window);
// Gecko and IE swaps values of clientHeight, clientWidth properties when
// in standards compliance mode from documentElement to document.body
doc = ((domLib_standardsMode && (domLib_isIE || domLib_isGecko)) ? win.document.documentElement : win.document.body);
// for IE in compliance mode
if (domLib_isIE)
{
pageHeight = doc.clientHeight;
pageWidth = doc.clientWidth;
pageYOffset = doc.scrollTop;
pageXOffset = doc.scrollLeft;
}
else
{
pageHeight = doc.clientHeight;
pageWidth = doc.clientWidth;
if (domLib_isKHTML)
{
pageHeight = win.innerHeight;
}
pageYOffset = win.pageYOffset;
pageXOffset = win.pageXOffset;
}
// we are bleeding off the right, move tip over to stay on page
// logic: take x position, add width and subtract from effective page width
if ((bleedRight = (x - pageXOffset) + in_width - (pageWidth - domTT_screenEdgePadding)) > 0)
{
x -= bleedRight;
}
// we are bleeding to the left, move tip over to stay on page
// if tip doesn't fit, we will go back to bleeding off the right
// logic: take x position and check if less than edge padding
if ((x - pageXOffset) < domTT_screenEdgePadding)
{
x = domTT_screenEdgePadding + pageXOffset;
}
// if we are bleeding off the bottom, flip to north
// logic: take y position, add height and subtract from effective page height
if ((bleedBottom = (y - pageYOffset) + in_height - (pageHeight - domTT_screenEdgePadding)) > 0)
{
y = in_y - in_height - in_offsetY;
}
// if we are bleeding off the top, flip to south
// if tip doesn't fit, we will go back to bleeding off the bottom
// logic: take y position and check if less than edge padding
if ((y - pageYOffset) < domTT_screenEdgePadding)
{
y = in_y + domTT_mouseHeight + in_offsetY;
}
return {'x' : x, 'y' : y};
}
// }}}
// {{{ domTT_isActive()
// in_id is either the tip id or the owner id
function domTT_isActive(in_id)
{
var tooltip = domTT_tooltips.get(in_id);
if (!tooltip || tooltip.get('status') != 'active')
{
return false;
}
else
{
return true;
}
}
// }}}
// {{{ domTT_runXXX()
// All of these domMenu_runXXX() methods are used by the event handling sections to
// avoid the circular memory leaks caused by inner functions
function domTT_runDeactivate(args) { domTT_deactivate(args[0]); }
function domTT_runShow(args) { domTT_show(args[0], args[1]); }
// }}}
// {{{ domTT_replaceTitles()
function domTT_replaceTitles(in_decorator)
{
var elements = domLib_getElementsByClass('tooltip');
for (var i = 0; i < elements.length; i++)
{
if (elements[i].title)
{
var content;
if (typeof(in_decorator) == 'function')
{
content = in_decorator(elements[i]);
}
else
{
content = elements[i].title;
}
content = content.replace(new RegExp('\'', 'g'), '\\\'');
elements[i].onmouseover = new Function('in_event', "domTT_activate(this, in_event, 'content', '" + content + "')");
elements[i].title = '';
}
}
}
// }}}
// {{{ domTT_update()
// Allow authors to update the contents of existing tips using the DOM
// Unfortunately, the tip must already exist, or else no work is done.
// TODO: make getting at content or caption cleaner
function domTT_update(handle, content, type)
{
// type defaults to 'content', can also be 'caption'
if (typeof(type) == 'undefined')
{
type = 'content';
}
var tip = domTT_tooltips.get(handle);
if (!tip)
{
return;
}
var tipObj = tip.get('node');
var updateNode;
if (type == 'content')
{
// ...
updateNode = tipObj.firstChild;
if (updateNode.className != 'contents')
{
//
...
...
updateNode = updateNode.firstChild.firstChild.nextSibling.firstChild.firstChild;
}
}
else
{
updateNode = tipObj.firstChild;
if (updateNode.className == 'contents')
{
// missing caption
return;
}
// ...
updateNode = updateNode.firstChild.firstChild.firstChild.firstChild;
}
// TODO: allow for a DOM node as content
updateNode.innerHTML = content;
}
// }}}
/*
* $Log$
* Revision 1.2 2003/11/04 17:25:12 bruce
* KB-301 (Related Document 'tree' not shown in Safari)
*
* Revision 1.1 2002/10/21 05:31:43 britchie
* More dev.
*
* Revision 1.9 2002/07/22 14:06:21 bc6ix
* fix license path, change version reporting to use 2 digits for each level
*
* Revision 1.8 2002/07/07 08:23:07 bc6ix
* fix line endings
*
* Revision 1.7 2002/05/14 16:52:52 bc6ix
* use CVS Log for revision history
*
*
*/
/* ***** BEGIN LICENSE BLOCK *****
* Licensed under Version: MPL 1.1/GPL 2.0/LGPL 2.1
* Full Terms at http://bclary.com/lib/js/license/mpl-tri-license.txt
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Netscape code.
*
* The Initial Developer of the Original Code is
* Netscape Corporation.
* Portions created by the Initial Developer are Copyright (C) 2001
* the Initial Developer. All Rights Reserved.
*
* Contributor(s): Bob Clary
*
* ***** END LICENSE BLOCK ***** */
function xbDetectBrowser()
{
var oldOnError = window.onerror;
var element = null;
window.onerror = null;
// work around bug in xpcdom Mozilla 0.9.1
window.saveNavigator = window.navigator;
navigator.OS = '';
navigator.version = parseFloat(navigator.appVersion);
navigator.org = '';
navigator.family = '';
var platform;
if (typeof(window.navigator.platform) != 'undefined')
{
platform = window.navigator.platform.toLowerCase();
if (platform.indexOf('win') != -1)
navigator.OS = 'win';
else if (platform.indexOf('mac') != -1)
navigator.OS = 'mac';
else if (platform.indexOf('unix') != -1 || platform.indexOf('linux') != -1 || platform.indexOf('sun') != -1)
navigator.OS = 'nix';
}
var i = 0;
var ua = window.navigator.userAgent.toLowerCase();
if (ua.indexOf('opera') != -1)
{
i = ua.indexOf('opera');
navigator.family = 'opera';
navigator.org = 'opera';
navigator.version = parseFloat('0' + ua.substr(i+6), 10);
}
else if ((i = ua.indexOf('msie')) != -1)
{
navigator.org = 'microsoft';
navigator.version = parseFloat('0' + ua.substr(i+5), 10);
if (navigator.version < 4)
navigator.family = 'ie3';
else
navigator.family = 'ie4'
}
else if ((i = ua.indexOf('applewebkit')) != -1)
{
navigator.family = 'safari';
navigator.org = 'apple';
i = ua.indexOf('applewebkit');
navigator.version = parseFloat('0' + ua.substr(i+12), 10);
}
else if (ua.indexOf('gecko') != -1)
{
navigator.family = 'gecko';
var rvStart = ua.indexOf('rv:');
var rvEnd = ua.indexOf(')', rvStart);
var rv = ua.substring(rvStart+3, rvEnd);
var rvParts = rv.split('.');
var rvValue = 0;
var exp = 1;
for (var i = 0; i < rvParts.length; i++)
{
var val = parseInt(rvParts[i]);
rvValue += val / exp;
exp *= 100;
}
navigator.version = rvValue;
if (ua.indexOf('netscape') != -1)
navigator.org = 'netscape';
else if (ua.indexOf('compuserve') != -1)
navigator.org = 'compuserve';
else
navigator.org = 'mozilla';
}
else if ((ua.indexOf('mozilla') !=-1) && (ua.indexOf('spoofer')==-1) && (ua.indexOf('compatible') == -1) && (ua.indexOf('opera')==-1)&& (ua.indexOf('webtv')==-1) && (ua.indexOf('hotjava')==-1))
{
var is_major = parseFloat(navigator.appVersion);
if (is_major < 4)
navigator.version = is_major;
else
{
i = ua.lastIndexOf('/')
navigator.version = parseFloat('0' + ua.substr(i+1), 10);
}
navigator.org = 'netscape';
navigator.family = 'nn' + parseInt(navigator.appVersion);
}
else if ((i = ua.indexOf('aol')) != -1 )
{
// aol
navigator.family = 'aol';
navigator.org = 'aol';
navigator.version = parseFloat('0' + ua.substr(i+4), 10);
}
else if ((i = ua.indexOf('hotjava')) != -1 )
{
// hotjava
navigator.family = 'hotjava';
navigator.org = 'sun';
navigator.version = parseFloat(navigator.appVersion);
}
window.onerror = oldOnError;
}
xbDetectBrowser();
//****************************************************************
// Keep this copyright notice:
// This copy of the script is the property of the owner of the
// particular web site you were visiting.
// Do not download the script's files from there.
// For a free download and full instructions go to:
// http://www.treeview.net
//****************************************************************
// Log of changes:
//
// 01 Mar 03 - VERSION 4.3 - Support for checkboxes
// 21 Feb 03 - Added support for Opera 7
// 22 Sep 02 - Added maySelect member for node-by-node control
// of selection and highlight
// 21 Sep 02 - Cookie values are now separated by cookieCutter
// 12 Sep 02 - VERSION 4.2 - Can highlight Selected Nodes and
// can preserve state through external (DB) IDs
// 29 Aug 02 - Fine tune 'supportDeferral' for IE4 and IE Mac
// 25 Aug 02 - Fixes: STARTALLOPEN, and multi-page frameless
// 09 Aug 02 - Fix repeated folder on Mozilla 1.x
// 31 Jul 02 - VERSION 4.1 - Dramatic speed increase for trees
// with hundreds or thousands of nodes; changes to the control
// flags of the gLnk function
// 18 Jul 02 - Changes in pre-load images function
// 13 Jun 02 - Add ICONPATH var to allow for gif subdir
// 20 Apr 02 - Improve support for frame-less layout
// 07 Apr 02 - Minor changes to support server-side dynamic feeding
// (example: FavoritesManagerASP)
// Definition of class Folder
// *****************************************************************
function Folder(folderDescription, hreference) //constructor
{
//constant data
this.desc = folderDescription;
this.hreference = hreference;
this.id = -1;
this.navObj = 0;
this.iconImg = 0;
this.nodeImg = 0;
this.isLastNode = 0;
this.iconSrc = ICONPATH + "ftv2folderopen.gif";
this.iconSrcClosed = ICONPATH + "ftv2folderclosed.gif";
this.children = new Array;
this.nChildren = 0;
this.level = 0;
this.leftSideCoded = "";
this.isLastNode=false;
this.parentObj = null;
this.maySelect=true;
this.prependHTML = ""
//dynamic data
this.isOpen = false
this.isLastOpenedFolder = false
this.isRendered = 0
//methods
this.initialize = initializeFolder
this.setState = setStateFolder
this.addChild = addChild
this.createIndex = createEntryIndex
this.escondeBlock = escondeBlock
this.esconde = escondeFolder
this.folderMstr = folderMstr
this.renderOb = drawFolder
this.totalHeight = totalHeight
this.subEntries = folderSubEntries
this.linkHTML = linkFolderHTML
this.blockStartHTML = blockStartHTML
this.blockEndHTML = blockEndHTML
this.nodeImageSrc = nodeImageSrc
this.iconImageSrc = iconImageSrc
this.getID = getID
this.forceOpeningOfAncestorFolders = forceOpeningOfAncestorFolders
}
function initializeFolder(level, lastNode, leftSide)
{
var j=0
var i=0
nc = this.nChildren
this.createIndex()
this.level = level
this.leftSideCoded = leftSide
if (browserVersion == 0 || STARTALLOPEN==1)
this.isOpen=true;
if (level>0)
if (lastNode) //the last child in the children array
leftSide = leftSide + "0"
else
leftSide = leftSide + "1"
this.isLastNode = lastNode
if (nc > 0)
{
level = level + 1
for (i=0 ; i < this.nChildren; i++)
{
if (i == this.nChildren-1)
this.children[i].initialize(level, 1, leftSide)
else
this.children[i].initialize(level, 0, leftSide)
}
}
}
function drawFolder(insertAtObj)
{
var nodeName = ""
var auxEv = ""
var docW = ""
var leftSide = leftSideHTML(this.leftSideCoded)
if (browserVersion > 0)
auxEv = ""
else
auxEv = ""
nodeName = this.nodeImageSrc()
if (this.level>0)
if (this.isLastNode) //the last child in the children array
leftSide = leftSide + "" + auxEv + " | "
else
leftSide = leftSide + "" + auxEv + " | "
this.isRendered = 1
if (browserVersion == 2) {
if (!doc.yPos)
doc.yPos=20
}
docW = this.blockStartHTML("folder");
docW = docW + "" + leftSide //;+ "";
if (USEICONS)
{
docW = docW + " | ";
docW = docW + this.linkHTML(false)
docW = docW + " | "
}
if (WRAPTEXT)
docW = docW + this.prependHTML+""
else
docW = docW + this.prependHTML+" | "
if (USETEXTLINKS)
{
docW = docW + this.linkHTML(true)
docW = docW + this.desc + ""
}
else
docW = docW + this.desc
docW = docW + " | "
docW = docW + this.blockEndHTML()
if (insertAtObj == null)
{
if (supportsDeferral) {
doc.write("") //transition between regular flow HTML, and node-insert DOM DHTML
insertAtObj = getElById("domRoot")
insertAtObj.insertAdjacentHTML("beforeEnd", docW)
}
else
doc.write(docW)
}
else
{
insertAtObj.insertAdjacentHTML("afterEnd", docW)
}
if (browserVersion == 2)
{
this.navObj = doc.layers["folder"+this.id]
if (USEICONS)
this.iconImg = this.navObj.document.images["folderIcon"+this.id]
this.nodeImg = this.navObj.document.images["nodeIcon"+this.id]
doc.yPos=doc.yPos+this.navObj.clip.height
}
else if (browserVersion != 0)
{
this.navObj = getElById("folder"+this.id)
if (USEICONS)
this.iconImg = getElById("folderIcon"+this.id)
this.nodeImg = getElById("nodeIcon"+this.id)
}
}
function setStateFolder(isOpen)
{
var subEntries
var totalHeight
var fIt = 0
var i=0
var currentOpen
if (isOpen == this.isOpen)
return
if (browserVersion == 2)
{
totalHeight = 0
for (i=0; i < this.nChildren; i++)
totalHeight = totalHeight + this.children[i].navObj.clip.height
subEntries = this.subEntries()
if (this.isOpen)
totalHeight = 0 - totalHeight
for (fIt = this.id + subEntries + 1; fIt < nEntries; fIt++)
indexOfEntries[fIt].navObj.moveBy(0, totalHeight)
}
this.isOpen = isOpen;
if (this.getID()!=foldersTree.getID() && PERSERVESTATE && !this.isOpen) //closing
{
currentOpen = GetCookie("clickedFolder")
if (currentOpen != null) {
currentOpen = currentOpen.replace(this.getID()+cookieCutter, "")
SetCookie("clickedFolder", currentOpen)
}
}
if (!this.isOpen && this.isLastOpenedfolder)
{
lastOpenedFolder = null;
this.isLastOpenedfolder = false;
}
propagateChangesInState(this)
}
function propagateChangesInState(folder)
{
var i=0
//Change icon
if (folder.nChildren > 0 && folder.level>0) //otherwise the one given at render stays
folder.nodeImg.src = folder.nodeImageSrc()
//Change node
if (USEICONS)
folder.iconImg.src = folder.iconImageSrc()
//Propagate changes
for (i=folder.nChildren-1; i>=0; i--)
if (folder.isOpen)
folder.children[i].folderMstr(folder.navObj)
else
folder.children[i].esconde()
}
function escondeFolder()
{
this.escondeBlock()
this.setState(0)
}
function linkFolderHTML(isTextLink)
{
var docW = "";
if (this.hreference)
{
if (USEFRAMES)
docW = docW + " 0)
docW = docW + "onClick='javascript:clickOnFolder(\""+this.getID()+"\")'"
docW = docW + ">"
}
else
docW = docW + ""
return docW;
}
function addChild(childNode)
{
this.children[this.nChildren] = childNode
childNode.parentObj = this
this.nChildren++
return childNode
}
function folderSubEntries()
{
var i = 0
var se = this.nChildren
for (i=0; i < this.nChildren; i++){
if (this.children[i].children) //is a folder
se = se + this.children[i].subEntries()
}
return se
}
function nodeImageSrc() {
var srcStr = "";
if (this.isLastNode) //the last child in the children array
{
if (this.nChildren == 0)
srcStr = ICONPATH + "bullet_sm.gif"
else
if (this.isOpen)
srcStr = ICONPATH + "minus.gif"
else
srcStr = ICONPATH + "plus.gif"
}
else
{
if (this.nChildren == 0)
srcStr = ICONPATH + "bullet_sm.gif"
else
if (this.isOpen)
srcStr = ICONPATH + "minus.gif"
else
srcStr = ICONPATH + "plus.gif"
}
return srcStr;
}
function iconImageSrc() {
if (this.isOpen)
return(this.iconSrc)
else
return(this.iconSrcClosed)
}
// Definition of class Item (a document or link inside a Folder)
// *************************************************************
function Item(itemDescription, itemLink, target) // Constructor
{
// constant data
this.desc = itemDescription
this.link = itemLink
this.id = -1 //initialized in initalize()
this.navObj = 0 //initialized in render()
this.iconImg = 0 //initialized in render()
this.iconSrc = ICONPATH + "ftv2doc.gif"
this.isRendered = 0
this.isLastNode = false
this.level = 0
this.leftSideCoded = ""
this.nChildren = 0
this.target = target
this.parentObj = null
this.maySelect=true
this.prependHTML = ""
// methods
this.initialize = initializeItem
this.createIndex = createEntryIndex
this.escondeBlock = escondeBlock
this.esconde = escondeBlock
this.folderMstr = folderMstr
this.renderOb = drawItem
this.totalHeight = totalHeight
this.blockStartHTML = blockStartHTML
this.blockEndHTML = blockEndHTML
this.getID = getID
this.forceOpeningOfAncestorFolders = forceOpeningOfAncestorFolders
}
function initializeItem(level, lastNode, leftSide)
{
this.createIndex()
this.level = level
this.leftSideCoded = leftSide
this.isLastNode = lastNode
}
function drawItem(insertAtObj)
{
var leftSide = leftSideHTML(this.leftSideCoded)
var docW = ""
var fullLink = "href=\""+this.link+"\" target=\""+this.target+"\" onClick=\"clickOnLink('"+this.getID()+"\', '"+this.link+"','"+this.target+"');return false;\"";
this.isRendered = 1
if (this.level>0)
if (this.isLastNode) //the last 'brother' in the children array
{
leftSide = leftSide + " | "
}
else
{
leftSide = leftSide + " | "
}
docW = docW + this.blockStartHTML("item")
docW = docW + " " + leftSide;
if (USEICONS)
docW = docW + "" + "" + " | "
if (WRAPTEXT)
docW = docW + this.prependHTML+""
else
docW = docW + this.prependHTML+" | "
if (USETEXTLINKS)
docW = docW + "" + this.desc + ""
else
docW = docW + this.desc
docW = docW + " | "
docW = docW + this.blockEndHTML()
if (insertAtObj == null)
{
doc.write(docW)
}
else
{
insertAtObj.insertAdjacentHTML("afterEnd", docW)
}
if (browserVersion == 2) {
this.navObj = doc.layers["item"+this.id]
if (USEICONS)
this.iconImg = this.navObj.document.images["itemIcon"+this.id]
doc.yPos=doc.yPos+this.navObj.clip.height
} else if (browserVersion != 0) {
this.navObj = getElById("item"+this.id)
if (USEICONS)
this.iconImg = getElById("itemIcon"+this.id)
}
}
// Methods common to both objects (pseudo-inheritance)
// ********************************************************
function forceOpeningOfAncestorFolders() {
if (this.parentObj == null || this.parentObj.isOpen)
return
else {
this.parentObj.forceOpeningOfAncestorFolders()
clickOnNodeObj(this.parentObj)
}
}
function escondeBlock()
{
if (browserVersion == 1 || browserVersion == 3) {
if (this.navObj.style.display == "none")
return
this.navObj.style.display = "none"
} else {
if (this.navObj.visibility == "hiden")
return
this.navObj.visibility = "hiden"
}
}
function folderMstr(domObj)
{
if (!this.isRendered)
this.renderOb(domObj)
else
if (browserVersion == 1 || browserVersion == 3)
this.navObj.style.display = "block"
else
this.navObj.visibility = "show"
}
function blockStartHTML(idprefix) {
var idParam = "id='" + idprefix + this.id + "'"
var docW = ""
if (browserVersion == 2)
docW = ""
else if (browserVersion != 0)
docW = ""
docW = docW + " "
return docW
}
function blockEndHTML() {
var docW = ""
docW = " "
if (browserVersion == 2)
docW = docW + ""
else if (browserVersion != 0)
docW = docW + " "
return docW
}
function createEntryIndex()
{
this.id = nEntries
indexOfEntries[nEntries] = this
nEntries++
}
// total height of subEntries open
function totalHeight() //used with browserVersion == 2
{
var h = this.navObj.clip.height
var i = 0
if (this.isOpen) //is a folder and _is_ open
for (i=0 ; i < this.nChildren; i++)
h = h + this.children[i].totalHeight()
return h
}
function leftSideHTML(leftSideCoded) {
var i;
var retStr = "";
for (i=0; i "
}
if (leftSideCoded.charAt(i) == "0")
{
retStr = retStr + " | "
}
}
return retStr
}
function getID()
{
//define a .xID in all nodes (folders and items) if you want to PERVESTATE that
//work when the tree changes. The value eXternal value must be unique for each
//node and must node change when other nodes are added or removed
//The value may be numeric or string, but cannot have the same char used in cookieCutter
if (typeof this.xID != "undefined")
return this.xID
else
return this.id
}
// Events
// *********************************************************
function clickOnFolder(folderId)
{
var clicked = findObj(folderId)
if (!clicked.isOpen) {
clickOnNodeObj(clicked)
}
if (lastOpenedFolder != null && lastOpenedFolder != folderId)
clickOnNode(lastOpenedFolder); //sets lastOpenedFolder to null
if (clicked.nChildren==0) {
lastOpenedFolder = folderId;
clicked.isLastOpenedfolder = true
}
if (isLinked(clicked.hreference)) {
highlightObjLink(clicked);
}
}
function clickOnNode(folderId)
{
clickOnNodeObj(findObj(folderId))
}
function clickOnNodeObj(folderObj)
{
var state = 0
var currentOpen
state = folderObj.isOpen
folderObj.setState(!state) //open<->close
if (folderObj.id!=foldersTree.id && PERSERVESTATE)
{
currentOpen = GetCookie("clickedFolder")
if (currentOpen == null)
currentOpen = ""
if (!folderObj.isOpen) //closing
{
currentOpen = currentOpen.replace(folderObj.getID()+cookieCutter, "")
SetCookie("clickedFolder", currentOpen)
}
else
SetCookie("clickedFolder", currentOpen+folderObj.getID()+cookieCutter)
}
}
function clickOnLink(clickedId, target, windowName) {
highlightObjLink(findObj(clickedId));
if (isLinked(target)) {
window.open(target,windowName);
}
}
function ld ()
{
return document.links.length-1
}
// Auxiliary Functions
// *******************
function findObj(id)
{
var i=0;
var nodeObj;
if (typeof foldersTree.xID != "undefined") {
nodeObj = indexOfEntries[i];
for(i=0;i= nEntries)
return null; //example: node removed in DB
else
return indexOfEntries[id];
}
function isLinked(hrefText) {
var result = true;
result = (result && hrefText !=null);
result = (result && hrefText != '');
result = (result && hrefText.indexOf('undefined') < 0);
result = (result && hrefText.indexOf('parent.op') < 0);
return result;
}
// Do highlighting by changing background and foreg. colors of folder or doc text
function highlightObjLink(nodeObj) {
if (!HIGHLIGHT || nodeObj==null || nodeObj.maySelect==false) {//node deleted in DB
return;
}
if (browserVersion == 1 || browserVersion == 3) {
var clickedDOMObj = getElById('itemTextLink'+nodeObj.id);
if (clickedDOMObj != null) {
if (lastClicked != null) {
var prevClickedDOMObj = getElById('itemTextLink'+lastClicked.id);
prevClickedDOMObj.style.color=lastClickedColor;
prevClickedDOMObj.style.backgroundColor=lastClickedBgColor;
}
lastClickedColor = clickedDOMObj.style.color;
lastClickedBgColor = clickedDOMObj.style.backgroundColor;
clickedDOMObj.style.color=HIGHLIGHT_COLOR;
clickedDOMObj.style.backgroundColor=HIGHLIGHT_BG;
}
}
lastClicked = nodeObj;
if (PERSERVESTATE)
SetCookie('highlightedTreeviewLink', nodeObj.getID());
}
function gFld(description, hreference)
{
folder = new Folder(description, hreference);
return folder;
}
function gLnk(optionFlags, description, linkData)
{
var fullLink = "";
var targetFlag = "";
var target = "";
var protocolFlag = "";
var protocol = "";
if (optionFlags>=0) //is numeric (old style) or empty (error)
{
return oldGLnk(optionFlags, description, linkData)
}
targetFlag = optionFlags.charAt(0)
if (targetFlag=="B")
target = "_blank"
if (targetFlag=="P")
target = "_parent"
if (targetFlag=="R")
target = "basefrm"
if (targetFlag=="S")
target = "_self"
if (targetFlag=="T")
target = "_top"
if (optionFlags.length > 1) {
protocolFlag = optionFlags.charAt(1)
if (protocolFlag=="h")
protocol = "http://"
if (protocolFlag=="s")
protocol = "https://"
if (protocolFlag=="f")
protocol = "ftp://"
if (protocolFlag=="m")
protocol = "mailto:"
}
fullLink = "'" + protocol + linkData + "' target=" + target
linkItem = new Item(description, protocol+linkData, target)
return linkItem
}
//Function created Aug 1, 2002 for backwards compatibility purposes
function oldGLnk(target, description, linkData)
{
var fullLink = "";
//Backwards compatibility code
if (USEFRAMES)
{
if (target==0)
{
fullLink = "'"+linkData+"' target=\"basefrm\""
}
else
{
if (target==1)
fullLink = "'http://"+linkData+"' target=_blank"
else
if (target==2)
fullLink = "'http://"+linkData+"' target=\"basefrm\""
else
fullLink = linkData+" target=\"_top\""
}
}
else
{
if (target==0)
{
fullLink = "'"+linkData+"' target=_top"
}
else
{
if (target==1)
fullLink = "'http://"+linkData+"' target=_blank"
else
fullLink = "'http://"+linkData+"' target=_top"
}
}
linkItem = new Item(description, fullLink)
return linkItem
}
function insFld(parentFolder, childFolder)
{
return parentFolder.addChild(childFolder)
}
function insDoc(parentFolder, document)
{
return parentFolder.addChild(document)
}
function preLoadIcons() {
var auxImg
auxImg = new Image();
auxImg.src = ICONPATH + "plus.gif";
auxImg.src = ICONPATH + "minus.gif";
auxImg.src = ICONPATH + "bullet_sm.gif";
}
//Open some folders for initial layout, if necessary
function setInitialLayout() {
if (browserVersion > 0 && !STARTALLOPEN)
clickOnNodeObj(foldersTree);
if (!STARTALLOPEN && (browserVersion > 0) && PERSERVESTATE)
PersistentFolderOpening();
}
//Used with NS4 and STARTALLOPEN
function renderAllTree(nodeObj, parent) {
var i=0;
nodeObj.renderOb(parent)
if (supportsDeferral)
for (i=nodeObj.nChildren-1; i>=0; i--)
renderAllTree(nodeObj.children[i], nodeObj.navObj)
else
for (i=0 ; i < nodeObj.nChildren; i++)
renderAllTree(nodeObj.children[i], null)
}
function hideWholeTree(nodeObj, hideThisOne, nodeObjMove) {
var i=0;
var heightContained=0;
var childrenMove=nodeObjMove;
if (hideThisOne)
nodeObj.escondeBlock()
if (browserVersion == 2)
nodeObj.navObj.moveBy(0, 0-nodeObjMove)
for (i=0 ; i < nodeObj.nChildren; i++) {
heightContainedInChild = hideWholeTree(nodeObj.children[i], true, childrenMove)
if (browserVersion == 2) {
heightContained = heightContained + heightContainedInChild + nodeObj.children[i].navObj.clip.height
childrenMove = childrenMove + heightContainedInChild
}
}
return heightContained;
}
// Simulating inserAdjacentHTML on NS6
// Code by thor@jscript.dk
// ******************************************
if(typeof HTMLElement!="undefined" && !HTMLElement.prototype.insertAdjacentElement){
HTMLElement.prototype.insertAdjacentElement = function (where,parsedNode)
{
switch (where){
case 'beforeBegin':
this.parentNode.insertBefore(parsedNode,this)
break;
case 'afterBegin':
this.insertBefore(parsedNode,this.firstChild);
break;
case 'beforeEnd':
this.appendChild(parsedNode);
break;
case 'afterEnd':
if (this.nextSibling)
this.parentNode.insertBefore(parsedNode,this.nextSibling);
else this.parentNode.appendChild(parsedNode);
break;
}
}
HTMLElement.prototype.insertAdjacentHTML = function(where,htmlStr)
{
var r = this.ownerDocument.createRange();
r.setStartBefore(this);
var parsedHTML = r.createContextualFragment(htmlStr);
this.insertAdjacentElement(where,parsedHTML)
}
}
function getElById(idVal) {
if (document.getElementById != null)
return document.getElementById(idVal)
if (document.all != null)
return document.all[idVal]
alert("Problem getting element by id")
return null
}
// Functions for cookies
// Note: THESE FUNCTIONS ARE OPTIONAL. No cookies are used unless
// the PERSERVESTATE variable is set to 1 (default 0)
// The separator currently in use is ^ (chr 94)
// ***********************************************************
function PersistentFolderOpening()
{
var stateInCookie;
var fldStr=""
var fldArr
var fldPos=0
var id
var nodeObj
stateInCookie = GetCookie("clickedFolder");
SetCookie('clickedFolder', "") //at the end of function it will be back, minus null cases
if(stateInCookie!=null)
{
fldArr = stateInCookie.split(cookieCutter)
for (fldPos=0; fldPos 2) ? argv[2] : null;
//var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
var path = "/"; //allows the tree to remain open across pages with diff names & paths
name = CookieBranding(name)
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function ExpireCookie (name)
{
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
name = CookieBranding(name)
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
//To customize the tree, overwrite these variables in the configuration file (demoFramesetNode.js, etc.)
var USETEXTLINKS = 0
var STARTALLOPEN = 0
var USEFRAMES = 1
var USEICONS = 1
var WRAPTEXT = 0
var PERSERVESTATE = 0
var ICONPATH = ''
var HIGHLIGHT = 0
var HIGHLIGHT_COLOR = 'white';
var HIGHLIGHT_BG = 'blue';
var BUILDALL = 0
//Other variables
var lastClicked = null;
var lastClickedColor;
var lastClickedBgColor;
var indexOfEntries = new Array
var nEntries = 0
var browserVersion = 0
var selectedFolder=0
var lastOpenedFolder=null
var t=5
var doc = document
var supportsDeferral = false
var cookieCutter = '^' //You can change this if you need to use ^ in your xID or treeID values
doc.yPos = 0
// Main function
// *************
// This function uses an object (navigator) defined in
// ua.js, imported in the main html page (left frame).
function initializeDocument()
{
preLoadIcons()
switch(navigator.family)
{
case 'ie4':
browserVersion = 1 //Simply means IE > 3.x
break;
case 'opera':
browserVersion = (navigator.version > 6 ? 1 : 0); //opera7 has a good DOM
break;
case 'nn4':
browserVersion = 2 //NS4.x
break;
case 'gecko':
browserVersion = 3 //NS6.x
break;
case 'safari':
browserVersion = 4 // Apple's webkit (Safari)
break;
default:
browserVersion = 0 //other, possibly without DHTML
break;
}
supportsDeferral = ((browserVersion == 1 && navigator.version >= 5 && navigator.OS != "mac") || browserVersion == 3);
supportsDeferral = supportsDeferral & (!BUILDALL)
if (browserVersion == 4)
browserVersion = 3;
if (!USEFRAMES && browserVersion == 2)
browserVersion = 0;
eval(String.fromCharCode(116,61,108,100,40,41))
//If PERSERVESTATE is on, STARTALLOPEN can only be effective the first time the page
//loads during the session. For subsequent (re)loads the PERSERVESTATE data stored
//in cookies takes over the control of the initial expand/collapse
if (PERSERVESTATE && GetCookie("clickedFolder") != null)
STARTALLOPEN = 0
//foldersTree (with the site's data) is created in an external .js (demoFramesetNode.js, for example)
foldersTree.initialize(0, true, "")
if (supportsDeferral && !STARTALLOPEN)
foldersTree.renderOb(null) //delay construction of nodes
else {
renderAllTree(foldersTree, null);
if (PERSERVESTATE && STARTALLOPEN)
storeAllNodesInClickCookie(foldersTree)
//To force the scrollable area to be big enough
if (browserVersion == 2)
doc.write(" ")
if (browserVersion != 0 && !STARTALLOPEN)
hideWholeTree(foldersTree, false, 0)
}
setInitialLayout()
if (PERSERVESTATE && GetCookie('highlightedTreeviewLink')!=null && GetCookie('highlightedTreeviewLink')!="") {
var nodeObj = findObj(GetCookie('highlightedTreeviewLink'))
if (nodeObj!=null){
nodeObj.forceOpeningOfAncestorFolders()
highlightObjLink(nodeObj);
}
else
SetCookie('highlightedTreeviewLink', '')
}
}
/*
toggleChoose function
This is for showing and hiding the choose community 'dropdown'.
This toggles the panel (slides up and down) from the tab button.
*/
function toggleChoose(thisID) {
if ($(thisID).style.display != 'none') {
Effect.toggle($(thisID), 'slide', {duration: .4});
} else {
Effect.toggle($(thisID), 'slide', {duration: .4});
}
}
function jiveToggleTab(thisPanel, otherPanels) {
var thisPanelElem = $(thisPanel);
// load the tabs for the panel elements
if (thisPanelElem) {
var thisTabElem = $(thisPanelElem.id+"-tab");
}
// toggle the tab styles and the panel visibility
if (thisPanelElem && thisPanelElem.style.display == 'none') {
if (thisTabElem) {
thisTabElem.className = "jive-body-tab jive-body-tabcurrent";
thisPanelElem.style.display = "block";
}
for (var i = 0; i < otherPanels.length; i++) {
var thatPanelElem = $(otherPanels[i]);
if (thatPanelElem) {
var thatTabElem = $(thatPanelElem.id+"-tab");
}
if (thatTabElem) {
thatTabElem.className = "jive-body-tab";
thatPanelElem.style.display = "none";
}
}
}
}
/*
jivetoggleLogin function
This is for showing and hiding the choose user login form.
*/
function jivetoggleLogin() {
Element.toggle('jiveLoginWelcome');
Element.toggle('jiveLoginForm');
if ($('jiveLoginForm').style.display != 'none') {
$('login-username').focus();
} else {
$('login-username').blur();
}
}
// the timeout variable that will be used to close menu bar
var jiveMenuTimeout;
var jiveMenuIndex = -1;
var jiveMenuID;
function jiveKeypressMenuHandler (event) {
if (Element.visible(jiveMenuID)) {
var key = event.which || event.keyCode;
switch (key) {
case Event.KEY_DOWN:
var links = $(jiveMenuID).getElementsByTagName('li');
if (jiveMenuIndex > -1 && jiveMenuIndex < (links.length - 1)) {
links[jiveMenuIndex].className = 'jive-userbar-menu-nohover';
}
if (jiveMenuIndex < (links.length - 1)) {
jiveMenuIndex++;
links[jiveMenuIndex].className = 'jive-userbar-menu-hover';
}
break;
case Event.KEY_UP:
var links = $(jiveMenuID).getElementsByTagName('li');
if (jiveMenuIndex > 0) {
links[jiveMenuIndex].className = 'jive-userbar-menu-nohover';
}
if (jiveMenuIndex > 0) {
jiveMenuIndex--;
links[jiveMenuIndex].className = 'jive-userbar-menu-hover';
}
break;
case Event.KEY_RETURN:
listElements = $(jiveMenuID).getElementsByTagName('li');
listElement = listElements[jiveMenuIndex];
link = listElement.getElementsByTagName("a");
if (link.length > 0) {
document.location.href = link[0].href;
}
break;
}
Event.stop(event);
}
}
/*
jivetoggleMenu function
This is for showing and hiding the choose user menu 'dropdowns'.
This toggles the panel (slides up and down) from the button.
*/
function jivetoggleMenu(jiveMenu) {
clearTimeout(jiveMenuTimeout);
var open = $(jiveMenu).style.display != 'none';
if (!open) {
jiveCloseAllMenus();
Element.toggle($(jiveMenu));
$(jiveMenu + "Link").className = "jive-userbar-droplink-on";
jiveMenuID = jiveMenu;
Event.observe(document, 'keypress', jiveKeypressMenuHandler, true);
}
}
/*
jiveSwapMenu function
This is for showing and hiding the choose user menu 'dropdowns'.
This toggles the panel (slides up and down) from the button.
*/
function jiveSwapMenu(jiveMenu) {
clearTimeout(jiveMenuTimeout);
var openMenu = null;
var menus = document.getElementsByClassName('jive-userbar-menu');
for (var i = 0; i < menus.length; i++) {
if (menus[i].style.display != 'none') {
openMenu = menus[i];
break;
}
}
if (openMenu != null) {
if (openMenu.id != jiveMenu) {
jiveCloseAllMenus();
Element.toggle($(jiveMenu));
$(jiveMenu + "Link").className = "jive-userbar-droplink-on";
}
}
}
// cancels any timeout set to close a jive menu bar
function jiveInsideMenu(evt) {
clearTimeout(jiveMenuTimeout);
}
// sets a timeout that will close the jive menu bar
function jiveOutsideMenu(evt) {
try {
var elem = evt.relatedTarget || evt.toElement;
if (typeof(elem) != 'undefined') {
while (elem.parentNode && (typeof(elem.tagName) == 'undefined' || elem.tagName.toUpperCase() != 'DIV')) {
elem = elem.parentNode;
}
}
if (typeof(elem) == 'undefined' || !elem.tagName || (!Element.hasClassName(elem, 'jive-userbar-menu'))) {
jiveMenuTimeout = setTimeout('jiveCloseAllMenus()', 1500);
}
}
catch (e) {
jiveMenuTimeout = setTimeout('jiveCloseAllMenus()', 1500);
}
}
// dynamically loads the jive menu positions
function jiveLoadMenus() {
var menus = document.getElementsByClassName('jive-userbar-menu');
for (var i = 0; i < menus.length; i++) {
var link = document.getElementById(menus[i].id + "Link");
menus[i].style.left = jiveGetX(link) + "px";
menus[i].style.top = (jiveGetY(link) + 34) + "px";
}
}
// loops through all open menu bars and closes them
function jiveCloseAllMenus() {
var menus = document.getElementsByClassName('jive-userbar-menu');
for (var i = 0; i < menus.length; i++) {
if (menus[i].style.display != "none") {
Element.toggle(menus[i]);
$(menus[i].id + "Link").className = "";
var links = menus[i].getElementsByTagName('li');
for (var k = 0; k < links.length; k++) {
links[k].className = 'jive-userbar-menu-nohover';
}
}
}
Event.stopObserving(document, 'keypress', jiveKeypressMenuHandler, true);
jiveMenuIndex = -1;
}
// get pixel position of an object
function jiveGetY(o){ var y = 0
if (o.offsetParent) while (o.offsetParent) { y += o.offsetTop; o = o.offsetParent }
return y
}
function jiveGetX(o){ var x = 0
if (o.offsetParent) while (o.offsetParent) { x += o.offsetLeft; o = o.offsetParent }
return x
}
// escape key and body click to close menu bars
if (document.layers) {
document.captureEvents(Event.KEYDOWN);
}
function jiveEscapeKey(evt) {
var keyCode = document.layers ?
evt.which : document.all ? event.keyCode : document.getElementById ? evt.keyCode : 0;
if (keyCode == 27) { // esc - close open menu
jiveCloseAllMenus();
}
}
function jiveBodyClick(evt) {
evt = evt || window.event; // IE required window.event
var elem = Event.findElement(evt, 'div');
// check parent or parent's parent for class dhtmlTreeStyle for tree dropdown in menu
var parentElem = Event.element(evt).parentNode;
if (!elem.tagName || (elem.id != 'jive-userbar-droplink' && !Element.hasClassName(elem, 'jive-userbar-menu') && !Element.hasClassName(parentElem, "dhtmlTreeStyle") && !Element.hasClassName(parentElem.parentNode, "dhtmlTreeStyle"))) {
jiveCloseAllMenus();
}
}
/*
jiveToggleOptions function
Function for toggling the state of an options element.
*/
function jiveToggleOptions(optionName) {
if ($(optionName + '-form').style.display != 'none') {
Element.hide(optionName + '-form');
$(optionName + '-hdr').className = 'jive-compose-hdr-opt-closed';
} else {
$(optionName + '-form').style.display = 'block';
$(optionName + '-hdr').className = 'jive-compose-hdr-opt';
}
}
function jiveShowTopicFilter(thisID) {
if ($(thisID).style.display != 'none') {
Element.toggle($(thisID));
//Effect.toggle($(thisID), 'slide', {duration: .4});
} else {
Element.toggle($(thisID));
//Effect.toggle($(thisID), 'slide', {duration: .4});
}
}
function jiveToggleSpaceDetails(thisID) {
Element.toggle($(thisID));
if ($(thisID).style.display != 'none') {
$(thisID + '-less').style.display = '';
$(thisID + '-more').style.display = 'none';
} else {
$(thisID + '-more').style.display = '';
$(thisID + '-less').style.display = 'none';
}
}
function jiveToggleSpaceDetails2(thisID) {
if ($(thisID).className == 'jive-space-namedesc-full') {
$(thisID).className = '';
$(thisID + '-more').style.display = '';
$(thisID + '-less').style.display = 'none';
} else {
$(thisID).className = 'jive-space-namedesc-full';
$(thisID + '-less').style.display = '';
$(thisID + '-more').style.display = 'none';
}
}
function jiveHideProfile() {
// hide any existing profile bubbles
try {
if ($('pcMain') && $('pcArrow')) {
Element.remove($('pcMain'));
Element.remove($('pcArrow'));
}
} catch(e) {
//alert('hidePop error: '+ e + e.message + ' : ' + e.description);
}
}
function jiveShowProfile(rootURL, profilelement, username) {
jiveHideProfile()
var formatPNGTag = function(properties) {
var id = (properties.id) ? ' id="' + properties.id + '"' : '';
if (document.all) {
return '';
} else {
return '';
}
}
var elem = $(profilelement);
iconId = elem.id;
var top = Position.cumulativeOffset(elem)[1];
var left = Position.cumulativeOffset(elem)[0];
// alert(top + ' : ' + left)
var poptop = 0
var popleft = 0
var arrowtop = 0
var arrowleft = 0
// 2ND ROW
if (top < 540) {
if (left < 400) {
// DOWN RIGHT ARROW
var arrowPNG = 'jive-profile-bubble-bottom-right.png';
offsetarrowtop = 3;
offsetarrowleft = 5;
if (left > 200) {
// 2nd ROW
offsetpoptop = -30;
offsetpopleft = 45;
} else {
// DEFAULT
offsetpoptop = -10;
offsetpopleft = 115;
}
} else {
// DOWN LEFT ARROW
var arrowPNG = 'jive-profile-bubble-bottom-left.png';
offsetarrowtop = 3;
offsetarrowleft = -100;
if (left < 500) {
// 3rd ROW
offsetpoptop = -30;
offsetpopleft = -450;
} else {
offsetpoptop = -10;
offsetpopleft = -530;
}
}
} else {
// TOP > 540
if (left < 400) {
// UP RIGHT ARROW
var arrowPNG = 'jive-profile-bubble-top-right.png';
offsetarrowtop = -210;
offsetarrowleft = 5;
if (left > 200) {
// 2nd ROW
offsetpoptop = -210;
offsetpopleft = 45;
} else {
// DEFAULT
offsetpoptop = -250;
offsetpopleft = 115;
}
} else {
// UP LEFT ARROW
var arrowPNG = 'jive-profile-bubble-top-left.png';
offsetarrowtop = -210;
offsetarrowleft = -100;
if (left < 500) {
// 3rd ROW
offsetpoptop = -250;
offsetpopleft = -450;
} else {
// DEFAULT
offsetpoptop = -250;
offsetpopleft = -530;
}
}
}
poptop = top + offsetpoptop;
popleft = left + offsetpopleft;
arrowtop = top + offsetarrowtop;
arrowleft = left + offsetarrowleft;
var popup = document.createElement('div');
popup.setAttribute('id','pcMain');
new Insertion.Top(popup, formatPNGTag({ width: 450, height: 21, border: 0, src: rootURL + 'images/jive-profile-bubble-background-top.png' }) + ' ');
new Insertion.Bottom(popup, '');
new Insertion.Bottom(popup, formatPNGTag({ width: 450, height: 21, border: 0, src: rootURL + 'images/jive-profile-bubble-background-bottom.png' }));
Element.setStyle(popup,{display: 'none', top: poptop + 'px', left: popleft + 'px' });
var arrow = document.createElement('div');
arrow.setAttribute('id','pcArrow');
new Insertion.Top(arrow, formatPNGTag({ width: 121, height: 226, border: 0, src: rootURL + 'images/' + arrowPNG }) + ' ');
Element.setStyle(arrow,{display: 'none', top: arrowtop + 'px', left: arrowleft + 'px'});
document.body.appendChild(popup);
document.body.appendChild(arrow);
Element.setStyle($('pcMain'),{display: 'block'});
Element.setStyle($('pcArrow'),{display: 'block'});
jiveGetUserContent(rootURL, username)
}
function jiveGetUserContent(rootURL, username) {
try {
$('pcContent').innerHTML = '';
// NOW LOAD DATA VIA AJAX
var callback = function(originalRequest) {
$('pcContent').innerHTML = originalRequest.responseText;
}
var error = function(originalRequest) {
$('pcContent').innerHTML = 'Oops! There was an error getting this user\'s profile.'
}
var url = rootURL + 'profile-short.jspa?username=' + username;
var myAjax = new Ajax.Request( url, { method: 'get', onComplete: callback, onFailure: error});
}catch(e) {
alert(e.message)
}
}
function callOnLoad(init) {
if (window.addEventListener)
{
window.addEventListener("load", init, false);
}
else if (window.attachEvent)
{
window.attachEvent("onload", init);
}
else
{
window.onload = init;
}
}
Jive = Class.create();
Jive.AlertMessage = function(element) {
var options = arguments[1] || {} ;
new Effect.Appear(element, {
queue: 'front',
scope: element,
duration: 1,
beforeStart:options.beforeStart,
afterFinish:function(obj) {
new Pause(1);
new Effect.Fade(element, {
queue: 'end',
scope: obj,
duration: 1,
afterFinish:options.afterFinish
});
}
});
};
function Pause(duration, busy){
this.duration= duration * 1000;
this.busywork = null; // function to call while waiting.
this.runner = 0;
if (arguments.length == 2) {
this.busywork = busy;
}
this.pause(this.duration);
}
Pause.prototype.pause = function(duration){
if ( (duration == null) || (duration < 0)) {return;}
var later = (new Date()).getTime() + duration;
while(true){
if ((new Date()).getTime() > later) {
break;
}
this.runner++;
if (this.busywork != null) {
this.busywork(this.runner);
}
} // while
} // pause method
/*
* $Revision: 14166 $
* $Date: 2005-02-07 15:57:29 -0800 (Mon, 07 Feb 2005) $
*
* Copyright (C) 1999-2007 Jive Software. All rights reserved.
*
* This software is the proprietary information of Jive Software. Use is subject to license terms.
*/
// -----------------------------------------------------------------------------------
//
// Lightbox v2.03.3
// by Lokesh Dhakar - http://www.huddletogether.com
// 5/21/06
//
// For more information on this script, visit:
// http://huddletogether.com/projects/lightbox2/
//
// Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
//
// Credit also due to those who have helped, inspired, and made their code available to the public.
// Including: Scott Upton(uptonic.com), Peter-Paul Koch(quirksmode.com), Thomas Fuchs(mir.aculo.us), and others.
//
//
// -----------------------------------------------------------------------------------
//
// Configuration
//
var fileLoadingImage = _jive_base_url + '/images/jive-image-loading.gif';
var fileBottomNavCloseImage = _jive_base_url + '/images/jive-image-close.gif';
var overlayOpacity = 0.8; // controls transparency of shadow overlay
var animate = true; // toggles resizing animations
var resizeSpeed = 7; // controls the speed of the image resizing animations (1=slowest and 10=fastest)
var borderSize = 10; //if you adjust the padding in the CSS, you will need to update this variable
// -----------------------------------------------------------------------------------
//
// Global Variables
//
var imageArray = new Array;
var activeImage;
if(animate == true){
overlayDuration = 0.2; // shadow fade in/out duration
if(resizeSpeed > 10){ resizeSpeed = 10;}
if(resizeSpeed < 1){ resizeSpeed = 1;}
resizeDuration = (11 - resizeSpeed) * 0.15;
} else {
overlayDuration = 0;
resizeDuration = 0;
}
// -----------------------------------------------------------------------------------
//
// Additional methods for Element added by SU, Couloir
// - further additions by Lokesh Dhakar (huddletogether.com)
//
Object.extend(Element, {
getWidth: function(element) {
element = $(element);
return element.offsetWidth;
},
setWidth: function(element,w) {
element = $(element);
element.style.width = w +"px";
},
setHeight: function(element,h) {
element = $(element);
element.style.height = h +"px";
},
setTop: function(element,t) {
element = $(element);
element.style.top = t +"px";
},
setLeft: function(element,l) {
element = $(element);
element.style.left = l +"px";
},
setSrc: function(element,src) {
element = $(element);
element.src = src;
},
setHref: function(element,href) {
element = $(element);
element.href = href;
},
setInnerHTML: function(element,content) {
element = $(element);
element.innerHTML = content;
}
});
// -----------------------------------------------------------------------------------
//
// Extending built-in Array object
// - array.removeDuplicates()
// - array.empty()
//
Array.prototype.removeDuplicates = function () {
for(i = 0; i < this.length; i++){
for(j = this.length-1; j>i; j--){
if(this[i][0] == this[j][0]){
this.splice(j,1);
}
}
}
}
// -----------------------------------------------------------------------------------
Array.prototype.empty = function () {
for(i = 0; i <= this.length; i++){
this.shift();
}
}
// -----------------------------------------------------------------------------------
//
// Lightbox Class Declaration
// - initialize()
// - start()
// - changeImage()
// - resizeImageContainer()
// - showImage()
// - updateDetails()
// - updateNav()
// - enableKeyboardNav()
// - disableKeyboardNav()
// - keyboardNavAction()
// - preloadNeighborImages()
// - end()
//
// Structuring of code inspired by Scott Upton (http://www.uptonic.com/)
//
var JiveImage = Class.create();
JiveImage.prototype = {
// initialize()
// Constructor runs on completion of the DOM loading. Calls updateImageList and then
// the function inserts html at the bottom of the page which is used to display the shadow
// overlay and the image container.
//
initialize: function() {
this.updateImageList();
// Code inserts html at the bottom of the page that looks similar to this:
//
//
//
//
//
//
//
//
//
//
//
//
var objBody = document.getElementsByTagName("body").item(0);
var objOverlay = document.createElement("div");
objOverlay.setAttribute('id','jive-overlay');
objOverlay.style.display = 'none';
objOverlay.onclick = function() { myJiveImage.end(); }
objBody.appendChild(objOverlay);
var objLightbox = document.createElement("div");
objLightbox.setAttribute('id','jive-lightbox');
objLightbox.style.display = 'none';
objLightbox.onclick = function(e) { // close Lightbox is user clicks shadow overlay
if (!e) var e = window.event;
var clickObj = Event.element(e).id;
if ( clickObj == 'jive-lightbox') {
myJiveImage.end();
}
};
objBody.appendChild(objLightbox);
var objOuterImageContainer = document.createElement("div");
objOuterImageContainer.setAttribute('id','jive-outerImageContainer');
objLightbox.appendChild(objOuterImageContainer);
// When Lightbox starts it will resize itself from 250 by 250 to the current image dimension.
// If animations are turned off, it will be hidden as to prevent a flicker of a
// white 250 by 250 box.
if(animate){
Element.setWidth('jive-outerImageContainer', 250);
Element.setHeight('jive-outerImageContainer', 250);
} else {
Element.setWidth('jive-outerImageContainer', 1);
Element.setHeight('jive-outerImageContainer', 1);
}
var objImageContainer = document.createElement("div");
objImageContainer.setAttribute('id','jive-imageContainer');
objOuterImageContainer.appendChild(objImageContainer);
var objLightboxImage = document.createElement("img");
objLightboxImage.setAttribute('id','jive-lightboxImage');
objImageContainer.appendChild(objLightboxImage);
var objHoverNav = document.createElement("div");
objHoverNav.setAttribute('id','jive-hoverNav');
objImageContainer.appendChild(objHoverNav);
var objPrevLink = document.createElement("a");
objPrevLink.setAttribute('id','jive-prevLink');
objPrevLink.setAttribute('href','#');
objHoverNav.appendChild(objPrevLink);
var objNextLink = document.createElement("a");
objNextLink.setAttribute('id','jive-nextLink');
objNextLink.setAttribute('href','#');
objHoverNav.appendChild(objNextLink);
var objLoading = document.createElement("div");
objLoading.setAttribute('id','jive-loading');
objImageContainer.appendChild(objLoading);
var objLoadingLink = document.createElement("a");
objLoadingLink.setAttribute('id','jive-loadingLink');
objLoadingLink.setAttribute('href','#');
objLoadingLink.onclick = function() { myJiveImage.end(); return false; }
objLoading.appendChild(objLoadingLink);
var objLoadingImage = document.createElement("img");
objLoadingImage.setAttribute('src', fileLoadingImage);
objLoadingLink.appendChild(objLoadingImage);
var objImageDataContainer = document.createElement("div");
objImageDataContainer.setAttribute('id','jive-imageDataContainer');
objLightbox.appendChild(objImageDataContainer);
var objImageData = document.createElement("div");
objImageData.setAttribute('id','jive-imageData');
objImageDataContainer.appendChild(objImageData);
var objImageDetails = document.createElement("div");
objImageDetails.setAttribute('id','jive-imageDetails');
objImageData.appendChild(objImageDetails);
var objCaption = document.createElement("span");
objCaption.setAttribute('id','jive-caption');
objImageDetails.appendChild(objCaption);
var objNumberDisplay = document.createElement("span");
objNumberDisplay.setAttribute('id','jive-numberDisplay');
objImageDetails.appendChild(objNumberDisplay);
var objBottomNav = document.createElement("div");
objBottomNav.setAttribute('id','jive-bottomNav');
objImageData.appendChild(objBottomNav);
var objBottomNavCloseLink = document.createElement("a");
objBottomNavCloseLink.setAttribute('id','jive-bottomNavClose');
objBottomNavCloseLink.setAttribute('href','#');
objBottomNavCloseLink.onclick = function() { myJiveImage.end(); return false; }
objBottomNav.appendChild(objBottomNavCloseLink);
var objBottomNavCloseImage = document.createElement("img");
objBottomNavCloseImage.setAttribute('src', fileBottomNavCloseImage);
objBottomNavCloseLink.appendChild(objBottomNavCloseImage);
},
//
// updateImageList()
// Loops through anchor tags looking for 'lightbox' references and applies onclick
// events to appropriate links. You can rerun after dynamically adding images w/ajax.
//
updateImageList: function() {
if (!document.getElementsByTagName){ return; }
var images = document.getElementsByTagName('img');
// loop through all image tags
for (var i=0; i= arrayPageSize[3]) {
// Set new height of image to browser widh minus a 250px buffer
var newHeight = arrayPageSize[3] - 250;
// Set width accordingly
var newWidth = (imgPreloader.width*newHeight)/imgPreloader.height;
// Do it
Element.setHeight('jive-lightboxImage',newHeight);
Element.setWidth('jive-lightboxImage',newWidth);
myJiveImage.resizeImageContainer(newWidth,newHeight);
}
// If image width is bigger or equal to window width, resize image
else if(imgPreloader.width >= arrayPageSize[2]) {
// Set new width of image to browser widh minus a 250px buffer
var newWidth = arrayPageSize[2] - 250;
// Set width accordingly
var newHeight = (imgPreloader.height*newWidth)/imgPreloader.width;
// Do it
Element.setHeight('jive-lightboxImage',newHeight);
Element.setWidth('jive-lightboxImage',newWidth);
myJiveImage.resizeImageContainer(newWidth,newHeight);
}
else {
Element.setHeight('jive-lightboxImage',imgPreloader.height);
Element.setWidth('jive-lightboxImage',imgPreloader.width);
myJiveImage.resizeImageContainer(imgPreloader.width, imgPreloader.height);
}
*/
Element.setHeight('jive-lightboxImage',imgPreloader.height);
Element.setWidth('jive-lightboxImage',imgPreloader.width);
myJiveImage.resizeImageContainer(imgPreloader.width, imgPreloader.height);
}
imgPreloader.src = imageArray[activeImage][0];
},
//
// resizeImageContainer()
//
resizeImageContainer: function( imgWidth, imgHeight) {
// get curren width and height
this.widthCurrent = Element.getWidth('jive-outerImageContainer');
this.heightCurrent = Element.getHeight('jive-outerImageContainer');
// get new width and height
var widthNew = (imgWidth + (borderSize * 2));
var heightNew = (imgHeight + (borderSize * 2));
// scalars based on change from old to new
this.xScale = ( widthNew / this.widthCurrent) * 100;
this.yScale = ( heightNew / this.heightCurrent) * 100;
// calculate size difference between new and old image, and resize if necessary
wDiff = this.widthCurrent - widthNew;
hDiff = this.heightCurrent - heightNew;
if(!( hDiff == 0)){ new Effect.Scale('jive-outerImageContainer', this.yScale, {scaleX: false, duration: resizeDuration, queue: 'front'}); }
if(!( wDiff == 0)){ new Effect.Scale('jive-outerImageContainer', this.xScale, {scaleY: false, delay: resizeDuration, duration: resizeDuration}); }
// if new and old image are same size and no scaling transition is necessary,
// do a quick pause to prevent image flicker.
if((hDiff == 0) && (wDiff == 0)){
if (navigator.appVersion.indexOf("MSIE")!=-1){ pause(250); } else { pause(100);}
}
Element.setHeight('jive-prevLink', imgHeight);
Element.setHeight('jive-nextLink', imgHeight);
Element.setWidth( 'jive-imageDataContainer', widthNew);
this.showImage();
},
//
// showImage()
// Display image and begin preloading neighbors.
//
showImage: function(){
Element.hide('jive-loading');
new Effect.Appear('jive-lightboxImage', { duration: resizeDuration, queue: 'end', afterFinish: function(){ myJiveImage.updateDetails(); } });
this.preloadNeighborImages();
},
//
// updateDetails()
// Display caption, image number, and bottom nav.
//
updateDetails: function() {
// if caption is not null
if(imageArray[activeImage][1]){
Element.show('jive-caption');
Element.setInnerHTML( 'jive-caption', imageArray[activeImage][1]);
}
// if image is part of set display 'Image x of x'
if(imageArray.length > 1){
Element.show('jive-numberDisplay');
Element.setInnerHTML( 'jive-numberDisplay', "Image " + eval(activeImage + 1) + " of " + imageArray.length);
}
new Effect.Parallel(
[ new Effect.SlideDown( 'jive-imageDataContainer', { sync: true, duration: resizeDuration, from: 0.0, to: 1.0 }),
new Effect.Appear('jive-imageDataContainer', { sync: true, duration: resizeDuration }) ],
{ duration: resizeDuration, afterFinish: function() {
// update overlay size and update nav
var arrayPageSize = getPageSize();
Element.setHeight('jive-overlay', arrayPageSize[1]);
myJiveImage.updateNav();
}
}
);
},
//
// updateNav()
// Display appropriate previous and next hover navigation.
//
updateNav: function() {
Element.show('jive-hoverNav');
// if not first image in set, display prev image button
if(activeImage != 0){
Element.show('jive-prevLink');
document.getElementById('jive-prevLink').onclick = function() {
myJiveImage.changeImage(activeImage - 1); return false;
}
}
// if not last image in set, display next image button
if(activeImage != (imageArray.length - 1)){
Element.show('jive-nextLink');
document.getElementById('jive-nextLink').onclick = function() {
myJiveImage.changeImage(activeImage + 1); return false;
}
}
this.enableKeyboardNav();
},
//
// enableKeyboardNav()
//
enableKeyboardNav: function() {
document.onkeydown = this.keyboardAction;
},
//
// disableKeyboardNav()
//
disableKeyboardNav: function() {
document.onkeydown = '';
},
//
// keyboardAction()
//
keyboardAction: function(e) {
if (e == null) { // ie
keycode = event.keyCode;
escapeKey = 27;
} else { // mozilla
keycode = e.keyCode;
escapeKey = e.DOM_VK_ESCAPE;
}
key = String.fromCharCode(keycode).toLowerCase();
if((key == 'x') || (key == 'o') || (key == 'c') || (keycode == escapeKey)){ // close lightbox
myJiveImage.end();
} else if((key == 'p') || (keycode == 37)){ // display previous image
if(activeImage != 0){
myJiveImage.disableKeyboardNav();
myJiveImage.changeImage(activeImage - 1);
}
} else if((key == 'n') || (keycode == 39)){ // display next image
if(activeImage != (imageArray.length - 1)){
myJiveImage.disableKeyboardNav();
myJiveImage.changeImage(activeImage + 1);
}
}
},
//
// preloadNeighborImages()
// Preload previous and next images.
//
preloadNeighborImages: function(){
if((imageArray.length - 1) > activeImage){
preloadNextImage = new Image();
preloadNextImage.src = imageArray[activeImage + 1][0];
}
if(activeImage > 0){
preloadPrevImage = new Image();
preloadPrevImage.src = imageArray[activeImage - 1][0];
}
},
//
// end()
//
end: function() {
this.disableKeyboardNav();
Element.hide('jive-lightbox');
new Effect.Fade('jive-overlay', { duration: overlayDuration});
showSelectBoxes();
showFlash();
}
}
// -----------------------------------------------------------------------------------
//
// getPageScroll()
// Returns array with x,y page scroll values.
// Core code from - quirksmode.com
//
function getPageScroll(){
var xScroll, yScroll;
if (self.pageYOffset) {
yScroll = self.pageYOffset;
xScroll = self.pageXOffset;
} else if (document.documentElement && document.documentElement.scrollTop){ // Explorer 6 Strict
yScroll = document.documentElement.scrollTop;
xScroll = document.documentElement.scrollLeft;
} else if (document.body) {// all other Explorers
yScroll = document.body.scrollTop;
xScroll = document.body.scrollLeft;
}
arrayPageScroll = new Array(xScroll,yScroll)
return arrayPageScroll;
}
// -----------------------------------------------------------------------------------
//
// getPageSize()
// Returns array with page width, height and window width, height
// Core code from - quirksmode.com
// Edit for Firefox by pHaez
//
function getPageSize(){
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = window.innerWidth + window.scrollMaxX;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
var windowWidth, windowHeight;
// console.log(self.innerWidth);
// console.log(document.documentElement.clientWidth);
if (self.innerHeight) { // all except Explorer
if(document.documentElement.clientWidth){
windowWidth = document.documentElement.clientWidth;
} else {
windowWidth = self.innerWidth;
}
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
// for small pages with total height less then height of the viewport
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
// console.log("xScroll " + xScroll)
// console.log("windowWidth " + windowWidth)
// for small pages with total width less then width of the viewport
if(xScroll < windowWidth){
pageWidth = xScroll;
} else {
pageWidth = windowWidth;
}
// console.log("pageWidth " + pageWidth)
arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
return arrayPageSize;
}
// -----------------------------------------------------------------------------------
//
// getKey(key)
// Gets keycode. If 'x' is pressed then it hides the lightbox.
//
function getKey(e){
if (e == null) { // ie
keycode = event.keyCode;
} else { // mozilla
keycode = e.which;
}
key = String.fromCharCode(keycode).toLowerCase();
if(key == 'x'){
}
}
// -----------------------------------------------------------------------------------
//
// listenKey()
//
function listenKey () { document.onkeypress = getKey; }
// ---------------------------------------------------
function showSelectBoxes(){
var selects = document.getElementsByTagName("select");
for (i = 0; i != selects.length; i++) {
selects[i].style.visibility = "visible";
}
}
// ---------------------------------------------------
function hideSelectBoxes(){
var selects = document.getElementsByTagName("select");
for (i = 0; i != selects.length; i++) {
selects[i].style.visibility = "hidden";
}
}
// ---------------------------------------------------
function showFlash(){
var flashObjects = document.getElementsByTagName("object");
for (i = 0; i < flashObjects.length; i++) {
flashObjects[i].style.visibility = "visible";
}
var flashEmbeds = document.getElementsByTagName("embed");
for (i = 0; i < flashEmbeds.length; i++) {
flashEmbeds[i].style.visibility = "visible";
}
}
// ---------------------------------------------------
function hideFlash(){
var flashObjects = document.getElementsByTagName("object");
for (i = 0; i < flashObjects.length; i++) {
flashObjects[i].style.visibility = "hidden";
}
var flashEmbeds = document.getElementsByTagName("embed");
for (i = 0; i < flashEmbeds.length; i++) {
flashEmbeds[i].style.visibility = "hidden";
}
}
// ---------------------------------------------------
//
// pause(numberMillis)
// Pauses code execution for specified time. Uses busy code, not good.
// Help from Ran Bar-On [ran2103@gmail.com]
//
function pause(ms){
var date = new Date();
curDate = null;
do{var curDate = new Date();}
while( curDate - date < ms);
}
/*
function pause(numberMillis) {
var curently = new Date().getTime() + sender;
while (new Date().getTime();
}
*/
// ---------------------------------------------------
function initJiveImage() { myJiveImage = new JiveImage(); }
Event.observe(window, 'load', initJiveImage, false);
|
|