|
From: Jon O. <jon...@us...> - 2005-08-20 18:19:25
|
Update of /cvsroot/mxbb/core/modules/mx_ajax In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21797/modules/mx_ajax Added Files: DynamicOptionList.js dynamic.js mxajax.js prototype.js rico.js Log Message: Major commit Adding new adminCP, blockCP and many new oo components Finally finalizing latest months hard work :-) --- NEW FILE: prototype.js --- /* Prototype: an object-oriented Javascript library, version 1.2.1 * (c) 2005 Sam Stephenson <sa...@co...> * * THIS FILE IS AUTOMATICALLY GENERATED. When sending patches, please diff * against the source tree, available from the Prototype darcs repository. * * Prototype is freely distributable under the terms of an MIT-style license. * * For details, see the Prototype web site: http://prototype.conio.net/ * /*--------------------------------------------------------------------------*/ var Prototype = { Version: '1.2.1' } var Class = { create: function() { return function() { this.initialize.apply(this, arguments); } } } var Abstract = new Object(); Object.prototype.extend = function(object) { for (property in object) { this[property] = object[property]; } return this; } Function.prototype.bind = function(object) { var method = this; return function() { method.apply(object, arguments); } } Function.prototype.bindAsEventListener = function(object) { var method = this; return function(event) { method.call(object, event || window.event); } } Number.prototype.toColorPart = function() { var digits = this.toString(16); if (this < 16) return '0' + digits; return digits; } var Try = { these: function() { var returnValue; for (var i = 0; i < arguments.length; i++) { var lambda = arguments[i]; try { returnValue = lambda(); break; } catch (e) {} } return returnValue; } } /*--------------------------------------------------------------------------*/ var PeriodicalExecuter = Class.create(); PeriodicalExecuter.prototype = { initialize: function(callback, frequency) { this.callback = callback; this.frequency = frequency; this.currentlyExecuting = false; this.registerCallback(); }, registerCallback: function() { setTimeout(this.onTimerEvent.bind(this), this.frequency * 1000); }, onTimerEvent: function() { if (!this.currentlyExecuting) { try { this.currentlyExecuting = true; this.callback(); } finally { this.currentlyExecuting = false; } } this.registerCallback(); } } /*--------------------------------------------------------------------------*/ function $() { var elements = new Array(); for (var i = 0; i < arguments.length; i++) { var element = arguments[i]; if (typeof element == 'string') element = document.getElementById(element); if (arguments.length == 1) return element; elements.push(element); } return elements; } /*--------------------------------------------------------------------------*/ if (!Array.prototype.push) { Array.prototype.push = function() { var startLength = this.length; for (var i = 0; i < arguments.length; i++) this[startLength + i] = arguments[i]; return this.length; } } if (!Function.prototype.apply) { // Based on code from http://www.youngpup.net/ Function.prototype.apply = function(object, parameters) { var parameterStrings = new Array(); if (!object) object = window; if (!parameters) parameters = new Array(); for (var i = 0; i < parameters.length; i++) parameterStrings[i] = 'x[' + i + ']'; object.__apply__ = this; var result = eval('obj.__apply__(' + parameterStrings[i].join(', ') + ')'); object.__apply__ = null; return result; } } /*--------------------------------------------------------------------------*/ var Ajax = { getTransport: function() { return Try.these( function() {return new ActiveXObject('Msxml2.XMLHTTP')}, function() {return new ActiveXObject('Microsoft.XMLHTTP')}, function() {return new XMLHttpRequest()} ) || false; }, emptyFunction: function() {} } Ajax.Base = function() {}; Ajax.Base.prototype = { setOptions: function(options) { this.options = { method: 'post', asynchronous: true, parameters: '' }.extend(options || {}); } } Ajax.Request = Class.create(); Ajax.Request.Events = ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; Ajax.Request.prototype = (new Ajax.Base()).extend({ initialize: function(url, options) { this.transport = Ajax.getTransport(); this.setOptions(options); try { if (this.options.method == 'get') url += '?' + this.options.parameters + '&_='; this.transport.open(this.options.method, url, this.options.asynchronous); if (this.options.asynchronous) { this.transport.onreadystatechange = this.onStateChange.bind(this); setTimeout((function() {this.respondToReadyState(1)}).bind(this), 10); } this.transport.setRequestHeader('X-Requested-With', 'XMLHttpRequest'); this.transport.setRequestHeader('X-Prototype-Version', Prototype.Version); if (this.options.method == 'post') { this.transport.setRequestHeader('Connection', 'close'); this.transport.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); } if (this.options.requestHeaders) { for (var i=0; i< (this.options.requestHeaders.length-1);i+=2) this.transport.setRequestHeader(this.options.requestHeaders[i], this.options.requestHeaders[i+1]); } var sendData = this.options.postBody ? this.options.postBody : this.options.parameters ? this.options.parameters + '&_' : null; this.transport.send(this.options.method == 'post' ? sendData : null ); } catch (e) { } }, onStateChange: function() { var readyState = this.transport.readyState; if (readyState != 1) this.respondToReadyState(this.transport.readyState); }, respondToReadyState: function(readyState) { var event = Ajax.Request.Events[readyState]; (this.options['on' + event] || Ajax.emptyFunction)(this.transport); } }); Ajax.Updater = Class.create(); Ajax.Updater.prototype = (new Ajax.Base()).extend({ initialize: function(container, url, options) { this.container = $(container); this.setOptions(options); if (this.options.asynchronous) { this.onComplete = this.options.onComplete; this.options.onComplete = this.updateContent.bind(this); } this.request = new Ajax.Request(url, this.options); if (!this.options.asynchronous) this.updateContent(); }, updateContent: function() { if (this.request.transport.status == 200) { if (this.options.insertion) { new this.options.insertion(this.container, this.request.transport.responseText); } else { this.container.innerHTML = this.request.transport.responseText; } } if (this.onComplete) { setTimeout((function() {this.onComplete( this.request.transport)}).bind(this), 10); } } }); /*--------------------------------------------------------------------------*/ var Field = { clear: function() { for (var i = 0; i < arguments.length; i++) $(arguments[i]).value = ''; }, focus: function(element) { $(element).focus(); }, present: function() { for (var i = 0; i < arguments.length; i++) if ($(arguments[i]).value == '') return false; return true; }, select: function(element) { $(element).select(); }, activate: function(element) { $(element).focus(); $(element).select(); } } /*--------------------------------------------------------------------------*/ var Form = { serialize: function(form) { var elements = Form.getElements($(form)); var queryComponents = new Array(); for (var i = 0; i < elements.length; i++) { var queryComponent = Form.Element.serialize(elements[i]); if (queryComponent) queryComponents.push(queryComponent); } return queryComponents.join('&'); }, getElements: function(form) { form = $(form); var elements = new Array(); for (tagName in Form.Element.Serializers) { var tagElements = form.getElementsByTagName(tagName); for (var j = 0; j < tagElements.length; j++) elements.push(tagElements[j]); } return elements; }, disable: function(form) { var elements = Form.getElements(form); for (var i = 0; i < elements.length; i++) { var element = elements[i]; element.blur(); element.disable = 'true'; } }, focusFirstElement: function(form) { form = $(form); var elements = Form.getElements(form); for (var i = 0; i < elements.length; i++) { var element = elements[i]; if (element.type != 'hidden' && !element.disabled) { Field.activate(element); break; } } }, reset: function(form) { $(form).reset(); } } Form.Element = { serialize: function(element) { element = $(element); var method = element.tagName.toLowerCase(); var parameter = Form.Element.Serializers[method](element); if (parameter) return encodeURIComponent(parameter[0]) + '=' + encodeURIComponent(parameter[1]); }, getValue: function(element) { element = $(element); var method = element.tagName.toLowerCase(); var parameter = Form.Element.Serializers[method](element); if (parameter) return parameter[1]; } } Form.Element.Serializers = { input: function(element) { switch (element.type.toLowerCase()) { case 'hidden': case 'password': case 'text': return Form.Element.Serializers.textarea(element); case 'checkbox': case 'radio': return Form.Element.Serializers.inputSelector(element); } return false; }, inputSelector: function(element) { if (element.checked) return [element.name, element.value]; }, textarea: function(element) { return [element.name, element.value]; }, select: function(element) { var index = element.selectedIndex; var value = element.options[index].value || element.options[index].text; return [element.name, (index >= 0) ? value : '']; } } /*--------------------------------------------------------------------------*/ var $F = Form.Element.getValue; /*--------------------------------------------------------------------------*/ Abstract.TimedObserver = function() {} Abstract.TimedObserver.prototype = { initialize: function(element, frequency, callback) { this.frequency = frequency; this.element = $(element); this.callback = callback; this.lastValue = this.getValue(); this.registerCallback(); }, registerCallback: function() { setTimeout(this.onTimerEvent.bind(this), this.frequency * 1000); }, onTimerEvent: function() { var value = this.getValue(); if (this.lastValue != value) { this.callback(this.element, value); this.lastValue = value; } this.registerCallback(); } } Form.Element.Observer = Class.create(); Form.Element.Observer.prototype = (new Abstract.TimedObserver()).extend({ getValue: function() { return Form.Element.getValue(this.element); } }); Form.Observer = Class.create(); Form.Observer.prototype = (new Abstract.TimedObserver()).extend({ getValue: function() { return Form.serialize(this.element); } }); /*--------------------------------------------------------------------------*/ document.getElementsByClassName = function(className) { var children = document.getElementsByTagName('*') || document.all; var elements = new Array(); for (var i = 0; i < children.length; i++) { var child = children[i]; var classNames = child.className.split(' '); for (var j = 0; j < classNames.length; j++) { if (classNames[j] == className) { elements.push(child); break; } } } return elements; } /*--------------------------------------------------------------------------*/ var Element = { toggle: function() { for (var i = 0; i < arguments.length; i++) { var element = $(arguments[i]); element.style.display = (element.style.display == 'none' ? '' : 'none'); } }, hide: function() { for (var i = 0; i < arguments.length; i++) { var element = $(arguments[i]); element.style.display = 'none'; } }, show: function() { for (var i = 0; i < arguments.length; i++) { var element = $(arguments[i]); element.style.display = ''; } }, remove: function(element) { element = $(element); element.parentNode.removeChild(element); }, getHeight: function(element) { element = $(element); return element.offsetHeight; } } var Toggle = new Object(); Toggle.display = Element.toggle; /*--------------------------------------------------------------------------*/ Abstract.Insertion = function(adjacency) { this.adjacency = adjacency; } Abstract.Insertion.prototype = { initialize: function(element, content) { this.element = $(element); this.content = content; if (this.adjacency && this.element.insertAdjacentHTML) { this.element.insertAdjacentHTML(this.adjacency, this.content); } else { this.range = this.element.ownerDocument.createRange(); if (this.initializeRange) this.initializeRange(); this.fragment = this.range.createContextualFragment(this.content); this.insertContent(); } } } var Insertion = new Object(); Insertion.Before = Class.create(); Insertion.Before.prototype = (new Abstract.Insertion('beforeBegin')).extend({ initializeRange: function() { this.range.setStartBefore(this.element); }, insertContent: function() { this.element.parentNode.insertBefore(this.fragment, this.element); } }); Insertion.Top = Class.create(); Insertion.Top.prototype = (new Abstract.Insertion('afterBegin')).extend({ initializeRange: function() { this.range.selectNodeContents(this.element); this.range.collapse(true); }, insertContent: function() { this.element.insertBefore(this.fragment, this.element.firstChild); } }); Insertion.Bottom = Class.create(); Insertion.Bottom.prototype = (new Abstract.Insertion('beforeEnd')).extend({ initializeRange: function() { this.range.selectNodeContents(this.element); this.range.collapse(this.element); }, insertContent: function() { this.element.appendChild(this.fragment); } }); Insertion.After = Class.create(); Insertion.After.prototype = (new Abstract.Insertion('afterEnd')).extend({ initializeRange: function() { this.range.setStartAfter(this.element); }, insertContent: function() { this.element.parentNode.insertBefore(this.fragment, this.element.nextSibling); } }); /*--------------------------------------------------------------------------*/ var Effect = new Object(); Effect.Highlight = Class.create(); Effect.Highlight.prototype = { initialize: function(element) { this.element = $(element); this.start = 153; this.finish = 255; this.current = this.start; this.fade(); }, fade: function() { if (this.isFinished()) return; if (this.timer) clearTimeout(this.timer); this.highlight(this.element, this.current); this.current += 17; this.timer = setTimeout(this.fade.bind(this), 250); }, isFinished: function() { return this.current > this.finish; }, highlight: function(element, current) { element.style.backgroundColor = "#ffff" + current.toColorPart(); } } Effect.Fade = Class.create(); Effect.Fade.prototype = { initialize: function(element) { this.element = $(element); this.start = 100; this.finish = 0; this.current = this.start; this.fade(); }, fade: function() { if (this.isFinished()) { this.element.style.display = 'none'; return; } if (this.timer) clearTimeout(this.timer); this.setOpacity(this.element, this.current); this.current -= 10; this.timer = setTimeout(this.fade.bind(this), 50); }, isFinished: function() { return this.current <= this.finish; }, setOpacity: function(element, opacity) { opacity = (opacity == 100) ? 99.999 : opacity; element.style.filter = "alpha(opacity:"+opacity+")"; element.style.opacity = opacity/100 /*//*/; } } Effect.Scale = Class.create(); Effect.Scale.prototype = { initialize: function(element, percent) { this.element = $(element); this.startScale = 1.0; this.startHeight = this.element.offsetHeight; this.startWidth = this.element.offsetWidth; this.currentHeight = this.startHeight; this.currentWidth = this.startWidth; this.finishScale = (percent/100) /*//*/; if (this.element.style.fontSize=="") this.sizeEm = 1.0; if (this.element.style.fontSize.indexOf("em")>0) this.sizeEm = parseFloat(this.element.style.fontSize); if(this.element.effect_scale) { clearTimeout(this.element.effect_scale.timer); this.startScale = this.element.effect_scale.currentScale; this.startHeight = this.element.effect_scale.startHeight; this.startWidth = this.element.effect_scale.startWidth; if(this.element.effect_scale.sizeEm) this.sizeEm = this.element.effect_scale.sizeEm; } this.element.effect_scale = this; this.currentScale = this.startScale; this.factor = this.finishScale - this.startScale; this.options = arguments[2] || {}; this.scale(); }, scale: function() { if (this.isFinished()) { this.setDimensions(this.element, this.startWidth*this.finishScale, this.startHeight*this.finishScale); if(this.sizeEm) this.element.style.fontSize = this.sizeEm*this.finishScale + "em"; if(this.options.complete) this.options.complete(this); return; } if (this.timer) clearTimeout(this.timer); if (this.options.step) this.options.step(this); this.setDimensions(this.element, this.currentWidth, this.currentHeight); if(this.sizeEm) this.element.style.fontSize = this.sizeEm*this.currentScale + "em"; this.currentScale += (this.factor/10) /*//*/; this.currentWidth = this.startWidth * this.currentScale; this.currentHeight = this.startHeight * this.currentScale; this.timer = setTimeout(this.scale.bind(this), 50); }, isFinished: function() { return (this.factor < 0) ? this.currentScale <= this.finishScale : this.currentScale >= this.finishScale; }, setDimensions: function(element, width, height) { element.style.width = width + 'px'; element.style.height = height + 'px'; } } Effect.Squish = Class.create(); Effect.Squish.prototype = { initialize: function(element) { this.element = $(element); new Effect.Scale(this.element, 1, { complete: this.hide.bind(this) } ); }, hide: function() { this.element.style.display = 'none'; } } Effect.Puff = Class.create(); Effect.Puff.prototype = { initialize: function(element) { this.element = $(element); this.opacity = 100; this.startTop = this.element.top || this.element.offsetTop; this.startLeft = this.element.left || this.element.offsetLeft; new Effect.Scale(this.element, 200, { step: this.fade.bind(this), complete: this.hide.bind(this) } ); }, fade: function(effect) { topd = (((effect.currentScale)*effect.startHeight) - effect.startHeight)/2; leftd = (((effect.currentScale)*effect.startWidth) - effect.startWidth)/2; this.element.style.position='absolute'; this.element.style.top = this.startTop-topd + "px"; this.element.style.left = this.startLeft-leftd + "px"; this.opacity -= 10; this.setOpacity(this.element, this.opacity); if(navigator.appVersion.indexOf('AppleWebKit')>0) this.element.innerHTML += ''; //force redraw on safari }, hide: function() { this.element.style.display = 'none'; }, setOpacity: function(element, opacity) { opacity = (opacity == 100) ? 99.999 : opacity; element.style.filter = "alpha(opacity:"+opacity+")"; element.style.opacity = opacity/100 /*//*/; } } Effect.Appear = Class.create(); Effect.Appear.prototype = { initialize: function(element) { this.element = $(element); this.start = 0; this.finish = 100; this.current = this.start; this.fade(); }, fade: function() { if (this.isFinished()) return; if (this.timer) clearTimeout(this.timer); this.setOpacity(this.element, this.current); this.current += 10; this.timer = setTimeout(this.fade.bind(this), 50); }, isFinished: function() { return this.current > this.finish; }, setOpacity: function(element, opacity) { opacity = (opacity == 100) ? 99.999 : opacity; element.style.filter = "alpha(opacity:"+opacity+")"; element.style.opacity = opacity/100 /*//*/; element.style.display = ''; } } Effect.ContentZoom = Class.create(); Effect.ContentZoom.prototype = { initialize: function(element, percent) { this.element = $(element); if (this.element.style.fontSize=="") this.sizeEm = 1.0; if (this.element.style.fontSize.indexOf("em")>0) this.sizeEm = parseFloat(this.element.style.fontSize); if(this.element.effect_contentzoom) { this.sizeEm = this.element.effect_contentzoom.sizeEm; } this.element.effect_contentzoom = this; this.element.style.fontSize = this.sizeEm*(percent/100) + "em" /*//*/; if(navigator.appVersion.indexOf('AppleWebKit')>0) { this.element.scrollTop -= 1; }; } } --- NEW FILE: DynamicOptionList.js --- // =================================================================== // Author: Matt Kruse <ma...@ma...> // WWW: http://www.mattkruse.com/ // // NOTICE: You may use this code for any purpose, commercial or // private, without any further permission from the author. You may // remove this notice from your final code if you wish, however it is // appreciated by the author if at least my web site address is kept. // // You may *NOT* re-distribute this code in any way except through its // use. That means, you can include it in your product, or your web // site, or any other form where the code is actually being used. You // may not put the plain javascript up on your site for download or // include it in your javascript libraries for download. // If you wish to share this code with others, please just point them // to the URL instead. // Please DO NOT link directly to my .js files from your site. Copy // the files to your server and use them there. Thank you. // =================================================================== var dynamicOptionListCount=0;var dynamicOptionListObjects = new Array(); function initDynamicOptionLists(){for(var i=0;i<dynamicOptionListObjects.length;i++){var dol = dynamicOptionListObjects[i];if(dol.formName!=null){dol.form = document.forms[dol.formName];}else if(dol.formIndex!=null){dol.form = document.forms[dol.formIndex];}else{var name = dol.fieldNames[0][0];for(var f=0;f<document.forms.length;f++){if(typeof(document.forms[f][name])!="undefined"){dol.form = document.forms[f];break;}}if(dol.form==null){alert("ERROR: Couldn't find form element "+name+" in any form on the page! Init aborted");return;}}for(var j=0;j<dol.fieldNames.length;j++){for(var k=0;k<dol.fieldNames[j].length-1;k++){var selObj = dol.form[dol.fieldNames[j][k]];if(typeof(selObj)=="undefined"){alert("Select box named "+dol.fieldNames[j][k]+" could not be found in the form. Init aborted");return;}if(k==0){if(selObj.options!=null){for(l=0;l<selObj.options.length;l++){var sopt = selObj.options[l];var m = dol.findMatchingOptionInArray(dol.options,sopt.text,sopt.value,false);if(m!=null){var reselectForNN6 = sopt.selected;var m2 = new Option(sopt.text, sopt.value, sopt.defaultSelected, sopt.selected);m2.selected = sopt.selected;m2.defaultSelected = sopt.defaultSelected;m2.DOLOption = m;selObj.options[l] = m2;selObj.options[l].selected = reselectForNN6;}}}}if(selObj.onchange==null){selObj.onchange = new Function("dynamicOptionListObjects["+dol.index+"].change(this)");}}}}resetDynamicOptionLists();} function resetDynamicOptionLists(theform){for(var i=0;i<dynamicOptionListObjects.length;i++){var dol = dynamicOptionListObjects[i];if(typeof(theform)=="undefined" || theform==null || theform==dol.form){for(var j=0;j<dol.fieldNames.length;j++){dol.change(dol.form[dol.fieldNames[j][0]],true);}}}} function DOLOption(text,value,defaultSelected,selected){this.text = text;this.value = value;this.defaultSelected = defaultSelected;this.selected = selected;this.options = new Array();return this;} function DynamicOptionList(){this.form = null;this.options = new Array();this.longestString = new Array();this.numberOfOptions = new Array();this.currentNode = null;this.currentField = null;this.currentNodeDepth = 0;this.fieldNames = new Array();this.formIndex = null;this.formName = null;this.fieldListIndexes = new Object();this.fieldIndexes = new Object();this.selectFirstOption = true;this.numberOfOptions = new Array();this.longestString = new Array();this.values = new Object();this.forValue = DOL_forValue;this.forText = DOL_forText;this.forField = DOL_forField;this.forX = DOL_forX;this.addOptions = DOL_addOptions;this.addOptionsTextValue = DOL_addOptionsTextValue;this.setDefaultOptions = DOL_setDefaultOptions;this.setValues = DOL_setValues;this.setValue = DOL_setValues;this.setFormIndex = DOL_setFormIndex;this.setFormName = DOL_setFormName;this.printOptions = DOL_printOptions;this.addDependentFields = DOL_addDependentFields;this.change = DOL_change;this.child = DOL_child;this.selectChildOptions = DOL_selectChildOptions;this.populateChild = DOL_populateChild;this.change = DOL_change;this.addNewOptionToList = DOL_addNewOptionToList;this.findMatchingOptionInArray = DOL_findMatchingOptionInArray;if(arguments.length > 0){for(var i=0;i<arguments.length;i++){this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length;this.fieldIndexes[arguments[i].toString()] = i;}this.fieldNames[this.fieldNames.length] = arguments;}this.index = window.dynamicOptionListCount++;window["dynamicOptionListObjects"][this.index] = this;} function DOL_findMatchingOptionInArray(a,text,value,exactMatchRequired){if(a==null || typeof(a)=="undefined"){return null;}var value_match = null;var text_match = null;for(var i=0;i<a.length;i++){var opt = a[i];if(opt.value==value && opt.text==text){return opt;}if(!exactMatchRequired){if(value_match==null && value!=null && opt.value==value){value_match = opt;}if(text_match==null && text!=null && opt.text==text){text_match = opt;}}}return(value_match!=null)?value_match:text_match;} function DOL_forX(s,type){if(this.currentNode==null){this.currentNodeDepth=0;}var useNode =(this.currentNode==null)?this:this.currentNode;var o = this.findMatchingOptionInArray(useNode["options"],(type=="text")?s:null,(type=="value")?s:null,false);if(o==null){o = new DOLOption(null,null,false,false);o[type] = s;useNode.options[useNode.options.length] = o;}this.currentNode = o;this.currentNodeDepth++;return this;} function DOL_forValue(s){return this.forX(s,"value");} function DOL_forText(s){return this.forX(s,"text");} function DOL_forField(f){this.currentField = f;return this;} function DOL_addNewOptionToList(a, text, value, defaultSelected){var o = new DOLOption(text,value,defaultSelected,false);if(a==null){a = new Array();}for(var i=0;i<a.length;i++){if(a[i].text==o.text && a[i].value==o.value){if(o.selected){a[i].selected=true;}if(o.defaultSelected){a[i].defaultSelected = true;}return a;}}a[a.length] = o;} function DOL_addOptions(){if(this.currentNode==null){this.currentNode = this;}if(this.currentNode["options"] == null){this.currentNode["options"] = new Array();}for(var i=0;i<arguments.length;i++){var text = arguments[i];this.addNewOptionToList(this.currentNode.options,text,text,false);if(typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined"){this.numberOfOptions[this.currentNodeDepth]=0;}if(this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]){this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length;}if(typeof(this.longestString[this.currentNodeDepth])=="undefined" ||(text.length > this.longestString[this.currentNodeDepth].length)){this.longestString[this.currentNodeDepth] = text;}}this.currentNode = null;this.currentNodeDepth = 0;} function DOL_addOptionsTextValue(){if(this.currentNode==null){this.currentNode = this;}if(this.currentNode["options"] == null){this.currentNode["options"] = new Array();}for(var i=0;i<arguments.length;i++){var text = arguments[i++];var value = arguments[i];this.addNewOptionToList(this.currentNode.options,text,value,false);if(typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined"){this.numberOfOptions[this.currentNodeDepth]=0;}if(this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]){this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length;}if(typeof(this.longestString[this.currentNodeDepth])=="undefined" ||(text.length > this.longestString[this.currentNodeDepth].length)){this.longestString[this.currentNodeDepth] = text;}}this.currentNode = null;this.currentNodeDepth = 0;} function DOL_child(obj){var listIndex = this.fieldListIndexes[obj.name];var index = this.fieldIndexes[obj.name];if(index <(this.fieldNames[listIndex].length-1)){return this.form[this.fieldNames[listIndex][index+1]];}return null;} function DOL_setDefaultOptions(){if(this.currentNode==null){this.currentNode = this;}for(var i=0;i<arguments.length;i++){var o = this.findMatchingOptionInArray(this.currentNode.options,null,arguments[i],false);if(o!=null){o.defaultSelected = true;}}this.currentNode = null;} function DOL_setValues(){if(this.currentField==null){alert("Can't call setValues() without using forField() first!");return;}if(typeof(this.values[this.currentField])=="undefined"){this.values[this.currentField] = new Object();}for(var i=0;i<arguments.length;i++){this.values[this.currentField][arguments[i]] = true;}this.currentField = null;} function DOL_setFormIndex(i){this.formIndex = i;} function DOL_setFormName(n){this.formName = n;} function DOL_printOptions(name){if((navigator.appName == 'Netscape') &&(parseInt(navigator.appVersion) <= 4)){var index = this.fieldIndexes[name];var ret = "";if(typeof(this.numberOfOptions[index])!="undefined"){for(var i=0;i<this.numberOfOptions[index];i++){ret += "<OPTION>";}}ret += "<OPTION>";if(typeof(this.longestString[index])!="undefined"){for(var i=0;i<this.longestString[index].length;i++){ret += "_";}}document.writeln(ret);}} function DOL_addDependentFields(){for(var i=0;i<arguments.length;i++){this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length;this.fieldIndexes[arguments[i].toString()] = i;}this.fieldNames[this.fieldNames.length] = arguments;} function DOL_change(obj, usePreselected){if(usePreselected==null || typeof(usePreselected)=="undefined"){usePreselected = false;}var changedListIndex = this.fieldListIndexes[obj.name];var changedIndex = this.fieldIndexes[obj.name];var child = this.child(obj);if(child == null){return;}if(obj.type == "select-one"){if(child.options!=null){child.options.length=0;}if(obj.options!=null && obj.options.length>0 && obj.selectedIndex>=0){var o = obj.options[obj.selectedIndex];this.populateChild(o.DOLOption,child,usePreselected);this.selectChildOptions(child,usePreselected);}}else if(obj.type == "select-multiple"){var currentlySelectedOptions = new Array();if(!usePreselected){for(var i=0;i<child.options.length;i++){var co = child.options[i];if(co.selected){this.addNewOptionToList(currentlySelectedOptions, co.text, co.value, co.defaultSelected);}}}child.options.length=0;if(obj.options!=null){var obj_o = obj.options;for(var i=0;i<obj_o.length;i++){if(obj_o[i].selected){this.populateChild(obj_o[i].DOLOption,child,usePreselected);}}var atLeastOneSelected = false;if(!usePreselected){for(var i=0;i<child.options.length;i++){var m = this.findMatchingOptionInArray(currentlySelectedOptions,child.options[i].text,child.options[i].value,true);if(m!=null){child.options[i].selected = true;atLeastOneSelected = true;}}}if(!atLeastOneSelected){this.selectChildOptions(child,usePreselected);}}}this.change(child,usePreselected);} function DOL_populateChild(dolOption,childSelectObj,usePreselected){if(dolOption!=null && dolOption.options!=null){for(var j=0;j<dolOption.options.length;j++){var srcOpt = dolOption.options[j];if(childSelectObj.options==null){childSelectObj.options = new Array();}var duplicate = false;var preSelectedExists = false;for(var k=0;k<childSelectObj.options.length;k++){var csi = childSelectObj.options[k];if(csi.text==srcOpt.text && csi.value==srcOpt.value){duplicate = true;break;}}if(!duplicate){var newopt = new Option(srcOpt.text, srcOpt.value, false, false);newopt.selected = false;newopt.defaultSelected = false;newopt.DOLOption = srcOpt;childSelectObj.options[childSelectObj.options.length] = newopt;}}}} function DOL_selectChildOptions(obj,usePreselected){var values = this.values[obj.name];var preselectedExists = false;if(usePreselected && values!=null && typeof(values)!="undefined"){for(var i=0;i<obj.options.length;i++){var v = obj.options[i].value;if(v!=null && values[v]!=null && typeof(values[v])!="undefined"){preselectedExists = true;break;}}}var atLeastOneSelected = false;for(var i=0;i<obj.options.length;i++){var o = obj.options[i];if(preselectedExists && o.value!=null && values[o.value]!=null && typeof(values[o.value])!="undefined"){o.selected = true;atLeastOneSelected = true;}else if(!preselectedExists && o.DOLOption!=null && o.DOLOption.defaultSelected){o.selected = true;atLeastOneSelected = true;}else{o.selected = false;}}if(this.selectFirstOption && !atLeastOneSelected && obj.options.length>0){obj.options[0].selected = true;}else if(!atLeastOneSelected && obj.type=="select-one"){obj.selectedIndex = -1;}} --- NEW FILE: dynamic.js --- // Global objects to keep track of DynamicOptionList objects created on the page var dynamicOptionListCount=0; var dynamicOptionListObjects = new Array(); // Init call to setup lists after page load. One call to this function sets up all lists. function initDynamicOptionLists() { // init each DynamicOptionList object for (var i=0; i<dynamicOptionListObjects.length; i++) { var dol = dynamicOptionListObjects[i]; // Find the form associated with this list if (dol.formName!=null) { dol.form = document.forms[dol.formName]; } else if (dol.formIndex!=null) { dol.form = document.forms[dol.formIndex]; } else { // Form wasn't set manually, so go find it! // Search for the first form element name in the lists var name = dol.fieldNames[0][0]; for (var f=0; f<document.forms.length; f++) { if (typeof(document.forms[f][name])!="undefined") { dol.form = document.forms[f]; break; } } if (dol.form==null) { alert("ERROR: Couldn't find form element "+name+" in any form on the page! Init aborted"); return; } } // Form is found, now set the onchange attributes of each dependent select box for (var j=0; j<dol.fieldNames.length; j++) { // For each set of field names... for (var k=0; k<dol.fieldNames[j].length-1; k++) { // For each field in the set... var selObj = dol.form[dol.fieldNames[j][k]]; if (typeof(selObj)=="undefined") { alert("Select box named "+dol.fieldNames[j][k]+" could not be found in the form. Init aborted"); return; } // Map the HTML options in the first select into the options we created if (k==0) { if (selObj.options!=null) { for (l=0; l<selObj.options.length; l++) { var sopt = selObj.options[l]; var m = dol.findMatchingOptionInArray(dol.options,sopt.text,sopt.value,false); if (m!=null) { var reselectForNN6 = sopt.selected; var m2 = new Option(sopt.text, sopt.value, sopt.defaultSelected, sopt.selected); m2.selected = sopt.selected; // For some reason I need to do this to make NN4 happy m2.defaultSelected = sopt.defaultSelected; m2.DOLOption = m; selObj.options[l] = m2; selObj.options[l].selected = reselectForNN6; // Reselect this option for NN6 to be happy. Yuck. } } } } if (selObj.onchange==null) { // We only modify the onChange attribute if it's empty! Otherwise do it yourself in your source! selObj.onchange = new Function("dynamicOptionListObjects["+dol.index+"].change(this)"); } } } } // Set the preselectd options on page load resetDynamicOptionLists(); } // This function populates lists with the preselected values. // It's pulled out into a separate function so it can be hooked into a 'reset' button on a form // Optionally passed a form object which should be the only form reset function resetDynamicOptionLists(theform) { // reset each DynamicOptionList object for (var i=0; i<dynamicOptionListObjects.length; i++) { var dol = dynamicOptionListObjects[i]; if (typeof(theform)=="undefined" || theform==null || theform==dol.form) { for (var j=0; j<dol.fieldNames.length; j++) { dol.change(dol.form[dol.fieldNames[j][0]],true); // Second argument says to use preselected values rather than default values } } } } // An object to represent an Option() but just for data-holding function DOLOption(text,value,defaultSelected,selected) { this.text = text; this.value = value; this.defaultSelected = defaultSelected; this.selected = selected; this.options = new Array(); // To hold sub-options return this; } // DynamicOptionList CONSTRUCTOR function DynamicOptionList() { this.form = null;// The form this list belongs to this.options = new Array();// Holds the options of dependent lists this.longestString = new Array();// Longest string that is currently a potential option (for Netscape) this.numberOfOptions = new Array();// The total number of options that might be displayed, to build dummy options (for Netscape) this.currentNode = null;// The current node that has been selected with forValue() or forText() this.currentField = null;// The current field that is selected to be used for setValue() this.currentNodeDepth = 0;// How far down the tree the currentNode is this.fieldNames = new Array();// Lists of dependent fields which use this object this.formIndex = null;// The index of the form to associate with this list this.formName = null;// The name of the form to associate with this list this.fieldListIndexes = new Object();// Hold the field lists index where fields exist this.fieldIndexes = new Object();// Hold the index within the list where fields exist this.selectFirstOption = true;// Whether or not to select the first option by default if no options are default or preselected, otherwise set the selectedIndex = -1 this.numberOfOptions = new Array();// Store the max number of options for a given option list this.longestString = new Array();// Store the longest possible string this.values = new Object(); // Will hold the preselected values for fields, by field name // Method mappings this.forValue = DOL_forValue; this.forText = DOL_forText; this.forField = DOL_forField; this.forX = DOL_forX; this.addOptions = DOL_addOptions; this.addOptionsTextValue = DOL_addOptionsTextValue; this.setDefaultOptions = DOL_setDefaultOptions; this.setValues = DOL_setValues; this.setValue = DOL_setValues; this.setFormIndex = DOL_setFormIndex; this.setFormName = DOL_setFormName; this.printOptions = DOL_printOptions; this.addDependentFields = DOL_addDependentFields; this.change = DOL_change; this.child = DOL_child; this.selectChildOptions = DOL_selectChildOptions; this.populateChild = DOL_populateChild; this.change = DOL_change; this.addNewOptionToList = DOL_addNewOptionToList; this.findMatchingOptionInArray = DOL_findMatchingOptionInArray; // Optionally pass in the dependent field names if (arguments.length > 0) { // Process arguments and add dependency groups for (var i=0; i<arguments.length; i++) { this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length; this.fieldIndexes[arguments[i].toString()] = i; } this.fieldNames[this.fieldNames.length] = arguments; } // Add this object to the global array of dynamicoptionlist objects this.index = window.dynamicOptionListCount++; window["dynamicOptionListObjects"][this.index] = this; } // Given an array of Option objects, search for an existing option that matches value, text, or both function DOL_findMatchingOptionInArray(a,text,value,exactMatchRequired) { if (a==null || typeof(a)=="undefined") { return null; } var value_match = null; // Whether or not a value has been matched var text_match = null; // Whether or not a text has been matched for (var i=0; i<a.length; i++) { var opt = a[i]; // If both value and text match, return it right away if (opt.value==value && opt.text==text) { return opt; } if (!exactMatchRequired) { // If value matches, store it until we complete scanning the list if (value_match==null && value!=null && opt.value==value) { value_match = opt; } // If text matches, store it for later if (text_match==null && text!=null && opt.text==text) { text_match = opt; } } } return (value_match!=null)?value_match:text_match; } // Util function used by forValue and forText function DOL_forX(s,type) { if (this.currentNode==null) { this.currentNodeDepth=0; } var useNode = (this.currentNode==null)?this:this.currentNode; var o = this.findMatchingOptionInArray(useNode["options"],(type=="text")?s:null,(type=="value")?s:null,false); if (o==null) { o = new DOLOption(null,null,false,false); o[type] = s; useNode.options[useNode.options.length] = o; } this.currentNode = o; this.currentNodeDepth++; return this; } // Set the portion of the list structure that is to be used by a later operation like addOptions function DOL_forValue(s) { return this.forX(s,"value"); } // Set the portion of the list structure that is to be used by a later operation like addOptions function DOL_forText(s) { return this.forX(s,"text"); } // Set the field to be used for setValue() calls function DOL_forField(f) { this.currentField = f; return this; } // Create and add an option to a list, avoiding duplicates function DOL_addNewOptionToList(a, text, value, defaultSelected) { var o = new DOLOption(text,value,defaultSelected,false); // Add the option to the array if (a==null) { a = new Array(); } for (var i=0; i<a.length; i++) { if (a[i].text==o.text && a[i].value==o.value) { if (o.selected) { a[i].selected=true; } if (o.defaultSelected) { a[i].defaultSelected = true; } return a; } } a[a.length] = o; } // Add sub-options to the currently-selected node, with the same text and value for each option function DOL_addOptions() { if (this.currentNode==null) { this.currentNode = this; } if (this.currentNode["options"] == null) { this.currentNode["options"] = new Array(); } for (var i=0; i<arguments.length; i++) { var text = arguments[i]; this.addNewOptionToList(this.currentNode.options,text,text,false); if (typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined") { this.numberOfOptions[this.currentNodeDepth]=0; } if (this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]) { this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length; } if (typeof(this.longestString[this.currentNodeDepth])=="undefined" || (text.length > this.longestString[this.currentNodeDepth].length)) { this.longestString[this.currentNodeDepth] = text; } } this.currentNode = null; this.currentNodeDepth = 0; } // Add sub-options to the currently-selected node, specifying separate text and values for each option function DOL_addOptionsTextValue() { if (this.currentNode==null) { this.currentNode = this; } if (this.currentNode["options"] == null) { this.currentNode["options"] = new Array(); } for (var i=0; i<arguments.length; i++) { var text = arguments[i++]; var value = arguments[i]; this.addNewOptionToList(this.currentNode.options,text,value,false); if (typeof(this.numberOfOptions[this.currentNodeDepth])=="undefined") { this.numberOfOptions[this.currentNodeDepth]=0; } if (this.currentNode.options.length > this.numberOfOptions[this.currentNodeDepth]) { this.numberOfOptions[this.currentNodeDepth] = this.currentNode.options.length; } if (typeof(this.longestString[this.currentNodeDepth])=="undefined" || (text.length > this.longestString[this.currentNodeDepth].length)) { this.longestString[this.currentNodeDepth] = text; } } this.currentNode = null; this.currentNodeDepth = 0; } // Find the first dependent list of a select box // If it's the last list in a chain, return null because there are no children function DOL_child(obj) { var listIndex = this.fieldListIndexes[obj.name]; var index = this.fieldIndexes[obj.name]; if (index < (this.fieldNames[listIndex].length-1)) { return this.form[this.fieldNames[listIndex][index+1]]; } return null; } // Set the options which should be selected by default for a certain value in the parent function DOL_setDefaultOptions() { if (this.currentNode==null) { this.currentNode = this; } for (var i=0; i<arguments.length; i++) { var o = this.findMatchingOptionInArray(this.currentNode.options,null,arguments[i],false); if (o!=null) { o.defaultSelected = true; } } this.currentNode = null; } // Set the options which should be selected when the page loads. This is different than the default value and ONLY applies when the page LOADS function DOL_setValues() { if (this.currentField==null) { alert("Can't call setValues() without using forField() first!"); return; } if (typeof(this.values[this.currentField])=="undefined") { this.values[this.currentField] = new Object(); } for (var i=0; i<arguments.length; i++) { this.values[this.currentField][arguments[i]] = true; } this.currentField = null; } // Manually set the form for the object using an index function DOL_setFormIndex(i) { this.formIndex = i; } // Manually set the form for the object using a form name function DOL_setFormName(n) { this.formName = n; } // Print blank <option> objects for Netscape4, since it refuses to grow or shrink select boxes for new options function DOL_printOptions(name) { // Only need to write out "dummy" options for Netscape4 if ((navigator.appName == 'Netscape') && (parseInt(navigator.appVersion) <= 4)){ var index = this.fieldIndexes[name]; var ret = ""; if (typeof(this.numberOfOptions[index])!="undefined") { for (var i=0; i<this.numberOfOptions[index]; i++) { ret += "<OPTION>"; } } ret += "<OPTION>"; if (typeof(this.longestString[index])!="undefined") { for (var i=0; i<this.longestString[index].length; i++) { ret += "_"; } } document.writeln(ret); } } // Add a list of field names which use this option-mapping object. // A single mapping object may be used by multiple sets of fields function DOL_addDependentFields() { for (var i=0; i<arguments.length; i++) { this.fieldListIndexes[arguments[i].toString()] = this.fieldNames.length; this.fieldIndexes[arguments[i].toString()] = i; } this.fieldNames[this.fieldNames.length] = arguments; } // Called when a parent select box is changed. It populates its direct child, then calls change on the child object to continue the population. function DOL_change(obj, usePreselected) { if (usePreselected==null || typeof(usePreselected)=="undefined") { usePreselected = false; } var changedListIndex = this.fieldListIndexes[obj.name]; var changedIndex = this.fieldIndexes[obj.name]; var child = this.child(obj); if (child == null) { return; } // No child, no need to continue if (obj.type == "select-one") { // Treat single-select differently so we don't have to scan the entire select list, which could potentially speed things up if (child.options!=null) { child.options.length=0; // Erase all the options from the child so we can re-populate } if (obj.options!=null && obj.options.length>0 && obj.selectedIndex>=0) { var o = obj.options[obj.selectedIndex]; this.populateChild(o.DOLOption,child,usePreselected); this.selectChildOptions(child,usePreselected); } } else if (obj.type == "select-multiple") { // For each selected value in the parent, find the options to fill in for this list // Loop through the child list and keep track of options that are currently selected var currentlySelectedOptions = new Array(); if (!usePreselected) { for (var i=0; i<child.options.length; i++) { var co = child.options[i]; if (co.selected) { this.addNewOptionToList(currentlySelectedOptions, co.text, co.value, co.defaultSelected); } } } child.options.length=0; if (obj.options!=null) { var obj_o = obj.options; // For each selected option in the parent... for (var i=0; i<obj_o.length; i++) { if (obj_o[i].selected) { // if option is selected, add its children to the list this.populateChild(obj_o[i].DOLOption,child,usePreselected); } } // Now go through and re-select any options which were selected before var atLeastOneSelected = false; if (!usePreselected) { for (var i=0; i<child.options.length; i++) { var m = this.findMatchingOptionInArray(currentlySelectedOptions,child.options[i].text,child.options[i].value,true); if (m!=null) { child.options[i].selected = true; atLeastOneSelected = true; } } } if (!atLeastOneSelected) { this.selectChildOptions(child,usePreselected); } } } // Change all the way down the chain this.change(child,usePreselected); } function DOL_populateChild(dolOption,childSelectObj,usePreselected) { // If this opton has sub-options, populate the child list with them if (dolOption!=null && dolOption.options!=null) { for (var j=0; j<dolOption.options.length; j++) { var srcOpt = dolOption.options[j]; if (childSelectObj.options==null) { childSelectObj.options = new Array(); } // Put option into select list var duplicate = false; var preSelectedExists = false; for (var k=0; k<childSelectObj.options.length; k++) { var csi = childSelectObj.options[k]; if (csi.text==srcOpt.text && csi.value==srcOpt.value) { duplicate = true; break; } } if (!duplicate) { var newopt = new Option(srcOpt.text, srcOpt.value, false, false); newopt.selected = false; // Again, we have to do these two statements for NN4 to work newopt.defaultSelected = false; newopt.DOLOption = srcOpt; childSelectObj.options[childSelectObj.options.length] = newopt; } } } } // Once a child select is populated, go back over it to select options which should be selected function DOL_selectChildOptions(obj,usePreselected) { // Look to see if any options are preselected=true. If so, then set then selected if usePreselected=true, otherwise set defaults var values = this.values[obj.name]; var preselectedExists = false; if (usePreselected && values!=null && typeof(values)!="undefined") { for (var i=0; i<obj.options.length; i++) { var v = obj.options[i].value; if (v!=null && values[v]!=null && typeof(values[v])!="undefined") { preselectedExists = true; break; } } } // Go back over all the options to do the selection var atLeastOneSelected = false; for (var i=0; i<obj.options.length; i++) { var o = obj.options[i]; if (preselectedExists && o.value!=null && values[o.value]!=null && typeof(values[o.value])!="undefined") { o.selected = true; atLeastOneSelected = true; } else if (!preselectedExists && o.DOLOption!=null && o.DOLOption.defaultSelected) { o.selected = true; atLeastOneSelected = true; } else { o.selected = false; } } // If nothing else was selected, select the first one by default if (this.selectFirstOption && !atLeastOneSelected && obj.options.length>0) { obj.options[0].selected = true; } else if (!atLeastOneSelected && obj.type=="select-one") { obj.selectedIndex = -1; } } --- NEW FILE: mxajax.js --- (This appears to be a binary file; contents omitted.) --- NEW FILE: rico.js --- /** * * Copyright 2005 Sabre Airline Solutions * * 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. **/ /* openrico.org rico.js */ // rico.js -------------------- [...1856 lines suppressed...] else if ( document.documentElement && document.documentElement.scrollLeft ) return document.documentElement.scrollLeft; else if ( document.body ) return document.body.scrollLeft; else return 0; }, docScrollTop: function() { if ( window.pageYOffset ) return window.pageYOffset; else if ( document.documentElement && document.documentElement.scrollTop ) return document.documentElement.scrollTop; else if ( document.body ) return document.body.scrollTop; else return 0; } }; |