diff options
| author | Christian Fowler <cfowler2@wcpss.net> | 2014-08-01 13:58:46 -0400 |
|---|---|---|
| committer | Christian Fowler <cfowler2@wcpss.net> | 2014-08-01 13:58:46 -0400 |
| commit | e8c25801333d15037c0bf4ab0af755df02332122 (patch) | |
| tree | 8b3780b2ab62510a922a58568088eb9812eeb74d /javascript | |
| parent | fc2ca6e16db78faca6c2859d4ef39991d698f26a (diff) | |
| download | util-e8c25801333d15037c0bf4ab0af755df02332122.tar.gz util-e8c25801333d15037c0bf4ab0af755df02332122.tar.bz2 util-e8c25801333d15037c0bf4ab0af755df02332122.zip | |
remove unused javascript libs
Diffstat (limited to 'javascript')
36 files changed, 0 insertions, 21867 deletions
diff --git a/javascript/MochiKitBitAjax.js b/javascript/MochiKitBitAjax.js deleted file mode 100644 index d37c146..0000000 --- a/javascript/MochiKitBitAjax.js +++ /dev/null @@ -1,40 +0,0 @@ -/* Dependencies: MochiKit Base Async */ -BitAjax = { - "updater": function(target, url, queryString) { - BitBase.showSpinner(); - if (queryString != "" && queryString !=null){ - url += "?"+queryString+"&tk="+bitTk; - } - var r = doSimpleXMLHttpRequest(url); - r.addCallback( BitAjax.updaterCallback, target ); - r.addErrback( BitAjax.error ); - }, - - "updaterCallback": function(target, rslt){ - BitBase.hideSpinner(); - var e = document.getElementById(target); - if (e != null){e.innerHTML = rslt.responseText;} - }, - - "error": function( rqst ) { - alert( 'Sorry, there was a problem getting the requested data:\n'+rqst.message ); - BitBase.hideSpinner(); - }, - - "getAndCall": function(elm, func, url, force) { - if (!force && elm.loadedResponse) { - func(elm.loadedResponse); - } else { - BitBase.showSpinner(); - var r = doSimpleXMLHttpRequest(url); - r.addCallback( BitAjax.getAndCallCallback, elm, func ); - r.addErrback( BitAjax.error ); - } - }, - - "getAndCallCallback": function(elm, func, rslt){ - BitBase.hideSpinner(); - elm.loadedResponse = rslt.responseText || "No Response."; - func(elm.loadedResponse); - } -} diff --git a/javascript/MochiKitBitTextarea.js b/javascript/MochiKitBitTextarea.js deleted file mode 100644 index 95d6218..0000000 --- a/javascript/MochiKitBitTextarea.js +++ /dev/null @@ -1,95 +0,0 @@ -/* this is mostly lifted from a hack of Drupal textarea.js - * see: http://drupal.org/files/issues/textarea-grow_2.patch - */ -/* Dependencies: MochiKit Base DOM Style*/ -BitTextarea = { - "DUMMY_DIV":null, - - //add this to body.onload or call if ajaxing in a from - "registerTextareas":function(){ - var BT = BitTextarea; - //create a dummy container for measuring text - oDiv1 = DIV( {'style':'position:absolute; top:0; left:0; overflow:hidden; visibility:hidden; height:10px;'}, null); - oDiv2 = DIV({'style':'position:absolute; top:0; left:0;', 'id':'BitTextareaDummy'},null); - //add these separately to avoid some weird bug in the div construction - document.body.appendChild ( oDiv1 ); - oDiv1.appendChild( oDiv2 ); - BT.DUMMY_DIV = $('BitTextareaDummy'); - //get all text areas on the page - aTextareas = document.getElementsByTagName( "textarea" ); - //assign onchange listeners - for( n=0; n<aTextareas.length; n++ ){ - aTextareas[n].onkeyup = partial( BT.onTextareaChange, aTextareas[n] ); - BT.onTextareaChange( aTextareas[n] ); - } - }, - - "onTextareaChange":function( e ){ - var BT = BitTextarea; - //get current text area size - oElmDims = MochiKit.Style.getElementDimensions( e ); - iTextareaH = oElmDims.h; - //get text size - iTextsizeH = BT.getTextHeight( e ); - //diff - iDiff = iTextsizeH - iTextareaH; - //check min and max - //add diff to text area size - iNewH = oElmDims.h; - if ( iDiff > 0 ){ - iMaxHeight = BT.getMaxHeight(); - iNewH = ( iTextsizeH > iMaxHeight ) ? iMaxHeight : iTextsizeH; - }else if( iDiff < 0 ){ - iNewH = iTextsizeH; - } - //enforce min in all cases - iMinHeight = BT.getMinHeight(); - iNewH = ( iNewH < iMinHeight ) ? iMinHeight : iNewH; - e.style.height = iNewH+"px"; - }, - - "getMaxHeight":function(){ - return MochiKit.Style.getViewportDimensions().h - 40; - }, - - "getMinHeight":function(){ - return 100; - }, - - "getTextHeight":function( e ){ - var BT = BitTextarea; - oDiv = BT.DUMMY_DIV; - oDiv.innerHTML = BT.encodeHTML(e.value); - BT.cloneTextareaStyles( e, oDiv ); - return oDiv.clientHeight; - }, - - "cloneTextareaStyles":function( e,div ){ - var f = MochiKit.Style.getStyle; - var style = { - fontFamily: f( e, 'fontFamily')||'', - fontSize: f( e, 'fontSize')||'', - fontWeight: f( e, 'fontWeight')||'', - fontStyle: f( e, 'fontStyle')||'', - fontStretch: f( e, 'fontStretch')||'', - fontVariant: f( e, 'fontVariant')||'', - letterSpacing: f( e, 'letterSpacing')||'', - wordSpacing: f( e, 'wordSpacing')||'', - lineHeight: f( e, 'lineHeight')||'', - textWrap: 'unrestricted' - }; - MochiKit.Style.setStyle( div, style ); - div.style.width = MochiKit.Style.getElementDimensions( e ).w + "px"; - }, - - "encodeHTML":function(str) { - str = String(str); - var aReplace = { '&': '&', '"': '"', '<': '<', '>': '>' }; - for (var char in aReplace) { - var regex = new RegExp(char, 'g'); - str = str.replace(regex, aReplace[char]); - } - str = str.replace(/(\r\n|[\r\n])/g, "<br />"); - return str; - } -}; diff --git a/javascript/libs/MochiKit/Async.js b/javascript/libs/MochiKit/Async.js deleted file mode 100644 index bb2cc5e..0000000 --- a/javascript/libs/MochiKit/Async.js +++ /dev/null @@ -1,700 +0,0 @@ -/*** - -MochiKit.Async 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005 Bob Ippolito. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide("MochiKit.Async"); - dojo.require("MochiKit.Base"); -} -if (typeof(JSAN) != 'undefined') { - JSAN.use("MochiKit.Base", []); -} - -try { - if (typeof(MochiKit.Base) == 'undefined') { - throw ""; - } -} catch (e) { - throw "MochiKit.Async depends on MochiKit.Base!"; -} - -if (typeof(MochiKit.Async) == 'undefined') { - MochiKit.Async = {}; -} - -MochiKit.Async.NAME = "MochiKit.Async"; -MochiKit.Async.VERSION = "1.4"; -MochiKit.Async.__repr__ = function () { - return "[" + this.NAME + " " + this.VERSION + "]"; -}; -MochiKit.Async.toString = function () { - return this.__repr__(); -}; - -/** @id MochiKit.Async.Deferred */ -MochiKit.Async.Deferred = function (/* optional */ canceller) { - this.chain = []; - this.id = this._nextId(); - this.fired = -1; - this.paused = 0; - this.results = [null, null]; - this.canceller = canceller; - this.silentlyCancelled = false; - this.chained = false; -}; - -MochiKit.Async.Deferred.prototype = { - /** @id MochiKit.Async.Deferred.prototype.repr */ - repr: function () { - var state; - if (this.fired == -1) { - state = 'unfired'; - } else if (this.fired === 0) { - state = 'success'; - } else { - state = 'error'; - } - return 'Deferred(' + this.id + ', ' + state + ')'; - }, - - toString: MochiKit.Base.forwardCall("repr"), - - _nextId: MochiKit.Base.counter(), - - /** @id MochiKit.Async.Deferred.prototype.cancel */ - cancel: function () { - var self = MochiKit.Async; - if (this.fired == -1) { - if (this.canceller) { - this.canceller(this); - } else { - this.silentlyCancelled = true; - } - if (this.fired == -1) { - this.errback(new self.CancelledError(this)); - } - } else if ((this.fired === 0) && (this.results[0] instanceof self.Deferred)) { - this.results[0].cancel(); - } - }, - - _resback: function (res) { - /*** - - The primitive that means either callback or errback - - ***/ - this.fired = ((res instanceof Error) ? 1 : 0); - this.results[this.fired] = res; - this._fire(); - }, - - _check: function () { - if (this.fired != -1) { - if (!this.silentlyCancelled) { - throw new MochiKit.Async.AlreadyCalledError(this); - } - this.silentlyCancelled = false; - return; - } - }, - - /** @id MochiKit.Async.Deferred.prototype.callback */ - callback: function (res) { - this._check(); - if (res instanceof MochiKit.Async.Deferred) { - throw new Error("Deferred instances can only be chained if they are the result of a callback"); - } - this._resback(res); - }, - - /** @id MochiKit.Async.Deferred.prototype.errback */ - errback: function (res) { - this._check(); - var self = MochiKit.Async; - if (res instanceof self.Deferred) { - throw new Error("Deferred instances can only be chained if they are the result of a callback"); - } - if (!(res instanceof Error)) { - res = new self.GenericError(res); - } - this._resback(res); - }, - - /** @id MochiKit.Async.Deferred.prototype.addBoth */ - addBoth: function (fn) { - if (arguments.length > 1) { - fn = MochiKit.Base.partial.apply(null, arguments); - } - return this.addCallbacks(fn, fn); - }, - - /** @id MochiKit.Async.Deferred.prototype.addCallback */ - addCallback: function (fn) { - if (arguments.length > 1) { - fn = MochiKit.Base.partial.apply(null, arguments); - } - return this.addCallbacks(fn, null); - }, - - /** @id MochiKit.Async.Deferred.prototype.addErrback */ - addErrback: function (fn) { - if (arguments.length > 1) { - fn = MochiKit.Base.partial.apply(null, arguments); - } - return this.addCallbacks(null, fn); - }, - - /** @id MochiKit.Async.Deferred.prototype.addCallbacks */ - addCallbacks: function (cb, eb) { - if (this.chained) { - throw new Error("Chained Deferreds can not be re-used"); - } - this.chain.push([cb, eb]); - if (this.fired >= 0) { - this._fire(); - } - return this; - }, - - _fire: function () { - /*** - - Used internally to exhaust the callback sequence when a result - is available. - - ***/ - var chain = this.chain; - var fired = this.fired; - var res = this.results[fired]; - var self = this; - var cb = null; - while (chain.length > 0 && this.paused === 0) { - // Array - var pair = chain.shift(); - var f = pair[fired]; - if (f === null) { - continue; - } - try { - res = f(res); - fired = ((res instanceof Error) ? 1 : 0); - if (res instanceof MochiKit.Async.Deferred) { - cb = function (res) { - self._resback(res); - self.paused--; - if ((self.paused === 0) && (self.fired >= 0)) { - self._fire(); - } - }; - this.paused++; - } - } catch (err) { - fired = 1; - if (!(err instanceof Error)) { - err = new MochiKit.Async.GenericError(err); - } - res = err; - } - } - this.fired = fired; - this.results[fired] = res; - if (cb && this.paused) { - // this is for "tail recursion" in case the dependent deferred - // is already fired - res.addBoth(cb); - res.chained = true; - } - } -}; - -MochiKit.Base.update(MochiKit.Async, { - /** @id MochiKit.Async.evalJSONRequest */ - evalJSONRequest: function (req) { - return MochiKit.Base.evalJSON(req.responseText); - }, - - /** @id MochiKit.Async.succeed */ - succeed: function (/* optional */result) { - var d = new MochiKit.Async.Deferred(); - d.callback.apply(d, arguments); - return d; - }, - - /** @id MochiKit.Async.fail */ - fail: function (/* optional */result) { - var d = new MochiKit.Async.Deferred(); - d.errback.apply(d, arguments); - return d; - }, - - /** @id MochiKit.Async.getXMLHttpRequest */ - getXMLHttpRequest: function () { - var self = arguments.callee; - if (!self.XMLHttpRequest) { - var tryThese = [ - function () { return new XMLHttpRequest(); }, - function () { return new ActiveXObject('Msxml2.XMLHTTP'); }, - function () { return new ActiveXObject('Microsoft.XMLHTTP'); }, - function () { return new ActiveXObject('Msxml2.XMLHTTP.4.0'); }, - function () { - throw new MochiKit.Async.BrowserComplianceError("Browser does not support XMLHttpRequest"); - } - ]; - for (var i = 0; i < tryThese.length; i++) { - var func = tryThese[i]; - try { - self.XMLHttpRequest = func; - return func(); - } catch (e) { - // pass - } - } - } - return self.XMLHttpRequest(); - }, - - _xhr_onreadystatechange: function (d) { - // MochiKit.Logging.logDebug('this.readyState', this.readyState); - var m = MochiKit.Base; - if (this.readyState == 4) { - // IE SUCKS - try { - this.onreadystatechange = null; - } catch (e) { - try { - this.onreadystatechange = m.noop; - } catch (e) { - } - } - var status = null; - try { - status = this.status; - if (!status && m.isNotEmpty(this.responseText)) { - // 0 or undefined seems to mean cached or local - status = 304; - } - } catch (e) { - // pass - // MochiKit.Logging.logDebug('error getting status?', repr(items(e))); - } - // 200 is OK, 201 is CREATED, 204 is NO CONTENT - // 304 is NOT MODIFIED, 1223 is apparently a bug in IE - if (status == 200 || status == 201 || status == 204 || - status == 304 || status == 1223) { - d.callback(this); - } else { - var err = new MochiKit.Async.XMLHttpRequestError(this, "Request failed"); - if (err.number) { - // XXX: This seems to happen on page change - d.errback(err); - } else { - // XXX: this seems to happen when the server is unreachable - d.errback(err); - } - } - } - }, - - _xhr_canceller: function (req) { - // IE SUCKS - try { - req.onreadystatechange = null; - } catch (e) { - try { - req.onreadystatechange = MochiKit.Base.noop; - } catch (e) { - } - } - req.abort(); - }, - - - /** @id MochiKit.Async.sendXMLHttpRequest */ - sendXMLHttpRequest: function (req, /* optional */ sendContent) { - if (typeof(sendContent) == "undefined" || sendContent === null) { - sendContent = ""; - } - - var m = MochiKit.Base; - var self = MochiKit.Async; - var d = new self.Deferred(m.partial(self._xhr_canceller, req)); - - try { - req.onreadystatechange = m.bind(self._xhr_onreadystatechange, - req, d); - req.send(sendContent); - } catch (e) { - try { - req.onreadystatechange = null; - } catch (ignore) { - // pass - } - d.errback(e); - } - - return d; - - }, - - /** @id MochiKit.Async.doXHR */ - doXHR: function (url, opts) { - /* - Work around a Firefox bug by dealing with XHR during - the next event loop iteration. Maybe it's this one: - https://bugzilla.mozilla.org/show_bug.cgi?id=249843 - */ - var self = MochiKit.Async; - return self.callLater(0, self._doXHR, url, opts); - }, - - _doXHR: function (url, opts) { - var m = MochiKit.Base; - opts = m.update({ - method: 'GET', - sendContent: '' - /* - queryString: undefined, - username: undefined, - password: undefined, - headers: undefined, - mimeType: undefined - */ - }, opts); - var self = MochiKit.Async; - var req = self.getXMLHttpRequest(); - if (opts.queryString) { - var qs = m.queryString(opts.queryString); - if (qs) { - url += "?" + qs; - } - } - // Safari will send undefined:undefined, so we have to check. - // We can't use apply, since the function is native. - if ('username' in opts) { - req.open(opts.method, url, true, opts.username, opts.password); - } else { - req.open(opts.method, url, true); - } - if (req.overrideMimeType && opts.mimeType) { - req.overrideMimeType(opts.mimeType); - } - req.setRequestHeader("X-Requested-With", "XMLHttpRequest"); - if (opts.headers) { - var headers = opts.headers; - if (!m.isArrayLike(headers)) { - headers = m.items(headers); - } - for (var i = 0; i < headers.length; i++) { - var header = headers[i]; - var name = header[0]; - var value = header[1]; - req.setRequestHeader(name, value); - } - } - return self.sendXMLHttpRequest(req, opts.sendContent); - }, - - _buildURL: function (url/*, ...*/) { - if (arguments.length > 1) { - var m = MochiKit.Base; - var qs = m.queryString.apply(null, m.extend(null, arguments, 1)); - if (qs) { - return url + "?" + qs; - } - } - return url; - }, - - /** @id MochiKit.Async.doSimpleXMLHttpRequest */ - doSimpleXMLHttpRequest: function (url/*, ...*/) { - var self = MochiKit.Async; - url = self._buildURL.apply(self, arguments); - return self.doXHR(url); - }, - - /** @id MochiKit.Async.loadJSONDoc */ - loadJSONDoc: function (url/*, ...*/) { - var self = MochiKit.Async; - url = self._buildURL.apply(self, arguments); - var d = self.doXHR(url, { - 'mimeType': 'text/plain', - 'headers': [['Accept', 'application/json']] - }); - d = d.addCallback(self.evalJSONRequest); - return d; - }, - - /** @id MochiKit.Async.wait */ - wait: function (seconds, /* optional */value) { - var d = new MochiKit.Async.Deferred(); - var m = MochiKit.Base; - if (typeof(value) != 'undefined') { - d.addCallback(function () { return value; }); - } - var timeout = setTimeout( - m.bind("callback", d), - Math.floor(seconds * 1000)); - d.canceller = function () { - try { - clearTimeout(timeout); - } catch (e) { - // pass - } - }; - return d; - }, - - /** @id MochiKit.Async.callLater */ - callLater: function (seconds, func) { - var m = MochiKit.Base; - var pfunc = m.partial.apply(m, m.extend(null, arguments, 1)); - return MochiKit.Async.wait(seconds).addCallback( - function (res) { return pfunc(); } - ); - } -}); - - -/** @id MochiKit.Async.DeferredLock */ -MochiKit.Async.DeferredLock = function () { - this.waiting = []; - this.locked = false; - this.id = this._nextId(); -}; - -MochiKit.Async.DeferredLock.prototype = { - __class__: MochiKit.Async.DeferredLock, - /** @id MochiKit.Async.DeferredLock.prototype.acquire */ - acquire: function () { - var d = new MochiKit.Async.Deferred(); - if (this.locked) { - this.waiting.push(d); - } else { - this.locked = true; - d.callback(this); - } - return d; - }, - /** @id MochiKit.Async.DeferredLock.prototype.release */ - release: function () { - if (!this.locked) { - throw TypeError("Tried to release an unlocked DeferredLock"); - } - this.locked = false; - if (this.waiting.length > 0) { - this.locked = true; - this.waiting.shift().callback(this); - } - }, - _nextId: MochiKit.Base.counter(), - repr: function () { - var state; - if (this.locked) { - state = 'locked, ' + this.waiting.length + ' waiting'; - } else { - state = 'unlocked'; - } - return 'DeferredLock(' + this.id + ', ' + state + ')'; - }, - toString: MochiKit.Base.forwardCall("repr") - -}; - -/** @id MochiKit.Async.DeferredList */ -MochiKit.Async.DeferredList = function (list, /* optional */fireOnOneCallback, fireOnOneErrback, consumeErrors, canceller) { - - // call parent constructor - MochiKit.Async.Deferred.apply(this, [canceller]); - - this.list = list; - var resultList = []; - this.resultList = resultList; - - this.finishedCount = 0; - this.fireOnOneCallback = fireOnOneCallback; - this.fireOnOneErrback = fireOnOneErrback; - this.consumeErrors = consumeErrors; - - var cb = MochiKit.Base.bind(this._cbDeferred, this); - for (var i = 0; i < list.length; i++) { - var d = list[i]; - resultList.push(undefined); - d.addCallback(cb, i, true); - d.addErrback(cb, i, false); - } - - if (list.length === 0 && !fireOnOneCallback) { - this.callback(this.resultList); - } - -}; - -MochiKit.Async.DeferredList.prototype = new MochiKit.Async.Deferred(); - -MochiKit.Async.DeferredList.prototype._cbDeferred = function (index, succeeded, result) { - this.resultList[index] = [succeeded, result]; - this.finishedCount += 1; - if (this.fired == -1) { - if (succeeded && this.fireOnOneCallback) { - this.callback([index, result]); - } else if (!succeeded && this.fireOnOneErrback) { - this.errback(result); - } else if (this.finishedCount == this.list.length) { - this.callback(this.resultList); - } - } - if (!succeeded && this.consumeErrors) { - result = null; - } - return result; -}; - -/** @id MochiKit.Async.gatherResults */ -MochiKit.Async.gatherResults = function (deferredList) { - var d = new MochiKit.Async.DeferredList(deferredList, false, true, false); - d.addCallback(function (results) { - var ret = []; - for (var i = 0; i < results.length; i++) { - ret.push(results[i][1]); - } - return ret; - }); - return d; -}; - -/** @id MochiKit.Async.maybeDeferred */ -MochiKit.Async.maybeDeferred = function (func) { - var self = MochiKit.Async; - var result; - try { - var r = func.apply(null, MochiKit.Base.extend([], arguments, 1)); - if (r instanceof self.Deferred) { - result = r; - } else if (r instanceof Error) { - result = self.fail(r); - } else { - result = self.succeed(r); - } - } catch (e) { - result = self.fail(e); - } - return result; -}; - - -MochiKit.Async.EXPORT = [ - "AlreadyCalledError", - "CancelledError", - "BrowserComplianceError", - "GenericError", - "XMLHttpRequestError", - "Deferred", - "succeed", - "fail", - "getXMLHttpRequest", - "doSimpleXMLHttpRequest", - "loadJSONDoc", - "wait", - "callLater", - "sendXMLHttpRequest", - "DeferredLock", - "DeferredList", - "gatherResults", - "maybeDeferred", - "doXHR" -]; - -MochiKit.Async.EXPORT_OK = [ - "evalJSONRequest" -]; - -MochiKit.Async.__new__ = function () { - var m = MochiKit.Base; - var ne = m.partial(m._newNamedError, this); - - ne("AlreadyCalledError", - /** @id MochiKit.Async.AlreadyCalledError */ - function (deferred) { - /*** - - Raised by the Deferred if callback or errback happens - after it was already fired. - - ***/ - this.deferred = deferred; - } - ); - - ne("CancelledError", - /** @id MochiKit.Async.CancelledError */ - function (deferred) { - /*** - - Raised by the Deferred cancellation mechanism. - - ***/ - this.deferred = deferred; - } - ); - - ne("BrowserComplianceError", - /** @id MochiKit.Async.BrowserComplianceError */ - function (msg) { - /*** - - Raised when the JavaScript runtime is not capable of performing - the given function. Technically, this should really never be - raised because a non-conforming JavaScript runtime probably - isn't going to support exceptions in the first place. - - ***/ - this.message = msg; - } - ); - - ne("GenericError", - /** @id MochiKit.Async.GenericError */ - function (msg) { - this.message = msg; - } - ); - - ne("XMLHttpRequestError", - /** @id MochiKit.Async.XMLHttpRequestError */ - function (req, msg) { - /*** - - Raised when an XMLHttpRequest does not complete for any reason. - - ***/ - this.req = req; - this.message = msg; - try { - // Strange but true that this can raise in some cases. - this.number = req.status; - } catch (e) { - // pass - } - } - ); - - - this.EXPORT_TAGS = { - ":common": this.EXPORT, - ":all": m.concat(this.EXPORT, this.EXPORT_OK) - }; - - m.nameFunctions(this); - -}; - -MochiKit.Async.__new__(); - -MochiKit.Base._exportSymbols(this, MochiKit.Async); diff --git a/javascript/libs/MochiKit/Base.js b/javascript/libs/MochiKit/Base.js deleted file mode 100644 index fe7b874..0000000 --- a/javascript/libs/MochiKit/Base.js +++ /dev/null @@ -1,1414 +0,0 @@ -/*** - -MochiKit.Base 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005 Bob Ippolito. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide("MochiKit.Base"); -} -if (typeof(MochiKit) == 'undefined') { - MochiKit = {}; -} -if (typeof(MochiKit.Base) == 'undefined') { - MochiKit.Base = {}; -} -if (typeof(MochiKit.__export__) == "undefined") { - MochiKit.__export__ = (MochiKit.__compat__ || - (typeof(JSAN) == 'undefined' && typeof(dojo) == 'undefined') - ); -} - -MochiKit.Base.VERSION = "1.4"; -MochiKit.Base.NAME = "MochiKit.Base"; -/** @id MochiKit.Base.update */ -MochiKit.Base.update = function (self, obj/*, ... */) { - if (self === null || self === undefined) { - self = {}; - } - for (var i = 1; i < arguments.length; i++) { - var o = arguments[i]; - if (typeof(o) != 'undefined' && o !== null) { - for (var k in o) { - self[k] = o[k]; - } - } - } - return self; -}; - -MochiKit.Base.update(MochiKit.Base, { - __repr__: function () { - return "[" + this.NAME + " " + this.VERSION + "]"; - }, - - toString: function () { - return this.__repr__(); - }, - - /** @id MochiKit.Base.camelize */ - camelize: function (selector) { - /* from dojo.style.toCamelCase */ - var arr = selector.split('-'); - var cc = arr[0]; - for (var i = 1; i < arr.length; i++) { - cc += arr[i].charAt(0).toUpperCase() + arr[i].substring(1); - } - return cc; - }, - - /** @id MochiKit.Base.counter */ - counter: function (n/* = 1 */) { - if (arguments.length === 0) { - n = 1; - } - return function () { - return n++; - }; - }, - - /** @id MochiKit.Base.clone */ - clone: function (obj) { - var me = arguments.callee; - if (arguments.length == 1) { - me.prototype = obj; - return new me(); - } - }, - - _flattenArray: function (res, lst) { - for (var i = 0; i < lst.length; i++) { - var o = lst[i]; - if (o instanceof Array) { - arguments.callee(res, o); - } else { - res.push(o); - } - } - return res; - }, - - /** @id MochiKit.Base.flattenArray */ - flattenArray: function (lst) { - return MochiKit.Base._flattenArray([], lst); - }, - - /** @id MochiKit.Base.flattenArguments */ - flattenArguments: function (lst/* ...*/) { - var res = []; - var m = MochiKit.Base; - var args = m.extend(null, arguments); - while (args.length) { - var o = args.shift(); - if (o && typeof(o) == "object" && typeof(o.length) == "number") { - for (var i = o.length - 1; i >= 0; i--) { - args.unshift(o[i]); - } - } else { - res.push(o); - } - } - return res; - }, - - /** @id MochiKit.Base.extend */ - extend: function (self, obj, /* optional */skip) { - // Extend an array with an array-like object starting - // from the skip index - if (!skip) { - skip = 0; - } - if (obj) { - // allow iterable fall-through, but skip the full isArrayLike - // check for speed, this is called often. - var l = obj.length; - if (typeof(l) != 'number' /* !isArrayLike(obj) */) { - if (typeof(MochiKit.Iter) != "undefined") { - obj = MochiKit.Iter.list(obj); - l = obj.length; - } else { - throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); - } - } - if (!self) { - self = []; - } - for (var i = skip; i < l; i++) { - self.push(obj[i]); - } - } - // This mutates, but it's convenient to return because - // it's often used like a constructor when turning some - // ghetto array-like to a real array - return self; - }, - - - /** @id MochiKit.Base.updatetree */ - updatetree: function (self, obj/*, ...*/) { - if (self === null || self === undefined) { - self = {}; - } - for (var i = 1; i < arguments.length; i++) { - var o = arguments[i]; - if (typeof(o) != 'undefined' && o !== null) { - for (var k in o) { - var v = o[k]; - if (typeof(self[k]) == 'object' && typeof(v) == 'object') { - arguments.callee(self[k], v); - } else { - self[k] = v; - } - } - } - } - return self; - }, - - /** @id MochiKit.Base.setdefault */ - setdefault: function (self, obj/*, ...*/) { - if (self === null || self === undefined) { - self = {}; - } - for (var i = 1; i < arguments.length; i++) { - var o = arguments[i]; - for (var k in o) { - if (!(k in self)) { - self[k] = o[k]; - } - } - } - return self; - }, - - /** @id MochiKit.Base.keys */ - keys: function (obj) { - var rval = []; - for (var prop in obj) { - rval.push(prop); - } - return rval; - }, - - /** @id MochiKit.Base.values */ - values: function (obj) { - var rval = []; - for (var prop in obj) { - rval.push(obj[prop]); - } - return rval; - }, - - /** @id MochiKit.Base.items */ - items: function (obj) { - var rval = []; - var e; - for (var prop in obj) { - var v; - try { - v = obj[prop]; - } catch (e) { - continue; - } - rval.push([prop, v]); - } - return rval; - }, - - - _newNamedError: function (module, name, func) { - func.prototype = new MochiKit.Base.NamedError(module.NAME + "." + name); - module[name] = func; - }, - - - /** @id MochiKit.Base.operator */ - operator: { - // unary logic operators - /** @id MochiKit.Base.truth */ - truth: function (a) { return !!a; }, - /** @id MochiKit.Base.lognot */ - lognot: function (a) { return !a; }, - /** @id MochiKit.Base.identity */ - identity: function (a) { return a; }, - - // bitwise unary operators - /** @id MochiKit.Base.not */ - not: function (a) { return ~a; }, - /** @id MochiKit.Base.neg */ - neg: function (a) { return -a; }, - - // binary operators - /** @id MochiKit.Base.add */ - add: function (a, b) { return a + b; }, - /** @id MochiKit.Base.sub */ - sub: function (a, b) { return a - b; }, - /** @id MochiKit.Base.div */ - div: function (a, b) { return a / b; }, - /** @id MochiKit.Base.mod */ - mod: function (a, b) { return a % b; }, - /** @id MochiKit.Base.mul */ - mul: function (a, b) { return a * b; }, - - // bitwise binary operators - /** @id MochiKit.Base.and */ - and: function (a, b) { return a & b; }, - /** @id MochiKit.Base.or */ - or: function (a, b) { return a | b; }, - /** @id MochiKit.Base.xor */ - xor: function (a, b) { return a ^ b; }, - /** @id MochiKit.Base.lshift */ - lshift: function (a, b) { return a << b; }, - /** @id MochiKit.Base.rshift */ - rshift: function (a, b) { return a >> b; }, - /** @id MochiKit.Base.zrshift */ - zrshift: function (a, b) { return a >>> b; }, - - // near-worthless built-in comparators - /** @id MochiKit.Base.eq */ - eq: function (a, b) { return a == b; }, - /** @id MochiKit.Base.ne */ - ne: function (a, b) { return a != b; }, - /** @id MochiKit.Base.gt */ - gt: function (a, b) { return a > b; }, - /** @id MochiKit.Base.ge */ - ge: function (a, b) { return a >= b; }, - /** @id MochiKit.Base.lt */ - lt: function (a, b) { return a < b; }, - /** @id MochiKit.Base.le */ - le: function (a, b) { return a <= b; }, - - // strict built-in comparators - seq: function (a, b) { return a === b; }, - sne: function (a, b) { return a !== b; }, - - // compare comparators - /** @id MochiKit.Base.ceq */ - ceq: function (a, b) { return MochiKit.Base.compare(a, b) === 0; }, - /** @id MochiKit.Base.cne */ - cne: function (a, b) { return MochiKit.Base.compare(a, b) !== 0; }, - /** @id MochiKit.Base.cgt */ - cgt: function (a, b) { return MochiKit.Base.compare(a, b) == 1; }, - /** @id MochiKit.Base.cge */ - cge: function (a, b) { return MochiKit.Base.compare(a, b) != -1; }, - /** @id MochiKit.Base.clt */ - clt: function (a, b) { return MochiKit.Base.compare(a, b) == -1; }, - /** @id MochiKit.Base.cle */ - cle: function (a, b) { return MochiKit.Base.compare(a, b) != 1; }, - - // binary logical operators - /** @id MochiKit.Base.logand */ - logand: function (a, b) { return a && b; }, - /** @id MochiKit.Base.logor */ - logor: function (a, b) { return a || b; }, - /** @id MochiKit.Base.contains */ - contains: function (a, b) { return b in a; } - }, - - /** @id MochiKit.Base.forwardCall */ - forwardCall: function (func) { - return function () { - return this[func].apply(this, arguments); - }; - }, - - /** @id MochiKit.Base.itemgetter */ - itemgetter: function (func) { - return function (arg) { - return arg[func]; - }; - }, - - /** @id MochiKit.Base.typeMatcher */ - typeMatcher: function (/* typ */) { - var types = {}; - for (var i = 0; i < arguments.length; i++) { - var typ = arguments[i]; - types[typ] = typ; - } - return function () { - for (var i = 0; i < arguments.length; i++) { - if (!(typeof(arguments[i]) in types)) { - return false; - } - } - return true; - }; - }, - - /** @id MochiKit.Base.isNull */ - isNull: function (/* ... */) { - for (var i = 0; i < arguments.length; i++) { - if (arguments[i] !== null) { - return false; - } - } - return true; - }, - - /** @id MochiKit.Base.isUndefinedOrNull */ - isUndefinedOrNull: function (/* ... */) { - for (var i = 0; i < arguments.length; i++) { - var o = arguments[i]; - if (!(typeof(o) == 'undefined' || o === null)) { - return false; - } - } - return true; - }, - - /** @id MochiKit.Base.isEmpty */ - isEmpty: function (obj) { - return !MochiKit.Base.isNotEmpty.apply(this, arguments); - }, - - /** @id MochiKit.Base.isNotEmpty */ - isNotEmpty: function (obj) { - for (var i = 0; i < arguments.length; i++) { - var o = arguments[i]; - if (!(o && o.length)) { - return false; - } - } - return true; - }, - - /** @id MochiKit.Base.isArrayLike */ - isArrayLike: function () { - for (var i = 0; i < arguments.length; i++) { - var o = arguments[i]; - var typ = typeof(o); - if ( - (typ != 'object' && !(typ == 'function' && typeof(o.item) == 'function')) || - o === null || - typeof(o.length) != 'number' || - o.nodeType === 3 || - o.nodeType === 4 - ) { - return false; - } - } - return true; - }, - - /** @id MochiKit.Base.isDateLike */ - isDateLike: function () { - for (var i = 0; i < arguments.length; i++) { - var o = arguments[i]; - if (typeof(o) != "object" || o === null - || typeof(o.getTime) != 'function') { - return false; - } - } - return true; - }, - - - /** @id MochiKit.Base.xmap */ - xmap: function (fn/*, obj... */) { - if (fn === null) { - return MochiKit.Base.extend(null, arguments, 1); - } - var rval = []; - for (var i = 1; i < arguments.length; i++) { - rval.push(fn(arguments[i])); - } - return rval; - }, - - /** @id MochiKit.Base.map */ - map: function (fn, lst/*, lst... */) { - var m = MochiKit.Base; - var itr = MochiKit.Iter; - var isArrayLike = m.isArrayLike; - if (arguments.length <= 2) { - // allow an iterable to be passed - if (!isArrayLike(lst)) { - if (itr) { - // fast path for map(null, iterable) - lst = itr.list(lst); - if (fn === null) { - return lst; - } - } else { - throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); - } - } - // fast path for map(null, lst) - if (fn === null) { - return m.extend(null, lst); - } - // disabled fast path for map(fn, lst) - /* - if (false && typeof(Array.prototype.map) == 'function') { - // Mozilla fast-path - return Array.prototype.map.call(lst, fn); - } - */ - var rval = []; - for (var i = 0; i < lst.length; i++) { - rval.push(fn(lst[i])); - } - return rval; - } else { - // default for map(null, ...) is zip(...) - if (fn === null) { - fn = Array; - } - var length = null; - for (i = 1; i < arguments.length; i++) { - // allow iterables to be passed - if (!isArrayLike(arguments[i])) { - if (itr) { - return itr.list(itr.imap.apply(null, arguments)); - } else { - throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); - } - } - // find the minimum length - var l = arguments[i].length; - if (length === null || length > l) { - length = l; - } - } - rval = []; - for (i = 0; i < length; i++) { - var args = []; - for (var j = 1; j < arguments.length; j++) { - args.push(arguments[j][i]); - } - rval.push(fn.apply(this, args)); - } - return rval; - } - }, - - /** @id MochiKit.Base.xfilter */ - xfilter: function (fn/*, obj... */) { - var rval = []; - if (fn === null) { - fn = MochiKit.Base.operator.truth; - } - for (var i = 1; i < arguments.length; i++) { - var o = arguments[i]; - if (fn(o)) { - rval.push(o); - } - } - return rval; - }, - - /** @id MochiKit.Base.filter */ - filter: function (fn, lst, self) { - var rval = []; - // allow an iterable to be passed - var m = MochiKit.Base; - if (!m.isArrayLike(lst)) { - if (MochiKit.Iter) { - lst = MochiKit.Iter.list(lst); - } else { - throw new TypeError("Argument not an array-like and MochiKit.Iter not present"); - } - } - if (fn === null) { - fn = m.operator.truth; - } - if (typeof(Array.prototype.filter) == 'function') { - // Mozilla fast-path - return Array.prototype.filter.call(lst, fn, self); - } else if (typeof(self) == 'undefined' || self === null) { - for (var i = 0; i < lst.length; i++) { - var o = lst[i]; - if (fn(o)) { - rval.push(o); - } - } - } else { - for (i = 0; i < lst.length; i++) { - o = lst[i]; - if (fn.call(self, o)) { - rval.push(o); - } - } - } - return rval; - }, - - - _wrapDumbFunction: function (func) { - return function () { - // fast path! - switch (arguments.length) { - case 0: return func(); - case 1: return func(arguments[0]); - case 2: return func(arguments[0], arguments[1]); - case 3: return func(arguments[0], arguments[1], arguments[2]); - } - var args = []; - for (var i = 0; i < arguments.length; i++) { - args.push("arguments[" + i + "]"); - } - return eval("(func(" + args.join(",") + "))"); - }; - }, - - /** @id MochiKit.Base.methodcaller */ - methodcaller: function (func/*, args... */) { - var args = MochiKit.Base.extend(null, arguments, 1); - if (typeof(func) == "function") { - return function (obj) { - return func.apply(obj, args); - }; - } else { - return function (obj) { - return obj[func].apply(obj, args); - }; - } - }, - - /** @id MochiKit.Base.method */ - method: function (self, func) { - var m = MochiKit.Base; - return m.bind.apply(this, m.extend([func, self], arguments, 2)); - }, - - /** @id MochiKit.Base.compose */ - compose: function (f1, f2/*, f3, ... fN */) { - var fnlist = []; - var m = MochiKit.Base; - if (arguments.length === 0) { - throw new TypeError("compose() requires at least one argument"); - } - for (var i = 0; i < arguments.length; i++) { - var fn = arguments[i]; - if (typeof(fn) != "function") { - throw new TypeError(m.repr(fn) + " is not a function"); - } - fnlist.push(fn); - } - return function () { - var args = arguments; - for (var i = fnlist.length - 1; i >= 0; i--) { - args = [fnlist[i].apply(this, args)]; - } - return args[0]; - }; - }, - - /** @id MochiKit.Base.bind */ - bind: function (func, self/* args... */) { - if (typeof(func) == "string") { - func = self[func]; - } - var im_func = func.im_func; - var im_preargs = func.im_preargs; - var im_self = func.im_self; - var m = MochiKit.Base; - if (typeof(func) == "function" && typeof(func.apply) == "undefined") { - // this is for cases where JavaScript sucks ass and gives you a - // really dumb built-in function like alert() that doesn't have - // an apply - func = m._wrapDumbFunction(func); - } - if (typeof(im_func) != 'function') { - im_func = func; - } - if (typeof(self) != 'undefined') { - im_self = self; - } - if (typeof(im_preargs) == 'undefined') { - im_preargs = []; - } else { - im_preargs = im_preargs.slice(); - } - m.extend(im_preargs, arguments, 2); - var newfunc = function () { - var args = arguments; - var me = arguments.callee; - if (me.im_preargs.length > 0) { - args = m.concat(me.im_preargs, args); - } - var self = me.im_self; - if (!self) { - self = this; - } - return me.im_func.apply(self, args); - }; - newfunc.im_self = im_self; - newfunc.im_func = im_func; - newfunc.im_preargs = im_preargs; - return newfunc; - }, - - /** @id MochiKit.Base.bindMethods */ - bindMethods: function (self) { - var bind = MochiKit.Base.bind; - for (var k in self) { - var func = self[k]; - if (typeof(func) == 'function') { - self[k] = bind(func, self); - } - } - }, - - /** @id MochiKit.Base.registerComparator */ - registerComparator: function (name, check, comparator, /* optional */ override) { - MochiKit.Base.comparatorRegistry.register(name, check, comparator, override); - }, - - _primitives: {'boolean': true, 'string': true, 'number': true}, - - /** @id MochiKit.Base.compare */ - compare: function (a, b) { - if (a == b) { - return 0; - } - var aIsNull = (typeof(a) == 'undefined' || a === null); - var bIsNull = (typeof(b) == 'undefined' || b === null); - if (aIsNull && bIsNull) { - return 0; - } else if (aIsNull) { - return -1; - } else if (bIsNull) { - return 1; - } - var m = MochiKit.Base; - // bool, number, string have meaningful comparisons - var prim = m._primitives; - if (!(typeof(a) in prim && typeof(b) in prim)) { - try { - return m.comparatorRegistry.match(a, b); - } catch (e) { - if (e != m.NotFound) { - throw e; - } - } - } - if (a < b) { - return -1; - } else if (a > b) { - return 1; - } - // These types can't be compared - var repr = m.repr; - throw new TypeError(repr(a) + " and " + repr(b) + " can not be compared"); - }, - - /** @id MochiKit.Base.compareDateLike */ - compareDateLike: function (a, b) { - return MochiKit.Base.compare(a.getTime(), b.getTime()); - }, - - /** @id MochiKit.Base.compareArrayLike */ - compareArrayLike: function (a, b) { - var compare = MochiKit.Base.compare; - var count = a.length; - var rval = 0; - if (count > b.length) { - rval = 1; - count = b.length; - } else if (count < b.length) { - rval = -1; - } - for (var i = 0; i < count; i++) { - var cmp = compare(a[i], b[i]); - if (cmp) { - return cmp; - } - } - return rval; - }, - - /** @id MochiKit.Base.registerRepr */ - registerRepr: function (name, check, wrap, /* optional */override) { - MochiKit.Base.reprRegistry.register(name, check, wrap, override); - }, - - /** @id MochiKit.Base.repr */ - repr: function (o) { - if (typeof(o) == "undefined") { - return "undefined"; - } else if (o === null) { - return "null"; - } - try { - if (typeof(o.__repr__) == 'function') { - return o.__repr__(); - } else if (typeof(o.repr) == 'function' && o.repr != arguments.callee) { - return o.repr(); - } - return MochiKit.Base.reprRegistry.match(o); - } catch (e) { - if (typeof(o.NAME) == 'string' && ( - o.toString == Function.prototype.toString || - o.toString == Object.prototype.toString - )) { - return o.NAME; - } - } - try { - var ostring = (o + ""); - } catch (e) { - return "[" + typeof(o) + "]"; - } - if (typeof(o) == "function") { - ostring = ostring.replace(/^\s+/, "").replace(/\s+/g, " "); - var idx = ostring.indexOf("{"); - if (idx != -1) { - ostring = ostring.substr(0, idx) + "{...}"; - } - } - return ostring; - }, - - /** @id MochiKit.Base.reprArrayLike */ - reprArrayLike: function (o) { - var m = MochiKit.Base; - return "[" + m.map(m.repr, o).join(", ") + "]"; - }, - - /** @id MochiKit.Base.reprString */ - reprString: function (o) { - return ('"' + o.replace(/(["\\])/g, '\\$1') + '"' - ).replace(/[\f]/g, "\\f" - ).replace(/[\b]/g, "\\b" - ).replace(/[\n]/g, "\\n" - ).replace(/[\t]/g, "\\t" - ).replace(/[\r]/g, "\\r"); - }, - - /** @id MochiKit.Base.reprNumber */ - reprNumber: function (o) { - return o + ""; - }, - - /** @id MochiKit.Base.registerJSON */ - registerJSON: function (name, check, wrap, /* optional */override) { - MochiKit.Base.jsonRegistry.register(name, check, wrap, override); - }, - - - /** @id MochiKit.Base.evalJSON */ - evalJSON: function () { - return eval("(" + MochiKit.Base._filterJSON(arguments[0]) + ")"); - }, - - _filterJSON: function (s) { - var m = s.match(/^\s*\/\*(.*)\*\/\s*$/); - if (m) { - return m[1]; - } - return s; - }, - - /** @id MochiKit.Base.serializeJSON */ - serializeJSON: function (o) { - var objtype = typeof(o); - if (objtype == "number" || objtype == "boolean") { - return o + ""; - } else if (o === null) { - return "null"; - } - var m = MochiKit.Base; - var reprString = m.reprString; - if (objtype == "string") { - return reprString(o); - } - // recurse - var me = arguments.callee; - // short-circuit for objects that support "json" serialization - // if they return "self" then just pass-through... - var newObj; - if (typeof(o.__json__) == "function") { - newObj = o.__json__(); - if (o !== newObj) { - return me(newObj); - } - } - if (typeof(o.json) == "function") { - newObj = o.json(); - if (o !== newObj) { - return me(newObj); - } - } - // array - if (objtype != "function" && typeof(o.length) == "number") { - var res = []; - for (var i = 0; i < o.length; i++) { - var val = me(o[i]); - if (typeof(val) != "string") { - val = "undefined"; - } - res.push(val); - } - return "[" + res.join(", ") + "]"; - } - // look in the registry - try { - newObj = m.jsonRegistry.match(o); - if (o !== newObj) { - return me(newObj); - } - } catch (e) { - if (e != m.NotFound) { - // something really bad happened - throw e; - } - } - // undefined is outside of the spec - if (objtype == "undefined") { - throw new TypeError("undefined can not be serialized as JSON"); - } - // it's a function with no adapter, bad - if (objtype == "function") { - return null; - } - // generic object code path - res = []; - for (var k in o) { - var useKey; - if (typeof(k) == "number") { - useKey = '"' + k + '"'; - } else if (typeof(k) == "string") { - useKey = reprString(k); - } else { - // skip non-string or number keys - continue; - } - val = me(o[k]); - if (typeof(val) != "string") { - // skip non-serializable values - continue; - } - res.push(useKey + ":" + val); - } - return "{" + res.join(", ") + "}"; - }, - - - /** @id MochiKit.Base.objEqual */ - objEqual: function (a, b) { - return (MochiKit.Base.compare(a, b) === 0); - }, - - /** @id MochiKit.Base.arrayEqual */ - arrayEqual: function (self, arr) { - if (self.length != arr.length) { - return false; - } - return (MochiKit.Base.compare(self, arr) === 0); - }, - - /** @id MochiKit.Base.concat */ - concat: function (/* lst... */) { - var rval = []; - var extend = MochiKit.Base.extend; - for (var i = 0; i < arguments.length; i++) { - extend(rval, arguments[i]); - } - return rval; - }, - - /** @id MochiKit.Base.keyComparator */ - keyComparator: function (key/* ... */) { - // fast-path for single key comparisons - var m = MochiKit.Base; - var compare = m.compare; - if (arguments.length == 1) { - return function (a, b) { - return compare(a[key], b[key]); - }; - } - var compareKeys = m.extend(null, arguments); - return function (a, b) { - var rval = 0; - // keep comparing until something is inequal or we run out of - // keys to compare - for (var i = 0; (rval === 0) && (i < compareKeys.length); i++) { - var key = compareKeys[i]; - rval = compare(a[key], b[key]); - } - return rval; - }; - }, - - /** @id MochiKit.Base.reverseKeyComparator */ - reverseKeyComparator: function (key) { - var comparator = MochiKit.Base.keyComparator.apply(this, arguments); - return function (a, b) { - return comparator(b, a); - }; - }, - - /** @id MochiKit.Base.partial */ - partial: function (func) { - var m = MochiKit.Base; - return m.bind.apply(this, m.extend([func, undefined], arguments, 1)); - }, - - /** @id MochiKit.Base.listMinMax */ - listMinMax: function (which, lst) { - if (lst.length === 0) { - return null; - } - var cur = lst[0]; - var compare = MochiKit.Base.compare; - for (var i = 1; i < lst.length; i++) { - var o = lst[i]; - if (compare(o, cur) == which) { - cur = o; - } - } - return cur; - }, - - /** @id MochiKit.Base.objMax */ - objMax: function (/* obj... */) { - return MochiKit.Base.listMinMax(1, arguments); - }, - - /** @id MochiKit.Base.objMin */ - objMin: function (/* obj... */) { - return MochiKit.Base.listMinMax(-1, arguments); - }, - - /** @id MochiKit.Base.findIdentical */ - findIdentical: function (lst, value, start/* = 0 */, /* optional */end) { - if (typeof(end) == "undefined" || end === null) { - end = lst.length; - } - if (typeof(start) == "undefined" || start === null) { - start = 0; - } - for (var i = start; i < end; i++) { - if (lst[i] === value) { - return i; - } - } - return -1; - }, - - /** @id MochiKit.Base.mean */ - mean: function(/* lst... */) { - /* http://www.nist.gov/dads/HTML/mean.html */ - var sum = 0; - - var m = MochiKit.Base; - var args = m.extend(null, arguments); - var count = args.length; - - while (args.length) { - var o = args.shift(); - if (o && typeof(o) == "object" && typeof(o.length) == "number") { - count += o.length - 1; - for (var i = o.length - 1; i >= 0; i--) { - sum += o[i]; - } - } else { - sum += o; - } - } - - if (count <= 0) { - throw new TypeError('mean() requires at least one argument'); - } - - return sum/count; - }, - - /** @id MochiKit.Base.median */ - median: function(/* lst... */) { - /* http://www.nist.gov/dads/HTML/median.html */ - var data = MochiKit.Base.flattenArguments(arguments); - if (data.length === 0) { - throw new TypeError('median() requires at least one argument'); - } - data.sort(compare); - if (data.length % 2 == 0) { - var upper = data.length / 2; - return (data[upper] + data[upper - 1]) / 2; - } else { - return data[(data.length - 1) / 2]; - } - }, - - /** @id MochiKit.Base.findValue */ - findValue: function (lst, value, start/* = 0 */, /* optional */end) { - if (typeof(end) == "undefined" || end === null) { - end = lst.length; - } - if (typeof(start) == "undefined" || start === null) { - start = 0; - } - var cmp = MochiKit.Base.compare; - for (var i = start; i < end; i++) { - if (cmp(lst[i], value) === 0) { - return i; - } - } - return -1; - }, - - /** @id MochiKit.Base.nodeWalk */ - nodeWalk: function (node, visitor) { - var nodes = [node]; - var extend = MochiKit.Base.extend; - while (nodes.length) { - var res = visitor(nodes.shift()); - if (res) { - extend(nodes, res); - } - } - }, - - - /** @id MochiKit.Base.nameFunctions */ - nameFunctions: function (namespace) { - var base = namespace.NAME; - if (typeof(base) == 'undefined') { - base = ''; - } else { - base = base + '.'; - } - for (var name in namespace) { - var o = namespace[name]; - if (typeof(o) == 'function' && typeof(o.NAME) == 'undefined') { - try { - o.NAME = base + name; - } catch (e) { - // pass - } - } - } - }, - - - /** @id MochiKit.Base.queryString */ - queryString: function (names, values) { - // check to see if names is a string or a DOM element, and if - // MochiKit.DOM is available. If so, drop it like it's a form - // Ugliest conditional in MochiKit? Probably! - if (typeof(MochiKit.DOM) != "undefined" && arguments.length == 1 - && (typeof(names) == "string" || ( - typeof(names.nodeType) != "undefined" && names.nodeType > 0 - )) - ) { - var kv = MochiKit.DOM.formContents(names); - names = kv[0]; - values = kv[1]; - } else if (arguments.length == 1) { - // Allow the return value of formContents to be passed directly - if (typeof(names.length) == "number" && names.length == 2) { - return arguments.callee(names[0], names[1]); - } - var o = names; - names = []; - values = []; - for (var k in o) { - var v = o[k]; - if (typeof(v) == "function") { - continue; - } else if (MochiKit.Base.isArrayLike(v)){ - for (var i = 0; i < v.length; i++) { - names.push(k); - values.push(v[i]); - } - } else { - names.push(k); - values.push(v); - } - } - } - var rval = []; - var len = Math.min(names.length, values.length); - var urlEncode = MochiKit.Base.urlEncode; - for (var i = 0; i < len; i++) { - v = values[i]; - if (typeof(v) != 'undefined' && v !== null) { - rval.push(urlEncode(names[i]) + "=" + urlEncode(v)); - } - } - return rval.join("&"); - }, - - - /** @id MochiKit.Base.parseQueryString */ - parseQueryString: function (encodedString, useArrays) { - // strip a leading '?' from the encoded string - var qstr = (encodedString.charAt(0) == "?") - ? encodedString.substring(1) - : encodedString; - var pairs = qstr.replace(/\+/g, "%20").split(/(\&\;|\&\#38\;|\&|\&)/); - var o = {}; - var decode; - if (typeof(decodeURIComponent) != "undefined") { - decode = decodeURIComponent; - } else { - decode = unescape; - } - if (useArrays) { - for (var i = 0; i < pairs.length; i++) { - var pair = pairs[i].split("="); - var name = decode(pair.shift()); - if (!name) { - continue; - } - var arr = o[name]; - if (!(arr instanceof Array)) { - arr = []; - o[name] = arr; - } - arr.push(decode(pair.join("="))); - } - } else { - for (i = 0; i < pairs.length; i++) { - pair = pairs[i].split("="); - var name = pair.shift(); - if (!name) { - continue; - } - o[decode(name)] = decode(pair.join("=")); - } - } - return o; - } -}); - -/** @id MochiKit.Base.AdapterRegistry */ -MochiKit.Base.AdapterRegistry = function () { - this.pairs = []; -}; - -MochiKit.Base.AdapterRegistry.prototype = { - /** @id MochiKit.Base.AdapterRegistry.prototype.register */ - register: function (name, check, wrap, /* optional */ override) { - if (override) { - this.pairs.unshift([name, check, wrap]); - } else { - this.pairs.push([name, check, wrap]); - } - }, - - /** @id MochiKit.Base.AdapterRegistry.prototype.match */ - match: function (/* ... */) { - for (var i = 0; i < this.pairs.length; i++) { - var pair = this.pairs[i]; - if (pair[1].apply(this, arguments)) { - return pair[2].apply(this, arguments); - } - } - throw MochiKit.Base.NotFound; - }, - - /** @id MochiKit.Base.AdapterRegistry.prototype.unregister */ - unregister: function (name) { - for (var i = 0; i < this.pairs.length; i++) { - var pair = this.pairs[i]; - if (pair[0] == name) { - this.pairs.splice(i, 1); - return true; - } - } - return false; - } -}; - - -MochiKit.Base.EXPORT = [ - "flattenArray", - "noop", - "camelize", - "counter", - "clone", - "extend", - "update", - "updatetree", - "setdefault", - "keys", - "values", - "items", - "NamedError", - "operator", - "forwardCall", - "itemgetter", - "typeMatcher", - "isCallable", - "isUndefined", - "isUndefinedOrNull", - "isNull", - "isEmpty", - "isNotEmpty", - "isArrayLike", - "isDateLike", - "xmap", - "map", - "xfilter", - "filter", - "methodcaller", - "compose", - "bind", - "bindMethods", - "NotFound", - "AdapterRegistry", - "registerComparator", - "compare", - "registerRepr", - "repr", - "objEqual", - "arrayEqual", - "concat", - "keyComparator", - "reverseKeyComparator", - "partial", - "merge", - "listMinMax", - "listMax", - "listMin", - "objMax", - "objMin", - "nodeWalk", - "zip", - "urlEncode", - "queryString", - "serializeJSON", - "registerJSON", - "evalJSON", - "parseQueryString", - "findValue", - "findIdentical", - "flattenArguments", - "method", - "average", - "mean", - "median" -]; - -MochiKit.Base.EXPORT_OK = [ - "nameFunctions", - "comparatorRegistry", - "reprRegistry", - "jsonRegistry", - "compareDateLike", - "compareArrayLike", - "reprArrayLike", - "reprString", - "reprNumber" -]; - -MochiKit.Base._exportSymbols = function (globals, module) { - if (!MochiKit.__export__) { - return; - } - var all = module.EXPORT_TAGS[":all"]; - for (var i = 0; i < all.length; i++) { - globals[all[i]] = module[all[i]]; - } -}; - -MochiKit.Base.__new__ = function () { - // A singleton raised when no suitable adapter is found - var m = this; - - // convenience - /** @id MochiKit.Base.noop */ - m.noop = m.operator.identity; - - // Backwards compat - m.forward = m.forwardCall; - m.find = m.findValue; - - if (typeof(encodeURIComponent) != "undefined") { - /** @id MochiKit.Base.urlEncode */ - m.urlEncode = function (unencoded) { - return encodeURIComponent(unencoded).replace(/\'/g, '%27'); - }; - } else { - m.urlEncode = function (unencoded) { - return escape(unencoded - ).replace(/\+/g, '%2B' - ).replace(/\"/g,'%22' - ).rval.replace(/\'/g, '%27'); - }; - } - - /** @id MochiKit.Base.NamedError */ - m.NamedError = function (name) { - this.message = name; - this.name = name; - }; - m.NamedError.prototype = new Error(); - m.update(m.NamedError.prototype, { - repr: function () { - if (this.message && this.message != this.name) { - return this.name + "(" + m.repr(this.message) + ")"; - } else { - return this.name + "()"; - } - }, - toString: m.forwardCall("repr") - }); - - /** @id MochiKit.Base.NotFound */ - m.NotFound = new m.NamedError("MochiKit.Base.NotFound"); - - - /** @id MochiKit.Base.listMax */ - m.listMax = m.partial(m.listMinMax, 1); - /** @id MochiKit.Base.listMin */ - m.listMin = m.partial(m.listMinMax, -1); - - /** @id MochiKit.Base.isCallable */ - m.isCallable = m.typeMatcher('function'); - /** @id MochiKit.Base.isUndefined */ - m.isUndefined = m.typeMatcher('undefined'); - - /** @id MochiKit.Base.merge */ - m.merge = m.partial(m.update, null); - /** @id MochiKit.Base.zip */ - m.zip = m.partial(m.map, null); - - /** @id MochiKit.Base.average */ - m.average = m.mean; - - /** @id MochiKit.Base.comparatorRegistry */ - m.comparatorRegistry = new m.AdapterRegistry(); - m.registerComparator("dateLike", m.isDateLike, m.compareDateLike); - m.registerComparator("arrayLike", m.isArrayLike, m.compareArrayLike); - - /** @id MochiKit.Base.reprRegistry */ - m.reprRegistry = new m.AdapterRegistry(); - m.registerRepr("arrayLike", m.isArrayLike, m.reprArrayLike); - m.registerRepr("string", m.typeMatcher("string"), m.reprString); - m.registerRepr("numbers", m.typeMatcher("number", "boolean"), m.reprNumber); - - /** @id MochiKit.Base.jsonRegistry */ - m.jsonRegistry = new m.AdapterRegistry(); - - var all = m.concat(m.EXPORT, m.EXPORT_OK); - m.EXPORT_TAGS = { - ":common": m.concat(m.EXPORT_OK), - ":all": all - }; - - m.nameFunctions(this); - -}; - -MochiKit.Base.__new__(); - -// -// XXX: Internet Explorer blows -// -if (MochiKit.__export__) { - compare = MochiKit.Base.compare; - compose = MochiKit.Base.compose; - serializeJSON = MochiKit.Base.serializeJSON; - mean = MochiKit.Base.mean; - median = MochiKit.Base.median; -} - -MochiKit.Base._exportSymbols(this, MochiKit.Base); diff --git a/javascript/libs/MochiKit/Color.js b/javascript/libs/MochiKit/Color.js deleted file mode 100644 index 708f490..0000000 --- a/javascript/libs/MochiKit/Color.js +++ /dev/null @@ -1,902 +0,0 @@ -/*** - -MochiKit.Color 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005 Bob Ippolito and others. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.Color'); - dojo.require('MochiKit.Base'); - dojo.require('MochiKit.DOM'); - dojo.require('MochiKit.Style'); -} - -if (typeof(JSAN) != 'undefined') { - JSAN.use("MochiKit.Base", []); - JSAN.use("MochiKit.DOM", []); - JSAN.use("MochiKit.Style", []); -} - -try { - if (typeof(MochiKit.Base) == 'undefined') { - throw ""; - } -} catch (e) { - throw "MochiKit.Color depends on MochiKit.Base"; -} - -try { - if (typeof(MochiKit.DOM) == 'undefined') { - throw ""; - } -} catch (e) { - throw "MochiKit.Color depends on MochiKit.DOM"; -} - -try { - if (typeof(MochiKit.Style) == 'undefined') { - throw ""; - } -} catch (e) { - throw "MochiKit.Color depends on MochiKit.Style"; -} - -if (typeof(MochiKit.Color) == "undefined") { - MochiKit.Color = {}; -} - -MochiKit.Color.NAME = "MochiKit.Color"; -MochiKit.Color.VERSION = "1.4"; - -MochiKit.Color.__repr__ = function () { - return "[" + this.NAME + " " + this.VERSION + "]"; -}; - -MochiKit.Color.toString = function () { - return this.__repr__(); -}; - - -/** @id MochiKit.Color.Color */ -MochiKit.Color.Color = function (red, green, blue, alpha) { - if (typeof(alpha) == 'undefined' || alpha === null) { - alpha = 1.0; - } - this.rgb = { - r: red, - g: green, - b: blue, - a: alpha - }; -}; - - -// Prototype methods - -MochiKit.Color.Color.prototype = { - - __class__: MochiKit.Color.Color, - - /** @id MochiKit.Color.Color.prototype.colorWithAlpha */ - colorWithAlpha: function (alpha) { - var rgb = this.rgb; - var m = MochiKit.Color; - return m.Color.fromRGB(rgb.r, rgb.g, rgb.b, alpha); - }, - - /** @id MochiKit.Color.Color.prototype.colorWithHue */ - colorWithHue: function (hue) { - // get an HSL model, and set the new hue... - var hsl = this.asHSL(); - hsl.h = hue; - var m = MochiKit.Color; - // convert back to RGB... - return m.Color.fromHSL(hsl); - }, - - /** @id MochiKit.Color.Color.prototype.colorWithSaturation */ - colorWithSaturation: function (saturation) { - // get an HSL model, and set the new hue... - var hsl = this.asHSL(); - hsl.s = saturation; - var m = MochiKit.Color; - // convert back to RGB... - return m.Color.fromHSL(hsl); - }, - - /** @id MochiKit.Color.Color.prototype.colorWithLightness */ - colorWithLightness: function (lightness) { - // get an HSL model, and set the new hue... - var hsl = this.asHSL(); - hsl.l = lightness; - var m = MochiKit.Color; - // convert back to RGB... - return m.Color.fromHSL(hsl); - }, - - /** @id MochiKit.Color.Color.prototype.darkerColorWithLevel */ - darkerColorWithLevel: function (level) { - var hsl = this.asHSL(); - hsl.l = Math.max(hsl.l - level, 0); - var m = MochiKit.Color; - return m.Color.fromHSL(hsl); - }, - - /** @id MochiKit.Color.Color.prototype.lighterColorWithLevel */ - lighterColorWithLevel: function (level) { - var hsl = this.asHSL(); - hsl.l = Math.min(hsl.l + level, 1); - var m = MochiKit.Color; - return m.Color.fromHSL(hsl); - }, - - /** @id MochiKit.Color.Color.prototype.blendedColor */ - blendedColor: function (other, /* optional */ fraction) { - if (typeof(fraction) == 'undefined' || fraction === null) { - fraction = 0.5; - } - var sf = 1.0 - fraction; - var s = this.rgb; - var d = other.rgb; - var df = fraction; - return MochiKit.Color.Color.fromRGB( - (s.r * sf) + (d.r * df), - (s.g * sf) + (d.g * df), - (s.b * sf) + (d.b * df), - (s.a * sf) + (d.a * df) - ); - }, - - /** @id MochiKit.Color.Color.prototype.compareRGB */ - compareRGB: function (other) { - var a = this.asRGB(); - var b = other.asRGB(); - return MochiKit.Base.compare( - [a.r, a.g, a.b, a.a], - [b.r, b.g, b.b, b.a] - ); - }, - - /** @id MochiKit.Color.Color.prototype.isLight */ - isLight: function () { - return this.asHSL().b > 0.5; - }, - - /** @id MochiKit.Color.Color.prototype.isDark */ - isDark: function () { - return (!this.isLight()); - }, - - /** @id MochiKit.Color.Color.prototype.toHSLString */ - toHSLString: function () { - var c = this.asHSL(); - var ccc = MochiKit.Color.clampColorComponent; - var rval = this._hslString; - if (!rval) { - var mid = ( - ccc(c.h, 360).toFixed(0) - + "," + ccc(c.s, 100).toPrecision(4) + "%" - + "," + ccc(c.l, 100).toPrecision(4) + "%" - ); - var a = c.a; - if (a >= 1) { - a = 1; - rval = "hsl(" + mid + ")"; - } else { - if (a <= 0) { - a = 0; - } - rval = "hsla(" + mid + "," + a + ")"; - } - this._hslString = rval; - } - return rval; - }, - - /** @id MochiKit.Color.Color.prototype.toRGBString */ - toRGBString: function () { - var c = this.rgb; - var ccc = MochiKit.Color.clampColorComponent; - var rval = this._rgbString; - if (!rval) { - var mid = ( - ccc(c.r, 255).toFixed(0) - + "," + ccc(c.g, 255).toFixed(0) - + "," + ccc(c.b, 255).toFixed(0) - ); - if (c.a != 1) { - rval = "rgba(" + mid + "," + c.a + ")"; - } else { - rval = "rgb(" + mid + ")"; - } - this._rgbString = rval; - } - return rval; - }, - - /** @id MochiKit.Color.Color.prototype.asRGB */ - asRGB: function () { - return MochiKit.Base.clone(this.rgb); - }, - - /** @id MochiKit.Color.Color.prototype.toHexString */ - toHexString: function () { - var m = MochiKit.Color; - var c = this.rgb; - var ccc = MochiKit.Color.clampColorComponent; - var rval = this._hexString; - if (!rval) { - rval = ("#" + - m.toColorPart(ccc(c.r, 255)) + - m.toColorPart(ccc(c.g, 255)) + - m.toColorPart(ccc(c.b, 255)) - ); - this._hexString = rval; - } - return rval; - }, - - /** @id MochiKit.Color.Color.prototype.asHSV */ - asHSV: function () { - var hsv = this.hsv; - var c = this.rgb; - if (typeof(hsv) == 'undefined' || hsv === null) { - hsv = MochiKit.Color.rgbToHSV(this.rgb); - this.hsv = hsv; - } - return MochiKit.Base.clone(hsv); - }, - - /** @id MochiKit.Color.Color.prototype.asHSL */ - asHSL: function () { - var hsl = this.hsl; - var c = this.rgb; - if (typeof(hsl) == 'undefined' || hsl === null) { - hsl = MochiKit.Color.rgbToHSL(this.rgb); - this.hsl = hsl; - } - return MochiKit.Base.clone(hsl); - }, - - /** @id MochiKit.Color.Color.prototype.toString */ - toString: function () { - return this.toRGBString(); - }, - - /** @id MochiKit.Color.Color.prototype.repr */ - repr: function () { - var c = this.rgb; - var col = [c.r, c.g, c.b, c.a]; - return this.__class__.NAME + "(" + col.join(", ") + ")"; - } - -}; - -// Constructor methods - -MochiKit.Base.update(MochiKit.Color.Color, { - /** @id MochiKit.Color.Color.fromRGB */ - fromRGB: function (red, green, blue, alpha) { - // designated initializer - var Color = MochiKit.Color.Color; - if (arguments.length == 1) { - var rgb = red; - red = rgb.r; - green = rgb.g; - blue = rgb.b; - if (typeof(rgb.a) == 'undefined') { - alpha = undefined; - } else { - alpha = rgb.a; - } - } - return new Color(red, green, blue, alpha); - }, - - /** @id MochiKit.Color.Color.fromHSL */ - fromHSL: function (hue, saturation, lightness, alpha) { - var m = MochiKit.Color; - return m.Color.fromRGB(m.hslToRGB.apply(m, arguments)); - }, - - /** @id MochiKit.Color.Color.fromHSV */ - fromHSV: function (hue, saturation, value, alpha) { - var m = MochiKit.Color; - return m.Color.fromRGB(m.hsvToRGB.apply(m, arguments)); - }, - - /** @id MochiKit.Color.Color.fromName */ - fromName: function (name) { - var Color = MochiKit.Color.Color; - // Opera 9 seems to "quote" named colors(?!) - if (name.charAt(0) == '"') { - name = name.substr(1, name.length - 2); - } - var htmlColor = Color._namedColors[name.toLowerCase()]; - if (typeof(htmlColor) == 'string') { - return Color.fromHexString(htmlColor); - } else if (name == "transparent") { - return Color.transparentColor(); - } - return null; - }, - - /** @id MochiKit.Color.Color.fromString */ - fromString: function (colorString) { - var self = MochiKit.Color.Color; - var three = colorString.substr(0, 3); - if (three == "rgb") { - return self.fromRGBString(colorString); - } else if (three == "hsl") { - return self.fromHSLString(colorString); - } else if (colorString.charAt(0) == "#") { - return self.fromHexString(colorString); - } - return self.fromName(colorString); - }, - - - /** @id MochiKit.Color.Color.fromHexString */ - fromHexString: function (hexCode) { - if (hexCode.charAt(0) == '#') { - hexCode = hexCode.substring(1); - } - var components = []; - var i, hex; - if (hexCode.length == 3) { - for (i = 0; i < 3; i++) { - hex = hexCode.substr(i, 1); - components.push(parseInt(hex + hex, 16) / 255.0); - } - } else { - for (i = 0; i < 6; i += 2) { - hex = hexCode.substr(i, 2); - components.push(parseInt(hex, 16) / 255.0); - } - } - var Color = MochiKit.Color.Color; - return Color.fromRGB.apply(Color, components); - }, - - - _fromColorString: function (pre, method, scales, colorCode) { - // parses either HSL or RGB - if (colorCode.indexOf(pre) === 0) { - colorCode = colorCode.substring(colorCode.indexOf("(", 3) + 1, colorCode.length - 1); - } - var colorChunks = colorCode.split(/\s*,\s*/); - var colorFloats = []; - for (var i = 0; i < colorChunks.length; i++) { - var c = colorChunks[i]; - var val; - var three = c.substring(c.length - 3); - if (c.charAt(c.length - 1) == '%') { - val = 0.01 * parseFloat(c.substring(0, c.length - 1)); - } else if (three == "deg") { - val = parseFloat(c) / 360.0; - } else if (three == "rad") { - val = parseFloat(c) / (Math.PI * 2); - } else { - val = scales[i] * parseFloat(c); - } - colorFloats.push(val); - } - return this[method].apply(this, colorFloats); - }, - - /** @id MochiKit.Color.Color.fromComputedStyle */ - fromComputedStyle: function (elem, style) { - var d = MochiKit.DOM; - var cls = MochiKit.Color.Color; - for (elem = d.getElement(elem); elem; elem = elem.parentNode) { - var actualColor = MochiKit.Style.getStyle.apply(d, arguments); - if (!actualColor) { - continue; - } - var color = cls.fromString(actualColor); - if (!color) { - break; - } - if (color.asRGB().a > 0) { - return color; - } - } - return null; - }, - - /** @id MochiKit.Color.Color.fromBackground */ - fromBackground: function (elem) { - var cls = MochiKit.Color.Color; - return cls.fromComputedStyle( - elem, "backgroundColor", "background-color") || cls.whiteColor(); - }, - - /** @id MochiKit.Color.Color.fromText */ - fromText: function (elem) { - var cls = MochiKit.Color.Color; - return cls.fromComputedStyle( - elem, "color", "color") || cls.blackColor(); - }, - - /** @id MochiKit.Color.Color.namedColors */ - namedColors: function () { - return MochiKit.Base.clone(MochiKit.Color.Color._namedColors); - } -}); - - -// Module level functions - -MochiKit.Base.update(MochiKit.Color, { - /** @id MochiKit.Color.clampColorComponent */ - clampColorComponent: function (v, scale) { - v *= scale; - if (v < 0) { - return 0; - } else if (v > scale) { - return scale; - } else { - return v; - } - }, - - _hslValue: function (n1, n2, hue) { - if (hue > 6.0) { - hue -= 6.0; - } else if (hue < 0.0) { - hue += 6.0; - } - var val; - if (hue < 1.0) { - val = n1 + (n2 - n1) * hue; - } else if (hue < 3.0) { - val = n2; - } else if (hue < 4.0) { - val = n1 + (n2 - n1) * (4.0 - hue); - } else { - val = n1; - } - return val; - }, - - /** @id MochiKit.Color.hsvToRGB */ - hsvToRGB: function (hue, saturation, value, alpha) { - if (arguments.length == 1) { - var hsv = hue; - hue = hsv.h; - saturation = hsv.s; - value = hsv.v; - alpha = hsv.a; - } - var red; - var green; - var blue; - if (saturation === 0) { - red = value; - green = value; - blue = value; - } else { - var i = Math.floor(hue * 6); - var f = (hue * 6) - i; - var p = value * (1 - saturation); - var q = value * (1 - (saturation * f)); - var t = value * (1 - (saturation * (1 - f))); - switch (i) { - case 1: red = q; green = value; blue = p; break; - case 2: red = p; green = value; blue = t; break; - case 3: red = p; green = q; blue = value; break; - case 4: red = t; green = p; blue = value; break; - case 5: red = value; green = p; blue = q; break; - case 6: // fall through - case 0: red = value; green = t; blue = p; break; - } - } - return { - r: red, - g: green, - b: blue, - a: alpha - }; - }, - - /** @id MochiKit.Color.hslToRGB */ - hslToRGB: function (hue, saturation, lightness, alpha) { - if (arguments.length == 1) { - var hsl = hue; - hue = hsl.h; - saturation = hsl.s; - lightness = hsl.l; - alpha = hsl.a; - } - var red; - var green; - var blue; - if (saturation === 0) { - red = lightness; - green = lightness; - blue = lightness; - } else { - var m2; - if (lightness <= 0.5) { - m2 = lightness * (1.0 + saturation); - } else { - m2 = lightness + saturation - (lightness * saturation); - } - var m1 = (2.0 * lightness) - m2; - var f = MochiKit.Color._hslValue; - var h6 = hue * 6.0; - red = f(m1, m2, h6 + 2); - green = f(m1, m2, h6); - blue = f(m1, m2, h6 - 2); - } - return { - r: red, - g: green, - b: blue, - a: alpha - }; - }, - - /** @id MochiKit.Color.rgbToHSV */ - rgbToHSV: function (red, green, blue, alpha) { - if (arguments.length == 1) { - var rgb = red; - red = rgb.r; - green = rgb.g; - blue = rgb.b; - alpha = rgb.a; - } - var max = Math.max(Math.max(red, green), blue); - var min = Math.min(Math.min(red, green), blue); - var hue; - var saturation; - var value = max; - if (min == max) { - hue = 0; - saturation = 0; - } else { - var delta = (max - min); - saturation = delta / max; - - if (red == max) { - hue = (green - blue) / delta; - } else if (green == max) { - hue = 2 + ((blue - red) / delta); - } else { - hue = 4 + ((red - green) / delta); - } - hue /= 6; - if (hue < 0) { - hue += 1; - } - if (hue > 1) { - hue -= 1; - } - } - return { - h: hue, - s: saturation, - v: value, - a: alpha - }; - }, - - /** @id MochiKit.Color.rgbToHSL */ - rgbToHSL: function (red, green, blue, alpha) { - if (arguments.length == 1) { - var rgb = red; - red = rgb.r; - green = rgb.g; - blue = rgb.b; - alpha = rgb.a; - } - var max = Math.max(red, Math.max(green, blue)); - var min = Math.min(red, Math.min(green, blue)); - var hue; - var saturation; - var lightness = (max + min) / 2.0; - var delta = max - min; - if (delta === 0) { - hue = 0; - saturation = 0; - } else { - if (lightness <= 0.5) { - saturation = delta / (max + min); - } else { - saturation = delta / (2 - max - min); - } - if (red == max) { - hue = (green - blue) / delta; - } else if (green == max) { - hue = 2 + ((blue - red) / delta); - } else { - hue = 4 + ((red - green) / delta); - } - hue /= 6; - if (hue < 0) { - hue += 1; - } - if (hue > 1) { - hue -= 1; - } - - } - return { - h: hue, - s: saturation, - l: lightness, - a: alpha - }; - }, - - /** @id MochiKit.Color.toColorPart */ - toColorPart: function (num) { - num = Math.round(num); - var digits = num.toString(16); - if (num < 16) { - return '0' + digits; - } - return digits; - }, - - __new__: function () { - var m = MochiKit.Base; - /** @id MochiKit.Color.fromRGBString */ - this.Color.fromRGBString = m.bind( - this.Color._fromColorString, this.Color, "rgb", "fromRGB", - [1.0/255.0, 1.0/255.0, 1.0/255.0, 1] - ); - /** @id MochiKit.Color.fromHSLString */ - this.Color.fromHSLString = m.bind( - this.Color._fromColorString, this.Color, "hsl", "fromHSL", - [1.0/360.0, 0.01, 0.01, 1] - ); - - var third = 1.0 / 3.0; - /** @id MochiKit.Color.colors */ - var colors = { - // NSColor colors plus transparent - /** @id MochiKit.Color.blackColor */ - black: [0, 0, 0], - /** @id MochiKit.Color.blueColor */ - blue: [0, 0, 1], - /** @id MochiKit.Color.brownColor */ - brown: [0.6, 0.4, 0.2], - /** @id MochiKit.Color.cyanColor */ - cyan: [0, 1, 1], - /** @id MochiKit.Color.darkGrayColor */ - darkGray: [third, third, third], - /** @id MochiKit.Color.grayColor */ - gray: [0.5, 0.5, 0.5], - /** @id MochiKit.Color.greenColor */ - green: [0, 1, 0], - /** @id MochiKit.Color.lightGrayColor */ - lightGray: [2 * third, 2 * third, 2 * third], - /** @id MochiKit.Color.magentaColor */ - magenta: [1, 0, 1], - /** @id MochiKit.Color.orangeColor */ - orange: [1, 0.5, 0], - /** @id MochiKit.Color.purpleColor */ - purple: [0.5, 0, 0.5], - /** @id MochiKit.Color.redColor */ - red: [1, 0, 0], - /** @id MochiKit.Color.transparentColor */ - transparent: [0, 0, 0, 0], - /** @id MochiKit.Color.whiteColor */ - white: [1, 1, 1], - /** @id MochiKit.Color.yellowColor */ - yellow: [1, 1, 0] - }; - - var makeColor = function (name, r, g, b, a) { - var rval = this.fromRGB(r, g, b, a); - this[name] = function () { return rval; }; - return rval; - }; - - for (var k in colors) { - var name = k + "Color"; - var bindArgs = m.concat( - [makeColor, this.Color, name], - colors[k] - ); - this.Color[name] = m.bind.apply(null, bindArgs); - } - - var isColor = function () { - for (var i = 0; i < arguments.length; i++) { - if (!(arguments[i] instanceof Color)) { - return false; - } - } - return true; - }; - - var compareColor = function (a, b) { - return a.compareRGB(b); - }; - - m.nameFunctions(this); - - m.registerComparator(this.Color.NAME, isColor, compareColor); - - this.EXPORT_TAGS = { - ":common": this.EXPORT, - ":all": m.concat(this.EXPORT, this.EXPORT_OK) - }; - - } -}); - -MochiKit.Color.EXPORT = [ - "Color" -]; - -MochiKit.Color.EXPORT_OK = [ - "clampColorComponent", - "rgbToHSL", - "hslToRGB", - "rgbToHSV", - "hsvToRGB", - "toColorPart" -]; - -MochiKit.Color.__new__(); - -MochiKit.Base._exportSymbols(this, MochiKit.Color); - -// Full table of css3 X11 colors <http://www.w3.org/TR/css3-color/#X11COLORS> - -MochiKit.Color.Color._namedColors = { - aliceblue: "#f0f8ff", - antiquewhite: "#faebd7", - aqua: "#00ffff", - aquamarine: "#7fffd4", - azure: "#f0ffff", - beige: "#f5f5dc", - bisque: "#ffe4c4", - black: "#000000", - blanchedalmond: "#ffebcd", - blue: "#0000ff", - blueviolet: "#8a2be2", - brown: "#a52a2a", - burlywood: "#deb887", - cadetblue: "#5f9ea0", - chartreuse: "#7fff00", - chocolate: "#d2691e", - coral: "#ff7f50", - cornflowerblue: "#6495ed", - cornsilk: "#fff8dc", - crimson: "#dc143c", - cyan: "#00ffff", - darkblue: "#00008b", - darkcyan: "#008b8b", - darkgoldenrod: "#b8860b", - darkgray: "#a9a9a9", - darkgreen: "#006400", - darkgrey: "#a9a9a9", - darkkhaki: "#bdb76b", - darkmagenta: "#8b008b", - darkolivegreen: "#556b2f", - darkorange: "#ff8c00", - darkorchid: "#9932cc", - darkred: "#8b0000", - darksalmon: "#e9967a", - darkseagreen: "#8fbc8f", - darkslateblue: "#483d8b", - darkslategray: "#2f4f4f", - darkslategrey: "#2f4f4f", - darkturquoise: "#00ced1", - darkviolet: "#9400d3", - deeppink: "#ff1493", - deepskyblue: "#00bfff", - dimgray: "#696969", - dimgrey: "#696969", - dodgerblue: "#1e90ff", - firebrick: "#b22222", - floralwhite: "#fffaf0", - forestgreen: "#228b22", - fuchsia: "#ff00ff", - gainsboro: "#dcdcdc", - ghostwhite: "#f8f8ff", - gold: "#ffd700", - goldenrod: "#daa520", - gray: "#808080", - green: "#008000", - greenyellow: "#adff2f", - grey: "#808080", - honeydew: "#f0fff0", - hotpink: "#ff69b4", - indianred: "#cd5c5c", - indigo: "#4b0082", - ivory: "#fffff0", - khaki: "#f0e68c", - lavender: "#e6e6fa", - lavenderblush: "#fff0f5", - lawngreen: "#7cfc00", - lemonchiffon: "#fffacd", - lightblue: "#add8e6", - lightcoral: "#f08080", - lightcyan: "#e0ffff", - lightgoldenrodyellow: "#fafad2", - lightgray: "#d3d3d3", - lightgreen: "#90ee90", - lightgrey: "#d3d3d3", - lightpink: "#ffb6c1", - lightsalmon: "#ffa07a", - lightseagreen: "#20b2aa", - lightskyblue: "#87cefa", - lightslategray: "#778899", - lightslategrey: "#778899", - lightsteelblue: "#b0c4de", - lightyellow: "#ffffe0", - lime: "#00ff00", - limegreen: "#32cd32", - linen: "#faf0e6", - magenta: "#ff00ff", - maroon: "#800000", - mediumaquamarine: "#66cdaa", - mediumblue: "#0000cd", - mediumorchid: "#ba55d3", - mediumpurple: "#9370db", - mediumseagreen: "#3cb371", - mediumslateblue: "#7b68ee", - mediumspringgreen: "#00fa9a", - mediumturquoise: "#48d1cc", - mediumvioletred: "#c71585", - midnightblue: "#191970", - mintcream: "#f5fffa", - mistyrose: "#ffe4e1", - moccasin: "#ffe4b5", - navajowhite: "#ffdead", - navy: "#000080", - oldlace: "#fdf5e6", - olive: "#808000", - olivedrab: "#6b8e23", - orange: "#ffa500", - orangered: "#ff4500", - orchid: "#da70d6", - palegoldenrod: "#eee8aa", - palegreen: "#98fb98", - paleturquoise: "#afeeee", - palevioletred: "#db7093", - papayawhip: "#ffefd5", - peachpuff: "#ffdab9", - peru: "#cd853f", - pink: "#ffc0cb", - plum: "#dda0dd", - powderblue: "#b0e0e6", - purple: "#800080", - red: "#ff0000", - rosybrown: "#bc8f8f", - royalblue: "#4169e1", - saddlebrown: "#8b4513", - salmon: "#fa8072", - sandybrown: "#f4a460", - seagreen: "#2e8b57", - seashell: "#fff5ee", - sienna: "#a0522d", - silver: "#c0c0c0", - skyblue: "#87ceeb", - slateblue: "#6a5acd", - slategray: "#708090", - slategrey: "#708090", - snow: "#fffafa", - springgreen: "#00ff7f", - steelblue: "#4682b4", - tan: "#d2b48c", - teal: "#008080", - thistle: "#d8bfd8", - tomato: "#ff6347", - turquoise: "#40e0d0", - violet: "#ee82ee", - wheat: "#f5deb3", - white: "#ffffff", - whitesmoke: "#f5f5f5", - yellow: "#ffff00", - yellowgreen: "#9acd32" -}; diff --git a/javascript/libs/MochiKit/Controls.css b/javascript/libs/MochiKit/Controls.css deleted file mode 100644 index 2d0eadb..0000000 --- a/javascript/libs/MochiKit/Controls.css +++ /dev/null @@ -1,51 +0,0 @@ - div.auto_complete { - position:absolute; - width:250px; - background-color:white; - border:1px solid #888; - margin:0px; - padding:0px; - } - ul.contacts { - list-style-type: none; - margin:0px; - padding:0px; - } - ul.contacts li.selected { background-color: #ffb; } - li.contact { - list-style-type: none; - display:block; - margin:0; - padding:2px; - height:32px; - } - li.contact div.image { - float:left; - width:32px; - height:32px; - margin-right:8px; - } - li.contact div.name { - font-weight:bold; - font-size:12px; - line-height:1.2em; - } - li.contact div.email { - font-size:10px; - color:#888; - } - #list { - margin:0; - margin-top:10px; - padding:0; - list-style-type: none; - width:250px; - } - #list li { - margin:0; - margin-bottom:4px; - padding:5px; - border:1px solid #888; - cursor:move; - } - diff --git a/javascript/libs/MochiKit/Controls.js b/javascript/libs/MochiKit/Controls.js deleted file mode 100644 index c044ef2..0000000 --- a/javascript/libs/MochiKit/Controls.js +++ /dev/null @@ -1,1388 +0,0 @@ -/*** -Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) - (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan) - (c) 2005 Jon Tirsen (http://www.tirsen.com) -Contributors: - Richard Livsey - Rahul Bhargava - Rob Wills - Mochi-ized By Thomas Herve (_firstname_@nimail.org) - -See scriptaculous.js for full license. - -Autocompleter.Base handles all the autocompletion functionality -that's independent of the data source for autocompletion. This -includes drawing the autocompletion menu, observing keyboard -and mouse events, and similar. - -Specific autocompleters need to provide, at the very least, -a getUpdatedChoices function that will be invoked every time -the text inside the monitored textbox changes. This method -should get the text for which to provide autocompletion by -invoking this.getToken(), NOT by directly accessing -this.element.value. This is to allow incremental tokenized -autocompletion. Specific auto-completion logic (AJAX, etc) -belongs in getUpdatedChoices. - -Tokenized incremental autocompletion is enabled automatically -when an autocompleter is instantiated with the 'tokens' option -in the options parameter, e.g.: -new Ajax.Autocompleter('id','upd', '/url/', { tokens: ',' }); -will incrementally autocomplete with a comma as the token. -Additionally, ',' in the above example can be replaced with -a token array, e.g. { tokens: [',', '\n'] } which -enables autocompletion on multiple tokens. This is most -useful when one of the tokens is \n (a newline), as it -allows smart autocompletion after linebreaks. - -***/ - -MochiKit.Base.update(MochiKit.Base, { - ScriptFragment: '(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)', - -/** @id MochiKit.Base.stripScripts */ - stripScripts: function (str) { - return str.replace(new RegExp(MochiKit.Base.ScriptFragment, 'img'), ''); - }, - -/** @id MochiKit.Base.stripTags */ - stripTags: function(str) { - return str.replace(/<\/?[^>]+>/gi, ''); - }, - -/** @id MochiKit.Base.extractScripts */ - extractScripts: function (str) { - var matchAll = new RegExp(MochiKit.Base.ScriptFragment, 'img'); - var matchOne = new RegExp(MochiKit.Base.ScriptFragment, 'im'); - return MochiKit.Base.map(function (scriptTag) { - return (scriptTag.match(matchOne) || ['', ''])[1]; - }, str.match(matchAll) || []); - }, - -/** @id MochiKit.Base.evalScripts */ - evalScripts: function (str) { - return MochiKit.Base.map(function (scr) { - eval(scr); - }, MochiKit.Base.extractScripts(str)); - } -}); - -MochiKit.Form = { - -/** @id MochiKit.Form.serialize */ - serialize: function (form) { - var elements = MochiKit.Form.getElements(form); - var queryComponents = []; - - for (var i = 0; i < elements.length; i++) { - var queryComponent = MochiKit.Form.serializeElement(elements[i]); - if (queryComponent) { - queryComponents.push(queryComponent); - } - } - - return queryComponents.join('&'); - }, - -/** @id MochiKit.Form.getElements */ - getElements: function (form) { - form = MochiKit.DOM.getElement(form); - var elements = []; - - for (var tagName in MochiKit.Form.Serializers) { - var tagElements = form.getElementsByTagName(tagName); - for (var j = 0; j < tagElements.length; j++) { - elements.push(tagElements[j]); - } - } - return elements; - }, - -/** @id MochiKit.Form.serializeElement */ - serializeElement: function (element) { - element = MochiKit.DOM.getElement(element); - var method = element.tagName.toLowerCase(); - var parameter = MochiKit.Form.Serializers[method](element); - - if (parameter) { - var key = encodeURIComponent(parameter[0]); - if (key.length === 0) { - return; - } - - if (!(parameter[1] instanceof Array)) { - parameter[1] = [parameter[1]]; - } - - return parameter[1].map(function (value) { - return key + '=' + encodeURIComponent(value); - }).join('&'); - } - } -}; - -MochiKit.Form.Serializers = { - -/** @id MochiKit.Form.Serializers.input */ - input: function (element) { - switch (element.type.toLowerCase()) { - case 'submit': - case 'hidden': - case 'password': - case 'text': - return MochiKit.Form.Serializers.textarea(element); - case 'checkbox': - case 'radio': - return MochiKit.Form.Serializers.inputSelector(element); - } - return false; - }, - -/** @id MochiKit.Form.Serializers.inputSelector */ - inputSelector: function (element) { - if (element.checked) { - return [element.name, element.value]; - } - }, - -/** @id MochiKit.Form.Serializers.textarea */ - textarea: function (element) { - return [element.name, element.value]; - }, - -/** @id MochiKit.Form.Serializers.select */ - select: function (element) { - return MochiKit.Form.Serializers[element.type == 'select-one' ? - 'selectOne' : 'selectMany'](element); - }, - -/** @id MochiKit.Form.Serializers.selectOne */ - selectOne: function (element) { - var value = '', opt, index = element.selectedIndex; - if (index >= 0) { - opt = element.options[index]; - value = opt.value; - if (!value && !('value' in opt)) { - value = opt.text; - } - } - return [element.name, value]; - }, - -/** @id MochiKit.Form.Serializers.selectMany */ - selectMany: function (element) { - var value = []; - for (var i = 0; i < element.length; i++) { - var opt = element.options[i]; - if (opt.selected) { - var optValue = opt.value; - if (!optValue && !('value' in opt)) { - optValue = opt.text; - } - value.push(optValue); - } - } - return [element.name, value]; - } -}; - -/** @id Ajax */ -var Ajax = { - activeRequestCount: 0 -}; - -Ajax.Responders = { - responders: [], - -/** @id Ajax.Responders.register */ - register: function (responderToAdd) { - if (MochiKit.Base.find(this.responders, responderToAdd) == -1) { - this.responders.push(responderToAdd); - } - }, - -/** @id Ajax.Responders.unregister */ - unregister: function (responderToRemove) { - this.responders = this.responders.without(responderToRemove); - }, - -/** @id Ajax.Responders.dispatch */ - dispatch: function (callback, request, transport, json) { - MochiKit.Iter.forEach(this.responders, function (responder) { - if (responder[callback] && - typeof(responder[callback]) == 'function') { - try { - responder[callback].apply(responder, [request, transport, json]); - } catch (e) {} - } - }); - } -}; - -Ajax.Responders.register({ - -/** @id Ajax.Responders.onCreate */ - onCreate: function () { - Ajax.activeRequestCount++; - }, - -/** @id Ajax.Responders.onComplete */ - onComplete: function () { - Ajax.activeRequestCount--; - } -}); - -/** @id Ajax.Base */ -Ajax.Base = function () {}; - -Ajax.Base.prototype = { - -/** @id Ajax.Base.prototype.setOptions */ - setOptions: function (options) { - this.options = { - method: 'post', - asynchronous: true, - parameters: '' - } - MochiKit.Base.update(this.options, options || {}); - }, - -/** @id Ajax.Base.prototype.responseIsSuccess */ - responseIsSuccess: function () { - return this.transport.status == undefined - || this.transport.status === 0 - || (this.transport.status >= 200 && this.transport.status < 300); - }, - -/** @id Ajax.Base.prototype.responseIsFailure */ - responseIsFailure: function () { - return !this.responseIsSuccess(); - } -}; - -/** @id Ajax.Request */ -Ajax.Request = function (url, options) { - this.__init__(url, options); -}; - -/** @id Ajax.Events */ -Ajax.Request.Events = ['Uninitialized', 'Loading', 'Loaded', - 'Interactive', 'Complete']; - -MochiKit.Base.update(Ajax.Request.prototype, Ajax.Base.prototype); - -MochiKit.Base.update(Ajax.Request.prototype, { - __init__: function (url, options) { - this.transport = MochiKit.Async.getXMLHttpRequest(); - this.setOptions(options); - this.request(url); - }, - -/** @id Ajax.Request.prototype.request */ - request: function (url) { - var parameters = this.options.parameters || ''; - if (parameters.length > 0){ - parameters += '&_='; - } - - try { - this.url = url; - if (this.options.method == 'get' && parameters.length > 0) { - this.url += (this.url.match(/\?/) ? '&' : '?') + parameters; - } - Ajax.Responders.dispatch('onCreate', this, this.transport); - - this.transport.open(this.options.method, this.url, - this.options.asynchronous); - - if (this.options.asynchronous) { - this.transport.onreadystatechange = MochiKit.Base.bind(this.onStateChange, this); - setTimeout(MochiKit.Base.bind(function () { - this.respondToReadyState(1); - }, this), 10); - } - - this.setRequestHeaders(); - - var body = this.options.postBody ? this.options.postBody : parameters; - this.transport.send(this.options.method == 'post' ? body : null); - - } catch (e) { - this.dispatchException(e); - } - }, - -/** @id Ajax.Request.prototype.setRequestHeaders */ - setRequestHeaders: function () { - var requestHeaders = ['X-Requested-With', 'XMLHttpRequest']; - - if (this.options.method == 'post') { - requestHeaders.push('Content-type', - 'application/x-www-form-urlencoded'); - - /* Force 'Connection: close' for Mozilla browsers to work around - * a bug where XMLHttpRequest sends an incorrect Content-length - * header. See Mozilla Bugzilla #246651. - */ - if (this.transport.overrideMimeType) { - requestHeaders.push('Connection', 'close'); - } - } - - if (this.options.requestHeaders) { - requestHeaders.push.apply(requestHeaders, this.options.requestHeaders); - } - - for (var i = 0; i < requestHeaders.length; i += 2) { - this.transport.setRequestHeader(requestHeaders[i], requestHeaders[i+1]); - } - }, - -/** @id Ajax.Request.prototype.onStateChange */ - onStateChange: function () { - var readyState = this.transport.readyState; - if (readyState != 1) { - this.respondToReadyState(this.transport.readyState); - } - }, - -/** @id Ajax.Request.prototype.header */ - header: function (name) { - try { - return this.transport.getResponseHeader(name); - } catch (e) {} - }, - -/** @id Ajax.Request.prototype.evalJSON */ - evalJSON: function () { - try { - return eval(this.header('X-JSON')); - } catch (e) {} - }, - -/** @id Ajax.Request.prototype.evalResponse */ - evalResponse: function () { - try { - return eval(this.transport.responseText); - } catch (e) { - this.dispatchException(e); - } - }, - -/** @id Ajax.Request.prototype.respondToReadyState */ - respondToReadyState: function (readyState) { - var event = Ajax.Request.Events[readyState]; - var transport = this.transport, json = this.evalJSON(); - - if (event == 'Complete') { - try { - (this.options['on' + this.transport.status] - || this.options['on' + (this.responseIsSuccess() ? 'Success' : 'Failure')] - || MochiKit.Base.noop)(transport, json); - } catch (e) { - this.dispatchException(e); - } - - if ((this.header('Content-type') || '').match(/^text\/javascript/i)) { - this.evalResponse(); - } - } - - try { - (this.options['on' + event] || MochiKit.Base.noop)(transport, json); - Ajax.Responders.dispatch('on' + event, this, transport, json); - } catch (e) { - this.dispatchException(e); - } - - /* Avoid memory leak in MSIE: clean up the oncomplete event handler */ - if (event == 'Complete') { - this.transport.onreadystatechange = MochiKit.Base.noop; - } - }, - -/** @id Ajax.Request.prototype.dispatchException */ - dispatchException: function (exception) { - (this.options.onException || MochiKit.Base.noop)(this, exception); - Ajax.Responders.dispatch('onException', this, exception); - } -}); - -/** @id Ajax.Updater */ -Ajax.Updater = function (container, url, options) { - this.__init__(container, url, options); -}; - -MochiKit.Base.update(Ajax.Updater.prototype, Ajax.Request.prototype); - -MochiKit.Base.update(Ajax.Updater.prototype, { - __init__: function (container, url, options) { - this.containers = { - success: container.success ? MochiKit.DOM.getElement(container.success) : MochiKit.DOM.getElement(container), - failure: container.failure ? MochiKit.DOM.getElement(container.failure) : - (container.success ? null : MochiKit.DOM.getElement(container)) - } - this.transport = MochiKit.Async.getXMLHttpRequest(); - this.setOptions(options); - - var onComplete = this.options.onComplete || MochiKit.Base.noop; - this.options.onComplete = MochiKit.Base.bind(function (transport, object) { - this.updateContent(); - onComplete(transport, object); - }, this); - - this.request(url); - }, - -/** @id Ajax.Updater.prototype.updateContent */ - updateContent: function () { - var receiver = this.responseIsSuccess() ? - this.containers.success : this.containers.failure; - var response = this.transport.responseText; - - if (!this.options.evalScripts) { - response = MochiKit.Base.stripScripts(response); - } - - if (receiver) { - if (this.options.insertion) { - new this.options.insertion(receiver, response); - } else { - MochiKit.DOM.getElement(receiver).innerHTML = - MochiKit.Base.stripScripts(response); - setTimeout(function () { - MochiKit.Base.evalScripts(response); - }, 10); - } - } - - if (this.responseIsSuccess()) { - if (this.onComplete) { - setTimeout(MochiKit.Base.bind(this.onComplete, this), 10); - } - } - } -}); - -/** @id Field */ -var Field = { - -/** @id clear */ - clear: function () { - for (var i = 0; i < arguments.length; i++) { - MochiKit.DOM.getElement(arguments[i]).value = ''; - } - }, - -/** @id focus */ - focus: function (element) { - MochiKit.DOM.getElement(element).focus(); - }, - -/** @id present */ - present: function () { - for (var i = 0; i < arguments.length; i++) { - if (MochiKit.DOM.getElement(arguments[i]).value == '') { - return false; - } - } - return true; - }, - -/** @id select */ - select: function (element) { - MochiKit.DOM.getElement(element).select(); - }, - -/** @id activate */ - activate: function (element) { - element = MochiKit.DOM.getElement(element); - element.focus(); - if (element.select) { - element.select(); - } - }, - -/** @id scrollFreeActivate */ - scrollFreeActivate: function (field) { - setTimeout(function () { - Field.activate(field); - }, 1); - } -}; - - -/** @id Autocompleter */ -var Autocompleter = {}; - -/** @id Autocompleter.Base */ -Autocompleter.Base = function () {}; - -Autocompleter.Base.prototype = { - -/** @id Autocompleter.Base.prototype.baseInitialize */ - baseInitialize: function (element, update, options) { - this.element = MochiKit.DOM.getElement(element); - this.update = MochiKit.DOM.getElement(update); - this.hasFocus = false; - this.changed = false; - this.active = false; - this.index = 0; - this.entryCount = 0; - - if (this.setOptions) { - this.setOptions(options); - } - else { - this.options = options || {}; - } - - this.options.paramName = this.options.paramName || this.element.name; - this.options.tokens = this.options.tokens || []; - this.options.frequency = this.options.frequency || 0.4; - this.options.minChars = this.options.minChars || 1; - this.options.onShow = this.options.onShow || function (element, update) { - if (!update.style.position || update.style.position == 'absolute') { - update.style.position = 'absolute'; - MochiKit.Position.clone(element, update, { - setHeight: false, - offsetTop: element.offsetHeight - }); - } - MochiKit.Visual.appear(update, {duration:0.15}); - }; - this.options.onHide = this.options.onHide || function (element, update) { - MochiKit.Visual.fade(update, {duration: 0.15}); - }; - - if (typeof(this.options.tokens) == 'string') { - this.options.tokens = new Array(this.options.tokens); - } - - this.observer = null; - - this.element.setAttribute('autocomplete', 'off'); - - MochiKit.Style.hideElement(this.update); - - MochiKit.Signal.connect(this.element, 'onblur', this, this.onBlur); - MochiKit.Signal.connect(this.element, 'onkeypress', this, this.onKeyPress, this); - }, - -/** @id Autocompleter.Base.prototype.show */ - show: function () { - if (MochiKit.Style.getStyle(this.update, 'display') == 'none') { - this.options.onShow(this.element, this.update); - } - if (!this.iefix && /MSIE/.test(navigator.userAgent && - (MochiKit.Style.getStyle(this.update, 'position') == 'absolute'))) { - new Insertion.After(this.update, - '<iframe id="' + this.update.id + '_iefix" '+ - 'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' + - 'src="javascript:false;" frameborder="0" scrolling="no"></iframe>'); - this.iefix = MochiKit.DOM.getElement(this.update.id + '_iefix'); - } - if (this.iefix) { - setTimeout(MochiKit.Base.bind(this.fixIEOverlapping, this), 50); - } - }, - -/** @id Autocompleter.Base.prototype.fixIEOverlapping */ - fixIEOverlapping: function () { - MochiKit.Position.clone(this.update, this.iefix); - this.iefix.style.zIndex = 1; - this.update.style.zIndex = 2; - MochiKit.Style.showElement(this.iefix); - }, - -/** @id Autocompleter.Base.prototype.hide */ - hide: function () { - this.stopIndicator(); - if (MochiKit.Style.getStyle(this.update, 'display') != 'none') { - this.options.onHide(this.element, this.update); - } - if (this.iefix) { - MochiKit.Style.hideElement(this.iefix); - } - }, - -/** @id Autocompleter.Base.prototype.startIndicator */ - startIndicator: function () { - if (this.options.indicator) { - MochiKit.Style.showElement(this.options.indicator); - } - }, - -/** @id Autocompleter.Base.prototype.stopIndicator */ - stopIndicator: function () { - if (this.options.indicator) { - MochiKit.Style.hideElement(this.options.indicator); - } - }, - -/** @id Autocompleter.Base.prototype.onKeyPress */ - onKeyPress: function (event) { - if (this.active) { - if (event.key().string == "KEY_TAB" || event.key().string == "KEY_RETURN") { - this.selectEntry(); - MochiKit.Event.stop(event); - } else if (event.key().string == "KEY_ESCAPE") { - this.hide(); - this.active = false; - MochiKit.Event.stop(event); - return; - } else if (event.key().string == "KEY_LEFT" || event.key().string == "KEY_RIGHT") { - return; - } else if (event.key().string == "KEY_UP") { - this.markPrevious(); - this.render(); - if (/AppleWebKit'/.test(navigator.appVersion)) { - event.stop(); - } - return; - } else if (event.key().string == "KEY_DOWN") { - this.markNext(); - this.render(); - if (/AppleWebKit'/.test(navigator.appVersion)) { - event.stop(); - } - return; - } - } else { - if (event.key().string == "KEY_TAB" || event.key().string == "KEY_RETURN") { - return; - } - } - - this.changed = true; - this.hasFocus = true; - - if (this.observer) { - clearTimeout(this.observer); - } - this.observer = setTimeout(MochiKit.Base.bind(this.onObserverEvent, this), - this.options.frequency*1000); - }, - -/** @id Autocompleter.Base.prototype.findElement */ - findElement: function (event, tagName) { - var element = event.target; - while (element.parentNode && (!element.tagName || - (element.tagName.toUpperCase() != tagName.toUpperCase()))) { - element = element.parentNode; - } - return element; - }, - -/** @id Autocompleter.Base.prototype.hover */ - onHover: function (event) { - var element = this.findElement(event, 'LI'); - if (this.index != element.autocompleteIndex) { - this.index = element.autocompleteIndex; - this.render(); - } - event.stop(); - }, - -/** @id Autocompleter.Base.prototype.onClick */ - onClick: function (event) { - var element = this.findElement(event, 'LI'); - this.index = element.autocompleteIndex; - this.selectEntry(); - this.hide(); - }, - -/** @id Autocompleter.Base.prototype.onBlur */ - onBlur: function (event) { - // needed to make click events working - setTimeout(MochiKit.Base.bind(this.hide, this), 250); - this.hasFocus = false; - this.active = false; - }, - -/** @id Autocompleter.Base.prototype.render */ - render: function () { - if (this.entryCount > 0) { - for (var i = 0; i < this.entryCount; i++) { - this.index == i ? - MochiKit.DOM.addElementClass(this.getEntry(i), 'selected') : - MochiKit.DOM.removeElementClass(this.getEntry(i), 'selected'); - } - if (this.hasFocus) { - this.show(); - this.active = true; - } - } else { - this.active = false; - this.hide(); - } - }, - -/** @id Autocompleter.Base.prototype.markPrevious */ - markPrevious: function () { - if (this.index > 0) { - this.index-- - } else { - this.index = this.entryCount-1; - } - }, - -/** @id Autocompleter.Base.prototype.markNext */ - markNext: function () { - if (this.index < this.entryCount-1) { - this.index++ - } else { - this.index = 0; - } - }, - -/** @id Autocompleter.Base.prototype.getEntry */ - getEntry: function (index) { - return this.update.firstChild.childNodes[index]; - }, - -/** @id Autocompleter.Base.prototype.getCurrentEntry */ - getCurrentEntry: function () { - return this.getEntry(this.index); - }, - -/** @id Autocompleter.Base.prototype.selectEntry */ - selectEntry: function () { - this.active = false; - this.updateElement(this.getCurrentEntry()); - }, - -/** @id Autocompleter.Base.prototype.collectTextNodesIgnoreClass */ - collectTextNodesIgnoreClass: function (element, className) { - return MochiKit.Base.flattenArray(MochiKit.Base.map(function (node) { - if (node.nodeType == 3) { - return node.nodeValue; - } else if (node.hasChildNodes() && !MochiKit.DOM.hasElementClass(node, className)) { - return this.collectTextNodesIgnoreClass(node, className); - } - return ''; - }, MochiKit.DOM.getElement(element).childNodes)).join(''); - }, - -/** @id Autocompleter.Base.prototype.updateElement */ - updateElement: function (selectedElement) { - if (this.options.updateElement) { - this.options.updateElement(selectedElement); - return; - } - var value = ''; - if (this.options.select) { - var nodes = document.getElementsByClassName(this.options.select, selectedElement) || []; - if (nodes.length > 0) { - value = MochiKit.DOM.scrapeText(nodes[0]); - } - } else { - value = this.collectTextNodesIgnoreClass(selectedElement, 'informal'); - } - var lastTokenPos = this.findLastToken(); - if (lastTokenPos != -1) { - var newValue = this.element.value.substr(0, lastTokenPos + 1); - var whitespace = this.element.value.substr(lastTokenPos + 1).match(/^\s+/); - if (whitespace) { - newValue += whitespace[0]; - } - this.element.value = newValue + value; - } else { - this.element.value = value; - } - this.element.focus(); - - if (this.options.afterUpdateElement) { - this.options.afterUpdateElement(this.element, selectedElement); - } - }, - -/** @id Autocompleter.Base.prototype.updateChoices */ - updateChoices: function (choices) { - if (!this.changed && this.hasFocus) { - this.update.innerHTML = choices; - var d = MochiKit.DOM; - d.removeEmptyTextNodes(this.update); - d.removeEmptyTextNodes(this.update.firstChild); - - if (this.update.firstChild && this.update.firstChild.childNodes) { - this.entryCount = this.update.firstChild.childNodes.length; - for (var i = 0; i < this.entryCount; i++) { - var entry = this.getEntry(i); - entry.autocompleteIndex = i; - this.addObservers(entry); - } - } else { - this.entryCount = 0; - } - - this.stopIndicator(); - - this.index = 0; - this.render(); - } - }, - -/** @id Autocompleter.Base.prototype.addObservers */ - addObservers: function (element) { - MochiKit.Signal.connect(element, 'onmouseover', this, this.onHover); - MochiKit.Signal.connect(element, 'onclick', this, this.onClick); - }, - -/** @id Autocompleter.Base.prototype.onObserverEvent */ - onObserverEvent: function () { - this.changed = false; - if (this.getToken().length >= this.options.minChars) { - this.startIndicator(); - this.getUpdatedChoices(); - } else { - this.active = false; - this.hide(); - } - }, - -/** @id Autocompleter.Base.prototype.getToken */ - getToken: function () { - var tokenPos = this.findLastToken(); - if (tokenPos != -1) { - var ret = this.element.value.substr(tokenPos + 1).replace(/^\s+/,'').replace(/\s+$/,''); - } else { - var ret = this.element.value; - } - return /\n/.test(ret) ? '' : ret; - }, - -/** @id Autocompleter.Base.prototype.findLastToken */ - findLastToken: function () { - var lastTokenPos = -1; - - for (var i = 0; i < this.options.tokens.length; i++) { - var thisTokenPos = this.element.value.lastIndexOf(this.options.tokens[i]); - if (thisTokenPos > lastTokenPos) { - lastTokenPos = thisTokenPos; - } - } - return lastTokenPos; - } -} - -/** @id Ajax.Autocompleter */ -Ajax.Autocompleter = function (element, update, url, options) { - this.__init__(element, update, url, options); -}; - -MochiKit.Base.update(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype); - -MochiKit.Base.update(Ajax.Autocompleter.prototype, { - __init__: function (element, update, url, options) { - this.baseInitialize(element, update, options); - this.options.asynchronous = true; - this.options.onComplete = MochiKit.Base.bind(this.onComplete, this); - this.options.defaultParams = this.options.parameters || null; - this.url = url; - }, - -/** @id Ajax.Autocompleter.prototype.getUpdatedChoices */ - getUpdatedChoices: function () { - 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); - }, - -/** @id Ajax.Autocompleter.prototype.onComplete */ - 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. - -***/ - -/** @id Autocompleter.Local */ -Autocompleter.Local = function (element, update, array, options) { - this.__init__(element, update, array, options); -}; - -MochiKit.Base.update(Autocompleter.Local.prototype, Autocompleter.Base.prototype); - -MochiKit.Base.update(Autocompleter.Local.prototype, { - __init__: function (element, update, array, options) { - this.baseInitialize(element, update, options); - this.options.array = array; - }, - -/** @id Autocompleter.Local.prototype.getUpdatedChoices */ - getUpdatedChoices: function () { - this.updateChoices(this.options.selector(this)); - }, - -/** @id Autocompleter.Local.prototype.setOptions */ - setOptions: function (options) { - this.options = MochiKit.Base.update({ - 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('<li><strong>' + elem.substr(0, entry.length) + '</strong>' + - elem.substr(entry.length) + '</li>'); - 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('<li>' + elem.substr(0, foundPos) + '<strong>' + - elem.substr(foundPos, entry.length) + '</strong>' + elem.substr( - foundPos + entry.length) + '</li>'); - 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 '<ul>' + ret.join('') + '</ul>'; - } - }, 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 - -***/ - -/** @id Ajax.InPlaceEditor */ -Ajax.InPlaceEditor = function (element, url, options) { - this.__init__(element, url, options); -}; - -/** @id Ajax.InPlaceEditor.defaultHighlightColor */ -Ajax.InPlaceEditor.defaultHighlightColor = '#FFFF99'; - -Ajax.InPlaceEditor.prototype = { - __init__: function (element, url, options) { - this.url = url; - this.element = MochiKit.DOM.getElement(element); - - this.options = MochiKit.Base.update({ - okButton: true, - okText: 'ok', - cancelLink: true, - cancelText: 'cancel', - savingText: 'Saving...', - clickToEditText: 'Click to edit', - okText: 'ok', - rows: 1, - onComplete: function (transport, element) { - new MochiKit.Visual.Highlight(element, {startcolor: this.options.highlightcolor}); - }, - onFailure: function (transport) { - alert('Error communicating with the server: ' + MochiKit.Base.stripTags(transport.responseText)); - }, - callback: function (form) { - return MochiKit.DOM.formContents(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: {} - }, options || {}); - - if (!this.options.formId && this.element.id) { - this.options.formId = this.element.id + '-inplaceeditor'; - if (MochiKit.DOM.getElement(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 = MochiKit.DOM.getElement(this.options.externalControl); - } - - this.originalBackground = MochiKit.Style.getStyle(this.element, 'background-color'); - if (!this.originalBackground) { - this.originalBackground = 'transparent'; - } - - this.element.title = this.options.clickToEditText; - - this.onclickListener = MochiKit.Signal.connect(this.element, 'onclick', this, this.enterEditMode); - this.mouseoverListener = MochiKit.Signal.connect(this.element, 'onmouseover', this, this.enterHover); - this.mouseoutListener = MochiKit.Signal.connect(this.element, 'onmouseout', this, this.leaveHover); - if (this.options.externalControl) { - this.onclickListenerExternal = MochiKit.Signal.connect(this.options.externalControl, - 'onclick', this, this.enterEditMode); - this.mouseoverListenerExternal = MochiKit.Signal.connect(this.options.externalControl, - 'onmouseover', this, this.enterHover); - this.mouseoutListenerExternal = MochiKit.Signal.connect(this.options.externalControl, - 'onmouseout', this, this.leaveHover); - } - }, - -/** @id Ajax.InPlaceEditor.prototype.enterEditMode */ - enterEditMode: function (evt) { - if (this.saving) { - return; - } - if (this.editing) { - return; - } - this.editing = true; - this.onEnterEditMode(); - if (this.options.externalControl) { - MochiKit.Style.hideElement(this.options.externalControl); - } - MochiKit.Style.hideElement(this.element); - this.createForm(); - this.element.parentNode.insertBefore(this.form, this.element); - Field.scrollFreeActivate(this.editField); - // stop the event to avoid a page refresh in Safari - if (evt) { - evt.stop(); - } - return false; - }, - -/** @id Ajax.InPlaceEditor.prototype.createForm */ - createForm: function () { - this.form = document.createElement('form'); - this.form.id = this.options.formId; - MochiKit.DOM.addElementClass(this.form, this.options.formClassName) - this.form.onsubmit = MochiKit.Base.bind(this.onSubmit, this); - - this.createEditField(); - - if (this.options.textarea) { - var br = document.createElement('br'); - this.form.appendChild(br); - } - - if (this.options.okButton) { - okButton = document.createElement('input'); - okButton.type = 'submit'; - okButton.value = this.options.okText; - this.form.appendChild(okButton); - } - - if (this.options.cancelLink) { - cancelLink = document.createElement('a'); - cancelLink.href = '#'; - cancelLink.appendChild(document.createTextNode(this.options.cancelText)); - cancelLink.onclick = MochiKit.Base.bind(this.onclickCancel, this); - this.form.appendChild(cancelLink); - } - }, - -/** @id Ajax.InPlaceEditor.prototype.hasHTMLLineBreaks */ - hasHTMLLineBreaks: function (string) { - if (!this.options.handleLineBreaks) { - return false; - } - return string.match(/<br/i) || string.match(/<p>/i); - }, - -/** @id Ajax.InPlaceEditor.prototype.convertHTMLLineBreaks */ - convertHTMLLineBreaks: function (string) { - return string.replace(/<br>/gi, '\n').replace(/<br\/>/gi, '\n').replace(/<\/p>/gi, '\n').replace(/<p>/gi, ''); - }, - -/** @id Ajax.InPlaceEditor.prototype.createEditField */ - 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 = 'value'; - textField.value = text; - textField.style.backgroundColor = this.options.highlightcolor; - var size = this.options.size || this.options.cols || 0; - if (size !== 0) { - textField.size = size; - } - if (this.options.submitOnBlur) { - textField.onblur = MochiKit.Base.bind(this.onSubmit, this); - } - this.editField = textField; - } else { - this.options.textarea = true; - var textArea = document.createElement('textarea'); - textArea.obj = this; - textArea.name = 'value'; - textArea.value = this.convertHTMLLineBreaks(text); - textArea.rows = this.options.rows; - textArea.cols = this.options.cols || 40; - if (this.options.submitOnBlur) { - textArea.onblur = MochiKit.Base.bind(this.onSubmit, this); - } - this.editField = textArea; - } - - if (this.options.loadTextURL) { - this.loadExternalText(); - } - this.form.appendChild(this.editField); - }, - -/** @id Ajax.InPlaceEditor.prototype.getText */ - getText: function () { - return this.element.innerHTML; - }, - -/** @id Ajax.InPlaceEditor.prototype.loadExternalText */ - loadExternalText: function () { - MochiKit.DOM.addElementClass(this.form, this.options.loadingClassName); - this.editField.disabled = true; - new Ajax.Request( - this.options.loadTextURL, - MochiKit.Base.update({ - asynchronous: true, - onComplete: MochiKit.Base.bind(this.onLoadedExternalText, this) - }, this.options.ajaxOptions) - ); - }, - -/** @id Ajax.InPlaceEditor.prototype.onLoadedExternalText */ - onLoadedExternalText: function (transport) { - MochiKit.DOM.removeElementClass(this.form, this.options.loadingClassName); - this.editField.disabled = false; - this.editField.value = MochiKit.Base.stripTags(transport); - }, - -/** @id Ajax.InPlaceEditor.prototype.onclickCancel */ - onclickCancel: function () { - this.onComplete(); - this.leaveEditMode(); - return false; - }, - -/** @id Ajax.InPlaceEditor.prototype.onFailure */ - onFailure: function (transport) { - this.options.onFailure(transport); - if (this.oldInnerHTML) { - this.element.innerHTML = this.oldInnerHTML; - this.oldInnerHTML = null; - } - return false; - }, - -/** @id Ajax.InPlaceEditor.prototype.onSubmit */ - 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 have left edit mode causing Saving to be - // displayed indefinitely - this.onLoading(); - - new Ajax.Updater( - { - success: this.element, - // dont update on failure (this could be an option) - failure: null - }, - this.url, - MochiKit.Base.update({ - parameters: this.options.callback(form, value), - onComplete: MochiKit.Base.bind(this.onComplete, this), - onFailure: MochiKit.Base.bind(this.onFailure, this) - }, this.options.ajaxOptions) - ); - // stop the event to avoid a page refresh in Safari - if (arguments.length > 1) { - arguments[0].stop(); - } - return false; - }, - -/** @id Ajax.InPlaceEditor.prototype.onLoading */ - onLoading: function () { - this.saving = true; - this.removeForm(); - this.leaveHover(); - this.showSaving(); - }, - -/** @id Ajax.InPlaceEditor.prototype.onSaving */ - showSaving: function () { - this.oldInnerHTML = this.element.innerHTML; - this.element.innerHTML = this.options.savingText; - MochiKit.DOM.addElementClass(this.element, this.options.savingClassName); - this.element.style.backgroundColor = this.originalBackground; - MochiKit.Style.showElement(this.element); - }, - -/** @id Ajax.InPlaceEditor.prototype.removeForm */ - removeForm: function () { - if (this.form) { - if (this.form.parentNode) { - MochiKit.DOM.removeElement(this.form); - } - this.form = null; - } - }, - -/** @id Ajax.InPlaceEditor.prototype.enterHover */ - enterHover: function () { - if (this.saving) { - return; - } - this.element.style.backgroundColor = this.options.highlightcolor; - if (this.effect) { - this.effect.cancel(); - } - MochiKit.DOM.addElementClass(this.element, this.options.hoverClassName) - }, - -/** @id Ajax.InPlaceEditor.prototype.leaveHover */ - leaveHover: function () { - if (this.options.backgroundColor) { - this.element.style.backgroundColor = this.oldBackground; - } - MochiKit.DOM.removeElementClass(this.element, this.options.hoverClassName) - if (this.saving) { - return; - } - this.effect = new MochiKit.Visual.Highlight(this.element, { - startcolor: this.options.highlightcolor, - endcolor: this.options.highlightendcolor, - restorecolor: this.originalBackground - }); - }, - -/** @id Ajax.InPlaceEditor.prototype.leaveEditMode */ - leaveEditMode: function () { - MochiKit.DOM.removeElementClass(this.element, this.options.savingClassName); - this.removeForm(); - this.leaveHover(); - this.element.style.backgroundColor = this.originalBackground; - MochiKit.Style.showElement(this.element); - if (this.options.externalControl) { - MochiKit.Style.showElement(this.options.externalControl); - } - this.editing = false; - this.saving = false; - this.oldInnerHTML = null; - this.onLeaveEditMode(); - }, - -/** @id Ajax.InPlaceEditor.prototype.onComplete */ - onComplete: function (transport) { - this.leaveEditMode(); - MochiKit.Base.bind(this.options.onComplete, this)(transport, this.element); - }, - -/** @id Ajax.InPlaceEditor.prototype.onEnterEditMode */ - onEnterEditMode: function () {}, - -/** @id Ajax.InPlaceEditor.prototype.onLeaveEditMode */ - onLeaveEditMode: function () {}, - - /** @id Ajax.InPlaceEditor.prototype.dispose */ - dispose: function () { - if (this.oldInnerHTML) { - this.element.innerHTML = this.oldInnerHTML; - } - this.leaveEditMode(); - MochiKit.Signal.disconnect(this.onclickListener); - MochiKit.Signal.disconnect(this.mouseoverListener); - MochiKit.Signal.disconnect(this.mouseoutListener); - if (this.options.externalControl) { - MochiKit.Signal.disconnect(this.onclickListenerExternal); - MochiKit.Signal.disconnect(this.mouseoverListenerExternal); - MochiKit.Signal.disconnect(this.mouseoutListenerExternal); - } - } -}; - diff --git a/javascript/libs/MochiKit/DOM.js b/javascript/libs/MochiKit/DOM.js deleted file mode 100644 index 550d3ff..0000000 --- a/javascript/libs/MochiKit/DOM.js +++ /dev/null @@ -1,1290 +0,0 @@ -/*** - -MochiKit.DOM 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005 Bob Ippolito. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide("MochiKit.DOM"); - dojo.require("MochiKit.Base"); -} -if (typeof(JSAN) != 'undefined') { - JSAN.use("MochiKit.Base", []); -} - -try { - if (typeof(MochiKit.Base) == 'undefined') { - throw ""; - } -} catch (e) { - throw "MochiKit.DOM depends on MochiKit.Base!"; -} - -if (typeof(MochiKit.DOM) == 'undefined') { - MochiKit.DOM = {}; -} - -MochiKit.DOM.NAME = "MochiKit.DOM"; -MochiKit.DOM.VERSION = "1.4"; -MochiKit.DOM.__repr__ = function () { - return "[" + this.NAME + " " + this.VERSION + "]"; -}; -MochiKit.DOM.toString = function () { - return this.__repr__(); -}; - -MochiKit.DOM.EXPORT = [ - "removeEmptyTextNodes", - "formContents", - "currentWindow", - "currentDocument", - "withWindow", - "withDocument", - "registerDOMConverter", - "coerceToDOM", - "createDOM", - "createDOMFunc", - "isChildNode", - "getNodeAttribute", - "removeNodeAttribute", - "setNodeAttribute", - "updateNodeAttributes", - "appendChildNodes", - "insertSiblingNodesAfter", - "insertSiblingNodesBefore", - "replaceChildNodes", - "removeElement", - "swapDOM", - "BUTTON", - "TT", - "PRE", - "H1", - "H2", - "H3", - "BR", - "CANVAS", - "HR", - "LABEL", - "TEXTAREA", - "FORM", - "STRONG", - "SELECT", - "OPTION", - "OPTGROUP", - "LEGEND", - "FIELDSET", - "P", - "UL", - "OL", - "LI", - "DL", - "DT", - "DD", - "TD", - "TR", - "THEAD", - "TBODY", - "TFOOT", - "TABLE", - "TH", - "INPUT", - "SPAN", - "A", - "DIV", - "IMG", - "getElement", - "$", - "getElementsByTagAndClassName", - "addToCallStack", - "addLoadEvent", - "focusOnLoad", - "setElementClass", - "toggleElementClass", - "addElementClass", - "removeElementClass", - "swapElementClass", - "hasElementClass", - "escapeHTML", - "toHTML", - "emitHTML", - "scrapeText", - "isParent", - "getFirstParentByTagAndClassName", - "makeClipping", - "undoClipping", - "makePositioned", - "undoPositioned", - "getFirstElementByTagAndClassName" -]; - -MochiKit.DOM.EXPORT_OK = [ - "domConverters" -]; - -MochiKit.DOM.DEPRECATED = [ - ['computedStyle', 'MochiKit.Style.getStyle', '1.4'], - /** @id MochiKit.DOM.elementDimensions */ - ['elementDimensions', 'MochiKit.Style.getElementDimensions', '1.4'], - /** @id MochiKit.DOM.elementPosition */ - ['elementPosition', 'MochiKit.Style.getElementPosition', '1.4'], - ['hideElement', 'MochiKit.Style.hideElement', '1.4'], - /** @id MochiKit.DOM.setElementDimensions */ - ['setElementDimensions', 'MochiKit.Style.setElementDimensions', '1.4'], - /** @id MochiKit.DOM.setElementPosition */ - ['setElementPosition', 'MochiKit.Style.setElementPosition', '1.4'], - ['setDisplayForElement', 'MochiKit.Style.setDisplayForElement', '1.4'], - /** @id MochiKit.DOM.setOpacity */ - ['setOpacity', 'MochiKit.Style.setOpacity', '1.4'], - ['showElement', 'MochiKit.Style.showElement', '1.4'], - /** @id MochiKit.DOM.Coordinates */ - ['Coordinates', 'MochiKit.Style.Coordinates', '1.4'], // FIXME: broken - /** @id MochiKit.DOM.Dimensions */ - ['Dimensions', 'MochiKit.Style.Dimensions', '1.4'] // FIXME: broken -]; - -/** @id MochiKit.DOM.getViewportDimensions */ -MochiKit.DOM.getViewportDimensions = new Function('' + - 'if (!MochiKit["Style"]) {' + - ' throw new Error("This function has been deprecated and depends on MochiKit.Style.");' + - '}' + - 'return MochiKit.Style.getViewportDimensions.apply(this, arguments);'); - -MochiKit.Base.update(MochiKit.DOM, { - - /** @id MochiKit.DOM.currentWindow */ - currentWindow: function () { - return MochiKit.DOM._window; - }, - - /** @id MochiKit.DOM.currentDocument */ - currentDocument: function () { - return MochiKit.DOM._document; - }, - - /** @id MochiKit.DOM.withWindow */ - withWindow: function (win, func) { - var self = MochiKit.DOM; - var oldDoc = self._document; - var oldWin = self._window; - var rval; - try { - self._window = win; - self._document = win.document; - rval = func(); - } catch (e) { - self._window = oldWin; - self._document = oldDoc; - throw e; - } - self._window = oldWin; - self._document = oldDoc; - return rval; - }, - - /** @id MochiKit.DOM.formContents */ - formContents: function (elem/* = document.body */) { - var names = []; - var values = []; - var m = MochiKit.Base; - var self = MochiKit.DOM; - if (typeof(elem) == "undefined" || elem === null) { - elem = self._document.body; - } else { - elem = self.getElement(elem); - } - m.nodeWalk(elem, function (elem) { - var name = elem.name; - if (m.isNotEmpty(name)) { - var tagName = elem.tagName.toUpperCase(); - if (tagName === "INPUT" - && (elem.type == "radio" || elem.type == "checkbox") - && !elem.checked - ) { - return null; - } - if (tagName === "SELECT") { - if (elem.type == "select-one") { - if (elem.selectedIndex >= 0) { - var opt = elem.options[elem.selectedIndex]; - var v = opt.value; - if (!v) { - var h = opt.outerHTML; - // internet explorer sure does suck. - if (h && !h.match(/^[^>]+\svalue\s*=/i)) { - v = opt.text; - } - } - names.push(name); - values.push(v); - return null; - } - // no form elements? - names.push(name); - values.push(""); - return null; - } else { - var opts = elem.options; - if (!opts.length) { - names.push(name); - values.push(""); - return null; - } - for (var i = 0; i < opts.length; i++) { - var opt = opts[i]; - if (!opt.selected) { - continue; - } - var v = opt.value; - if (!v) { - var h = opt.outerHTML; - // internet explorer sure does suck. - if (h && !h.match(/^[^>]+\svalue\s*=/i)) { - v = opt.text; - } - } - names.push(name); - values.push(v); - } - return null; - } - } - if (tagName === "FORM" || tagName === "P" || tagName === "SPAN" - || tagName === "DIV" - ) { - return elem.childNodes; - } - names.push(name); - values.push(elem.value || ''); - return null; - } - return elem.childNodes; - }); - return [names, values]; - }, - - /** @id MochiKit.DOM.withDocument */ - withDocument: function (doc, func) { - var self = MochiKit.DOM; - var oldDoc = self._document; - var rval; - try { - self._document = doc; - rval = func(); - } catch (e) { - self._document = oldDoc; - throw e; - } - self._document = oldDoc; - return rval; - }, - - /** @id MochiKit.DOM.registerDOMConverter */ - registerDOMConverter: function (name, check, wrap, /* optional */override) { - MochiKit.DOM.domConverters.register(name, check, wrap, override); - }, - - /** @id MochiKit.DOM.coerceToDOM */ - coerceToDOM: function (node, ctx) { - var m = MochiKit.Base; - var im = MochiKit.Iter; - var self = MochiKit.DOM; - if (im) { - var iter = im.iter; - var repeat = im.repeat; - var map = m.map; - } - var domConverters = self.domConverters; - var coerceToDOM = arguments.callee; - var NotFound = m.NotFound; - while (true) { - if (typeof(node) == 'undefined' || node === null) { - return null; - } - // this is a safari childNodes object, avoiding crashes w/ attr - // lookup - if (typeof(node) == "function" && - typeof(node.length) == "number" && - !(node instanceof Function)) { - node = im.list(node); - } - if (typeof(node.nodeType) != 'undefined' && node.nodeType > 0) { - return node; - } - if (typeof(node) == 'number' || typeof(node) == 'boolean') { - node = node.toString(); - // FALL THROUGH - } - if (typeof(node) == 'string') { - return self._document.createTextNode(node); - } - if (typeof(node.__dom__) == 'function') { - node = node.__dom__(ctx); - continue; - } - if (typeof(node.dom) == 'function') { - node = node.dom(ctx); - continue; - } - if (typeof(node) == 'function') { - node = node.apply(ctx, [ctx]); - continue; - } - - if (im) { - // iterable - var iterNodes = null; - try { - iterNodes = iter(node); - } catch (e) { - // pass - } - if (iterNodes) { - return map(coerceToDOM, iterNodes, repeat(ctx)); - } - } - - // adapter - try { - node = domConverters.match(node, ctx); - continue; - } catch (e) { - if (e != NotFound) { - throw e; - } - } - - // fallback - return self._document.createTextNode(node.toString()); - } - // mozilla warnings aren't too bright - return undefined; - }, - - /** @id MochiKit.DOM.isChildNode */ - isChildNode: function (node, maybeparent) { - var self = MochiKit.DOM; - if (typeof(node) == "string") { - node = self.getElement(node); - } - if (typeof(maybeparent) == "string") { - maybeparent = self.getElement(maybeparent); - } - if (typeof(node) == 'undefined' || node === null || node === self._document) { - return false; - } - do { - if (node === maybeparent) { - return true; - } - var tagName = node.tagName; - node = node.parentNode; - if (!tagName) { - break; - } - tagName = tagName.toUpperCase(); - } while (tagName != "BODY" && tagName != "HTML"); - return false; - }, - - /** @id MochiKit.DOM.setNodeAttribute */ - setNodeAttribute: function (node, attr, value) { - var o = {}; - o[attr] = value; - try { - return MochiKit.DOM.updateNodeAttributes(node, o); - } catch (e) { - // pass - } - return null; - }, - - /** @id MochiKit.DOM.getNodeAttribute */ - getNodeAttribute: function (node, attr) { - var self = MochiKit.DOM; - var rename = self.attributeArray.renames[attr]; - node = self.getElement(node); - try { - if (rename) { - return node[rename]; - } - return node.getAttribute(attr); - } catch (e) { - // pass - } - return null; - }, - - /** @id MochiKit.DOM.removeNodeAttribute */ - removeNodeAttribute: function (node, attr) { - var self = MochiKit.DOM; - var rename = self.attributeArray.renames[attr]; - node = self.getElement(node); - try { - if (rename) { - return node[rename]; - } - return node.removeAttribute(attr); - } catch (e) { - // pass - } - return null; - }, - - /** @id MochiKit.DOM.updateNodeAttributes */ - updateNodeAttributes: function (node, attrs) { - var elem = node; - var self = MochiKit.DOM; - if (typeof(node) == 'string') { - elem = self.getElement(node); - } - if (attrs) { - var updatetree = MochiKit.Base.updatetree; - if (self.attributeArray.compliant) { - // not IE, good. - for (var k in attrs) { - var v = attrs[k]; - if (typeof(v) == 'object' && typeof(elem[k]) == 'object') { - if (k == "style" && MochiKit.Style) { - MochiKit.Style.setStyle(elem, v); - } else { - updatetree(elem[k], v); - } - } else if (k.substring(0, 2) == "on") { - if (typeof(v) == "string") { - v = new Function(v); - } - elem[k] = v; - } else { - elem.setAttribute(k, v); - } - } - } else { - // IE is insane in the membrane - var renames = self.attributeArray.renames; - for (var k in attrs) { - v = attrs[k]; - var renamed = renames[k]; - if (k == "style" && typeof(v) == "string") { - elem.style.cssText = v; - } else if (typeof(renamed) == "string") { - elem[renamed] = v; - } else if (typeof(elem[k]) == 'object' - && typeof(v) == 'object') { - if (k == "style" && MochiKit.Style) { - MochiKit.Style.setStyle(elem, v); - } else { - updatetree(elem[k], v); - } - } else if (k.substring(0, 2) == "on") { - if (typeof(v) == "string") { - v = new Function(v); - } - elem[k] = v; - } else { - elem.setAttribute(k, v); - } - } - } - } - return elem; - }, - - /** @id MochiKit.DOM.appendChildNodes */ - appendChildNodes: function (node/*, nodes...*/) { - var elem = node; - var self = MochiKit.DOM; - if (typeof(node) == 'string') { - elem = self.getElement(node); - } - var nodeStack = [ - self.coerceToDOM( - MochiKit.Base.extend(null, arguments, 1), - elem - ) - ]; - var concat = MochiKit.Base.concat; - while (nodeStack.length) { - var n = nodeStack.shift(); - if (typeof(n) == 'undefined' || n === null) { - // pass - } else if (typeof(n.nodeType) == 'number') { - elem.appendChild(n); - } else { - nodeStack = concat(n, nodeStack); - } - } - return elem; - }, - - - /** @id MochiKit.DOM.insertSiblingNodesBefore */ - insertSiblingNodesBefore: function (node/*, nodes...*/) { - var elem = node; - var self = MochiKit.DOM; - if (typeof(node) == 'string') { - elem = self.getElement(node); - } - var nodeStack = [ - self.coerceToDOM( - MochiKit.Base.extend(null, arguments, 1), - elem - ) - ]; - var parentnode = elem.parentNode; - var concat = MochiKit.Base.concat; - while (nodeStack.length) { - var n = nodeStack.shift(); - if (typeof(n) == 'undefined' || n === null) { - // pass - } else if (typeof(n.nodeType) == 'number') { - parentnode.insertBefore(n, elem); - } else { - nodeStack = concat(n, nodeStack); - } - } - return parentnode; - }, - - /** @id MochiKit.DOM.insertSiblingNodesAfter */ - insertSiblingNodesAfter: function (node/*, nodes...*/) { - var elem = node; - var self = MochiKit.DOM; - - if (typeof(node) == 'string') { - elem = self.getElement(node); - } - var nodeStack = [ - self.coerceToDOM( - MochiKit.Base.extend(null, arguments, 1), - elem - ) - ]; - - if (elem.nextSibling) { - return self.insertSiblingNodesBefore(elem.nextSibling, nodeStack); - } - else { - return self.appendChildNodes(elem.parentNode, nodeStack); - } - }, - - /** @id MochiKit.DOM.replaceChildNodes */ - replaceChildNodes: function (node/*, nodes...*/) { - var elem = node; - var self = MochiKit.DOM; - if (typeof(node) == 'string') { - elem = self.getElement(node); - arguments[0] = elem; - } - var child; - while ((child = elem.firstChild)) { - elem.removeChild(child); - } - if (arguments.length < 2) { - return elem; - } else { - return self.appendChildNodes.apply(this, arguments); - } - }, - - /** @id MochiKit.DOM.createDOM */ - createDOM: function (name, attrs/*, nodes... */) { - var elem; - var self = MochiKit.DOM; - var m = MochiKit.Base; - if (typeof(attrs) == "string" || typeof(attrs) == "number") { - var args = m.extend([name, null], arguments, 1); - return arguments.callee.apply(this, args); - } - if (typeof(name) == 'string') { - // Internet Explorer is dumb - var xhtml = self._xhtml; - if (attrs && !self.attributeArray.compliant) { - // http://msdn.microsoft.com/workshop/author/dhtml/reference/properties/name_2.asp - var contents = ""; - if ('name' in attrs) { - contents += ' name="' + self.escapeHTML(attrs.name) + '"'; - } - if (name == 'input' && 'type' in attrs) { - contents += ' type="' + self.escapeHTML(attrs.type) + '"'; - } - if (contents) { - name = "<" + name + contents + ">"; - xhtml = false; - } - } - var d = self._document; - if (xhtml && d === document) { - elem = d.createElementNS("http://www.w3.org/1999/xhtml", name); - } else { - elem = d.createElement(name); - } - } else { - elem = name; - } - if (attrs) { - self.updateNodeAttributes(elem, attrs); - } - if (arguments.length <= 2) { - return elem; - } else { - var args = m.extend([elem], arguments, 2); - return self.appendChildNodes.apply(this, args); - } - }, - - /** @id MochiKit.DOM.createDOMFunc */ - createDOMFunc: function (/* tag, attrs, *nodes */) { - var m = MochiKit.Base; - return m.partial.apply( - this, - m.extend([MochiKit.DOM.createDOM], arguments) - ); - }, - - /** @id MochiKit.DOM.removeElement */ - removeElement: function (elem) { - var e = MochiKit.DOM.getElement(elem); - e.parentNode.removeChild(e); - return e; - }, - - /** @id MochiKit.DOM.swapDOM */ - swapDOM: function (dest, src) { - var self = MochiKit.DOM; - dest = self.getElement(dest); - var parent = dest.parentNode; - if (src) { - src = self.getElement(src); - parent.replaceChild(src, dest); - } else { - parent.removeChild(dest); - } - return src; - }, - - /** @id MochiKit.DOM.getElement */ - getElement: function (id) { - var self = MochiKit.DOM; - if (arguments.length == 1) { - return ((typeof(id) == "string") ? - self._document.getElementById(id) : id); - } else { - return MochiKit.Base.map(self.getElement, arguments); - } - }, - - /** @id MochiKit.DOM.getElementsByTagAndClassName */ - getElementsByTagAndClassName: function (tagName, className, - /* optional */parent) { - var self = MochiKit.DOM; - if (typeof(tagName) == 'undefined' || tagName === null) { - tagName = '*'; - } - if (typeof(parent) == 'undefined' || parent === null) { - parent = self._document; - } - parent = self.getElement(parent); - var children = (parent.getElementsByTagName(tagName) - || self._document.all); - if (typeof(className) == 'undefined' || className === null) { - return MochiKit.Base.extend(null, children); - } - - var elements = []; - for (var i = 0; i < children.length; i++) { - var child = children[i]; - var cls = child.className; - if (!cls) { - continue; - } - var classNames = cls.split(' '); - for (var j = 0; j < classNames.length; j++) { - if (classNames[j] == className) { - elements.push(child); - break; - } - } - } - - return elements; - }, - - _newCallStack: function (path, once) { - var rval = function () { - var callStack = arguments.callee.callStack; - for (var i = 0; i < callStack.length; i++) { - if (callStack[i].apply(this, arguments) === false) { - break; - } - } - if (once) { - try { - this[path] = null; - } catch (e) { - // pass - } - } - }; - rval.callStack = []; - return rval; - }, - - /** @id MochiKit.DOM.addToCallStack */ - addToCallStack: function (target, path, func, once) { - var self = MochiKit.DOM; - var existing = target[path]; - var regfunc = existing; - if (!(typeof(existing) == 'function' - && typeof(existing.callStack) == "object" - && existing.callStack !== null)) { - regfunc = self._newCallStack(path, once); - if (typeof(existing) == 'function') { - regfunc.callStack.push(existing); - } - target[path] = regfunc; - } - regfunc.callStack.push(func); - }, - - /** @id MochiKit.DOM.addLoadEvent */ - addLoadEvent: function (func) { - var self = MochiKit.DOM; - self.addToCallStack(self._window, "onload", func, true); - - }, - - /** @id MochiKit.DOM.focusOnLoad */ - focusOnLoad: function (element) { - var self = MochiKit.DOM; - self.addLoadEvent(function () { - element = self.getElement(element); - if (element) { - element.focus(); - } - }); - }, - - /** @id MochiKit.DOM.setElementClass */ - setElementClass: function (element, className) { - var self = MochiKit.DOM; - var obj = self.getElement(element); - if (self.attributeArray.compliant) { - obj.setAttribute("class", className); - } else { - obj.setAttribute("className", className); - } - }, - - /** @id MochiKit.DOM.toggleElementClass */ - toggleElementClass: function (className/*, element... */) { - var self = MochiKit.DOM; - for (var i = 1; i < arguments.length; i++) { - var obj = self.getElement(arguments[i]); - if (!self.addElementClass(obj, className)) { - self.removeElementClass(obj, className); - } - } - }, - - /** @id MochiKit.DOM.addElementClass */ - addElementClass: function (element, className) { - var self = MochiKit.DOM; - var obj = self.getElement(element); - var cls = obj.className; - // trivial case, no className yet - if (cls == undefined || cls.length === 0) { - self.setElementClass(obj, className); - return true; - } - // the other trivial case, already set as the only class - if (cls == className) { - return false; - } - var classes = cls.split(" "); - for (var i = 0; i < classes.length; i++) { - // already present - if (classes[i] == className) { - return false; - } - } - // append class - self.setElementClass(obj, cls + " " + className); - return true; - }, - - /** @id MochiKit.DOM.removeElementClass */ - removeElementClass: function (element, className) { - var self = MochiKit.DOM; - var obj = self.getElement(element); - var cls = obj.className; - // trivial case, no className yet - if (cls == undefined || cls.length === 0) { - return false; - } - // other trivial case, set only to className - if (cls == className) { - self.setElementClass(obj, ""); - return true; - } - var classes = cls.split(" "); - for (var i = 0; i < classes.length; i++) { - // already present - if (classes[i] == className) { - // only check sane case where the class is used once - classes.splice(i, 1); - self.setElementClass(obj, classes.join(" ")); - return true; - } - } - // not found - return false; - }, - - /** @id MochiKit.DOM.swapElementClass */ - swapElementClass: function (element, fromClass, toClass) { - var obj = MochiKit.DOM.getElement(element); - var res = MochiKit.DOM.removeElementClass(obj, fromClass); - if (res) { - MochiKit.DOM.addElementClass(obj, toClass); - } - return res; - }, - - /** @id MochiKit.DOM.hasElementClass */ - hasElementClass: function (element, className/*...*/) { - var obj = MochiKit.DOM.getElement(element); - var cls = obj.className; - if (!cls) { - return false; - } - var classes = cls.split(" "); - for (var i = 1; i < arguments.length; i++) { - var good = false; - for (var j = 0; j < classes.length; j++) { - if (classes[j] == arguments[i]) { - good = true; - break; - } - } - if (!good) { - return false; - } - } - return true; - }, - - /** @id MochiKit.DOM.escapeHTML */ - escapeHTML: function (s) { - return s.replace(/&/g, "&" - ).replace(/"/g, """ - ).replace(/</g, "<" - ).replace(/>/g, ">"); - }, - - /** @id MochiKit.DOM.toHTML */ - toHTML: function (dom) { - return MochiKit.DOM.emitHTML(dom).join(""); - }, - - /** @id MochiKit.DOM.emitHTML */ - emitHTML: function (dom, /* optional */lst) { - if (typeof(lst) == 'undefined' || lst === null) { - lst = []; - } - // queue is the call stack, we're doing this non-recursively - var queue = [dom]; - var self = MochiKit.DOM; - var escapeHTML = self.escapeHTML; - var attributeArray = self.attributeArray; - while (queue.length) { - dom = queue.pop(); - if (typeof(dom) == 'string') { - lst.push(dom); - } else if (dom.nodeType == 1) { - // we're not using higher order stuff here - // because safari has heisenbugs.. argh. - // - // I think it might have something to do with - // garbage collection and function calls. - lst.push('<' + dom.tagName.toLowerCase()); - var attributes = []; - var domAttr = attributeArray(dom); - for (var i = 0; i < domAttr.length; i++) { - var a = domAttr[i]; - attributes.push([ - " ", - a.name, - '="', - escapeHTML(a.value), - '"' - ]); - } - attributes.sort(); - for (i = 0; i < attributes.length; i++) { - var attrs = attributes[i]; - for (var j = 0; j < attrs.length; j++) { - lst.push(attrs[j]); - } - } - if (dom.hasChildNodes()) { - lst.push(">"); - // queue is the FILO call stack, so we put the close tag - // on first - queue.push("</" + dom.tagName.toLowerCase() + ">"); - var cnodes = dom.childNodes; - for (i = cnodes.length - 1; i >= 0; i--) { - queue.push(cnodes[i]); - } - } else { - lst.push('/>'); - } - } else if (dom.nodeType == 3) { - lst.push(escapeHTML(dom.nodeValue)); - } - } - return lst; - }, - - /** @id MochiKit.DOM.scrapeText */ - scrapeText: function (node, /* optional */asArray) { - var rval = []; - (function (node) { - var cn = node.childNodes; - if (cn) { - for (var i = 0; i < cn.length; i++) { - arguments.callee.call(this, cn[i]); - } - } - var nodeValue = node.nodeValue; - if (typeof(nodeValue) == 'string') { - rval.push(nodeValue); - } - })(MochiKit.DOM.getElement(node)); - if (asArray) { - return rval; - } else { - return rval.join(""); - } - }, - - /** @id MochiKit.DOM.removeEmptyTextNodes */ - removeEmptyTextNodes: function (element) { - element = MochiKit.DOM.getElement(element); - for (var i = 0; i < element.childNodes.length; i++) { - var node = element.childNodes[i]; - if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) { - node.parentNode.removeChild(node); - } - } - }, - - /** @id MochiKit.DOM.makeClipping */ - makeClipping: function (element) { - element = MochiKit.DOM.getElement(element); - var oldOverflow = element.style.overflow; - if ((MochiKit.Style.getStyle(element, 'overflow') || 'visible') != 'hidden') { - element.style.overflow = 'hidden'; - } - return oldOverflow; - }, - - /** @id MochiKit.DOM.undoClipping */ - undoClipping: function (element, overflow) { - element = MochiKit.DOM.getElement(element); - if (!overflow) { - return; - } - element.style.overflow = overflow; - }, - - /** @id MochiKit.DOM.makePositioned */ - makePositioned: function (element) { - element = MochiKit.DOM.getElement(element); - var pos = MochiKit.Style.getStyle(element, 'position'); - if (pos == 'static' || !pos) { - element.style.position = 'relative'; - // Opera returns the offset relative to the positioning context, - // when an element is position relative but top and left have - // not been defined - if (/Opera/.test(navigator.userAgent)) { - element.style.top = 0; - element.style.left = 0; - } - } - }, - - /** @id MochiKit.DOM.undoPositioned */ - undoPositioned: function (element) { - element = MochiKit.DOM.getElement(element); - if (element.style.position == 'relative') { - element.style.position = element.style.top = element.style.left = element.style.bottom = element.style.right = ''; - } - }, - - /** @id MochiKit.DOM.getFirstElementByTagAndClassName */ - getFirstElementByTagAndClassName: function (tagName, className, - /* optional */parent) { - var self = MochiKit.DOM; - if (typeof(tagName) == 'undefined' || tagName === null) { - tagName = '*'; - } - if (typeof(parent) == 'undefined' || parent === null) { - parent = self._document; - } - parent = self.getElement(parent); - var children = (parent.getElementsByTagName(tagName) - || self._document.all); - if (typeof(className) == 'undefined' || className === null) { - return children[0]; - } - - 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) { - return child; - } - } - } - }, - - /** @id MochiKit.DOM.getFirstParentByTagAndClassName */ - getFirstParentByTagAndClassName: function (elem, tagName, className) { - var self = MochiKit.DOM; - elem = self.getElement(elem); - if (typeof(tagName) == 'undefined' || tagName === null) { - tagName = '*'; - } else { - tagName = tagName.toUpperCase(); - } - if (typeof(className) == 'undefined' || className === null) { - className = null; - } - - var classList = ''; - var curTagName = ''; - while (elem && elem.tagName) { - elem = elem.parentNode; - if (tagName == '*' && className === null) { - return elem; - } - classList = elem.className.split(' '); - curTagName = elem.tagName.toUpperCase(); - if (className === null && tagName == curTagName) { - return elem; - } else if (className !== null) { - for (var i = 0; i < classList.length; i++) { - if (tagName == '*' && classList[i] == className) { - return elem; - } else if (tagName == curTagName && classList[i] == className) { - return elem; - } - } - } - } - return elem; - }, - - /** @id MochiKit.DOM.isParent */ - isParent: function (child, element) { - if (!child.parentNode || child == element) { - return false; - } - - if (child.parentNode == element) { - return true; - } - - return MochiKit.DOM.isParent(child.parentNode, element); - }, - - __new__: function (win) { - - var m = MochiKit.Base; - if (typeof(document) != "undefined") { - this._document = document; - var kXULNSURI = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - this._xhtml = (document.documentElement && - document.createElementNS && - document.documentElement.namespaceURI === kXULNSURI); - } else if (MochiKit.MockDOM) { - this._document = MochiKit.MockDOM.document; - } - this._window = win; - - this.domConverters = new m.AdapterRegistry(); - - var __tmpElement = this._document.createElement("span"); - var attributeArray; - if (__tmpElement && __tmpElement.attributes && - __tmpElement.attributes.length > 0) { - // for braindead browsers (IE) that insert extra junk - var filter = m.filter; - attributeArray = function (node) { - return filter(attributeArray.ignoreAttrFilter, node.attributes); - }; - attributeArray.ignoreAttr = {}; - var attrs = __tmpElement.attributes; - var ignoreAttr = attributeArray.ignoreAttr; - for (var i = 0; i < attrs.length; i++) { - var a = attrs[i]; - ignoreAttr[a.name] = a.value; - } - attributeArray.ignoreAttrFilter = function (a) { - return (attributeArray.ignoreAttr[a.name] != a.value); - }; - attributeArray.compliant = false; - attributeArray.renames = { - "class": "className", - "checked": "defaultChecked", - "usemap": "useMap", - "for": "htmlFor", - "readonly": "readOnly", - "colspan": "colSpan", - "bgcolor": "bgColor", - "cellspacing": "cellSpacing", - "cellpadding": "cellPadding" - }; - } else { - attributeArray = function (node) { - /*** - - Return an array of attributes for a given node, - filtering out attributes that don't belong for - that are inserted by "Certain Browsers". - - ***/ - return node.attributes; - }; - attributeArray.compliant = true; - attributeArray.renames = {}; - } - this.attributeArray = attributeArray; - - // FIXME: this really belongs in Base, and could probably be cleaner - var _deprecated = function(fromModule, arr) { - var modules = arr[1].split('.'); - var str = ''; - var obj = {}; - - str += 'if (!MochiKit.' + modules[1] + ') { throw new Error("'; - str += 'This function has been deprecated and depends on MochiKit.'; - str += modules[1] + '.");}'; - str += 'return MochiKit.' + modules[1] + '.' + arr[0]; - str += '.apply(this, arguments);'; - - obj[modules[2]] = new Function(str); - MochiKit.Base.update(MochiKit[fromModule], obj); - } - for (var i; i < MochiKit.DOM.DEPRECATED.length; i++) { - _deprecated('DOM', MochiKit.DOM.DEPRECATED[i]); - } - - // shorthand for createDOM syntax - var createDOMFunc = this.createDOMFunc; - /** @id MochiKit.DOM.UL */ - this.UL = createDOMFunc("ul"); - /** @id MochiKit.DOM.OL */ - this.OL = createDOMFunc("ol"); - /** @id MochiKit.DOM.LI */ - this.LI = createDOMFunc("li"); - /** @id MochiKit.DOM.DL */ - this.DL = createDOMFunc("dl"); - /** @id MochiKit.DOM.DT */ - this.DT = createDOMFunc("dt"); - /** @id MochiKit.DOM.DD */ - this.DD = createDOMFunc("dd"); - /** @id MochiKit.DOM.TD */ - this.TD = createDOMFunc("td"); - /** @id MochiKit.DOM.TR */ - this.TR = createDOMFunc("tr"); - /** @id MochiKit.DOM.TBODY */ - this.TBODY = createDOMFunc("tbody"); - /** @id MochiKit.DOM.THEAD */ - this.THEAD = createDOMFunc("thead"); - /** @id MochiKit.DOM.TFOOT */ - this.TFOOT = createDOMFunc("tfoot"); - /** @id MochiKit.DOM.TABLE */ - this.TABLE = createDOMFunc("table"); - /** @id MochiKit.DOM.TH */ - this.TH = createDOMFunc("th"); - /** @id MochiKit.DOM.INPUT */ - this.INPUT = createDOMFunc("input"); - /** @id MochiKit.DOM.SPAN */ - this.SPAN = createDOMFunc("span"); - /** @id MochiKit.DOM.A */ - this.A = createDOMFunc("a"); - /** @id MochiKit.DOM.DIV */ - this.DIV = createDOMFunc("div"); - /** @id MochiKit.DOM.IMG */ - this.IMG = createDOMFunc("img"); - /** @id MochiKit.DOM.BUTTON */ - this.BUTTON = createDOMFunc("button"); - /** @id MochiKit.DOM.TT */ - this.TT = createDOMFunc("tt"); - /** @id MochiKit.DOM.PRE */ - this.PRE = createDOMFunc("pre"); - /** @id MochiKit.DOM.H1 */ - this.H1 = createDOMFunc("h1"); - /** @id MochiKit.DOM.H2 */ - this.H2 = createDOMFunc("h2"); - /** @id MochiKit.DOM.H3 */ - this.H3 = createDOMFunc("h3"); - /** @id MochiKit.DOM.BR */ - this.BR = createDOMFunc("br"); - /** @id MochiKit.DOM.HR */ - this.HR = createDOMFunc("hr"); - /** @id MochiKit.DOM.LABEL */ - this.LABEL = createDOMFunc("label"); - /** @id MochiKit.DOM.TEXTAREA */ - this.TEXTAREA = createDOMFunc("textarea"); - /** @id MochiKit.DOM.FORM */ - this.FORM = createDOMFunc("form"); - /** @id MochiKit.DOM.P */ - this.P = createDOMFunc("p"); - /** @id MochiKit.DOM.SELECT */ - this.SELECT = createDOMFunc("select"); - /** @id MochiKit.DOM.OPTION */ - this.OPTION = createDOMFunc("option"); - /** @id MochiKit.DOM.OPTGROUP */ - this.OPTGROUP = createDOMFunc("optgroup"); - /** @id MochiKit.DOM.LEGEND */ - this.LEGEND = createDOMFunc("legend"); - /** @id MochiKit.DOM.FIELDSET */ - this.FIELDSET = createDOMFunc("fieldset"); - /** @id MochiKit.DOM.STRONG */ - this.STRONG = createDOMFunc("strong"); - /** @id MochiKit.DOM.CANVAS */ - this.CANVAS = createDOMFunc("canvas"); - - /** @id MochiKit.DOM.$ */ - this.$ = this.getElement; - - this.EXPORT_TAGS = { - ":common": this.EXPORT, - ":all": m.concat(this.EXPORT, this.EXPORT_OK) - }; - - m.nameFunctions(this); - - } -}); - - -MochiKit.DOM.__new__(((typeof(window) == "undefined") ? this : window)); - -// -// XXX: Internet Explorer blows -// -if (MochiKit.__export__) { - withWindow = MochiKit.DOM.withWindow; - withDocument = MochiKit.DOM.withDocument; -} - -MochiKit.Base._exportSymbols(this, MochiKit.DOM); diff --git a/javascript/libs/MochiKit/DateTime.js b/javascript/libs/MochiKit/DateTime.js deleted file mode 100644 index c0b03ee..0000000 --- a/javascript/libs/MochiKit/DateTime.js +++ /dev/null @@ -1,216 +0,0 @@ -/*** - -MochiKit.DateTime 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005 Bob Ippolito. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.DateTime'); -} - -if (typeof(MochiKit) == 'undefined') { - MochiKit = {}; -} - -if (typeof(MochiKit.DateTime) == 'undefined') { - MochiKit.DateTime = {}; -} - -MochiKit.DateTime.NAME = "MochiKit.DateTime"; -MochiKit.DateTime.VERSION = "1.4"; -MochiKit.DateTime.__repr__ = function () { - return "[" + this.NAME + " " + this.VERSION + "]"; -}; -MochiKit.DateTime.toString = function () { - return this.__repr__(); -}; - -/** @id MochiKit.DateTime.isoDate */ -MochiKit.DateTime.isoDate = function (str) { - str = str + ""; - if (typeof(str) != "string" || str.length === 0) { - return null; - } - var iso = str.split('-'); - if (iso.length === 0) { - return null; - } - return new Date(iso[0], iso[1] - 1, iso[2]); -}; - -MochiKit.DateTime._isoRegexp = /(\d{4,})(?:-(\d{1,2})(?:-(\d{1,2})(?:[T ](\d{1,2}):(\d{1,2})(?::(\d{1,2})(?:\.(\d+))?)?(?:(Z)|([+-])(\d{1,2})(?::(\d{1,2}))?)?)?)?)?/; - -/** @id MochiKit.DateTime.isoTimestamp */ -MochiKit.DateTime.isoTimestamp = function (str) { - str = str + ""; - if (typeof(str) != "string" || str.length === 0) { - return null; - } - var res = str.match(MochiKit.DateTime._isoRegexp); - if (typeof(res) == "undefined" || res === null) { - return null; - } - var year, month, day, hour, min, sec, msec; - year = parseInt(res[1], 10); - if (typeof(res[2]) == "undefined" || res[2] === '') { - return new Date(year); - } - month = parseInt(res[2], 10) - 1; - day = parseInt(res[3], 10); - if (typeof(res[4]) == "undefined" || res[4] === '') { - return new Date(year, month, day); - } - hour = parseInt(res[4], 10); - min = parseInt(res[5], 10); - sec = (typeof(res[6]) != "undefined" && res[6] !== '') ? parseInt(res[6], 10) : 0; - if (typeof(res[7]) != "undefined" && res[7] !== '') { - msec = Math.round(1000.0 * parseFloat("0." + res[7])); - } else { - msec = 0; - } - if ((typeof(res[8]) == "undefined" || res[8] === '') && (typeof(res[9]) == "undefined" || res[9] === '')) { - return new Date(year, month, day, hour, min, sec, msec); - } - var ofs; - if (typeof(res[9]) != "undefined" && res[9] !== '') { - ofs = parseInt(res[10], 10) * 3600000; - if (typeof(res[11]) != "undefined" && res[11] !== '') { - ofs += parseInt(res[11], 10) * 60000; - } - if (res[9] == "-") { - ofs = -ofs; - } - } else { - ofs = 0; - } - return new Date(Date.UTC(year, month, day, hour, min, sec, msec) - ofs); -}; - -/** @id MochiKit.DateTime.toISOTime */ -MochiKit.DateTime.toISOTime = function (date, realISO/* = false */) { - if (typeof(date) == "undefined" || date === null) { - return null; - } - var hh = date.getHours(); - var mm = date.getMinutes(); - var ss = date.getSeconds(); - var lst = [ - ((realISO && (hh < 10)) ? "0" + hh : hh), - ((mm < 10) ? "0" + mm : mm), - ((ss < 10) ? "0" + ss : ss) - ]; - return lst.join(":"); -}; - -/** @id MochiKit.DateTime.toISOTimeStamp */ -MochiKit.DateTime.toISOTimestamp = function (date, realISO/* = false*/) { - if (typeof(date) == "undefined" || date === null) { - return null; - } - var sep = realISO ? "T" : " "; - var foot = realISO ? "Z" : ""; - if (realISO) { - date = new Date(date.getTime() + (date.getTimezoneOffset() * 60000)); - } - return MochiKit.DateTime.toISODate(date) + sep + MochiKit.DateTime.toISOTime(date, realISO) + foot; -}; - -/** @id MochiKit.DateTime.toISODate */ -MochiKit.DateTime.toISODate = function (date) { - if (typeof(date) == "undefined" || date === null) { - return null; - } - var _padTwo = MochiKit.DateTime._padTwo; - return [ - date.getFullYear(), - _padTwo(date.getMonth() + 1), - _padTwo(date.getDate()) - ].join("-"); -}; - -/** @id MochiKit.DateTime.americanDate */ -MochiKit.DateTime.americanDate = function (d) { - d = d + ""; - if (typeof(d) != "string" || d.length === 0) { - return null; - } - var a = d.split('/'); - return new Date(a[2], a[0] - 1, a[1]); -}; - -MochiKit.DateTime._padTwo = function (n) { - return (n > 9) ? n : "0" + n; -}; - -/** @id MochiKit.DateTime.toPaddedAmericanDate */ -MochiKit.DateTime.toPaddedAmericanDate = function (d) { - if (typeof(d) == "undefined" || d === null) { - return null; - } - var _padTwo = MochiKit.DateTime._padTwo; - return [ - _padTwo(d.getMonth() + 1), - _padTwo(d.getDate()), - d.getFullYear() - ].join('/'); -}; - -/** @id MochiKit.DateTime.toAmericanDate */ -MochiKit.DateTime.toAmericanDate = function (d) { - if (typeof(d) == "undefined" || d === null) { - return null; - } - return [d.getMonth() + 1, d.getDate(), d.getFullYear()].join('/'); -}; - -MochiKit.DateTime.EXPORT = [ - "isoDate", - "isoTimestamp", - "toISOTime", - "toISOTimestamp", - "toISODate", - "americanDate", - "toPaddedAmericanDate", - "toAmericanDate" -]; - -MochiKit.DateTime.EXPORT_OK = []; -MochiKit.DateTime.EXPORT_TAGS = { - ":common": MochiKit.DateTime.EXPORT, - ":all": MochiKit.DateTime.EXPORT -}; - -MochiKit.DateTime.__new__ = function () { - // MochiKit.Base.nameFunctions(this); - var base = this.NAME + "."; - for (var k in this) { - var o = this[k]; - if (typeof(o) == 'function' && typeof(o.NAME) == 'undefined') { - try { - o.NAME = base + k; - } catch (e) { - // pass - } - } - } -}; - -MochiKit.DateTime.__new__(); - -if (typeof(MochiKit.Base) != "undefined") { - MochiKit.Base._exportSymbols(this, MochiKit.DateTime); -} else { - (function (globals, module) { - if ((typeof(JSAN) == 'undefined' && typeof(dojo) == 'undefined') - || (MochiKit.__export__ === false)) { - var all = module.EXPORT_TAGS[":all"]; - for (var i = 0; i < all.length; i++) { - globals[all[i]] = module[all[i]]; - } - } - })(this, MochiKit.DateTime); -} diff --git a/javascript/libs/MochiKit/DragAndDrop.js b/javascript/libs/MochiKit/DragAndDrop.js deleted file mode 100644 index 6213ddc..0000000 --- a/javascript/libs/MochiKit/DragAndDrop.js +++ /dev/null @@ -1,824 +0,0 @@ -/*** -MochiKit.DragAndDrop 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) - Mochi-ized By Thomas Herve (_firstname_@nimail.org) - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.DragAndDrop'); - dojo.require('MochiKit.Base'); - dojo.require('MochiKit.DOM'); - dojo.require('MochiKit.Iter'); - dojo.require('MochiKit.Visual'); - dojo.require('MochiKit.Signal'); -} - -if (typeof(JSAN) != 'undefined') { - JSAN.use("MochiKit.Base", []); - JSAN.use("MochiKit.DOM", []); - JSAN.use("MochiKit.Visual", []); - JSAN.use("MochiKit.Iter", []); - JSAN.use("MochiKit.Signal", []); -} - -try { - if (typeof(MochiKit.Base) == 'undefined' || - typeof(MochiKit.DOM) == 'undefined' || - typeof(MochiKit.Visual) == 'undefined' || - typeof(MochiKit.Signal) == 'undefined' || - typeof(MochiKit.Iter) == 'undefined') { - throw ""; - } -} catch (e) { - throw "MochiKit.DragAndDrop depends on MochiKit.Base, MochiKit.DOM, MochiKit.Visual, MochiKit.Signal and MochiKit.Iter!"; -} - -if (typeof(MochiKit.DragAndDrop) == 'undefined') { - MochiKit.DragAndDrop = {}; -} - -MochiKit.DragAndDrop.NAME = 'MochiKit.DragAndDrop'; -MochiKit.DragAndDrop.VERSION = '1.4'; - -MochiKit.DragAndDrop.__repr__ = function () { - return '[' + this.NAME + ' ' + this.VERSION + ']'; -}; - -MochiKit.DragAndDrop.toString = function () { - return this.__repr__(); -}; - -MochiKit.DragAndDrop.EXPORT = [ - "Droppable", - "Draggable" -]; - -MochiKit.DragAndDrop.EXPORT_OK = [ - "Droppables", - "Draggables" -]; - -MochiKit.DragAndDrop.Droppables = { - /*** - - Manage all droppables. Shouldn't be used, use the Droppable object instead. - - ***/ - drops: [], - - remove: function (element) { - this.drops = MochiKit.Base.filter(function (d) { - return d.element != MochiKit.DOM.getElement(element); - }, this.drops); - }, - - register: function (drop) { - this.drops.push(drop); - }, - - unregister: function (drop) { - this.drops = MochiKit.Base.filter(function (d) { - return d != drop; - }, this.drops); - }, - - prepare: function (element) { - MochiKit.Base.map(function (drop) { - if (drop.isAccepted(element)) { - if (drop.options.activeclass) { - MochiKit.DOM.addElementClass(drop.element, - drop.options.activeclass); - } - drop.options.onactive(drop.element, element); - } - }, this.drops); - }, - - findDeepestChild: function (drops) { - deepest = drops[0]; - - for (i = 1; i < drops.length; ++i) { - if (MochiKit.DOM.isParent(drops[i].element, deepest.element)) { - deepest = drops[i]; - } - } - return deepest; - }, - - show: function (point, element) { - if (!this.drops.length) { - return; - } - var affected = []; - - if (this.last_active) { - this.last_active.deactivate(); - } - MochiKit.Iter.forEach(this.drops, function (drop) { - if (drop.isAffected(point, element)) { - affected.push(drop); - } - }); - if (affected.length > 0) { - drop = this.findDeepestChild(affected); - MochiKit.Position.within(drop.element, point.page.x, point.page.y); - drop.options.onhover(element, drop.element, - MochiKit.Position.overlap(drop.options.overlap, drop.element)); - drop.activate(); - } - }, - - fire: function (event, element) { - if (!this.last_active) { - return; - } - MochiKit.Position.prepare(); - - if (this.last_active.isAffected(event.mouse(), element)) { - this.last_active.options.ondrop(element, - this.last_active.element, event); - } - }, - - reset: function (element) { - MochiKit.Base.map(function (drop) { - if (drop.options.activeclass) { - MochiKit.DOM.removeElementClass(drop.element, - drop.options.activeclass); - } - drop.options.ondesactive(drop.element, element); - }, this.drops); - if (this.last_active) { - this.last_active.deactivate(); - } - } -}; - -/** @id MochiKit.DragAndDrop.Droppable */ -MochiKit.DragAndDrop.Droppable = function (element, options) { - var cls = arguments.callee; - if (!(this instanceof cls)) { - return new cls(element, options); - } - this.__init__(element, options); -}; - -MochiKit.DragAndDrop.Droppable.prototype = { - /*** - - A droppable object. Simple use is to create giving an element: - - new MochiKit.DragAndDrop.Droppable('myelement'); - - Generally you'll want to define the 'ondrop' function and maybe the - 'accept' option to filter draggables. - - ***/ - __class__: MochiKit.DragAndDrop.Droppable, - - __init__: function (element, /* optional */options) { - var d = MochiKit.DOM; - var b = MochiKit.Base; - this.element = d.getElement(element); - this.options = b.update({ - - /** @id MochiKit.DragAndDrop.greedy */ - greedy: true, - - /** @id MochiKit.DragAndDrop.hoverclass */ - hoverclass: null, - - /** @id MochiKit.DragAndDrop.activeclass */ - activeclass: null, - - /** @id MochiKit.DragAndDrop.hoverfunc */ - hoverfunc: b.noop, - - /** @id MochiKit.DragAndDrop.accept */ - accept: null, - - /** @id MochiKit.DragAndDrop.onactive */ - onactive: b.noop, - - /** @id MochiKit.DragAndDrop.ondesactive */ - ondesactive: b.noop, - - /** @id MochiKit.DragAndDrop.onhover */ - onhover: b.noop, - - /** @id MochiKit.DragAndDrop.ondrop */ - ondrop: b.noop, - - /** @id MochiKit.DragAndDrop.containment */ - containment: [], - tree: false - }, options); - - // cache containers - this.options._containers = []; - b.map(MochiKit.Base.bind(function (c) { - this.options._containers.push(d.getElement(c)); - }, this), this.options.containment); - - d.makePositioned(this.element); // fix IE - - MochiKit.DragAndDrop.Droppables.register(this); - }, - - /** @id MochiKit.DragAndDrop.isContained */ - isContained: function (element) { - if (this.options._containers.length) { - var containmentNode; - if (this.options.tree) { - containmentNode = element.treeNode; - } else { - containmentNode = element.parentNode; - } - return MochiKit.Iter.some(this.options._containers, function (c) { - return containmentNode == c; - }); - } else { - return true; - } - }, - - /** @id MochiKit.DragAndDrop.isAccepted */ - isAccepted: function (element) { - return ((!this.options.accept) || MochiKit.Iter.some( - this.options.accept, function (c) { - return MochiKit.DOM.hasElementClass(element, c); - })); - }, - - /** @id MochiKit.DragAndDrop.isAffected */ - isAffected: function (point, element) { - return ((this.element != element) && - this.isContained(element) && - this.isAccepted(element) && - MochiKit.Position.within(this.element, point.page.x, - point.page.y)); - }, - - /** @id MochiKit.DragAndDrop.deactivate */ - deactivate: function () { - /*** - - A droppable is deactivate when a draggable has been over it and left. - - ***/ - if (this.options.hoverclass) { - MochiKit.DOM.removeElementClass(this.element, - this.options.hoverclass); - } - this.options.hoverfunc(this.element, false); - MochiKit.DragAndDrop.Droppables.last_active = null; - }, - - /** @id MochiKit.DragAndDrop.activate */ - activate: function () { - /*** - - A droppable is active when a draggable is over it. - - ***/ - if (this.options.hoverclass) { - MochiKit.DOM.addElementClass(this.element, this.options.hoverclass); - } - this.options.hoverfunc(this.element, true); - MochiKit.DragAndDrop.Droppables.last_active = this; - }, - - /** @id MochiKit.DragAndDrop.destroy */ - destroy: function () { - /*** - - Delete this droppable. - - ***/ - MochiKit.DragAndDrop.Droppables.unregister(this); - }, - - /** @id MochiKit.DragAndDrop.repr */ - repr: function () { - return '[' + this.__class__.NAME + ", options:" + MochiKit.Base.repr(this.options) + "]"; - } -}; - -MochiKit.DragAndDrop.Draggables = { - /*** - - Manage draggables elements. Not intended to direct use. - - ***/ - drags: [], - - register: function (draggable) { - if (this.drags.length === 0) { - var conn = MochiKit.Signal.connect; - this.eventMouseUp = conn(document, 'onmouseup', this, this.endDrag); - this.eventMouseMove = conn(document, 'onmousemove', this, - this.updateDrag); - this.eventKeypress = conn(document, 'onkeypress', this, - this.keyPress); - } - this.drags.push(draggable); - }, - - unregister: function (draggable) { - this.drags = MochiKit.Base.filter(function (d) { - return d != draggable; - }, this.drags); - if (this.drags.length === 0) { - var disc = MochiKit.Signal.disconnect; - disc(this.eventMouseUp); - disc(this.eventMouseMove); - disc(this.eventKeypress); - } - }, - - activate: function (draggable) { - // allows keypress events if window is not currently focused - // fails for Safari - window.focus(); - this.activeDraggable = draggable; - }, - - deactivate: function () { - this.activeDraggable = null; - }, - - updateDrag: function (event) { - if (!this.activeDraggable) { - return; - } - var pointer = event.mouse(); - // Mozilla-based browsers fire successive mousemove events with - // the same coordinates, prevent needless redrawing (moz bug?) - if (this._lastPointer && (MochiKit.Base.repr(this._lastPointer.page) == - MochiKit.Base.repr(pointer.page))) { - return; - } - this._lastPointer = pointer; - this.activeDraggable.updateDrag(event, pointer); - }, - - endDrag: function (event) { - if (!this.activeDraggable) { - return; - } - this._lastPointer = null; - this.activeDraggable.endDrag(event); - this.activeDraggable = null; - }, - - keyPress: function (event) { - if (this.activeDraggable) { - this.activeDraggable.keyPress(event); - } - }, - - notify: function (eventName, draggable, event) { - MochiKit.Signal.signal(this, eventName, draggable, event); - } -}; - -/** @id MochiKit.DragAndDrop.Draggable */ -MochiKit.DragAndDrop.Draggable = function (element, options) { - var cls = arguments.callee; - if (!(this instanceof cls)) { - return new cls(element, options); - } - this.__init__(element, options); -}; - -MochiKit.DragAndDrop.Draggable.prototype = { - /*** - - A draggable object. Simple instantiate : - - new MochiKit.DragAndDrop.Draggable('myelement'); - - ***/ - __class__ : MochiKit.DragAndDrop.Draggable, - - __init__: function (element, /* optional */options) { - var v = MochiKit.Visual; - var b = MochiKit.Base; - options = b.update({ - - /** @id MochiKit.DragAndDrop.handle */ - handle: false, - - /** @id MochiKit.DragAndDrop.starteffect */ - starteffect: function (innerelement) { - this._savedOpacity = MochiKit.Style.getStyle(innerelement, 'opacity') || 1.0; - new v.Opacity(innerelement, {duration:0.2, from:this._savedOpacity, to:0.7}); - }, - /** @id MochiKit.DragAndDrop.reverteffect */ - reverteffect: function (innerelement, top_offset, left_offset) { - var dur = Math.sqrt(Math.abs(top_offset^2) + - Math.abs(left_offset^2))*0.02; - return new v.Move(innerelement, - {x: -left_offset, y: -top_offset, duration: dur}); - }, - - /** @id MochiKit.DragAndDrop.endeffect */ - endeffect: function (innerelement) { - new v.Opacity(innerelement, {duration:0.2, from:0.7, to:this._savedOpacity}); - }, - - /** @id MochiKit.DragAndDrop.onchange */ - onchange: b.noop, - - /** @id MochiKit.DragAndDrop.zindex */ - zindex: 1000, - - /** @id MochiKit.DragAndDrop.revert */ - revert: false, - - /** @id MochiKit.DragAndDrop.scroll */ - scroll: false, - - /** @id MochiKit.DragAndDrop.scrollSensitivity */ - scrollSensitivity: 20, - - /** @id MochiKit.DragAndDrop.scrollSpeed */ - scrollSpeed: 15, - // false, or xy or [x, y] or function (x, y){return [x, y];} - - /** @id MochiKit.DragAndDrop.snap */ - snap: false - }, options); - - var d = MochiKit.DOM; - this.element = d.getElement(element); - - if (options.handle && (typeof(options.handle) == 'string')) { - this.handle = d.getFirstElementByTagAndClassName(null, - options.handle, this.element); - } - if (!this.handle) { - this.handle = d.getElement(options.handle); - } - if (!this.handle) { - this.handle = this.element; - } - - if (options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { - options.scroll = d.getElement(options.scroll); - this._isScrollChild = MochiKit.DOM.isChildNode(this.element, options.scroll); - } - - d.makePositioned(this.element); // fix IE - - this.delta = this.currentDelta(); - this.options = options; - this.dragging = false; - - this.eventMouseDown = MochiKit.Signal.connect(this.handle, - 'onmousedown', this, this.initDrag); - MochiKit.DragAndDrop.Draggables.register(this); - }, - - /** @id MochiKit.DragAndDrop.destroy */ - destroy: function () { - MochiKit.Signal.disconnect(this.eventMouseDown); - MochiKit.DragAndDrop.Draggables.unregister(this); - }, - - /** @id MochiKit.DragAndDrop.currentDelta */ - currentDelta: function () { - var s = MochiKit.Style.getStyle; - return [ - parseInt(s(this.element, 'left') || '0'), - parseInt(s(this.element, 'top') || '0')]; - }, - - /** @id MochiKit.DragAndDrop.initDrag */ - initDrag: function (event) { - if (!event.mouse().button.left) { - return; - } - // abort on form elements, fixes a Firefox issue - var src = event.target(); - var tagName = (src.tagName || '').toUpperCase(); - if (tagName === 'INPUT' || tagName === 'SELECT' || - tagName === 'OPTION' || tagName === 'BUTTON' || - tagName === 'TEXTAREA') { - return; - } - - if (this._revert) { - this._revert.cancel(); - this._revert = null; - } - - var pointer = event.mouse(); - var pos = MochiKit.Position.cumulativeOffset(this.element); - this.offset = [pointer.page.x - pos.x, pointer.page.y - pos.y]; - - MochiKit.DragAndDrop.Draggables.activate(this); - event.stop(); - }, - - /** @id MochiKit.DragAndDrop.startDrag */ - startDrag: function (event) { - this.dragging = true; - if (this.options.selectclass) { - MochiKit.DOM.addElementClass(this.element, - this.options.selectclass); - } - if (this.options.zindex) { - this.originalZ = parseInt(MochiKit.Style.getStyle(this.element, - 'z-index') || '0'); - this.element.style.zIndex = this.options.zindex; - } - - if (this.options.ghosting) { - this._clone = this.element.cloneNode(true); - this.ghostPosition = MochiKit.Position.absolutize(this.element); - this.element.parentNode.insertBefore(this._clone, this.element); - } - - if (this.options.scroll) { - if (this.options.scroll == window) { - var where = this._getWindowScroll(this.options.scroll); - this.originalScrollLeft = where.left; - this.originalScrollTop = where.top; - } else { - this.originalScrollLeft = this.options.scroll.scrollLeft; - this.originalScrollTop = this.options.scroll.scrollTop; - } - } - - MochiKit.DragAndDrop.Droppables.prepare(this.element); - MochiKit.DragAndDrop.Draggables.notify('start', this, event); - if (this.options.starteffect) { - this.options.starteffect(this.element); - } - }, - - /** @id MochiKit.DragAndDrop.updateDrag */ - updateDrag: function (event, pointer) { - if (!this.dragging) { - this.startDrag(event); - } - MochiKit.Position.prepare(); - MochiKit.DragAndDrop.Droppables.show(pointer, this.element); - MochiKit.DragAndDrop.Draggables.notify('drag', this, event); - this.draw(pointer); - this.options.onchange(this); - - if (this.options.scroll) { - this.stopScrolling(); - var p, q; - if (this.options.scroll == window) { - var s = this._getWindowScroll(this.options.scroll); - p = new MochiKit.Style.Coordinates(s.left, s.top); - q = new MochiKit.Style.Coordinates(s.left + s.width, - s.top + s.height); - } else { - p = MochiKit.Position.page(this.options.scroll); - p.x += this.options.scroll.scrollLeft; - p.y += this.options.scroll.scrollTop; - p.x += (window.pageXOffset || document.documentElement.scrollLeft || document.body.scrollLeft || 0); - p.y += (window.pageYOffset || document.documentElement.scrollTop || document.body.scrollTop || 0); - q = new MochiKit.Style.Coordinates(p.x + this.options.scroll.offsetWidth, - p.y + this.options.scroll.offsetHeight); - } - var speed = [0, 0]; - if (pointer.page.x > (q.x - this.options.scrollSensitivity)) { - speed[0] = pointer.page.x - (q.x - this.options.scrollSensitivity); - } else if (pointer.page.x < (p.x + this.options.scrollSensitivity)) { - speed[0] = pointer.page.x - (p.x + this.options.scrollSensitivity); - } - if (pointer.page.y > (q.y - this.options.scrollSensitivity)) { - speed[1] = pointer.page.y - (q.y - this.options.scrollSensitivity); - } else if (pointer.page.y < (p.y + this.options.scrollSensitivity)) { - speed[1] = pointer.page.y - (p.y + this.options.scrollSensitivity); - } - this.startScrolling(speed); - } - - // fix AppleWebKit rendering - if (/AppleWebKit/.test(navigator.appVersion)) { - window.scrollBy(0, 0); - } - event.stop(); - }, - - /** @id MochiKit.DragAndDrop.finishDrag */ - finishDrag: function (event, success) { - var dr = MochiKit.DragAndDrop; - this.dragging = false; - if (this.options.selectclass) { - MochiKit.DOM.removeElementClass(this.element, - this.options.selectclass); - } - - if (this.options.ghosting) { - // XXX: from a user point of view, it would be better to remove - // the node only *after* the MochiKit.Visual.Move end when used - // with revert. - MochiKit.Position.relativize(this.element, this.ghostPosition); - MochiKit.DOM.removeElement(this._clone); - this._clone = null; - } - - if (success) { - dr.Droppables.fire(event, this.element); - } - dr.Draggables.notify('end', this, event); - - var revert = this.options.revert; - if (revert && typeof(revert) == 'function') { - revert = revert(this.element); - } - - var d = this.currentDelta(); - if (revert && this.options.reverteffect) { - this._revert = this.options.reverteffect(this.element, - d[1] - this.delta[1], d[0] - this.delta[0]); - } else { - this.delta = d; - } - - if (this.options.zindex) { - this.element.style.zIndex = this.originalZ; - } - - if (this.options.endeffect) { - this.options.endeffect(this.element); - } - - dr.Draggables.deactivate(); - dr.Droppables.reset(this.element); - }, - - /** @id MochiKit.DragAndDrop.keyPress */ - keyPress: function (event) { - if (event.key().string != "KEY_ESCAPE") { - return; - } - this.finishDrag(event, false); - event.stop(); - }, - - /** @id MochiKit.DragAndDrop.endDrag */ - endDrag: function (event) { - if (!this.dragging) { - return; - } - this.stopScrolling(); - this.finishDrag(event, true); - event.stop(); - }, - - /** @id MochiKit.DragAndDrop.draw */ - draw: function (point) { - var pos = MochiKit.Position.cumulativeOffset(this.element); - var d = this.currentDelta(); - pos.x -= d[0]; - pos.y -= d[1]; - - if (this.options.scroll && (this.options.scroll != window && this._isScrollChild)) { - pos.x -= this.options.scroll.scrollLeft - this.originalScrollLeft; - pos.y -= this.options.scroll.scrollTop - this.originalScrollTop; - } - - var p = [point.page.x - pos.x - this.offset[0], - point.page.y - pos.y - this.offset[1]]; - - if (this.options.snap) { - if (typeof(this.options.snap) == 'function') { - p = this.options.snap(p[0], p[1]); - } else { - if (this.options.snap instanceof Array) { - var i = -1; - p = MochiKit.Base.map(MochiKit.Base.bind(function (v) { - i += 1; - return Math.round(v/this.options.snap[i]) * - this.options.snap[i]; - }, this), p); - } else { - p = MochiKit.Base.map(MochiKit.Base.bind(function (v) { - return Math.round(v/this.options.snap) * - this.options.snap; - }, this), p); - } - } - } - var style = this.element.style; - if ((!this.options.constraint) || - (this.options.constraint == 'horizontal')) { - style.left = p[0] + 'px'; - } - if ((!this.options.constraint) || - (this.options.constraint == 'vertical')) { - style.top = p[1] + 'px'; - } - if (style.visibility == 'hidden') { - style.visibility = ''; // fix gecko rendering - } - }, - - /** @id MochiKit.DragAndDrop.stopScrolling */ - stopScrolling: function () { - if (this.scrollInterval) { - clearInterval(this.scrollInterval); - this.scrollInterval = null; - MochiKit.DragAndDrop.Draggables._lastScrollPointer = null; - } - }, - - /** @id MochiKit.DragAndDrop.startScrolling */ - startScrolling: function (speed) { - if (!speed[0] && !speed[1]) { - return; - } - this.scrollSpeed = [speed[0] * this.options.scrollSpeed, - speed[1] * this.options.scrollSpeed]; - this.lastScrolled = new Date(); - this.scrollInterval = setInterval(MochiKit.Base.bind(this.scroll, this), 10); - }, - - /** @id MochiKit.DragAndDrop.scroll */ - scroll: function () { - var current = new Date(); - var delta = current - this.lastScrolled; - this.lastScrolled = current; - - if (this.options.scroll == window) { - var s = this._getWindowScroll(this.options.scroll); - if (this.scrollSpeed[0] || this.scrollSpeed[1]) { - var dm = delta / 1000; - this.options.scroll.scrollTo(s.left + dm * this.scrollSpeed[0], - s.top + dm * this.scrollSpeed[1]); - } - } else { - this.options.scroll.scrollLeft += this.scrollSpeed[0] * delta / 1000; - this.options.scroll.scrollTop += this.scrollSpeed[1] * delta / 1000; - } - - var d = MochiKit.DragAndDrop; - - MochiKit.Position.prepare(); - d.Droppables.show(d.Draggables._lastPointer, this.element); - d.Draggables.notify('drag', this); - if (this._isScrollChild) { - d.Draggables._lastScrollPointer = d.Draggables._lastScrollPointer || d.Draggables._lastPointer; - d.Draggables._lastScrollPointer.x += this.scrollSpeed[0] * delta / 1000; - d.Draggables._lastScrollPointer.y += this.scrollSpeed[1] * delta / 1000; - if (d.Draggables._lastScrollPointer.x < 0) { - d.Draggables._lastScrollPointer.x = 0; - } - if (d.Draggables._lastScrollPointer.y < 0) { - d.Draggables._lastScrollPointer.y = 0; - } - this.draw(d.Draggables._lastScrollPointer); - } - - this.options.onchange(this); - }, - - _getWindowScroll: function (win) { - var vp, w, h; - MochiKit.DOM.withWindow(win, function () { - vp = MochiKit.Style.getViewportPosition(win.document); - }); - if (win.innerWidth) { - w = win.innerWidth; - h = win.innerHeight; - } else if (win.document.documentElement && win.document.documentElement.clientWidth) { - w = win.document.documentElement.clientWidth; - h = win.document.documentElement.clientHeight; - } else { - w = win.document.body.offsetWidth; - h = win.document.body.offsetHeight; - } - return {top: vp.y, left: vp.x, width: w, height: h}; - }, - - /** @id MochiKit.DragAndDrop.repr */ - repr: function () { - return '[' + this.__class__.NAME + ", options:" + MochiKit.Base.repr(this.options) + "]"; - } -}; - -MochiKit.DragAndDrop.__new__ = function () { - MochiKit.Base.nameFunctions(this); - - this.EXPORT_TAGS = { - ":common": this.EXPORT, - ":all": MochiKit.Base.concat(this.EXPORT, this.EXPORT_OK) - }; -}; - -MochiKit.DragAndDrop.__new__(); - -MochiKit.Base._exportSymbols(this, MochiKit.DragAndDrop); - diff --git a/javascript/libs/MochiKit/Format.js b/javascript/libs/MochiKit/Format.js deleted file mode 100644 index 27c2f6f..0000000 --- a/javascript/libs/MochiKit/Format.js +++ /dev/null @@ -1,308 +0,0 @@ -/*** - -MochiKit.Format 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005 Bob Ippolito. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.Format'); -} - -if (typeof(MochiKit) == 'undefined') { - MochiKit = {}; -} - -if (typeof(MochiKit.Format) == 'undefined') { - MochiKit.Format = {}; -} - -MochiKit.Format.NAME = "MochiKit.Format"; -MochiKit.Format.VERSION = "1.4"; -MochiKit.Format.__repr__ = function () { - return "[" + this.NAME + " " + this.VERSION + "]"; -}; -MochiKit.Format.toString = function () { - return this.__repr__(); -}; - -MochiKit.Format._numberFormatter = function (placeholder, header, footer, locale, isPercent, precision, leadingZeros, separatorAt, trailingZeros) { - return function (num) { - num = parseFloat(num); - if (typeof(num) == "undefined" || num === null || isNaN(num)) { - return placeholder; - } - var curheader = header; - var curfooter = footer; - if (num < 0) { - num = -num; - } else { - curheader = curheader.replace(/-/, ""); - } - var me = arguments.callee; - var fmt = MochiKit.Format.formatLocale(locale); - if (isPercent) { - num = num * 100.0; - curfooter = fmt.percent + curfooter; - } - num = MochiKit.Format.roundToFixed(num, precision); - var parts = num.split(/\./); - var whole = parts[0]; - var frac = (parts.length == 1) ? "" : parts[1]; - var res = ""; - while (whole.length < leadingZeros) { - whole = "0" + whole; - } - if (separatorAt) { - while (whole.length > separatorAt) { - var i = whole.length - separatorAt; - //res = res + fmt.separator + whole.substring(i, whole.length); - res = fmt.separator + whole.substring(i, whole.length) + res; - whole = whole.substring(0, i); - } - } - res = whole + res; - if (precision > 0) { - while (frac.length < trailingZeros) { - frac = frac + "0"; - } - res = res + fmt.decimal + frac; - } - return curheader + res + curfooter; - }; -}; - -/** @id MochiKit.Format.numberFormatter */ -MochiKit.Format.numberFormatter = function (pattern, placeholder/* = "" */, locale/* = "default" */) { - // http://java.sun.com/docs/books/tutorial/i18n/format/numberpattern.html - // | 0 | leading or trailing zeros - // | # | just the number - // | , | separator - // | . | decimal separator - // | % | Multiply by 100 and format as percent - if (typeof(placeholder) == "undefined") { - placeholder = ""; - } - var match = pattern.match(/((?:[0#]+,)?[0#]+)(?:\.([0#]+))?(%)?/); - if (!match) { - throw TypeError("Invalid pattern"); - } - var header = pattern.substr(0, match.index); - var footer = pattern.substr(match.index + match[0].length); - if (header.search(/-/) == -1) { - header = header + "-"; - } - var whole = match[1]; - var frac = (typeof(match[2]) == "string" && match[2] != "") ? match[2] : ""; - var isPercent = (typeof(match[3]) == "string" && match[3] != ""); - var tmp = whole.split(/,/); - var separatorAt; - if (typeof(locale) == "undefined") { - locale = "default"; - } - if (tmp.length == 1) { - separatorAt = null; - } else { - separatorAt = tmp[1].length; - } - var leadingZeros = whole.length - whole.replace(/0/g, "").length; - var trailingZeros = frac.length - frac.replace(/0/g, "").length; - var precision = frac.length; - var rval = MochiKit.Format._numberFormatter( - placeholder, header, footer, locale, isPercent, precision, - leadingZeros, separatorAt, trailingZeros - ); - var m = MochiKit.Base; - if (m) { - var fn = arguments.callee; - var args = m.concat(arguments); - rval.repr = function () { - return [ - self.NAME, - "(", - map(m.repr, args).join(", "), - ")" - ].join(""); - }; - } - return rval; -}; - -/** @id MochiKit.Format.formatLocale */ -MochiKit.Format.formatLocale = function (locale) { - if (typeof(locale) == "undefined" || locale === null) { - locale = "default"; - } - if (typeof(locale) == "string") { - var rval = MochiKit.Format.LOCALE[locale]; - if (typeof(rval) == "string") { - rval = arguments.callee(rval); - MochiKit.Format.LOCALE[locale] = rval; - } - return rval; - } else { - return locale; - } -}; - -/** @id MochiKit.Format.twoDigitAverage */ -MochiKit.Format.twoDigitAverage = function (numerator, denominator) { - if (denominator) { - var res = numerator / denominator; - if (!isNaN(res)) { - return MochiKit.Format.twoDigitFloat(numerator / denominator); - } - } - return "0"; -}; - -/** @id MochiKit.Format.twoDigitFloat */ -MochiKit.Format.twoDigitFloat = function (someFloat) { - var sign = (someFloat < 0 ? '-' : ''); - var s = Math.floor(Math.abs(someFloat) * 100).toString(); - if (s == '0') { - return s; - } - if (s.length < 3) { - if (s.length == 1) { - s = '0' + s; - } - while (s.charAt(s.length - 1) == '0') { - s = s.substring(0, s.length - 1); - } - return sign + '0.' + s; - } - var head = sign + s.substring(0, s.length - 2); - var tail = s.substring(s.length - 2, s.length); - if (tail == '00') { - return head; - } else if (tail.charAt(1) == '0') { - return head + '.' + tail.charAt(0); - } else { - return head + '.' + tail; - } -}; - -/** @id MochiKit.Format.lstrip */ -MochiKit.Format.lstrip = function (str, /* optional */chars) { - str = str + ""; - if (typeof(str) != "string") { - return null; - } - if (!chars) { - return str.replace(/^\s+/, ""); - } else { - return str.replace(new RegExp("^[" + chars + "]+"), ""); - } -}; - -/** @id MochiKit.Format.rstrip */ -MochiKit.Format.rstrip = function (str, /* optional */chars) { - str = str + ""; - if (typeof(str) != "string") { - return null; - } - if (!chars) { - return str.replace(/\s+$/, ""); - } else { - return str.replace(new RegExp("[" + chars + "]+$"), ""); - } -}; - -/** @id MochiKit.Format.strip */ -MochiKit.Format.strip = function (str, /* optional */chars) { - var self = MochiKit.Format; - return self.rstrip(self.lstrip(str, chars), chars); -}; - -/** @id MochiKit.Format.truncToFixed */ -MochiKit.Format.truncToFixed = function (aNumber, precision) { - aNumber = Math.floor(aNumber * Math.pow(10, precision)); - var res = (aNumber * Math.pow(10, -precision)).toFixed(precision); - if (res.charAt(0) == ".") { - res = "0" + res; - } - return res; -}; - -/** @id MochiKit.Format.roundToFixed */ -MochiKit.Format.roundToFixed = function (aNumber, precision) { - return MochiKit.Format.truncToFixed( - aNumber + 0.5 * Math.pow(10, -precision), - precision - ); -}; - -/** @id MochiKit.Format.percentFormat */ -MochiKit.Format.percentFormat = function (someFloat) { - return MochiKit.Format.twoDigitFloat(100 * someFloat) + '%'; -}; - -MochiKit.Format.EXPORT = [ - "truncToFixed", - "roundToFixed", - "numberFormatter", - "formatLocale", - "twoDigitAverage", - "twoDigitFloat", - "percentFormat", - "lstrip", - "rstrip", - "strip" -]; - -MochiKit.Format.LOCALE = { - en_US: {separator: ",", decimal: ".", percent: "%"}, - de_DE: {separator: ".", decimal: ",", percent: "%"}, - pt_BR: {separator: ".", decimal: ",", percent: "%"}, - fr_FR: {separator: " ", decimal: ",", percent: "%"}, - "default": "en_US" -}; - -MochiKit.Format.EXPORT_OK = []; -MochiKit.Format.EXPORT_TAGS = { - ':all': MochiKit.Format.EXPORT, - ':common': MochiKit.Format.EXPORT -}; - -MochiKit.Format.__new__ = function () { - // MochiKit.Base.nameFunctions(this); - var base = this.NAME + "."; - var k, v, o; - for (k in this.LOCALE) { - o = this.LOCALE[k]; - if (typeof(o) == "object") { - o.repr = function () { return this.NAME; }; - o.NAME = base + "LOCALE." + k; - } - } - for (k in this) { - o = this[k]; - if (typeof(o) == 'function' && typeof(o.NAME) == 'undefined') { - try { - o.NAME = base + k; - } catch (e) { - // pass - } - } - } -}; - -MochiKit.Format.__new__(); - -if (typeof(MochiKit.Base) != "undefined") { - MochiKit.Base._exportSymbols(this, MochiKit.Format); -} else { - (function (globals, module) { - if ((typeof(JSAN) == 'undefined' && typeof(dojo) == 'undefined') - || (MochiKit.__export__ === false)) { - var all = module.EXPORT_TAGS[":all"]; - for (var i = 0; i < all.length; i++) { - globals[all[i]] = module[all[i]]; - } - } - })(this, MochiKit.Format); -} diff --git a/javascript/libs/MochiKit/Iter.js b/javascript/libs/MochiKit/Iter.js deleted file mode 100644 index 3b8e095..0000000 --- a/javascript/libs/MochiKit/Iter.js +++ /dev/null @@ -1,851 +0,0 @@ -/*** - -MochiKit.Iter 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005 Bob Ippolito. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.Iter'); - dojo.require('MochiKit.Base'); -} - -if (typeof(JSAN) != 'undefined') { - JSAN.use("MochiKit.Base", []); -} - -try { - if (typeof(MochiKit.Base) == 'undefined') { - throw ""; - } -} catch (e) { - throw "MochiKit.Iter depends on MochiKit.Base!"; -} - -if (typeof(MochiKit.Iter) == 'undefined') { - MochiKit.Iter = {}; -} - -MochiKit.Iter.NAME = "MochiKit.Iter"; -MochiKit.Iter.VERSION = "1.4"; -MochiKit.Base.update(MochiKit.Iter, { - __repr__: function () { - return "[" + this.NAME + " " + this.VERSION + "]"; - }, - toString: function () { - return this.__repr__(); - }, - - /** @id MochiKit.Iter.registerIteratorFactory */ - registerIteratorFactory: function (name, check, iterfactory, /* optional */ override) { - MochiKit.Iter.iteratorRegistry.register(name, check, iterfactory, override); - }, - - /** @id MochiKit.Iter.iter */ - iter: function (iterable, /* optional */ sentinel) { - var self = MochiKit.Iter; - if (arguments.length == 2) { - return self.takewhile( - function (a) { return a != sentinel; }, - iterable - ); - } - if (typeof(iterable.next) == 'function') { - return iterable; - } else if (typeof(iterable.iter) == 'function') { - return iterable.iter(); - /* - } else if (typeof(iterable.__iterator__) == 'function') { - // - // XXX: We can't support JavaScript 1.7 __iterator__ directly - // because of Object.prototype.__iterator__ - // - return iterable.__iterator__(); - */ - } - - try { - return self.iteratorRegistry.match(iterable); - } catch (e) { - var m = MochiKit.Base; - if (e == m.NotFound) { - e = new TypeError(typeof(iterable) + ": " + m.repr(iterable) + " is not iterable"); - } - throw e; - } - }, - - /** @id MochiKit.Iter.count */ - count: function (n) { - if (!n) { - n = 0; - } - var m = MochiKit.Base; - return { - repr: function () { return "count(" + n + ")"; }, - toString: m.forwardCall("repr"), - next: m.counter(n) - }; - }, - - /** @id MochiKit.Iter.cycle */ - cycle: function (p) { - var self = MochiKit.Iter; - var m = MochiKit.Base; - var lst = []; - var iterator = self.iter(p); - return { - repr: function () { return "cycle(...)"; }, - toString: m.forwardCall("repr"), - next: function () { - try { - var rval = iterator.next(); - lst.push(rval); - return rval; - } catch (e) { - if (e != self.StopIteration) { - throw e; - } - if (lst.length === 0) { - this.next = function () { - throw self.StopIteration; - }; - } else { - var i = -1; - this.next = function () { - i = (i + 1) % lst.length; - return lst[i]; - }; - } - return this.next(); - } - } - }; - }, - - /** @id MochiKit.Iter.repeat */ - repeat: function (elem, /* optional */n) { - var m = MochiKit.Base; - if (typeof(n) == 'undefined') { - return { - repr: function () { - return "repeat(" + m.repr(elem) + ")"; - }, - toString: m.forwardCall("repr"), - next: function () { - return elem; - } - }; - } - return { - repr: function () { - return "repeat(" + m.repr(elem) + ", " + n + ")"; - }, - toString: m.forwardCall("repr"), - next: function () { - if (n <= 0) { - throw MochiKit.Iter.StopIteration; - } - n -= 1; - return elem; - } - }; - }, - - /** @id MochiKit.Iter.next */ - next: function (iterator) { - return iterator.next(); - }, - - /** @id MochiKit.Iter.izip */ - izip: function (p, q/*, ...*/) { - var m = MochiKit.Base; - var self = MochiKit.Iter; - var next = self.next; - var iterables = m.map(self.iter, arguments); - return { - repr: function () { return "izip(...)"; }, - toString: m.forwardCall("repr"), - next: function () { return m.map(next, iterables); } - }; - }, - - /** @id MochiKit.Iter.ifilter */ - ifilter: function (pred, seq) { - var m = MochiKit.Base; - seq = MochiKit.Iter.iter(seq); - if (pred === null) { - pred = m.operator.truth; - } - return { - repr: function () { return "ifilter(...)"; }, - toString: m.forwardCall("repr"), - next: function () { - while (true) { - var rval = seq.next(); - if (pred(rval)) { - return rval; - } - } - // mozilla warnings aren't too bright - return undefined; - } - }; - }, - - /** @id MochiKit.Iter.ifilterfalse */ - ifilterfalse: function (pred, seq) { - var m = MochiKit.Base; - seq = MochiKit.Iter.iter(seq); - if (pred === null) { - pred = m.operator.truth; - } - return { - repr: function () { return "ifilterfalse(...)"; }, - toString: m.forwardCall("repr"), - next: function () { - while (true) { - var rval = seq.next(); - if (!pred(rval)) { - return rval; - } - } - // mozilla warnings aren't too bright - return undefined; - } - }; - }, - - /** @id MochiKit.Iter.islice */ - islice: function (seq/*, [start,] stop[, step] */) { - var self = MochiKit.Iter; - var m = MochiKit.Base; - seq = self.iter(seq); - var start = 0; - var stop = 0; - var step = 1; - var i = -1; - if (arguments.length == 2) { - stop = arguments[1]; - } else if (arguments.length == 3) { - start = arguments[1]; - stop = arguments[2]; - } else { - start = arguments[1]; - stop = arguments[2]; - step = arguments[3]; - } - return { - repr: function () { - return "islice(" + ["...", start, stop, step].join(", ") + ")"; - }, - toString: m.forwardCall("repr"), - next: function () { - var rval; - while (i < start) { - rval = seq.next(); - i++; - } - if (start >= stop) { - throw self.StopIteration; - } - start += step; - return rval; - } - }; - }, - - /** @id MochiKit.Iter.imap */ - imap: function (fun, p, q/*, ...*/) { - var m = MochiKit.Base; - var self = MochiKit.Iter; - var iterables = m.map(self.iter, m.extend(null, arguments, 1)); - var map = m.map; - var next = self.next; - return { - repr: function () { return "imap(...)"; }, - toString: m.forwardCall("repr"), - next: function () { - return fun.apply(this, map(next, iterables)); - } - }; - }, - - /** @id MochiKit.Iter.applymap */ - applymap: function (fun, seq, self) { - seq = MochiKit.Iter.iter(seq); - var m = MochiKit.Base; - return { - repr: function () { return "applymap(...)"; }, - toString: m.forwardCall("repr"), - next: function () { - return fun.apply(self, seq.next()); - } - }; - }, - - /** @id MochiKit.Iter.chain */ - chain: function (p, q/*, ...*/) { - // dumb fast path - var self = MochiKit.Iter; - var m = MochiKit.Base; - if (arguments.length == 1) { - return self.iter(arguments[0]); - } - var argiter = m.map(self.iter, arguments); - return { - repr: function () { return "chain(...)"; }, - toString: m.forwardCall("repr"), - next: function () { - while (argiter.length > 1) { - try { - return argiter[0].next(); - } catch (e) { - if (e != self.StopIteration) { - throw e; - } - argiter.shift(); - } - } - if (argiter.length == 1) { - // optimize last element - var arg = argiter.shift(); - this.next = m.bind("next", arg); - return this.next(); - } - throw self.StopIteration; - } - }; - }, - - /** @id MochiKit.Iter.takewhile */ - takewhile: function (pred, seq) { - var self = MochiKit.Iter; - seq = self.iter(seq); - return { - repr: function () { return "takewhile(...)"; }, - toString: MochiKit.Base.forwardCall("repr"), - next: function () { - var rval = seq.next(); - if (!pred(rval)) { - this.next = function () { - throw self.StopIteration; - }; - this.next(); - } - return rval; - } - }; - }, - - /** @id MochiKit.Iter.dropwhile */ - dropwhile: function (pred, seq) { - seq = MochiKit.Iter.iter(seq); - var m = MochiKit.Base; - var bind = m.bind; - return { - "repr": function () { return "dropwhile(...)"; }, - "toString": m.forwardCall("repr"), - "next": function () { - while (true) { - var rval = seq.next(); - if (!pred(rval)) { - break; - } - } - this.next = bind("next", seq); - return rval; - } - }; - }, - - _tee: function (ident, sync, iterable) { - sync.pos[ident] = -1; - var m = MochiKit.Base; - var listMin = m.listMin; - return { - repr: function () { return "tee(" + ident + ", ...)"; }, - toString: m.forwardCall("repr"), - next: function () { - var rval; - var i = sync.pos[ident]; - - if (i == sync.max) { - rval = iterable.next(); - sync.deque.push(rval); - sync.max += 1; - sync.pos[ident] += 1; - } else { - rval = sync.deque[i - sync.min]; - sync.pos[ident] += 1; - if (i == sync.min && listMin(sync.pos) != sync.min) { - sync.min += 1; - sync.deque.shift(); - } - } - return rval; - } - }; - }, - - /** @id MochiKit.Iter.tee */ - tee: function (iterable, n/* = 2 */) { - var rval = []; - var sync = { - "pos": [], - "deque": [], - "max": -1, - "min": -1 - }; - if (arguments.length == 1 || typeof(n) == "undefined" || n === null) { - n = 2; - } - var self = MochiKit.Iter; - iterable = self.iter(iterable); - var _tee = self._tee; - for (var i = 0; i < n; i++) { - rval.push(_tee(i, sync, iterable)); - } - return rval; - }, - - /** @id MochiKit.Iter.list */ - list: function (iterable) { - // Fast-path for Array and Array-like - var rval; - if (iterable instanceof Array) { - return iterable.slice(); - } - // this is necessary to avoid a Safari crash - if (typeof(iterable) == "function" && - !(iterable instanceof Function) && - typeof(iterable.length) == 'number') { - rval = []; - for (var i = 0; i < iterable.length; i++) { - rval.push(iterable[i]); - } - return rval; - } - - var self = MochiKit.Iter; - iterable = self.iter(iterable); - var rval = []; - try { - while (true) { - rval.push(iterable.next()); - } - } catch (e) { - if (e != self.StopIteration) { - throw e; - } - return rval; - } - // mozilla warnings aren't too bright - return undefined; - }, - - - /** @id MochiKit.Iter.reduce */ - reduce: function (fn, iterable, /* optional */initial) { - var i = 0; - var x = initial; - var self = MochiKit.Iter; - iterable = self.iter(iterable); - if (arguments.length < 3) { - try { - x = iterable.next(); - } catch (e) { - if (e == self.StopIteration) { - e = new TypeError("reduce() of empty sequence with no initial value"); - } - throw e; - } - i++; - } - try { - while (true) { - x = fn(x, iterable.next()); - } - } catch (e) { - if (e != self.StopIteration) { - throw e; - } - } - return x; - }, - - /** @id MochiKit.Iter.range */ - range: function (/* [start,] stop[, step] */) { - var start = 0; - var stop = 0; - var step = 1; - if (arguments.length == 1) { - stop = arguments[0]; - } else if (arguments.length == 2) { - start = arguments[0]; - stop = arguments[1]; - } else if (arguments.length == 3) { - start = arguments[0]; - stop = arguments[1]; - step = arguments[2]; - } else { - throw new TypeError("range() takes 1, 2, or 3 arguments!"); - } - if (step === 0) { - throw new TypeError("range() step must not be 0"); - } - return { - next: function () { - if ((step > 0 && start >= stop) || (step < 0 && start <= stop)) { - throw MochiKit.Iter.StopIteration; - } - var rval = start; - start += step; - return rval; - }, - repr: function () { - return "range(" + [start, stop, step].join(", ") + ")"; - }, - toString: MochiKit.Base.forwardCall("repr") - }; - }, - - /** @id MochiKit.Iter.sum */ - sum: function (iterable, start/* = 0 */) { - if (typeof(start) == "undefined" || start === null) { - start = 0; - } - var x = start; - var self = MochiKit.Iter; - iterable = self.iter(iterable); - try { - while (true) { - x += iterable.next(); - } - } catch (e) { - if (e != self.StopIteration) { - throw e; - } - } - return x; - }, - - /** @id MochiKit.Iter.exhaust */ - exhaust: function (iterable) { - var self = MochiKit.Iter; - iterable = self.iter(iterable); - try { - while (true) { - iterable.next(); - } - } catch (e) { - if (e != self.StopIteration) { - throw e; - } - } - }, - - /** @id MochiKit.Iter.forEach */ - forEach: function (iterable, func, /* optional */self) { - var m = MochiKit.Base; - if (arguments.length > 2) { - func = m.bind(func, self); - } - // fast path for array - if (m.isArrayLike(iterable)) { - try { - for (var i = 0; i < iterable.length; i++) { - func(iterable[i]); - } - } catch (e) { - if (e != MochiKit.Iter.StopIteration) { - throw e; - } - } - } else { - self = MochiKit.Iter; - self.exhaust(self.imap(func, iterable)); - } - }, - - /** @id MochiKit.Iter.every */ - every: function (iterable, func) { - var self = MochiKit.Iter; - try { - self.ifilterfalse(func, iterable).next(); - return false; - } catch (e) { - if (e != self.StopIteration) { - throw e; - } - return true; - } - }, - - /** @id MochiKit.Iter.sorted */ - sorted: function (iterable, /* optional */cmp) { - var rval = MochiKit.Iter.list(iterable); - if (arguments.length == 1) { - cmp = MochiKit.Base.compare; - } - rval.sort(cmp); - return rval; - }, - - /** @id MochiKit.Iter.reversed */ - reversed: function (iterable) { - var rval = MochiKit.Iter.list(iterable); - rval.reverse(); - return rval; - }, - - /** @id MochiKit.Iter.some */ - some: function (iterable, func) { - var self = MochiKit.Iter; - try { - self.ifilter(func, iterable).next(); - return true; - } catch (e) { - if (e != self.StopIteration) { - throw e; - } - return false; - } - }, - - /** @id MochiKit.Iter.iextend */ - iextend: function (lst, iterable) { - if (MochiKit.Base.isArrayLike(iterable)) { - // fast-path for array-like - for (var i = 0; i < iterable.length; i++) { - lst.push(iterable[i]); - } - } else { - var self = MochiKit.Iter; - iterable = self.iter(iterable); - try { - while (true) { - lst.push(iterable.next()); - } - } catch (e) { - if (e != self.StopIteration) { - throw e; - } - } - } - return lst; - }, - - /** @id MochiKit.Iter.groupby */ - groupby: function(iterable, /* optional */ keyfunc) { - var m = MochiKit.Base; - var self = MochiKit.Iter; - if (arguments.length < 2) { - keyfunc = m.operator.identity; - } - iterable = self.iter(iterable); - - // shared - var pk = undefined; - var k = undefined; - var v; - - function fetch() { - v = iterable.next(); - k = keyfunc(v); - }; - - function eat() { - var ret = v; - v = undefined; - return ret; - }; - - var first = true; - var compare = m.compare; - return { - repr: function () { return "groupby(...)"; }, - next: function() { - // iterator-next - - // iterate until meet next group - while (compare(k, pk) === 0) { - fetch(); - if (first) { - first = false; - break; - } - } - pk = k; - return [k, { - next: function() { - // subiterator-next - if (v == undefined) { // Is there something to eat? - fetch(); - } - if (compare(k, pk) !== 0) { - throw self.StopIteration; - } - return eat(); - } - }]; - } - }; - }, - - /** @id MochiKit.Iter.groupby_as_array */ - groupby_as_array: function (iterable, /* optional */ keyfunc) { - var m = MochiKit.Base; - var self = MochiKit.Iter; - if (arguments.length < 2) { - keyfunc = m.operator.identity; - } - - iterable = self.iter(iterable); - var result = []; - var first = true; - var prev_key; - var compare = m.compare; - while (true) { - try { - var value = iterable.next(); - var key = keyfunc(value); - } catch (e) { - if (e == self.StopIteration) { - break; - } - throw e; - } - if (first || compare(key, prev_key) !== 0) { - var values = []; - result.push([key, values]); - } - values.push(value); - first = false; - prev_key = key; - } - return result; - }, - - /** @id MochiKit.Iter.arrayLikeIter */ - arrayLikeIter: function (iterable) { - var i = 0; - return { - repr: function () { return "arrayLikeIter(...)"; }, - toString: MochiKit.Base.forwardCall("repr"), - next: function () { - if (i >= iterable.length) { - throw MochiKit.Iter.StopIteration; - } - return iterable[i++]; - } - }; - }, - - /** @id MochiKit.Iter.hasIterateNext */ - hasIterateNext: function (iterable) { - return (iterable && typeof(iterable.iterateNext) == "function"); - }, - - /** @id MochiKit.Iter.iterateNextIter */ - iterateNextIter: function (iterable) { - return { - repr: function () { return "iterateNextIter(...)"; }, - toString: MochiKit.Base.forwardCall("repr"), - next: function () { - var rval = iterable.iterateNext(); - if (rval === null || rval === undefined) { - throw MochiKit.Iter.StopIteration; - } - return rval; - } - }; - } -}); - - -MochiKit.Iter.EXPORT_OK = [ - "iteratorRegistry", - "arrayLikeIter", - "hasIterateNext", - "iterateNextIter" -]; - -MochiKit.Iter.EXPORT = [ - "StopIteration", - "registerIteratorFactory", - "iter", - "count", - "cycle", - "repeat", - "next", - "izip", - "ifilter", - "ifilterfalse", - "islice", - "imap", - "applymap", - "chain", - "takewhile", - "dropwhile", - "tee", - "list", - "reduce", - "range", - "sum", - "exhaust", - "forEach", - "every", - "sorted", - "reversed", - "some", - "iextend", - "groupby", - "groupby_as_array" -]; - -MochiKit.Iter.__new__ = function () { - var m = MochiKit.Base; - // Re-use StopIteration if exists (e.g. SpiderMonkey) - if (typeof(StopIteration) != "undefined") { - this.StopIteration = StopIteration; - } else { - /** @id MochiKit.Iter.StopIteration */ - this.StopIteration = new m.NamedError("StopIteration"); - } - this.iteratorRegistry = new m.AdapterRegistry(); - // Register the iterator factory for arrays - this.registerIteratorFactory( - "arrayLike", - m.isArrayLike, - this.arrayLikeIter - ); - - this.registerIteratorFactory( - "iterateNext", - this.hasIterateNext, - this.iterateNextIter - ); - - this.EXPORT_TAGS = { - ":common": this.EXPORT, - ":all": m.concat(this.EXPORT, this.EXPORT_OK) - }; - - m.nameFunctions(this); - -}; - -MochiKit.Iter.__new__(); - -// -// XXX: Internet Explorer blows -// -if (MochiKit.__export__) { - reduce = MochiKit.Iter.reduce; -} - -MochiKit.Base._exportSymbols(this, MochiKit.Iter); diff --git a/javascript/libs/MochiKit/Logging.js b/javascript/libs/MochiKit/Logging.js deleted file mode 100644 index 4d25c3e..0000000 --- a/javascript/libs/MochiKit/Logging.js +++ /dev/null @@ -1,321 +0,0 @@ -/*** - -MochiKit.Logging 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005 Bob Ippolito. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.Logging'); - dojo.require('MochiKit.Base'); -} - -if (typeof(JSAN) != 'undefined') { - JSAN.use("MochiKit.Base", []); -} - -try { - if (typeof(MochiKit.Base) == 'undefined') { - throw ""; - } -} catch (e) { - throw "MochiKit.Logging depends on MochiKit.Base!"; -} - -if (typeof(MochiKit.Logging) == 'undefined') { - MochiKit.Logging = {}; -} - -MochiKit.Logging.NAME = "MochiKit.Logging"; -MochiKit.Logging.VERSION = "1.4"; -MochiKit.Logging.__repr__ = function () { - return "[" + this.NAME + " " + this.VERSION + "]"; -}; - -MochiKit.Logging.toString = function () { - return this.__repr__(); -}; - - -MochiKit.Logging.EXPORT = [ - "LogLevel", - "LogMessage", - "Logger", - "alertListener", - "logger", - "log", - "logError", - "logDebug", - "logFatal", - "logWarning" -]; - - -MochiKit.Logging.EXPORT_OK = [ - "logLevelAtLeast", - "isLogMessage", - "compareLogMessage" -]; - - -/** @id MochiKit.Logging.LogMessage */ -MochiKit.Logging.LogMessage = function (num, level, info) { - this.num = num; - this.level = level; - this.info = info; - this.timestamp = new Date(); -}; - -MochiKit.Logging.LogMessage.prototype = { - /** @id MochiKit.Logging.LogMessage.prototype.repr */ - repr: function () { - var m = MochiKit.Base; - return 'LogMessage(' + - m.map( - m.repr, - [this.num, this.level, this.info] - ).join(', ') + ')'; - }, - /** @id MochiKit.Logging.LogMessage.prototype.toString */ - toString: MochiKit.Base.forwardCall("repr") -}; - -MochiKit.Base.update(MochiKit.Logging, { - /** @id MochiKit.Logging.logLevelAtLeast */ - logLevelAtLeast: function (minLevel) { - var self = MochiKit.Logging; - if (typeof(minLevel) == 'string') { - minLevel = self.LogLevel[minLevel]; - } - return function (msg) { - var msgLevel = msg.level; - if (typeof(msgLevel) == 'string') { - msgLevel = self.LogLevel[msgLevel]; - } - return msgLevel >= minLevel; - }; - }, - - /** @id MochiKit.Logging.isLogMessage */ - isLogMessage: function (/* ... */) { - var LogMessage = MochiKit.Logging.LogMessage; - for (var i = 0; i < arguments.length; i++) { - if (!(arguments[i] instanceof LogMessage)) { - return false; - } - } - return true; - }, - - /** @id MochiKit.Logging.compareLogMessage */ - compareLogMessage: function (a, b) { - return MochiKit.Base.compare([a.level, a.info], [b.level, b.info]); - }, - - /** @id MochiKit.Logging.alertListener */ - alertListener: function (msg) { - alert( - "num: " + msg.num + - "\nlevel: " + msg.level + - "\ninfo: " + msg.info.join(" ") - ); - } - -}); - -/** @id MochiKit.Logging.Logger */ -MochiKit.Logging.Logger = function (/* optional */maxSize) { - this.counter = 0; - if (typeof(maxSize) == 'undefined' || maxSize === null) { - maxSize = -1; - } - this.maxSize = maxSize; - this._messages = []; - this.listeners = {}; - this.useNativeConsole = false; -}; - -MochiKit.Logging.Logger.prototype = { - /** @id MochiKit.Logging.Logger.prototype.clear */ - clear: function () { - this._messages.splice(0, this._messages.length); - }, - - /** @id MochiKit.Logging.Logger.prototype.logToConsole */ - logToConsole: function (msg) { - if (typeof(window) != "undefined" && window.console - && window.console.log) { - // Safari and FireBug 0.4 - // Percent replacement is a workaround for cute Safari crashing bug - window.console.log(msg.replace(/%/g, '\uFF05')); - } else if (typeof(opera) != "undefined" && opera.postError) { - // Opera - opera.postError(msg); - } else if (typeof(printfire) == "function") { - // FireBug 0.3 and earlier - printfire(msg); - } else if (typeof(Debug) != "undefined" && Debug.writeln) { - // IE Web Development Helper (?) - // http://www.nikhilk.net/Entry.aspx?id=93 - Debug.writeln(msg); - } else if (typeof(debug) != "undefined" && debug.trace) { - // Atlas framework (?) - // http://www.nikhilk.net/Entry.aspx?id=93 - debug.trace(msg); - } - }, - - /** @id MochiKit.Logging.Logger.prototype.dispatchListeners */ - dispatchListeners: function (msg) { - for (var k in this.listeners) { - var pair = this.listeners[k]; - if (pair.ident != k || (pair[0] && !pair[0](msg))) { - continue; - } - pair[1](msg); - } - }, - - /** @id MochiKit.Logging.Logger.prototype.addListener */ - addListener: function (ident, filter, listener) { - if (typeof(filter) == 'string') { - filter = MochiKit.Logging.logLevelAtLeast(filter); - } - var entry = [filter, listener]; - entry.ident = ident; - this.listeners[ident] = entry; - }, - - /** @id MochiKit.Logging.Logger.prototype.removeListener */ - removeListener: function (ident) { - delete this.listeners[ident]; - }, - - /** @id MochiKit.Logging.Logger.prototype.baseLog */ - baseLog: function (level, message/*, ...*/) { - var msg = new MochiKit.Logging.LogMessage( - this.counter, - level, - MochiKit.Base.extend(null, arguments, 1) - ); - this._messages.push(msg); - this.dispatchListeners(msg); - if (this.useNativeConsole) { - this.logToConsole(msg.level + ": " + msg.info.join(" ")); - } - this.counter += 1; - while (this.maxSize >= 0 && this._messages.length > this.maxSize) { - this._messages.shift(); - } - }, - - /** @id MochiKit.Logging.Logger.prototype.getMessages */ - getMessages: function (howMany) { - var firstMsg = 0; - if (!(typeof(howMany) == 'undefined' || howMany === null)) { - firstMsg = Math.max(0, this._messages.length - howMany); - } - return this._messages.slice(firstMsg); - }, - - /** @id MochiKit.Logging.Logger.prototype.getMessageText */ - getMessageText: function (howMany) { - if (typeof(howMany) == 'undefined' || howMany === null) { - howMany = 30; - } - var messages = this.getMessages(howMany); - if (messages.length) { - var lst = map(function (m) { - return '\n [' + m.num + '] ' + m.level + ': ' + m.info.join(' '); - }, messages); - lst.unshift('LAST ' + messages.length + ' MESSAGES:'); - return lst.join(''); - } - return ''; - }, - - /** @id MochiKit.Logging.Logger.prototype.debuggingBookmarklet */ - debuggingBookmarklet: function (inline) { - if (typeof(MochiKit.LoggingPane) == "undefined") { - alert(this.getMessageText()); - } else { - MochiKit.LoggingPane.createLoggingPane(inline || false); - } - } -}; - -MochiKit.Logging.__new__ = function () { - this.LogLevel = { - ERROR: 40, - FATAL: 50, - WARNING: 30, - INFO: 20, - DEBUG: 10 - }; - - var m = MochiKit.Base; - m.registerComparator("LogMessage", - this.isLogMessage, - this.compareLogMessage - ); - - var partial = m.partial; - - var Logger = this.Logger; - var baseLog = Logger.prototype.baseLog; - m.update(this.Logger.prototype, { - debug: partial(baseLog, 'DEBUG'), - log: partial(baseLog, 'INFO'), - error: partial(baseLog, 'ERROR'), - fatal: partial(baseLog, 'FATAL'), - warning: partial(baseLog, 'WARNING') - }); - - // indirectly find logger so it can be replaced - var self = this; - var connectLog = function (name) { - return function () { - self.logger[name].apply(self.logger, arguments); - }; - }; - - /** @id MochiKit.Logging.log */ - this.log = connectLog('log'); - /** @id MochiKit.Logging.logError */ - this.logError = connectLog('error'); - /** @id MochiKit.Logging.logDebug */ - this.logDebug = connectLog('debug'); - /** @id MochiKit.Logging.logFatal */ - this.logFatal = connectLog('fatal'); - /** @id MochiKit.Logging.logWarning */ - this.logWarning = connectLog('warning'); - this.logger = new Logger(); - this.logger.useNativeConsole = true; - - this.EXPORT_TAGS = { - ":common": this.EXPORT, - ":all": m.concat(this.EXPORT, this.EXPORT_OK) - }; - - m.nameFunctions(this); - -}; - -if (typeof(printfire) == "undefined" && - typeof(document) != "undefined" && document.createEvent && - typeof(dispatchEvent) != "undefined") { - // FireBug really should be less lame about this global function - printfire = function () { - printfire.args = arguments; - var ev = document.createEvent("Events"); - ev.initEvent("printfire", false, true); - dispatchEvent(ev); - }; -} - -MochiKit.Logging.__new__(); - -MochiKit.Base._exportSymbols(this, MochiKit.Logging); diff --git a/javascript/libs/MochiKit/LoggingPane.js b/javascript/libs/MochiKit/LoggingPane.js deleted file mode 100644 index 3798ae4..0000000 --- a/javascript/libs/MochiKit/LoggingPane.js +++ /dev/null @@ -1,374 +0,0 @@ -/*** - -MochiKit.LoggingPane 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005 Bob Ippolito. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.LoggingPane'); - dojo.require('MochiKit.Logging'); - dojo.require('MochiKit.Base'); -} - -if (typeof(JSAN) != 'undefined') { - JSAN.use("MochiKit.Logging", []); - JSAN.use("MochiKit.Base", []); -} - -try { - if (typeof(MochiKit.Base) == 'undefined' || typeof(MochiKit.Logging) == 'undefined') { - throw ""; - } -} catch (e) { - throw "MochiKit.LoggingPane depends on MochiKit.Base and MochiKit.Logging!"; -} - -if (typeof(MochiKit.LoggingPane) == 'undefined') { - MochiKit.LoggingPane = {}; -} - -MochiKit.LoggingPane.NAME = "MochiKit.LoggingPane"; -MochiKit.LoggingPane.VERSION = "1.4"; -MochiKit.LoggingPane.__repr__ = function () { - return "[" + this.NAME + " " + this.VERSION + "]"; -}; - -MochiKit.LoggingPane.toString = function () { - return this.__repr__(); -}; - -/** @id MochiKit.LoggingPane.createLoggingPane */ -MochiKit.LoggingPane.createLoggingPane = function (inline/* = false */) { - var m = MochiKit.LoggingPane; - inline = !(!inline); - if (m._loggingPane && m._loggingPane.inline != inline) { - m._loggingPane.closePane(); - m._loggingPane = null; - } - if (!m._loggingPane || m._loggingPane.closed) { - m._loggingPane = new m.LoggingPane(inline, MochiKit.Logging.logger); - } - return m._loggingPane; -}; - -/** @id MochiKit.LoggingPane.LoggingPane */ -MochiKit.LoggingPane.LoggingPane = function (inline/* = false */, logger/* = MochiKit.Logging.logger */) { - - /* Use a div if inline, pop up a window if not */ - /* Create the elements */ - if (typeof(logger) == "undefined" || logger === null) { - logger = MochiKit.Logging.logger; - } - this.logger = logger; - var update = MochiKit.Base.update; - var updatetree = MochiKit.Base.updatetree; - var bind = MochiKit.Base.bind; - var clone = MochiKit.Base.clone; - var win = window; - var uid = "_MochiKit_LoggingPane"; - if (typeof(MochiKit.DOM) != "undefined") { - win = MochiKit.DOM.currentWindow(); - } - if (!inline) { - // name the popup with the base URL for uniqueness - var url = win.location.href.split("?")[0].replace(/[#:\/.><&-]/g, "_"); - var name = uid + "_" + url; - var nwin = win.open("", name, "dependent,resizable,height=200"); - if (!nwin) { - alert("Not able to open debugging window due to pop-up blocking."); - return undefined; - } - nwin.document.write( - '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" ' - + '"http://www.w3.org/TR/html4/loose.dtd">' - + '<html><head><title>[MochiKit.LoggingPane]</title></head>' - + '<body></body></html>' - ); - nwin.document.close(); - nwin.document.title += ' ' + win.document.title; - win = nwin; - } - var doc = win.document; - this.doc = doc; - - // Connect to the debug pane if it already exists (i.e. in a window orphaned by the page being refreshed) - var debugPane = doc.getElementById(uid); - var existing_pane = !!debugPane; - if (debugPane && typeof(debugPane.loggingPane) != "undefined") { - debugPane.loggingPane.logger = this.logger; - debugPane.loggingPane.buildAndApplyFilter(); - return debugPane.loggingPane; - } - - if (existing_pane) { - // clear any existing contents - var child; - while ((child = debugPane.firstChild)) { - debugPane.removeChild(child); - } - } else { - debugPane = doc.createElement("div"); - debugPane.id = uid; - } - debugPane.loggingPane = this; - var levelFilterField = doc.createElement("input"); - var infoFilterField = doc.createElement("input"); - var filterButton = doc.createElement("button"); - var loadButton = doc.createElement("button"); - var clearButton = doc.createElement("button"); - var closeButton = doc.createElement("button"); - var logPaneArea = doc.createElement("div"); - var logPane = doc.createElement("div"); - - /* Set up the functions */ - var listenerId = uid + "_Listener"; - this.colorTable = clone(this.colorTable); - var messages = []; - var messageFilter = null; - - /** @id MochiKit.LoggingPane.messageLevel */ - var messageLevel = function (msg) { - var level = msg.level; - if (typeof(level) == "number") { - level = MochiKit.Logging.LogLevel[level]; - } - return level; - }; - - /** @id MochiKit.LoggingPane.messageText */ - var messageText = function (msg) { - return msg.info.join(" "); - }; - - /** @id MochiKit.LoggingPane.addMessageText */ - var addMessageText = bind(function (msg) { - var level = messageLevel(msg); - var text = messageText(msg); - var c = this.colorTable[level]; - var p = doc.createElement("span"); - p.className = "MochiKit-LogMessage MochiKit-LogLevel-" + level; - p.style.cssText = "margin: 0px; white-space: -moz-pre-wrap; white-space: -o-pre-wrap; white-space: pre-wrap; white-space: pre-line; word-wrap: break-word; wrap-option: emergency; color: " + c; - p.appendChild(doc.createTextNode(level + ": " + text)); - logPane.appendChild(p); - logPane.appendChild(doc.createElement("br")); - if (logPaneArea.offsetHeight > logPaneArea.scrollHeight) { - logPaneArea.scrollTop = 0; - } else { - logPaneArea.scrollTop = logPaneArea.scrollHeight; - } - }, this); - - /** @id MochiKit.LoggingPane.addMessage */ - var addMessage = function (msg) { - messages[messages.length] = msg; - addMessageText(msg); - }; - - /** @id MochiKit.LoggingPane.buildMessageFilter */ - var buildMessageFilter = function () { - var levelre, infore; - try { - /* Catch any exceptions that might arise due to invalid regexes */ - levelre = new RegExp(levelFilterField.value); - infore = new RegExp(infoFilterField.value); - } catch(e) { - /* If there was an error with the regexes, do no filtering */ - logDebug("Error in filter regex: " + e.message); - return null; - } - - return function (msg) { - return ( - levelre.test(messageLevel(msg)) && - infore.test(messageText(msg)) - ); - }; - }; - - /** @id MochiKit.LoggingPane.clearMessagePane */ - var clearMessagePane = function () { - while (logPane.firstChild) { - logPane.removeChild(logPane.firstChild); - } - }; - - /** @id MochiKit.LoggingPane.clearMessages */ - var clearMessages = function () { - messages = []; - clearMessagePane(); - }; - - /** @id MochiKit.LoggingPane.closePane */ - var closePane = bind(function () { - if (this.closed) { - return; - } - this.closed = true; - if (MochiKit.LoggingPane._loggingPane == this) { - MochiKit.LoggingPane._loggingPane = null; - } - this.logger.removeListener(listenerId); - try { - try { - debugPane.loggingPane = null; - } catch(e) { logFatal("Bookmarklet was closed incorrectly."); } - if (inline) { - debugPane.parentNode.removeChild(debugPane); - } else { - this.win.close(); - } - } catch(e) {} - }, this); - - /** @id MochiKit.LoggingPane.filterMessages */ - var filterMessages = function () { - clearMessagePane(); - - for (var i = 0; i < messages.length; i++) { - var msg = messages[i]; - if (messageFilter === null || messageFilter(msg)) { - addMessageText(msg); - } - } - }; - - this.buildAndApplyFilter = function () { - messageFilter = buildMessageFilter(); - - filterMessages(); - - this.logger.removeListener(listenerId); - this.logger.addListener(listenerId, messageFilter, addMessage); - }; - - - /** @id MochiKit.LoggingPane.loadMessages */ - var loadMessages = bind(function () { - messages = this.logger.getMessages(); - filterMessages(); - }, this); - - /** @id MochiKit.LoggingPane.filterOnEnter */ - var filterOnEnter = bind(function (event) { - event = event || window.event; - key = event.which || event.keyCode; - if (key == 13) { - this.buildAndApplyFilter(); - } - }, this); - - /* Create the debug pane */ - var style = "display: block; z-index: 1000; left: 0px; bottom: 0px; position: fixed; width: 100%; background-color: white; font: " + this.logFont; - if (inline) { - style += "; height: 10em; border-top: 2px solid black"; - } else { - style += "; height: 100%;"; - } - debugPane.style.cssText = style; - - if (!existing_pane) { - doc.body.appendChild(debugPane); - } - - /* Create the filter fields */ - style = {"cssText": "width: 33%; display: inline; font: " + this.logFont}; - - updatetree(levelFilterField, { - "value": "FATAL|ERROR|WARNING|INFO|DEBUG", - "onkeypress": filterOnEnter, - "style": style - }); - debugPane.appendChild(levelFilterField); - - updatetree(infoFilterField, { - "value": ".*", - "onkeypress": filterOnEnter, - "style": style - }); - debugPane.appendChild(infoFilterField); - - /* Create the buttons */ - style = "width: 8%; display:inline; font: " + this.logFont; - - filterButton.appendChild(doc.createTextNode("Filter")); - filterButton.onclick = bind("buildAndApplyFilter", this); - filterButton.style.cssText = style; - debugPane.appendChild(filterButton); - - loadButton.appendChild(doc.createTextNode("Load")); - loadButton.onclick = loadMessages; - loadButton.style.cssText = style; - debugPane.appendChild(loadButton); - - clearButton.appendChild(doc.createTextNode("Clear")); - clearButton.onclick = clearMessages; - clearButton.style.cssText = style; - debugPane.appendChild(clearButton); - - closeButton.appendChild(doc.createTextNode("Close")); - closeButton.onclick = closePane; - closeButton.style.cssText = style; - debugPane.appendChild(closeButton); - - /* Create the logging pane */ - logPaneArea.style.cssText = "overflow: auto; width: 100%"; - logPane.style.cssText = "width: 100%; height: " + (inline ? "8em" : "100%"); - - logPaneArea.appendChild(logPane); - debugPane.appendChild(logPaneArea); - - this.buildAndApplyFilter(); - loadMessages(); - - if (inline) { - this.win = undefined; - } else { - this.win = win; - } - this.inline = inline; - this.closePane = closePane; - this.closed = false; - - - return this; -}; - -MochiKit.LoggingPane.LoggingPane.prototype = { - "logFont": "8pt Verdana,sans-serif", - "colorTable": { - "ERROR": "red", - "FATAL": "darkred", - "WARNING": "blue", - "INFO": "black", - "DEBUG": "green" - } -}; - - -MochiKit.LoggingPane.EXPORT_OK = [ - "LoggingPane" -]; - -MochiKit.LoggingPane.EXPORT = [ - "createLoggingPane" -]; - -MochiKit.LoggingPane.__new__ = function () { - this.EXPORT_TAGS = { - ":common": this.EXPORT, - ":all": MochiKit.Base.concat(this.EXPORT, this.EXPORT_OK) - }; - - MochiKit.Base.nameFunctions(this); - - MochiKit.LoggingPane._loggingPane = null; - -}; - -MochiKit.LoggingPane.__new__(); - -MochiKit.Base._exportSymbols(this, MochiKit.LoggingPane); diff --git a/javascript/libs/MochiKit/MochiKit.js b/javascript/libs/MochiKit/MochiKit.js deleted file mode 100644 index 3a13b24..0000000 --- a/javascript/libs/MochiKit/MochiKit.js +++ /dev/null @@ -1,154 +0,0 @@ -/*** - -MochiKit.MochiKit 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005 Bob Ippolito. All rights Reserved. - -***/ - -if (typeof(MochiKit) == 'undefined') { - MochiKit = {}; -} - -if (typeof(MochiKit.MochiKit) == 'undefined') { - /** @id MochiKit.MochiKit */ - MochiKit.MochiKit = {}; -} - -MochiKit.MochiKit.NAME = "MochiKit.MochiKit"; -MochiKit.MochiKit.VERSION = "1.4"; -MochiKit.MochiKit.__repr__ = function () { - return "[" + this.NAME + " " + this.VERSION + "]"; -}; - -/** @id MochiKit.MochiKit.toString */ -MochiKit.MochiKit.toString = function () { - return this.__repr__(); -}; - -/** @id MochiKit.MochiKit.SUBMODULES */ -MochiKit.MochiKit.SUBMODULES = [ - "Base", - "Iter", - "Logging", - "DateTime", - "Format", - "Async", - "DOM", - "Selector", - "Style", - "LoggingPane", - "Color", - "Signal", - "Position", - "Visual" -]; - -if (typeof(JSAN) != 'undefined' || typeof(dojo) != 'undefined') { - if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.MochiKit'); - dojo.require("MochiKit.*"); - } - if (typeof(JSAN) != 'undefined') { - (function (lst) { - for (var i = 0; i < lst.length; i++) { - JSAN.use("MochiKit." + lst[i], []); - } - })(MochiKit.MochiKit.SUBMODULES); - } - (function () { - var extend = MochiKit.Base.extend; - var self = MochiKit.MochiKit; - var modules = self.SUBMODULES; - var EXPORT = []; - var EXPORT_OK = []; - var EXPORT_TAGS = {}; - var i, k, m, all; - for (i = 0; i < modules.length; i++) { - m = MochiKit[modules[i]]; - extend(EXPORT, m.EXPORT); - extend(EXPORT_OK, m.EXPORT_OK); - for (k in m.EXPORT_TAGS) { - EXPORT_TAGS[k] = extend(EXPORT_TAGS[k], m.EXPORT_TAGS[k]); - } - all = m.EXPORT_TAGS[":all"]; - if (!all) { - all = extend(null, m.EXPORT, m.EXPORT_OK); - } - var j; - for (j = 0; j < all.length; j++) { - k = all[j]; - self[k] = m[k]; - } - } - self.EXPORT = EXPORT; - self.EXPORT_OK = EXPORT_OK; - self.EXPORT_TAGS = EXPORT_TAGS; - }()); - -} else { - if (typeof(MochiKit.__compat__) == 'undefined') { - MochiKit.__compat__ = true; - } - (function () { - if (typeof(document) == "undefined") { - return; - } - var scripts = document.getElementsByTagName("script"); - var kXULNSURI = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; - var base = null; - var baseElem = null; - var allScripts = {}; - var i; - for (i = 0; i < scripts.length; i++) { - var src = scripts[i].getAttribute("src"); - if (!src) { - continue; - } - allScripts[src] = true; - if (src.match(/MochiKit.js$/)) { - base = src.substring(0, src.lastIndexOf('MochiKit.js')); - baseElem = scripts[i]; - } - } - if (base === null) { - return; - } - var modules = MochiKit.MochiKit.SUBMODULES; - for (var i = 0; i < modules.length; i++) { - if (MochiKit[modules[i]]) { - continue; - } - var uri = base + modules[i] + '.js'; - if (uri in allScripts) { - continue; - } - if (document.documentElement && - document.documentElement.namespaceURI == kXULNSURI) { - // XUL - var s = document.createElementNS(kXULNSURI, 'script'); - s.setAttribute("id", "MochiKit_" + base + modules[i]); - s.setAttribute("src", uri); - s.setAttribute("type", "application/x-javascript"); - baseElem.parentNode.appendChild(s); - } else { - // HTML - /* - DOM can not be used here because Safari does - deferred loading of scripts unless they are - in the document or inserted with document.write - - This is not XHTML compliant. If you want XHTML - compliance then you must use the packed version of MochiKit - or include each script individually (basically unroll - these document.write calls into your XHTML source) - - */ - document.write('<script src="' + uri + - '" type="text/javascript"></script>'); - } - }; - })(); -} diff --git a/javascript/libs/MochiKit/MockDOM.js b/javascript/libs/MochiKit/MockDOM.js deleted file mode 100644 index 92558cb..0000000 --- a/javascript/libs/MochiKit/MockDOM.js +++ /dev/null @@ -1,115 +0,0 @@ -/*** - -MochiKit.MockDOM 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005 Bob Ippolito. All rights Reserved. - -***/ - -if (typeof(MochiKit) == "undefined") { - MochiKit = {}; -} - -if (typeof(MochiKit.MockDOM) == "undefined") { - MochiKit.MockDOM = {}; -} - -MochiKit.MockDOM.NAME = "MochiKit.MockDOM"; -MochiKit.MockDOM.VERSION = "1.4"; - -MochiKit.MockDOM.__repr__ = function () { - return "[" + this.NAME + " " + this.VERSION + "]"; -}; - -/** @id MochiKit.MockDOM.toString */ -MochiKit.MockDOM.toString = function () { - return this.__repr__(); -}; - -/** @id MochiKit.MockDOM.createDocument */ -MochiKit.MockDOM.createDocument = function () { - var doc = new MochiKit.MockDOM.MockElement("DOCUMENT"); - doc.body = doc.createElement("BODY"); - doc.appendChild(doc.body); - return doc; -}; - -/** @id MochiKit.MockDOM.MockElement */ -MochiKit.MockDOM.MockElement = function (name, data, ownerDocument) { - this.tagName = this.nodeName = name.toUpperCase(); - this.ownerDocument = ownerDocument || null; - if (name == "DOCUMENT") { - this.nodeType = 9; - this.childNodes = []; - } else if (typeof(data) == "string") { - this.nodeValue = data; - this.nodeType = 3; - } else { - this.nodeType = 1; - this.childNodes = []; - } - if (name.substring(0, 1) == "<") { - var nameattr = name.substring( - name.indexOf('"') + 1, name.lastIndexOf('"')); - name = name.substring(1, name.indexOf(" ")); - this.tagName = this.nodeName = name.toUpperCase(); - this.setAttribute("name", nameattr); - } -}; - -MochiKit.MockDOM.MockElement.prototype = { - /** @id MochiKit.MockDOM.MockElement.prototype.createElement */ - createElement: function (tagName) { - return new MochiKit.MockDOM.MockElement(tagName, null, this.nodeType == 9 ? this : this.ownerDocument); - }, - /** @id MochiKit.MockDOM.MockElement.prototype.createTextNode */ - createTextNode: function (text) { - return new MochiKit.MockDOM.MockElement("text", text, this.nodeType == 9 ? this : this.ownerDocument); - }, - /** @id MochiKit.MockDOM.MockElement.prototype.setAttribute */ - setAttribute: function (name, value) { - this[name] = value; - }, - /** @id MochiKit.MockDOM.MockElement.prototype.getAttribute */ - getAttribute: function (name) { - return this[name]; - }, - /** @id MochiKit.MockDOM.MockElement.prototype.appendChild */ - appendChild: function (child) { - this.childNodes.push(child); - }, - /** @id MochiKit.MockDOM.MockElement.prototype.toString */ - toString: function () { - return "MockElement(" + this.tagName + ")"; - }, - /** @id MochiKit.MockDOM.MockElement.prototype.getElementsByTagName */ - getElementsByTagName: function (tagName) { - var foundElements = []; - MochiKit.Base.nodeWalk(this, function(node){ - if (tagName == '*' || tagName == node.tagName) { - foundElements.push(node); - return node.childNodes; - } - }); - return foundElements; - } -}; - - /** @id MochiKit.MockDOM.EXPORT_OK */ -MochiKit.MockDOM.EXPORT_OK = [ - "mockElement", - "createDocument" -]; - - /** @id MochiKit.MockDOM.EXPORT */ -MochiKit.MockDOM.EXPORT = [ - "document" -]; - -MochiKit.MockDOM.__new__ = function () { - this.document = this.createDocument(); -}; - -MochiKit.MockDOM.__new__(); diff --git a/javascript/libs/MochiKit/Position.js b/javascript/libs/MochiKit/Position.js deleted file mode 100644 index 23b0f18..0000000 --- a/javascript/libs/MochiKit/Position.js +++ /dev/null @@ -1,258 +0,0 @@ -/*** - -MochiKit.Position 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005-2006 Bob Ippolito and others. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.Position'); - dojo.require('MochiKit.Base'); - dojo.require('MochiKit.DOM'); - dojo.require('MochiKit.Style'); -} -if (typeof(JSAN) != 'undefined') { - JSAN.use('MochiKit.Base', []); - JSAN.use('MochiKit.DOM', []); - JSAN.use('MochiKit.Style', []); -} - -try { - if (typeof(MochiKit.Base) == 'undefined' || - typeof(MochiKit.Style) == 'undefined' || - typeof(MochiKit.DOM) == 'undefined') { - throw ''; - } -} catch (e) { - throw 'MochiKit.Style depends on MochiKit.Base, MochiKit.DOM, and MochiKit.Style!'; -} - -if (typeof(MochiKit.Position) == 'undefined') { - MochiKit.Position = {}; -} - -MochiKit.Position.NAME = 'MochiKit.Position'; -MochiKit.Position.VERSION = '1.4'; -MochiKit.Position.__repr__ = function () { - return '[' + this.NAME + ' ' + this.VERSION + ']'; -}; -MochiKit.Position.toString = function () { - return this.__repr__(); -}; - -MochiKit.Position.EXPORT_OK = []; - -MochiKit.Position.EXPORT = [ -]; - - -MochiKit.Base.update(MochiKit.Position, { - // set to true if needed, warning: firefox performance problems - // NOT neeeded for page scrolling, only if draggable contained in - // scrollable elements - includeScrollOffsets: false, - - /** @id MochiKit.Position.prepare */ - prepare: function () { - var deltaX = window.pageXOffset - || document.documentElement.scrollLeft - || document.body.scrollLeft - || 0; - var deltaY = window.pageYOffset - || document.documentElement.scrollTop - || document.body.scrollTop - || 0; - this.windowOffset = new MochiKit.Style.Coordinates(deltaX, deltaY); - }, - - /** @id MochiKit.Position.cumulativeOffset */ - cumulativeOffset: function (element) { - var valueT = 0; - var valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - } while (element); - return new MochiKit.Style.Coordinates(valueL, valueT); - }, - - /** @id MochiKit.Position.realOffset */ - realOffset: function (element) { - var valueT = 0; - var valueL = 0; - do { - valueT += element.scrollTop || 0; - valueL += element.scrollLeft || 0; - element = element.parentNode; - } while (element); - return new MochiKit.Style.Coordinates(valueL, valueT); - }, - - /** @id MochiKit.Position.within */ - within: function (element, x, y) { - if (this.includeScrollOffsets) { - return this.withinIncludingScrolloffsets(element, x, y); - } - this.xcomp = x; - this.ycomp = y; - this.offset = this.cumulativeOffset(element); - if (element.style.position == "fixed") { - this.offset.x += this.windowOffset.x; - this.offset.y += this.windowOffset.y; - } - - return (y >= this.offset.y && - y < this.offset.y + element.offsetHeight && - x >= this.offset.x && - x < this.offset.x + element.offsetWidth); - }, - - /** @id MochiKit.Position.withinIncludingScrolloffsets */ - withinIncludingScrolloffsets: function (element, x, y) { - var offsetcache = this.realOffset(element); - - this.xcomp = x + offsetcache.x - this.windowOffset.x; - this.ycomp = y + offsetcache.y - this.windowOffset.y; - this.offset = this.cumulativeOffset(element); - - return (this.ycomp >= this.offset.y && - this.ycomp < this.offset.y + element.offsetHeight && - this.xcomp >= this.offset.x && - this.xcomp < this.offset.x + element.offsetWidth); - }, - - // within must be called directly before - /** @id MochiKit.Position.overlap */ - overlap: function (mode, element) { - if (!mode) { - return 0; - } - if (mode == 'vertical') { - return ((this.offset.y + element.offsetHeight) - this.ycomp) / - element.offsetHeight; - } - if (mode == 'horizontal') { - return ((this.offset.x + element.offsetWidth) - this.xcomp) / - element.offsetWidth; - } - }, - - /** @id MochiKit.Position.absolutize */ - absolutize: function (element) { - element = MochiKit.DOM.getElement(element); - if (element.style.position == 'absolute') { - return; - } - MochiKit.Position.prepare(); - - var offsets = MochiKit.Position.positionedOffset(element); - var width = element.clientWidth; - var height = element.clientHeight; - - var oldStyle = { - 'position': element.style.position, - 'left': offsets.x - parseFloat(element.style.left || 0), - 'top': offsets.y - parseFloat(element.style.top || 0), - 'width': element.style.width, - 'height': element.style.height - }; - - element.style.position = 'absolute'; - element.style.top = offsets.y + 'px'; - element.style.left = offsets.x + 'px'; - element.style.width = width + 'px'; - element.style.height = height + 'px'; - - return oldStyle; - }, - - /** @id MochiKit.Position.positionedOffset */ - positionedOffset: function (element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - if (element) { - p = MochiKit.Style.getStyle(element, 'position'); - if (p == 'relative' || p == 'absolute') { - break; - } - } - } while (element); - return new MochiKit.Style.Coordinates(valueL, valueT); - }, - - /** @id MochiKit.Position.relativize */ - relativize: function (element, oldPos) { - element = MochiKit.DOM.getElement(element); - if (element.style.position == 'relative') { - return; - } - MochiKit.Position.prepare(); - - var top = parseFloat(element.style.top || 0) - - (oldPos['top'] || 0); - var left = parseFloat(element.style.left || 0) - - (oldPos['left'] || 0); - - element.style.position = oldPos['position']; - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.width = oldPos['width']; - element.style.height = oldPos['height']; - }, - - /** @id MochiKit.Position.clone */ - clone: function (source, target) { - source = MochiKit.DOM.getElement(source); - target = MochiKit.DOM.getElement(target); - target.style.position = 'absolute'; - var offsets = this.cumulativeOffset(source); - target.style.top = offsets.y + 'px'; - target.style.left = offsets.x + 'px'; - target.style.width = source.offsetWidth + 'px'; - target.style.height = source.offsetHeight + 'px'; - }, - - /** @id MochiKit.Position.page */ - page: function (forElement) { - var valueT = 0; - var valueL = 0; - - var element = forElement; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - - // Safari fix - if (element.offsetParent == document.body && MochiKit.Style.getStyle(element, 'position') == 'absolute') { - break; - } - } while (element = element.offsetParent); - - element = forElement; - do { - valueT -= element.scrollTop || 0; - valueL -= element.scrollLeft || 0; - } while (element = element.parentNode); - - return new MochiKit.Style.Coordinates(valueL, valueT); - } -}); - -MochiKit.Position.__new__ = function (win) { - var m = MochiKit.Base; - this.EXPORT_TAGS = { - ':common': this.EXPORT, - ':all': m.concat(this.EXPORT, this.EXPORT_OK) - }; - - m.nameFunctions(this); -}; - -MochiKit.Position.__new__(this);
\ No newline at end of file diff --git a/javascript/libs/MochiKit/Selector.js b/javascript/libs/MochiKit/Selector.js deleted file mode 100644 index f5d1afa..0000000 --- a/javascript/libs/MochiKit/Selector.js +++ /dev/null @@ -1,431 +0,0 @@ -/*** - -MochiKit.Selector 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005 Bob Ippolito and others. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.Selector'); - dojo.require('MochiKit.Base'); - dojo.require('MochiKit.DOM'); - dojo.require('MochiKit.Iter'); -} - -if (typeof(JSAN) != 'undefined') { - JSAN.use("MochiKit.Base", []); - JSAN.use("MochiKit.DOM", []); - JSAN.use("MochiKit.Iter", []); -} - -try { - if (typeof(MochiKit.Base) === 'undefined' || - typeof(MochiKit.DOM) === 'undefined' || - typeof(MochiKit.Iter) === 'undefined') { - throw ""; - } -} catch (e) { - throw "MochiKit.Selector depends on MochiKit.Base, MochiKit.DOM and MochiKit.Iter!"; -} - -if (typeof(MochiKit.Selector) == 'undefined') { - MochiKit.Selector = {}; -} - -MochiKit.Selector.NAME = "MochiKit.Selector"; - -MochiKit.Selector.VERSION = "1.4"; - -MochiKit.Selector.__repr__ = function () { - return "[" + this.NAME + " " + this.VERSION + "]"; -}; - -MochiKit.Selector.toString = function () { - return this.__repr__(); -}; - -MochiKit.Selector.EXPORT = [ - "Selector", - "findChildElements", - "findDocElements", - "$$" -]; - -MochiKit.Selector.EXPORT_OK = [ -]; - -MochiKit.Selector.Selector = function (expression) { - this.params = {classNames: [], pseudoClassNames: []}; - this.expression = expression.toString().replace(/(^\s+|\s+$)/g, ''); - this.parseExpression(); - this.compileMatcher(); -}; - -MochiKit.Selector.Selector.prototype = { - /*** - - Selector class: convenient object to make CSS selections. - - ***/ - __class__: MochiKit.Selector.Selector, - - /** @id MochiKit.Selector.Selector.prototype.parseExpression */ - parseExpression: function () { - function abort(message) { - throw 'Parse error in selector: ' + message; - } - - if (this.expression == '') { - abort('empty expression'); - } - - var repr = MochiKit.Base.repr; - var params = this.params; - var expr = this.expression; - var match, modifier, clause, rest; - while (match = expr.match(/^(.*)\[([a-z0-9_:-]+?)(?:([~\|!^$*]?=)(?:"([^"]*)"|([^\]\s]*)))?\]$/i)) { - params.attributes = params.attributes || []; - params.attributes.push({name: match[2], operator: match[3], value: match[4] || match[5] || ''}); - expr = match[1]; - } - - if (expr == '*') { - return this.params.wildcard = true; - } - - while (match = expr.match(/^([^a-z0-9_-])?([a-z0-9_-]+(?:\([^)]*\))?)(.*)/i)) { - modifier = match[1]; - clause = match[2]; - rest = match[3]; - switch (modifier) { - case '#': - params.id = clause; - break; - case '.': - params.classNames.push(clause); - break; - case ':': - params.pseudoClassNames.push(clause); - break; - case '': - case undefined: - params.tagName = clause.toUpperCase(); - break; - default: - abort(repr(expr)); - } - expr = rest; - } - - if (expr.length > 0) { - abort(repr(expr)); - } - }, - - /** @id MochiKit.Selector.Selector.prototype.buildMatchExpression */ - buildMatchExpression: function () { - var repr = MochiKit.Base.repr; - var params = this.params; - var conditions = []; - var clause, i; - - function childElements(element) { - return "MochiKit.Base.filter(function (node) { return node.nodeType == 1; }, " + element + ".childNodes)"; - } - - if (params.wildcard) { - conditions.push('true'); - } - if (clause = params.id) { - conditions.push('element.id == ' + repr(clause)); - } - if (clause = params.tagName) { - conditions.push('element.tagName.toUpperCase() == ' + repr(clause)); - } - if ((clause = params.classNames).length > 0) { - for (i = 0; i < clause.length; i++) { - conditions.push('MochiKit.DOM.hasElementClass(element, ' + repr(clause[i]) + ')'); - } - } - if ((clause = params.pseudoClassNames).length > 0) { - for (i = 0; i < clause.length; i++) { - var match = clause[i].match(/^([^(]+)(?:\((.*)\))?$/); - var pseudoClass = match[1]; - var pseudoClassArgument = match[2]; - switch (pseudoClass) { - case 'root': - conditions.push('element.nodeType == 9 || element === element.ownerDocument.documentElement'); break; - case 'nth-child': - case 'nth-last-child': - case 'nth-of-type': - case 'nth-last-of-type': - match = pseudoClassArgument.match(/^((?:(\d+)n\+)?(\d+)|odd|even)$/); - if (!match) { - throw "Invalid argument to pseudo element nth-child: " + pseudoClassArgument; - } - var a, b; - if (match[0] == 'odd') { - a = 2; - b = 1; - } else if (match[0] == 'even') { - a = 2; - b = 0; - } else { - a = match[2] && parseInt(match) || null; - b = parseInt(match[3]); - } - conditions.push('this.nthChild(element,' + a + ',' + b - + ',' + !!pseudoClass.match('^nth-last') // Reverse - + ',' + !!pseudoClass.match('of-type$') // Restrict to same tagName - + ')'); - break; - case 'first-child': - conditions.push('this.nthChild(element, null, 1)'); - break; - case 'last-child': - conditions.push('this.nthChild(element, null, 1, true)'); - break; - case 'first-of-type': - conditions.push('this.nthChild(element, null, 1, false, true)'); - break; - case 'last-of-type': - conditions.push('this.nthChild(element, null, 1, true, true)'); - break; - case 'only-child': - conditions.push(childElements('element.parentNode') + '.length == 1'); - break; - case 'only-of-type': - conditions.push('MochiKit.Base.filter(function (node) { return node.tagName == element.tagName; }, ' + childElements('element.parentNode') + ').length == 1'); - break; - case 'empty': - conditions.push('element.childNodes.length == 0'); - break; - case 'enabled': - conditions.push('(this.isUIElement(element) && element.disabled === false)'); - break; - case 'disabled': - conditions.push('(this.isUIElement(element) && element.disabled === true)'); - break; - case 'checked': - conditions.push('(this.isUIElement(element) && element.checked === true)'); - break; - case 'not': - var subselector = new MochiKit.Selector.Selector(pseudoClassArgument); - conditions.push('!( ' + subselector.buildMatchExpression() + ')') - break; - } - } - } - if (clause = params.attributes) { - MochiKit.Base.map(function (attribute) { - var value = 'MochiKit.DOM.getNodeAttribute(element, ' + repr(attribute.name) + ')'; - var splitValueBy = function (delimiter) { - return value + '.split(' + repr(delimiter) + ')'; - } - - switch (attribute.operator) { - case '=': - conditions.push(value + ' == ' + repr(attribute.value)); - break; - case '~=': - conditions.push(value + ' && MochiKit.Base.findValue(' + splitValueBy(' ') + ', ' + repr(attribute.value) + ') > -1'); - break; - case '^=': - conditions.push(value + '.substring(0, ' + attribute.value.length + ') == ' + repr(attribute.value)); - break; - case '$=': - conditions.push(value + '.substring(' + value + '.length - ' + attribute.value.length + ') == ' + repr(attribute.value)); - break; - case '*=': - conditions.push(value + '.match(' + repr(attribute.value) + ')'); - break; - case '|=': - conditions.push( - value + ' && ' + splitValueBy('-') + '[0].toUpperCase() == ' + repr(attribute.value.toUpperCase()) - ); - break; - case '!=': - conditions.push(value + ' != ' + repr(attribute.value)); - break; - case '': - case undefined: - conditions.push(value + ' != null'); - break; - default: - throw 'Unknown operator ' + attribute.operator + ' in selector'; - } - }, clause); - } - - return conditions.join(' && '); - }, - - /** @id MochiKit.Selector.Selector.prototype.compileMatcher */ - compileMatcher: function () { - this.match = new Function('element', 'if (!element.tagName) return false; \ - return ' + this.buildMatchExpression()); - }, - - /** @id MochiKit.Selector.Selector.prototype.nthChild */ - nthChild: function (element, a, b, reverse, sametag){ - var siblings = MochiKit.Base.filter(function (node) { - return node.nodeType == 1; - }, element.parentNode.childNodes); - if (sametag) { - siblings = MochiKit.Base.filter(function (node) { - return node.tagName == element.tagName; - }, siblings); - } - if (reverse) { - siblings = MochiKit.Iter.reversed(siblings); - } - if (a) { - var actualIndex = MochiKit.Base.findIdentical(siblings, element); - return ((actualIndex + 1 - b) / a) % 1 == 0; - } else { - return b == MochiKit.Base.findIdentical(siblings, element) + 1; - } - }, - - /** @id MochiKit.Selector.Selector.prototype.isUIElement */ - isUIElement: function (element) { - return MochiKit.Base.findValue(['input', 'button', 'select', 'option', 'textarea', 'object'], - element.tagName.toLowerCase()) > -1; - }, - - /** @id MochiKit.Selector.Selector.prototype.findElements */ - findElements: function (scope, axis) { - var element; - - if (axis == undefined) { - axis = ""; - } - - function inScope(element, scope) { - if (axis == "") { - return MochiKit.DOM.isChildNode(element, scope); - } else if (axis == ">") { - return element.parentNode == scope; - } else if (axis == "+") { - return element == nextSiblingElement(scope); - } else if (axis == "~") { - var sibling = scope; - while (sibling = nextSiblingElement(sibling)) { - if (element == sibling) { - return true; - } - } - return false; - } else { - throw "Invalid axis: " + axis; - } - } - - if (element = MochiKit.DOM.getElement(this.params.id)) { - if (this.match(element)) { - if (!scope || inScope(element, scope)) { - return [element]; - } - } - } - - function nextSiblingElement(node) { - node = node.nextSibling; - while (node && node.nodeType != 1) { - node = node.nextSibling; - } - return node; - } - - if (axis == "") { - scope = (scope || MochiKit.DOM.currentDocument()).getElementsByTagName(this.params.tagName || '*'); - } else if (axis == ">") { - if (!scope) { - throw "> combinator not allowed without preceeding expression"; - } - scope = MochiKit.Base.filter(function (node) { - return node.nodeType == 1; - }, scope.childNodes); - } else if (axis == "+") { - if (!scope) { - throw "+ combinator not allowed without preceeding expression"; - } - scope = nextSiblingElement(scope) && [nextSiblingElement(scope)]; - } else if (axis == "~") { - if (!scope) { - throw "~ combinator not allowed without preceeding expression"; - } - var newscope = []; - while (nextSiblingElement(scope)) { - scope = nextSiblingElement(scope); - newscope.push(scope); - } - scope = newscope; - } - - if (!scope) { - return []; - } - - var results = MochiKit.Base.filter(MochiKit.Base.bind(function (scopeElt) { - return this.match(scopeElt); - }, this), scope); - - return results; - }, - - /** @id MochiKit.Selector.Selector.prototype.repr */ - repr: function () { - return 'Selector(' + this.expression + ')'; - }, - - toString: MochiKit.Base.forwardCall("repr") -}; - -MochiKit.Base.update(MochiKit.Selector, { - - /** @id MochiKit.Selector.findChildElements */ - findChildElements: function (element, expressions) { - return MochiKit.Base.flattenArray(MochiKit.Base.map(function (expression) { - var nextScope = ""; - return MochiKit.Iter.reduce(function (results, expr) { - if (match = expr.match(/^[>+~]$/)) { - nextScope = match[0]; - return results; - } else { - var selector = new MochiKit.Selector.Selector(expr); - var elements = MochiKit.Iter.reduce(function (elements, result) { - return MochiKit.Base.extend(elements, selector.findElements(result || element, nextScope)); - }, results, []); - nextScope = ""; - return elements; - } - }, expression.replace(/(^\s+|\s+$)/g, '').split(/\s+/), [null]); - }, expressions)); - }, - - findDocElements: function () { - return MochiKit.Selector.findChildElements(MochiKit.DOM.currentDocument(), arguments); - }, - - __new__: function () { - var m = MochiKit.Base; - - this.$$ = this.findDocElements; - - this.EXPORT_TAGS = { - ":common": this.EXPORT, - ":all": m.concat(this.EXPORT, this.EXPORT_OK) - }; - - m.nameFunctions(this); - } -}); - -MochiKit.Selector.__new__(); - -MochiKit.Base._exportSymbols(this, MochiKit.Selector); - diff --git a/javascript/libs/MochiKit/Signal.js b/javascript/libs/MochiKit/Signal.js deleted file mode 100644 index de50240..0000000 --- a/javascript/libs/MochiKit/Signal.js +++ /dev/null @@ -1,903 +0,0 @@ -/*** - -MochiKit.Signal 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2006 Jonathan Gardner, Beau Hartshorne, Bob Ippolito. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.Signal'); - dojo.require('MochiKit.Base'); - dojo.require('MochiKit.DOM'); - dojo.require('MochiKit.Style'); -} -if (typeof(JSAN) != 'undefined') { - JSAN.use('MochiKit.Base', []); - JSAN.use('MochiKit.DOM', []); - JSAN.use('MochiKit.Style', []); -} - -try { - if (typeof(MochiKit.Base) == 'undefined') { - throw ''; - } -} catch (e) { - throw 'MochiKit.Signal depends on MochiKit.Base!'; -} - -try { - if (typeof(MochiKit.DOM) == 'undefined') { - throw ''; - } -} catch (e) { - throw 'MochiKit.Signal depends on MochiKit.DOM!'; -} - -try { - if (typeof(MochiKit.Style) == 'undefined') { - throw ''; - } -} catch (e) { - throw 'MochiKit.Signal depends on MochiKit.Style!'; -} - -if (typeof(MochiKit.Signal) == 'undefined') { - MochiKit.Signal = {}; -} - -MochiKit.Signal.NAME = 'MochiKit.Signal'; -MochiKit.Signal.VERSION = '1.4'; - -MochiKit.Signal._observers = []; - -/** @id MochiKit.Signal.Event */ -MochiKit.Signal.Event = function (src, e) { - this._event = e || window.event; - this._src = src; -}; - -MochiKit.Base.update(MochiKit.Signal.Event.prototype, { - - __repr__: function () { - var repr = MochiKit.Base.repr; - var str = '{event(): ' + repr(this.event()) + - ', src(): ' + repr(this.src()) + - ', type(): ' + repr(this.type()) + - ', target(): ' + repr(this.target()); - - if (this.type() && - this.type().indexOf('key') === 0 || - this.type().indexOf('mouse') === 0 || - this.type().indexOf('click') != -1 || - this.type() == 'contextmenu') { - str += ', modifier(): ' + '{alt: ' + repr(this.modifier().alt) + - ', ctrl: ' + repr(this.modifier().ctrl) + - ', meta: ' + repr(this.modifier().meta) + - ', shift: ' + repr(this.modifier().shift) + - ', any: ' + repr(this.modifier().any) + '}'; - } - - if (this.type() && this.type().indexOf('key') === 0) { - str += ', key(): {code: ' + repr(this.key().code) + - ', string: ' + repr(this.key().string) + '}'; - } - - if (this.type() && ( - this.type().indexOf('mouse') === 0 || - this.type().indexOf('click') != -1 || - this.type() == 'contextmenu')) { - - str += ', mouse(): {page: ' + repr(this.mouse().page) + - ', client: ' + repr(this.mouse().client); - - if (this.type() != 'mousemove') { - str += ', button: {left: ' + repr(this.mouse().button.left) + - ', middle: ' + repr(this.mouse().button.middle) + - ', right: ' + repr(this.mouse().button.right) + '}}'; - } else { - str += '}'; - } - } - if (this.type() == 'mouseover' || this.type() == 'mouseout') { - str += ', relatedTarget(): ' + repr(this.relatedTarget()); - } - str += '}'; - return str; - }, - - /** @id MochiKit.Signal.Event.prototype.toString */ - toString: function () { - return this.__repr__(); - }, - - /** @id MochiKit.Signal.Event.prototype.src */ - src: function () { - return this._src; - }, - - /** @id MochiKit.Signal.Event.prototype.event */ - event: function () { - return this._event; - }, - - /** @id MochiKit.Signal.Event.prototype.type */ - type: function () { - return this._event.type || undefined; - }, - - /** @id MochiKit.Signal.Event.prototype.target */ - target: function () { - return this._event.target || this._event.srcElement; - }, - - _relatedTarget: null, - /** @id MochiKit.Signal.Event.prototype.relatedTarget */ - relatedTarget: function () { - if (this._relatedTarget !== null) { - return this._relatedTarget; - } - - var elem = null; - if (this.type() == 'mouseover') { - elem = (this._event.relatedTarget || - this._event.fromElement); - } else if (this.type() == 'mouseout') { - elem = (this._event.relatedTarget || - this._event.toElement); - } - if (elem !== null) { - this._relatedTarget = elem; - return elem; - } - - return undefined; - }, - - _modifier: null, - /** @id MochiKit.Signal.Event.prototype.modifier */ - modifier: function () { - if (this._modifier !== null) { - return this._modifier; - } - var m = {}; - m.alt = this._event.altKey; - m.ctrl = this._event.ctrlKey; - m.meta = this._event.metaKey || false; // IE and Opera punt here - m.shift = this._event.shiftKey; - m.any = m.alt || m.ctrl || m.shift || m.meta; - this._modifier = m; - return m; - }, - - _key: null, - /** @id MochiKit.Signal.Event.prototype.key */ - key: function () { - if (this._key !== null) { - return this._key; - } - var k = {}; - if (this.type() && this.type().indexOf('key') === 0) { - - /* - - If you're looking for a special key, look for it in keydown or - keyup, but never keypress. If you're looking for a Unicode - chracter, look for it with keypress, but never keyup or - keydown. - - Notes: - - FF key event behavior: - key event charCode keyCode - DOWN ku,kd 0 40 - DOWN kp 0 40 - ESC ku,kd 0 27 - ESC kp 0 27 - a ku,kd 0 65 - a kp 97 0 - shift+a ku,kd 0 65 - shift+a kp 65 0 - 1 ku,kd 0 49 - 1 kp 49 0 - shift+1 ku,kd 0 0 - shift+1 kp 33 0 - - IE key event behavior: - (IE doesn't fire keypress events for special keys.) - key event keyCode - DOWN ku,kd 40 - DOWN kp undefined - ESC ku,kd 27 - ESC kp 27 - a ku,kd 65 - a kp 97 - shift+a ku,kd 65 - shift+a kp 65 - 1 ku,kd 49 - 1 kp 49 - shift+1 ku,kd 49 - shift+1 kp 33 - - Safari key event behavior: - (Safari sets charCode and keyCode to something crazy for - special keys.) - key event charCode keyCode - DOWN ku,kd 63233 40 - DOWN kp 63233 63233 - ESC ku,kd 27 27 - ESC kp 27 27 - a ku,kd 97 65 - a kp 97 97 - shift+a ku,kd 65 65 - shift+a kp 65 65 - 1 ku,kd 49 49 - 1 kp 49 49 - shift+1 ku,kd 33 49 - shift+1 kp 33 33 - - */ - - /* look for special keys here */ - if (this.type() == 'keydown' || this.type() == 'keyup') { - k.code = this._event.keyCode; - k.string = (MochiKit.Signal._specialKeys[k.code] || - 'KEY_UNKNOWN'); - this._key = k; - return k; - - /* look for characters here */ - } else if (this.type() == 'keypress') { - - /* - - Special key behavior: - - IE: does not fire keypress events for special keys - FF: sets charCode to 0, and sets the correct keyCode - Safari: sets keyCode and charCode to something stupid - - */ - - k.code = 0; - k.string = ''; - - if (typeof(this._event.charCode) != 'undefined' && - this._event.charCode !== 0 && - !MochiKit.Signal._specialMacKeys[this._event.charCode]) { - k.code = this._event.charCode; - k.string = String.fromCharCode(k.code); - } else if (this._event.keyCode && - typeof(this._event.charCode) == 'undefined') { // IE - k.code = this._event.keyCode; - k.string = String.fromCharCode(k.code); - } - - this._key = k; - return k; - } - } - return undefined; - }, - - _mouse: null, - /** @id MochiKit.Signal.Event.prototype.mouse */ - mouse: function () { - if (this._mouse !== null) { - return this._mouse; - } - - var m = {}; - var e = this._event; - - if (this.type() && ( - this.type().indexOf('mouse') === 0 || - this.type().indexOf('click') != -1 || - this.type() == 'contextmenu')) { - - m.client = new MochiKit.Style.Coordinates(0, 0); - if (e.clientX || e.clientY) { - m.client.x = (!e.clientX || e.clientX < 0) ? 0 : e.clientX; - m.client.y = (!e.clientY || e.clientY < 0) ? 0 : e.clientY; - } - - m.page = new MochiKit.Style.Coordinates(0, 0); - if (e.pageX || e.pageY) { - m.page.x = (!e.pageX || e.pageX < 0) ? 0 : e.pageX; - m.page.y = (!e.pageY || e.pageY < 0) ? 0 : e.pageY; - } else { - /* - - The IE shortcut can be off by two. We fix it. See: - http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/getboundingclientrect.asp - - This is similar to the method used in - MochiKit.Style.getElementPosition(). - - */ - var de = MochiKit.DOM._document.documentElement; - var b = MochiKit.DOM._document.body; - - m.page.x = e.clientX + - (de.scrollLeft || b.scrollLeft) - - (de.clientLeft || 0); - - m.page.y = e.clientY + - (de.scrollTop || b.scrollTop) - - (de.clientTop || 0); - - } - if (this.type() != 'mousemove') { - m.button = {}; - m.button.left = false; - m.button.right = false; - m.button.middle = false; - - /* we could check e.button, but which is more consistent */ - if (e.which) { - m.button.left = (e.which == 1); - m.button.middle = (e.which == 2); - m.button.right = (e.which == 3); - - /* - - Mac browsers and right click: - - - Safari doesn't fire any click events on a right - click: - http://bugs.webkit.org/show_bug.cgi?id=6595 - - - Firefox fires the event, and sets ctrlKey = true - - - Opera fires the event, and sets metaKey = true - - oncontextmenu is fired on right clicks between - browsers and across platforms. - - */ - - } else { - m.button.left = !!(e.button & 1); - m.button.right = !!(e.button & 2); - m.button.middle = !!(e.button & 4); - } - } - this._mouse = m; - return m; - } - return undefined; - }, - - /** @id MochiKit.Signal.Event.prototype.stop */ - stop: function () { - this.stopPropagation(); - this.preventDefault(); - }, - - /** @id MochiKit.Signal.Event.prototype.stopPropagation */ - stopPropagation: function () { - if (this._event.stopPropagation) { - this._event.stopPropagation(); - } else { - this._event.cancelBubble = true; - } - }, - - /** @id MochiKit.Signal.Event.prototype.preventDefault */ - preventDefault: function () { - if (this._event.preventDefault) { - this._event.preventDefault(); - } else if (this._confirmUnload === null) { - this._event.returnValue = false; - } - }, - - _confirmUnload: null, - - /** @id MochiKit.Signal.Event.prototype.confirmUnload */ - confirmUnload: function (msg) { - if (this.type() == 'beforeunload') { - this._confirmUnload = msg; - this._event.returnValue = msg; - } - } -}); - -/* Safari sets keyCode to these special values onkeypress. */ -MochiKit.Signal._specialMacKeys = { - 3: 'KEY_ENTER', - 63289: 'KEY_NUM_PAD_CLEAR', - 63276: 'KEY_PAGE_UP', - 63277: 'KEY_PAGE_DOWN', - 63275: 'KEY_END', - 63273: 'KEY_HOME', - 63234: 'KEY_ARROW_LEFT', - 63232: 'KEY_ARROW_UP', - 63235: 'KEY_ARROW_RIGHT', - 63233: 'KEY_ARROW_DOWN', - 63302: 'KEY_INSERT', - 63272: 'KEY_DELETE' -}; - -/* for KEY_F1 - KEY_F12 */ -(function () { - var _specialMacKeys = MochiKit.Signal._specialMacKeys; - for (i = 63236; i <= 63242; i++) { - // no F0 - _specialMacKeys[i] = 'KEY_F' + (i - 63236 + 1); - } -})(); - -/* Standard keyboard key codes. */ -MochiKit.Signal._specialKeys = { - 8: 'KEY_BACKSPACE', - 9: 'KEY_TAB', - 12: 'KEY_NUM_PAD_CLEAR', // weird, for Safari and Mac FF only - 13: 'KEY_ENTER', - 16: 'KEY_SHIFT', - 17: 'KEY_CTRL', - 18: 'KEY_ALT', - 19: 'KEY_PAUSE', - 20: 'KEY_CAPS_LOCK', - 27: 'KEY_ESCAPE', - 32: 'KEY_SPACEBAR', - 33: 'KEY_PAGE_UP', - 34: 'KEY_PAGE_DOWN', - 35: 'KEY_END', - 36: 'KEY_HOME', - 37: 'KEY_ARROW_LEFT', - 38: 'KEY_ARROW_UP', - 39: 'KEY_ARROW_RIGHT', - 40: 'KEY_ARROW_DOWN', - 44: 'KEY_PRINT_SCREEN', - 45: 'KEY_INSERT', - 46: 'KEY_DELETE', - 59: 'KEY_SEMICOLON', // weird, for Safari and IE only - 91: 'KEY_WINDOWS_LEFT', - 92: 'KEY_WINDOWS_RIGHT', - 93: 'KEY_SELECT', - 106: 'KEY_NUM_PAD_ASTERISK', - 107: 'KEY_NUM_PAD_PLUS_SIGN', - 109: 'KEY_NUM_PAD_HYPHEN-MINUS', - 110: 'KEY_NUM_PAD_FULL_STOP', - 111: 'KEY_NUM_PAD_SOLIDUS', - 144: 'KEY_NUM_LOCK', - 145: 'KEY_SCROLL_LOCK', - 186: 'KEY_SEMICOLON', - 187: 'KEY_EQUALS_SIGN', - 188: 'KEY_COMMA', - 189: 'KEY_HYPHEN-MINUS', - 190: 'KEY_FULL_STOP', - 191: 'KEY_SOLIDUS', - 192: 'KEY_GRAVE_ACCENT', - 219: 'KEY_LEFT_SQUARE_BRACKET', - 220: 'KEY_REVERSE_SOLIDUS', - 221: 'KEY_RIGHT_SQUARE_BRACKET', - 222: 'KEY_APOSTROPHE' - // undefined: 'KEY_UNKNOWN' -}; - -(function () { - /* for KEY_0 - KEY_9 */ - var _specialKeys = MochiKit.Signal._specialKeys; - for (var i = 48; i <= 57; i++) { - _specialKeys[i] = 'KEY_' + (i - 48); - } - - /* for KEY_A - KEY_Z */ - for (i = 65; i <= 90; i++) { - _specialKeys[i] = 'KEY_' + String.fromCharCode(i); - } - - /* for KEY_NUM_PAD_0 - KEY_NUM_PAD_9 */ - for (i = 96; i <= 105; i++) { - _specialKeys[i] = 'KEY_NUM_PAD_' + (i - 96); - } - - /* for KEY_F1 - KEY_F12 */ - for (i = 112; i <= 123; i++) { - // no F0 - _specialKeys[i] = 'KEY_F' + (i - 112 + 1); - } -})(); - -/* Internal object to keep track of created signals. */ -MochiKit.Signal.Ident = function (ident) { - this.source = ident.source; - this.signal = ident.signal; - this.listener = ident.listener; - this.isDOM = ident.isDOM; - this.objOrFunc = ident.objOrFunc; - this.funcOrStr = ident.funcOrStr; - this.connected = ident.connected; -}; - -MochiKit.Signal.Ident.prototype = {}; - -MochiKit.Base.update(MochiKit.Signal, { - - __repr__: function () { - return '[' + this.NAME + ' ' + this.VERSION + ']'; - }, - - toString: function () { - return this.__repr__(); - }, - - _unloadCache: function () { - var self = MochiKit.Signal; - var observers = self._observers; - - for (var i = 0; i < observers.length; i++) { - if (observers[i].signal !== 'onload' && observers[i].signal !== 'onunload') { - self._disconnect(observers[i]); - } - } - }, - - _listener: function (src, sig, func, obj, isDOM) { - var self = MochiKit.Signal; - var E = self.Event; - if (!isDOM) { - /* We don't want to re-bind already bound methods */ - if (typeof(func.im_self) == 'undefined') { - return MochiKit.Base.bind(func, obj); - } else { - return func; - } - } - obj = obj || src; - if (typeof(func) == "string") { - if (sig === 'onload' || sig === 'onunload') { - return function (nativeEvent) { - obj[func].apply(obj, [new E(src, nativeEvent)]); - - var ident = new MochiKit.Signal.Ident({ - source: src, signal: sig, objOrFunc: obj, funcOrStr: func}); - - MochiKit.Signal._disconnect(ident); - }; - } else { - return function (nativeEvent) { - obj[func].apply(obj, [new E(src, nativeEvent)]); - }; - } - } else { - if (sig === 'onload' || sig === 'onunload') { - return function (nativeEvent) { - func.apply(obj, [new E(src, nativeEvent)]); - - var ident = new MochiKit.Signal.Ident({ - source: src, signal: sig, objOrFunc: func}); - - MochiKit.Signal._disconnect(ident); - }; - } else { - return function (nativeEvent) { - func.apply(obj, [new E(src, nativeEvent)]); - }; - } - } - }, - - _browserAlreadyHasMouseEnterAndLeave: function () { - return /MSIE/.test(navigator.userAgent); - }, - - _mouseEnterListener: function (src, sig, func, obj) { - var E = MochiKit.Signal.Event; - return function (nativeEvent) { - var e = new E(src, nativeEvent); - try { - e.relatedTarget().nodeName; - } catch (err) { - /* probably hit a permission denied error; possibly one of - * firefox's screwy anonymous DIVs inside an input element. - * Allow this event to propogate up. - */ - return; - } - e.stop(); - if (MochiKit.DOM.isChildNode(e.relatedTarget(), src)) { - /* We've moved between our node and a child. Ignore. */ - return; - } - e.type = function () { return sig; }; - if (typeof(func) == "string") { - return obj[func].apply(obj, [e]); - } else { - return func.apply(obj, [e]); - } - }; - }, - - _getDestPair: function (objOrFunc, funcOrStr) { - var obj = null; - var func = null; - if (typeof(funcOrStr) != 'undefined') { - obj = objOrFunc; - func = funcOrStr; - if (typeof(funcOrStr) == 'string') { - if (typeof(objOrFunc[funcOrStr]) != "function") { - throw new Error("'funcOrStr' must be a function on 'objOrFunc'"); - } - } else if (typeof(funcOrStr) != 'function') { - throw new Error("'funcOrStr' must be a function or string"); - } - } else if (typeof(objOrFunc) != "function") { - throw new Error("'objOrFunc' must be a function if 'funcOrStr' is not given"); - } else { - func = objOrFunc; - } - return [obj, func]; - }, - - /** @id MochiKit.Signal.connect */ - connect: function (src, sig, objOrFunc/* optional */, funcOrStr) { - src = MochiKit.DOM.getElement(src); - var self = MochiKit.Signal; - - if (typeof(sig) != 'string') { - throw new Error("'sig' must be a string"); - } - - var destPair = self._getDestPair(objOrFunc, funcOrStr); - var obj = destPair[0]; - var func = destPair[1]; - if (typeof(obj) == 'undefined' || obj === null) { - obj = src; - } - - var isDOM = !!(src.addEventListener || src.attachEvent); - if (isDOM && (sig === "onmouseenter" || sig === "onmouseleave") - && !self._browserAlreadyHasMouseEnterAndLeave()) { - var listener = self._mouseEnterListener(src, sig.substr(2), func, obj); - if (sig === "onmouseenter") { - sig = "onmouseover"; - } else { - sig = "onmouseout"; - } - } else { - var listener = self._listener(src, sig, func, obj, isDOM); - } - - if (src.addEventListener) { - src.addEventListener(sig.substr(2), listener, false); - } else if (src.attachEvent) { - src.attachEvent(sig, listener); // useCapture unsupported - } - - var ident = new MochiKit.Signal.Ident({ - source: src, - signal: sig, - listener: listener, - isDOM: isDOM, - objOrFunc: objOrFunc, - funcOrStr: funcOrStr, - connected: true - }); - self._observers.push(ident); - - if (!isDOM && typeof(src.__connect__) == 'function') { - var args = MochiKit.Base.extend([ident], arguments, 1); - src.__connect__.apply(src, args); - } - - return ident; - }, - - _disconnect: function (ident) { - // already disconnected - if (!ident.connected) { - return; - } - ident.connected = false; - // check isDOM - if (!ident.isDOM) { - return; - } - var src = ident.source; - var sig = ident.signal; - var listener = ident.listener; - - if (src.removeEventListener) { - src.removeEventListener(sig.substr(2), listener, false); - } else if (src.detachEvent) { - src.detachEvent(sig, listener); // useCapture unsupported - } else { - throw new Error("'src' must be a DOM element"); - } - }, - - /** @id MochiKit.Signal.disconnect */ - disconnect: function (ident) { - var self = MochiKit.Signal; - var observers = self._observers; - var m = MochiKit.Base; - if (arguments.length > 1) { - // compatibility API - var src = MochiKit.DOM.getElement(arguments[0]); - var sig = arguments[1]; - var obj = arguments[2]; - var func = arguments[3]; - for (var i = observers.length - 1; i >= 0; i--) { - var o = observers[i]; - if (o.source === src && o.signal === sig && o.objOrFunc === obj && o.funcOrStr === func) { - self._disconnect(o); - if (!self._lock) { - observers.splice(i, 1); - } else { - self._dirty = true; - } - return true; - } - } - } else { - var idx = m.findIdentical(observers, ident); - if (idx >= 0) { - self._disconnect(ident); - if (!self._lock) { - observers.splice(idx, 1); - } else { - self._dirty = true; - } - return true; - } - } - return false; - }, - - /** @id MochiKit.Signal.disconnectAllTo */ - disconnectAllTo: function (objOrFunc, /* optional */funcOrStr) { - var self = MochiKit.Signal; - var observers = self._observers; - var disconnect = self._disconnect; - var locked = self._lock; - var dirty = self._dirty; - if (typeof(funcOrStr) === 'undefined') { - funcOrStr = null; - } - for (var i = observers.length - 1; i >= 0; i--) { - var ident = observers[i]; - if (ident.objOrFunc === objOrFunc && - (funcOrStr === null || ident.funcOrStr === funcOrStr)) { - disconnect(ident); - if (locked) { - dirty = true; - } else { - observers.splice(i, 1); - } - } - } - self._dirty = dirty; - }, - - /** @id MochiKit.Signal.disconnectAll */ - disconnectAll: function (src/* optional */, sig) { - src = MochiKit.DOM.getElement(src); - var m = MochiKit.Base; - var signals = m.flattenArguments(m.extend(null, arguments, 1)); - var self = MochiKit.Signal; - var disconnect = self._disconnect; - var observers = self._observers; - var i, ident; - var locked = self._lock; - var dirty = self._dirty; - if (signals.length === 0) { - // disconnect all - for (i = observers.length - 1; i >= 0; i--) { - ident = observers[i]; - if (ident.source === src) { - disconnect(ident); - if (!locked) { - observers.splice(i, 1); - } else { - dirty = true; - } - } - } - } else { - var sigs = {}; - for (i = 0; i < signals.length; i++) { - sigs[signals[i]] = true; - } - for (i = observers.length - 1; i >= 0; i--) { - ident = observers[i]; - if (ident.source === src && ident.signal in sigs) { - disconnect(ident); - if (!locked) { - observers.splice(i, 1); - } else { - dirty = true; - } - } - } - } - self._dirty = dirty; - }, - - /** @id MochiKit.Signal.signal */ - signal: function (src, sig) { - var self = MochiKit.Signal; - var observers = self._observers; - src = MochiKit.DOM.getElement(src); - var args = MochiKit.Base.extend(null, arguments, 2); - var errors = []; - self._lock = true; - for (var i = 0; i < observers.length; i++) { - var ident = observers[i]; - if (ident.source === src && ident.signal === sig && - ident.connected) { - try { - ident.listener.apply(src, args); - } catch (e) { - errors.push(e); - } - } - } - self._lock = false; - if (self._dirty) { - self._dirty = false; - for (var i = observers.length - 1; i >= 0; i--) { - if (!observers[i].connected) { - observers.splice(i, 1); - } - } - } - if (errors.length == 1) { - throw errors[0]; - } else if (errors.length > 1) { - var e = new Error("Multiple errors thrown in handling 'sig', see errors property"); - e.errors = errors; - throw e; - } - } - -}); - -MochiKit.Signal.EXPORT_OK = []; - -MochiKit.Signal.EXPORT = [ - 'connect', - 'disconnect', - 'signal', - 'disconnectAll', - 'disconnectAllTo' -]; - -MochiKit.Signal.__new__ = function (win) { - var m = MochiKit.Base; - this._document = document; - this._window = win; - this._lock = false; - this._dirty = false; - - try { - this.connect(window, 'onunload', this._unloadCache); - } catch (e) { - // pass: might not be a browser - } - - this.EXPORT_TAGS = { - ':common': this.EXPORT, - ':all': m.concat(this.EXPORT, this.EXPORT_OK) - }; - - m.nameFunctions(this); -}; - -MochiKit.Signal.__new__(this); - -// -// XXX: Internet Explorer blows -// -if (MochiKit.__export__) { - connect = MochiKit.Signal.connect; - disconnect = MochiKit.Signal.disconnect; - disconnectAll = MochiKit.Signal.disconnectAll; - signal = MochiKit.Signal.signal; -} - -MochiKit.Base._exportSymbols(this, MochiKit.Signal); diff --git a/javascript/libs/MochiKit/Sortable.js b/javascript/libs/MochiKit/Sortable.js deleted file mode 100644 index 8976ec0..0000000 --- a/javascript/libs/MochiKit/Sortable.js +++ /dev/null @@ -1,589 +0,0 @@ -/*** -Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) - Mochi-ized By Thomas Herve (_firstname_@nimail.org) - -See scriptaculous.js for full license. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.Sortable'); - dojo.require('MochiKit.Base'); - dojo.require('MochiKit.DOM'); - dojo.require('MochiKit.Iter'); -} - -if (typeof(JSAN) != 'undefined') { - JSAN.use("MochiKit.Base", []); - JSAN.use("MochiKit.DOM", []); - JSAN.use("MochiKit.Iter", []); -} - -try { - if (typeof(MochiKit.Base) == 'undefined' || - typeof(MochiKit.DOM) == 'undefined' || - typeof(MochiKit.Iter) == 'undefined') { - throw ""; - } -} catch (e) { - throw "MochiKit.DragAndDrop depends on MochiKit.Base, MochiKit.DOM and MochiKit.Iter!"; -} - -if (typeof(MochiKit.Sortable) == 'undefined') { - MochiKit.Sortable = {}; -} - -MochiKit.Sortable.NAME = 'MochiKit.Sortable'; -MochiKit.Sortable.VERSION = '1.4'; - -MochiKit.Sortable.__repr__ = function () { - return '[' + this.NAME + ' ' + this.VERSION + ']'; -}; - -MochiKit.Sortable.toString = function () { - return this.__repr__(); -}; - -MochiKit.Sortable.EXPORT = [ -]; - -MochiKit.Sortable.EXPORT_OK = [ -]; - -MochiKit.Base.update(MochiKit.Sortable, { - /*** - - Manage sortables. Mainly use the create function to add a sortable. - - ***/ - sortables: {}, - - _findRootElement: function (element) { - while (element.tagName.toUpperCase() != "BODY") { - if (element.id && MochiKit.Sortable.sortables[element.id]) { - return element; - } - element = element.parentNode; - } - }, - - /** @id MochiKit.Sortable.options */ - options: function (element) { - element = MochiKit.Sortable._findRootElement(MochiKit.DOM.getElement(element)); - if (!element) { - return; - } - return MochiKit.Sortable.sortables[element.id]; - }, - - /** @id MochiKit.Sortable.destroy */ - destroy: function (element){ - var s = MochiKit.Sortable.options(element); - var b = MochiKit.Base; - var d = MochiKit.DragAndDrop; - - if (s) { - MochiKit.Signal.disconnect(s.startHandle); - MochiKit.Signal.disconnect(s.endHandle); - b.map(function (dr) { - d.Droppables.remove(dr); - }, s.droppables); - b.map(function (dr) { - dr.destroy(); - }, s.draggables); - - delete MochiKit.Sortable.sortables[s.element.id]; - } - }, - - /** @id MochiKit.Sortable.create */ - create: function (element, options) { - element = MochiKit.DOM.getElement(element); - var self = MochiKit.Sortable; - - /** @id MochiKit.Sortable.options */ - options = MochiKit.Base.update({ - - /** @id MochiKit.Sortable.element */ - element: element, - - /** @id MochiKit.Sortable.tag */ - tag: 'li', // assumes li children, override with tag: 'tagname' - - /** @id MochiKit.Sortable.dropOnEmpty */ - dropOnEmpty: false, - - /** @id MochiKit.Sortable.tree */ - tree: false, - - /** @id MochiKit.Sortable.treeTag */ - treeTag: 'ul', - - /** @id MochiKit.Sortable.overlap */ - overlap: 'vertical', // one of 'vertical', 'horizontal' - - /** @id MochiKit.Sortable.constraint */ - constraint: 'vertical', // one of 'vertical', 'horizontal', false - // also takes array of elements (or ids); or false - - /** @id MochiKit.Sortable.containment */ - containment: [element], - - /** @id MochiKit.Sortable.handle */ - handle: false, // or a CSS class - - /** @id MochiKit.Sortable.only */ - only: false, - - /** @id MochiKit.Sortable.hoverclass */ - hoverclass: null, - - /** @id MochiKit.Sortable.ghosting */ - ghosting: false, - - /** @id MochiKit.Sortable.scroll */ - scroll: false, - - /** @id MochiKit.Sortable.scrollSensitivity */ - scrollSensitivity: 20, - - /** @id MochiKit.Sortable.scrollSpeed */ - scrollSpeed: 15, - - /** @id MochiKit.Sortable.format */ - format: /^[^_]*_(.*)$/, - - /** @id MochiKit.Sortable.onChange */ - onChange: MochiKit.Base.noop, - - /** @id MochiKit.Sortable.onUpdate */ - onUpdate: MochiKit.Base.noop, - - /** @id MochiKit.Sortable.accept */ - accept: null - }, options); - - // clear any old sortable with same element - self.destroy(element); - - // build options for the draggables - var options_for_draggable = { - revert: true, - ghosting: options.ghosting, - scroll: options.scroll, - scrollSensitivity: options.scrollSensitivity, - scrollSpeed: options.scrollSpeed, - constraint: options.constraint, - handle: options.handle - }; - - if (options.starteffect) { - options_for_draggable.starteffect = options.starteffect; - } - - if (options.reverteffect) { - options_for_draggable.reverteffect = options.reverteffect; - } else if (options.ghosting) { - options_for_draggable.reverteffect = function (innerelement) { - innerelement.style.top = 0; - innerelement.style.left = 0; - }; - } - - if (options.endeffect) { - options_for_draggable.endeffect = options.endeffect; - } - - if (options.zindex) { - options_for_draggable.zindex = options.zindex; - } - - // build options for the droppables - var options_for_droppable = { - overlap: options.overlap, - containment: options.containment, - hoverclass: options.hoverclass, - onhover: self.onHover, - tree: options.tree, - accept: options.accept - } - - var options_for_tree = { - onhover: self.onEmptyHover, - overlap: options.overlap, - containment: options.containment, - hoverclass: options.hoverclass, - accept: options.accept - } - - // fix for gecko engine - MochiKit.DOM.removeEmptyTextNodes(element); - - options.draggables = []; - options.droppables = []; - - // drop on empty handling - if (options.dropOnEmpty || options.tree) { - new MochiKit.DragAndDrop.Droppable(element, options_for_tree); - options.droppables.push(element); - } - MochiKit.Base.map(function (e) { - // handles are per-draggable - var handle = options.handle ? - MochiKit.DOM.getFirstElementByTagAndClassName(null, - options.handle, e) : e; - options.draggables.push( - new MochiKit.DragAndDrop.Draggable(e, - MochiKit.Base.update(options_for_draggable, - {handle: handle}))); - new MochiKit.DragAndDrop.Droppable(e, options_for_droppable); - if (options.tree) { - e.treeNode = element; - } - options.droppables.push(e); - }, (self.findElements(element, options) || [])); - - if (options.tree) { - MochiKit.Base.map(function (e) { - new MochiKit.DragAndDrop.Droppable(e, options_for_tree); - e.treeNode = element; - options.droppables.push(e); - }, (self.findTreeElements(element, options) || [])); - } - - // keep reference - self.sortables[element.id] = options; - - options.lastValue = self.serialize(element); - options.startHandle = MochiKit.Signal.connect(MochiKit.DragAndDrop.Draggables, 'start', - MochiKit.Base.partial(self.onStart, element)); - options.endHandle = MochiKit.Signal.connect(MochiKit.DragAndDrop.Draggables, 'end', - MochiKit.Base.partial(self.onEnd, element)); - }, - - /** @id MochiKit.Sortable.onStart */ - onStart: function (element, draggable) { - var self = MochiKit.Sortable; - var options = self.options(element); - options.lastValue = self.serialize(options.element); - }, - - /** @id MochiKit.Sortable.onEnd */ - onEnd: function (element, draggable) { - var self = MochiKit.Sortable; - self.unmark(); - var options = self.options(element); - if (options.lastValue != self.serialize(options.element)) { - options.onUpdate(options.element); - } - }, - - // return all suitable-for-sortable elements in a guaranteed order - - /** @id MochiKit.Sortable.findElements */ - findElements: function (element, options) { - return MochiKit.Sortable.findChildren( - element, options.only, options.tree ? true : false, options.tag); - }, - - /** @id MochiKit.Sortable.findTreeElements */ - findTreeElements: function (element, options) { - return MochiKit.Sortable.findChildren( - element, options.only, options.tree ? true : false, options.treeTag); - }, - - /** @id MochiKit.Sortable.findChildren */ - findChildren: function (element, only, recursive, tagName) { - if (!element.hasChildNodes()) { - return null; - } - tagName = tagName.toUpperCase(); - if (only) { - only = MochiKit.Base.flattenArray([only]); - } - var elements = []; - MochiKit.Base.map(function (e) { - if (e.tagName && - e.tagName.toUpperCase() == tagName && - (!only || - MochiKit.Iter.some(only, function (c) { - return MochiKit.DOM.hasElementClass(e, c); - }))) { - elements.push(e); - } - if (recursive) { - var grandchildren = MochiKit.Sortable.findChildren(e, only, recursive, tagName); - if (grandchildren && grandchildren.length > 0) { - elements = elements.concat(grandchildren); - } - } - }, element.childNodes); - return elements; - }, - - /** @id MochiKit.Sortable.onHover */ - onHover: function (element, dropon, overlap) { - if (MochiKit.DOM.isParent(dropon, element)) { - return; - } - var self = MochiKit.Sortable; - - if (overlap > .33 && overlap < .66 && self.options(dropon).tree) { - return; - } else if (overlap > 0.5) { - self.mark(dropon, 'before'); - if (dropon.previousSibling != element) { - var oldParentNode = element.parentNode; - element.style.visibility = 'hidden'; // fix gecko rendering - dropon.parentNode.insertBefore(element, dropon); - if (dropon.parentNode != oldParentNode) { - self.options(oldParentNode).onChange(element); - } - self.options(dropon.parentNode).onChange(element); - } - } else { - self.mark(dropon, 'after'); - var nextElement = dropon.nextSibling || null; - if (nextElement != element) { - var oldParentNode = element.parentNode; - element.style.visibility = 'hidden'; // fix gecko rendering - dropon.parentNode.insertBefore(element, nextElement); - if (dropon.parentNode != oldParentNode) { - self.options(oldParentNode).onChange(element); - } - self.options(dropon.parentNode).onChange(element); - } - } - }, - - _offsetSize: function (element, type) { - if (type == 'vertical' || type == 'height') { - return element.offsetHeight; - } else { - return element.offsetWidth; - } - }, - - /** @id MochiKit.Sortable.onEmptyHover */ - onEmptyHover: function (element, dropon, overlap) { - var oldParentNode = element.parentNode; - var self = MochiKit.Sortable; - var droponOptions = self.options(dropon); - - if (!MochiKit.DOM.isParent(dropon, element)) { - var index; - - var children = self.findElements(dropon, {tag: droponOptions.tag, - only: droponOptions.only}); - var child = null; - - if (children) { - var offset = self._offsetSize(dropon, droponOptions.overlap) * (1.0 - overlap); - - for (index = 0; index < children.length; index += 1) { - if (offset - self._offsetSize(children[index], droponOptions.overlap) >= 0) { - offset -= self._offsetSize(children[index], droponOptions.overlap); - } else if (offset - (self._offsetSize (children[index], droponOptions.overlap) / 2) >= 0) { - child = index + 1 < children.length ? children[index + 1] : null; - break; - } else { - child = children[index]; - break; - } - } - } - - dropon.insertBefore(element, child); - - self.options(oldParentNode).onChange(element); - droponOptions.onChange(element); - } - }, - - /** @id MochiKit.Sortable.unmark */ - unmark: function () { - var m = MochiKit.Sortable._marker; - if (m) { - MochiKit.Style.hideElement(m); - } - }, - - /** @id MochiKit.Sortable.mark */ - mark: function (dropon, position) { - // mark on ghosting only - var d = MochiKit.DOM; - var self = MochiKit.Sortable; - var sortable = self.options(dropon.parentNode); - if (sortable && !sortable.ghosting) { - return; - } - - if (!self._marker) { - self._marker = d.getElement('dropmarker') || - document.createElement('DIV'); - MochiKit.Style.hideElement(self._marker); - d.addElementClass(self._marker, 'dropmarker'); - self._marker.style.position = 'absolute'; - document.getElementsByTagName('body').item(0).appendChild(self._marker); - } - var offsets = MochiKit.Position.cumulativeOffset(dropon); - self._marker.style.left = offsets.x + 'px'; - self._marker.style.top = offsets.y + 'px'; - - if (position == 'after') { - if (sortable.overlap == 'horizontal') { - self._marker.style.left = (offsets.x + dropon.clientWidth) + 'px'; - } else { - self._marker.style.top = (offsets.y + dropon.clientHeight) + 'px'; - } - } - MochiKit.Style.showElement(self._marker); - }, - - _tree: function (element, options, parent) { - var self = MochiKit.Sortable; - var children = self.findElements(element, options) || []; - - for (var i = 0; i < children.length; ++i) { - var match = children[i].id.match(options.format); - - if (!match) { - continue; - } - - var child = { - id: encodeURIComponent(match ? match[1] : null), - element: element, - parent: parent, - children: [], - position: parent.children.length, - container: self._findChildrenElement(children[i], options.treeTag.toUpperCase()) - } - - /* Get the element containing the children and recurse over it */ - if (child.container) { - self._tree(child.container, options, child) - } - - parent.children.push (child); - } - - return parent; - }, - - /* Finds the first element of the given tag type within a parent element. - Used for finding the first LI[ST] within a L[IST]I[TEM].*/ - _findChildrenElement: function (element, containerTag) { - if (element && element.hasChildNodes) { - containerTag = containerTag.toUpperCase(); - for (var i = 0; i < element.childNodes.length; ++i) { - if (element.childNodes[i].tagName.toUpperCase() == containerTag) { - return element.childNodes[i]; - } - } - } - return null; - }, - - /** @id MochiKit.Sortable.tree */ - tree: function (element, options) { - element = MochiKit.DOM.getElement(element); - var sortableOptions = MochiKit.Sortable.options(element); - options = MochiKit.Base.update({ - tag: sortableOptions.tag, - treeTag: sortableOptions.treeTag, - only: sortableOptions.only, - name: element.id, - format: sortableOptions.format - }, options || {}); - - var root = { - id: null, - parent: null, - children: new Array, - container: element, - position: 0 - } - - return MochiKit.Sortable._tree(element, options, root); - }, - - /** - * Specifies the sequence for the Sortable. - * @param {Node} element Element to use as the Sortable. - * @param {Object} newSequence New sequence to use. - * @param {Object} options Options to use fro the Sortable. - */ - setSequence: function (element, newSequence, options) { - var self = MochiKit.Sortable; - var b = MochiKit.Base; - element = MochiKit.DOM.getElement(element); - options = b.update(self.options(element), options || {}); - - var nodeMap = {}; - b.map(function (n) { - var m = n.id.match(options.format); - if (m) { - nodeMap[m[1]] = [n, n.parentNode]; - } - n.parentNode.removeChild(n); - }, self.findElements(element, options)); - - b.map(function (ident) { - var n = nodeMap[ident]; - if (n) { - n[1].appendChild(n[0]); - delete nodeMap[ident]; - } - }, newSequence); - }, - - /* Construct a [i] index for a particular node */ - _constructIndex: function (node) { - var index = ''; - do { - if (node.id) { - index = '[' + node.position + ']' + index; - } - } while ((node = node.parent) != null); - return index; - }, - - /** @id MochiKit.Sortable.sequence */ - sequence: function (element, options) { - element = MochiKit.DOM.getElement(element); - var self = MochiKit.Sortable; - var options = MochiKit.Base.update(self.options(element), options || {}); - - return MochiKit.Base.map(function (item) { - return item.id.match(options.format) ? item.id.match(options.format)[1] : ''; - }, MochiKit.DOM.getElement(self.findElements(element, options) || [])); - }, - - /** - * Serializes the content of a Sortable. Useful to send this content through a XMLHTTPRequest. - * These options override the Sortable options for the serialization only. - * @param {Node} element Element to serialize. - * @param {Object} options Serialization options. - */ - serialize: function (element, options) { - element = MochiKit.DOM.getElement(element); - var self = MochiKit.Sortable; - options = MochiKit.Base.update(self.options(element), options || {}); - var name = encodeURIComponent(options.name || element.id); - - if (options.tree) { - return MochiKit.Base.flattenArray(MochiKit.Base.map(function (item) { - return [name + self._constructIndex(item) + "[id]=" + - encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)); - }, self.tree(element, options).children)).join('&'); - } else { - return MochiKit.Base.map(function (item) { - return name + "[]=" + encodeURIComponent(item); - }, self.sequence(element, options)).join('&'); - } - } -}); - -// trunk compatibility -MochiKit.Sortable.Sortable = MochiKit.Sortable; diff --git a/javascript/libs/MochiKit/Style.js b/javascript/libs/MochiKit/Style.js deleted file mode 100644 index a7d62f8..0000000 --- a/javascript/libs/MochiKit/Style.js +++ /dev/null @@ -1,447 +0,0 @@ -/*** - -MochiKit.Style 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005-2006 Bob Ippolito, Beau Hartshorne. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.Style'); - dojo.require('MochiKit.Base'); - dojo.require('MochiKit.DOM'); -} -if (typeof(JSAN) != 'undefined') { - JSAN.use('MochiKit.Base', []); - JSAN.use('MochiKit.DOM', []); -} - -try { - if (typeof(MochiKit.Base) == 'undefined') { - throw ''; - } -} catch (e) { - throw 'MochiKit.Style depends on MochiKit.Base!'; -} - -try { - if (typeof(MochiKit.DOM) == 'undefined') { - throw ''; - } -} catch (e) { - throw 'MochiKit.Style depends on MochiKit.DOM!'; -} - - -if (typeof(MochiKit.Style) == 'undefined') { - MochiKit.Style = {}; -} - -MochiKit.Style.NAME = 'MochiKit.Style'; -MochiKit.Style.VERSION = '1.4'; -MochiKit.Style.__repr__ = function () { - return '[' + this.NAME + ' ' + this.VERSION + ']'; -}; -MochiKit.Style.toString = function () { - return this.__repr__(); -}; - -MochiKit.Style.EXPORT_OK = []; - -MochiKit.Style.EXPORT = [ - 'setStyle', - 'setOpacity', - 'getStyle', - 'getElementDimensions', - 'elementDimensions', // deprecated - 'setElementDimensions', - 'getElementPosition', - 'elementPosition', // deprecated - 'setElementPosition', - 'setDisplayForElement', - 'hideElement', - 'showElement', - 'getViewportDimensions', - 'getViewportPosition', - 'Dimensions', - 'Coordinates' -]; - - -/* - - Dimensions - -*/ -/** @id MochiKit.Style.Dimensions */ -MochiKit.Style.Dimensions = function (w, h) { - this.w = w; - this.h = h; -}; - -MochiKit.Style.Dimensions.prototype.__repr__ = function () { - var repr = MochiKit.Base.repr; - return '{w: ' + repr(this.w) + ', h: ' + repr(this.h) + '}'; -}; - -MochiKit.Style.Dimensions.prototype.toString = function () { - return this.__repr__(); -}; - - -/* - - Coordinates - -*/ -/** @id MochiKit.Style.Coordinates */ -MochiKit.Style.Coordinates = function (x, y) { - this.x = x; - this.y = y; -}; - -MochiKit.Style.Coordinates.prototype.__repr__ = function () { - var repr = MochiKit.Base.repr; - return '{x: ' + repr(this.x) + ', y: ' + repr(this.y) + '}'; -}; - -MochiKit.Style.Coordinates.prototype.toString = function () { - return this.__repr__(); -}; - - -MochiKit.Base.update(MochiKit.Style, { - - /** @id MochiKit.Style.getStyle */ - getStyle: function (elem, cssProperty) { - var dom = MochiKit.DOM; - var d = dom._document; - - elem = dom.getElement(elem); - cssProperty = MochiKit.Base.camelize(cssProperty); - - if (!elem || elem == d) { - return undefined; - } - if (cssProperty == 'opacity' && elem.filters) { - var opacity = (MochiKit.Style.getStyle(elem, 'filter') || '').match(/alpha\(opacity=(.*)\)/); - if (opacity && opacity[1]) { - return parseFloat(opacity[1]) / 100; - } - return 1.0; - } - var value = elem.style ? elem.style[cssProperty] : null; - if (!value) { - if (d.defaultView && d.defaultView.getComputedStyle) { - var css = d.defaultView.getComputedStyle(elem, null); - cssProperty = cssProperty.replace(/([A-Z])/g, '-$1' - ).toLowerCase(); // from dojo.style.toSelectorCase - value = css ? css.getPropertyValue(cssProperty) : null; - } else if (elem.currentStyle) { - value = elem.currentStyle[cssProperty]; - } - } - if (cssProperty == 'opacity') { - value = parseFloat(value); - } - - if (/Opera/.test(navigator.userAgent) && (MochiKit.Base.find(['left', 'top', 'right', 'bottom'], cssProperty) != -1)) { - if (MochiKit.Style.getStyle(elem, 'position') == 'static') { - value = 'auto'; - } - } - - return value == 'auto' ? null : value; - }, - - /** @id MochiKit.Style.setStyle */ - setStyle: function (elem, style) { - elem = MochiKit.DOM.getElement(elem); - for (var name in style) { - if (name == 'opacity') { - MochiKit.Style.setOpacity(elem, style[name]); - } else { - elem.style[MochiKit.Base.camelize(name)] = style[name]; - } - } - }, - - /** @id MochiKit.Style.setOpacity */ - setOpacity: function (elem, o) { - elem = MochiKit.DOM.getElement(elem); - var self = MochiKit.Style; - if (o == 1) { - var toSet = /Gecko/.test(navigator.userAgent) && !(/Konqueror|AppleWebKit|KHTML/.test(navigator.userAgent)); - elem.style["opacity"] = toSet ? 0.999999 : 1.0; - if (/MSIE/.test(navigator.userAgent)) { - elem.style['filter'] = - self.getStyle(elem, 'filter').replace(/alpha\([^\)]*\)/gi, ''); - } - } else { - if (o < 0.00001) { - o = 0; - } - elem.style["opacity"] = o; - if (/MSIE/.test(navigator.userAgent)) { - elem.style['filter'] = - self.getStyle(elem, 'filter').replace(/alpha\([^\)]*\)/gi, '') + 'alpha(opacity=' + o * 100 + ')'; - } - } - }, - - /* - - getElementPosition is adapted from YAHOO.util.Dom.getXY v0.9.0. - Copyright: Copyright (c) 2006, Yahoo! Inc. All rights reserved. - License: BSD, http://developer.yahoo.net/yui/license.txt - - */ - - /** @id MochiKit.Style.getElementPosition */ - getElementPosition: function (elem, /* optional */relativeTo) { - var self = MochiKit.Style; - var dom = MochiKit.DOM; - elem = dom.getElement(elem); - - if (!elem || - (!(elem.x && elem.y) && - (!elem.parentNode === null || - self.getStyle(elem, 'display') == 'none'))) { - return undefined; - } - - var c = new self.Coordinates(0, 0); - var box = null; - var parent = null; - - var d = MochiKit.DOM._document; - var de = d.documentElement; - var b = d.body; - - if (!elem.parentNode && elem.x && elem.y) { - /* it's just a MochiKit.Style.Coordinates object */ - c.x += elem.x || 0; - c.y += elem.y || 0; - } else if (elem.getBoundingClientRect) { // IE shortcut - /* - - The IE shortcut can be off by two. We fix it. See: - http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/getboundingclientrect.asp - - This is similar to the method used in - MochiKit.Signal.Event.mouse(). - - */ - box = elem.getBoundingClientRect(); - - c.x += box.left + - (de.scrollLeft || b.scrollLeft) - - (de.clientLeft || 0); - - c.y += box.top + - (de.scrollTop || b.scrollTop) - - (de.clientTop || 0); - - // Don't pass through next steps - return c; - } else if (elem.offsetParent) { - c.x += elem.offsetLeft; - c.y += elem.offsetTop; - parent = elem.offsetParent; - - if (parent != elem) { - while (parent) { - c.x += parent.offsetLeft; - c.y += parent.offsetTop; - parent = parent.offsetParent; - } - } - - /* - - Opera < 9 and old Safari (absolute) incorrectly account for - body offsetTop and offsetLeft. - - */ - var ua = navigator.userAgent.toLowerCase(); - if ((typeof(opera) != 'undefined' && - parseFloat(opera.version()) < 9) || - (ua.indexOf('AppleWebKit') != -1 && - self.getStyle(elem, 'position') == 'absolute')) { - - c.x -= b.offsetLeft; - c.y -= b.offsetTop; - - } - } - - if (typeof(relativeTo) != 'undefined') { - relativeTo = arguments.callee(relativeTo); - if (relativeTo) { - c.x -= (relativeTo.x || 0); - c.y -= (relativeTo.y || 0); - } - } - - if (elem.parentNode) { - parent = elem.parentNode; - } else { - parent = null; - } - - while (parent) { - var tagName = parent.tagName.toUpperCase(); - if (tagName === 'BODY' || tagName === 'HTML') { - break; - } - var disp = self.getStyle(parent, 'display'); - // Handle strange Opera bug for some display - if (disp.search(/^inline|table-row.*$/i)) { - c.x -= parent.scrollLeft; - c.y -= parent.scrollTop; - } - if (parent.parentNode) { - parent = parent.parentNode; - } else { - parent = null; - } - } - - return c; - }, - - /** @id MochiKit.Style.setElementPosition */ - setElementPosition: function (elem, newPos/* optional */, units) { - elem = MochiKit.DOM.getElement(elem); - if (typeof(units) == 'undefined') { - units = 'px'; - } - var newStyle = {}; - var isUndefNull = MochiKit.Base.isUndefinedOrNull; - if (!isUndefNull(newPos.x)) { - newStyle['left'] = newPos.x + units; - } - if (!isUndefNull(newPos.y)) { - newStyle['top'] = newPos.y + units; - } - MochiKit.DOM.updateNodeAttributes(elem, {'style': newStyle}); - }, - - /** @id MochiKit.Style.getElementDimensions */ - getElementDimensions: function (elem) { - var self = MochiKit.Style; - var dom = MochiKit.DOM; - if (typeof(elem.w) == 'number' || typeof(elem.h) == 'number') { - return new self.Dimensions(elem.w || 0, elem.h || 0); - } - elem = dom.getElement(elem); - if (!elem) { - return undefined; - } - var disp = self.getStyle(elem, 'display'); - // display can be empty/undefined on WebKit/KHTML - if (disp != 'none' && disp !== '' && typeof(disp) != 'undefined') { - return new self.Dimensions(elem.offsetWidth || 0, - elem.offsetHeight || 0); - } - var s = elem.style; - var originalVisibility = s.visibility; - var originalPosition = s.position; - s.visibility = 'hidden'; - s.position = 'absolute'; - s.display = ''; - var originalWidth = elem.offsetWidth; - var originalHeight = elem.offsetHeight; - s.display = 'none'; - s.position = originalPosition; - s.visibility = originalVisibility; - return new self.Dimensions(originalWidth, originalHeight); - }, - - /** @id MochiKit.Style.setElementDimensions */ - setElementDimensions: function (elem, newSize/* optional */, units) { - elem = MochiKit.DOM.getElement(elem); - if (typeof(units) == 'undefined') { - units = 'px'; - } - var newStyle = {}; - var isUndefNull = MochiKit.Base.isUndefinedOrNull; - if (!isUndefNull(newSize.w)) { - newStyle['width'] = newSize.w + units; - } - if (!isUndefNull(newSize.h)) { - newStyle['height'] = newSize.h + units; - } - MochiKit.DOM.updateNodeAttributes(elem, {'style': newStyle}); - }, - - /** @id MochiKit.Style.setDisplayForElement */ - setDisplayForElement: function (display, element/*, ...*/) { - var elements = MochiKit.Base.extend(null, arguments, 1); - var getElement = MochiKit.DOM.getElement; - for (var i = 0; i < elements.length; i++) { - element = getElement(elements[i]); - if (element) { - element.style.display = display; - } - } - }, - - /** @id MochiKit.Style.getViewportDimensions */ - getViewportDimensions: function () { - var d = new MochiKit.Style.Dimensions(); - - var w = MochiKit.DOM._window; - var b = MochiKit.DOM._document.body; - - if (w.innerWidth) { - d.w = w.innerWidth; - d.h = w.innerHeight; - } else if (b.parentElement.clientWidth) { - d.w = b.parentElement.clientWidth; - d.h = b.parentElement.clientHeight; - } else if (b && b.clientWidth) { - d.w = b.clientWidth; - d.h = b.clientHeight; - } - return d; - }, - - /** @id MochiKit.Style.getViewportPosition */ - getViewportPosition: function () { - var c = new MochiKit.Style.Coordinates(0, 0); - var d = MochiKit.DOM._document; - var de = d.documentElement; - var db = d.body; - if (de && (de.scrollTop || de.scrollLeft)) { - c.x = de.scrollLeft; - c.y = de.scrollTop; - } else if (db) { - c.x = db.scrollLeft; - c.y = db.scrollTop; - } - return c; - }, - - __new__: function () { - var m = MochiKit.Base; - - this.elementPosition = this.getElementPosition; - this.elementDimensions = this.getElementDimensions; - - this.hideElement = m.partial(this.setDisplayForElement, 'none'); - this.showElement = m.partial(this.setDisplayForElement, 'block'); - - this.EXPORT_TAGS = { - ':common': this.EXPORT, - ':all': m.concat(this.EXPORT, this.EXPORT_OK) - }; - - m.nameFunctions(this); - } -}); - -MochiKit.Style.__new__(); -MochiKit.Base._exportSymbols(this, MochiKit.Style); diff --git a/javascript/libs/MochiKit/Test.js b/javascript/libs/MochiKit/Test.js deleted file mode 100644 index 494a5b4..0000000 --- a/javascript/libs/MochiKit/Test.js +++ /dev/null @@ -1,181 +0,0 @@ -/*** - -MochiKit.Test 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005 Bob Ippolito. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.Test'); - dojo.require('MochiKit.Base'); -} - -if (typeof(JSAN) != 'undefined') { - JSAN.use("MochiKit.Base", []); -} - -try { - if (typeof(MochiKit.Base) == 'undefined') { - throw ""; - } -} catch (e) { - throw "MochiKit.Test depends on MochiKit.Base!"; -} - -if (typeof(MochiKit.Test) == 'undefined') { - MochiKit.Test = {}; -} - -MochiKit.Test.NAME = "MochiKit.Test"; -MochiKit.Test.VERSION = "1.4"; -MochiKit.Test.__repr__ = function () { - return "[" + this.NAME + " " + this.VERSION + "]"; -}; - -MochiKit.Test.toString = function () { - return this.__repr__(); -}; - - -MochiKit.Test.EXPORT = ["runTests"]; -MochiKit.Test.EXPORT_OK = []; - -MochiKit.Test.runTests = function (obj) { - if (typeof(obj) == "string") { - obj = JSAN.use(obj); - } - var suite = new MochiKit.Test.Suite(); - suite.run(obj); -}; - -MochiKit.Test.Suite = function () { - this.testIndex = 0; - MochiKit.Base.bindMethods(this); -}; - -MochiKit.Test.Suite.prototype = { - run: function (obj) { - try { - obj(this); - } catch (e) { - this.traceback(e); - } - }, - traceback: function (e) { - var items = MochiKit.Iter.sorted(MochiKit.Base.items(e)); - print("not ok " + this.testIndex + " - Error thrown"); - for (var i = 0; i < items.length; i++) { - var kv = items[i]; - if (kv[0] == "stack") { - kv[1] = kv[1].split(/\n/)[0]; - } - this.print("# " + kv.join(": ")); - } - }, - print: function (s) { - print(s); - }, - is: function (got, expected, /* optional */message) { - var res = 1; - var msg = null; - try { - res = MochiKit.Base.compare(got, expected); - } catch (e) { - msg = "Can not compare " + typeof(got) + ":" + typeof(expected); - } - if (res) { - msg = "Expected value did not compare equal"; - } - if (!res) { - return this.testResult(true, message); - } - return this.testResult(false, message, - [[msg], ["got:", got], ["expected:", expected]]); - }, - - testResult: function (pass, msg, failures) { - this.testIndex += 1; - if (pass) { - this.print("ok " + this.testIndex + " - " + msg); - return; - } - this.print("not ok " + this.testIndex + " - " + msg); - if (failures) { - for (var i = 0; i < failures.length; i++) { - this.print("# " + failures[i].join(" ")); - } - } - }, - - isDeeply: function (got, expected, /* optional */message) { - var m = MochiKit.Base; - var res = 1; - try { - res = m.compare(got, expected); - } catch (e) { - // pass - } - if (res === 0) { - return this.ok(true, message); - } - var gk = m.keys(got); - var ek = m.keys(expected); - gk.sort(); - ek.sort(); - if (m.compare(gk, ek)) { - // differing keys - var cmp = {}; - var i; - for (i = 0; i < gk.length; i++) { - cmp[gk[i]] = "got"; - } - for (i = 0; i < ek.length; i++) { - if (ek[i] in cmp) { - delete cmp[ek[i]]; - } else { - cmp[ek[i]] = "expected"; - } - } - var diffkeys = m.keys(cmp); - diffkeys.sort(); - var gotkeys = []; - var expkeys = []; - while (diffkeys.length) { - var k = diffkeys.shift(); - if (k in Object.prototype) { - continue; - } - (cmp[k] == "got" ? gotkeys : expkeys).push(k); - } - - - } - - return this.testResult((!res), msg, - (msg ? [["got:", got], ["expected:", expected]] : undefined) - ); - }, - - ok: function (res, message) { - return this.testResult(res, message); - } -}; - -MochiKit.Test.__new__ = function () { - var m = MochiKit.Base; - - this.EXPORT_TAGS = { - ":common": this.EXPORT, - ":all": m.concat(this.EXPORT, this.EXPORT_OK) - }; - - m.nameFunctions(this); - -}; - -MochiKit.Test.__new__(); - -MochiKit.Base._exportSymbols(this, MochiKit.Test); diff --git a/javascript/libs/MochiKit/ThickBox.css b/javascript/libs/MochiKit/ThickBox.css deleted file mode 100644 index 642610e..0000000 --- a/javascript/libs/MochiKit/ThickBox.css +++ /dev/null @@ -1,140 +0,0 @@ -/* ----------------------------------------------------------------------------------------------------------------*/ -/* ---------->>> global settings needed for thickbox <<<-----------------------------------------------------------*/ -/* ----------------------------------------------------------------------------------------------------------------*/ -*{padding: 0; margin: 0;} - -html, body { -min-height: 100%; -height: auto !important; -height: 100% -} - -/* ----------------------------------------------------------------------------------------------------------------*/ -/* ---------->>> thickbox specific link and font settings <<<------------------------------------------------------*/ -/* ---------------------------------------------------------------------------------------------------------------- -#TB_window { - font: 12px Arial, Helvetica, sans-serif; - color: #333333; -} - -#TB_secondLine { - font: 10px Arial, Helvetica, sans-serif; - color:#666666; -} - -#TB_window a:link {color: #666666;} -#TB_window a:visited {color: #666666;} -#TB_window a:hover {color: #000;} -#TB_window a:active {color: #666666;} -#TB_window a:focus{color: #666666;} -*/ - -/* ----------------------------------------------------------------------------------------------------------------*/ -/* ---------->>> thickbox settings <<<-----------------------------------------------------------------------------*/ -/* ----------------------------------------------------------------------------------------------------------------*/ -#TB_overlay { - position: absolute; - z-index:100; - width: 100%; - height: 100%; - top: 0px; - left: 0px; - min-height:100%; - background-color:#000; - filter:alpha(opacity=60); - -moz-opacity: 0.6; - opacity: 0.6; -} - -#TB_window { - position: absolute; - background: #ffffff; - z-index: 102; - color:#000000; - display:none; - border: 4px solid #525252; - text-align:left; -} - -#TB_window img { - display:block; - margin: 15px 0 0 15px; - border-right: 1px solid #ccc; - border-bottom: 1px solid #ccc; - border-top: 1px solid #666; - border-left: 1px solid #666; -} - -#TB_caption{ - height:25px; - padding:7px 30px 10px 25px; - float:left; -} - -#TB_closeWindow{ - height:25px; - padding:11px 25px 10px 0; - float:right; -} - -#TB_closeAjaxWindow{ - padding:5px 10px 7px 0; - margin-bottom:1px; - text-align:right; - float:right; -} - -#TB_ajaxWindowTitle{ - float:left; - padding:7px 0 5px 10px; - margin-bottom:1px; -} - -#TB_title{ - background-color:#e8e8e8; - color:#333333; - height:27px; -} - -#TB_ajaxContent{ - clear:both; - padding:2px 15px 15px 15px; - overflow:auto; - text-align:left; - line-height:1.4em; -} - -#TB_ajaxContent p{ - padding:5px 0px 5px 0px; -} - -#TB_load{ - position: absolute; - display:none; - height:100px; - width:100px; - z-index:101; -} - -#TB_HideSelect{ - z-index:99; - position:absolute; - top: 0; - left: 0; - width:100%; - height:100%; - background-color:#fff; - border:none; - filter:alpha(opacity=0); - -moz-opacity: 0; - opacity: 0; -} - -#TB_iframeContent{ - clear:both; - border:none; - margin-bottom:-1px; - margin-top:1px; - _margin-bottom:1px; -} - diff --git a/javascript/libs/MochiKit/ThickBox.js b/javascript/libs/MochiKit/ThickBox.js deleted file mode 100644 index a9358b1..0000000 --- a/javascript/libs/MochiKit/ThickBox.js +++ /dev/null @@ -1,334 +0,0 @@ - -/* - * Modified for use with MochiKit 1.4 rather than the originally-used jQuery library - * Changes to comments also made - removed some, modified others, added some, etc. - * Changes and additions Copyright (c) 2006 by Jason Bunting (http://www.jasonbunting.com) - */ - -/* - * Thickbox 2.1 - One Box To Rule Them All. - * By Cody Lindley (http://www.codylindley.com) - * Copyright (c) 2006 cody lindley - * Licensed under the MIT License: - * http://www.opensource.org/licenses/mit-license.php - */ - -///////////////////////////////////////////////////////////////////// -// initialize the page when it is done loading -connect(window, "onload", function() { - //add thickbox to href elements that have a class of .thickbox - forEach(list(getElementsByTagAndClassName("a", "thickbox")), function(element) { - connect(element, "onclick", function(evt) { - var title = element.title || element.name || null; - var group = element.rel || false; - TB_show(title, element.href, group); - evt.stop(); - }); - }); -}); -///////////////////////////////////////////////////////////////////// - -//function called when the user clicks on a thickbox link -function TB_show(caption, url, imageGroup) { - - try { - - if($("TB_HideSelect") == null) { - appendChildNodes(currentDocument().body, createDOM(evalHTML("<iframe id='TB_HideSelect'></iframe><div id='TB_overlay'></div><div id='TB_window'></div>"))); - connect("TB_overlay", "onclick", TB_remove); - } - caption = (caption || ""); - connect(window, "onscroll", TB_position); - TB_overlaySize(); - appendChildNodes(currentDocument().body, createDOM(evalHTML("<div id='TB_load'><img src='images/loadingAnimation.gif' /></div>"))); - TB_load_position(); - - // determine if there is a query string - if so, extract base url - var baseURL = null; - if(url.indexOf("?") !== -1){ - baseURL = url.substr(0, url.indexOf("?")); - } else { - baseURL = url; - } - - var urlString = /\.jpg|\.jpeg|\.png|\.gif|\.bmp/g; - var urlType = baseURL.toLowerCase().match(urlString); - - // code to show images - if(urlType == '.jpg' || urlType == '.jpeg' || urlType == '.png' || urlType == '.gif' || urlType == '.bmp') { - TB_PrevCaption = ""; - TB_PrevURL = ""; - TB_PrevHTML = ""; - TB_NextCaption = ""; - TB_NextURL = ""; - TB_NextHTML = ""; - TB_imageCount = ""; - TB_FoundURL = false; - if(imageGroup){ - TB_TempArray = getElementsByTagNameAndAttributeValue("a", "rel", imageGroup); - for (TB_Counter = 0; ((TB_Counter < TB_TempArray.length) && (TB_NextHTML == "")); TB_Counter++) { - var urlTypeTemp = TB_TempArray[TB_Counter].href.toLowerCase().match(urlString); - if (!(TB_TempArray[TB_Counter].href == url)) { - if (TB_FoundURL) { - TB_NextCaption = TB_TempArray[TB_Counter].title; - TB_NextURL = TB_TempArray[TB_Counter].href; - TB_NextHTML = "<span id='TB_next'> <a href='#'>Next ></a></span>"; - } else { - TB_PrevCaption = TB_TempArray[TB_Counter].title; - TB_PrevURL = TB_TempArray[TB_Counter].href; - TB_PrevHTML = "<span id='TB_prev'> <a href='#'>< Prev</a></span>"; - } - } else { - TB_FoundURL = true; - TB_imageCount = "Image " + (TB_Counter + 1) +" of "+ (TB_TempArray.length); - } - } - } - - imgPreloader = new Image(); - connect(imgPreloader, "onload", function() { - imgPreloader.onload = null; - - // Resizing large images - orginal by Christian Montoya edited by Cody Lindley. - var pageDimensions = getViewportDimensions(); - var x = pageDimensions.w - 150; - var y = pageDimensions.h - 150; - var imageWidth = imgPreloader.width; - var imageHeight = imgPreloader.height; - if (imageWidth > x) { - imageHeight = imageHeight * (x / imageWidth); - imageWidth = x; - if (imageHeight > y) { - imageWidth = imageWidth * (y / imageHeight); - imageHeight = y; - } - } else if (imageHeight > y) { - imageWidth = imageWidth * (y / imageHeight); - imageHeight = y; - if (imageWidth > x) { - imageHeight = imageHeight * (x / imageWidth); - imageWidth = x; - } - } - // End Resizing - - TB_WIDTH = imageWidth + 30; - TB_HEIGHT = imageHeight + 60; - - appendChildNodes("TB_window", createDOM(evalHTML("<a href='' id='TB_ImageOff' title='Close'><img id='TB_Image' src='"+url+"' width='"+imageWidth+"' height='"+imageHeight+"' alt='"+caption+"'/></a>" + "<div id='TB_caption'>"+caption+"<div id='TB_secondLine'>" + TB_imageCount + TB_PrevHTML + TB_NextHTML + "</div></div><div id='TB_closeWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a></div>"))); - - connect("TB_closeWindowButton", "onclick", TB_remove); - - if (!(TB_PrevHTML == "")) { - function goPrev() { - removeElement("TB_window"); - appendChildNodes(currentDocument().body, DIV({"id":"TB_window"}, null)); - TB_show(TB_PrevCaption, TB_PrevURL, imageGroup); - return false; - } - connect("TB_prev", "onclick", goPrev); - } - - if (!(TB_NextHTML == "")) { - function goNext(){ - removeElement("TB_window"); - appendChildNodes(currentDocument().body, DIV({"id":"TB_window"}, null)); - TB_show(TB_NextCaption, TB_NextURL, imageGroup); - return false; - } - connect("TB_next", "onclick", goNext); - } - - document.onkeydown = function(e){ - if (e == null) { // ie - keycode = event.keyCode; - } else { // mozilla - keycode = e.which; - } - if(keycode == 27) { // close - TB_remove(); - } else if(keycode == 190) { // display previous image - if(!(TB_NextHTML == "")) { - document.onkeydown = ""; - goNext(); - } - } else if(keycode == 188) { // display next image - if(!(TB_PrevHTML == "")) { - document.onkeydown = ""; - goPrev(); - } - } - } - - TB_position(); - removeElement("TB_load"); - connect("TB_ImageOff", "onclick", TB_remove); - showElement("TB_window"); - - }); - - imgPreloader.src = url; - - } else { //code to show html pages - - var queryString = url.replace(/^[^\?]+\??/,''); - var params = parseQueryString(queryString); - - TB_WIDTH = (params["width"]*1) + 30; - TB_HEIGHT = (params["height"]*1) + 40; - ajaxContentW = TB_WIDTH - 30; - ajaxContentH = TB_HEIGHT - 45; - - if(url.indexOf("TB_iframe") != -1) { - urlNoQuery = url.split("TB_"); - appendChildNodes("TB_window", createDOM(evalHTML("<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton' title='Close'>close</a></div></div><iframe frameborder='0' hspace='0' src='"+urlNoQuery[0]+"' id='TB_iframeContent' name='TB_iframeContent' style='width:"+(ajaxContentW + 29)+"px;height:"+(ajaxContentH + 17)+"px;' onload='TB_showIframe()'> </iframe>"))); - } else { - $("TB_window").innerHTML = $("TB_window").innerHTML + "<div id='TB_title'><div id='TB_ajaxWindowTitle'>"+caption+"</div><div id='TB_closeAjaxWindow'><a href='#' id='TB_closeWindowButton'>close</a></div></div><div id='TB_ajaxContent' style='width:"+ajaxContentW+"px;height:"+ajaxContentH+"px;'></div>"; - } - - connect("TB_closeWindowButton", "onclick", TB_remove); - - if(url.indexOf('TB_inline') != -1) { - $("TB_ajaxContent").innerHTML = ($(params['inlineId']).innerHTML); - TB_position(); - removeElement("TB_load"); - showElement("TB_window"); - } else if(url.indexOf('TB_iframe') != -1) { - TB_position(); - if(frames['TB_iframeContent'] == undefined) {//be nice to safari - removeElement("TB_load"); - showElement("TB_window"); - connect(currentDocument(), "onkeyup", function(evt) { - if(evt.key().code == 27) { - TB_remove(); - } - }); - } - } else { - var deferred = doSimpleXMLHttpRequest(url); - deferred.addCallback(function(xhr) { - var responseText = xhr.responseText; - $("TB_ajaxContent").innerHTML = responseText; - TB_position(); - removeElement("TB_load"); - showElement("TB_window"); - }); - } - executeJavascript("TB_window"); - } - connect(window, "onresize", TB_position); - connect(currentDocument(), "onkeyup", function(evt) { - if(evt.key().code == 27) { - TB_remove(); - } - }); - } catch(e) { - logError(e); - } -} - -//helper functions below - -function TB_showIframe() { - removeElement("TB_load"); - showElement("TB_window"); -} - -function TB_remove() { - forEach(["TB_window","TB_overlay","TB_HideSelect"], function(elem) { - removeElement(elem); - }); -} - -function TB_position() { - var pageDimensions = getViewportDimensions(); - var arrayPageScroll = TB_getPageScrollTop(); - setStyle("TB_window", {"width":(TB_WIDTH + "px"), "left":((arrayPageScroll[0] + (pageDimensions.w - TB_WIDTH)/2)+"px"), "top":((arrayPageScroll[1] + (pageDimensions.h-TB_HEIGHT)/2)+"px")}); -} - -function TB_overlaySize(){ - if (window.innerHeight && window.scrollMaxY || window.innerWidth && window.scrollMaxX) { - yScroll = window.innerHeight + window.scrollMaxY; - xScroll = window.innerWidth + window.scrollMaxX; - } else if (document.body.scrollHeight > document.body.offsetHeight || document.body.scrollWidth > document.body.offsetWidth){ // all but Explorer Mac - yScroll = document.body.scrollHeight; - xScroll = document.body.scrollWidth; - } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari - yScroll = document.body.offsetHeight; - xScroll = document.body.offsetWidth; - } - setElementDimensions("TB_overlay", {"w":xScroll,"h":yScroll}); - setElementDimensions("TB_HideSelect", {"w":xScroll,"h":yScroll}); -} - -function TB_load_position() { - var pageDimensions = getViewportDimensions(); - var arrayPageScroll = TB_getPageScrollTop(); - setStyle("TB_load", {"left": (arrayPageScroll[0] + (pageDimensions.w - 100)/2)+"px", "top": (arrayPageScroll[1] + ((pageDimensions.h-100)/2))+"px", "display":"block"}); -} - - -function TB_getPageScrollTop(){ - var yScrolltop; - var xScrollleft; - if (self.pageYOffset || self.pageXOffset) { - yScrolltop = self.pageYOffset; - xScrollleft = self.pageXOffset; - } else if (document.documentElement && document.documentElement.scrollTop || document.documentElement.scrollLeft ){ // Explorer 6 Strict - yScrolltop = document.documentElement.scrollTop; - xScrollleft = document.documentElement.scrollLeft; - } else if (document.body) {// all other Explorers - yScrolltop = document.body.scrollTop; - xScrollleft = document.body.scrollLeft; - } - arrayPageScroll = new Array(xScrollleft,yScrolltop) - return arrayPageScroll; -} - -///////////////////////////////////////////////////////////////////// -/* From mochikit trac at http://trac.mochikit.com/wiki/ParsingHtml */ -function evalHTML(value) { - if (typeof(value) != "string") { - return null; - } - value = MochiKit.Format.strip(value); - if (value.length == 0) { - return null; - } - var parser = MochiKit.DOM.DIV(); - var html = MochiKit.DOM.currentDocument().createDocumentFragment(); - var child; - parser.innerHTML = value; - while ((child = parser.firstChild)) { - html.appendChild(child); - } - return html; -} -///////////////////////////////////////////////////////////////////// -function getElementsByTagNameAndAttributeValue(tagName, attribute, value) { - var elements = []; - forEach(list(document.getElementsByTagName(tagName)), function(element) { - if(element[attribute] != null && element[attribute].toUpperCase() == value.toUpperCase()) { - elements.push(element); - } - }); - return elements; -} -///////////////////////////////////////////////////////////////////// - -function executeJavascript (element) { - var element = MochiKit.DOM.getElement(element); - if (element) { - var st = element.getElementsByTagName("SCRIPT"); - var string_to_execute; - - for (var i=0;i<st.length; i++) { - string_to_execute = st[i].innerHTML; - try { - eval(string_to_execute.split("<!--").join("").split("-->").join("")); - } catch(e) { - MochiKit.Logging.log(e); - } // end try - } // end for - } // end if -} diff --git a/javascript/libs/MochiKit/Visual.js b/javascript/libs/MochiKit/Visual.js deleted file mode 100644 index e9924c8..0000000 --- a/javascript/libs/MochiKit/Visual.js +++ /dev/null @@ -1,1981 +0,0 @@ -/*** - -MochiKit.Visual 1.4 - -See <http://mochikit.com/> for documentation, downloads, license, etc. - -(c) 2005 Bob Ippolito and others. All rights Reserved. - -***/ - -if (typeof(dojo) != 'undefined') { - dojo.provide('MochiKit.Visual'); - dojo.require('MochiKit.Base'); - dojo.require('MochiKit.DOM'); - dojo.require('MochiKit.Style'); - dojo.require('MochiKit.Color'); - dojo.require('MochiKit.Position'); -} - -if (typeof(JSAN) != 'undefined') { - JSAN.use("MochiKit.Base", []); - JSAN.use("MochiKit.DOM", []); - JSAN.use("MochiKit.Style", []); - JSAN.use("MochiKit.Color", []); - JSAN.use("MochiKit.Position", []); -} - -try { - if (typeof(MochiKit.Base) === 'undefined' || - typeof(MochiKit.DOM) === 'undefined' || - typeof(MochiKit.Style) === 'undefined' || - typeof(MochiKit.Position) === 'undefined' || - typeof(MochiKit.Color) === 'undefined') { - throw ""; - } -} catch (e) { - throw "MochiKit.Visual depends on MochiKit.Base, MochiKit.DOM, MochiKit.Style, MochiKit.Position and MochiKit.Color!"; -} - -if (typeof(MochiKit.Visual) == "undefined") { - MochiKit.Visual = {}; -} - -MochiKit.Visual.NAME = "MochiKit.Visual"; -MochiKit.Visual.VERSION = "1.4"; - -MochiKit.Visual.__repr__ = function () { - return "[" + this.NAME + " " + this.VERSION + "]"; -}; - -MochiKit.Visual.toString = function () { - return this.__repr__(); -}; - -MochiKit.Visual._RoundCorners = function (e, options) { - e = MochiKit.DOM.getElement(e); - this._setOptions(options); - if (this.options.__unstable__wrapElement) { - e = this._doWrap(e); - } - - var color = this.options.color; - var C = MochiKit.Color.Color; - if (this.options.color === "fromElement") { - color = C.fromBackground(e); - } else if (!(color instanceof C)) { - color = C.fromString(color); - } - this.isTransparent = (color.asRGB().a <= 0); - - var bgColor = this.options.bgColor; - if (this.options.bgColor === "fromParent") { - bgColor = C.fromBackground(e.offsetParent); - } else if (!(bgColor instanceof C)) { - bgColor = C.fromString(bgColor); - } - - this._roundCornersImpl(e, color, bgColor); -}; - -MochiKit.Visual._RoundCorners.prototype = { - _doWrap: function (e) { - var parent = e.parentNode; - var doc = MochiKit.DOM.currentDocument(); - if (typeof(doc.defaultView) === "undefined" - || doc.defaultView === null) { - return e; - } - var style = doc.defaultView.getComputedStyle(e, null); - if (typeof(style) === "undefined" || style === null) { - return e; - } - var wrapper = MochiKit.DOM.DIV({"style": { - display: "block", - // convert padding to margin - marginTop: style.getPropertyValue("padding-top"), - marginRight: style.getPropertyValue("padding-right"), - marginBottom: style.getPropertyValue("padding-bottom"), - marginLeft: style.getPropertyValue("padding-left"), - // remove padding so the rounding looks right - padding: "0px" - /* - paddingRight: "0px", - paddingLeft: "0px" - */ - }}); - wrapper.innerHTML = e.innerHTML; - e.innerHTML = ""; - e.appendChild(wrapper); - return e; - }, - - _roundCornersImpl: function (e, color, bgColor) { - if (this.options.border) { - this._renderBorder(e, bgColor); - } - if (this._isTopRounded()) { - this._roundTopCorners(e, color, bgColor); - } - if (this._isBottomRounded()) { - this._roundBottomCorners(e, color, bgColor); - } - }, - - _renderBorder: function (el, bgColor) { - var borderValue = "1px solid " + this._borderColor(bgColor); - var borderL = "border-left: " + borderValue; - var borderR = "border-right: " + borderValue; - var style = "style='" + borderL + ";" + borderR + "'"; - el.innerHTML = "<div " + style + ">" + el.innerHTML + "</div>"; - }, - - _roundTopCorners: function (el, color, bgColor) { - var corner = this._createCorner(bgColor); - for (var i = 0; i < this.options.numSlices; i++) { - corner.appendChild( - this._createCornerSlice(color, bgColor, i, "top") - ); - } - el.style.paddingTop = 0; - el.insertBefore(corner, el.firstChild); - }, - - _roundBottomCorners: function (el, color, bgColor) { - var corner = this._createCorner(bgColor); - for (var i = (this.options.numSlices - 1); i >= 0; i--) { - corner.appendChild( - this._createCornerSlice(color, bgColor, i, "bottom") - ); - } - el.style.paddingBottom = 0; - el.appendChild(corner); - }, - - _createCorner: function (bgColor) { - var dom = MochiKit.DOM; - return dom.DIV({style: {backgroundColor: bgColor.toString()}}); - }, - - _createCornerSlice: function (color, bgColor, n, position) { - var slice = MochiKit.DOM.SPAN(); - - var inStyle = slice.style; - inStyle.backgroundColor = color.toString(); - inStyle.display = "block"; - inStyle.height = "1px"; - inStyle.overflow = "hidden"; - inStyle.fontSize = "1px"; - - var borderColor = this._borderColor(color, bgColor); - if (this.options.border && n === 0) { - inStyle.borderTopStyle = "solid"; - inStyle.borderTopWidth = "1px"; - inStyle.borderLeftWidth = "0px"; - inStyle.borderRightWidth = "0px"; - inStyle.borderBottomWidth = "0px"; - // assumes css compliant box model - inStyle.height = "0px"; - inStyle.borderColor = borderColor.toString(); - } else if (borderColor) { - inStyle.borderColor = borderColor.toString(); - inStyle.borderStyle = "solid"; - inStyle.borderWidth = "0px 1px"; - } - - if (!this.options.compact && (n == (this.options.numSlices - 1))) { - inStyle.height = "2px"; - } - - this._setMargin(slice, n, position); - this._setBorder(slice, n, position); - - return slice; - }, - - _setOptions: function (options) { - this.options = { - corners: "all", - color: "fromElement", - bgColor: "fromParent", - blend: true, - border: false, - compact: false, - __unstable__wrapElement: false - }; - MochiKit.Base.update(this.options, options); - - this.options.numSlices = (this.options.compact ? 2 : 4); - }, - - _whichSideTop: function () { - var corners = this.options.corners; - if (this._hasString(corners, "all", "top")) { - return ""; - } - - var has_tl = (corners.indexOf("tl") != -1); - var has_tr = (corners.indexOf("tr") != -1); - if (has_tl && has_tr) { - return ""; - } - if (has_tl) { - return "left"; - } - if (has_tr) { - return "right"; - } - return ""; - }, - - _whichSideBottom: function () { - var corners = this.options.corners; - if (this._hasString(corners, "all", "bottom")) { - return ""; - } - - var has_bl = (corners.indexOf('bl') != -1); - var has_br = (corners.indexOf('br') != -1); - if (has_bl && has_br) { - return ""; - } - if (has_bl) { - return "left"; - } - if (has_br) { - return "right"; - } - return ""; - }, - - _borderColor: function (color, bgColor) { - if (color == "transparent") { - return bgColor; - } else if (this.options.border) { - return this.options.border; - } else if (this.options.blend) { - return bgColor.blendedColor(color); - } - return ""; - }, - - - _setMargin: function (el, n, corners) { - var marginSize = this._marginSize(n) + "px"; - var whichSide = ( - corners == "top" ? this._whichSideTop() : this._whichSideBottom() - ); - var style = el.style; - - if (whichSide == "left") { - style.marginLeft = marginSize; - style.marginRight = "0px"; - } else if (whichSide == "right") { - style.marginRight = marginSize; - style.marginLeft = "0px"; - } else { - style.marginLeft = marginSize; - style.marginRight = marginSize; - } - }, - - _setBorder: function (el, n, corners) { - var borderSize = this._borderSize(n) + "px"; - var whichSide = ( - corners == "top" ? this._whichSideTop() : this._whichSideBottom() - ); - - var style = el.style; - if (whichSide == "left") { - style.borderLeftWidth = borderSize; - style.borderRightWidth = "0px"; - } else if (whichSide == "right") { - style.borderRightWidth = borderSize; - style.borderLeftWidth = "0px"; - } else { - style.borderLeftWidth = borderSize; - style.borderRightWidth = borderSize; - } - }, - - _marginSize: function (n) { - if (this.isTransparent) { - return 0; - } - - var o = this.options; - if (o.compact && o.blend) { - var smBlendedMarginSizes = [1, 0]; - return smBlendedMarginSizes[n]; - } else if (o.compact) { - var compactMarginSizes = [2, 1]; - return compactMarginSizes[n]; - } else if (o.blend) { - var blendedMarginSizes = [3, 2, 1, 0]; - return blendedMarginSizes[n]; - } else { - var marginSizes = [5, 3, 2, 1]; - return marginSizes[n]; - } - }, - - _borderSize: function (n) { - var o = this.options; - var borderSizes; - if (o.compact && (o.blend || this.isTransparent)) { - return 1; - } else if (o.compact) { - borderSizes = [1, 0]; - } else if (o.blend) { - borderSizes = [2, 1, 1, 1]; - } else if (o.border) { - borderSizes = [0, 2, 0, 0]; - } else if (this.isTransparent) { - borderSizes = [5, 3, 2, 1]; - } else { - return 0; - } - return borderSizes[n]; - }, - - _hasString: function (str) { - for (var i = 1; i< arguments.length; i++) { - if (str.indexOf(arguments[i]) != -1) { - return true; - } - } - return false; - }, - - _isTopRounded: function () { - return this._hasString(this.options.corners, - "all", "top", "tl", "tr" - ); - }, - - _isBottomRounded: function () { - return this._hasString(this.options.corners, - "all", "bottom", "bl", "br" - ); - }, - - _hasSingleTextChild: function (el) { - return (el.childNodes.length == 1 && el.childNodes[0].nodeType == 3); - } -}; - -/** @id MochiKit.Visual.roundElement */ -MochiKit.Visual.roundElement = function (e, options) { - new MochiKit.Visual._RoundCorners(e, options); -}; - -/** @id MochiKit.Visual.roundClass */ -MochiKit.Visual.roundClass = function (tagName, className, options) { - var elements = MochiKit.DOM.getElementsByTagAndClassName( - tagName, className - ); - for (var i = 0; i < elements.length; i++) { - MochiKit.Visual.roundElement(elements[i], options); - } -}; - -/** @id MochiKit.Visual.tagifyText */ -MochiKit.Visual.tagifyText = function (element, /* optional */tagifyStyle) { - /*** - - Change a node text to character in tags. - - @param tagifyStyle: the style to apply to character nodes, default to - 'position: relative'. - - ***/ - tagifyStyle = tagifyStyle || 'position:relative'; - if (/MSIE/.test(navigator.userAgent)) { - tagifyStyle += ';zoom:1'; - } - element = MochiKit.DOM.getElement(element); - var ma = MochiKit.Base.map; - ma(function (child) { - if (child.nodeType == 3) { - ma(function (character) { - element.insertBefore( - MochiKit.DOM.SPAN({style: tagifyStyle}, - character == ' ' ? String.fromCharCode(160) : character), child); - }, child.nodeValue.split('')); - MochiKit.DOM.removeElement(child); - } - }, element.childNodes); -}; - -/** @id MochiKit.Visual.forceRerendering */ -MochiKit.Visual.forceRerendering = function (element) { - try { - element = MochiKit.DOM.getElement(element); - var n = document.createTextNode(' '); - element.appendChild(n); - element.removeChild(n); - } catch(e) { - } -}; - -/** @id MochiKit.Visual.multiple */ -MochiKit.Visual.multiple = function (elements, effect, /* optional */options) { - /*** - - Launch the same effect subsequently on given elements. - - ***/ - options = MochiKit.Base.update({ - speed: 0.1, delay: 0.0 - }, options); - var masterDelay = options.delay; - var index = 0; - MochiKit.Base.map(function (innerelement) { - options.delay = index * options.speed + masterDelay; - new effect(innerelement, options); - index += 1; - }, elements); -}; - -MochiKit.Visual.PAIRS = { - 'slide': ['slideDown', 'slideUp'], - 'blind': ['blindDown', 'blindUp'], - 'appear': ['appear', 'fade'], - 'size': ['grow', 'shrink'] -}; - -/** @id MochiKit.Visual.toggle */ -MochiKit.Visual.toggle = function (element, /* optional */effect, /* optional */options) { - /*** - - Toggle an item between two state depending of its visibility, making - a effect between these states. Default effect is 'appear', can be - 'slide' or 'blind'. - - ***/ - element = MochiKit.DOM.getElement(element); - effect = (effect || 'appear').toLowerCase(); - options = MochiKit.Base.update({ - queue: {position: 'end', scope: (element.id || 'global'), limit: 1} - }, options); - var v = MochiKit.Visual; - v[MochiKit.Style.getStyle(element, 'display') != 'none' ? - v.PAIRS[effect][1] : v.PAIRS[effect][0]](element, options); -}; - -/*** - -Transitions: define functions calculating variations depending of a position. - -***/ - -MochiKit.Visual.Transitions = {}; - -/** @id MochiKit.Visual.Transitions.linear */ -MochiKit.Visual.Transitions.linear = function (pos) { - return pos; -}; - -/** @id MochiKit.Visual.Transitions.sinoidal */ -MochiKit.Visual.Transitions.sinoidal = function (pos) { - return (-Math.cos(pos*Math.PI)/2) + 0.5; -}; - -/** @id MochiKit.Visual.Transitions.reverse */ -MochiKit.Visual.Transitions.reverse = function (pos) { - return 1 - pos; -}; - -/** @id MochiKit.Visual.Transitions.flicker */ -MochiKit.Visual.Transitions.flicker = function (pos) { - return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; -}; - -/** @id MochiKit.Visual.Transitions.wobble */ -MochiKit.Visual.Transitions.wobble = function (pos) { - return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; -}; - -/** @id MochiKit.Visual.Transitions.pulse */ -MochiKit.Visual.Transitions.pulse = function (pos, pulses) { - if (!pulses) { - return (Math.floor(pos*10) % 2 === 0 ? - (pos*10 - Math.floor(pos*10)) : 1 - (pos*10 - Math.floor(pos*10))); - } - return (Math.round((pos % (1/pulses)) * pulses) == 0 ? - ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) : - 1 - ((pos * pulses * 2) - Math.floor(pos * pulses * 2))); -}; - -/** @id MochiKit.Visual.Transitions.none */ -MochiKit.Visual.Transitions.none = function (pos) { - return 0; -}; - -/** @id MochiKit.Visual.Transitions.full */ -MochiKit.Visual.Transitions.full = function (pos) { - return 1; -}; - -/*** - -Core effects - -***/ - -MochiKit.Visual.ScopedQueue = function () { - var cls = arguments.callee; - if (!(this instanceof cls)) { - return new cls(); - } - this.__init__(); -}; - -MochiKit.Base.update(MochiKit.Visual.ScopedQueue.prototype, { - __init__: function () { - this.effects = []; - this.interval = null; - }, - - /** @id MochiKit.Visual.ScopedQueue.prototype.add */ - add: function (effect) { - var timestamp = new Date().getTime(); - - var position = (typeof(effect.options.queue) == 'string') ? - effect.options.queue : effect.options.queue.position; - - var ma = MochiKit.Base.map; - switch (position) { - case 'front': - // move unstarted effects after this effect - ma(function (e) { - if (e.state == 'idle') { - e.startOn += effect.finishOn; - e.finishOn += effect.finishOn; - } - }, this.effects); - break; - case 'end': - var finish; - // start effect after last queued effect has finished - ma(function (e) { - var i = e.finishOn; - if (i >= (finish || i)) { - finish = i; - } - }, this.effects); - timestamp = finish || timestamp; - break; - case 'break': - ma(function (e) { - e.finalize(); - }, this.effects); - break; - } - - effect.startOn += timestamp; - effect.finishOn += timestamp; - if (!effect.options.queue.limit || - this.effects.length < effect.options.queue.limit) { - this.effects.push(effect); - } - - if (!this.interval) { - this.interval = this.startLoop(MochiKit.Base.bind(this.loop, this), - 40); - } - }, - - /** @id MochiKit.Visual.ScopedQueue.prototype.startLoop */ - startLoop: function (func, interval) { - return setInterval(func, interval); - }, - - /** @id MochiKit.Visual.ScopedQueue.prototype.remove */ - remove: function (effect) { - this.effects = MochiKit.Base.filter(function (e) { - return e != effect; - }, this.effects); - if (!this.effects.length) { - this.stopLoop(this.interval); - this.interval = null; - } - }, - - /** @id MochiKit.Visual.ScopedQueue.prototype.stopLoop */ - stopLoop: function (interval) { - clearInterval(interval); - }, - - /** @id MochiKit.Visual.ScopedQueue.prototype.loop */ - loop: function () { - var timePos = new Date().getTime(); - MochiKit.Base.map(function (effect) { - effect.loop(timePos); - }, this.effects); - } -}); - -MochiKit.Visual.Queues = { - instances: {}, - - get: function (queueName) { - if (typeof(queueName) != 'string') { - return queueName; - } - - if (!this.instances[queueName]) { - this.instances[queueName] = new MochiKit.Visual.ScopedQueue(); - } - return this.instances[queueName]; - } -}; - -MochiKit.Visual.Queue = MochiKit.Visual.Queues.get('global'); - -MochiKit.Visual.DefaultOptions = { - transition: MochiKit.Visual.Transitions.sinoidal, - duration: 1.0, // seconds - fps: 25.0, // max. 25fps due to MochiKit.Visual.Queue implementation - sync: false, // true for combining - from: 0.0, - to: 1.0, - delay: 0.0, - queue: 'parallel' -}; - -MochiKit.Visual.Base = function () {}; - -MochiKit.Visual.Base.prototype = { - /*** - - Basic class for all Effects. Define a looping mechanism called for each step - of an effect. Don't instantiate it, only subclass it. - - ***/ - - __class__ : MochiKit.Visual.Base, - - /** @id MochiKit.Visual.Base.prototype.start */ - start: function (options) { - var v = MochiKit.Visual; - this.options = MochiKit.Base.setdefault(options, - v.DefaultOptions); - this.currentFrame = 0; - this.state = 'idle'; - this.startOn = this.options.delay*1000; - this.finishOn = this.startOn + (this.options.duration*1000); - this.event('beforeStart'); - if (!this.options.sync) { - v.Queues.get(typeof(this.options.queue) == 'string' ? - 'global' : this.options.queue.scope).add(this); - } - }, - - /** @id MochiKit.Visual.Base.prototype.loop */ - loop: function (timePos) { - if (timePos >= this.startOn) { - if (timePos >= this.finishOn) { - return this.finalize(); - } - var pos = (timePos - this.startOn) / (this.finishOn - this.startOn); - var frame = - Math.round(pos * this.options.fps * this.options.duration); - if (frame > this.currentFrame) { - this.render(pos); - this.currentFrame = frame; - } - } - }, - - /** @id MochiKit.Visual.Base.prototype.render */ - render: function (pos) { - if (this.state == 'idle') { - this.state = 'running'; - this.event('beforeSetup'); - this.setup(); - this.event('afterSetup'); - } - if (this.state == 'running') { - if (this.options.transition) { - pos = this.options.transition(pos); - } - pos *= (this.options.to - this.options.from); - pos += this.options.from; - this.event('beforeUpdate'); - this.update(pos); - this.event('afterUpdate'); - } - }, - - /** @id MochiKit.Visual.Base.prototype.cancel */ - cancel: function () { - if (!this.options.sync) { - MochiKit.Visual.Queues.get(typeof(this.options.queue) == 'string' ? - 'global' : this.options.queue.scope).remove(this); - } - this.state = 'finished'; - }, - - /** @id MochiKit.Visual.Base.prototype.finalize */ - finalize: function () { - this.render(1.0); - this.cancel(); - this.event('beforeFinish'); - this.finish(); - this.event('afterFinish'); - }, - - setup: function () { - }, - - finish: function () { - }, - - update: function (position) { - }, - - /** @id MochiKit.Visual.Base.prototype.event */ - event: function (eventName) { - if (this.options[eventName + 'Internal']) { - this.options[eventName + 'Internal'](this); - } - if (this.options[eventName]) { - this.options[eventName](this); - } - }, - - /** @id MochiKit.Visual.Base.prototype.repr */ - repr: function () { - return '[' + this.__class__.NAME + ', options:' + - MochiKit.Base.repr(this.options) + ']'; - } -}; - - /** @id MochiKit.Visual.Parallel */ -MochiKit.Visual.Parallel = function (effects, options) { - var cls = arguments.callee; - if (!(this instanceof cls)) { - return new cls(effects, options); - } - - this.__init__(effects, options); -}; - -MochiKit.Visual.Parallel.prototype = new MochiKit.Visual.Base(); - -MochiKit.Base.update(MochiKit.Visual.Parallel.prototype, { - /*** - - Run multiple effects at the same time. - - ***/ - - __class__ : MochiKit.Visual.Parallel, - - __init__: function (effects, options) { - this.effects = effects || []; - this.start(options); - }, - - /** @id MochiKit.Visual.Parallel.prototype.update */ - update: function (position) { - MochiKit.Base.map(function (effect) { - effect.render(position); - }, this.effects); - }, - - /** @id MochiKit.Visual.Parallel.prototype.finish */ - finish: function () { - MochiKit.Base.map(function (effect) { - effect.finalize(); - }, this.effects); - } -}); - -/** @id MochiKit.Visual.Opacity */ -MochiKit.Visual.Opacity = function (element, options) { - var cls = arguments.callee; - if (!(this instanceof cls)) { - return new cls(element, options); - } - this.__init__(element, options); -}; - -MochiKit.Visual.Opacity.prototype = new MochiKit.Visual.Base(); - -MochiKit.Base.update(MochiKit.Visual.Opacity.prototype, { - /*** - - Change the opacity of an element. - - @param options: 'from' and 'to' change the starting and ending opacities. - Must be between 0.0 and 1.0. Default to current opacity and 1.0. - - ***/ - - __class__ : MochiKit.Visual.Opacity, - - __init__: function (element, /* optional */options) { - var b = MochiKit.Base; - var s = MochiKit.Style; - this.element = MochiKit.DOM.getElement(element); - // make this work on IE on elements without 'layout' - if (this.element.currentStyle && - (!this.element.currentStyle.hasLayout)) { - s.setStyle(this.element, {zoom: 1}); - } - options = b.update({ - from: s.getStyle(this.element, 'opacity') || 0.0, - to: 1.0 - }, options); - this.start(options); - }, - - /** @id MochiKit.Visual.Opacity.prototype.update */ - update: function (position) { - MochiKit.Style.setStyle(this.element, {'opacity': position}); - } -}); - -/** @id MochiKit.Visual.Move.prototype */ -MochiKit.Visual.Move = function (element, options) { - var cls = arguments.callee; - if (!(this instanceof cls)) { - return new cls(element, options); - } - this.__init__(element, options); -}; - -MochiKit.Visual.Move.prototype = new MochiKit.Visual.Base(); - -MochiKit.Base.update(MochiKit.Visual.Move.prototype, { - /*** - - Move an element between its current position to a defined position - - @param options: 'x' and 'y' for final positions, default to 0, 0. - - ***/ - - __class__ : MochiKit.Visual.Move, - - __init__: function (element, /* optional */options) { - this.element = MochiKit.DOM.getElement(element); - options = MochiKit.Base.update({ - x: 0, - y: 0, - mode: 'relative' - }, options); - this.start(options); - }, - - /** @id MochiKit.Visual.Move.prototype.setup */ - setup: function () { - // Bug in Opera: Opera returns the 'real' position of a static element - // or relative element that does not have top/left explicitly set. - // ==> Always set top and left for position relative elements in your - // stylesheets (to 0 if you do not need them) - MochiKit.DOM.makePositioned(this.element); - - var s = this.element.style; - var originalVisibility = s.visibility; - var originalDisplay = s.display; - if (originalDisplay == 'none') { - s.visibility = 'hidden'; - s.display = ''; - } - - this.originalLeft = parseFloat(MochiKit.Style.getStyle(this.element, 'left') || '0'); - this.originalTop = parseFloat(MochiKit.Style.getStyle(this.element, 'top') || '0'); - - if (this.options.mode == 'absolute') { - // absolute movement, so we need to calc deltaX and deltaY - this.options.x -= this.originalLeft; - this.options.y -= this.originalTop; - } - if (originalDisplay == 'none') { - s.visibility = originalVisibility; - s.display = originalDisplay; - } - }, - - /** @id MochiKit.Visual.Move.prototype.update */ - update: function (position) { - MochiKit.Style.setStyle(this.element, { - left: Math.round(this.options.x * position + this.originalLeft) + 'px', - top: Math.round(this.options.y * position + this.originalTop) + 'px' - }); - } -}); - -/** @id MochiKit.Visual.Scale */ -MochiKit.Visual.Scale = function (element, percent, options) { - var cls = arguments.callee; - if (!(this instanceof cls)) { - return new cls(element, percent, options); - } - this.__init__(element, percent, options); -}; - -MochiKit.Visual.Scale.prototype = new MochiKit.Visual.Base(); - -MochiKit.Base.update(MochiKit.Visual.Scale.prototype, { - /*** - - Change the size of an element. - - @param percent: final_size = percent*original_size - - @param options: several options changing scale behaviour - - ***/ - - __class__ : MochiKit.Visual.Scale, - - __init__: function (element, percent, /* optional */options) { - this.element = MochiKit.DOM.getElement(element); - options = MochiKit.Base.update({ - scaleX: true, - scaleY: true, - scaleContent: true, - scaleFromCenter: false, - scaleMode: 'box', // 'box' or 'contents' or {} with provided values - scaleFrom: 100.0, - scaleTo: percent - }, options); - this.start(options); - }, - - /** @id MochiKit.Visual.Scale.prototype.setup */ - setup: function () { - this.restoreAfterFinish = this.options.restoreAfterFinish || false; - this.elementPositioning = MochiKit.Style.getStyle(this.element, - 'position'); - - var ma = MochiKit.Base.map; - var b = MochiKit.Base.bind; - this.originalStyle = {}; - ma(b(function (k) { - this.originalStyle[k] = this.element.style[k]; - }, this), ['top', 'left', 'width', 'height', 'fontSize']); - - this.originalTop = this.element.offsetTop; - this.originalLeft = this.element.offsetLeft; - - var fontSize = MochiKit.Style.getStyle(this.element, - 'font-size') || '100%'; - ma(b(function (fontSizeType) { - if (fontSize.indexOf(fontSizeType) > 0) { - this.fontSize = parseFloat(fontSize); - this.fontSizeType = fontSizeType; - } - }, this), ['em', 'px', '%']); - - this.factor = (this.options.scaleTo - this.options.scaleFrom)/100; - - if (/^content/.test(this.options.scaleMode)) { - this.dims = [this.element.scrollHeight, this.element.scrollWidth]; - } else if (this.options.scaleMode == 'box') { - this.dims = [this.element.offsetHeight, this.element.offsetWidth]; - } else { - this.dims = [this.options.scaleMode.originalHeight, - this.options.scaleMode.originalWidth]; - } - }, - - /** @id MochiKit.Visual.Scale.prototype.update */ - update: function (position) { - var currentScale = (this.options.scaleFrom/100.0) + - (this.factor * position); - if (this.options.scaleContent && this.fontSize) { - MochiKit.Style.setStyle(this.element, { - fontSize: this.fontSize * currentScale + this.fontSizeType - }); - } - this.setDimensions(this.dims[0] * currentScale, - this.dims[1] * currentScale); - }, - - /** @id MochiKit.Visual.Scale.prototype.finish */ - finish: function () { - if (this.restoreAfterFinish) { - MochiKit.Style.setStyle(this.element, this.originalStyle); - } - }, - - /** @id MochiKit.Visual.Scale.prototype.setDimensions */ - setDimensions: function (height, width) { - var d = {}; - var r = Math.round; - if (/MSIE/.test(navigator.userAgent)) { - r = Math.ceil; - } - if (this.options.scaleX) { - d.width = r(width) + 'px'; - } - if (this.options.scaleY) { - d.height = r(height) + 'px'; - } - if (this.options.scaleFromCenter) { - var topd = (height - this.dims[0])/2; - var leftd = (width - this.dims[1])/2; - if (this.elementPositioning == 'absolute') { - if (this.options.scaleY) { - d.top = this.originalTop - topd + 'px'; - } - if (this.options.scaleX) { - d.left = this.originalLeft - leftd + 'px'; - } - } else { - if (this.options.scaleY) { - d.top = -topd + 'px'; - } - if (this.options.scaleX) { - d.left = -leftd + 'px'; - } - } - } - MochiKit.Style.setStyle(this.element, d); - } -}); - -/** @id MochiKit.Visual.Highlight */ -MochiKit.Visual.Highlight = function (element, options) { - var cls = arguments.callee; - if (!(this instanceof cls)) { - return new cls(element, options); - } - this.__init__(element, options); -}; - -MochiKit.Visual.Highlight.prototype = new MochiKit.Visual.Base(); - -MochiKit.Base.update(MochiKit.Visual.Highlight.prototype, { - /*** - - Highlight an item of the page. - - @param options: 'startcolor' for choosing highlighting color, default - to '#ffff99'. - - ***/ - - __class__ : MochiKit.Visual.Highlight, - - __init__: function (element, /* optional */options) { - this.element = MochiKit.DOM.getElement(element); - options = MochiKit.Base.update({ - startcolor: '#ffff99' - }, options); - this.start(options); - }, - - /** @id MochiKit.Visual.Highlight.prototype.setup */ - setup: function () { - var b = MochiKit.Base; - var s = MochiKit.Style; - // Prevent executing on elements not in the layout flow - if (s.getStyle(this.element, 'display') == 'none') { - this.cancel(); - return; - } - // Disable background image during the effect - this.oldStyle = { - backgroundImage: s.getStyle(this.element, 'background-image') - }; - s.setStyle(this.element, { - backgroundImage: 'none' - }); - - if (!this.options.endcolor) { - this.options.endcolor = - MochiKit.Color.Color.fromBackground(this.element).toHexString(); - } - if (b.isUndefinedOrNull(this.options.restorecolor)) { - this.options.restorecolor = s.getStyle(this.element, - 'background-color'); - } - // init color calculations - this._base = b.map(b.bind(function (i) { - return parseInt( - this.options.startcolor.slice(i*2 + 1, i*2 + 3), 16); - }, this), [0, 1, 2]); - this._delta = b.map(b.bind(function (i) { - return parseInt(this.options.endcolor.slice(i*2 + 1, i*2 + 3), 16) - - this._base[i]; - }, this), [0, 1, 2]); - }, - - /** @id MochiKit.Visual.Highlight.prototype.update */ - update: function (position) { - var m = '#'; - MochiKit.Base.map(MochiKit.Base.bind(function (i) { - m += MochiKit.Color.toColorPart(Math.round(this._base[i] + - this._delta[i]*position)); - }, this), [0, 1, 2]); - MochiKit.Style.setStyle(this.element, { - backgroundColor: m - }); - }, - - /** @id MochiKit.Visual.Highlight.prototype.finish */ - finish: function () { - MochiKit.Style.setStyle(this.element, - MochiKit.Base.update(this.oldStyle, { - backgroundColor: this.options.restorecolor - })); - } -}); - -/** @id MochiKit.Visual.ScrollTo */ -MochiKit.Visual.ScrollTo = function (element, options) { - var cls = arguments.callee; - if (!(this instanceof cls)) { - return new cls(element, options); - } - this.__init__(element, options); -}; - -MochiKit.Visual.ScrollTo.prototype = new MochiKit.Visual.Base(); - -MochiKit.Base.update(MochiKit.Visual.ScrollTo.prototype, { - /*** - - Scroll to an element in the page. - - ***/ - - __class__ : MochiKit.Visual.ScrollTo, - - __init__: function (element, /* optional */options) { - this.element = MochiKit.DOM.getElement(element); - this.start(options); - }, - - /** @id MochiKit.Visual.ScrollTo.prototype.setup */ - setup: function () { - var p = MochiKit.Position; - p.prepare(); - var offsets = p.cumulativeOffset(this.element); - if (this.options.offset) { - offsets.y += this.options.offset; - } - var max; - if (window.innerHeight) { - max = window.innerHeight - window.height; - } else if (document.documentElement && - document.documentElement.clientHeight) { - max = document.documentElement.clientHeight - - document.body.scrollHeight; - } else if (document.body) { - max = document.body.clientHeight - document.body.scrollHeight; - } - this.scrollStart = p.windowOffset.y; - this.delta = (offsets.y > max ? max : offsets.y) - this.scrollStart; - }, - - /** @id MochiKit.Visual.ScrollTo.prototype.update */ - update: function (position) { - var p = MochiKit.Position; - p.prepare(); - window.scrollTo(p.windowOffset.x, this.scrollStart + (position * this.delta)); - } -}); - -MochiKit.Visual.CSS_LENGTH = /^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/; - -MochiKit.Visual.Morph = function (element, options) { - var cls = arguments.callee; - if (!(this instanceof cls)) { - return new cls(element, options); - } - this.__init__(element, options); -}; - -MochiKit.Visual.Morph.prototype = new MochiKit.Visual.Base(); - -MochiKit.Base.update(MochiKit.Visual.Morph.prototype, { - /*** - - Morph effect: make a transformation from current style to the given style, - automatically making a transition between the two. - - ***/ - - __class__ : MochiKit.Visual.Morph, - - __init__: function (element, /* optional */options) { - this.element = MochiKit.DOM.getElement(element); - this.start(options); - }, - - /** @id MochiKit.Visual.Morph.prototype.setup */ - setup: function () { - var b = MochiKit.Base; - var style = this.options.style; - this.styleStart = {}; - this.styleEnd = {}; - this.units = {}; - var value, unit; - for (var s in style) { - value = style[s]; - s = b.camelize(s); - if (MochiKit.Visual.CSS_LENGTH.test(value)) { - var components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/); - value = parseFloat(components[1]); - unit = (components.length == 3) ? components[2] : null; - this.styleEnd[s] = value; - this.units[s] = unit; - value = MochiKit.Style.getStyle(this.element, s); - components = value.match(/^([\+\-]?[0-9\.]+)(.*)$/); - value = parseFloat(components[1]); - this.styleStart[s] = value; - } else { - var c = MochiKit.Color.Color; - value = c.fromString(value); - if (value) { - this.units[s] = "color"; - this.styleEnd[s] = value.toHexString(); - value = MochiKit.Style.getStyle(this.element, s); - this.styleStart[s] = c.fromString(value).toHexString(); - - this.styleStart[s] = b.map(b.bind(function (i) { - return parseInt( - this.styleStart[s].slice(i*2 + 1, i*2 + 3), 16); - }, this), [0, 1, 2]); - this.styleEnd[s] = b.map(b.bind(function (i) { - return parseInt( - this.styleEnd[s].slice(i*2 + 1, i*2 + 3), 16); - }, this), [0, 1, 2]); - } - } - } - }, - - /** @id MochiKit.Visual.Morph.prototype.update */ - update: function (position) { - var value; - for (var s in this.styleStart) { - if (this.units[s] == "color") { - var m = '#'; - var start = this.styleStart[s]; - var end = this.styleEnd[s]; - MochiKit.Base.map(MochiKit.Base.bind(function (i) { - m += MochiKit.Color.toColorPart(Math.round(start[i] + - (end[i] - start[i])*position)); - }, this), [0, 1, 2]); - this.element.style[s] = m; - } else { - value = this.styleStart[s] + Math.round((this.styleEnd[s] - this.styleStart[s]) * position * 1000) / 1000 + this.units[s]; - this.element.style[s] = value; - } - } - } -}); - -/*** - -Combination effects. - -***/ - -/** @id MochiKit.Visual.fade */ -MochiKit.Visual.fade = function (element, /* optional */ options) { - /*** - - Fade a given element: change its opacity and hide it in the end. - - @param options: 'to' and 'from' to change opacity. - - ***/ - var s = MochiKit.Style; - var oldOpacity = s.getStyle(element, 'opacity'); - options = MochiKit.Base.update({ - from: s.getStyle(element, 'opacity') || 1.0, - to: 0.0, - afterFinishInternal: function (effect) { - if (effect.options.to !== 0) { - return; - } - s.hideElement(effect.element); - s.setStyle(effect.element, {'opacity': oldOpacity}); - } - }, options); - return new MochiKit.Visual.Opacity(element, options); -}; - -/** @id MochiKit.Visual.appear */ -MochiKit.Visual.appear = function (element, /* optional */ options) { - /*** - - Make an element appear. - - @param options: 'to' and 'from' to change opacity. - - ***/ - var s = MochiKit.Style; - var v = MochiKit.Visual; - options = MochiKit.Base.update({ - from: (s.getStyle(element, 'display') == 'none' ? 0.0 : - s.getStyle(element, 'opacity') || 0.0), - to: 1.0, - // force Safari to render floated elements properly - afterFinishInternal: function (effect) { - v.forceRerendering(effect.element); - }, - beforeSetupInternal: function (effect) { - s.setStyle(effect.element, {'opacity': effect.options.from}); - s.showElement(effect.element); - } - }, options); - return new v.Opacity(element, options); -}; - -/** @id MochiKit.Visual.puff */ -MochiKit.Visual.puff = function (element, /* optional */ options) { - /*** - - 'Puff' an element: grow it to double size, fading it and make it hidden. - - ***/ - var s = MochiKit.Style; - var v = MochiKit.Visual; - element = MochiKit.DOM.getElement(element); - var oldStyle = { - position: s.getStyle(element, 'position'), - top: element.style.top, - left: element.style.left, - width: element.style.width, - height: element.style.height, - opacity: s.getStyle(element, 'opacity') - }; - options = MochiKit.Base.update({ - beforeSetupInternal: function (effect) { - MochiKit.Position.absolutize(effect.effects[0].element); - }, - afterFinishInternal: function (effect) { - s.hideElement(effect.effects[0].element); - s.setStyle(effect.effects[0].element, oldStyle); - }, - scaleContent: true, - scaleFromCenter: true - }, options); - return new v.Parallel( - [new v.Scale(element, 200, - {sync: true, scaleFromCenter: options.scaleFromCenter, - scaleContent: options.scaleContent, restoreAfterFinish: true}), - new v.Opacity(element, {sync: true, to: 0.0 })], - options); -}; - -/** @id MochiKit.Visual.blindUp */ -MochiKit.Visual.blindUp = function (element, /* optional */ options) { - /*** - - Blind an element up: change its vertical size to 0. - - ***/ - var d = MochiKit.DOM; - element = d.getElement(element); - var elemClip = d.makeClipping(element); - options = MochiKit.Base.update({ - scaleContent: false, - scaleX: false, - restoreAfterFinish: true, - afterFinishInternal: function (effect) { - MochiKit.Style.hideElement(effect.element); - d.undoClipping(effect.element, elemClip); - } - }, options); - - return new MochiKit.Visual.Scale(element, 0, options); -}; - -/** @id MochiKit.Visual.blindDown */ -MochiKit.Visual.blindDown = function (element, /* optional */ options) { - /*** - - Blind an element down: restore its vertical size. - - ***/ - var d = MochiKit.DOM; - var s = MochiKit.Style; - element = d.getElement(element); - var elementDimensions = s.getElementDimensions(element); - var elemClip; - options = MochiKit.Base.update({ - scaleContent: false, - scaleX: false, - scaleFrom: 0, - scaleMode: {originalHeight: elementDimensions.h, - originalWidth: elementDimensions.w}, - restoreAfterFinish: true, - afterSetupInternal: function (effect) { - elemClip = d.makeClipping(effect.element); - s.setStyle(effect.element, {height: '0px'}); - s.showElement(effect.element); - }, - afterFinishInternal: function (effect) { - d.undoClipping(effect.element, elemClip); - } - }, options); - return new MochiKit.Visual.Scale(element, 100, options); -}; - -/** @id MochiKit.Visual.switchOff */ -MochiKit.Visual.switchOff = function (element, /* optional */ options) { - /*** - - Apply a switch-off-like effect. - - ***/ - var d = MochiKit.DOM; - element = d.getElement(element); - var oldOpacity = MochiKit.Style.getStyle(element, 'opacity'); - var elemClip; - options = MochiKit.Base.update({ - duration: 0.3, - scaleFromCenter: true, - scaleX: false, - scaleContent: false, - restoreAfterFinish: true, - beforeSetupInternal: function (effect) { - d.makePositioned(effect.element); - elemClip = d.makeClipping(effect.element); - }, - afterFinishInternal: function (effect) { - MochiKit.Style.hideElement(effect.element); - d.undoClipping(effect.element, elemClip); - d.undoPositioned(effect.element); - MochiKit.Style.setStyle(effect.element, {'opacity': oldOpacity}); - } - }, options); - var v = MochiKit.Visual; - return new v.appear(element, { - duration: 0.4, - from: 0, - transition: v.Transitions.flicker, - afterFinishInternal: function (effect) { - new v.Scale(effect.element, 1, options); - } - }); -}; - -/** @id MochiKit.Visual.dropOut */ -MochiKit.Visual.dropOut = function (element, /* optional */ options) { - /*** - - Make an element fall and disappear. - - ***/ - var d = MochiKit.DOM; - var s = MochiKit.Style; - element = d.getElement(element); - var oldStyle = { - top: s.getStyle(element, 'top'), - left: s.getStyle(element, 'left'), - opacity: s.getStyle(element, 'opacity') - }; - - options = MochiKit.Base.update({ - duration: 0.5, - distance: 100, - beforeSetupInternal: function (effect) { - d.makePositioned(effect.effects[0].element); - }, - afterFinishInternal: function (effect) { - s.hideElement(effect.effects[0].element); - d.undoPositioned(effect.effects[0].element); - s.setStyle(effect.effects[0].element, oldStyle); - } - }, options); - var v = MochiKit.Visual; - return new v.Parallel( - [new v.Move(element, {x: 0, y: options.distance, sync: true}), - new v.Opacity(element, {sync: true, to: 0.0})], - options); -}; - -/** @id MochiKit.Visual.shake */ -MochiKit.Visual.shake = function (element, /* optional */ options) { - /*** - - Move an element from left to right several times. - - ***/ - var d = MochiKit.DOM; - var v = MochiKit.Visual; - var s = MochiKit.Style; - element = d.getElement(element); - options = MochiKit.Base.update({ - x: -20, - y: 0, - duration: 0.05, - afterFinishInternal: function (effect) { - d.undoPositioned(effect.element); - s.setStyle(effect.element, oldStyle); - } - }, options); - var oldStyle = { - top: s.getStyle(element, 'top'), - left: s.getStyle(element, 'left') }; - return new v.Move(element, - {x: 20, y: 0, duration: 0.05, afterFinishInternal: function (effect) { - new v.Move(effect.element, - {x: -40, y: 0, duration: 0.1, afterFinishInternal: function (effect) { - new v.Move(effect.element, - {x: 40, y: 0, duration: 0.1, afterFinishInternal: function (effect) { - new v.Move(effect.element, - {x: -40, y: 0, duration: 0.1, afterFinishInternal: function (effect) { - new v.Move(effect.element, - {x: 40, y: 0, duration: 0.1, afterFinishInternal: function (effect) { - new v.Move(effect.element, options - ) }}) }}) }}) }}) }}); -}; - -/** @id MochiKit.Visual.slideDown */ -MochiKit.Visual.slideDown = function (element, /* optional */ options) { - /*** - - Slide an element down. - It needs to have the content of the element wrapped in a container - element with fixed height. - - ***/ - var d = MochiKit.DOM; - var b = MochiKit.Base; - var s = MochiKit.Style; - element = d.getElement(element); - if (!element.firstChild) { - throw "MochiKit.Visual.slideDown must be used on a element with a child"; - } - d.removeEmptyTextNodes(element); - var oldInnerBottom = s.getStyle(element.firstChild, 'bottom') || 0; - var elementDimensions = s.getElementDimensions(element); - var elemClip; - options = b.update({ - scaleContent: false, - scaleX: false, - scaleFrom: 0, - scaleMode: {originalHeight: elementDimensions.h, - originalWidth: elementDimensions.w}, - restoreAfterFinish: true, - afterSetupInternal: function (effect) { - d.makePositioned(effect.element); - d.makePositioned(effect.element.firstChild); - if (/Opera/.test(navigator.userAgent)) { - s.setStyle(effect.element, {top: ''}); - } - elemClip = d.makeClipping(effect.element); - s.setStyle(effect.element, {height: '0px'}); - s.showElement(effect.element); - }, - afterUpdateInternal: function (effect) { - s.setStyle(effect.element.firstChild, - {bottom: (effect.dims[0] - effect.element.clientHeight) + 'px'}); - }, - afterFinishInternal: function (effect) { - d.undoClipping(effect.element, elemClip); - // IE will crash if child is undoPositioned first - if (/MSIE/.test(navigator.userAgent)) { - d.undoPositioned(effect.element); - d.undoPositioned(effect.element.firstChild); - } else { - d.undoPositioned(effect.element.firstChild); - d.undoPositioned(effect.element); - } - s.setStyle(effect.element.firstChild, - {bottom: oldInnerBottom}); - } - }, options); - - return new MochiKit.Visual.Scale(element, 100, options); -}; - -/** @id MochiKit.Visual.slideUp */ -MochiKit.Visual.slideUp = function (element, /* optional */ options) { - /*** - - Slide an element up. - It needs to have the content of the element wrapped in a container - element with fixed height. - - ***/ - var d = MochiKit.DOM; - var b = MochiKit.Base; - var s = MochiKit.Style; - element = d.getElement(element); - if (!element.firstChild) { - throw "MochiKit.Visual.slideUp must be used on a element with a child"; - } - d.removeEmptyTextNodes(element); - var oldInnerBottom = s.getStyle(element.firstChild, 'bottom'); - var elemClip; - options = b.update({ - scaleContent: false, - scaleX: false, - scaleMode: 'box', - scaleFrom: 100, - restoreAfterFinish: true, - beforeStartInternal: function (effect) { - d.makePositioned(effect.element); - d.makePositioned(effect.element.firstChild); - if (/Opera/.test(navigator.userAgent)) { - s.setStyle(effect.element, {top: ''}); - } - elemClip = d.makeClipping(effect.element); - s.showElement(effect.element); - }, - afterUpdateInternal: function (effect) { - s.setStyle(effect.element.firstChild, - {bottom: (effect.dims[0] - effect.element.clientHeight) + 'px'}); - }, - afterFinishInternal: function (effect) { - s.hideElement(effect.element); - d.undoClipping(effect.element, elemClip); - d.undoPositioned(effect.element.firstChild); - d.undoPositioned(effect.element); - s.setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); - } - }, options); - return new MochiKit.Visual.Scale(element, 0, options); -}; - -// Bug in opera makes the TD containing this element expand for a instance -// after finish -/** @id MochiKit.Visual.squish */ -MochiKit.Visual.squish = function (element, /* optional */ options) { - /*** - - Reduce an element and make it disappear. - - ***/ - var d = MochiKit.DOM; - var b = MochiKit.Base; - var elemClip; - options = b.update({ - restoreAfterFinish: true, - beforeSetupInternal: function (effect) { - elemClip = d.makeClipping(effect.element); - }, - afterFinishInternal: function (effect) { - MochiKit.Style.hideElement(effect.element); - d.undoClipping(effect.element, elemClip); - } - }, options); - - return new MochiKit.Visual.Scale(element, /Opera/.test(navigator.userAgent) ? 1 : 0, options); -}; - -/** @id MochiKit.Visual.grow */ -MochiKit.Visual.grow = function (element, /* optional */ options) { - /*** - - Grow an element to its original size. Make it zero-sized before - if necessary. - - ***/ - var d = MochiKit.DOM; - var v = MochiKit.Visual; - var s = MochiKit.Style; - element = d.getElement(element); - options = MochiKit.Base.update({ - direction: 'center', - moveTransition: v.Transitions.sinoidal, - scaleTransition: v.Transitions.sinoidal, - opacityTransition: v.Transitions.full, - scaleContent: true, - scaleFromCenter: false - }, options); - var oldStyle = { - top: element.style.top, - left: element.style.left, - height: element.style.height, - width: element.style.width, - opacity: s.getStyle(element, 'opacity') - }; - - var dims = s.getElementDimensions(element); - var initialMoveX, initialMoveY; - var moveX, moveY; - - switch (options.direction) { - case 'top-left': - initialMoveX = initialMoveY = moveX = moveY = 0; - break; - case 'top-right': - initialMoveX = dims.w; - initialMoveY = moveY = 0; - moveX = -dims.w; - break; - case 'bottom-left': - initialMoveX = moveX = 0; - initialMoveY = dims.h; - moveY = -dims.h; - break; - case 'bottom-right': - initialMoveX = dims.w; - initialMoveY = dims.h; - moveX = -dims.w; - moveY = -dims.h; - break; - case 'center': - initialMoveX = dims.w / 2; - initialMoveY = dims.h / 2; - moveX = -dims.w / 2; - moveY = -dims.h / 2; - break; - } - - var optionsParallel = MochiKit.Base.update({ - beforeSetupInternal: function (effect) { - s.setStyle(effect.effects[0].element, {height: '0px'}); - s.showElement(effect.effects[0].element); - }, - afterFinishInternal: function (effect) { - d.undoClipping(effect.effects[0].element); - d.undoPositioned(effect.effects[0].element); - s.setStyle(effect.effects[0].element, oldStyle); - } - }, options); - - return new v.Move(element, { - x: initialMoveX, - y: initialMoveY, - duration: 0.01, - beforeSetupInternal: function (effect) { - s.hideElement(effect.element); - d.makeClipping(effect.element); - d.makePositioned(effect.element); - }, - afterFinishInternal: function (effect) { - new v.Parallel( - [new v.Opacity(effect.element, { - sync: true, to: 1.0, from: 0.0, - transition: options.opacityTransition - }), - new v.Move(effect.element, { - x: moveX, y: moveY, sync: true, - transition: options.moveTransition - }), - new v.Scale(effect.element, 100, { - scaleMode: {originalHeight: dims.h, - originalWidth: dims.w}, - sync: true, - scaleFrom: /Opera/.test(navigator.userAgent) ? 1 : 0, - transition: options.scaleTransition, - scaleContent: options.scaleContent, - scaleFromCenter: options.scaleFromCenter, - restoreAfterFinish: true - }) - ], optionsParallel - ); - } - }); -}; - -/** @id MochiKit.Visual.shrink */ -MochiKit.Visual.shrink = function (element, /* optional */ options) { - /*** - - Shrink an element and make it disappear. - - ***/ - var d = MochiKit.DOM; - var v = MochiKit.Visual; - var s = MochiKit.Style; - element = d.getElement(element); - options = MochiKit.Base.update({ - direction: 'center', - moveTransition: v.Transitions.sinoidal, - scaleTransition: v.Transitions.sinoidal, - opacityTransition: v.Transitions.none, - scaleContent: true, - scaleFromCenter: false - }, options); - var oldStyle = { - top: element.style.top, - left: element.style.left, - height: element.style.height, - width: element.style.width, - opacity: s.getStyle(element, 'opacity') - }; - - var dims = s.getElementDimensions(element); - var moveX, moveY; - - switch (options.direction) { - case 'top-left': - moveX = moveY = 0; - break; - case 'top-right': - moveX = dims.w; - moveY = 0; - break; - case 'bottom-left': - moveX = 0; - moveY = dims.h; - break; - case 'bottom-right': - moveX = dims.w; - moveY = dims.h; - break; - case 'center': - moveX = dims.w / 2; - moveY = dims.h / 2; - break; - } - var elemClip; - - var optionsParallel = MochiKit.Base.update({ - beforeStartInternal: function (effect) { - elemClip = d.makePositioned(effect.effects[0].element); - d.makeClipping(effect.effects[0].element); - }, - afterFinishInternal: function (effect) { - s.hideElement(effect.effects[0].element); - d.undoClipping(effect.effects[0].element, elemClip); - d.undoPositioned(effect.effects[0].element); - s.setStyle(effect.effects[0].element, oldStyle); - } - }, options); - - return new v.Parallel( - [new v.Opacity(element, { - sync: true, to: 0.0, from: 1.0, - transition: options.opacityTransition - }), - new v.Scale(element, /Opera/.test(navigator.userAgent) ? 1 : 0, { - sync: true, transition: options.scaleTransition, - scaleContent: options.scaleContent, - scaleFromCenter: options.scaleFromCenter, - restoreAfterFinish: true - }), - new v.Move(element, { - x: moveX, y: moveY, sync: true, transition: options.moveTransition - }) - ], optionsParallel - ); -}; - -/** @id MochiKit.Visual.pulsate */ -MochiKit.Visual.pulsate = function (element, /* optional */ options) { - /*** - - Pulse an element between appear/fade. - - ***/ - var d = MochiKit.DOM; - var v = MochiKit.Visual; - var b = MochiKit.Base; - var oldOpacity = MochiKit.Style.getStyle(element, 'opacity'); - options = b.update({ - duration: 3.0, - from: 0, - afterFinishInternal: function (effect) { - MochiKit.Style.setStyle(effect.element, {'opacity': oldOpacity}); - } - }, options); - var transition = options.transition || v.Transitions.sinoidal; - var reverser = b.bind(function (pos) { - return transition(1 - v.Transitions.pulse(pos, options.pulses)); - }, transition); - b.bind(reverser, transition); - return new v.Opacity(element, b.update({ - transition: reverser}, options)); -}; - -/** @id MochiKit.Visual.fold */ -MochiKit.Visual.fold = function (element, /* optional */ options) { - /*** - - Fold an element, first vertically, then horizontally. - - ***/ - var d = MochiKit.DOM; - var v = MochiKit.Visual; - var s = MochiKit.Style; - element = d.getElement(element); - var oldStyle = { - top: element.style.top, - left: element.style.left, - width: element.style.width, - height: element.style.height - }; - var elemClip = d.makeClipping(element); - options = MochiKit.Base.update({ - scaleContent: false, - scaleX: false, - afterFinishInternal: function (effect) { - new v.Scale(element, 1, { - scaleContent: false, - scaleY: false, - afterFinishInternal: function (effect) { - s.hideElement(effect.element); - d.undoClipping(effect.element, elemClip); - s.setStyle(effect.element, oldStyle); - } - }); - } - }, options); - return new v.Scale(element, 5, options); -}; - - -// Compatibility with MochiKit 1.0 -MochiKit.Visual.Color = MochiKit.Color.Color; -MochiKit.Visual.getElementsComputedStyle = MochiKit.DOM.computedStyle; - -/* end of Rico adaptation */ - -MochiKit.Visual.__new__ = function () { - var m = MochiKit.Base; - - m.nameFunctions(this); - - this.EXPORT_TAGS = { - ":common": this.EXPORT, - ":all": m.concat(this.EXPORT, this.EXPORT_OK) - }; - -}; - -MochiKit.Visual.EXPORT = [ - "roundElement", - "roundClass", - "tagifyText", - "multiple", - "toggle", - "Parallel", - "Opacity", - "Move", - "Scale", - "Highlight", - "ScrollTo", - "Morph", - "fade", - "appear", - "puff", - "blindUp", - "blindDown", - "switchOff", - "dropOut", - "shake", - "slideDown", - "slideUp", - "squish", - "grow", - "shrink", - "pulsate", - "fold" -]; - -MochiKit.Visual.EXPORT_OK = [ - "Base", - "PAIRS" -]; - -MochiKit.Visual.__new__(); - -MochiKit.Base._exportSymbols(this, MochiKit.Visual); diff --git a/javascript/libs/MochiKit/__package__.js b/javascript/libs/MochiKit/__package__.js deleted file mode 100644 index 8d644b1..0000000 --- a/javascript/libs/MochiKit/__package__.js +++ /dev/null @@ -1,18 +0,0 @@ -dojo.kwCompoundRequire({ - "common": [ - "MochiKit.Base", - "MochiKit.Iter", - "MochiKit.Logging", - "MochiKit.DateTime", - "MochiKit.Format", - "MochiKit.Async", - "MochiKit.DOM", - "MochiKit.Style", - "MochiKit.LoggingPane", - "MochiKit.Color", - "MochiKit.Signal", - "MochiKit.Position", - "MochiKit.Visual" - ] -}); -dojo.provide("MochiKit.*"); diff --git a/javascript/libs/mygosu/DynamicTree.css b/javascript/libs/mygosu/DynamicTree.css deleted file mode 100755 index 145421d..0000000 --- a/javascript/libs/mygosu/DynamicTree.css +++ /dev/null @@ -1,13 +0,0 @@ -.DynamicTree {line-height:18px; white-space:nowrap; cursor:default;} -.DynamicTree .section {background:url(/liberty/icons/tree-branch.gif) repeat-y; display:none;} -.DynamicTree .last {background:none;} -.DynamicTree .folder .folder, -.DynamicTree .doc .doc, -.DynamicTree .folder .doc {margin-left:18px;} -.DynamicTree .text-active {font-weight:bold;} -.DynamicTree img {border:0; vertical-align:middle;} -.DynamicTree .tree-tooltip {float:left;} - -/* hack for IE to fix a bug (background of .section disappearing when mouse is over a link, for example Node 1.1.1.1) */ -* html .DynamicTree .doc {position:relative;} -* html .DynamicTree .doc a {position:absolute; top:3px;} diff --git a/javascript/libs/mygosu/DynamicTreeBuilder.js b/javascript/libs/mygosu/DynamicTreeBuilder.js deleted file mode 100644 index 7858b0a..0000000 --- a/javascript/libs/mygosu/DynamicTreeBuilder.js +++ /dev/null @@ -1,5 +0,0 @@ -// DynamicTree 1.5.0 Author: Cezary Tomczak [www.gosu.pl] Free for any use as long as all copyright messages are intact -eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('7 2q=3i.3e.3g();8 2R(2z){d(2q.3f(2z)+1)}8 P(5){3.14=32;3.b={"2L":"2Z.1K","2N":"35.1K","15":"3h.1K","10":"39.1K","2S":"n-2S.M","W":"n-W.M","R":"n-R.M","1R":"n-R-28.M","1w":"n-1w.M","2h":"n-1w-25.M","4":"n-4.M","1Y":"n-4-25.M","1W":"n-4-28.M","1X":"n-4-28-25.M"};3.2t="";3.2s="";3.3b=8(){7 p,b;o(p 1Q 3.b){3.b[p]=3.14+3.b[p]}o(p 1Q 3.b){3.1E.V(z 3c());3.1E.1c().r=3.b[p];3.b[p]=3.1E.1c().r}3.1B($(3.5).c,3.n);3.2v();6(1x.2K){1x.2K("36",8(e){l.1P()},F)}y 6(1x.2F){1x.2F("31",8(e){l.1P()})}3.D()};3.37=8(){3.20();3.n=z C("n","",Q,z t(),F,N);3.m={};3.q=[];3.9="";3.21=0;3.1B($(3.5).c,3.n);3.D()};3.1B=8(k,n){o(7 i=0;i<k.f;i++){6(k[i].2p==1){6(!k[i].17){2H}k[i].5=3.5+"-"+(++3.21);7 4=z C();4.5=k[i].5;6(k[i].13){6(k[i].13.3a=="A"){7 a=k[i].13;6(a.13){4.h=a.13.2k.1f()}6(a.S){7 s=a.j.2w.3d(/S=["\'](2G:\\/\\/2G\\/)?([^"\']*)["\']/i);6(s){4.S=s[2]}}6(a.1F){4.1F=a.1F}6(a.1H){4.1H=a.1H}}y{4.h=k[i].13.2k.1f()}}4.j=n;4.c=(k[i].17=="R"?z t():Q);4.1e=(k[i].17=="W");4.H=(k[i].17=="R");n.c.V(4);3.m[4.5]=4}6(k[i].2p==1&&k[i].c){3.1B(k[i].c,n.c.1c())}}};3.2U=8(5){7 19=$(5+"-2d");7 4=$(5+"-4");7 J=$(5+"-J");6(19.1z.1y=="2e"){19.1z.1y="38";6(3.m[5].L()){4.r=3.b.1Y}y{4.r=3.b.4}J.r=3.b.R;3.q.23(5)}y{19.1z.1y="2e";6(3.m[5].L()){4.r=3.b.1X}y{4.r=3.b.1W}J.r=3.b.1R;3.q.V(5)}6(4.1h){4.1h=4.1h}6(J.1h){J.1h=J.1h}};3.2c=8(5){6(3.9){$(3.9+"-h").17="h"}$(5+"-h").17="h-9";3.9=5;3.2m.2o()};3.1l=8(){7 s="";7 k=3.n.c;o(7 i=0;i<k.f;i++){s+=k[i].1l()}d s};3.D=8(){$(3.5).2w=3.1l()};3.2v=8(){7 q=3.E.2O("q");6(q){3.q=q.1I("|");3.q.27(8(5){d l.m[5]&&l.m[5].H&&l.m[5].c.f})}};3.1P=8(){6(3.q.f){3.E.2I("q",3.q.33("|"),34*24*30,3.2t,3.2s)}y{3.20()}};3.20=8(){3.E.2Y("q")};3.2P=8(){6(!3.9){w"P.2P() u, 3m 3k 2x 9 4"}d 3.m[3.9]};3.3I=8(){d 3.9&&!3.m[3.9].1T()};3.3H=8(){d 3.9&&!3.m[3.9].L()};3.3F=8(){d 3.9&&(3.m[3.9].2E()>1)};3.3C=8(){6(3.9){7 4=3.m[3.9].Y();1U(4){6(4.H){d N}4=4.Y()}}d F};3.2B=8(){d 2u(3.9)};3.2D=8(){d 2u(3.9)};3.1S=8(){d 3.9&&3.m[3.9].H};3.3E=8(){6(3.9){7 4=3.m[3.9];6(4.1e){d N}6(4.H&&!4.c.f){d N}}d F};3.3J=8(){7 4=3.m[3.9];7 I=4.K();7 1b=4.j;1b.16(4);1b.T(4,I-1);3.D()};3.3K=8(){7 4=3.m[3.9];7 I=4.K();7 1b=4.j;1b.16(4);1b.T(4,I+1);3.D()};3.3M=8(){7 4=3.m[3.9];7 15=4.j;15.16(4);15.j.T(4,15.K()+1);3.D()};3.3Q=8(){7 4=3.m[3.9];7 1g=4.Y();7 1O=Q;1U(1g){6(1g.H){1O=1g.5;3P}1g=1g.Y()}7 10=3.m[1O];4.j.16(4);6(10.c.f){10.T(4,10.c.f)}y{10.11(4)}3.D()};3.X=8(5,h,x,B){6(!5||3.m[5]||!h||(x!="W"&&x!="R")){w 3.5+\'.X("\'+5+\'", "\'+h+\'", "\'+x+\'") u, 1k 1j\'}7 4;6(x=="W"){4=z C(5,h,Q,Q,N,F)}y{4=z C(5,h,Q,z t(),F,N)}6(B){o(7 p 1Q B){4[p]=B[p]}}3.m[5]=4;d 4};3.3L=8(5,h,x,B){7 4=3.X(5,h,x,B);6(3.n.c.f){3.n.T(4,0)}y{3.n.11(4)}3.D()};3.2C=8(5,h,x,B){6(!3.2B()){w 3.5+\'.2C() u, 1k 1j\'}7 4=3.X(5,h,x,B);7 9=3.m[3.9];9.j.T(4,9.K());3.D()};3.2r=8(5,h,x,B){6(!3.2D()){w 3.5+\'.2r() u, 1k 1j\'}7 4=3.X(5,h,x,B);7 9=3.m[3.9];6(9.j.c[9.K()+1]){9.j.T(4,9.K()+1)}y{9.j.11(4)}3.D()};3.2y=8(5,h,x,B){6(!3.1S()){w 3.5+\'.2y() u, 1k 1j\'}7 4=3.X(5,h,x,B);7 9=3.m[3.9];6(9.c.f){9.T(4,0)}y{9.11(4)}3.D()};3.2j=8(5,h,x,B){6(!3.1S()){w 3.5+\'.2j() u, 1k 1j\'}7 4=3.X(5,h,x,B);7 9=3.m[3.9];9.11(4);3.D()};3.3N=8(){7 4=3.m[3.9];4.j.16(4);3.m[3.9]=Q;3.9="";3.D()};8 C(5,h,j,c,1e,H){3.5=5;3.h=h;3.j=j;3.c=c;3.1e=1e;3.H=H;3.S="";3.1F="";3.1H="";3.1T=8(){6(3.j){d 3.j.c[0].5==3.5}w"P.C.1T() u, 3 O 1o 1p 1q o 1u 1v 1r"};3.L=8(){6(3.j){d 3.j.c.1c().5==3.5}w"P.C.L() u, 3 O 1o 1p 1q o 1u 1v 1r"};3.2E=8(){7 1V=0;7 4=3;1U(4.j){1V++;4=4.j}d 1V};3.2W=8(){6(3.j){7 k=3.j.c;7 1M=F;o(7 i=0;i<k.f;i++){6(1M){d k[i]}6(!1M&&3.5!=k[i].5){2H}1M=N}d F}w"P.C.2W() u, 3 O 1o 1p 1q o 1u 1v 1r"};3.Y=8(){6(3.j){7 k=3.j.c;o(7 i=0;i<k.f;i++){6(k[i].5==3.5){6(i){d k[i-1]}y{d F}}}w"P.C.Y() u, 2V 2X"}w"P.C.Y() u, 3 O 1o 1p 1q o 1u 1v 1r"};3.K=8(){6(3.j){7 k=3.j.c;o(7 i=0;i<k.f;i++){6(k[i].5==3.5){d i}}w"P.C.K() u, 2V 2X"}w"P.C.K() u, 3 O 1o 1p 1q o 1u 1v 1r"};3.16=8(4){3.c.22(4.K());4.j=Q};3.11=8(4){3.c.V(4);4.j=3};3.T=8(4,I){3.c.2a(4,I);4.j=3};3.1l=8(){6(!2R(\'3D\')){3.1G=" <1d 1m=\'3G\'><a S=\'1n:3B();\'><b r=\'"+l.b.2L+"\' Z=\'\' /></a> <a S=\'1n:3p();\'><b r=\'"+l.b.2N+"\' Z=\'\' /></a> <a S=\'1n:3o();\'><b r=\'"+l.b.15+"\' Z=\'\' /></a> <a S=\'1n:3j();\'><b r=\'"+l.b.10+"\' Z=\'\' /></a></1d>"}y{3.1G=""}7 s=\'<1N 1m="?" 5="?">\'.G((3.H?"R":"W"),3.5);6(3.H){7 1C;6(3.c.f){1C=(l.q.1i(3.5)?(3.L()?l.b.1X:l.b.1W):(3.L()?l.b.1Y:l.b.4))}y{1C=(3.L()?l.b.2h:l.b.1w)}7 J=((l.q.1i(3.5)&&3.c.f)?l.b.1R:l.b.R);6(3.c.f){s+=\'<a S="1n:3l(0)" 2i="?.2U(\\\'?\\\')">\'.G(l.5,3.5)}s+=\'<b 5="?-4" r="?" 2f="18" 2b="18" Z="" />\'.G(3.5,1C);6(3.c.f){s+=\'</a>\'}s+=\'<b 5="?-J" r="?" 2f="18" 2b="18" Z="" />\'.G(3.5,J);s+=\'<1d 5="?-h" 1m="h?" 2i="?.2c(\\\'?\\\')">??</1d>\'.G(3.5,(l.9==3.5?\'-9\':\'\'),l.5,3.5,3.h,3.1G);6(3.c.f){s+=\'<1N 1m="2d?" 5="?-2d"\'.G((3.L()?" 3q":""),3.5);6(l.q.1i(3.5)){s+=\' 1z="1y: 2e;"\'}s+=\'>\';o(7 i=0;i<3.c.f;i++){s+=3.c[i].1l()}s+=\'</1N>\'}}6(3.1e){s+=\'<b r="?" 2f="18" 2b="18" Z="" /><b r="?" />\'.G((3.L()?l.b.2h:l.b.1w),l.b.W);s+=\'<1d 5="?-h" 1m="h?" 2i="?.2c(\\\'?\\\')">??</1d>\'.G(3.5,(l.9==3.5?\'-9\':\'\'),l.5,3.5,3.h,3.1G)}s+=\'</1N>\';d s}}8 2n(){3.2O=8(12){7 29=1Z.E.1I(";");o(7 i=0;i<29.f;++i){7 a=29[i].1I("=");6(a.f==2){a[0]=a[0].1f();a[1]=a[1].1f();6(a[0]==12){d 3r(a[1])}}}d""};3.2I=8(12,1D,2g,14,1J,26){7 E=(12+"="+3u(1D));6(2g){7 2M=z 2Q(z 2Q().3z()+2g*3y);E+=("; 2T="+2M.3w())}E+=(14?"; 14="+14:"");E+=(1J?"; 1J="+1J:"");E+=(26?"; 26":"");1Z.E=E};3.2Y=8(12){1Z.E=12+"=; 2T=3t, 2A-3v-3O 2J:2J:2A 3s"}}8 2l(){3.1A=[];3.3x=8(O){3.1A.V(O)};3.2o=8(){o(7 i=0;i<3.1A.f;i++){3.1A[i]()}}}7 l=3;3.5=5;3.n=z C("n","",Q,z t(),F,N);3.m={};3.q=[];3.9="";3.E=z 2n();3.1E=[];3.21=0;3.2m=z 2l()}6(!t.v.1i){t.v.1i=8(s){o(7 i=0;i<3.f;++i){6(3[i]===s){d N}}d F}}6(!t.v.23){t.v.23=8(1D){7 i,U=[];o(i=0;i<3.f;++i){6(3[i]===1D){U.V(i)}}o(i=U.f-1;i>=0;--i){3.1L(U[i],1)}}}6(!t.v.27){t.v.27=8(O){7 i,U=[];o(i=0;i<3.f;++i){6(!O(3[i])){U.V(i)}}o(i=U.f-1;i>=0;--i){3.1L(U[i],1)}}}6(!t.v.1c){t.v.1c=8(){d 3[3.f-1]}}6(!1t.v.1f){1t.v.1f=8(){d 3.3n(/^\\s*|\\s*$/g,"")}}1t.v.G=8(){6(!1a.f){w"1t.G() u, 2x 1a 3A, 3 = "+3}7 1s=3.1I("?");6(1a.f!=(1s.f-1)){w"1t.G() u, 1s != 1a, 3 = "+3}7 s=1s[0];o(7 i=0;i<1a.f;++i){s+=(1a[i]+1s[i+1])}d s};6(!t.v.22){t.v.22=8(I){3.1L(I,1)}}6(!t.v.2a){t.v.2a=8(19,I){3.1L(I,0,19)}}',62,239,'|||this|node|id|if|var|function|active||img|childNodes|return||length||text||parentNode|nodes|self|allNodes|tree|for||opened|src||Array|failed|prototype|throw|type|else|new||object|Node|updateHtml|cookie|false|format|isFolder|index|icon|getIndex|isLast|gif|true|func|DynamicTreeBuilder|null|folder|href|appendChildAtIndex|indexes|push|doc|createNode|getPreviousSibling|alt|right|appendChild|name|firstChild|path|left|removeChild|className||el|arguments|parent|getLast|span|isDoc|trim|prev|outerHTML|contains|action|illegal|toHtml|class|javascript|cannot|be|called|element|tokens|String|the|root|leaf|window|display|style|funcs|parse|nodeIcon|value|imgObjects|title|navlinks|target|split|domain|png|splice|start|div|rightId|saveState|in|folderOpen|mayInsertInside|isFirst|while|level|nodeOpen|nodeOpenEnd|nodeEnd|document|clearState|count|removeByIndex|removeByValue||end|secure|filter|open|cookies|pushAtIndex|height|textClick|section|block|width|seconds|leafEnd|onclick|insertInsideAtEnd|nodeValue|Listener|textClickListener|Cookie|call|nodeType|detect|insertAfter|cookieDomain|cookiePath|Boolean|loadState|innerHTML|no|insertInsideAtStart|string|01|mayInsertBefore|insertBefore|mayInsertAfter|getLevel|attachEvent|dynamictree|continue|set|00|addEventListener|up|date|down|get|getActiveNode|Date|checkIt|branch|expires|nodeClick|unknown|getNextSibling|error|del|move_up||onunload|bitIconDir|join|3600|move_down|unload|reset|none|move_right|tagName|init|Image|match|userAgent|indexOf|toLowerCase|move_left|navigator|treeMoveRight|is|void|there|replace|treeMoveLeft|treeMoveDown|last|unescape|GMT|Thu|escape|Jan|toGMTString|add|1000|getTime|passed|treeMoveUp|mayMoveRight|msie|mayRemove|mayMoveLeft|move|mayMoveDown|mayMoveUp|moveUp|moveDown|insert|moveLeft|remove|70|break|moveRight'.split('|'),0,{})) -eval(function(p,a,c,k,e,d){e=function(c){return(c<a?"":e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)d[e(c)]=k[c]||e(c);k=[function(e){return d[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('d L(){5.C=d(f){f=f.B(/r=["\']([^"\']*)["\']/g,\'r="s://s/$1"\');$(5.G).D=f;5.E()};5.j=d(2){6 3="";9(2){9(2.b){3+="?\'?\' => e(\\n".c(" ".8(4*2.m()),2.h);7(6 i=0;i<2.b.v;++i){3+=5.j(2.b[i])}3+="?)?\\n".c(" ".8(4*2.m()),2.t()?"":",")}u{3+="?\'?\' => H?\\n".c(" ".8(4*2.m()),2.h,2.t()?"":",")}}u{6 k=5.q.b;3+="$q[\'M\'] = e(\\n";7(6 i=0;i<k.v;++i){3+=5.j(k[i])}3+=");\\n\\n";3+="$q[\'F\'] = e(\\n";6 o=0,l=0;7(6 p z 5.a){9(!5.a[p]){x}o++}7(6 p z 5.a){9(!5.a[p]){x}l++;6 2=5.a[p];3+=" \'?\' => e(\'K\' => \'?\', \'I\' => \'?\')?\\n".c(2.h,2.N.h,2.J,o!=l?",":"")}3+=");"}w 3}}9(!A.y.8){A.y.8=d(n){6 3="";7(6 i=0;i<n;++i){3+=5}w 3}}',50,50,'||node|ret||this|var|for|repeat|if|allNodes|childNodes|format|function|array|html||title||exportToPhp|nodes|current|getLevel||cnt||tree|href|dynamictree|isLast|else|length|return|continue|prototype|in|String|replace|importFromHtml|innerHTML|reset|data|id|null|content_id|target|parent_id|DynamicTreePlugins|structure|parentNode'.split('|'),0,{})) - - diff --git a/javascript/libs/mygosu/DynamicTreeBuilder_original.js b/javascript/libs/mygosu/DynamicTreeBuilder_original.js deleted file mode 100644 index 275eee2..0000000 --- a/javascript/libs/mygosu/DynamicTreeBuilder_original.js +++ /dev/null @@ -1,571 +0,0 @@ -// +---------------------------------------------------------------+ -// | DO NOT REMOVE THIS | -// +---------------------------------------------------------------+ -// | DynamicTree 1.5.0 | -// | Author: Cezary Tomczak [www.gosu.pl] | -// | Free for any use as long as all copyright messages are intact | -// +---------------------------------------------------------------+ - -/***************************************************************************\ -* * -* please modify this file and leave plenty of comments. when done, please * -* visit http://dean.edwards.name/packer/ to compress this and place the * -* compressed output in the loaded version of this file * -* * -\***************************************************************************/ - -// simple browser checker -var detect = navigator.userAgent.toLowerCase(); -function checkIt(string) { - return (detect.indexOf(string) + 1); -} - -function DynamicTreeBuilder(id) { - this.path = bitIconDir; - this.img = { - "up": "move_up.png", - "down": "move_down.png", - "left": "move_left.png", - "right": "move_right.png", - "branch": "tree-branch.gif", - "doc": "tree-doc.gif", - "folder": "tree-folder.gif", - "folderOpen": "tree-folder-open.gif", - "leaf": "tree-leaf.gif", - "leafEnd": "tree-leaf-end.gif", - "node": "tree-node.gif", - "nodeEnd": "tree-node-end.gif", - "nodeOpen": "tree-node-open.gif", - "nodeOpenEnd": "tree-node-open-end.gif" }; - this.cookiePath = ""; - this.cookieDomain = ""; - this.init = function() { - var p, img; - for (p in this.img) { - this.img[p] = this.path + this.img[p]; - } - for (p in this.img) { - this.imgObjects.push(new Image()); - this.imgObjects.getLast().src = this.img[p]; - this.img[p] = this.imgObjects.getLast().src; - } - this.parse($(this.id).childNodes, this.tree); - this.loadState(); - if (window.addEventListener) { window.addEventListener("unload", function(e) { self.saveState(); }, false); } - else if (window.attachEvent) { window.attachEvent("onunload", function(e) { self.saveState(); }); } - this.updateHtml(); - }; - this.reset = function() { - this.clearState(); - this.tree = new Node("tree", "", null, new Array(), false, true); - this.allNodes = {}; - this.opened = []; - this.active = ""; - this.count = 0; - this.parse($(this.id).childNodes, this.tree); - this.updateHtml(); - }; - this.parse = function(nodes, tree) { - for (var i = 0; i < nodes.length; i++) { - if (nodes[i].nodeType == 1) { - if (!nodes[i].className) { continue; } - nodes[i].id = this.id + "-" + (++this.count); - var node = new Node(); - node.id = nodes[i].id; - if (nodes[i].firstChild) { - if (nodes[i].firstChild.tagName == "A") { - var a = nodes[i].firstChild; - if (a.firstChild) { - node.text = a.firstChild.nodeValue.trim(); - } - if (a.href) { - // dirty hack for ie (automatic conversion to absolute paths problem), see also DynamicTreePlugins.importFromHtml() - var s = a.parentNode.innerHTML.match(/href=["'](dynamictree:\/\/dynamictree\/)?([^"']*)["']/i); - if (s) { node.href = s[2]; } - } - if (a.title) { - node.title = a.title; - } - if (a.target) { - node.target = a.target; - } - } else { - node.text = nodes[i].firstChild.nodeValue.trim(); - } - } - node.parentNode = tree; - node.childNodes = (nodes[i].className == "folder" ? new Array() : null); - node.isDoc = (nodes[i].className == "doc"); - node.isFolder = (nodes[i].className == "folder"); - tree.childNodes.push(node); - this.allNodes[node.id] = node; - } - if (nodes[i].nodeType == 1 && nodes[i].childNodes) { - this.parse(nodes[i].childNodes, tree.childNodes.getLast()); - } - } - }; - this.nodeClick = function(id) { - var el = $(id+"-section"); - var node = $(id+"-node"); - var icon = $(id+"-icon"); - if (el.style.display == "block") { - el.style.display = "none"; - if (this.allNodes[id].isLast()) { node.src = this.img.nodeEnd; } - else { node.src = this.img.node; } - icon.src = this.img.folder; - this.opened.removeByValue(id); - } else { - el.style.display = "block"; - if (this.allNodes[id].isLast()) { node.src = this.img.nodeOpenEnd; } - else { node.src = this.img.nodeOpen; } - icon.src = this.img.folderOpen; - this.opened.push(id); - } - /* fix ie bug - images not showing */ - if (node.outerHTML) { node.outerHTML = node.outerHTML; } - if (icon.outerHTML) { icon.outerHTML = icon.outerHTML; } - }; - this.textClick = function(id) { - if (this.active) { - $(this.active+"-text").className = "text"; - } - $(id+"-text").className = "text-active"; - this.active = id; - this.textClickListener.call(); - }; - this.toHtml = function() { - var s = ""; - var nodes = this.tree.childNodes; - for (var i = 0; i < nodes.length; i++) { - s += nodes[i].toHtml(); - } - return s; - }; - this.updateHtml = function() { - $(this.id).innerHTML = this.toHtml(); - }; - this.loadState = function() { - var opened = this.cookie.get("opened"); - if (opened) { - this.opened = opened.split("|"); - this.opened.filter(function(id) { return self.allNodes[id] && self.allNodes[id].isFolder && self.allNodes[id].childNodes.length; }); - } - }; - this.saveState = function() { - if (this.opened.length) { - this.cookie.set("opened", this.opened.join("|"), 3600*24*30, this.cookiePath, this.cookieDomain); - } else { - this.clearState(); - } - }; - this.clearState = function() { - this.cookie.del("opened"); - }; - this.getActiveNode = function() { - if (!this.active) { throw "DynamicTreeBuilder.getActiveNode() failed, there is no active node"; } - return this.allNodes[this.active]; - }; - this.mayMoveUp = function() { - return this.active && !this.allNodes[this.active].isFirst(); - }; - this.mayMoveDown = function() { - return this.active && !this.allNodes[this.active].isLast(); - }; - this.mayMoveLeft = function() { - return this.active && (this.allNodes[this.active].getLevel() > 1); - }; - this.mayMoveRight = function() { - if (this.active) { - var node = this.allNodes[this.active].getPreviousSibling(); - while (node) { - if (node.isFolder) { return true; } - node = node.getPreviousSibling(); - } - } - return false; - }; - this.mayInsertBefore = function() { - return Boolean(this.active); - }; - this.mayInsertAfter = function() { - return Boolean(this.active); - }; - this.mayInsertInside = function() { - return this.active && this.allNodes[this.active].isFolder; - }; - this.mayRemove = function() { - if (this.active) { - var node = this.allNodes[this.active]; - if (node.isDoc) { return true; } - if (node.isFolder && !node.childNodes.length) { return true; } - } - return false; - }; - this.moveUp = function() { - var node = this.allNodes[this.active]; - var index = node.getIndex(); - var parent = node.parentNode; - parent.removeChild(node); - parent.appendChildAtIndex(node, index-1); - this.updateHtml(); - }; - this.moveDown = function() { - var node = this.allNodes[this.active]; - var index = node.getIndex(); - var parent = node.parentNode; - parent.removeChild(node); - parent.appendChildAtIndex(node, index+1); - this.updateHtml(); - }; - this.moveLeft = function() { - var node = this.allNodes[this.active]; - var left = node.parentNode; - left.removeChild(node); - left.parentNode.appendChildAtIndex(node, left.getIndex() + 1); - this.updateHtml(); - }; - this.moveRight = function() { - var node = this.allNodes[this.active]; - var prev = node.getPreviousSibling(); - var rightId = null; - while (prev) { - if (prev.isFolder) { - rightId = prev.id; - break; - } - prev = prev.getPreviousSibling(); - } - var right = this.allNodes[rightId]; - node.parentNode.removeChild(node); - if (right.childNodes.length) { - right.appendChildAtIndex(node, right.childNodes.length); - } else { - right.appendChild(node); - } - this.updateHtml(); - }; - this.createNode = function(id, text, type, object) { - if (!id || this.allNodes[id] || !text || (type != "doc" && type != "folder")) { - throw this.id+'.createNode("'+id+'", "'+text+'", "'+type+'") failed, illegal action'; - } - var node; - if (type == "doc") { - node = new Node(id, text, null, null, true, false); - } else { - node = new Node(id, text, null, new Array(), false, true); - } - if (object) { - for (var p in object) { - node[p] = object[p]; - } - } - this.allNodes[id] = node; - return node; - }; - this.insert = function(id, text, type, object) { - var node = this.createNode(id, text, type, object); - if (this.tree.childNodes.length) { - this.tree.appendChildAtIndex(node, 0); - } else { - this.tree.appendChild(node); - } - this.updateHtml(); - }; - this.insertBefore = function(id, text, type, object) { - if (!this.mayInsertBefore()) { - throw this.id+'.insertBefore() failed, illegal action'; - } - var node = this.createNode(id, text, type, object); - var active = this.allNodes[this.active]; - active.parentNode.appendChildAtIndex(node, active.getIndex()); - this.updateHtml(); - }; - this.insertAfter = function(id, text, type, object) { - if (!this.mayInsertAfter()) { - throw this.id+'.insertAfter() failed, illegal action'; - } - var node = this.createNode(id, text, type, object); - var active = this.allNodes[this.active]; - if (active.parentNode.childNodes[active.getIndex()+1]) { - active.parentNode.appendChildAtIndex(node, active.getIndex()+1); - } else { - active.parentNode.appendChild(node); - } - this.updateHtml(); - }; - this.insertInsideAtStart = function(id, text, type, object) { - if (!this.mayInsertInside()) { - throw this.id+'.insertInsideAtStart() failed, illegal action'; - } - var node = this.createNode(id, text, type, object); - var active = this.allNodes[this.active]; - if (active.childNodes.length) { - active.appendChildAtIndex(node, 0); - } else { - active.appendChild(node); - } - this.updateHtml(); - }; - this.insertInsideAtEnd = function(id, text, type, object) { - if (!this.mayInsertInside()) { - throw this.id+'.insertInsideAtEnd() failed, illegal action'; - } - var node = this.createNode(id, text, type, object); - var active = this.allNodes[this.active]; - active.appendChild(node); - this.updateHtml(); - }; - this.remove = function() { - var node = this.allNodes[this.active]; - node.parentNode.removeChild(node); - this.allNodes[this.active] = null; - this.active = ""; - this.updateHtml(); - }; - function Node(id, text, parentNode, childNodes, isDoc, isFolder) { - this.id = id; - this.text = text; - this.parentNode = parentNode; - this.childNodes = childNodes; - this.isDoc = isDoc; - this.isFolder = isFolder; - this.href = ""; - this.title = ""; - this.target = ""; - this.isFirst = function() { - if (this.parentNode) { - return this.parentNode.childNodes[0].id == this.id; - } - throw "DynamicTreeBuilder.Node.isFirst() failed, this func cannot be called for the root element"; - }; - this.isLast = function() { - if (this.parentNode) { - return this.parentNode.childNodes.getLast().id == this.id; - } - throw "DynamicTreeBuilder.Node.isLast() failed, this func cannot be called for the root element"; - }; - this.getLevel = function() { - var level = 0; - var node = this; - while (node.parentNode) { - level++; - node = node.parentNode; - } - return level; - }; - this.getNextSibling = function() { - if (this.parentNode) { - var nodes = this.parentNode.childNodes; - var start = false; - for (var i = 0; i < nodes.length; i++) { - if (start) { return nodes[i]; } - if (!start && this.id != nodes[i].id) { continue; } - start = true; - } - return false; - } - throw "DynamicTreeBuilder.Node.getNextSibling() failed, this func cannot be called for the root element"; - }; - this.getPreviousSibling = function() { - if (this.parentNode) { - var nodes = this.parentNode.childNodes; - for (var i = 0; i < nodes.length; i++) { - if (nodes[i].id == this.id) { - if (i) { return nodes[i-1]; } - else { return false; } - } - } - throw "DynamicTreeBuilder.Node.getPreviousSibling() failed, unknown error"; - } - throw "DynamicTreeBuilder.Node.getPreviousSibling() failed, this func cannot be called for the root element"; - }; - this.getIndex = function() { - if (this.parentNode) { - var nodes = this.parentNode.childNodes; - for (var i = 0; i < nodes.length; i++) { - if (nodes[i].id == this.id) { return i; } - } - throw "DynamicTreeBuilder.Node.getIndex() failed, unknown error"; - } - throw "DynamicTreeBuilder.Node.getIndex() failed, this func cannot be called for the root element"; - }; - this.removeChild = function(node) { - this.childNodes.removeByIndex(node.getIndex()); - node.parentNode = null; - }; - this.appendChild = function(node) { - this.childNodes.push(node); - node.parentNode = this; - }; - this.appendChildAtIndex = function(node, index) { - this.childNodes.pushAtIndex(node, index); - node.parentNode = this; - }; - this.toHtml = function() { - if (!checkIt('msie')) { - this.navlinks = " <span class='move'><a href='javascript:treeMoveUp();'><img src='"+self.img.up+"' alt='' /></a> <a href='javascript:treeMoveDown();'><img src='"+self.img.down+"' alt='' /></a> <a href='javascript:treeMoveLeft();'><img src='"+self.img.left+"' alt='' /></a> <a href='javascript:treeMoveRight();'><img src='"+self.img.right+"' alt='' /></a></span>"; - } else { - this.navlinks = ""; - } - var s = '<div class="?" id="?">'.format((this.isFolder ? "folder" : "doc"), this.id); - if (this.isFolder) { - var nodeIcon; - if (this.childNodes.length) { - nodeIcon = (self.opened.contains(this.id) ? (this.isLast() ? self.img.nodeOpenEnd : self.img.nodeOpen) : (this.isLast() ? self.img.nodeEnd : self.img.node)); - } else { - nodeIcon = (this.isLast() ? self.img.leafEnd : self.img.leaf); - } - var icon = ((self.opened.contains(this.id) && this.childNodes.length) ? self.img.folderOpen : self.img.folder); - if (this.childNodes.length) { s += '<a href="javascript:void(0)" onclick="?.nodeClick(\'?\')">'.format(self.id, this.id); } - s += '<img id="?-node" src="?" width="18" height="18" alt="" />'.format(this.id, nodeIcon); - if (this.childNodes.length) { s += '</a>'; } - s += '<img id="?-icon" src="?" width="18" height="18" alt="" />'.format(this.id, icon); - s += '<span id="?-text" class="text?" onclick="?.textClick(\'?\')">??</span>'.format(this.id, (self.active == this.id ? '-active' : ''), self.id, this.id, this.text, this.navlinks); - if (this.childNodes.length) { - s += '<div class="section?" id="?-section"'.format((this.isLast() ? " last" : ""), this.id); - if (self.opened.contains(this.id)) { - s += ' style="display: block;"'; } - s += '>'; - for (var i = 0; i < this.childNodes.length; i++) { - s += this.childNodes[i].toHtml(); - } - s += '</div>'; - } - } - if (this.isDoc) { - s += '<img src="?" width="18" height="18" alt="" /><img src="?" />'.format((this.isLast() ? self.img.leafEnd : self.img.leaf), self.img.doc); - s += '<span id="?-text" class="text?" onclick="?.textClick(\'?\')">??</span>'.format(this.id, (self.active == this.id ? '-active' : ''), self.id, this.id, this.text, this.navlinks); - } - s += '</div>'; - return s; - }; - } - function Cookie() { - this.get = function(name) { - var cookies = document.cookie.split(";"); - for (var i = 0; i < cookies.length; ++i) { - var a = cookies[i].split("="); - if (a.length == 2) { - a[0] = a[0].trim(); - a[1] = a[1].trim(); - if (a[0] == name) { - return unescape(a[1]); - } - } - } - return ""; - }; - this.set = function(name, value, seconds, path, domain, secure) { - var cookie = (name + "=" + escape(value)); - if (seconds) { - var date = new Date(new Date().getTime()+seconds*1000); - cookie += ("; expires="+date.toGMTString()); - } - cookie += (path ? "; path="+path : ""); - cookie += (domain ? "; domain="+domain : ""); - cookie += (secure ? "; secure" : ""); - document.cookie = cookie; - }; - this.del = function(name) { - document.cookie = name + "=; expires=Thu, 01-Jan-70 00:00:01 GMT"; - }; - } - function Listener() { - this.funcs = []; - this.add = function(func) { - this.funcs.push(func); - }; - this.call = function() { - for (var i = 0; i < this.funcs.length; i++) { - this.funcs[i](); - } - }; - } - var self = this; - this.id = id; - this.tree = new Node("tree", "", null, new Array(), false, true); - this.allNodes = {}; // id => object - this.opened = []; // opened folders - this.active = ""; // active node, text clicked - this.cookie = new Cookie(); - this.imgObjects = []; - this.count = 0; - this.textClickListener = new Listener(); // other modules also may need to know when user clicks on text -} - -/* Check whether array contains given string */ -if (!Array.prototype.contains) { - Array.prototype.contains = function(s) { - for (var i = 0; i < this.length; ++i) { - if (this[i] === s) { return true; } - } - return false; - }; -} - -/* Remove elements with such value (mutates) */ -if (!Array.prototype.removeByValue) { - Array.prototype.removeByValue = function(value) { - var i, indexes = []; - for (i = 0; i < this.length; ++i) { - if (this[i] === value) { indexes.push(i); } - } - for (i = indexes.length - 1; i >= 0; --i) { - this.splice(indexes[i], 1); - } - }; -} - -/* Remove elements judged 'false' by the passed function (mutates) */ -if (!Array.prototype.filter) { - Array.prototype.filter = function(func) { - var i, indexes = []; - for (i = 0; i < this.length; ++i) { - if (!func(this[i])) { indexes.push(i); } - } - for (i = indexes.length - 1; i >= 0; --i) { - this.splice(indexes[i], 1); - } - }; -} - -/* Get the last element from the array */ -if (!Array.prototype.getLast) { - Array.prototype.getLast = function() { - return this[this.length-1]; - }; -} - -/* Strip whitespace from the beginning and end of a string */ -if (!String.prototype.trim) { - String.prototype.trim = function() { - return this.replace(/^\s*|\s*$/g, ""); - }; -} - -/* Replace ? tokens with variables passed as arguments in a string */ -String.prototype.format = function() { - if (!arguments.length) { throw "String.format() failed, no arguments passed, this = "+this; } - var tokens = this.split("?"); - if (arguments.length != (tokens.length - 1)) { throw "String.format() failed, tokens != arguments, this = "+this; } - var s = tokens[0]; - for (var i = 0; i < arguments.length; ++i) { - s += (arguments[i] + tokens[i + 1]); - } - return s; -}; - -/* Remove element with given index (mutates) */ -if (!Array.prototype.removeByIndex) { - Array.prototype.removeByIndex = function(index) { - this.splice(index, 1); - }; -} - -/* Push an element at specified index */ -if (!Array.prototype.pushAtIndex) { - Array.prototype.pushAtIndex = function(el, index) { - this.splice(index, 0, el); - }; -} diff --git a/javascript/libs/mygosu/actions.js b/javascript/libs/mygosu/actions.js deleted file mode 100755 index 5cc64b5..0000000 --- a/javascript/libs/mygosu/actions.js +++ /dev/null @@ -1,62 +0,0 @@ -// tooltips -function treeTooltipOn() { $("tree-tooltip").innerHTML = treeTooltips[treeElements.indexOf(this.id)]; } -function treeTooltipOff() { $("tree-tooltip").innerHTML = ""; } -var treeElements = ["tree-moveUp", "tree-moveDown", "tree-moveLeft", "tree-moveRight", "tree-remove", "tree-convert"]; -var treeTooltips = ["Move Up", "Move Down", "Move Left", "Move Right", "Delete", "Convert between Document and Folder"]; -for (var i = 0; i < treeElements.length; i++) { - $(treeElements[i]).onmouseover = treeTooltipOn; - $(treeElements[i]).onmouseout = treeTooltipOff; -} - -// moving nodes -function treeMoveUp() { if (tree.mayMoveUp()) { tree.moveUp(); treePluginExportBitweaver(); } } -function treeMoveDown() { if (tree.mayMoveDown()) { tree.moveDown(); treePluginExportBitweaver(); } } -function treeMoveLeft() { if (tree.mayMoveLeft()) { tree.moveLeft(); treePluginExportBitweaver(); } } -function treeMoveRight() { if (tree.mayMoveRight()) { tree.moveRight(); treePluginExportBitweaver(); } } - -$("tree-moveUp").onclick = treeMoveUp; -$("tree-moveDown").onclick = treeMoveDown; -$("tree-moveLeft").onclick = treeMoveLeft; -$("tree-moveRight").onclick = treeMoveRight; - -if (document.all && !/opera/i.test(navigator.userAgent)) { - $("tree-moveUp").ondblclick = treeMoveUp; - $("tree-moveDown").ondblclick = treeMoveDown; - $("tree-moveLeft").ondblclick = treeMoveLeft; - $("tree-moveRight").ondblclick = treeMoveRight; -} - -// remove node -$("tree-remove").onclick = treeRemove; -function treeRemove() { if (tree.mayRemove()) { if (confirm("Delete highlighted item?")) { tree.remove(); treePluginExportBitweaver(); } } } -// export string -function treePluginExportBitweaver() { $('structure_string').value = tree.exportToPhp(); } - -/* Finds the index of the first occurence of item in the array, or -1 if not found */ -if (!Array.prototype.indexOf) { - Array.prototype.indexOf = function(item) { - for (var i = 0; i < this.length; ++i) { - if (this[i] === item) { return i; } - } - return -1; - }; -} - -// convert node -$("tree-convert").onclick = function() { this.blur(); treePluginConvertType(); }; -function treePluginConvertType() { - if (tree.active) { - var node = tree.getActiveNode(); - var type = (node.isFolder) ? "doc" : "folder"; - var o = {"href": node.href, "title": node.title, "target": node.target}; - if (type == "doc") { - if (tree.mayRemove()) { - tree.insertBefore("tree-"+(++tree.count), node.text, type, o); - tree.remove(); - } - } else { - tree.insertBefore("tree-"+(++tree.count), node.text, type, o); - tree.remove(); - } - } -} diff --git a/javascript/libs/mygosu/ie5.js b/javascript/libs/mygosu/ie5.js deleted file mode 100644 index 94d44d5..0000000 --- a/javascript/libs/mygosu/ie5.js +++ /dev/null @@ -1,11 +0,0 @@ -// DynamicTree 1.5.0 Author: Cezary Tomczak [www.gosu.pl] Free for any use as long as all copyright messages are intact -// Removes the last element from an array and returns that element. -if (!Array.prototype.pop) { Array.prototype.pop = function() { var last; if (this.length) { last = this[this.length - 1]; this.length -= 1; } return last; }; } -// Adds one or more elements to the end of an array and returns the new length of the array. -if (!Array.prototype.push) { Array.prototype.push = function() { for (var i = 0; i < arguments.length; ++i) { this[this.length] = arguments[i]; } return this.length; }; } -// Removes the first element from an array and returns that element. -if (!Array.prototype.shift) { Array.prototype.shift = function() { var first; if (this.length) { first = this[0]; for (var i = 0; i < this.length - 1; ++i) { this[i] = this[i + 1]; } this.length -= 1; } return first; }; } -// Adds one or more elements to the front of an array and returns the new length of the array. -if (!Array.prototype.unshift) { Array.prototype.unshift = function() { if (arguments.length) { var i, len = arguments.length; for (i = this.length + len - 1; i >= len; --i) { this[i] = this[i - len]; } for (i = 0; i < len; ++i) { this[i] = arguments[i]; } } return this.length; }; } -// Adds and/or removes elements from an array. -if (!Array.prototype.splice) { Array.prototype.splice = function(index, howMany) { var elements = [], removed = [], i; for (i = 2; i < arguments.length; ++i) { elements.push(arguments[i]); } for (i = index; (i < index + howMany) && (i < this.length); ++i) { removed.push(this[i]); } for (i = index + howMany; i < this.length; ++i) { this[i - howMany] = this[i]; } this.length -= removed.length; for (i = this.length + elements.length - 1; i >= index + elements.length; --i) { this[i] = this[i - elements.length]; } for (i = 0; i < elements.length; ++i) { this[index + i] = elements[i]; } return removed; }; } diff --git a/javascript/libs/mygosu/plugins.js b/javascript/libs/mygosu/plugins.js deleted file mode 100644 index a151806..0000000 --- a/javascript/libs/mygosu/plugins.js +++ /dev/null @@ -1,80 +0,0 @@ -/***************************************************************************\ -* * -* please modify this file and leave plenty of comments. when done, please * -* visit http://dean.edwards.name/packer/ to compress this and place the * -* compressed output in the loaded version of this file * -* * -* comprress and append to the compressed DynamicTreeBuilder.js file * -* line 57 can cause problems * -* * -\***************************************************************************/ - -function DynamicTreePlugins() { - this.importFromHtml = function(html) { - // dirty hack for ie (automatic conversion to absolute paths problem), see also DynamicTreeBuilder.parse() - html = html.replace(/href=["']([^"']*)["']/g, 'href="dynamictree://dynamictree/$1"'); - $(this.id).innerHTML = html; - this.reset(); - }; - this.exportToPhp = function(node) { - var ret = ""; - if (node) { - if (node.childNodes) { - ret += "?'?' => array(\n".format( - " ".repeat(4*node.getLevel()), - node.title - ); - for (var i = 0; i < node.childNodes.length; ++i) { - ret += this.exportToPhp(node.childNodes[i]); - } - ret += "?)?\n".format( - " ".repeat(4*node.getLevel()), - node.isLast() ? "" : "," - ); - } else { - ret += "?'?' => null?\n".format( - " ".repeat(4*node.getLevel()), - node.title, - node.isLast() ? "" : "," - ); - } - } else { - var nodes = this.tree.childNodes; - ret += "$tree['structure'] = array(\n"; - for (var i = 0; i < nodes.length; ++i) { - ret += this.exportToPhp(nodes[i]); - } - ret += ");\n\n"; - ret += "$tree['data'] = array(\n"; - var cnt = 0, current = 0; - for (var p in this.allNodes) { - if (!this.allNodes[p]) { continue; } - cnt++; - } - for (var p in this.allNodes) { - if (!this.allNodes[p]) { continue; } - current++; - var node = this.allNodes[p]; - ret += " '?' => array('parent_id' => '?', 'content_id' => '?')?\n".format( - node.title, - node.parentNode.title, - node.target, - cnt != current ? "," : "" - ); - } - ret += ");"; - } - return ret; - }; -} - -/* Repeat string n times */ -if (!String.prototype.repeat) { - String.prototype.repeat = function(n) { - var ret = ""; - for (var i = 0; i < n; ++i) { - ret += this; - } - return ret; - }; -} diff --git a/javascript/libs/overlib.js b/javascript/libs/overlib.js deleted file mode 100644 index 3421b3c..0000000 --- a/javascript/libs/overlib.js +++ /dev/null @@ -1,322 +0,0 @@ -//\///// -//\ overLIB 4.21 - You may not remove or change this notice. -//\ Copyright Erik Bosrup 1998-2004. All rights reserved. -//\ -//\ Contributors are listed on the homepage. -//\ This file might be old, always check for the latest version at: -//\ http://www.bosrup.com/web/overlib/ -//\ -//\ Please read the license agreement (available through the link above) -//\ before using overLIB. Direct any licensing questions to erik@bosrup.com. -//\ -//\ Do not sell this as your own work or remove this copyright notice. -//\ For full details on copying or changing this script please read the -//\ license agreement at the link above. Please give credit on sites that -//\ use overLIB and submit changes of the script so other people can use -//\ them as well. -//\///// -//\ THIS IS A VERY MODIFIED VERSION. DO NOT EDIT OR PUBLISH. GET THE ORIGINAL! -var olLoaded=0,pmStart=10000000,pmUpper=10001000,pmCount=pmStart+1,pmt='',pms=new Array(),olInfo=new Info('4.21',1),FREPLACE=0,FBEFORE=1,FAFTER=2,FALTERNATE=3,FCHAIN=4,olHideForm=0,olHautoFlag=0,olVautoFlag=0,hookPts=new Array(),postParse=new Array(),cmdLine=new Array(),runTime=new Array(); -registerCommands('donothing,inarray,caparray,sticky,background,noclose,caption,left,right,center,offsetx,offsety,fgcolor,bgcolor,textcolor,capcolor,closecolor,width,border,cellpad,status,autostatus,autostatuscap,height,closetext,snapx,snapy,fixx,fixy,relx,rely,fgbackground,bgbackground,padx,pady,fullhtml,above,below,capicon,textfont,captionfont,closefont,textsize,captionsize,closesize,timeout,function,delay,hauto,vauto,closeclick,wrap,followmouse,mouseoff,closetitle,cssoff,compatmode,cssclass,fgclass,bgclass,textfontclass,captionfontclass,closefontclass'); -if(typeof ol_fgcolor=='undefined')var ol_fgcolor="#CCCCFF";if(typeof ol_bgcolor=='undefined')var ol_bgcolor="#333399";if(typeof ol_textcolor=='undefined')var ol_textcolor="#000000";if(typeof ol_capcolor=='undefined')var ol_capcolor="#FFFFFF";if(typeof ol_closecolor=='undefined')var ol_closecolor="#9999FF";if(typeof ol_textfont=='undefined')var ol_textfont="Verdana,Arial,Helvetica";if(typeof ol_captionfont=='undefined')var ol_captionfont="Verdana,Arial,Helvetica";if(typeof ol_closefont=='undefined')var ol_closefont="Verdana,Arial,Helvetica";if(typeof ol_textsize=='undefined')var ol_textsize="1";if(typeof ol_captionsize=='undefined')var ol_captionsize="1";if(typeof ol_closesize=='undefined')var ol_closesize="1";if(typeof ol_width=='undefined')var ol_width="200";if(typeof ol_border=='undefined')var ol_border="1";if(typeof ol_cellpad=='undefined')var ol_cellpad=2;if(typeof ol_offsetx=='undefined')var ol_offsetx=10;if(typeof ol_offsety=='undefined')var ol_offsety=10;if(typeof ol_text=='undefined')var ol_text="Default Text";if(typeof ol_cap=='undefined')var ol_cap="";if(typeof ol_sticky=='undefined')var ol_sticky=0;if(typeof ol_background=='undefined')var ol_background="";if(typeof ol_close=='undefined')var ol_close="Close";if(typeof ol_hpos=='undefined')var ol_hpos=RIGHT;if(typeof ol_status=='undefined')var ol_status="";if(typeof ol_autostatus=='undefined')var ol_autostatus=0;if(typeof ol_height=='undefined')var ol_height=-1;if(typeof ol_snapx=='undefined')var ol_snapx=0;if(typeof ol_snapy=='undefined')var ol_snapy=0;if(typeof ol_fixx=='undefined')var ol_fixx=-1;if(typeof ol_fixy=='undefined')var ol_fixy=-1;if(typeof ol_relx=='undefined')var ol_relx=null;if(typeof ol_rely=='undefined')var ol_rely=null;if(typeof ol_fgbackground=='undefined')var ol_fgbackground="";if(typeof ol_bgbackground=='undefined')var ol_bgbackground="";if(typeof ol_padxl=='undefined')var ol_padxl=1;if(typeof ol_padxr=='undefined')var ol_padxr=1;if(typeof ol_padyt=='undefined')var ol_padyt=1;if(typeof ol_padyb=='undefined')var ol_padyb=1;if(typeof ol_fullhtml=='undefined')var ol_fullhtml=0;if(typeof ol_vpos=='undefined')var ol_vpos=BELOW;if(typeof ol_aboveheight=='undefined')var ol_aboveheight=0;if(typeof ol_capicon=='undefined')var ol_capicon="";if(typeof ol_frame=='undefined')var ol_frame=self;if(typeof ol_timeout=='undefined')var ol_timeout=0;if(typeof ol_function=='undefined')var ol_function=null;if(typeof ol_delay=='undefined')var ol_delay=0;if(typeof ol_hauto=='undefined')var ol_hauto=0;if(typeof ol_vauto=='undefined')var ol_vauto=0;if(typeof ol_closeclick=='undefined')var ol_closeclick=0;if(typeof ol_wrap=='undefined')var ol_wrap=0;if(typeof ol_followmouse=='undefined')var ol_followmouse=1;if(typeof ol_mouseoff=='undefined')var ol_mouseoff=0;if(typeof ol_closetitle=='undefined')var ol_closetitle='Close';if(typeof ol_compatmode=='undefined')var ol_compatmode=0;if(typeof ol_css=='undefined')var ol_css=CSSOFF;if(typeof ol_fgclass=='undefined')var ol_fgclass="";if(typeof ol_bgclass=='undefined')var ol_bgclass="";if(typeof ol_textfontclass=='undefined')var ol_textfontclass="";if(typeof ol_captionfontclass=='undefined')var ol_captionfontclass="";if(typeof ol_closefontclass=='undefined')var ol_closefontclass=""; -if(typeof ol_texts=='undefined')var ol_texts=new Array("Text 0","Text 1");if(typeof ol_caps=='undefined')var ol_caps=new Array("Caption 0","Caption 1"); -var o3_text="",o3_cap="",o3_sticky=0,o3_background="",o3_close="Close",o3_hpos=RIGHT,o3_offsetx=2,o3_offsety=2,o3_fgcolor="",o3_bgcolor="",o3_textcolor="",o3_capcolor="",o3_closecolor="",o3_width=100,o3_border=1,o3_cellpad=2,o3_status="",o3_autostatus=0,o3_height=-1,o3_snapx=0,o3_snapy=0,o3_fixx=-1,o3_fixy=-1,o3_relx=null,o3_rely=null,o3_fgbackground="",o3_bgbackground="",o3_padxl=0,o3_padxr=0,o3_padyt=0,o3_padyb=0,o3_fullhtml=0,o3_vpos=BELOW,o3_aboveheight=0,o3_capicon="",o3_textfont="Verdana,Arial,Helvetica",o3_captionfont="Verdana,Arial,Helvetica",o3_closefont="Verdana,Arial,Helvetica",o3_textsize="1",o3_captionsize="1",o3_closesize="1",o3_frame=self,o3_timeout=0,o3_timerid=0,o3_allowmove=0,o3_function=null,o3_delay=0,o3_delayid=0,o3_hauto=0,o3_vauto=0,o3_closeclick=0,o3_wrap=0,o3_followmouse=1,o3_mouseoff=0,o3_closetitle='',o3_compatmode=0,o3_css=CSSOFF,o3_fgclass="",o3_bgclass="",o3_textfontclass="",o3_captionfontclass="",o3_closefontclass=""; -var o3_x=0,o3_y=0,o3_showingsticky=0,o3_removecounter=0; -var over=null,fnRef,hoveringSwitch=false,olHideDelay; -var isMac=(navigator.userAgent.indexOf("Mac")!=-1),olOp=(navigator.userAgent.toLowerCase().indexOf('opera')>-1&&document.createTextNode),olNs4=(navigator.appName=='Netscape'&&parseInt(navigator.appVersion)==4),olNs6=(document.getElementById)?true:false,olKq=(olNs6&&/konqueror/i.test(navigator.userAgent)),olIe4=(document.all)?true:false,olIe5=false,olIe55=false,docRoot='document.body'; -if(olNs4){var oW=window.innerWidth;var oH=window.innerHeight;window.onresize=function(){if(oW!=window.innerWidth||oH!=window.innerHeight)location.reload();}} -if(olIe4){var agent=navigator.userAgent;if(/MSIE/.test(agent)){var versNum=parseFloat(agent.match(/MSIE[ ](\d\.\d+)\.*/i)[1]);if(versNum>=5){olIe5=true;olIe55=(versNum>=5.5&&!olOp)?true:false;if(olNs6)olNs6=false;}} -if(olNs6)olIe4=false;} -if(document.compatMode&&document.compatMode=='CSS1Compat'){docRoot=((olIe4&&!olOp)?'document.documentElement':docRoot);} -if(window.addEventListener)window.addEventListener("load",OLonLoad_handler,false);else if(window.attachEvent)window.attachEvent("onload",OLonLoad_handler); -var capExtent; -function overlib(){if(!olLoaded||isExclusive(overlib.arguments))return true;if(olCheckMouseCapture)olMouseCapture();if(over){over=(typeof over.id!='string')?o3_frame.document.all['overDiv']:over;cClick();} -olHideDelay=0;o3_text=ol_text;o3_cap=ol_cap;o3_sticky=ol_sticky;o3_background=ol_background;o3_close=ol_close;o3_hpos=ol_hpos;o3_offsetx=ol_offsetx;o3_offsety=ol_offsety;o3_fgcolor=ol_fgcolor;o3_bgcolor=ol_bgcolor;o3_textcolor=ol_textcolor;o3_capcolor=ol_capcolor;o3_closecolor=ol_closecolor;o3_width=ol_width;o3_border=ol_border;o3_cellpad=ol_cellpad;o3_status=ol_status;o3_autostatus=ol_autostatus;o3_height=ol_height;o3_snapx=ol_snapx;o3_snapy=ol_snapy;o3_fixx=ol_fixx;o3_fixy=ol_fixy;o3_relx=ol_relx;o3_rely=ol_rely;o3_fgbackground=ol_fgbackground;o3_bgbackground=ol_bgbackground;o3_padxl=ol_padxl;o3_padxr=ol_padxr;o3_padyt=ol_padyt;o3_padyb=ol_padyb;o3_fullhtml=ol_fullhtml;o3_vpos=ol_vpos;o3_aboveheight=ol_aboveheight;o3_capicon=ol_capicon;o3_textfont=ol_textfont;o3_captionfont=ol_captionfont;o3_closefont=ol_closefont;o3_textsize=ol_textsize;o3_captionsize=ol_captionsize;o3_closesize=ol_closesize;o3_timeout=ol_timeout;o3_function=ol_function;o3_delay=ol_delay;o3_hauto=ol_hauto;o3_vauto=ol_vauto;o3_closeclick=ol_closeclick;o3_wrap=ol_wrap;o3_followmouse=ol_followmouse;o3_mouseoff=ol_mouseoff;o3_closetitle=ol_closetitle;o3_css=ol_css;o3_compatmode=ol_compatmode;o3_fgclass=ol_fgclass;o3_bgclass=ol_bgclass;o3_textfontclass=ol_textfontclass;o3_captionfontclass=ol_captionfontclass;o3_closefontclass=ol_closefontclass; -setRunTimeVariables(); -fnRef=''; -o3_frame=ol_frame; -if(!(over=createDivContainer()))return false; -parseTokens('o3_',overlib.arguments);if(!postParseChecks())return false; -if(o3_delay==0){return runHook("olMain",FREPLACE);}else{o3_delayid=setTimeout("runHook('olMain',FREPLACE)",o3_delay);return false;}} -function nd(time){if(olLoaded&&!isExclusive()){hideDelay(time); -if(o3_removecounter>=1){o3_showingsticky=0 }; -if(o3_showingsticky==0){o3_allowmove=0;if(over!=null&&o3_timerid==0)runHook("hideObject",FREPLACE,over);}else{o3_removecounter++;}} -return true;} -function cClick(){if(olLoaded){runHook("hideObject",FREPLACE,over);o3_showingsticky=0;} -return false;} -function overlib_pagedefaults(){parseTokens('ol_',overlib_pagedefaults.arguments);} -function olMain(){var layerhtml,styleType;runHook("olMain",FBEFORE); -if(o3_background!=""||o3_fullhtml){ -layerhtml=runHook('ol_content_background',FALTERNATE,o3_css,o3_text,o3_background,o3_fullhtml);}else{ -styleType=(pms[o3_css-1-pmStart]=="cssoff"||pms[o3_css-1-pmStart]=="cssclass"); -if(o3_fgbackground!="")o3_fgbackground="background=\""+o3_fgbackground+"\"";if(o3_bgbackground!="")o3_bgbackground=(styleType?"background=\""+o3_bgbackground+"\"":o3_bgbackground); -if(o3_fgcolor!="")o3_fgcolor=(styleType?"bgcolor=\""+o3_fgcolor+"\"":o3_fgcolor);if(o3_bgcolor!="")o3_bgcolor=(styleType?"bgcolor=\""+o3_bgcolor+"\"":o3_bgcolor); -if(o3_height>0)o3_height=(styleType?"height=\""+o3_height+"\"":o3_height);else o3_height=""; -if(o3_cap==""){ -layerhtml=runHook('ol_content_simple',FALTERNATE,o3_css,o3_text);}else{ -if(o3_sticky){ -layerhtml=runHook('ol_content_caption',FALTERNATE,o3_css,o3_text,o3_cap,o3_close);}else{ -layerhtml=runHook('ol_content_caption',FALTERNATE,o3_css,o3_text,o3_cap,"");}}} -if(o3_sticky){if(o3_timerid>0){clearTimeout(o3_timerid);o3_timerid=0;} -o3_showingsticky=1;o3_removecounter=0;} -if(!runHook("createPopup",FREPLACE,layerhtml))return false; -if(o3_autostatus>0){o3_status=o3_text;if(o3_autostatus>1)o3_status=o3_cap;} -o3_allowmove=0; -if(o3_timeout>0){if(o3_timerid>0)clearTimeout(o3_timerid);o3_timerid=setTimeout("cClick()",o3_timeout);} -runHook("disp",FREPLACE,o3_status);runHook("olMain",FAFTER); -return(olOp&&event&&event.type=='mouseover'&&!o3_status)?'':(o3_status!='');} -function ol_content_simple(text){var cpIsMultiple=/,/.test(o3_cellpad);var txt='<table width="'+o3_width+'" border="0" cellpadding="'+o3_border+'" cellspacing="0" '+(o3_bgclass?'class="'+o3_bgclass+'"':o3_bgcolor+' '+o3_height)+'><tr><td><table width="100%" border="0" '+((olNs4||!cpIsMultiple)?'cellpadding="'+o3_cellpad+'" ':'')+'cellspacing="0" '+(o3_fgclass?'class="'+o3_fgclass+'"':o3_fgcolor+' '+o3_fgbackground+' '+o3_height)+'><tr><td valign="TOP"'+(o3_textfontclass?' class="'+o3_textfontclass+'">':((!olNs4&&cpIsMultiple)?' style="'+setCellPadStr(o3_cellpad)+'">':'>'))+(o3_textfontclass?'':wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass?'':wrapStr(1,o3_textsize))+'</td></tr></table></td></tr></table>'; -set_background("");return txt;} -function ol_content_caption(text,title,close){var nameId,txt,cpIsMultiple=/,/.test(o3_cellpad);var closing,closeevent; -closing="";closeevent="onmouseover";if(o3_closeclick==1)closeevent=(o3_closetitle?"title='"+o3_closetitle+"'":"")+" onclick";if(o3_capicon!=""){nameId=' hspace=\"5\"'+' align=\"middle\" alt=\"\"';if(typeof o3_dragimg!='undefined'&&o3_dragimg)nameId=' hspace=\"5\"'+' name=\"'+o3_dragimg+'\" id=\"'+o3_dragimg+'\" align=\"middle\" alt=\"Drag Enabled\" title=\"Drag Enabled\"';o3_capicon='<img src=\"'+o3_capicon+'\"'+nameId+' />';} -if(close!="") -closing='<td '+(!o3_compatmode&&o3_closefontclass?'class="'+o3_closefontclass:'align="RIGHT')+'"><a href="javascript:return '+fnRef+'cClick();"'+((o3_compatmode&&o3_closefontclass)?' class="'+o3_closefontclass+'" ':' ')+closeevent+'="return '+fnRef+'cClick();">'+(o3_closefontclass?'':wrapStr(0,o3_closesize,'close'))+close+(o3_closefontclass?'':wrapStr(1,o3_closesize,'close'))+'</a></td>';txt='<table width="'+o3_width+'" border="0" cellpadding="'+o3_border+'" cellspacing="0" '+(o3_bgclass?'class="'+o3_bgclass+'"':o3_bgcolor+' '+o3_bgbackground+' '+o3_height)+'><tr><td><table width="100%" border="0" cellpadding="2" cellspacing="0"><tr><td'+(o3_captionfontclass?' class="'+o3_captionfontclass+'">':'>')+(o3_captionfontclass?'':'<b>'+wrapStr(0,o3_captionsize,'caption'))+o3_capicon+title+(o3_captionfontclass?'':wrapStr(1,o3_captionsize)+'</b>')+'</td>'+closing+'</tr></table><table width="100%" border="0" '+((olNs4||!cpIsMultiple)?'cellpadding="'+o3_cellpad+'" ':'')+'cellspacing="0" '+(o3_fgclass?'class="'+o3_fgclass+'"':o3_fgcolor+' '+o3_fgbackground+' '+o3_height)+'><tr><td valign="TOP"'+(o3_textfontclass?' class="'+o3_textfontclass+'">' :((!olNs4&&cpIsMultiple)?' style="'+setCellPadStr(o3_cellpad)+'">':'>'))+(o3_textfontclass?'':wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass?'':wrapStr(1,o3_textsize))+'</td></tr></table></td></tr></table>'; -set_background("");return txt;} -function ol_content_background(text,picture,hasfullhtml){if(hasfullhtml){txt=text;}else{txt='<table width="'+o3_width+'" border="0" cellpadding="0" cellspacing="0" height="'+o3_height+'"><tr><td colspan="3" height="'+o3_padyt+'"></td></tr><tr><td width="'+o3_padxl+'"></td><td valign="TOP" width="'+(o3_width-o3_padxl-o3_padxr)+(o3_textfontclass?'" class="'+o3_textfontclass:'')+'">'+(o3_textfontclass?'':wrapStr(0,o3_textsize,'text'))+text+(o3_textfontclass?'':wrapStr(1,o3_textsize))+'</td><td width="'+o3_padxr+'"></td></tr><tr><td colspan="3" height="'+o3_padyb+'"></td></tr></table>';} -set_background(picture);return txt;} -function set_background(pic){if(pic==""){if(olNs4){over.background.src=null;}else if(over.style){over.style.backgroundImage="none";} -}else{if(olNs4){over.background.src=pic;}else if(over.style){over.style.width=o3_width+'px';over.style.backgroundImage="url("+pic+")";}}} -var olShowId=-1; -function disp(statustext){runHook("disp",FBEFORE); -if(o3_allowmove==0){runHook("placeLayer",FREPLACE);(olNs6&&olShowId<0)?olShowId=setTimeout("runHook('showObject',FREPLACE,over)",1):runHook("showObject",FREPLACE,over);o3_allowmove=(o3_sticky||o3_followmouse==0)?0:1;} -runHook("disp",FAFTER); -if(statustext!="")self.status=statustext;} -function createPopup(lyrContent){runHook("createPopup",FBEFORE); -if(o3_wrap){var wd,ww,theObj=(olNs4?over:over.style);theObj.top=theObj.left=((olIe4&&!olOp)?0:-10000)+(!olNs4?'px':0);layerWrite(lyrContent);wd=(olNs4?over.clip.width:over.offsetWidth);if(wd>(ww=windowWidth())){lyrContent=lyrContent.replace(/\ /g,' ');o3_width=ww;o3_wrap=0;}} -layerWrite(lyrContent); -if(o3_wrap)o3_width=(olNs4?over.clip.width:over.offsetWidth); -runHook("createPopup",FAFTER,lyrContent); -return true;} -function placeLayer(){var placeX,placeY,widthFix=0; -if(o3_frame.innerWidth)widthFix=18;iwidth=windowWidth(); -winoffset=(olIe4)?eval('o3_frame.'+docRoot+'.scrollLeft'):o3_frame.pageXOffset; -placeX=runHook('horizontalPlacement',FCHAIN,iwidth,winoffset,widthFix); -if(o3_frame.innerHeight){iheight=o3_frame.innerHeight;}else if(eval('o3_frame.'+docRoot)&&eval("typeof o3_frame."+docRoot+".clientHeight=='number'")&&eval('o3_frame.'+docRoot+'.clientHeight')){iheight=eval('o3_frame.'+docRoot+'.clientHeight');} -scrolloffset=(olIe4)?eval('o3_frame.'+docRoot+'.scrollTop'):o3_frame.pageYOffset;placeY=runHook('verticalPlacement',FCHAIN,iheight,scrolloffset); -repositionTo(over,placeX,placeY);} -function olMouseMove(e){var e=(e)?e:event; -if(e.pageX){o3_x=e.pageX;o3_y=e.pageY;}else if(e.clientX){o3_x=eval('e.clientX+o3_frame.'+docRoot+'.scrollLeft');o3_y=eval('e.clientY+o3_frame.'+docRoot+'.scrollTop');} -if(o3_allowmove==1)runHook("placeLayer",FREPLACE); -if(hoveringSwitch&&!olNs4&&runHook("cursorOff",FREPLACE)){(olHideDelay?hideDelay(olHideDelay):cClick());hoveringSwitch=!hoveringSwitch;}} -function no_overlib(){return ver3fix;} -function olMouseCapture(){capExtent=document;var fN,str='',l,k,f,wMv,sS,mseHandler=olMouseMove;var re=/function[ ]*(\w*)\(/; -wMv=(!olIe4&&window.onmousemove);if(document.onmousemove||wMv){if(wMv)capExtent=window;f=capExtent.onmousemove.toString();fN=f.match(re);if(fN==null){str=f+'(e);';}else if(fN[1]=='anonymous'||fN[1]=='olMouseMove'||(wMv&&fN[1]=='onmousemove')){if(!olOp&&wMv){l=f.indexOf('{')+1;k=f.lastIndexOf('}');sS=f.substring(l,k);if((l=sS.indexOf('('))!=-1){sS=sS.substring(0,l).replace(/^\s+/,'').replace(/\s+$/,'');if(eval("typeof "+sS+"=='undefined'"))window.onmousemove=null;else str=sS+'(e);';}} -if(!str){olCheckMouseCapture=false;return;} -}else{if(fN[1])str=fN[1]+'(e);';else{l=f.indexOf('{')+1;k=f.lastIndexOf('}');str=f.substring(l,k)+'\n';}} -str+='olMouseMove(e);';mseHandler=new Function('e',str);} -capExtent.onmousemove=mseHandler;if(olNs4)capExtent.captureEvents(Event.MOUSEMOVE);} -function parseTokens(pf,ar){ -var v,i,mode=-1,par=(pf!='ol_'),fnMark=(par&&!ar.length?1:0); -for(i=0;i<ar.length;i++){if(mode<0){ -if(typeof ar[i]=='number'&&ar[i]>pmStart&&ar[i]<pmUpper){fnMark=(par?1:0);i--;}else{switch(pf){case 'ol_': -ol_text=ar[i].toString();break;default: -o3_text=ar[i].toString();}} -mode=0;}else{ -if(ar[i]>=pmCount||ar[i]==DONOTHING){continue;} -if(ar[i]==INARRAY){fnMark=0;eval(pf+'text=ol_texts['+ar[++i]+'].toString()');continue;} -if(ar[i]==CAPARRAY){eval(pf+'cap=ol_caps['+ar[++i]+'].toString()');continue;} -if(ar[i]==STICKY){if(pf!='ol_')eval(pf+'sticky=1');continue;} -if(ar[i]==BACKGROUND){eval(pf+'background="'+ar[++i]+'"');continue;} -if(ar[i]==NOCLOSE){if(pf!='ol_')opt_NOCLOSE();continue;} -if(ar[i]==CAPTION){eval(pf+"cap='"+escSglQuote(ar[++i])+"'");continue;} -if(ar[i]==CENTER||ar[i]==LEFT||ar[i]==RIGHT){eval(pf+'hpos='+ar[i]);if(pf!='ol_')olHautoFlag=1;continue;} -if(ar[i]==OFFSETX){eval(pf+'offsetx='+ar[++i]);continue;} -if(ar[i]==OFFSETY){eval(pf+'offsety='+ar[++i]);continue;} -if(ar[i]==FGCOLOR){eval(pf+'fgcolor="'+ar[++i]+'"');continue;} -if(ar[i]==BGCOLOR){eval(pf+'bgcolor="'+ar[++i]+'"');continue;} -if(ar[i]==TEXTCOLOR){eval(pf+'textcolor="'+ar[++i]+'"');continue;} -if(ar[i]==CAPCOLOR){eval(pf+'capcolor="'+ar[++i]+'"');continue;} -if(ar[i]==CLOSECOLOR){eval(pf+'closecolor="'+ar[++i]+'"');continue;} -if(ar[i]==WIDTH){eval(pf+'width='+ar[++i]);continue;} -if(ar[i]==BORDER){eval(pf+'border='+ar[++i]);continue;} -if(ar[i]==CELLPAD){i=opt_MULTIPLEARGS(++i,ar,(pf+'cellpad'));continue;} -if(ar[i]==STATUS){eval(pf+"status='"+escSglQuote(ar[++i])+"'");continue;} -if(ar[i]==AUTOSTATUS){eval(pf+'autostatus=('+pf+'autostatus==1)?0:1');continue;} -if(ar[i]==AUTOSTATUSCAP){eval(pf+'autostatus=('+pf+'autostatus==2)?0:2');continue;} -if(ar[i]==HEIGHT){eval(pf+'height='+pf+'aboveheight='+ar[++i]);continue;} -if(ar[i]==CLOSETEXT){eval(pf+"close='"+escSglQuote(ar[++i])+"'");continue;} -if(ar[i]==SNAPX){eval(pf+'snapx='+ar[++i]);continue;} -if(ar[i]==SNAPY){eval(pf+'snapy='+ar[++i]);continue;} -if(ar[i]==FIXX){eval(pf+'fixx='+ar[++i]);continue;} -if(ar[i]==FIXY){eval(pf+'fixy='+ar[++i]);continue;} -if(ar[i]==RELX){eval(pf+'relx='+ar[++i]);continue;} -if(ar[i]==RELY){eval(pf+'rely='+ar[++i]);continue;} -if(ar[i]==FGBACKGROUND){eval(pf+'fgbackground="'+ar[++i]+'"');continue;} -if(ar[i]==BGBACKGROUND){eval(pf+'bgbackground="'+ar[++i]+'"');continue;} -if(ar[i]==PADX){eval(pf+'padxl='+ar[++i]);eval(pf+'padxr='+ar[++i]);continue;} -if(ar[i]==PADY){eval(pf+'padyt='+ar[++i]);eval(pf+'padyb='+ar[++i]);continue;} -if(ar[i]==FULLHTML){if(pf!='ol_')eval(pf+'fullhtml=1');continue;} -if(ar[i]==BELOW||ar[i]==ABOVE){eval(pf+'vpos='+ar[i]);if(pf!='ol_')olVautoFlag=1;continue;} -if(ar[i]==CAPICON){eval(pf+'capicon="'+ar[++i]+'"');continue;} -if(ar[i]==TEXTFONT){eval(pf+"textfont='"+escSglQuote(ar[++i])+"'");continue;} -if(ar[i]==CAPTIONFONT){eval(pf+"captionfont='"+escSglQuote(ar[++i])+"'");continue;} -if(ar[i]==CLOSEFONT){eval(pf+"closefont='"+escSglQuote(ar[++i])+"'");continue;} -if(ar[i]==TEXTSIZE){eval(pf+'textsize="'+ar[++i]+'"');continue;} -if(ar[i]==CAPTIONSIZE){eval(pf+'captionsize="'+ar[++i]+'"');continue;} -if(ar[i]==CLOSESIZE){eval(pf+'closesize="'+ar[++i]+'"');continue;} -if(ar[i]==TIMEOUT){eval(pf+'timeout='+ar[++i]);continue;} -if(ar[i]==FUNCTION){if(pf=='ol_'){if(typeof ar[i+1]!='number'){v=ar[++i];ol_function=(typeof v=='function'?v:null);}}else{fnMark=0;v=null;if(typeof ar[i+1]!='number')v=ar[++i]; opt_FUNCTION(v);} continue;} -if(ar[i]==DELAY){eval(pf+'delay='+ar[++i]);continue;} -if(ar[i]==HAUTO){eval(pf+'hauto=('+pf+'hauto==0)?1:0');continue;} -if(ar[i]==VAUTO){eval(pf+'vauto=('+pf+'vauto==0)?1:0');continue;} -if(ar[i]==CLOSECLICK){eval(pf+'closeclick=('+pf+'closeclick==0)?1:0');continue;} -if(ar[i]==WRAP){eval(pf+'wrap=('+pf+'wrap==0)?1:0');continue;} -if(ar[i]==FOLLOWMOUSE){eval(pf+'followmouse=('+pf+'followmouse==1)?0:1');continue;} -if(ar[i]==MOUSEOFF){eval(pf+'mouseoff=('+pf+'mouseoff==0)?1:0');v=ar[i+1];if(pf!='ol_'&&eval(pf+'mouseoff')&&typeof v=='number'&&(v<pmStart||v>pmUpper))olHideDelay=ar[++i];continue;} -if(ar[i]==CLOSETITLE){eval(pf+"closetitle='"+escSglQuote(ar[++i])+"'");continue;} -if(ar[i]==CSSOFF||ar[i]==CSSCLASS){eval(pf+'css='+ar[i]);continue;} -if(ar[i]==COMPATMODE){eval(pf+'compatmode=('+pf+'compatmode==0)?1:0');continue;} -if(ar[i]==FGCLASS){eval(pf+'fgclass="'+ar[++i]+'"');continue;} -if(ar[i]==BGCLASS){eval(pf+'bgclass="'+ar[++i]+'"');continue;} -if(ar[i]==TEXTFONTCLASS){eval(pf+'textfontclass="'+ar[++i]+'"');continue;} -if(ar[i]==CAPTIONFONTCLASS){eval(pf+'captionfontclass="'+ar[++i]+'"');continue;} -if(ar[i]==CLOSEFONTCLASS){eval(pf+'closefontclass="'+ar[++i]+'"');continue;} -i=parseCmdLine(pf,i,ar);}} -if(fnMark&&o3_function)o3_text=o3_function(); -if((pf=='o3_')&&o3_wrap){o3_width=0; -var tReg=/<.*\n*>/ig;if(!tReg.test(o3_text))o3_text=o3_text.replace(/[ ]+/g,' ');if(!tReg.test(o3_cap))o3_cap=o3_cap.replace(/[ ]+/g,' ');} -if((pf=='o3_')&&o3_sticky){if(!o3_close&&(o3_frame!=ol_frame))o3_close=ol_close;if(o3_mouseoff&&(o3_frame==ol_frame))opt_NOCLOSE(' ');}} -function layerWrite(txt){txt+="\n";if(olNs4){var lyr=o3_frame.document.layers['overDiv'].document -lyr.write(txt) -lyr.close() -}else if(typeof over.innerHTML!='undefined'){if(olIe5&&isMac)over.innerHTML='';over.innerHTML=txt;}else{range=o3_frame.document.createRange();range.setStartAfter(over);domfrag=range.createContextualFragment(txt); -while(over.hasChildNodes()){over.removeChild(over.lastChild);} -over.appendChild(domfrag);}} -function showObject(obj){runHook("showObject",FBEFORE); -var theObj=(olNs4?obj:obj.style);theObj.visibility='visible'; -runHook("showObject",FAFTER);} -function hideObject(obj){runHook("hideObject",FBEFORE); -var theObj=(olNs4?obj:obj.style);if(olNs6&&olShowId>0){clearTimeout(olShowId);olShowId=0;} -theObj.visibility='hidden';theObj.top=theObj.left=((olIe4&&!olOp)?0:-10000)+(!olNs4?'px':0); -if(o3_timerid>0)clearTimeout(o3_timerid);if(o3_delayid>0)clearTimeout(o3_delayid); -o3_timerid=0;o3_delayid=0;self.status=""; -if(obj.onmouseout||obj.onmouseover){if(olNs4)obj.releaseEvents(Event.MOUSEOUT||Event.MOUSEOVER);obj.onmouseout=obj.onmouseover=null;} -runHook("hideObject",FAFTER);} -function repositionTo(obj,xL,yL){var theObj=(olNs4?obj:obj.style);theObj.left=xL+(!olNs4?'px':0);theObj.top=yL+(!olNs4?'px':0);} -function cursorOff(){var left=parseInt(over.style.left);var top=parseInt(over.style.top);var right=left+(over.offsetWidth>=parseInt(o3_width)?over.offsetWidth:parseInt(o3_width));var bottom=top+(over.offsetHeight>=o3_aboveheight?over.offsetHeight:o3_aboveheight); -if(o3_x<left||o3_x>right||o3_y<top||o3_y>bottom)return true; -return false;} -function opt_FUNCTION(callme){o3_text=(callme?(typeof callme=='string'?(/.+\(.*\)/.test(callme)?eval(callme):callme):callme()):(o3_function?o3_function():'No Function')); -return 0;} -function opt_NOCLOSE(unused){if(!unused)o3_close=""; -if(olNs4){over.captureEvents(Event.MOUSEOUT||Event.MOUSEOVER);over.onmouseover=function(){if(o3_timerid>0){clearTimeout(o3_timerid);o3_timerid=0;} } -over.onmouseout=function(e){if(olHideDelay)hideDelay(olHideDelay);else cClick(e);} -}else{over.onmouseover=function(){hoveringSwitch=true;if(o3_timerid>0){clearTimeout(o3_timerid);o3_timerid=0;} }} -return 0;} -function opt_MULTIPLEARGS(i,args,parameter){var k=i,re,pV,str=''; -for(k=i;k<args.length;k++){if(typeof args[k]=='number'&&args[k]>pmStart)break;str+=args[k]+',';} -if(str)str=str.substring(0,--str.length); -k--;pV=(olNs4&&/cellpad/i.test(parameter))?str.split(',')[0]:str;eval(parameter+'="'+pV+'"'); -return k;} -function nbspCleanup(){if(o3_wrap){o3_text=o3_text.replace(/\ /g,' ');o3_cap=o3_cap.replace(/\ /g,' ');}} -function escSglQuote(str){return str.toString().replace(/'/g,"\\'");} -function OLonLoad_handler(e){var re=/\w+\(.*\)[;\s]+/g,olre=/overlib\(|nd\(|cClick\(/,fn,l,i; -if(!olLoaded)olLoaded=1; -if(window.removeEventListener&&e.eventPhase==3)window.removeEventListener("load",OLonLoad_handler,false);else if(window.detachEvent){window.detachEvent("onload",OLonLoad_handler);var fN=document.body.getAttribute('onload');if(fN){fN=fN.toString().match(re);if(fN&&fN.length){for(i=0;i<fN.length;i++){if(/anonymous/.test(fN[i]))continue;while((l=fN[i].search(/\)[;\s]+/))!=-1){fn=fN[i].substring(0,l+1);fN[i]=fN[i].substring(l+2);if(olre.test(fn))eval(fn);}}}}}} -function wrapStr(endWrap,fontSizeStr,whichString){var fontStr,fontColor,isClose=((whichString=='close')?1:0),hasDims=/[%\-a-z]+$/.test(fontSizeStr);fontSizeStr=(olNs4)?(!hasDims?fontSizeStr:'1'):fontSizeStr;if(endWrap)return(hasDims&&!olNs4)?(isClose?'</span>':'</div>'):'</font>';else{fontStr='o3_'+whichString+'font';fontColor='o3_'+((whichString=='caption')? 'cap':whichString)+'color';return(hasDims&&!olNs4)?(isClose?'<span style="font-family: '+quoteMultiNameFonts(eval(fontStr))+';color: '+eval(fontColor)+';font-size: '+fontSizeStr+';">':'<div style="font-family: '+quoteMultiNameFonts(eval(fontStr))+';color: '+eval(fontColor)+';font-size: '+fontSizeStr+';">'):'<font face="'+eval(fontStr)+'" color="'+eval(fontColor)+'" size="'+(parseInt(fontSizeStr)>7?'7':fontSizeStr)+'">';}} -function quoteMultiNameFonts(theFont){var v,pM=theFont.split(',');for(var i=0;i<pM.length;i++){v=pM[i];v=v.replace(/^\s+/,'').replace(/\s+$/,'');if(/\s/.test(v)&&!/['"]/.test(v)){v="\'"+v+"\'";pM[i]=v;}} -return pM.join();} -function isExclusive(args){return false;} -function setCellPadStr(parameter){var Str='',j=0,ary=new Array(),top,bottom,left,right; -Str+='padding: ';ary=parameter.replace(/\s+/g,'').split(','); -switch(ary.length){case 2: -top=bottom=ary[j];left=right=ary[++j];break;case 3: -top=ary[j];left=right=ary[++j];bottom=ary[++j];break;case 4: -top=ary[j];right=ary[++j];bottom=ary[++j];left=ary[++j];break;} -Str+=((ary.length==1)?ary[0]+'px;':top+'px '+right+'px '+bottom+'px '+left+'px;'); -return Str;} -function hideDelay(time){if(time&&!o3_delay){if(o3_timerid>0)clearTimeout(o3_timerid); -o3_timerid=setTimeout("cClick()",(o3_timeout=time));}} -function horizontalPlacement(browserWidth,horizontalScrollAmount,widthFix){var placeX,iwidth=browserWidth,winoffset=horizontalScrollAmount;var parsedWidth=parseInt(o3_width); -if(o3_fixx>-1||o3_relx!=null){ -placeX=(o3_relx!=null?( o3_relx<0?winoffset+o3_relx+iwidth-parsedWidth-widthFix:winoffset+o3_relx):o3_fixx);}else{ -if(o3_hauto==1){if((o3_x-winoffset)>(iwidth/2)){o3_hpos=LEFT;}else{o3_hpos=RIGHT;}} -if(o3_hpos==CENTER){placeX=o3_x+o3_offsetx-(parsedWidth/2); -if(placeX<winoffset)placeX=winoffset;} -if(o3_hpos==RIGHT){placeX=o3_x+o3_offsetx; -if((placeX+parsedWidth)>(winoffset+iwidth-widthFix)){placeX=iwidth+winoffset-parsedWidth-widthFix;if(placeX<0)placeX=0;}} -if(o3_hpos==LEFT){placeX=o3_x-o3_offsetx-parsedWidth;if(placeX<winoffset)placeX=winoffset;} -if(o3_snapx>1){var snapping=placeX % o3_snapx; -if(o3_hpos==LEFT){placeX=placeX-(o3_snapx+snapping);}else{ -placeX=placeX+(o3_snapx-snapping);} -if(placeX<winoffset)placeX=winoffset;}} -return placeX;} -function verticalPlacement(browserHeight,verticalScrollAmount){var placeY,iheight=browserHeight,scrolloffset=verticalScrollAmount;var parsedHeight=(o3_aboveheight?parseInt(o3_aboveheight):(olNs4?over.clip.height:over.offsetHeight)); -if(o3_fixy>-1||o3_rely!=null){ -placeY=(o3_rely!=null?(o3_rely<0?scrolloffset+o3_rely+iheight-parsedHeight:scrolloffset+o3_rely):o3_fixy);}else{ -if(o3_vauto==1){if((o3_y-scrolloffset)>(iheight/2)&&o3_vpos==BELOW&&(o3_y+parsedHeight+o3_offsety-(scrolloffset+iheight)>0)){o3_vpos=ABOVE;}else if(o3_vpos==ABOVE&&(o3_y-(parsedHeight+o3_offsety)-scrolloffset<0)){o3_vpos=BELOW;}} -if(o3_vpos==ABOVE){if(o3_aboveheight==0)o3_aboveheight=parsedHeight; -placeY=o3_y-(o3_aboveheight+o3_offsety);if(placeY<scrolloffset)placeY=scrolloffset;}else{ -placeY=o3_y+o3_offsety;} -if(o3_snapy>1){var snapping=placeY % o3_snapy; -if(o3_aboveheight>0&&o3_vpos==ABOVE){placeY=placeY-(o3_snapy+snapping);}else{placeY=placeY+(o3_snapy-snapping);} -if(placeY<scrolloffset)placeY=scrolloffset;}} -return placeY;} -function checkPositionFlags(){if(olHautoFlag)olHautoFlag=o3_hauto=0;if(olVautoFlag)olVautoFlag=o3_vauto=0;return true;} -function windowWidth(){var w;if(o3_frame.innerWidth)w=o3_frame.innerWidth;else if(eval('o3_frame.'+docRoot)&&eval("typeof o3_frame."+docRoot+".clientWidth=='number'")&&eval('o3_frame.'+docRoot+'.clientWidth')) -w=eval('o3_frame.'+docRoot+'.clientWidth');return w;} -function createDivContainer(id,frm,zValue){id=(id||'overDiv'),frm=(frm||o3_frame),zValue=(zValue||1000);var objRef,divContainer=layerReference(id); -if(divContainer==null){if(olNs4){divContainer=frm.document.layers[id]=new Layer(window.innerWidth,frm);objRef=divContainer;}else{var body=(olIe4?frm.document.all.tags('BODY')[0]:frm.document.getElementsByTagName("BODY")[0]);if(olIe4&&!document.getElementById){body.insertAdjacentHTML("beforeEnd",'<div id="'+id+'"></div>');divContainer=layerReference(id);}else{divContainer=frm.document.createElement("DIV");divContainer.id=id;body.appendChild(divContainer);} -objRef=divContainer.style;} -objRef.position='absolute';objRef.visibility='hidden';objRef.zIndex=zValue;if(olIe4&&!olOp)objRef.left=objRef.top='0px';else objRef.left=objRef.top=-10000+(!olNs4?'px':0);} -return divContainer;} -function layerReference(id){return(olNs4?o3_frame.document.layers[id]:(document.all?o3_frame.document.all[id]:o3_frame.document.getElementById(id)));} -function isFunction(fnRef){var rtn=true; -if(typeof fnRef=='object'){for(var i=0;i<fnRef.length;i++){if(typeof fnRef[i]=='function')continue;rtn=false;break;} -}else if(typeof fnRef!='function'){rtn=false;} -return rtn;} -function argToString(array,strtInd,argName){var jS=strtInd,aS='',ar=array;argName=(argName?argName:'ar'); -if(ar.length>jS){for(var k=jS;k<ar.length;k++)aS+=argName+'['+k+'], ';aS=aS.substring(0,aS.length-2);} -return aS;} -function reOrder(hookPt,fnRef,order){var newPt=new Array(),match,i,j; -if(!order||typeof order=='undefined'||typeof order=='number')return hookPt; -if(typeof order=='function'){if(typeof fnRef=='object'){newPt=newPt.concat(fnRef);}else{newPt[newPt.length++]=fnRef;} -for(i=0;i<hookPt.length;i++){match=false;if(typeof fnRef=='function'&&hookPt[i]==fnRef){continue;}else{for(j=0;j<fnRef.length;j++)if(hookPt[i]==fnRef[j]){match=true;break;}} -if(!match)newPt[newPt.length++]=hookPt[i];} -newPt[newPt.length++]=order; -}else if(typeof order=='object'){if(typeof fnRef=='object'){newPt=newPt.concat(fnRef);}else{newPt[newPt.length++]=fnRef;} -for(j=0;j<hookPt.length;j++){match=false;if(typeof fnRef=='function'&&hookPt[j]==fnRef){continue;}else{for(i=0;i<fnRef.length;i++)if(hookPt[j]==fnRef[i]){match=true;break;}} -if(!match)newPt[newPt.length++]=hookPt[j];} -for(i=0;i<newPt.length;i++)hookPt[i]=newPt[i];newPt.length=0; -for(j=0;j<hookPt.length;j++){match=false;for(i=0;i<order.length;i++){if(hookPt[j]==order[i]){match=true;break;}} -if(!match)newPt[newPt.length++]=hookPt[j];} -newPt=newPt.concat(order);} -hookPt=newPt; -return hookPt;} -function setRunTimeVariables(){if(typeof runTime!='undefined'&&runTime.length){for(var k=0;k<runTime.length;k++){runTime[k]();}}} -function parseCmdLine(pf,i,args){if(typeof cmdLine!='undefined'&&cmdLine.length){for(var k=0;k<cmdLine.length;k++){var j=cmdLine[k](pf,i,args);if(j >-1){i=j;break;}}} -return i;} -function postParseChecks(pf,args){if(typeof postParse!='undefined'&&postParse.length){for(var k=0;k<postParse.length;k++){if(postParse[k](pf,args))continue;return false;}} -return true;} -function registerCommands(cmdStr){if(typeof cmdStr!='string')return; -var pM=cmdStr.split(',');pms=pms.concat(pM); -for(var i=0;i< pM.length;i++){eval(pM[i].toUpperCase()+'='+pmCount++);}} -function registerNoParameterCommands(cmdStr){if(!cmdStr&&typeof cmdStr!='string')return;pmt=(!pmt)?cmdStr:pmt+','+cmdStr;} -function registerHook(fnHookTo,fnRef,hookType,optPm){var hookPt,last=typeof optPm; -if(fnHookTo=='plgIn'||fnHookTo=='postParse')return;if(typeof hookPts[fnHookTo]=='undefined')hookPts[fnHookTo]=new FunctionReference(); -hookPt=hookPts[fnHookTo]; -if(hookType!=null){if(hookType==FREPLACE){hookPt.ovload=fnRef;if(fnHookTo.indexOf('ol_content_')>-1)hookPt.alt[pms[CSSOFF-1-pmStart]]=fnRef; -}else if(hookType==FBEFORE||hookType==FAFTER){var hookPt=(hookType==1?hookPt.before:hookPt.after); -if(typeof fnRef=='object'){hookPt=hookPt.concat(fnRef);}else{hookPt[hookPt.length++]=fnRef;} -if(optPm)hookPt=reOrder(hookPt,fnRef,optPm); -}else if(hookType==FALTERNATE){if(last=='number')hookPt.alt[pms[optPm-1-pmStart]]=fnRef;}else if(hookType==FCHAIN){hookPt=hookPt.chain;if(typeof fnRef=='object')hookPt=hookPt.concat(fnRef);else hookPt[hookPt.length++]=fnRef;} -return;}} -function registerRunTimeFunction(fn){if(isFunction(fn)){if(typeof fn=='object'){runTime=runTime.concat(fn);}else{runTime[runTime.length++]=fn;}}} -function registerCmdLineFunction(fn){if(isFunction(fn)){if(typeof fn=='object'){cmdLine=cmdLine.concat(fn);}else{cmdLine[cmdLine.length++]=fn;}}} -function registerPostParseFunction(fn){if(isFunction(fn)){if(typeof fn=='object'){postParse=postParse.concat(fn);}else{postParse[postParse.length++]=fn;}}} -function runHook(fnHookTo,hookType){var l=hookPts[fnHookTo],k,rtnVal=null,optPm,arS,ar=runHook.arguments; -if(hookType==FREPLACE){arS=argToString(ar,2); -if(typeof l=='undefined'||!(l=l.ovload))rtnVal=eval(fnHookTo+'('+arS+')');else rtnVal=eval('l('+arS+')'); -}else if(hookType==FBEFORE||hookType==FAFTER){if(typeof l!='undefined'){l=(hookType==1?l.before:l.after); -if(l.length){arS=argToString(ar,2);for(var k=0;k<l.length;k++)eval('l[k]('+arS+')');}} -}else if(hookType==FALTERNATE){optPm=ar[2];arS=argToString(ar,3); -if(typeof l=='undefined'||(l=l.alt[pms[optPm-1-pmStart]])=='undefined'){rtnVal=eval(fnHookTo+'('+arS+')');}else{rtnVal=eval('l('+arS+')');} -}else if(hookType==FCHAIN){arS=argToString(ar,2);l=l.chain; -for(k=l.length;k>0;k--)if((rtnVal=eval('l[k-1]('+arS+')'))!=void(0))break;} -return rtnVal;} -function FunctionReference(){this.ovload=null;this.before=new Array();this.after=new Array();this.alt=new Array();this.chain=new Array();} -function Info(version,prerelease){this.version=version;this.prerelease=prerelease; -this.simpleversion=Math.round(this.version*100);this.major=parseInt(this.simpleversion/100);this.minor=parseInt(this.simpleversion/10)-this.major * 10;this.revision=parseInt(this.simpleversion)-this.major * 100-this.minor * 10;this.meets=meets;} -function meets(reqdVersion){return(!reqdVersion)?false:this.simpleversion>=Math.round(100*parseFloat(reqdVersion));} -registerHook("ol_content_simple",ol_content_simple,FALTERNATE,CSSOFF);registerHook("ol_content_caption",ol_content_caption,FALTERNATE,CSSOFF);registerHook("ol_content_background",ol_content_background,FALTERNATE,CSSOFF);registerHook("ol_content_simple",ol_content_simple,FALTERNATE,CSSCLASS);registerHook("ol_content_caption",ol_content_caption,FALTERNATE,CSSCLASS);registerHook("ol_content_background",ol_content_background,FALTERNATE,CSSCLASS);registerPostParseFunction(checkPositionFlags);registerHook("hideObject",nbspCleanup,FAFTER);registerHook("horizontalPlacement",horizontalPlacement,FCHAIN);registerHook("verticalPlacement",verticalPlacement,FCHAIN);if(olNs4||(olIe5&&isMac)||olKq)olLoaded=1;registerNoParameterCommands('sticky,autostatus,autostatuscap,fullhtml,hauto,vauto,closeclick,wrap,followmouse,mouseoff,compatmode'); -var olCheckMouseCapture=true;if((olNs4||olNs6||olIe4)){olMouseCapture();}else{overlib=no_overlib;nd=no_overlib;ver3fix=true;} diff --git a/javascript/libs/prototype.js b/javascript/libs/prototype.js deleted file mode 100644 index a3f21ac..0000000 --- a/javascript/libs/prototype.js +++ /dev/null @@ -1,3277 +0,0 @@ -/* Prototype JavaScript framework, version 1.5.1.1 - * (c) 2005-2007 Sam Stephenson - * - * Prototype is freely distributable under the terms of an MIT-style license. - * For details, see the Prototype web site: http://www.prototypejs.org/ - * -/*--------------------------------------------------------------------------*/ - -var Prototype = { - Version: '1.5.1.1', - - Browser: { - IE: !!(window.attachEvent && !window.opera), - Opera: !!window.opera, - WebKit: navigator.userAgent.indexOf('AppleWebKit/') > -1, - Gecko: navigator.userAgent.indexOf('Gecko') > -1 && navigator.userAgent.indexOf('KHTML') == -1 - }, - - BrowserFeatures: { - XPath: !!document.evaluate, - ElementExtensions: !!window.HTMLElement, - SpecificElementExtensions: - (document.createElement('div').__proto__ !== - document.createElement('form').__proto__) - }, - - ScriptFragment: '<script[^>]*>([\\S\\s]*?)<\/script>', - JSONFilter: /^\/\*-secure-([\s\S]*)\*\/\s*$/, - - emptyFunction: function() { }, - K: function(x) { return x } -} - -var Class = { - create: function() { - return function() { - this.initialize.apply(this, arguments); - } - } -} - -var Abstract = new Object(); - -Object.extend = function(destination, source) { - for (var property in source) { - destination[property] = source[property]; - } - return destination; -} - -Object.extend(Object, { - inspect: function(object) { - try { - if (object === undefined) return 'undefined'; - if (object === null) return 'null'; - return object.inspect ? object.inspect() : object.toString(); - } catch (e) { - if (e instanceof RangeError) return '...'; - throw e; - } - }, - - toJSON: function(object) { - var type = typeof object; - switch(type) { - case 'undefined': - case 'function': - case 'unknown': return; - case 'boolean': return object.toString(); - } - if (object === null) return 'null'; - if (object.toJSON) return object.toJSON(); - if (object.ownerDocument === document) return; - var results = []; - for (var property in object) { - var value = Object.toJSON(object[property]); - if (value !== undefined) - results.push(property.toJSON() + ': ' + value); - } - return '{' + results.join(', ') + '}'; - }, - - keys: function(object) { - var keys = []; - for (var property in object) - keys.push(property); - return keys; - }, - - values: function(object) { - var values = []; - for (var property in object) - values.push(object[property]); - return values; - }, - - clone: function(object) { - return Object.extend({}, object); - } -}); - -Function.prototype.bind = function() { - var __method = this, args = $A(arguments), object = args.shift(); - return function() { - return __method.apply(object, args.concat($A(arguments))); - } -} - -Function.prototype.bindAsEventListener = function(object) { - var __method = this, args = $A(arguments), object = args.shift(); - return function(event) { - return __method.apply(object, [event || window.event].concat(args)); - } -} - -Object.extend(Number.prototype, { - toColorPart: function() { - return this.toPaddedString(2, 16); - }, - - succ: function() { - return this + 1; - }, - - times: function(iterator) { - $R(0, this, true).each(iterator); - return this; - }, - - toPaddedString: function(length, radix) { - var string = this.toString(radix || 10); - return '0'.times(length - string.length) + string; - }, - - toJSON: function() { - return isFinite(this) ? this.toString() : 'null'; - } -}); - -Date.prototype.toJSON = function() { - return '"' + this.getFullYear() + '-' + - (this.getMonth() + 1).toPaddedString(2) + '-' + - this.getDate().toPaddedString(2) + 'T' + - this.getHours().toPaddedString(2) + ':' + - this.getMinutes().toPaddedString(2) + ':' + - this.getSeconds().toPaddedString(2) + '"'; -}; - -var Try = { - these: function() { - var returnValue; - - for (var i = 0, length = arguments.length; i < 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() { - this.timer = setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); - }, - - stop: function() { - if (!this.timer) return; - clearInterval(this.timer); - this.timer = null; - }, - - onTimerEvent: function() { - if (!this.currentlyExecuting) { - try { - this.currentlyExecuting = true; - this.callback(this); - } finally { - this.currentlyExecuting = false; - } - } - } -} -Object.extend(String, { - interpret: function(value) { - return value == null ? '' : String(value); - }, - specialChar: { - '\b': '\\b', - '\t': '\\t', - '\n': '\\n', - '\f': '\\f', - '\r': '\\r', - '\\': '\\\\' - } -}); - -Object.extend(String.prototype, { - gsub: function(pattern, replacement) { - var result = '', source = this, match; - replacement = arguments.callee.prepareReplacement(replacement); - - while (source.length > 0) { - if (match = source.match(pattern)) { - result += source.slice(0, match.index); - result += String.interpret(replacement(match)); - source = source.slice(match.index + match[0].length); - } else { - result += source, source = ''; - } - } - return result; - }, - - sub: function(pattern, replacement, count) { - replacement = this.gsub.prepareReplacement(replacement); - count = count === undefined ? 1 : count; - - return this.gsub(pattern, function(match) { - if (--count < 0) return match[0]; - return replacement(match); - }); - }, - - scan: function(pattern, iterator) { - this.gsub(pattern, iterator); - return this; - }, - - truncate: function(length, truncation) { - length = length || 30; - truncation = truncation === undefined ? '...' : truncation; - return this.length > length ? - this.slice(0, length - truncation.length) + truncation : this; - }, - - strip: function() { - return this.replace(/^\s+/, '').replace(/\s+$/, ''); - }, - - stripTags: function() { - return this.replace(/<\/?[^>]+>/gi, ''); - }, - - stripScripts: function() { - return this.replace(new RegExp(Prototype.ScriptFragment, 'img'), ''); - }, - - extractScripts: function() { - var matchAll = new RegExp(Prototype.ScriptFragment, 'img'); - var matchOne = new RegExp(Prototype.ScriptFragment, 'im'); - return (this.match(matchAll) || []).map(function(scriptTag) { - return (scriptTag.match(matchOne) || ['', ''])[1]; - }); - }, - - evalScripts: function() { - return this.extractScripts().map(function(script) { return eval(script) }); - }, - - escapeHTML: function() { - var self = arguments.callee; - self.text.data = this; - return self.div.innerHTML; - }, - - unescapeHTML: function() { - var div = document.createElement('div'); - div.innerHTML = this.stripTags(); - return div.childNodes[0] ? (div.childNodes.length > 1 ? - $A(div.childNodes).inject('', function(memo, node) { return memo+node.nodeValue }) : - div.childNodes[0].nodeValue) : ''; - }, - - toQueryParams: function(separator) { - var match = this.strip().match(/([^?#]*)(#.*)?$/); - if (!match) return {}; - - return match[1].split(separator || '&').inject({}, function(hash, pair) { - if ((pair = pair.split('='))[0]) { - var key = decodeURIComponent(pair.shift()); - var value = pair.length > 1 ? pair.join('=') : pair[0]; - if (value != undefined) value = decodeURIComponent(value); - - if (key in hash) { - if (hash[key].constructor != Array) hash[key] = [hash[key]]; - hash[key].push(value); - } - else hash[key] = value; - } - return hash; - }); - }, - - toArray: function() { - return this.split(''); - }, - - succ: function() { - return this.slice(0, this.length - 1) + - String.fromCharCode(this.charCodeAt(this.length - 1) + 1); - }, - - times: function(count) { - var result = ''; - for (var i = 0; i < count; i++) result += this; - return result; - }, - - camelize: function() { - var parts = this.split('-'), len = parts.length; - if (len == 1) return parts[0]; - - var camelized = this.charAt(0) == '-' - ? parts[0].charAt(0).toUpperCase() + parts[0].substring(1) - : parts[0]; - - for (var i = 1; i < len; i++) - camelized += parts[i].charAt(0).toUpperCase() + parts[i].substring(1); - - return camelized; - }, - - capitalize: function() { - return this.charAt(0).toUpperCase() + this.substring(1).toLowerCase(); - }, - - underscore: function() { - return this.gsub(/::/, '/').gsub(/([A-Z]+)([A-Z][a-z])/,'#{1}_#{2}').gsub(/([a-z\d])([A-Z])/,'#{1}_#{2}').gsub(/-/,'_').toLowerCase(); - }, - - dasherize: function() { - return this.gsub(/_/,'-'); - }, - - inspect: function(useDoubleQuotes) { - var escapedString = this.gsub(/[\x00-\x1f\\]/, function(match) { - var character = String.specialChar[match[0]]; - return character ? character : '\\u00' + match[0].charCodeAt().toPaddedString(2, 16); - }); - if (useDoubleQuotes) return '"' + escapedString.replace(/"/g, '\\"') + '"'; - return "'" + escapedString.replace(/'/g, '\\\'') + "'"; - }, - - toJSON: function() { - return this.inspect(true); - }, - - unfilterJSON: function(filter) { - return this.sub(filter || Prototype.JSONFilter, '#{1}'); - }, - - isJSON: function() { - var str = this.replace(/\\./g, '@').replace(/"[^"\\\n\r]*"/g, ''); - return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str); - }, - - evalJSON: function(sanitize) { - var json = this.unfilterJSON(); - try { - if (!sanitize || json.isJSON()) return eval('(' + json + ')'); - } catch (e) { } - throw new SyntaxError('Badly formed JSON string: ' + this.inspect()); - }, - - include: function(pattern) { - return this.indexOf(pattern) > -1; - }, - - startsWith: function(pattern) { - return this.indexOf(pattern) === 0; - }, - - endsWith: function(pattern) { - var d = this.length - pattern.length; - return d >= 0 && this.lastIndexOf(pattern) === d; - }, - - empty: function() { - return this == ''; - }, - - blank: function() { - return /^\s*$/.test(this); - } -}); - -if (Prototype.Browser.WebKit || Prototype.Browser.IE) Object.extend(String.prototype, { - escapeHTML: function() { - return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); - }, - unescapeHTML: function() { - return this.replace(/&/g,'&').replace(/</g,'<').replace(/>/g,'>'); - } -}); - -String.prototype.gsub.prepareReplacement = function(replacement) { - if (typeof replacement == 'function') return replacement; - var template = new Template(replacement); - return function(match) { return template.evaluate(match) }; -} - -String.prototype.parseQuery = String.prototype.toQueryParams; - -Object.extend(String.prototype.escapeHTML, { - div: document.createElement('div'), - text: document.createTextNode('') -}); - -with (String.prototype.escapeHTML) div.appendChild(text); - -var Template = Class.create(); -Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/; -Template.prototype = { - initialize: function(template, pattern) { - this.template = template.toString(); - this.pattern = pattern || Template.Pattern; - }, - - evaluate: function(object) { - return this.template.gsub(this.pattern, function(match) { - var before = match[1]; - if (before == '\\') return match[2]; - return before + String.interpret(object[match[3]]); - }); - } -} - -var $break = {}, $continue = new Error('"throw $continue" is deprecated, use "return" instead'); - -var Enumerable = { - each: function(iterator) { - var index = 0; - try { - this._each(function(value) { - iterator(value, index++); - }); - } catch (e) { - if (e != $break) throw e; - } - return this; - }, - - eachSlice: function(number, iterator) { - var index = -number, slices = [], array = this.toArray(); - while ((index += number) < array.length) - slices.push(array.slice(index, index+number)); - return slices.map(iterator); - }, - - all: function(iterator) { - var result = true; - this.each(function(value, index) { - result = result && !!(iterator || Prototype.K)(value, index); - if (!result) throw $break; - }); - return result; - }, - - any: function(iterator) { - var result = false; - this.each(function(value, index) { - if (result = !!(iterator || Prototype.K)(value, index)) - throw $break; - }); - return result; - }, - - collect: function(iterator) { - var results = []; - this.each(function(value, index) { - results.push((iterator || Prototype.K)(value, index)); - }); - return results; - }, - - detect: function(iterator) { - var result; - this.each(function(value, index) { - if (iterator(value, index)) { - result = value; - throw $break; - } - }); - return result; - }, - - findAll: function(iterator) { - var results = []; - this.each(function(value, index) { - if (iterator(value, index)) - results.push(value); - }); - return results; - }, - - grep: function(pattern, iterator) { - var results = []; - this.each(function(value, index) { - var stringValue = value.toString(); - if (stringValue.match(pattern)) - results.push((iterator || Prototype.K)(value, index)); - }) - return results; - }, - - include: function(object) { - var found = false; - this.each(function(value) { - if (value == object) { - found = true; - throw $break; - } - }); - return found; - }, - - inGroupsOf: function(number, fillWith) { - fillWith = fillWith === undefined ? null : fillWith; - return this.eachSlice(number, function(slice) { - while(slice.length < number) slice.push(fillWith); - return slice; - }); - }, - - inject: function(memo, iterator) { - this.each(function(value, index) { - memo = iterator(memo, value, index); - }); - return memo; - }, - - invoke: function(method) { - var args = $A(arguments).slice(1); - return this.map(function(value) { - return value[method].apply(value, args); - }); - }, - - max: function(iterator) { - var result; - this.each(function(value, index) { - value = (iterator || Prototype.K)(value, index); - if (result == undefined || value >= result) - result = value; - }); - return result; - }, - - min: function(iterator) { - var result; - this.each(function(value, index) { - value = (iterator || Prototype.K)(value, index); - if (result == undefined || value < result) - result = value; - }); - return result; - }, - - partition: function(iterator) { - var trues = [], falses = []; - this.each(function(value, index) { - ((iterator || Prototype.K)(value, index) ? - trues : falses).push(value); - }); - return [trues, falses]; - }, - - pluck: function(property) { - var results = []; - this.each(function(value, index) { - results.push(value[property]); - }); - return results; - }, - - reject: function(iterator) { - var results = []; - this.each(function(value, index) { - if (!iterator(value, index)) - results.push(value); - }); - return results; - }, - - sortBy: function(iterator) { - return this.map(function(value, index) { - return {value: value, criteria: iterator(value, index)}; - }).sort(function(left, right) { - var a = left.criteria, b = right.criteria; - return a < b ? -1 : a > b ? 1 : 0; - }).pluck('value'); - }, - - toArray: function() { - return this.map(); - }, - - zip: function() { - var iterator = Prototype.K, args = $A(arguments); - if (typeof args.last() == 'function') - iterator = args.pop(); - - var collections = [this].concat(args).map($A); - return this.map(function(value, index) { - return iterator(collections.pluck(index)); - }); - }, - - size: function() { - return this.toArray().length; - }, - - inspect: function() { - return '#<Enumerable:' + this.toArray().inspect() + '>'; - } -} - -Object.extend(Enumerable, { - map: Enumerable.collect, - find: Enumerable.detect, - select: Enumerable.findAll, - member: Enumerable.include, - entries: Enumerable.toArray -}); -var $A = Array.from = function(iterable) { - if (!iterable) return []; - if (iterable.toArray) { - return iterable.toArray(); - } else { - var results = []; - for (var i = 0, length = iterable.length; i < length; i++) - results.push(iterable[i]); - return results; - } -} - -if (Prototype.Browser.WebKit) { - $A = Array.from = function(iterable) { - if (!iterable) return []; - if (!(typeof iterable == 'function' && iterable == '[object NodeList]') && - iterable.toArray) { - return iterable.toArray(); - } else { - var results = []; - for (var i = 0, length = iterable.length; i < length; i++) - results.push(iterable[i]); - return results; - } - } -} - -Object.extend(Array.prototype, Enumerable); - -if (!Array.prototype._reverse) - Array.prototype._reverse = Array.prototype.reverse; - -Object.extend(Array.prototype, { - _each: function(iterator) { - for (var i = 0, length = this.length; i < length; i++) - iterator(this[i]); - }, - - clear: function() { - this.length = 0; - return this; - }, - - first: function() { - return this[0]; - }, - - last: function() { - return this[this.length - 1]; - }, - - compact: function() { - return this.select(function(value) { - return value != null; - }); - }, - - flatten: function() { - return this.inject([], function(array, value) { - return array.concat(value && value.constructor == Array ? - value.flatten() : [value]); - }); - }, - - without: function() { - var values = $A(arguments); - return this.select(function(value) { - return !values.include(value); - }); - }, - - indexOf: function(object) { - for (var i = 0, length = this.length; i < length; i++) - if (this[i] == object) return i; - return -1; - }, - - reverse: function(inline) { - return (inline !== false ? this : this.toArray())._reverse(); - }, - - reduce: function() { - return this.length > 1 ? this : this[0]; - }, - - uniq: function(sorted) { - return this.inject([], function(array, value, index) { - if (0 == index || (sorted ? array.last() != value : !array.include(value))) - array.push(value); - return array; - }); - }, - - clone: function() { - return [].concat(this); - }, - - size: function() { - return this.length; - }, - - inspect: function() { - return '[' + this.map(Object.inspect).join(', ') + ']'; - }, - - toJSON: function() { - var results = []; - this.each(function(object) { - var value = Object.toJSON(object); - if (value !== undefined) results.push(value); - }); - return '[' + results.join(', ') + ']'; - } -}); - -Array.prototype.toArray = Array.prototype.clone; - -function $w(string) { - string = string.strip(); - return string ? string.split(/\s+/) : []; -} - -if (Prototype.Browser.Opera){ - Array.prototype.concat = function() { - var array = []; - for (var i = 0, length = this.length; i < length; i++) array.push(this[i]); - for (var i = 0, length = arguments.length; i < length; i++) { - if (arguments[i].constructor == Array) { - for (var j = 0, arrayLength = arguments[i].length; j < arrayLength; j++) - array.push(arguments[i][j]); - } else { - array.push(arguments[i]); - } - } - return array; - } -} -var Hash = function(object) { - if (object instanceof Hash) this.merge(object); - else Object.extend(this, object || {}); -}; - -Object.extend(Hash, { - toQueryString: function(obj) { - var parts = []; - parts.add = arguments.callee.addPair; - - this.prototype._each.call(obj, function(pair) { - if (!pair.key) return; - var value = pair.value; - - if (value && typeof value == 'object') { - if (value.constructor == Array) value.each(function(value) { - parts.add(pair.key, value); - }); - return; - } - parts.add(pair.key, value); - }); - - return parts.join('&'); - }, - - toJSON: function(object) { - var results = []; - this.prototype._each.call(object, function(pair) { - var value = Object.toJSON(pair.value); - if (value !== undefined) results.push(pair.key.toJSON() + ': ' + value); - }); - return '{' + results.join(', ') + '}'; - } -}); - -Hash.toQueryString.addPair = function(key, value, prefix) { - key = encodeURIComponent(key); - if (value === undefined) this.push(key); - else this.push(key + '=' + (value == null ? '' : encodeURIComponent(value))); -} - -Object.extend(Hash.prototype, Enumerable); -Object.extend(Hash.prototype, { - _each: function(iterator) { - for (var key in this) { - var value = this[key]; - if (value && value == Hash.prototype[key]) continue; - - var pair = [key, value]; - pair.key = key; - pair.value = value; - iterator(pair); - } - }, - - keys: function() { - return this.pluck('key'); - }, - - values: function() { - return this.pluck('value'); - }, - - merge: function(hash) { - return $H(hash).inject(this, function(mergedHash, pair) { - mergedHash[pair.key] = pair.value; - return mergedHash; - }); - }, - - remove: function() { - var result; - for(var i = 0, length = arguments.length; i < length; i++) { - var value = this[arguments[i]]; - if (value !== undefined){ - if (result === undefined) result = value; - else { - if (result.constructor != Array) result = [result]; - result.push(value) - } - } - delete this[arguments[i]]; - } - return result; - }, - - toQueryString: function() { - return Hash.toQueryString(this); - }, - - inspect: function() { - return '#<Hash:{' + this.map(function(pair) { - return pair.map(Object.inspect).join(': '); - }).join(', ') + '}>'; - }, - - toJSON: function() { - return Hash.toJSON(this); - } -}); - -function $H(object) { - if (object instanceof Hash) return object; - return new Hash(object); -}; - -// Safari iterates over shadowed properties -if (function() { - var i = 0, Test = function(value) { this.key = value }; - Test.prototype.key = 'foo'; - for (var property in new Test('bar')) i++; - return i > 1; -}()) Hash.prototype._each = function(iterator) { - var cache = []; - for (var key in this) { - var value = this[key]; - if ((value && value == Hash.prototype[key]) || cache.include(key)) continue; - cache.push(key); - var pair = [key, value]; - pair.key = key; - pair.value = value; - iterator(pair); - } -}; -ObjectRange = Class.create(); -Object.extend(ObjectRange.prototype, Enumerable); -Object.extend(ObjectRange.prototype, { - initialize: function(start, end, exclusive) { - this.start = start; - this.end = end; - this.exclusive = exclusive; - }, - - _each: function(iterator) { - var value = this.start; - while (this.include(value)) { - iterator(value); - value = value.succ(); - } - }, - - include: function(value) { - if (value < this.start) - return false; - if (this.exclusive) - return value < this.end; - return value <= this.end; - } -}); - -var $R = function(start, end, exclusive) { - return new ObjectRange(start, end, exclusive); -} - -var Ajax = { - getTransport: function() { - return Try.these( - function() {return new XMLHttpRequest()}, - function() {return new ActiveXObject('Msxml2.XMLHTTP')}, - function() {return new ActiveXObject('Microsoft.XMLHTTP')} - ) || false; - }, - - activeRequestCount: 0 -} - -Ajax.Responders = { - responders: [], - - _each: function(iterator) { - this.responders._each(iterator); - }, - - register: function(responder) { - if (!this.include(responder)) - this.responders.push(responder); - }, - - unregister: function(responder) { - this.responders = this.responders.without(responder); - }, - - dispatch: function(callback, request, transport, json) { - this.each(function(responder) { - if (typeof responder[callback] == 'function') { - try { - responder[callback].apply(responder, [request, transport, json]); - } catch (e) {} - } - }); - } -}; - -Object.extend(Ajax.Responders, Enumerable); - -Ajax.Responders.register({ - onCreate: function() { - Ajax.activeRequestCount++; - }, - onComplete: function() { - Ajax.activeRequestCount--; - } -}); - -Ajax.Base = function() {}; -Ajax.Base.prototype = { - setOptions: function(options) { - this.options = { - method: 'post', - asynchronous: true, - contentType: 'application/x-www-form-urlencoded', - encoding: 'UTF-8', - parameters: '' - } - Object.extend(this.options, options || {}); - - this.options.method = this.options.method.toLowerCase(); - if (typeof this.options.parameters == 'string') - this.options.parameters = this.options.parameters.toQueryParams(); - } -} - -Ajax.Request = Class.create(); -Ajax.Request.Events = - ['Uninitialized', 'Loading', 'Loaded', 'Interactive', 'Complete']; - -Ajax.Request.prototype = Object.extend(new Ajax.Base(), { - _complete: false, - - initialize: function(url, options) { - this.transport = Ajax.getTransport(); - this.setOptions(options); - this.request(url); - }, - - request: function(url) { - this.url = url; - this.method = this.options.method; - var params = Object.clone(this.options.parameters); - - if (!['get', 'post'].include(this.method)) { - // simulate other verbs over post - params['_method'] = this.method; - this.method = 'post'; - } - - this.parameters = params; - - if (params = Hash.toQueryString(params)) { - // when GET, append parameters to URL - if (this.method == 'get') - this.url += (this.url.include('?') ? '&' : '?') + params; - else if (/Konqueror|Safari|KHTML/.test(navigator.userAgent)) - params += '&_='; - } - - try { - if (this.options.onCreate) this.options.onCreate(this.transport); - Ajax.Responders.dispatch('onCreate', this, this.transport); - - this.transport.open(this.method.toUpperCase(), this.url, - this.options.asynchronous); - - if (this.options.asynchronous) - setTimeout(function() { this.respondToReadyState(1) }.bind(this), 10); - - this.transport.onreadystatechange = this.onStateChange.bind(this); - this.setRequestHeaders(); - - this.body = this.method == 'post' ? (this.options.postBody || params) : null; - this.transport.send(this.body); - - /* Force Firefox to handle ready state 4 for synchronous requests */ - if (!this.options.asynchronous && this.transport.overrideMimeType) - this.onStateChange(); - - } - catch (e) { - this.dispatchException(e); - } - }, - - onStateChange: function() { - var readyState = this.transport.readyState; - if (readyState > 1 && !((readyState == 4) && this._complete)) - this.respondToReadyState(this.transport.readyState); - }, - - setRequestHeaders: function() { - var headers = { - 'X-Requested-With': 'XMLHttpRequest', - 'X-Prototype-Version': Prototype.Version, - 'Accept': 'text/javascript, text/html, application/xml, text/xml, */*' - }; - - if (this.method == 'post') { - headers['Content-type'] = this.options.contentType + - (this.options.encoding ? '; charset=' + this.options.encoding : ''); - - /* Force "Connection: close" for older Mozilla browsers to work - * around a bug where XMLHttpRequest sends an incorrect - * Content-length header. See Mozilla Bugzilla #246651. - */ - if (this.transport.overrideMimeType && - (navigator.userAgent.match(/Gecko\/(\d{4})/) || [0,2005])[1] < 2005) - headers['Connection'] = 'close'; - } - - // user-defined headers - if (typeof this.options.requestHeaders == 'object') { - var extras = this.options.requestHeaders; - - if (typeof extras.push == 'function') - for (var i = 0, length = extras.length; i < length; i += 2) - headers[extras[i]] = extras[i+1]; - else - $H(extras).each(function(pair) { headers[pair.key] = pair.value }); - } - - for (var name in headers) - this.transport.setRequestHeader(name, headers[name]); - }, - - success: function() { - return !this.transport.status - || (this.transport.status >= 200 && this.transport.status < 300); - }, - - respondToReadyState: function(readyState) { - var state = Ajax.Request.Events[readyState]; - var transport = this.transport, json = this.evalJSON(); - - if (state == 'Complete') { - try { - this._complete = true; - (this.options['on' + this.transport.status] - || this.options['on' + (this.success() ? 'Success' : 'Failure')] - || Prototype.emptyFunction)(transport, json); - } catch (e) { - this.dispatchException(e); - } - - var contentType = this.getHeader('Content-type'); - if (contentType && contentType.strip(). - match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)) - this.evalResponse(); - } - - try { - (this.options['on' + state] || Prototype.emptyFunction)(transport, json); - Ajax.Responders.dispatch('on' + state, this, transport, json); - } catch (e) { - this.dispatchException(e); - } - - if (state == 'Complete') { - // avoid memory leak in MSIE: clean up - this.transport.onreadystatechange = Prototype.emptyFunction; - } - }, - - getHeader: function(name) { - try { - return this.transport.getResponseHeader(name); - } catch (e) { return null } - }, - - evalJSON: function() { - try { - var json = this.getHeader('X-JSON'); - return json ? json.evalJSON() : null; - } catch (e) { return null } - }, - - evalResponse: function() { - try { - return eval((this.transport.responseText || '').unfilterJSON()); - } catch (e) { - this.dispatchException(e); - } - }, - - dispatchException: function(exception) { - (this.options.onException || Prototype.emptyFunction)(this, exception); - Ajax.Responders.dispatch('onException', this, exception); - } -}); - -Ajax.Updater = Class.create(); - -Object.extend(Object.extend(Ajax.Updater.prototype, Ajax.Request.prototype), { - initialize: function(container, url, options) { - this.container = { - success: (container.success || container), - failure: (container.failure || (container.success ? null : container)) - } - - this.transport = Ajax.getTransport(); - this.setOptions(options); - - var onComplete = this.options.onComplete || Prototype.emptyFunction; - this.options.onComplete = (function(transport, param) { - this.updateContent(); - onComplete(transport, param); - }).bind(this); - - this.request(url); - }, - - updateContent: function() { - var receiver = this.container[this.success() ? 'success' : 'failure']; - var response = this.transport.responseText; - - if (!this.options.evalScripts) response = response.stripScripts(); - - if (receiver = $(receiver)) { - if (this.options.insertion) - new this.options.insertion(receiver, response); - else - receiver.update(response); - } - - if (this.success()) { - if (this.onComplete) - setTimeout(this.onComplete.bind(this), 10); - } - } -}); - -Ajax.PeriodicalUpdater = Class.create(); -Ajax.PeriodicalUpdater.prototype = Object.extend(new Ajax.Base(), { - initialize: function(container, url, options) { - this.setOptions(options); - this.onComplete = this.options.onComplete; - - this.frequency = (this.options.frequency || 2); - this.decay = (this.options.decay || 1); - - this.updater = {}; - this.container = container; - this.url = url; - - this.start(); - }, - - start: function() { - this.options.onComplete = this.updateComplete.bind(this); - this.onTimerEvent(); - }, - - stop: function() { - this.updater.options.onComplete = undefined; - clearTimeout(this.timer); - (this.onComplete || Prototype.emptyFunction).apply(this, arguments); - }, - - updateComplete: function(request) { - if (this.options.decay) { - this.decay = (request.responseText == this.lastText ? - this.decay * this.options.decay : 1); - - this.lastText = request.responseText; - } - this.timer = setTimeout(this.onTimerEvent.bind(this), - this.decay * this.frequency * 1000); - }, - - onTimerEvent: function() { - this.updater = new Ajax.Updater(this.container, this.url, this.options); - } -}); -function $(element) { - if (arguments.length > 1) { - for (var i = 0, elements = [], length = arguments.length; i < length; i++) - elements.push($(arguments[i])); - return elements; - } - if (typeof element == 'string') - element = document.getElementById(element); - return Element.extend(element); -} - -if (Prototype.BrowserFeatures.XPath) { - document._getElementsByXPath = function(expression, parentElement) { - var results = []; - var query = document.evaluate(expression, $(parentElement) || document, - null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); - for (var i = 0, length = query.snapshotLength; i < length; i++) - results.push(query.snapshotItem(i)); - return results; - }; - - document.getElementsByClassName = function(className, parentElement) { - var q = ".//*[contains(concat(' ', @class, ' '), ' " + className + " ')]"; - return document._getElementsByXPath(q, parentElement); - } - -} else document.getElementsByClassName = function(className, parentElement) { - var children = ($(parentElement) || document.body).getElementsByTagName('*'); - var elements = [], child, pattern = new RegExp("(^|\\s)" + className + "(\\s|$)"); - for (var i = 0, length = children.length; i < length; i++) { - child = children[i]; - var elementClassName = child.className; - if (elementClassName.length == 0) continue; - if (elementClassName == className || elementClassName.match(pattern)) - elements.push(Element.extend(child)); - } - return elements; -}; - -/*--------------------------------------------------------------------------*/ - -if (!window.Element) var Element = {}; - -Element.extend = function(element) { - var F = Prototype.BrowserFeatures; - if (!element || !element.tagName || element.nodeType == 3 || - element._extended || F.SpecificElementExtensions || element == window) - return element; - - var methods = {}, tagName = element.tagName, cache = Element.extend.cache, - T = Element.Methods.ByTag; - - // extend methods for all tags (Safari doesn't need this) - if (!F.ElementExtensions) { - Object.extend(methods, Element.Methods), - Object.extend(methods, Element.Methods.Simulated); - } - - // extend methods for specific tags - if (T[tagName]) Object.extend(methods, T[tagName]); - - for (var property in methods) { - var value = methods[property]; - if (typeof value == 'function' && !(property in element)) - element[property] = cache.findOrStore(value); - } - - element._extended = Prototype.emptyFunction; - return element; -}; - -Element.extend.cache = { - findOrStore: function(value) { - return this[value] = this[value] || function() { - return value.apply(null, [this].concat($A(arguments))); - } - } -}; - -Element.Methods = { - visible: function(element) { - return $(element).style.display != 'none'; - }, - - toggle: function(element) { - element = $(element); - Element[Element.visible(element) ? 'hide' : 'show'](element); - return element; - }, - - hide: function(element) { - $(element).style.display = 'none'; - return element; - }, - - show: function(element) { - $(element).style.display = ''; - return element; - }, - - remove: function(element) { - element = $(element); - element.parentNode.removeChild(element); - return element; - }, - - update: function(element, html) { - html = typeof html == 'undefined' ? '' : html.toString(); - $(element).innerHTML = html.stripScripts(); - setTimeout(function() {html.evalScripts()}, 10); - return element; - }, - - replace: function(element, html) { - element = $(element); - html = typeof html == 'undefined' ? '' : html.toString(); - if (element.outerHTML) { - element.outerHTML = html.stripScripts(); - } else { - var range = element.ownerDocument.createRange(); - range.selectNodeContents(element); - element.parentNode.replaceChild( - range.createContextualFragment(html.stripScripts()), element); - } - setTimeout(function() {html.evalScripts()}, 10); - return element; - }, - - inspect: function(element) { - element = $(element); - var result = '<' + element.tagName.toLowerCase(); - $H({'id': 'id', 'className': 'class'}).each(function(pair) { - var property = pair.first(), attribute = pair.last(); - var value = (element[property] || '').toString(); - if (value) result += ' ' + attribute + '=' + value.inspect(true); - }); - return result + '>'; - }, - - recursivelyCollect: function(element, property) { - element = $(element); - var elements = []; - while (element = element[property]) - if (element.nodeType == 1) - elements.push(Element.extend(element)); - return elements; - }, - - ancestors: function(element) { - return $(element).recursivelyCollect('parentNode'); - }, - - descendants: function(element) { - return $A($(element).getElementsByTagName('*')).each(Element.extend); - }, - - firstDescendant: function(element) { - element = $(element).firstChild; - while (element && element.nodeType != 1) element = element.nextSibling; - return $(element); - }, - - immediateDescendants: function(element) { - if (!(element = $(element).firstChild)) return []; - while (element && element.nodeType != 1) element = element.nextSibling; - if (element) return [element].concat($(element).nextSiblings()); - return []; - }, - - previousSiblings: function(element) { - return $(element).recursivelyCollect('previousSibling'); - }, - - nextSiblings: function(element) { - return $(element).recursivelyCollect('nextSibling'); - }, - - siblings: function(element) { - element = $(element); - return element.previousSiblings().reverse().concat(element.nextSiblings()); - }, - - match: function(element, selector) { - if (typeof selector == 'string') - selector = new Selector(selector); - return selector.match($(element)); - }, - - up: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(element.parentNode); - var ancestors = element.ancestors(); - return expression ? Selector.findElement(ancestors, expression, index) : - ancestors[index || 0]; - }, - - down: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return element.firstDescendant(); - var descendants = element.descendants(); - return expression ? Selector.findElement(descendants, expression, index) : - descendants[index || 0]; - }, - - previous: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(Selector.handlers.previousElementSibling(element)); - var previousSiblings = element.previousSiblings(); - return expression ? Selector.findElement(previousSiblings, expression, index) : - previousSiblings[index || 0]; - }, - - next: function(element, expression, index) { - element = $(element); - if (arguments.length == 1) return $(Selector.handlers.nextElementSibling(element)); - var nextSiblings = element.nextSiblings(); - return expression ? Selector.findElement(nextSiblings, expression, index) : - nextSiblings[index || 0]; - }, - - getElementsBySelector: function() { - var args = $A(arguments), element = $(args.shift()); - return Selector.findChildElements(element, args); - }, - - getElementsByClassName: function(element, className) { - return document.getElementsByClassName(className, element); - }, - - readAttribute: function(element, name) { - element = $(element); - if (Prototype.Browser.IE) { - if (!element.attributes) return null; - var t = Element._attributeTranslations; - if (t.values[name]) return t.values[name](element, name); - if (t.names[name]) name = t.names[name]; - var attribute = element.attributes[name]; - return attribute ? attribute.nodeValue : null; - } - return element.getAttribute(name); - }, - - getHeight: function(element) { - return $(element).getDimensions().height; - }, - - getWidth: function(element) { - return $(element).getDimensions().width; - }, - - classNames: function(element) { - return new Element.ClassNames(element); - }, - - hasClassName: function(element, className) { - if (!(element = $(element))) return; - var elementClassName = element.className; - if (elementClassName.length == 0) return false; - if (elementClassName == className || - elementClassName.match(new RegExp("(^|\\s)" + className + "(\\s|$)"))) - return true; - return false; - }, - - addClassName: function(element, className) { - if (!(element = $(element))) return; - Element.classNames(element).add(className); - return element; - }, - - removeClassName: function(element, className) { - if (!(element = $(element))) return; - Element.classNames(element).remove(className); - return element; - }, - - toggleClassName: function(element, className) { - if (!(element = $(element))) return; - Element.classNames(element)[element.hasClassName(className) ? 'remove' : 'add'](className); - return element; - }, - - observe: function() { - Event.observe.apply(Event, arguments); - return $A(arguments).first(); - }, - - stopObserving: function() { - Event.stopObserving.apply(Event, arguments); - return $A(arguments).first(); - }, - - // removes whitespace-only text node children - cleanWhitespace: function(element) { - element = $(element); - var node = element.firstChild; - while (node) { - var nextNode = node.nextSibling; - if (node.nodeType == 3 && !/\S/.test(node.nodeValue)) - element.removeChild(node); - node = nextNode; - } - return element; - }, - - empty: function(element) { - return $(element).innerHTML.blank(); - }, - - descendantOf: function(element, ancestor) { - element = $(element), ancestor = $(ancestor); - while (element = element.parentNode) - if (element == ancestor) return true; - return false; - }, - - scrollTo: function(element) { - element = $(element); - var pos = Position.cumulativeOffset(element); - window.scrollTo(pos[0], pos[1]); - return element; - }, - - getStyle: function(element, style) { - element = $(element); - style = style == 'float' ? 'cssFloat' : style.camelize(); - var value = element.style[style]; - if (!value) { - var css = document.defaultView.getComputedStyle(element, null); - value = css ? css[style] : null; - } - if (style == 'opacity') return value ? parseFloat(value) : 1.0; - return value == 'auto' ? null : value; - }, - - getOpacity: function(element) { - return $(element).getStyle('opacity'); - }, - - setStyle: function(element, styles, camelized) { - element = $(element); - var elementStyle = element.style; - - for (var property in styles) - if (property == 'opacity') element.setOpacity(styles[property]) - else - elementStyle[(property == 'float' || property == 'cssFloat') ? - (elementStyle.styleFloat === undefined ? 'cssFloat' : 'styleFloat') : - (camelized ? property : property.camelize())] = styles[property]; - - return element; - }, - - setOpacity: function(element, value) { - element = $(element); - element.style.opacity = (value == 1 || value === '') ? '' : - (value < 0.00001) ? 0 : value; - return element; - }, - - getDimensions: function(element) { - element = $(element); - var display = $(element).getStyle('display'); - if (display != 'none' && display != null) // Safari bug - return {width: element.offsetWidth, height: element.offsetHeight}; - - // All *Width and *Height properties give 0 on elements with display none, - // so enable the element temporarily - var els = element.style; - var originalVisibility = els.visibility; - var originalPosition = els.position; - var originalDisplay = els.display; - els.visibility = 'hidden'; - els.position = 'absolute'; - els.display = 'block'; - var originalWidth = element.clientWidth; - var originalHeight = element.clientHeight; - els.display = originalDisplay; - els.position = originalPosition; - els.visibility = originalVisibility; - return {width: originalWidth, height: originalHeight}; - }, - - makePositioned: function(element) { - element = $(element); - var pos = Element.getStyle(element, 'position'); - if (pos == 'static' || !pos) { - element._madePositioned = true; - element.style.position = 'relative'; - // Opera returns the offset relative to the positioning context, when an - // element is position relative but top and left have not been defined - if (window.opera) { - element.style.top = 0; - element.style.left = 0; - } - } - return element; - }, - - undoPositioned: function(element) { - element = $(element); - if (element._madePositioned) { - element._madePositioned = undefined; - element.style.position = - element.style.top = - element.style.left = - element.style.bottom = - element.style.right = ''; - } - return element; - }, - - makeClipping: function(element) { - element = $(element); - if (element._overflow) return element; - element._overflow = element.style.overflow || 'auto'; - if ((Element.getStyle(element, 'overflow') || 'visible') != 'hidden') - element.style.overflow = 'hidden'; - return element; - }, - - undoClipping: function(element) { - element = $(element); - if (!element._overflow) return element; - element.style.overflow = element._overflow == 'auto' ? '' : element._overflow; - element._overflow = null; - return element; - } -}; - -Object.extend(Element.Methods, { - childOf: Element.Methods.descendantOf, - childElements: Element.Methods.immediateDescendants -}); - -if (Prototype.Browser.Opera) { - Element.Methods._getStyle = Element.Methods.getStyle; - Element.Methods.getStyle = function(element, style) { - switch(style) { - case 'left': - case 'top': - case 'right': - case 'bottom': - if (Element._getStyle(element, 'position') == 'static') return null; - default: return Element._getStyle(element, style); - } - }; -} -else if (Prototype.Browser.IE) { - Element.Methods.getStyle = function(element, style) { - element = $(element); - style = (style == 'float' || style == 'cssFloat') ? 'styleFloat' : style.camelize(); - var value = element.style[style]; - if (!value && element.currentStyle) value = element.currentStyle[style]; - - if (style == 'opacity') { - if (value = (element.getStyle('filter') || '').match(/alpha\(opacity=(.*)\)/)) - if (value[1]) return parseFloat(value[1]) / 100; - return 1.0; - } - - if (value == 'auto') { - if ((style == 'width' || style == 'height') && (element.getStyle('display') != 'none')) - return element['offset'+style.capitalize()] + 'px'; - return null; - } - return value; - }; - - Element.Methods.setOpacity = function(element, value) { - element = $(element); - var filter = element.getStyle('filter'), style = element.style; - if (value == 1 || value === '') { - style.filter = filter.replace(/alpha\([^\)]*\)/gi,''); - return element; - } else if (value < 0.00001) value = 0; - style.filter = filter.replace(/alpha\([^\)]*\)/gi, '') + - 'alpha(opacity=' + (value * 100) + ')'; - return element; - }; - - // IE is missing .innerHTML support for TABLE-related elements - Element.Methods.update = function(element, html) { - element = $(element); - html = typeof html == 'undefined' ? '' : html.toString(); - var tagName = element.tagName.toUpperCase(); - if (['THEAD','TBODY','TR','TD'].include(tagName)) { - var div = document.createElement('div'); - switch (tagName) { - case 'THEAD': - case 'TBODY': - div.innerHTML = '<table><tbody>' + html.stripScripts() + '</tbody></table>'; - depth = 2; - break; - case 'TR': - div.innerHTML = '<table><tbody><tr>' + html.stripScripts() + '</tr></tbody></table>'; - depth = 3; - break; - case 'TD': - div.innerHTML = '<table><tbody><tr><td>' + html.stripScripts() + '</td></tr></tbody></table>'; - depth = 4; - } - $A(element.childNodes).each(function(node) { element.removeChild(node) }); - depth.times(function() { div = div.firstChild }); - $A(div.childNodes).each(function(node) { element.appendChild(node) }); - } else { - element.innerHTML = html.stripScripts(); - } - setTimeout(function() { html.evalScripts() }, 10); - return element; - } -} -else if (Prototype.Browser.Gecko) { - Element.Methods.setOpacity = function(element, value) { - element = $(element); - element.style.opacity = (value == 1) ? 0.999999 : - (value === '') ? '' : (value < 0.00001) ? 0 : value; - return element; - }; -} - -Element._attributeTranslations = { - names: { - colspan: "colSpan", - rowspan: "rowSpan", - valign: "vAlign", - datetime: "dateTime", - accesskey: "accessKey", - tabindex: "tabIndex", - enctype: "encType", - maxlength: "maxLength", - readonly: "readOnly", - longdesc: "longDesc" - }, - values: { - _getAttr: function(element, attribute) { - return element.getAttribute(attribute, 2); - }, - _flag: function(element, attribute) { - return $(element).hasAttribute(attribute) ? attribute : null; - }, - style: function(element) { - return element.style.cssText.toLowerCase(); - }, - title: function(element) { - var node = element.getAttributeNode('title'); - return node.specified ? node.nodeValue : null; - } - } -}; - -(function() { - Object.extend(this, { - href: this._getAttr, - src: this._getAttr, - type: this._getAttr, - disabled: this._flag, - checked: this._flag, - readonly: this._flag, - multiple: this._flag - }); -}).call(Element._attributeTranslations.values); - -Element.Methods.Simulated = { - hasAttribute: function(element, attribute) { - var t = Element._attributeTranslations, node; - attribute = t.names[attribute] || attribute; - node = $(element).getAttributeNode(attribute); - return node && node.specified; - } -}; - -Element.Methods.ByTag = {}; - -Object.extend(Element, Element.Methods); - -if (!Prototype.BrowserFeatures.ElementExtensions && - document.createElement('div').__proto__) { - window.HTMLElement = {}; - window.HTMLElement.prototype = document.createElement('div').__proto__; - Prototype.BrowserFeatures.ElementExtensions = true; -} - -Element.hasAttribute = function(element, attribute) { - if (element.hasAttribute) return element.hasAttribute(attribute); - return Element.Methods.Simulated.hasAttribute(element, attribute); -}; - -Element.addMethods = function(methods) { - var F = Prototype.BrowserFeatures, T = Element.Methods.ByTag; - - if (!methods) { - Object.extend(Form, Form.Methods); - Object.extend(Form.Element, Form.Element.Methods); - Object.extend(Element.Methods.ByTag, { - "FORM": Object.clone(Form.Methods), - "INPUT": Object.clone(Form.Element.Methods), - "SELECT": Object.clone(Form.Element.Methods), - "TEXTAREA": Object.clone(Form.Element.Methods) - }); - } - - if (arguments.length == 2) { - var tagName = methods; - methods = arguments[1]; - } - - if (!tagName) Object.extend(Element.Methods, methods || {}); - else { - if (tagName.constructor == Array) tagName.each(extend); - else extend(tagName); - } - - function extend(tagName) { - tagName = tagName.toUpperCase(); - if (!Element.Methods.ByTag[tagName]) - Element.Methods.ByTag[tagName] = {}; - Object.extend(Element.Methods.ByTag[tagName], methods); - } - - function copy(methods, destination, onlyIfAbsent) { - onlyIfAbsent = onlyIfAbsent || false; - var cache = Element.extend.cache; - for (var property in methods) { - var value = methods[property]; - if (!onlyIfAbsent || !(property in destination)) - destination[property] = cache.findOrStore(value); - } - } - - function findDOMClass(tagName) { - var klass; - var trans = { - "OPTGROUP": "OptGroup", "TEXTAREA": "TextArea", "P": "Paragraph", - "FIELDSET": "FieldSet", "UL": "UList", "OL": "OList", "DL": "DList", - "DIR": "Directory", "H1": "Heading", "H2": "Heading", "H3": "Heading", - "H4": "Heading", "H5": "Heading", "H6": "Heading", "Q": "Quote", - "INS": "Mod", "DEL": "Mod", "A": "Anchor", "IMG": "Image", "CAPTION": - "TableCaption", "COL": "TableCol", "COLGROUP": "TableCol", "THEAD": - "TableSection", "TFOOT": "TableSection", "TBODY": "TableSection", "TR": - "TableRow", "TH": "TableCell", "TD": "TableCell", "FRAMESET": - "FrameSet", "IFRAME": "IFrame" - }; - if (trans[tagName]) klass = 'HTML' + trans[tagName] + 'Element'; - if (window[klass]) return window[klass]; - klass = 'HTML' + tagName + 'Element'; - if (window[klass]) return window[klass]; - klass = 'HTML' + tagName.capitalize() + 'Element'; - if (window[klass]) return window[klass]; - - window[klass] = {}; - window[klass].prototype = document.createElement(tagName).__proto__; - return window[klass]; - } - - if (F.ElementExtensions) { - copy(Element.Methods, HTMLElement.prototype); - copy(Element.Methods.Simulated, HTMLElement.prototype, true); - } - - if (F.SpecificElementExtensions) { - for (var tag in Element.Methods.ByTag) { - var klass = findDOMClass(tag); - if (typeof klass == "undefined") continue; - copy(T[tag], klass.prototype); - } - } - - Object.extend(Element, Element.Methods); - delete Element.ByTag; -}; - -var Toggle = { display: Element.toggle }; - -/*--------------------------------------------------------------------------*/ - -Abstract.Insertion = function(adjacency) { - this.adjacency = adjacency; -} - -Abstract.Insertion.prototype = { - initialize: function(element, content) { - this.element = $(element); - this.content = content.stripScripts(); - - if (this.adjacency && this.element.insertAdjacentHTML) { - try { - this.element.insertAdjacentHTML(this.adjacency, this.content); - } catch (e) { - var tagName = this.element.tagName.toUpperCase(); - if (['TBODY', 'TR'].include(tagName)) { - this.insertContent(this.contentFromAnonymousTable()); - } else { - throw e; - } - } - } else { - this.range = this.element.ownerDocument.createRange(); - if (this.initializeRange) this.initializeRange(); - this.insertContent([this.range.createContextualFragment(this.content)]); - } - - setTimeout(function() {content.evalScripts()}, 10); - }, - - contentFromAnonymousTable: function() { - var div = document.createElement('div'); - div.innerHTML = '<table><tbody>' + this.content + '</tbody></table>'; - return $A(div.childNodes[0].childNodes[0].childNodes); - } -} - -var Insertion = new Object(); - -Insertion.Before = Class.create(); -Insertion.Before.prototype = Object.extend(new Abstract.Insertion('beforeBegin'), { - initializeRange: function() { - this.range.setStartBefore(this.element); - }, - - insertContent: function(fragments) { - fragments.each((function(fragment) { - this.element.parentNode.insertBefore(fragment, this.element); - }).bind(this)); - } -}); - -Insertion.Top = Class.create(); -Insertion.Top.prototype = Object.extend(new Abstract.Insertion('afterBegin'), { - initializeRange: function() { - this.range.selectNodeContents(this.element); - this.range.collapse(true); - }, - - insertContent: function(fragments) { - fragments.reverse(false).each((function(fragment) { - this.element.insertBefore(fragment, this.element.firstChild); - }).bind(this)); - } -}); - -Insertion.Bottom = Class.create(); -Insertion.Bottom.prototype = Object.extend(new Abstract.Insertion('beforeEnd'), { - initializeRange: function() { - this.range.selectNodeContents(this.element); - this.range.collapse(this.element); - }, - - insertContent: function(fragments) { - fragments.each((function(fragment) { - this.element.appendChild(fragment); - }).bind(this)); - } -}); - -Insertion.After = Class.create(); -Insertion.After.prototype = Object.extend(new Abstract.Insertion('afterEnd'), { - initializeRange: function() { - this.range.setStartAfter(this.element); - }, - - insertContent: function(fragments) { - fragments.each((function(fragment) { - this.element.parentNode.insertBefore(fragment, - this.element.nextSibling); - }).bind(this)); - } -}); - -/*--------------------------------------------------------------------------*/ - -Element.ClassNames = Class.create(); -Element.ClassNames.prototype = { - initialize: function(element) { - this.element = $(element); - }, - - _each: function(iterator) { - this.element.className.split(/\s+/).select(function(name) { - return name.length > 0; - })._each(iterator); - }, - - set: function(className) { - this.element.className = className; - }, - - add: function(classNameToAdd) { - if (this.include(classNameToAdd)) return; - this.set($A(this).concat(classNameToAdd).join(' ')); - }, - - remove: function(classNameToRemove) { - if (!this.include(classNameToRemove)) return; - this.set($A(this).without(classNameToRemove).join(' ')); - }, - - toString: function() { - return $A(this).join(' '); - } -}; - -Object.extend(Element.ClassNames.prototype, Enumerable); -/* Portions of the Selector class are derived from Jack Slocum’s DomQuery, - * part of YUI-Ext version 0.40, distributed under the terms of an MIT-style - * license. Please see http://www.yui-ext.com/ for more information. */ - -var Selector = Class.create(); - -Selector.prototype = { - initialize: function(expression) { - this.expression = expression.strip(); - this.compileMatcher(); - }, - - compileMatcher: function() { - // Selectors with namespaced attributes can't use the XPath version - if (Prototype.BrowserFeatures.XPath && !(/\[[\w-]*?:/).test(this.expression)) - return this.compileXPathMatcher(); - - var e = this.expression, ps = Selector.patterns, h = Selector.handlers, - c = Selector.criteria, le, p, m; - - if (Selector._cache[e]) { - this.matcher = Selector._cache[e]; return; - } - this.matcher = ["this.matcher = function(root) {", - "var r = root, h = Selector.handlers, c = false, n;"]; - - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - p = ps[i]; - if (m = e.match(p)) { - this.matcher.push(typeof c[i] == 'function' ? c[i](m) : - new Template(c[i]).evaluate(m)); - e = e.replace(m[0], ''); - break; - } - } - } - - this.matcher.push("return h.unique(n);\n}"); - eval(this.matcher.join('\n')); - Selector._cache[this.expression] = this.matcher; - }, - - compileXPathMatcher: function() { - var e = this.expression, ps = Selector.patterns, - x = Selector.xpath, le, m; - - if (Selector._cache[e]) { - this.xpath = Selector._cache[e]; return; - } - - this.matcher = ['.//*']; - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in ps) { - if (m = e.match(ps[i])) { - this.matcher.push(typeof x[i] == 'function' ? x[i](m) : - new Template(x[i]).evaluate(m)); - e = e.replace(m[0], ''); - break; - } - } - } - - this.xpath = this.matcher.join(''); - Selector._cache[this.expression] = this.xpath; - }, - - findElements: function(root) { - root = root || document; - if (this.xpath) return document._getElementsByXPath(this.xpath, root); - return this.matcher(root); - }, - - match: function(element) { - return this.findElements(document).include(element); - }, - - toString: function() { - return this.expression; - }, - - inspect: function() { - return "#<Selector:" + this.expression.inspect() + ">"; - } -}; - -Object.extend(Selector, { - _cache: {}, - - xpath: { - descendant: "//*", - child: "/*", - adjacent: "/following-sibling::*[1]", - laterSibling: '/following-sibling::*', - tagName: function(m) { - if (m[1] == '*') return ''; - return "[local-name()='" + m[1].toLowerCase() + - "' or local-name()='" + m[1].toUpperCase() + "']"; - }, - className: "[contains(concat(' ', @class, ' '), ' #{1} ')]", - id: "[@id='#{1}']", - attrPresence: "[@#{1}]", - attr: function(m) { - m[3] = m[5] || m[6]; - return new Template(Selector.xpath.operators[m[2]]).evaluate(m); - }, - pseudo: function(m) { - var h = Selector.xpath.pseudos[m[1]]; - if (!h) return ''; - if (typeof h === 'function') return h(m); - return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m); - }, - operators: { - '=': "[@#{1}='#{3}']", - '!=': "[@#{1}!='#{3}']", - '^=': "[starts-with(@#{1}, '#{3}')]", - '$=': "[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']", - '*=': "[contains(@#{1}, '#{3}')]", - '~=': "[contains(concat(' ', @#{1}, ' '), ' #{3} ')]", - '|=': "[contains(concat('-', @#{1}, '-'), '-#{3}-')]" - }, - pseudos: { - 'first-child': '[not(preceding-sibling::*)]', - 'last-child': '[not(following-sibling::*)]', - 'only-child': '[not(preceding-sibling::* or following-sibling::*)]', - 'empty': "[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]", - 'checked': "[@checked]", - 'disabled': "[@disabled]", - 'enabled': "[not(@disabled)]", - 'not': function(m) { - var e = m[6], p = Selector.patterns, - x = Selector.xpath, le, m, v; - - var exclusion = []; - while (e && le != e && (/\S/).test(e)) { - le = e; - for (var i in p) { - if (m = e.match(p[i])) { - v = typeof x[i] == 'function' ? x[i](m) : new Template(x[i]).evaluate(m); - exclusion.push("(" + v.substring(1, v.length - 1) + ")"); - e = e.replace(m[0], ''); - break; - } - } - } - return "[not(" + exclusion.join(" and ") + ")]"; - }, - 'nth-child': function(m) { - return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ", m); - }, - 'nth-last-child': function(m) { - return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ", m); - }, - 'nth-of-type': function(m) { - return Selector.xpath.pseudos.nth("position() ", m); - }, - 'nth-last-of-type': function(m) { - return Selector.xpath.pseudos.nth("(last() + 1 - position()) ", m); - }, - 'first-of-type': function(m) { - m[6] = "1"; return Selector.xpath.pseudos['nth-of-type'](m); - }, - 'last-of-type': function(m) { - m[6] = "1"; return Selector.xpath.pseudos['nth-last-of-type'](m); - }, - 'only-of-type': function(m) { - var p = Selector.xpath.pseudos; return p['first-of-type'](m) + p['last-of-type'](m); - }, - nth: function(fragment, m) { - var mm, formula = m[6], predicate; - if (formula == 'even') formula = '2n+0'; - if (formula == 'odd') formula = '2n+1'; - if (mm = formula.match(/^(\d+)$/)) // digit only - return '[' + fragment + "= " + mm[1] + ']'; - if (mm = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b - if (mm[1] == "-") mm[1] = -1; - var a = mm[1] ? Number(mm[1]) : 1; - var b = mm[2] ? Number(mm[2]) : 0; - predicate = "[((#{fragment} - #{b}) mod #{a} = 0) and " + - "((#{fragment} - #{b}) div #{a} >= 0)]"; - return new Template(predicate).evaluate({ - fragment: fragment, a: a, b: b }); - } - } - } - }, - - criteria: { - tagName: 'n = h.tagName(n, r, "#{1}", c); c = false;', - className: 'n = h.className(n, r, "#{1}", c); c = false;', - id: 'n = h.id(n, r, "#{1}", c); c = false;', - attrPresence: 'n = h.attrPresence(n, r, "#{1}"); c = false;', - attr: function(m) { - m[3] = (m[5] || m[6]); - return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(m); - }, - pseudo: function(m) { - if (m[6]) m[6] = m[6].replace(/"/g, '\\"'); - return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(m); - }, - descendant: 'c = "descendant";', - child: 'c = "child";', - adjacent: 'c = "adjacent";', - laterSibling: 'c = "laterSibling";' - }, - - patterns: { - // combinators must be listed first - // (and descendant needs to be last combinator) - laterSibling: /^\s*~\s*/, - child: /^\s*>\s*/, - adjacent: /^\s*\+\s*/, - descendant: /^\s/, - - // selectors follow - tagName: /^\s*(\*|[\w\-]+)(\b|$)?/, - id: /^#([\w\-\*]+)(\b|$)/, - className: /^\.([\w\-\*]+)(\b|$)/, - pseudo: /^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/, - attrPresence: /^\[([\w]+)\]/, - attr: /\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\]]*?)\4|([^'"][^\]]*?)))?\]/ - }, - - handlers: { - // UTILITY FUNCTIONS - // joins two collections - concat: function(a, b) { - for (var i = 0, node; node = b[i]; i++) - a.push(node); - return a; - }, - - // marks an array of nodes for counting - mark: function(nodes) { - for (var i = 0, node; node = nodes[i]; i++) - node._counted = true; - return nodes; - }, - - unmark: function(nodes) { - for (var i = 0, node; node = nodes[i]; i++) - node._counted = undefined; - return nodes; - }, - - // mark each child node with its position (for nth calls) - // "ofType" flag indicates whether we're indexing for nth-of-type - // rather than nth-child - index: function(parentNode, reverse, ofType) { - parentNode._counted = true; - if (reverse) { - for (var nodes = parentNode.childNodes, i = nodes.length - 1, j = 1; i >= 0; i--) { - node = nodes[i]; - if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++; - } - } else { - for (var i = 0, j = 1, nodes = parentNode.childNodes; node = nodes[i]; i++) - if (node.nodeType == 1 && (!ofType || node._counted)) node.nodeIndex = j++; - } - }, - - // filters out duplicates and extends all nodes - unique: function(nodes) { - if (nodes.length == 0) return nodes; - var results = [], n; - for (var i = 0, l = nodes.length; i < l; i++) - if (!(n = nodes[i])._counted) { - n._counted = true; - results.push(Element.extend(n)); - } - return Selector.handlers.unmark(results); - }, - - // COMBINATOR FUNCTIONS - descendant: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - h.concat(results, node.getElementsByTagName('*')); - return results; - }, - - child: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) { - for (var j = 0, children = [], child; child = node.childNodes[j]; j++) - if (child.nodeType == 1 && child.tagName != '!') results.push(child); - } - return results; - }, - - adjacent: function(nodes) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - var next = this.nextElementSibling(node); - if (next) results.push(next); - } - return results; - }, - - laterSibling: function(nodes) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - h.concat(results, Element.nextSiblings(node)); - return results; - }, - - nextElementSibling: function(node) { - while (node = node.nextSibling) - if (node.nodeType == 1) return node; - return null; - }, - - previousElementSibling: function(node) { - while (node = node.previousSibling) - if (node.nodeType == 1) return node; - return null; - }, - - // TOKEN FUNCTIONS - tagName: function(nodes, root, tagName, combinator) { - tagName = tagName.toUpperCase(); - var results = [], h = Selector.handlers; - if (nodes) { - if (combinator) { - // fastlane for ordinary descendant combinators - if (combinator == "descendant") { - for (var i = 0, node; node = nodes[i]; i++) - h.concat(results, node.getElementsByTagName(tagName)); - return results; - } else nodes = this[combinator](nodes); - if (tagName == "*") return nodes; - } - for (var i = 0, node; node = nodes[i]; i++) - if (node.tagName.toUpperCase() == tagName) results.push(node); - return results; - } else return root.getElementsByTagName(tagName); - }, - - id: function(nodes, root, id, combinator) { - var targetNode = $(id), h = Selector.handlers; - if (!nodes && root == document) return targetNode ? [targetNode] : []; - if (nodes) { - if (combinator) { - if (combinator == 'child') { - for (var i = 0, node; node = nodes[i]; i++) - if (targetNode.parentNode == node) return [targetNode]; - } else if (combinator == 'descendant') { - for (var i = 0, node; node = nodes[i]; i++) - if (Element.descendantOf(targetNode, node)) return [targetNode]; - } else if (combinator == 'adjacent') { - for (var i = 0, node; node = nodes[i]; i++) - if (Selector.handlers.previousElementSibling(targetNode) == node) - return [targetNode]; - } else nodes = h[combinator](nodes); - } - for (var i = 0, node; node = nodes[i]; i++) - if (node == targetNode) return [targetNode]; - return []; - } - return (targetNode && Element.descendantOf(targetNode, root)) ? [targetNode] : []; - }, - - className: function(nodes, root, className, combinator) { - if (nodes && combinator) nodes = this[combinator](nodes); - return Selector.handlers.byClassName(nodes, root, className); - }, - - byClassName: function(nodes, root, className) { - if (!nodes) nodes = Selector.handlers.descendant([root]); - var needle = ' ' + className + ' '; - for (var i = 0, results = [], node, nodeClassName; node = nodes[i]; i++) { - nodeClassName = node.className; - if (nodeClassName.length == 0) continue; - if (nodeClassName == className || (' ' + nodeClassName + ' ').include(needle)) - results.push(node); - } - return results; - }, - - attrPresence: function(nodes, root, attr) { - var results = []; - for (var i = 0, node; node = nodes[i]; i++) - if (Element.hasAttribute(node, attr)) results.push(node); - return results; - }, - - attr: function(nodes, root, attr, value, operator) { - if (!nodes) nodes = root.getElementsByTagName("*"); - var handler = Selector.operators[operator], results = []; - for (var i = 0, node; node = nodes[i]; i++) { - var nodeValue = Element.readAttribute(node, attr); - if (nodeValue === null) continue; - if (handler(nodeValue, value)) results.push(node); - } - return results; - }, - - pseudo: function(nodes, name, value, root, combinator) { - if (nodes && combinator) nodes = this[combinator](nodes); - if (!nodes) nodes = root.getElementsByTagName("*"); - return Selector.pseudos[name](nodes, value, root); - } - }, - - pseudos: { - 'first-child': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - if (Selector.handlers.previousElementSibling(node)) continue; - results.push(node); - } - return results; - }, - 'last-child': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - if (Selector.handlers.nextElementSibling(node)) continue; - results.push(node); - } - return results; - }, - 'only-child': function(nodes, value, root) { - var h = Selector.handlers; - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!h.previousElementSibling(node) && !h.nextElementSibling(node)) - results.push(node); - return results; - }, - 'nth-child': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root); - }, - 'nth-last-child': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, true); - }, - 'nth-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, false, true); - }, - 'nth-last-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, formula, root, true, true); - }, - 'first-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, "1", root, false, true); - }, - 'last-of-type': function(nodes, formula, root) { - return Selector.pseudos.nth(nodes, "1", root, true, true); - }, - 'only-of-type': function(nodes, formula, root) { - var p = Selector.pseudos; - return p['last-of-type'](p['first-of-type'](nodes, formula, root), formula, root); - }, - - // handles the an+b logic - getIndices: function(a, b, total) { - if (a == 0) return b > 0 ? [b] : []; - return $R(1, total).inject([], function(memo, i) { - if (0 == (i - b) % a && (i - b) / a >= 0) memo.push(i); - return memo; - }); - }, - - // handles nth(-last)-child, nth(-last)-of-type, and (first|last)-of-type - nth: function(nodes, formula, root, reverse, ofType) { - if (nodes.length == 0) return []; - if (formula == 'even') formula = '2n+0'; - if (formula == 'odd') formula = '2n+1'; - var h = Selector.handlers, results = [], indexed = [], m; - h.mark(nodes); - for (var i = 0, node; node = nodes[i]; i++) { - if (!node.parentNode._counted) { - h.index(node.parentNode, reverse, ofType); - indexed.push(node.parentNode); - } - } - if (formula.match(/^\d+$/)) { // just a number - formula = Number(formula); - for (var i = 0, node; node = nodes[i]; i++) - if (node.nodeIndex == formula) results.push(node); - } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b - if (m[1] == "-") m[1] = -1; - var a = m[1] ? Number(m[1]) : 1; - var b = m[2] ? Number(m[2]) : 0; - var indices = Selector.pseudos.getIndices(a, b, nodes.length); - for (var i = 0, node, l = indices.length; node = nodes[i]; i++) { - for (var j = 0; j < l; j++) - if (node.nodeIndex == indices[j]) results.push(node); - } - } - h.unmark(nodes); - h.unmark(indexed); - return results; - }, - - 'empty': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) { - // IE treats comments as element nodes - if (node.tagName == '!' || (node.firstChild && !node.innerHTML.match(/^\s*$/))) continue; - results.push(node); - } - return results; - }, - - 'not': function(nodes, selector, root) { - var h = Selector.handlers, selectorType, m; - var exclusions = new Selector(selector).findElements(root); - h.mark(exclusions); - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!node._counted) results.push(node); - h.unmark(exclusions); - return results; - }, - - 'enabled': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (!node.disabled) results.push(node); - return results; - }, - - 'disabled': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (node.disabled) results.push(node); - return results; - }, - - 'checked': function(nodes, value, root) { - for (var i = 0, results = [], node; node = nodes[i]; i++) - if (node.checked) results.push(node); - return results; - } - }, - - operators: { - '=': function(nv, v) { return nv == v; }, - '!=': function(nv, v) { return nv != v; }, - '^=': function(nv, v) { return nv.startsWith(v); }, - '$=': function(nv, v) { return nv.endsWith(v); }, - '*=': function(nv, v) { return nv.include(v); }, - '~=': function(nv, v) { return (' ' + nv + ' ').include(' ' + v + ' '); }, - '|=': function(nv, v) { return ('-' + nv.toUpperCase() + '-').include('-' + v.toUpperCase() + '-'); } - }, - - matchElements: function(elements, expression) { - var matches = new Selector(expression).findElements(), h = Selector.handlers; - h.mark(matches); - for (var i = 0, results = [], element; element = elements[i]; i++) - if (element._counted) results.push(element); - h.unmark(matches); - return results; - }, - - findElement: function(elements, expression, index) { - if (typeof expression == 'number') { - index = expression; expression = false; - } - return Selector.matchElements(elements, expression || '*')[index || 0]; - }, - - findChildElements: function(element, expressions) { - var exprs = expressions.join(','), expressions = []; - exprs.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/, function(m) { - expressions.push(m[1].strip()); - }); - var results = [], h = Selector.handlers; - for (var i = 0, l = expressions.length, selector; i < l; i++) { - selector = new Selector(expressions[i].strip()); - h.concat(results, selector.findElements(element)); - } - return (l > 1) ? h.unique(results) : results; - } -}); - -function $$() { - return Selector.findChildElements(document, $A(arguments)); -} -var Form = { - reset: function(form) { - $(form).reset(); - return form; - }, - - serializeElements: function(elements, getHash) { - var data = elements.inject({}, function(result, element) { - if (!element.disabled && element.name) { - var key = element.name, value = $(element).getValue(); - if (value != null) { - if (key in result) { - if (result[key].constructor != Array) result[key] = [result[key]]; - result[key].push(value); - } - else result[key] = value; - } - } - return result; - }); - - return getHash ? data : Hash.toQueryString(data); - } -}; - -Form.Methods = { - serialize: function(form, getHash) { - return Form.serializeElements(Form.getElements(form), getHash); - }, - - getElements: function(form) { - return $A($(form).getElementsByTagName('*')).inject([], - function(elements, child) { - if (Form.Element.Serializers[child.tagName.toLowerCase()]) - elements.push(Element.extend(child)); - return elements; - } - ); - }, - - getInputs: function(form, typeName, name) { - form = $(form); - var inputs = form.getElementsByTagName('input'); - - if (!typeName && !name) return $A(inputs).map(Element.extend); - - for (var i = 0, matchingInputs = [], length = inputs.length; i < length; i++) { - var input = inputs[i]; - if ((typeName && input.type != typeName) || (name && input.name != name)) - continue; - matchingInputs.push(Element.extend(input)); - } - - return matchingInputs; - }, - - disable: function(form) { - form = $(form); - Form.getElements(form).invoke('disable'); - return form; - }, - - enable: function(form) { - form = $(form); - Form.getElements(form).invoke('enable'); - return form; - }, - - findFirstElement: function(form) { - return $(form).getElements().find(function(element) { - return element.type != 'hidden' && !element.disabled && - ['input', 'select', 'textarea'].include(element.tagName.toLowerCase()); - }); - }, - - focusFirstElement: function(form) { - form = $(form); - form.findFirstElement().activate(); - return form; - }, - - request: function(form, options) { - form = $(form), options = Object.clone(options || {}); - - var params = options.parameters; - options.parameters = form.serialize(true); - - if (params) { - if (typeof params == 'string') params = params.toQueryParams(); - Object.extend(options.parameters, params); - } - - if (form.hasAttribute('method') && !options.method) - options.method = form.method; - - return new Ajax.Request(form.readAttribute('action'), options); - } -} - -/*--------------------------------------------------------------------------*/ - -Form.Element = { - focus: function(element) { - $(element).focus(); - return element; - }, - - select: function(element) { - $(element).select(); - return element; - } -} - -Form.Element.Methods = { - serialize: function(element) { - element = $(element); - if (!element.disabled && element.name) { - var value = element.getValue(); - if (value != undefined) { - var pair = {}; - pair[element.name] = value; - return Hash.toQueryString(pair); - } - } - return ''; - }, - - getValue: function(element) { - element = $(element); - var method = element.tagName.toLowerCase(); - return Form.Element.Serializers[method](element); - }, - - clear: function(element) { - $(element).value = ''; - return element; - }, - - present: function(element) { - return $(element).value != ''; - }, - - activate: function(element) { - element = $(element); - try { - element.focus(); - if (element.select && (element.tagName.toLowerCase() != 'input' || - !['button', 'reset', 'submit'].include(element.type))) - element.select(); - } catch (e) {} - return element; - }, - - disable: function(element) { - element = $(element); - element.blur(); - element.disabled = true; - return element; - }, - - enable: function(element) { - element = $(element); - element.disabled = false; - return element; - } -} - -/*--------------------------------------------------------------------------*/ - -var Field = Form.Element; -var $F = Form.Element.Methods.getValue; - -/*--------------------------------------------------------------------------*/ - -Form.Element.Serializers = { - input: function(element) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - return Form.Element.Serializers.inputSelector(element); - default: - return Form.Element.Serializers.textarea(element); - } - }, - - inputSelector: function(element) { - return element.checked ? element.value : null; - }, - - textarea: function(element) { - return element.value; - }, - - select: function(element) { - return this[element.type == 'select-one' ? - 'selectOne' : 'selectMany'](element); - }, - - selectOne: function(element) { - var index = element.selectedIndex; - return index >= 0 ? this.optionValue(element.options[index]) : null; - }, - - selectMany: function(element) { - var values, length = element.length; - if (!length) return null; - - for (var i = 0, values = []; i < length; i++) { - var opt = element.options[i]; - if (opt.selected) values.push(this.optionValue(opt)); - } - return values; - }, - - optionValue: function(opt) { - // extend element because hasAttribute may not be native - return Element.extend(opt).hasAttribute('value') ? opt.value : opt.text; - } -} - -/*--------------------------------------------------------------------------*/ - -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() { - setInterval(this.onTimerEvent.bind(this), this.frequency * 1000); - }, - - onTimerEvent: function() { - var value = this.getValue(); - var changed = ('string' == typeof this.lastValue && 'string' == typeof value - ? this.lastValue != value : String(this.lastValue) != String(value)); - if (changed) { - this.callback(this.element, value); - this.lastValue = value; - } - } -} - -Form.Element.Observer = Class.create(); -Form.Element.Observer.prototype = Object.extend(new Abstract.TimedObserver(), { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.Observer = Class.create(); -Form.Observer.prototype = Object.extend(new Abstract.TimedObserver(), { - getValue: function() { - return Form.serialize(this.element); - } -}); - -/*--------------------------------------------------------------------------*/ - -Abstract.EventObserver = function() {} -Abstract.EventObserver.prototype = { - initialize: function(element, callback) { - this.element = $(element); - this.callback = callback; - - this.lastValue = this.getValue(); - if (this.element.tagName.toLowerCase() == 'form') - this.registerFormCallbacks(); - else - this.registerCallback(this.element); - }, - - onElementEvent: function() { - var value = this.getValue(); - if (this.lastValue != value) { - this.callback(this.element, value); - this.lastValue = value; - } - }, - - registerFormCallbacks: function() { - Form.getElements(this.element).each(this.registerCallback.bind(this)); - }, - - registerCallback: function(element) { - if (element.type) { - switch (element.type.toLowerCase()) { - case 'checkbox': - case 'radio': - Event.observe(element, 'click', this.onElementEvent.bind(this)); - break; - default: - Event.observe(element, 'change', this.onElementEvent.bind(this)); - break; - } - } - } -} - -Form.Element.EventObserver = Class.create(); -Form.Element.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), { - getValue: function() { - return Form.Element.getValue(this.element); - } -}); - -Form.EventObserver = Class.create(); -Form.EventObserver.prototype = Object.extend(new Abstract.EventObserver(), { - getValue: function() { - return Form.serialize(this.element); - } -}); -if (!window.Event) { - var Event = new Object(); -} - -Object.extend(Event, { - KEY_BACKSPACE: 8, - KEY_TAB: 9, - KEY_RETURN: 13, - KEY_ESC: 27, - KEY_LEFT: 37, - KEY_UP: 38, - KEY_RIGHT: 39, - KEY_DOWN: 40, - KEY_DELETE: 46, - KEY_HOME: 36, - KEY_END: 35, - KEY_PAGEUP: 33, - KEY_PAGEDOWN: 34, - - element: function(event) { - return $(event.target || event.srcElement); - }, - - isLeftClick: function(event) { - return (((event.which) && (event.which == 1)) || - ((event.button) && (event.button == 1))); - }, - - pointerX: function(event) { - return event.pageX || (event.clientX + - (document.documentElement.scrollLeft || document.body.scrollLeft)); - }, - - pointerY: function(event) { - return event.pageY || (event.clientY + - (document.documentElement.scrollTop || document.body.scrollTop)); - }, - - stop: function(event) { - if (event.preventDefault) { - event.preventDefault(); - event.stopPropagation(); - } else { - event.returnValue = false; - event.cancelBubble = true; - } - }, - - // find the first node with the given tagName, starting from the - // node the event was triggered on; traverses the DOM upwards - findElement: function(event, tagName) { - var element = Event.element(event); - while (element.parentNode && (!element.tagName || - (element.tagName.toUpperCase() != tagName.toUpperCase()))) - element = element.parentNode; - return element; - }, - - observers: false, - - _observeAndCache: function(element, name, observer, useCapture) { - if (!this.observers) this.observers = []; - if (element.addEventListener) { - this.observers.push([element, name, observer, useCapture]); - element.addEventListener(name, observer, useCapture); - } else if (element.attachEvent) { - this.observers.push([element, name, observer, useCapture]); - element.attachEvent('on' + name, observer); - } - }, - - unloadCache: function() { - if (!Event.observers) return; - for (var i = 0, length = Event.observers.length; i < length; i++) { - Event.stopObserving.apply(this, Event.observers[i]); - Event.observers[i][0] = null; - } - Event.observers = false; - }, - - observe: function(element, name, observer, useCapture) { - element = $(element); - useCapture = useCapture || false; - - if (name == 'keypress' && - (Prototype.Browser.WebKit || element.attachEvent)) - name = 'keydown'; - - Event._observeAndCache(element, name, observer, useCapture); - }, - - stopObserving: function(element, name, observer, useCapture) { - element = $(element); - useCapture = useCapture || false; - - if (name == 'keypress' && - (Prototype.Browser.WebKit || element.attachEvent)) - name = 'keydown'; - - if (element.removeEventListener) { - element.removeEventListener(name, observer, useCapture); - } else if (element.detachEvent) { - try { - element.detachEvent('on' + name, observer); - } catch (e) {} - } - } -}); - -/* prevent memory leaks in IE */ -if (Prototype.Browser.IE) - Event.observe(window, 'unload', Event.unloadCache, false); -var Position = { - // set to true if needed, warning: firefox performance problems - // NOT neeeded for page scrolling, only if draggable contained in - // scrollable elements - includeScrollOffsets: false, - - // must be called before calling withinIncludingScrolloffset, every time the - // page is scrolled - prepare: function() { - this.deltaX = window.pageXOffset - || document.documentElement.scrollLeft - || document.body.scrollLeft - || 0; - this.deltaY = window.pageYOffset - || document.documentElement.scrollTop - || document.body.scrollTop - || 0; - }, - - realOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.scrollTop || 0; - valueL += element.scrollLeft || 0; - element = element.parentNode; - } while (element); - return [valueL, valueT]; - }, - - cumulativeOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - } while (element); - return [valueL, valueT]; - }, - - positionedOffset: function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - element = element.offsetParent; - if (element) { - if(element.tagName=='BODY') break; - var p = Element.getStyle(element, 'position'); - if (p == 'relative' || p == 'absolute') break; - } - } while (element); - return [valueL, valueT]; - }, - - offsetParent: function(element) { - if (element.offsetParent) return element.offsetParent; - if (element == document.body) return element; - - while ((element = element.parentNode) && element != document.body) - if (Element.getStyle(element, 'position') != 'static') - return element; - - return document.body; - }, - - // caches x/y coordinate pair to use with overlap - within: function(element, x, y) { - if (this.includeScrollOffsets) - return this.withinIncludingScrolloffsets(element, x, y); - this.xcomp = x; - this.ycomp = y; - this.offset = this.cumulativeOffset(element); - - return (y >= this.offset[1] && - y < this.offset[1] + element.offsetHeight && - x >= this.offset[0] && - x < this.offset[0] + element.offsetWidth); - }, - - withinIncludingScrolloffsets: function(element, x, y) { - var offsetcache = this.realOffset(element); - - this.xcomp = x + offsetcache[0] - this.deltaX; - this.ycomp = y + offsetcache[1] - this.deltaY; - this.offset = this.cumulativeOffset(element); - - return (this.ycomp >= this.offset[1] && - this.ycomp < this.offset[1] + element.offsetHeight && - this.xcomp >= this.offset[0] && - this.xcomp < this.offset[0] + element.offsetWidth); - }, - - // within must be called directly before - overlap: function(mode, element) { - if (!mode) return 0; - if (mode == 'vertical') - return ((this.offset[1] + element.offsetHeight) - this.ycomp) / - element.offsetHeight; - if (mode == 'horizontal') - return ((this.offset[0] + element.offsetWidth) - this.xcomp) / - element.offsetWidth; - }, - - page: function(forElement) { - var valueT = 0, valueL = 0; - - var element = forElement; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - - // Safari fix - if (element.offsetParent == document.body) - if (Element.getStyle(element,'position')=='absolute') break; - - } while (element = element.offsetParent); - - element = forElement; - do { - if (!window.opera || element.tagName=='BODY') { - valueT -= element.scrollTop || 0; - valueL -= element.scrollLeft || 0; - } - } while (element = element.parentNode); - - return [valueL, valueT]; - }, - - clone: function(source, target) { - var options = Object.extend({ - setLeft: true, - setTop: true, - setWidth: true, - setHeight: true, - offsetTop: 0, - offsetLeft: 0 - }, arguments[2] || {}) - - // find page position of source - source = $(source); - var p = Position.page(source); - - // find coordinate system to use - target = $(target); - var delta = [0, 0]; - var parent = null; - // delta [0,0] will do fine with position: fixed elements, - // position:absolute needs offsetParent deltas - if (Element.getStyle(target,'position') == 'absolute') { - parent = Position.offsetParent(target); - delta = Position.page(parent); - } - - // correct by body offsets (fixes Safari) - if (parent == document.body) { - delta[0] -= document.body.offsetLeft; - delta[1] -= document.body.offsetTop; - } - - // set position - if(options.setLeft) target.style.left = (p[0] - delta[0] + options.offsetLeft) + 'px'; - if(options.setTop) target.style.top = (p[1] - delta[1] + options.offsetTop) + 'px'; - if(options.setWidth) target.style.width = source.offsetWidth + 'px'; - if(options.setHeight) target.style.height = source.offsetHeight + 'px'; - }, - - absolutize: function(element) { - element = $(element); - if (element.style.position == 'absolute') return; - Position.prepare(); - - var offsets = Position.positionedOffset(element); - var top = offsets[1]; - var left = offsets[0]; - var width = element.clientWidth; - var height = element.clientHeight; - - element._originalLeft = left - parseFloat(element.style.left || 0); - element._originalTop = top - parseFloat(element.style.top || 0); - element._originalWidth = element.style.width; - element._originalHeight = element.style.height; - - element.style.position = 'absolute'; - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.width = width + 'px'; - element.style.height = height + 'px'; - }, - - relativize: function(element) { - element = $(element); - if (element.style.position == 'relative') return; - Position.prepare(); - - element.style.position = 'relative'; - var top = parseFloat(element.style.top || 0) - (element._originalTop || 0); - var left = parseFloat(element.style.left || 0) - (element._originalLeft || 0); - - element.style.top = top + 'px'; - element.style.left = left + 'px'; - element.style.height = element._originalHeight; - element.style.width = element._originalWidth; - } -} - -// Safari returns margins on body which is incorrect if the child is absolutely -// positioned. For performance reasons, redefine Position.cumulativeOffset for -// KHTML/WebKit only. -if (Prototype.Browser.WebKit) { - Position.cumulativeOffset = function(element) { - var valueT = 0, valueL = 0; - do { - valueT += element.offsetTop || 0; - valueL += element.offsetLeft || 0; - if (element.offsetParent == document.body) - if (Element.getStyle(element, 'position') == 'absolute') break; - - element = element.offsetParent; - } while (element); - - return [valueL, valueT]; - } -} - -Element.addMethods();
\ No newline at end of file diff --git a/javascript/libs/rico.js b/javascript/libs/rico.js deleted file mode 100644 index 65bcb48..0000000 --- a/javascript/libs/rico.js +++ /dev/null @@ -1,2818 +0,0 @@ -/** - * - * 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. - **/ - - -//-------------------- rico.js -var Rico = { - Version: '1.1.2', - prototypeVersion: parseFloat(Prototype.Version.split(".")[0] + "." + Prototype.Version.split(".")[1]) -} - -if((typeof Prototype=='undefined') || Rico.prototypeVersion < 1.3) - throw("Rico requires the Prototype JavaScript framework >= 1.3"); - -Rico.ArrayExtensions = new Array(); - -if (Object.prototype.extend) { - Rico.ArrayExtensions[ Rico.ArrayExtensions.length ] = Object.prototype.extend; -}else{ - Object.prototype.extend = function(object) { - return Object.extend.apply(this, [this, object]); - } - Rico.ArrayExtensions[ Rico.ArrayExtensions.length ] = Object.prototype.extend; -} - -if (Array.prototype.push) { - Rico.ArrayExtensions[ Rico.ArrayExtensions.length ] = Array.prototype.push; -} - -if (!Array.prototype.remove) { - Array.prototype.remove = function(dx) { - if( isNaN(dx) || dx > this.length ) - return false; - for( var i=0,n=0; i<this.length; i++ ) - if( i != dx ) - this[n++]=this[i]; - this.length-=1; - }; - Rico.ArrayExtensions[ Rico.ArrayExtensions.length ] = Array.prototype.remove; -} - -if (!Array.prototype.removeItem) { - Array.prototype.removeItem = function(item) { - for ( var i = 0 ; i < this.length ; i++ ) - if ( this[i] == item ) { - this.remove(i); - break; - } - }; - Rico.ArrayExtensions[ Rico.ArrayExtensions.length ] = Array.prototype.removeItem; -} - -if (!Array.prototype.indices) { - Array.prototype.indices = function() { - var indexArray = new Array(); - for ( index in this ) { - var ignoreThis = false; - for ( var i = 0 ; i < Rico.ArrayExtensions.length ; i++ ) { - if ( this[index] == Rico.ArrayExtensions[i] ) { - ignoreThis = true; - break; - } - } - if ( !ignoreThis ) - indexArray[ indexArray.length ] = index; - } - return indexArray; - } - Rico.ArrayExtensions[ Rico.ArrayExtensions.length ] = Array.prototype.indices; -} - -// Create the loadXML method and xml getter for Mozilla -if ( window.DOMParser && - window.XMLSerializer && - window.Node && Node.prototype && Node.prototype.__defineGetter__ ) { - - if (!Document.prototype.loadXML) { - Document.prototype.loadXML = function (s) { - var doc2 = (new DOMParser()).parseFromString(s, "text/xml"); - while (this.hasChildNodes()) - this.removeChild(this.lastChild); - - for (var i = 0; i < doc2.childNodes.length; i++) { - this.appendChild(this.importNode(doc2.childNodes[i], true)); - } - }; - } - - Document.prototype.__defineGetter__( "xml", - function () { - return (new XMLSerializer()).serializeToString(this); - } - ); -} - -document.getElementsByTagAndClassName = function(tagName, className) { - if ( tagName == null ) - tagName = '*'; - - var children = document.getElementsByTagName(tagName) || document.all; - var elements = new Array(); - - if ( className == null ) - return children; - - 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; -} - - -//-------------------- ricoAccordion.js -Rico.Accordion = Class.create(); - -Rico.Accordion.prototype = { - - initialize: function(container, options) { - this.container = $(container); - this.lastExpandedTab = null; - this.accordionTabs = new Array(); - this.setOptions(options); - this._attachBehaviors(); - if(!container) return; - - this.container.style.borderBottom = '1px solid ' + this.options.borderColor; - // validate onloadShowTab - if (this.options.onLoadShowTab >= this.accordionTabs.length) - this.options.onLoadShowTab = 0; - - // set the initial visual state... - for ( var i=0 ; i < this.accordionTabs.length ; i++ ) - { - if (i != this.options.onLoadShowTab){ - this.accordionTabs[i].collapse(); - this.accordionTabs[i].content.style.display = 'none'; - } - } - this.lastExpandedTab = this.accordionTabs[this.options.onLoadShowTab]; - if (this.options.panelHeight == 'auto'){ - var tabToCheck = (this.options.onloadShowTab === 0)? 1 : 0; - var titleBarSize = parseInt(RicoUtil.getElementsComputedStyle(this.accordionTabs[tabToCheck].titleBar, 'height')); - if (isNaN(titleBarSize)) - titleBarSize = this.accordionTabs[tabToCheck].titleBar.offsetHeight; - - var totalTitleBarSize = this.accordionTabs.length * titleBarSize; - var parentHeight = parseInt(RicoUtil.getElementsComputedStyle(this.container.parentNode, 'height')); - if (isNaN(parentHeight)) - parentHeight = this.container.parentNode.offsetHeight; - - this.options.panelHeight = parentHeight - totalTitleBarSize-2; - } - - this.lastExpandedTab.content.style.height = this.options.panelHeight + "px"; - this.lastExpandedTab.showExpanded(); - this.lastExpandedTab.titleBar.style.fontWeight = this.options.expandedFontWeight; - - }, - - setOptions: function(options) { - this.options = { - expandedBg : '#63699c', - hoverBg : '#63699c', - collapsedBg : '#6b79a5', - expandedTextColor : '#ffffff', - expandedFontWeight : 'bold', - hoverTextColor : '#ffffff', - collapsedTextColor : '#ced7ef', - collapsedFontWeight : 'normal', - hoverTextColor : '#ffffff', - borderColor : '#1f669b', - panelHeight : 200, - onHideTab : null, - onShowTab : null, - onLoadShowTab : 0 - } - Object.extend(this.options, options || {}); - }, - - showTabByIndex: function( anIndex, animate ) { - var doAnimate = arguments.length == 1 ? true : animate; - this.showTab( this.accordionTabs[anIndex], doAnimate ); - }, - - showTab: function( accordionTab, animate ) { - if ( this.lastExpandedTab == accordionTab ) - return; - - var doAnimate = arguments.length == 1 ? true : animate; - - if ( this.options.onHideTab ) - this.options.onHideTab(this.lastExpandedTab); - - this.lastExpandedTab.showCollapsed(); - var accordion = this; - var lastExpandedTab = this.lastExpandedTab; - - this.lastExpandedTab.content.style.height = (this.options.panelHeight - 1) + 'px'; - accordionTab.content.style.display = ''; - - accordionTab.titleBar.style.fontWeight = this.options.expandedFontWeight; - - if ( doAnimate ) { - new Rico.Effect.AccordionSize( this.lastExpandedTab.content, - accordionTab.content, - 1, - this.options.panelHeight, - 100, 10, - { complete: function() {accordion.showTabDone(lastExpandedTab)} } ); - this.lastExpandedTab = accordionTab; - } - else { - this.lastExpandedTab.content.style.height = "1px"; - accordionTab.content.style.height = this.options.panelHeight + "px"; - this.lastExpandedTab = accordionTab; - this.showTabDone(lastExpandedTab); - } - }, - - showTabDone: function(collapsedTab) { - collapsedTab.content.style.display = 'none'; - this.lastExpandedTab.showExpanded(); - if ( this.options.onShowTab ) - this.options.onShowTab(this.lastExpandedTab); - }, - - _attachBehaviors: function() { - var panels = this._getDirectChildrenByTag(this.container, 'DIV'); - for ( var i = 0 ; i < panels.length ; i++ ) { - - var tabChildren = this._getDirectChildrenByTag(panels[i],'DIV'); - if ( tabChildren.length != 2 ) - continue; // unexpected - - var tabTitleBar = tabChildren[0]; - var tabContentBox = tabChildren[1]; - this.accordionTabs.push( new Rico.Accordion.Tab(this,tabTitleBar,tabContentBox) ); - } - }, - - _getDirectChildrenByTag: function(e, tagName) { - var kids = new Array(); - var allKids = e.childNodes; - for( var i = 0 ; i < allKids.length ; i++ ) - if ( allKids[i] && allKids[i].tagName && allKids[i].tagName == tagName ) - kids.push(allKids[i]); - return kids; - } - -}; - -Rico.Accordion.Tab = Class.create(); - -Rico.Accordion.Tab.prototype = { - - initialize: function(accordion, titleBar, content) { - this.accordion = accordion; - this.titleBar = titleBar; - this.content = content; - this._attachBehaviors(); - }, - - collapse: function() { - this.showCollapsed(); - this.content.style.height = "1px"; - }, - - showCollapsed: function() { - this.expanded = false; - this.titleBar.style.backgroundColor = this.accordion.options.collapsedBg; - this.titleBar.style.color = this.accordion.options.collapsedTextColor; - this.titleBar.style.fontWeight = this.accordion.options.collapsedFontWeight; - this.content.style.overflow = "hidden"; - }, - - showExpanded: function() { - this.expanded = true; - this.titleBar.style.backgroundColor = this.accordion.options.expandedBg; - this.titleBar.style.color = this.accordion.options.expandedTextColor; - this.content.style.overflow = "auto"; - }, - - titleBarClicked: function(e) { - if ( this.accordion.lastExpandedTab == this ) - return; - this.accordion.showTab(this); - }, - - hover: function(e) { - this.titleBar.style.backgroundColor = this.accordion.options.hoverBg; - this.titleBar.style.color = this.accordion.options.hoverTextColor; - }, - - unhover: function(e) { - if ( this.expanded ) { - this.titleBar.style.backgroundColor = this.accordion.options.expandedBg; - this.titleBar.style.color = this.accordion.options.expandedTextColor; - } - else { - this.titleBar.style.backgroundColor = this.accordion.options.collapsedBg; - this.titleBar.style.color = this.accordion.options.collapsedTextColor; - } - }, - - _attachBehaviors: function() { - this.content.style.border = "1px solid " + this.accordion.options.borderColor; - this.content.style.borderTopWidth = "0px"; - this.content.style.borderBottomWidth = "0px"; - this.content.style.margin = "0px"; - - this.titleBar.onclick = this.titleBarClicked.bindAsEventListener(this); - this.titleBar.onmouseover = this.hover.bindAsEventListener(this); - this.titleBar.onmouseout = this.unhover.bindAsEventListener(this); - } - -}; - - -//-------------------- ricoAjaxEngine.js -Rico.AjaxEngine = Class.create(); - -Rico.AjaxEngine.prototype = { - - initialize: function() { - this.ajaxElements = new Array(); - this.ajaxObjects = new Array(); - this.requestURLS = new Array(); - this.options = {}; - }, - - registerAjaxElement: function( anId, anElement ) { - if ( !anElement ) - anElement = $(anId); - this.ajaxElements[anId] = anElement; - }, - - registerAjaxObject: function( anId, anObject ) { - this.ajaxObjects[anId] = anObject; - }, - - registerRequest: function (requestLogicalName, requestURL) { - this.requestURLS[requestLogicalName] = requestURL; - }, - - sendRequest: function(requestName, options) { - // Allow for backwards Compatibility - if ( arguments.length >= 2 ) - if (typeof arguments[1] == 'string') - options = {parameters: this._createQueryString(arguments, 1)}; - this.sendRequestWithData(requestName, null, options); - }, - - sendRequestWithData: function(requestName, xmlDocument, options) { - var requestURL = this.requestURLS[requestName]; - if ( requestURL == null ) - return; - - // Allow for backwards Compatibility - if ( arguments.length >= 3 ) - if (typeof arguments[2] == 'string') - options.parameters = this._createQueryString(arguments, 2); - - new Ajax.Request(requestURL, this._requestOptions(options,xmlDocument)); - }, - - sendRequestAndUpdate: function(requestName,container,options) { - // Allow for backwards Compatibility - if ( arguments.length >= 3 ) - if (typeof arguments[2] == 'string') - options.parameters = this._createQueryString(arguments, 2); - - this.sendRequestWithDataAndUpdate(requestName, null, container, options); - }, - - sendRequestWithDataAndUpdate: function(requestName,xmlDocument,container,options) { - var requestURL = this.requestURLS[requestName]; - if ( requestURL == null ) - return; - - // Allow for backwards Compatibility - if ( arguments.length >= 4 ) - if (typeof arguments[3] == 'string') - options.parameters = this._createQueryString(arguments, 3); - - var updaterOptions = this._requestOptions(options,xmlDocument); - - new Ajax.Updater(container, requestURL, updaterOptions); - }, - - // Private -- not part of intended engine API -------------------------------------------------------------------- - - _requestOptions: function(options,xmlDoc) { - var requestHeaders = ['X-Rico-Version', Rico.Version ]; - var sendMethod = 'post'; - if ( xmlDoc == null ) - if (Rico.prototypeVersion < 1.4) - requestHeaders.push( 'Content-type', 'text/xml' ); - else - sendMethod = 'get'; - (!options) ? options = {} : ''; - - if (!options._RicoOptionsProcessed){ - // Check and keep any user onComplete functions - if (options.onComplete) - options.onRicoComplete = options.onComplete; - // Fix onComplete - if (options.overrideOnComplete) - options.onComplete = options.overrideOnComplete; - else - options.onComplete = this._onRequestComplete.bind(this); - options._RicoOptionsProcessed = true; - } - - // Set the default options and extend with any user options - this.options = { - requestHeaders: requestHeaders, - parameters: options.parameters, - postBody: xmlDoc, - method: sendMethod, - onComplete: options.onComplete - }; - // Set any user options: - Object.extend(this.options, options); - return this.options; - }, - - _createQueryString: function( theArgs, offset ) { - var queryString = "" - for ( var i = offset ; i < theArgs.length ; i++ ) { - if ( i != offset ) - queryString += "&"; - - var anArg = theArgs[i]; - - if ( anArg.name != undefined && anArg.value != undefined ) { - queryString += anArg.name + "=" + escape(anArg.value); - } - else { - var ePos = anArg.indexOf('='); - var argName = anArg.substring( 0, ePos ); - var argValue = anArg.substring( ePos + 1 ); - queryString += argName + "=" + escape(argValue); - } - } - return queryString; - }, - - _onRequestComplete : function(request) { - if(!request) - return; - // User can set an onFailure option - which will be called by prototype - if (request.status != 200) - return; - - var response = request.responseXML.getElementsByTagName("ajax-response"); - if (response == null || response.length != 1) - return; - this._processAjaxResponse( response[0].childNodes ); - - // Check if user has set a onComplete function - var onRicoComplete = this.options.onRicoComplete; - if (onRicoComplete != null) - onRicoComplete(); - }, - - _processAjaxResponse: function( xmlResponseElements ) { - for ( var i = 0 ; i < xmlResponseElements.length ; i++ ) { - var responseElement = xmlResponseElements[i]; - - // only process nodes of type element..... - if ( responseElement.nodeType != 1 ) - continue; - - var responseType = responseElement.getAttribute("type"); - var responseId = responseElement.getAttribute("id"); - - if ( responseType == "object" ) - this._processAjaxObjectUpdate( this.ajaxObjects[ responseId ], responseElement ); - else if ( responseType == "element" ) - this._processAjaxElementUpdate( this.ajaxElements[ responseId ], responseElement ); - else - alert('unrecognized AjaxResponse type : ' + responseType ); - } - }, - - _processAjaxObjectUpdate: function( ajaxObject, responseElement ) { - ajaxObject.ajaxUpdate( responseElement ); - }, - - _processAjaxElementUpdate: function( ajaxElement, responseElement ) { - ajaxElement.innerHTML = RicoUtil.getContentAsString(responseElement); - } - -} - -var ajaxEngine = new Rico.AjaxEngine(); - - -//-------------------- ricoColor.js -Rico.Color = Class.create(); - -Rico.Color.prototype = { - - initialize: function(red, green, blue) { - this.rgb = { r: red, g : green, b : blue }; - }, - - setRed: function(r) { - this.rgb.r = r; - }, - - setGreen: function(g) { - this.rgb.g = g; - }, - - setBlue: function(b) { - this.rgb.b = b; - }, - - setHue: function(h) { - - // get an HSB model, and set the new hue... - var hsb = this.asHSB(); - hsb.h = h; - - // convert back to RGB... - this.rgb = Rico.Color.HSBtoRGB(hsb.h, hsb.s, hsb.b); - }, - - setSaturation: function(s) { - // get an HSB model, and set the new hue... - var hsb = this.asHSB(); - hsb.s = s; - - // convert back to RGB and set values... - this.rgb = Rico.Color.HSBtoRGB(hsb.h, hsb.s, hsb.b); - }, - - setBrightness: function(b) { - // get an HSB model, and set the new hue... - var hsb = this.asHSB(); - hsb.b = b; - - // convert back to RGB and set values... - this.rgb = Rico.Color.HSBtoRGB( hsb.h, hsb.s, hsb.b ); - }, - - darken: function(percent) { - var hsb = this.asHSB(); - this.rgb = Rico.Color.HSBtoRGB(hsb.h, hsb.s, Math.max(hsb.b - percent,0)); - }, - - brighten: function(percent) { - var hsb = this.asHSB(); - this.rgb = Rico.Color.HSBtoRGB(hsb.h, hsb.s, Math.min(hsb.b + percent,1)); - }, - - blend: function(other) { - this.rgb.r = Math.floor((this.rgb.r + other.rgb.r)/2); - this.rgb.g = Math.floor((this.rgb.g + other.rgb.g)/2); - this.rgb.b = Math.floor((this.rgb.b + other.rgb.b)/2); - }, - - isBright: function() { - var hsb = this.asHSB(); - return this.asHSB().b > 0.5; - }, - - isDark: function() { - return ! this.isBright(); - }, - - asRGB: function() { - return "rgb(" + this.rgb.r + "," + this.rgb.g + "," + this.rgb.b + ")"; - }, - - asHex: function() { - return "#" + this.rgb.r.toColorPart() + this.rgb.g.toColorPart() + this.rgb.b.toColorPart(); - }, - - asHSB: function() { - return Rico.Color.RGBtoHSB(this.rgb.r, this.rgb.g, this.rgb.b); - }, - - toString: function() { - return this.asHex(); - } - -}; - -Rico.Color.createFromHex = function(hexCode) { - if(hexCode.length==4) { - var shortHexCode = hexCode; - var hexCode = '#'; - for(var i=1;i<4;i++) hexCode += (shortHexCode.charAt(i) + -shortHexCode.charAt(i)); - } - if ( hexCode.indexOf('#') == 0 ) - hexCode = hexCode.substring(1); - var red = hexCode.substring(0,2); - var green = hexCode.substring(2,4); - var blue = hexCode.substring(4,6); - return new Rico.Color( parseInt(red,16), parseInt(green,16), parseInt(blue,16) ); -} - -/** - * Factory method for creating a color from the background of - * an HTML element. - */ -Rico.Color.createColorFromBackground = function(elem) { - - var actualColor = RicoUtil.getElementsComputedStyle($(elem), "backgroundColor", "background-color"); - - if ( actualColor == "transparent" && elem.parentNode ) - return Rico.Color.createColorFromBackground(elem.parentNode); - - if ( actualColor == null ) - return new Rico.Color(255,255,255); - - if ( actualColor.indexOf("rgb(") == 0 ) { - var colors = actualColor.substring(4, actualColor.length - 1 ); - var colorArray = colors.split(","); - return new Rico.Color( parseInt( colorArray[0] ), - parseInt( colorArray[1] ), - parseInt( colorArray[2] ) ); - - } - else if ( actualColor.indexOf("#") == 0 ) { - return Rico.Color.createFromHex(actualColor); - } - else - return new Rico.Color(255,255,255); -} - -Rico.Color.HSBtoRGB = function(hue, saturation, brightness) { - - var red = 0; - var green = 0; - var blue = 0; - - if (saturation == 0) { - red = parseInt(brightness * 255.0 + 0.5); - green = red; - blue = red; - } - else { - var h = (hue - Math.floor(hue)) * 6.0; - var f = h - Math.floor(h); - var p = brightness * (1.0 - saturation); - var q = brightness * (1.0 - saturation * f); - var t = brightness * (1.0 - (saturation * (1.0 - f))); - - switch (parseInt(h)) { - case 0: - red = (brightness * 255.0 + 0.5); - green = (t * 255.0 + 0.5); - blue = (p * 255.0 + 0.5); - break; - case 1: - red = (q * 255.0 + 0.5); - green = (brightness * 255.0 + 0.5); - blue = (p * 255.0 + 0.5); - break; - case 2: - red = (p * 255.0 + 0.5); - green = (brightness * 255.0 + 0.5); - blue = (t * 255.0 + 0.5); - break; - case 3: - red = (p * 255.0 + 0.5); - green = (q * 255.0 + 0.5); - blue = (brightness * 255.0 + 0.5); - break; - case 4: - red = (t * 255.0 + 0.5); - green = (p * 255.0 + 0.5); - blue = (brightness * 255.0 + 0.5); - break; - case 5: - red = (brightness * 255.0 + 0.5); - green = (p * 255.0 + 0.5); - blue = (q * 255.0 + 0.5); - break; - } - } - - return { r : parseInt(red), g : parseInt(green) , b : parseInt(blue) }; -} - -Rico.Color.RGBtoHSB = function(r, g, b) { - - var hue; - var saturation; - var brightness; - - var cmax = (r > g) ? r : g; - if (b > cmax) - cmax = b; - - var cmin = (r < g) ? r : g; - if (b < cmin) - cmin = b; - - brightness = cmax / 255.0; - if (cmax != 0) - saturation = (cmax - cmin)/cmax; - else - saturation = 0; - - if (saturation == 0) - hue = 0; - else { - var redc = (cmax - r)/(cmax - cmin); - var greenc = (cmax - g)/(cmax - cmin); - var bluec = (cmax - b)/(cmax - cmin); - - if (r == cmax) - hue = bluec - greenc; - else if (g == cmax) - hue = 2.0 + redc - bluec; - else - hue = 4.0 + greenc - redc; - - hue = hue / 6.0; - if (hue < 0) - hue = hue + 1.0; - } - - return { h : hue, s : saturation, b : brightness }; -} - - -//-------------------- ricoCorner.js -Rico.Corner = { - - round: function(e, options) { - var e = $(e); - this._setOptions(options); - - var color = this.options.color; - if ( this.options.color == "fromElement" ) - color = this._background(e); - - var bgColor = this.options.bgColor; - if ( this.options.bgColor == "fromParent" ) - bgColor = this._background(e.offsetParent); - - this._roundCornersImpl(e, color, bgColor); - }, - - _roundCornersImpl: function(e, color, bgColor) { - if(this.options.border) - this._renderBorder(e,bgColor); - if(this._isTopRounded()) - this._roundTopCorners(e,color,bgColor); - if(this._isBottomRounded()) - this._roundBottomCorners(e,color,bgColor); - }, - - _renderBorder: function(el,bgColor) { - var borderValue = "1px solid " + this._borderColor(bgColor); - var borderL = "border-left: " + borderValue; - var borderR = "border-right: " + borderValue; - var style = "style='" + borderL + ";" + borderR + "'"; - el.innerHTML = "<div " + style + ">" + el.innerHTML + "</div>" - }, - - _roundTopCorners: function(el, color, bgColor) { - var corner = this._createCorner(bgColor); - for(var i=0 ; i < this.options.numSlices ; i++ ) - corner.appendChild(this._createCornerSlice(color,bgColor,i,"top")); - el.style.paddingTop = 0; - el.insertBefore(corner,el.firstChild); - }, - - _roundBottomCorners: function(el, color, bgColor) { - var corner = this._createCorner(bgColor); - for(var i=(this.options.numSlices-1) ; i >= 0 ; i-- ) - corner.appendChild(this._createCornerSlice(color,bgColor,i,"bottom")); - el.style.paddingBottom = 0; - el.appendChild(corner); - }, - - _createCorner: function(bgColor) { - var corner = document.createElement("div"); - corner.style.backgroundColor = (this._isTransparent() ? "transparent" : bgColor); - return corner; - }, - - _createCornerSlice: function(color,bgColor, n, position) { - var slice = document.createElement("span"); - - var inStyle = slice.style; - inStyle.backgroundColor = color; - inStyle.display = "block"; - inStyle.height = "1px"; - inStyle.overflow = "hidden"; - inStyle.fontSize = "1px"; - - var borderColor = this._borderColor(color,bgColor); - if ( this.options.border && n == 0 ) { - inStyle.borderTopStyle = "solid"; - inStyle.borderTopWidth = "1px"; - inStyle.borderLeftWidth = "0px"; - inStyle.borderRightWidth = "0px"; - inStyle.borderBottomWidth = "0px"; - inStyle.height = "0px"; // assumes css compliant box model - inStyle.borderColor = borderColor; - } - else if(borderColor) { - inStyle.borderColor = borderColor; - inStyle.borderStyle = "solid"; - inStyle.borderWidth = "0px 1px"; - } - - if ( !this.options.compact && (n == (this.options.numSlices-1)) ) - inStyle.height = "2px"; - - this._setMargin(slice, n, position); - this._setBorder(slice, n, position); - return slice; - }, - - _setOptions: function(options) { - this.options = { - corners : "all", - color : "fromElement", - bgColor : "fromParent", - blend : true, - border : false, - compact : false - } - Object.extend(this.options, options || {}); - - this.options.numSlices = this.options.compact ? 2 : 4; - if ( this._isTransparent() ) - this.options.blend = false; - }, - - _whichSideTop: function() { - if ( this._hasString(this.options.corners, "all", "top") ) - return ""; - - if ( this.options.corners.indexOf("tl") >= 0 && this.options.corners.indexOf("tr") >= 0 ) - return ""; - - if (this.options.corners.indexOf("tl") >= 0) - return "left"; - else if (this.options.corners.indexOf("tr") >= 0) - return "right"; - return ""; - }, - - _whichSideBottom: function() { - if ( this._hasString(this.options.corners, "all", "bottom") ) - return ""; - - if ( this.options.corners.indexOf("bl")>=0 && this.options.corners.indexOf("br")>=0 ) - return ""; - - if(this.options.corners.indexOf("bl") >=0) - return "left"; - else if(this.options.corners.indexOf("br")>=0) - return "right"; - return ""; - }, - - _borderColor : function(color,bgColor) { - if ( color == "transparent" ) - return bgColor; - else if ( this.options.border ) - return this.options.border; - else if ( this.options.blend ) - return this._blend( bgColor, color ); - else - return ""; - }, - - - _setMargin: function(el, n, corners) { - var marginSize = this._marginSize(n); - var whichSide = corners == "top" ? this._whichSideTop() : this._whichSideBottom(); - - if ( whichSide == "left" ) { - el.style.marginLeft = marginSize + "px"; el.style.marginRight = "0px"; - } - else if ( whichSide == "right" ) { - el.style.marginRight = marginSize + "px"; el.style.marginLeft = "0px"; - } - else { - el.style.marginLeft = marginSize + "px"; el.style.marginRight = marginSize + "px"; - } - }, - - _setBorder: function(el,n,corners) { - var borderSize = this._borderSize(n); - var whichSide = corners == "top" ? this._whichSideTop() : this._whichSideBottom(); - if ( whichSide == "left" ) { - el.style.borderLeftWidth = borderSize + "px"; el.style.borderRightWidth = "0px"; - } - else if ( whichSide == "right" ) { - el.style.borderRightWidth = borderSize + "px"; el.style.borderLeftWidth = "0px"; - } - else { - el.style.borderLeftWidth = borderSize + "px"; el.style.borderRightWidth = borderSize + "px"; - } - if (this.options.border != false) - el.style.borderLeftWidth = borderSize + "px"; el.style.borderRightWidth = borderSize + "px"; - }, - - _marginSize: function(n) { - if ( this._isTransparent() ) - return 0; - - var marginSizes = [ 5, 3, 2, 1 ]; - var blendedMarginSizes = [ 3, 2, 1, 0 ]; - var compactMarginSizes = [ 2, 1 ]; - var smBlendedMarginSizes = [ 1, 0 ]; - - if ( this.options.compact && this.options.blend ) - return smBlendedMarginSizes[n]; - else if ( this.options.compact ) - return compactMarginSizes[n]; - else if ( this.options.blend ) - return blendedMarginSizes[n]; - else - return marginSizes[n]; - }, - - _borderSize: function(n) { - var transparentBorderSizes = [ 5, 3, 2, 1 ]; - var blendedBorderSizes = [ 2, 1, 1, 1 ]; - var compactBorderSizes = [ 1, 0 ]; - var actualBorderSizes = [ 0, 2, 0, 0 ]; - - if ( this.options.compact && (this.options.blend || this._isTransparent()) ) - return 1; - else if ( this.options.compact ) - return compactBorderSizes[n]; - else if ( this.options.blend ) - return blendedBorderSizes[n]; - else if ( this.options.border ) - return actualBorderSizes[n]; - else if ( this._isTransparent() ) - return transparentBorderSizes[n]; - return 0; - }, - - _hasString: function(str) { for(var i=1 ; i<arguments.length ; i++) if (str.indexOf(arguments[i]) >= 0) return true; return false; }, - _blend: function(c1, c2) { var cc1 = Rico.Color.createFromHex(c1); cc1.blend(Rico.Color.createFromHex(c2)); return cc1; }, - _background: function(el) { try { return Rico.Color.createColorFromBackground(el).asHex(); } catch(err) { return "#ffffff"; } }, - _isTransparent: function() { return this.options.color == "transparent"; }, - _isTopRounded: function() { return this._hasString(this.options.corners, "all", "top", "tl", "tr"); }, - _isBottomRounded: function() { return this._hasString(this.options.corners, "all", "bottom", "bl", "br"); }, - _hasSingleTextChild: function(el) { return el.childNodes.length == 1 && el.childNodes[0].nodeType == 3; } -} - - -//-------------------- ricoDragAndDrop.js -Rico.DragAndDrop = Class.create(); - -Rico.DragAndDrop.prototype = { - - initialize: function() { - this.dropZones = new Array(); - this.draggables = new Array(); - this.currentDragObjects = new Array(); - this.dragElement = null; - this.lastSelectedDraggable = null; - this.currentDragObjectVisible = false; - this.interestedInMotionEvents = false; - this._mouseDown = this._mouseDownHandler.bindAsEventListener(this); - this._mouseMove = this._mouseMoveHandler.bindAsEventListener(this); - this._mouseUp = this._mouseUpHandler.bindAsEventListener(this); - }, - - registerDropZone: function(aDropZone) { - this.dropZones[ this.dropZones.length ] = aDropZone; - }, - - deregisterDropZone: function(aDropZone) { - var newDropZones = new Array(); - var j = 0; - for ( var i = 0 ; i < this.dropZones.length ; i++ ) { - if ( this.dropZones[i] != aDropZone ) - newDropZones[j++] = this.dropZones[i]; - } - - this.dropZones = newDropZones; - }, - - clearDropZones: function() { - this.dropZones = new Array(); - }, - - registerDraggable: function( aDraggable ) { - this.draggables[ this.draggables.length ] = aDraggable; - this._addMouseDownHandler( aDraggable ); - }, - - clearSelection: function() { - for ( var i = 0 ; i < this.currentDragObjects.length ; i++ ) - this.currentDragObjects[i].deselect(); - this.currentDragObjects = new Array(); - this.lastSelectedDraggable = null; - }, - - hasSelection: function() { - return this.currentDragObjects.length > 0; - }, - - setStartDragFromElement: function( e, mouseDownElement ) { - this.origPos = RicoUtil.toDocumentPosition(mouseDownElement); - this.startx = e.screenX - this.origPos.x - this.starty = e.screenY - this.origPos.y - //this.startComponentX = e.layerX ? e.layerX : e.offsetX; - //this.startComponentY = e.layerY ? e.layerY : e.offsetY; - //this.adjustedForDraggableSize = false; - - this.interestedInMotionEvents = this.hasSelection(); - this._terminateEvent(e); - }, - - updateSelection: function( draggable, extendSelection ) { - if ( ! extendSelection ) - this.clearSelection(); - - if ( draggable.isSelected() ) { - this.currentDragObjects.removeItem(draggable); - draggable.deselect(); - if ( draggable == this.lastSelectedDraggable ) - this.lastSelectedDraggable = null; - } - else { - this.currentDragObjects[ this.currentDragObjects.length ] = draggable; - draggable.select(); - this.lastSelectedDraggable = draggable; - } - }, - - _mouseDownHandler: function(e) { - if ( arguments.length == 0 ) - e = event; - - // if not button 1 ignore it... - var nsEvent = e.which != undefined; - if ( (nsEvent && e.which != 1) || (!nsEvent && e.button != 1)) - return; - - var eventTarget = e.target ? e.target : e.srcElement; - var draggableObject = eventTarget.draggable; - - var candidate = eventTarget; - while (draggableObject == null && candidate.parentNode) { - candidate = candidate.parentNode; - draggableObject = candidate.draggable; - } - - if ( draggableObject == null ) - return; - - this.updateSelection( draggableObject, e.ctrlKey ); - - // clear the drop zones postion cache... - if ( this.hasSelection() ) - for ( var i = 0 ; i < this.dropZones.length ; i++ ) - this.dropZones[i].clearPositionCache(); - - this.setStartDragFromElement( e, draggableObject.getMouseDownHTMLElement() ); - }, - - - _mouseMoveHandler: function(e) { - var nsEvent = e.which != undefined; - if ( !this.interestedInMotionEvents ) { - //this._terminateEvent(e); - return; - } - - if ( ! this.hasSelection() ) - return; - - if ( ! this.currentDragObjectVisible ) - this._startDrag(e); - - if ( !this.activatedDropZones ) - this._activateRegisteredDropZones(); - - //if ( !this.adjustedForDraggableSize ) - // this._adjustForDraggableSize(e); - - this._updateDraggableLocation(e); - this._updateDropZonesHover(e); - - this._terminateEvent(e); - }, - - _makeDraggableObjectVisible: function(e) - { - if ( !this.hasSelection() ) - return; - - var dragElement; - if ( this.currentDragObjects.length > 1 ) - dragElement = this.currentDragObjects[0].getMultiObjectDragGUI(this.currentDragObjects); - else - dragElement = this.currentDragObjects[0].getSingleObjectDragGUI(); - - // go ahead and absolute position it... - if ( RicoUtil.getElementsComputedStyle(dragElement, "position") != "absolute" ) - dragElement.style.position = "absolute"; - - // need to parent him into the document... - if ( dragElement.parentNode == null || dragElement.parentNode.nodeType == 11 ) - document.body.appendChild(dragElement); - - this.dragElement = dragElement; - this._updateDraggableLocation(e); - - this.currentDragObjectVisible = true; - }, - - /** - _adjustForDraggableSize: function(e) { - var dragElementWidth = this.dragElement.offsetWidth; - var dragElementHeight = this.dragElement.offsetHeight; - if ( this.startComponentX > dragElementWidth ) - this.startx -= this.startComponentX - dragElementWidth + 2; - if ( e.offsetY ) { - if ( this.startComponentY > dragElementHeight ) - this.starty -= this.startComponentY - dragElementHeight + 2; - } - this.adjustedForDraggableSize = true; - }, - **/ - - _leftOffset: function(e) { - return e.offsetX ? document.body.scrollLeft : 0 - }, - - _topOffset: function(e) { - return e.offsetY ? document.body.scrollTop:0 - }, - - - _updateDraggableLocation: function(e) { - var dragObjectStyle = this.dragElement.style; - dragObjectStyle.left = (e.screenX + this._leftOffset(e) - this.startx) + "px" - dragObjectStyle.top = (e.screenY + this._topOffset(e) - this.starty) + "px"; - }, - - _updateDropZonesHover: function(e) { - var n = this.dropZones.length; - for ( var i = 0 ; i < n ; i++ ) { - if ( ! this._mousePointInDropZone( e, this.dropZones[i] ) ) - this.dropZones[i].hideHover(); - } - - for ( var i = 0 ; i < n ; i++ ) { - if ( this._mousePointInDropZone( e, this.dropZones[i] ) ) { - if ( this.dropZones[i].canAccept(this.currentDragObjects) ) - this.dropZones[i].showHover(); - } - } - }, - - _startDrag: function(e) { - for ( var i = 0 ; i < this.currentDragObjects.length ; i++ ) - this.currentDragObjects[i].startDrag(); - - this._makeDraggableObjectVisible(e); - }, - - _mouseUpHandler: function(e) { - if ( ! this.hasSelection() ) - return; - - var nsEvent = e.which != undefined; - if ( (nsEvent && e.which != 1) || (!nsEvent && e.button != 1)) - return; - - this.interestedInMotionEvents = false; - - if ( this.dragElement == null ) { - this._terminateEvent(e); - return; - } - - if ( this._placeDraggableInDropZone(e) ) - this._completeDropOperation(e); - else { - this._terminateEvent(e); - new Rico.Effect.Position( this.dragElement, - this.origPos.x, - this.origPos.y, - 200, - 20, - { complete : this._doCancelDragProcessing.bind(this) } ); - } - - Event.stopObserving(document.body, "mousemove", this._mouseMove); - Event.stopObserving(document.body, "mouseup", this._mouseUp); - }, - - _retTrue: function () { - return true; - }, - - _completeDropOperation: function(e) { - if ( this.dragElement != this.currentDragObjects[0].getMouseDownHTMLElement() ) { - if ( this.dragElement.parentNode != null ) - this.dragElement.parentNode.removeChild(this.dragElement); - } - - this._deactivateRegisteredDropZones(); - this._endDrag(); - this.clearSelection(); - this.dragElement = null; - this.currentDragObjectVisible = false; - this._terminateEvent(e); - }, - - _doCancelDragProcessing: function() { - this._cancelDrag(); - - if ( this.dragElement != this.currentDragObjects[0].getMouseDownHTMLElement() && this.dragElement) - if ( this.dragElement.parentNode != null ) - this.dragElement.parentNode.removeChild(this.dragElement); - - - this._deactivateRegisteredDropZones(); - this.dragElement = null; - this.currentDragObjectVisible = false; - }, - - _placeDraggableInDropZone: function(e) { - var foundDropZone = false; - var n = this.dropZones.length; - for ( var i = 0 ; i < n ; i++ ) { - if ( this._mousePointInDropZone( e, this.dropZones[i] ) ) { - if ( this.dropZones[i].canAccept(this.currentDragObjects) ) { - this.dropZones[i].hideHover(); - this.dropZones[i].accept(this.currentDragObjects); - foundDropZone = true; - break; - } - } - } - - return foundDropZone; - }, - - _cancelDrag: function() { - for ( var i = 0 ; i < this.currentDragObjects.length ; i++ ) - this.currentDragObjects[i].cancelDrag(); - }, - - _endDrag: function() { - for ( var i = 0 ; i < this.currentDragObjects.length ; i++ ) - this.currentDragObjects[i].endDrag(); - }, - - _mousePointInDropZone: function( e, dropZone ) { - - var absoluteRect = dropZone.getAbsoluteRect(); - - return e.clientX > absoluteRect.left + this._leftOffset(e) && - e.clientX < absoluteRect.right + this._leftOffset(e) && - e.clientY > absoluteRect.top + this._topOffset(e) && - e.clientY < absoluteRect.bottom + this._topOffset(e); - }, - - _addMouseDownHandler: function( aDraggable ) - { - htmlElement = aDraggable.getMouseDownHTMLElement(); - if ( htmlElement != null ) { - htmlElement.draggable = aDraggable; - Event.observe(htmlElement , "mousedown", this._onmousedown.bindAsEventListener(this)); - Event.observe(htmlElement, "mousedown", this._mouseDown); - } - }, - - _activateRegisteredDropZones: function() { - var n = this.dropZones.length; - for ( var i = 0 ; i < n ; i++ ) { - var dropZone = this.dropZones[i]; - if ( dropZone.canAccept(this.currentDragObjects) ) - dropZone.activate(); - } - - this.activatedDropZones = true; - }, - - _deactivateRegisteredDropZones: function() { - var n = this.dropZones.length; - for ( var i = 0 ; i < n ; i++ ) - this.dropZones[i].deactivate(); - this.activatedDropZones = false; - }, - - _onmousedown: function () { - Event.observe(document.body, "mousemove", this._mouseMove); - Event.observe(document.body, "mouseup", this._mouseUp); - }, - - _terminateEvent: function(e) { - if ( e.stopPropagation != undefined ) - e.stopPropagation(); - else if ( e.cancelBubble != undefined ) - e.cancelBubble = true; - - if ( e.preventDefault != undefined ) - e.preventDefault(); - else - e.returnValue = false; - }, - - - initializeEventHandlers: function() { - if ( typeof document.implementation != "undefined" && - document.implementation.hasFeature("HTML", "1.0") && - document.implementation.hasFeature("Events", "2.0") && - document.implementation.hasFeature("CSS", "2.0") ) { - document.addEventListener("mouseup", this._mouseUpHandler.bindAsEventListener(this), false); - document.addEventListener("mousemove", this._mouseMoveHandler.bindAsEventListener(this), false); - } - else { - document.attachEvent( "onmouseup", this._mouseUpHandler.bindAsEventListener(this) ); - document.attachEvent( "onmousemove", this._mouseMoveHandler.bindAsEventListener(this) ); - } - } - } - - var dndMgr = new Rico.DragAndDrop(); - dndMgr.initializeEventHandlers(); - - -//-------------------- ricoDraggable.js -Rico.Draggable = Class.create(); - -Rico.Draggable.prototype = { - - initialize: function( type, htmlElement ) { - this.type = type; - this.htmlElement = $(htmlElement); - this.selected = false; - }, - - /** - * Returns the HTML element that should have a mouse down event - * added to it in order to initiate a drag operation - * - **/ - getMouseDownHTMLElement: function() { - return this.htmlElement; - }, - - select: function() { - this.selected = true; - - if ( this.showingSelected ) - return; - - var htmlElement = this.getMouseDownHTMLElement(); - - var color = Rico.Color.createColorFromBackground(htmlElement); - color.isBright() ? color.darken(0.033) : color.brighten(0.033); - - this.saveBackground = RicoUtil.getElementsComputedStyle(htmlElement, "backgroundColor", "background-color"); - htmlElement.style.backgroundColor = color.asHex(); - this.showingSelected = true; - }, - - deselect: function() { - this.selected = false; - if ( !this.showingSelected ) - return; - - var htmlElement = this.getMouseDownHTMLElement(); - - htmlElement.style.backgroundColor = this.saveBackground; - this.showingSelected = false; - }, - - isSelected: function() { - return this.selected; - }, - - startDrag: function() { - }, - - cancelDrag: function() { - }, - - endDrag: function() { - }, - - getSingleObjectDragGUI: function() { - return this.htmlElement; - }, - - getMultiObjectDragGUI: function( draggables ) { - return this.htmlElement; - }, - - getDroppedGUI: function() { - return this.htmlElement; - }, - - toString: function() { - return this.type + ":" + this.htmlElement + ":"; - } - -} - - -//-------------------- ricoDropzone.js -Rico.Dropzone = Class.create(); - -Rico.Dropzone.prototype = { - - initialize: function( htmlElement ) { - this.htmlElement = $(htmlElement); - this.absoluteRect = null; - }, - - getHTMLElement: function() { - return this.htmlElement; - }, - - clearPositionCache: function() { - this.absoluteRect = null; - }, - - getAbsoluteRect: function() { - if ( this.absoluteRect == null ) { - var htmlElement = this.getHTMLElement(); - var pos = RicoUtil.toViewportPosition(htmlElement); - - this.absoluteRect = { - top: pos.y, - left: pos.x, - bottom: pos.y + htmlElement.offsetHeight, - right: pos.x + htmlElement.offsetWidth - }; - } - return this.absoluteRect; - }, - - activate: function() { - var htmlElement = this.getHTMLElement(); - if (htmlElement == null || this.showingActive) - return; - - this.showingActive = true; - this.saveBackgroundColor = htmlElement.style.backgroundColor; - - var fallbackColor = "#ffea84"; - var currentColor = Rico.Color.createColorFromBackground(htmlElement); - if ( currentColor == null ) - htmlElement.style.backgroundColor = fallbackColor; - else { - currentColor.isBright() ? currentColor.darken(0.2) : currentColor.brighten(0.2); - htmlElement.style.backgroundColor = currentColor.asHex(); - } - }, - - deactivate: function() { - var htmlElement = this.getHTMLElement(); - if (htmlElement == null || !this.showingActive) - return; - - htmlElement.style.backgroundColor = this.saveBackgroundColor; - this.showingActive = false; - this.saveBackgroundColor = null; - }, - - showHover: function() { - var htmlElement = this.getHTMLElement(); - if ( htmlElement == null || this.showingHover ) - return; - - this.saveBorderWidth = htmlElement.style.borderWidth; - this.saveBorderStyle = htmlElement.style.borderStyle; - this.saveBorderColor = htmlElement.style.borderColor; - - this.showingHover = true; - htmlElement.style.borderWidth = "1px"; - htmlElement.style.borderStyle = "solid"; - //htmlElement.style.borderColor = "#ff9900"; - htmlElement.style.borderColor = "#ffff00"; - }, - - hideHover: function() { - var htmlElement = this.getHTMLElement(); - if ( htmlElement == null || !this.showingHover ) - return; - - htmlElement.style.borderWidth = this.saveBorderWidth; - htmlElement.style.borderStyle = this.saveBorderStyle; - htmlElement.style.borderColor = this.saveBorderColor; - this.showingHover = false; - }, - - canAccept: function(draggableObjects) { - return true; - }, - - accept: function(draggableObjects) { - var htmlElement = this.getHTMLElement(); - if ( htmlElement == null ) - return; - - n = draggableObjects.length; - for ( var i = 0 ; i < n ; i++ ) - { - var theGUI = draggableObjects[i].getDroppedGUI(); - if ( RicoUtil.getElementsComputedStyle( theGUI, "position" ) == "absolute" ) - { - theGUI.style.position = "static"; - theGUI.style.top = ""; - theGUI.style.top = ""; - } - htmlElement.appendChild(theGUI); - } - } -} - - -//-------------------- ricoEffects.js - -Rico.Effect = {}; - -Rico.Effect.SizeAndPosition = Class.create(); -Rico.Effect.SizeAndPosition.prototype = { - - initialize: function(element, x, y, w, h, duration, steps, options) { - this.element = $(element); - this.x = x; - this.y = y; - this.w = w; - this.h = h; - this.duration = duration; - this.steps = steps; - this.options = arguments[7] || {}; - - this.sizeAndPosition(); - }, - - sizeAndPosition: function() { - if (this.isFinished()) { - if(this.options.complete) this.options.complete(this); - return; - } - - if (this.timer) - clearTimeout(this.timer); - - var stepDuration = Math.round(this.duration/this.steps) ; - - // Get original values: x,y = top left corner; w,h = width height - var currentX = this.element.offsetLeft; - var currentY = this.element.offsetTop; - var currentW = this.element.offsetWidth; - var currentH = this.element.offsetHeight; - - // If values not set, or zero, we do not modify them, and take original as final as well - this.x = (this.x) ? this.x : currentX; - this.y = (this.y) ? this.y : currentY; - this.w = (this.w) ? this.w : currentW; - this.h = (this.h) ? this.h : currentH; - - // how much do we need to modify our values for each step? - var difX = this.steps > 0 ? (this.x - currentX)/this.steps : 0; - var difY = this.steps > 0 ? (this.y - currentY)/this.steps : 0; - var difW = this.steps > 0 ? (this.w - currentW)/this.steps : 0; - var difH = this.steps > 0 ? (this.h - currentH)/this.steps : 0; - - this.moveBy(difX, difY); - this.resizeBy(difW, difH); - - this.duration -= stepDuration; - this.steps--; - - this.timer = setTimeout(this.sizeAndPosition.bind(this), stepDuration); - }, - - isFinished: function() { - return this.steps <= 0; - }, - - moveBy: function( difX, difY ) { - var currentLeft = this.element.offsetLeft; - var currentTop = this.element.offsetTop; - var intDifX = parseInt(difX); - var intDifY = parseInt(difY); - - var style = this.element.style; - if ( intDifX != 0 ) - style.left = (currentLeft + intDifX) + "px"; - if ( intDifY != 0 ) - style.top = (currentTop + intDifY) + "px"; - }, - - resizeBy: function( difW, difH ) { - var currentWidth = this.element.offsetWidth; - var currentHeight = this.element.offsetHeight; - var intDifW = parseInt(difW); - var intDifH = parseInt(difH); - - var style = this.element.style; - if ( intDifW != 0 ) - style.width = (currentWidth + intDifW) + "px"; - if ( intDifH != 0 ) - style.height = (currentHeight + intDifH) + "px"; - } -} - -Rico.Effect.Size = Class.create(); -Rico.Effect.Size.prototype = { - - initialize: function(element, w, h, duration, steps, options) { - new Rico.Effect.SizeAndPosition(element, null, null, w, h, duration, steps, options); - } -} - -Rico.Effect.Position = Class.create(); -Rico.Effect.Position.prototype = { - - initialize: function(element, x, y, duration, steps, options) { - new Rico.Effect.SizeAndPosition(element, x, y, null, null, duration, steps, options); - } -} - -Rico.Effect.Round = Class.create(); -Rico.Effect.Round.prototype = { - - initialize: function(tagName, className, options) { - var elements = document.getElementsByTagAndClassName(tagName,className); - for ( var i = 0 ; i < elements.length ; i++ ) - Rico.Corner.round( elements[i], options ); - } -}; - -Rico.Effect.FadeTo = Class.create(); -Rico.Effect.FadeTo.prototype = { - - initialize: function( element, opacity, duration, steps, options) { - this.element = $(element); - this.opacity = opacity; - this.duration = duration; - this.steps = steps; - this.options = arguments[4] || {}; - this.fadeTo(); - }, - - fadeTo: function() { - if (this.isFinished()) { - if(this.options.complete) this.options.complete(this); - return; - } - - if (this.timer) - clearTimeout(this.timer); - - var stepDuration = Math.round(this.duration/this.steps) ; - var currentOpacity = this.getElementOpacity(); - var delta = this.steps > 0 ? (this.opacity - currentOpacity)/this.steps : 0; - - this.changeOpacityBy(delta); - this.duration -= stepDuration; - this.steps--; - - this.timer = setTimeout(this.fadeTo.bind(this), stepDuration); - }, - - changeOpacityBy: function(v) { - var currentOpacity = this.getElementOpacity(); - var newOpacity = Math.max(0, Math.min(currentOpacity+v, 1)); - this.element.ricoOpacity = newOpacity; - - this.element.style.filter = "alpha(opacity:"+Math.round(newOpacity*100)+")"; - this.element.style.opacity = newOpacity; /*//*/; - }, - - isFinished: function() { - return this.steps <= 0; - }, - - getElementOpacity: function() { - if ( this.element.ricoOpacity == undefined ) { - var opacity = RicoUtil.getElementsComputedStyle(this.element, 'opacity'); - this.element.ricoOpacity = opacity != undefined ? opacity : 1.0; - } - return parseFloat(this.element.ricoOpacity); - } -} - -Rico.Effect.AccordionSize = Class.create(); - -Rico.Effect.AccordionSize.prototype = { - - initialize: function(e1, e2, start, end, duration, steps, options) { - this.e1 = $(e1); - this.e2 = $(e2); - this.start = start; - this.end = end; - this.duration = duration; - this.steps = steps; - this.options = arguments[6] || {}; - - this.accordionSize(); - }, - - accordionSize: function() { - - if (this.isFinished()) { - // just in case there are round errors or such... - this.e1.style.height = this.start + "px"; - this.e2.style.height = this.end + "px"; - - if(this.options.complete) - this.options.complete(this); - return; - } - - if (this.timer) - clearTimeout(this.timer); - - var stepDuration = Math.round(this.duration/this.steps) ; - - var diff = this.steps > 0 ? (parseInt(this.e1.offsetHeight) - this.start)/this.steps : 0; - this.resizeBy(diff); - - this.duration -= stepDuration; - this.steps--; - - this.timer = setTimeout(this.accordionSize.bind(this), stepDuration); - }, - - isFinished: function() { - return this.steps <= 0; - }, - - resizeBy: function(diff) { - var h1Height = this.e1.offsetHeight; - var h2Height = this.e2.offsetHeight; - var intDiff = parseInt(diff); - if ( diff != 0 ) { - this.e1.style.height = (h1Height - intDiff) + "px"; - this.e2.style.height = (h2Height + intDiff) + "px"; - } - } - -}; - - -//-------------------- ricoLiveGrid.js -// Rico.LiveGridMetaData ----------------------------------------------------- - -Rico.LiveGridMetaData = Class.create(); - -Rico.LiveGridMetaData.prototype = { - - initialize: function( pageSize, totalRows, columnCount, options ) { - this.pageSize = pageSize; - this.totalRows = totalRows; - this.setOptions(options); - this.ArrowHeight = 16; - this.columnCount = columnCount; - }, - - setOptions: function(options) { - this.options = { - largeBufferSize : 7.0, // 7 pages - nearLimitFactor : 0.2 // 20% of buffer - }; - Object.extend(this.options, options || {}); - }, - - getPageSize: function() { - return this.pageSize; - }, - - getTotalRows: function() { - return this.totalRows; - }, - - setTotalRows: function(n) { - this.totalRows = n; - }, - - getLargeBufferSize: function() { - return parseInt(this.options.largeBufferSize * this.pageSize); - }, - - getLimitTolerance: function() { - return parseInt(this.getLargeBufferSize() * this.options.nearLimitFactor); - } -}; - -// Rico.LiveGridScroller ----------------------------------------------------- - -Rico.LiveGridScroller = Class.create(); - -Rico.LiveGridScroller.prototype = { - - initialize: function(liveGrid, viewPort) { - this.isIE = navigator.userAgent.toLowerCase().indexOf("msie") >= 0; - this.liveGrid = liveGrid; - this.metaData = liveGrid.metaData; - this.createScrollBar(); - this.scrollTimeout = null; - this.lastScrollPos = 0; - this.viewPort = viewPort; - this.rows = new Array(); - }, - - isUnPlugged: function() { - return this.scrollerDiv.onscroll == null; - }, - - plugin: function() { - this.scrollerDiv.onscroll = this.handleScroll.bindAsEventListener(this); - }, - - unplug: function() { - this.scrollerDiv.onscroll = null; - }, - - sizeIEHeaderHack: function() { - if ( !this.isIE ) return; - var headerTable = $(this.liveGrid.tableId + "_header"); - if ( headerTable ) - headerTable.rows[0].cells[0].style.width = - (headerTable.rows[0].cells[0].offsetWidth + 1) + "px"; - }, - - createScrollBar: function() { - var visibleHeight = this.liveGrid.viewPort.visibleHeight(); - // create the outer div... - this.scrollerDiv = document.createElement("div"); - var scrollerStyle = this.scrollerDiv.style; - scrollerStyle.borderRight = this.liveGrid.options.scrollerBorderRight; - scrollerStyle.position = "relative"; - scrollerStyle.left = this.isIE ? "-6px" : "-3px"; - scrollerStyle.width = "19px"; - scrollerStyle.height = visibleHeight + "px"; - scrollerStyle.overflow = "auto"; - - // create the inner div... - this.heightDiv = document.createElement("div"); - this.heightDiv.style.width = "1px"; - - this.heightDiv.style.height = parseInt(visibleHeight * - this.metaData.getTotalRows()/this.metaData.getPageSize()) + "px" ; - this.scrollerDiv.appendChild(this.heightDiv); - this.scrollerDiv.onscroll = this.handleScroll.bindAsEventListener(this); - - var table = this.liveGrid.table; - table.parentNode.parentNode.insertBefore( this.scrollerDiv, table.parentNode.nextSibling ); - var eventName = this.isIE ? "mousewheel" : "DOMMouseScroll"; - Event.observe(table, eventName, - function(evt) { - if (evt.wheelDelta>=0 || evt.detail < 0) //wheel-up - this.scrollerDiv.scrollTop -= (2*this.viewPort.rowHeight); - else - this.scrollerDiv.scrollTop += (2*this.viewPort.rowHeight); - this.handleScroll(false); - }.bindAsEventListener(this), - false); - }, - - updateSize: function() { - var table = this.liveGrid.table; - var visibleHeight = this.viewPort.visibleHeight(); - this.heightDiv.style.height = parseInt(visibleHeight * - this.metaData.getTotalRows()/this.metaData.getPageSize()) + "px"; - }, - - rowToPixel: function(rowOffset) { - return (rowOffset / this.metaData.getTotalRows()) * this.heightDiv.offsetHeight - }, - - moveScroll: function(rowOffset) { - this.scrollerDiv.scrollTop = this.rowToPixel(rowOffset); - if ( this.metaData.options.onscroll ) - this.metaData.options.onscroll( this.liveGrid, rowOffset ); - }, - - handleScroll: function() { - if ( this.scrollTimeout ) - clearTimeout( this.scrollTimeout ); - - var scrollDiff = this.lastScrollPos-this.scrollerDiv.scrollTop; - if (scrollDiff != 0.00) { - var r = this.scrollerDiv.scrollTop % this.viewPort.rowHeight; - if (r != 0) { - this.unplug(); - if ( scrollDiff < 0 ) { - this.scrollerDiv.scrollTop += (this.viewPort.rowHeight-r); - } else { - this.scrollerDiv.scrollTop -= r; - } - this.plugin(); - } - } - var contentOffset = parseInt(this.scrollerDiv.scrollTop / this.viewPort.rowHeight); - this.liveGrid.requestContentRefresh(contentOffset); - this.viewPort.scrollTo(this.scrollerDiv.scrollTop); - - if ( this.metaData.options.onscroll ) - this.metaData.options.onscroll( this.liveGrid, contentOffset ); - - this.scrollTimeout = setTimeout(this.scrollIdle.bind(this), 1200 ); - this.lastScrollPos = this.scrollerDiv.scrollTop; - - }, - - scrollIdle: function() { - if ( this.metaData.options.onscrollidle ) - this.metaData.options.onscrollidle(); - } -}; - -// Rico.LiveGridBuffer ----------------------------------------------------- - -Rico.LiveGridBuffer = Class.create(); - -Rico.LiveGridBuffer.prototype = { - - initialize: function(metaData, viewPort) { - this.startPos = 0; - this.size = 0; - this.metaData = metaData; - this.rows = new Array(); - this.updateInProgress = false; - this.viewPort = viewPort; - this.maxBufferSize = metaData.getLargeBufferSize() * 2; - this.maxFetchSize = metaData.getLargeBufferSize(); - this.lastOffset = 0; - }, - - getBlankRow: function() { - if (!this.blankRow ) { - this.blankRow = new Array(); - for ( var i=0; i < this.metaData.columnCount ; i++ ) - this.blankRow[i] = " "; - } - return this.blankRow; - }, - - loadRows: function(ajaxResponse) { - var rowsElement = ajaxResponse.getElementsByTagName('rows')[0]; - this.updateUI = rowsElement.getAttribute("update_ui") == "true" - var newRows = new Array() - var trs = rowsElement.getElementsByTagName("tr"); - for ( var i=0 ; i < trs.length; i++ ) { - var row = newRows[i] = new Array(); - var cells = trs[i].getElementsByTagName("td"); - for ( var j=0; j < cells.length ; j++ ) { - var cell = cells[j]; - var convertSpaces = cell.getAttribute("convert_spaces") == "true"; - var cellContent = RicoUtil.getContentAsString(cell); - row[j] = convertSpaces ? this.convertSpaces(cellContent) : cellContent; - if (!row[j]) - row[j] = ' '; - } - } - return newRows; - }, - - update: function(ajaxResponse, start) { - var newRows = this.loadRows(ajaxResponse); - if (this.rows.length == 0) { // initial load - this.rows = newRows; - this.size = this.rows.length; - this.startPos = start; - return; - } - if (start > this.startPos) { //appending - if (this.startPos + this.rows.length < start) { - this.rows = newRows; - this.startPos = start;// - } else { - this.rows = this.rows.concat( newRows.slice(0, newRows.length)); - if (this.rows.length > this.maxBufferSize) { - var fullSize = this.rows.length; - this.rows = this.rows.slice(this.rows.length - this.maxBufferSize, this.rows.length) - this.startPos = this.startPos + (fullSize - this.rows.length); - } - } - } else { //prepending - if (start + newRows.length < this.startPos) { - this.rows = newRows; - } else { - this.rows = newRows.slice(0, this.startPos).concat(this.rows); - if (this.rows.length > this.maxBufferSize) - this.rows = this.rows.slice(0, this.maxBufferSize) - } - this.startPos = start; - } - this.size = this.rows.length; - }, - - clear: function() { - this.rows = new Array(); - this.startPos = 0; - this.size = 0; - }, - - isOverlapping: function(start, size) { - return ((start < this.endPos()) && (this.startPos < start + size)) || (this.endPos() == 0) - }, - - isInRange: function(position) { - return (position >= this.startPos) && (position + this.metaData.getPageSize() <= this.endPos()); - //&& this.size() != 0; - }, - - isNearingTopLimit: function(position) { - return position - this.startPos < this.metaData.getLimitTolerance(); - }, - - endPos: function() { - return this.startPos + this.rows.length; - }, - - isNearingBottomLimit: function(position) { - return this.endPos() - (position + this.metaData.getPageSize()) < this.metaData.getLimitTolerance(); - }, - - isAtTop: function() { - return this.startPos == 0; - }, - - isAtBottom: function() { - return this.endPos() == this.metaData.getTotalRows(); - }, - - isNearingLimit: function(position) { - return ( !this.isAtTop() && this.isNearingTopLimit(position)) || - ( !this.isAtBottom() && this.isNearingBottomLimit(position) ) - }, - - getFetchSize: function(offset) { - var adjustedOffset = this.getFetchOffset(offset); - var adjustedSize = 0; - if (adjustedOffset >= this.startPos) { //apending - var endFetchOffset = this.maxFetchSize + adjustedOffset; - if (endFetchOffset > this.metaData.totalRows) - endFetchOffset = this.metaData.totalRows; - adjustedSize = endFetchOffset - adjustedOffset; - if(adjustedOffset == 0 && adjustedSize < this.maxFetchSize){ - adjustedSize = this.maxFetchSize; - } - } else {//prepending - var adjustedSize = this.startPos - adjustedOffset; - if (adjustedSize > this.maxFetchSize) - adjustedSize = this.maxFetchSize; - } - return adjustedSize; - }, - - getFetchOffset: function(offset) { - var adjustedOffset = offset; - if (offset > this.startPos) //apending - adjustedOffset = (offset > this.endPos()) ? offset : this.endPos(); - else { //prepending - if (offset + this.maxFetchSize >= this.startPos) { - var adjustedOffset = this.startPos - this.maxFetchSize; - if (adjustedOffset < 0) - adjustedOffset = 0; - } - } - this.lastOffset = adjustedOffset; - return adjustedOffset; - }, - - getRows: function(start, count) { - var begPos = start - this.startPos - var endPos = begPos + count - - // er? need more data... - if ( endPos > this.size ) - endPos = this.size - - var results = new Array() - var index = 0; - for ( var i=begPos ; i < endPos; i++ ) { - results[index++] = this.rows[i] - } - return results - }, - - convertSpaces: function(s) { - return s.split(" ").join(" "); - } - -}; - - -//Rico.GridViewPort -------------------------------------------------- -Rico.GridViewPort = Class.create(); - -Rico.GridViewPort.prototype = { - - initialize: function(table, rowHeight, visibleRows, buffer, liveGrid) { - this.lastDisplayedStartPos = 0; - this.div = table.parentNode; - this.table = table - this.rowHeight = rowHeight; - this.div.style.height = (this.rowHeight * visibleRows) + "px"; - this.div.style.overflow = "hidden"; - this.buffer = buffer; - this.liveGrid = liveGrid; - this.visibleRows = visibleRows + 1; - this.lastPixelOffset = 0; - this.startPos = 0; - }, - - populateRow: function(htmlRow, row) { - for (var j=0; j < row.length; j++) { - htmlRow.cells[j].innerHTML = row[j] - } - }, - - bufferChanged: function() { - this.refreshContents( parseInt(this.lastPixelOffset / this.rowHeight)); - }, - - clearRows: function() { - if (!this.isBlank) { - this.liveGrid.table.className = this.liveGrid.options.loadingClass; - for (var i=0; i < this.visibleRows; i++) - this.populateRow(this.table.rows[i], this.buffer.getBlankRow()); - this.isBlank = true; - } - }, - - clearContents: function() { - this.clearRows(); - this.scrollTo(0); - this.startPos = 0; - this.lastStartPos = -1; - }, - - refreshContents: function(startPos) { - if (startPos == this.lastRowPos && !this.isPartialBlank && !this.isBlank) { - return; - } - if ((startPos + this.visibleRows < this.buffer.startPos) - || (this.buffer.startPos + this.buffer.size < startPos) - || (this.buffer.size == 0)) { - this.clearRows(); - return; - } - this.isBlank = false; - var viewPrecedesBuffer = this.buffer.startPos > startPos - var contentStartPos = viewPrecedesBuffer ? this.buffer.startPos: startPos; - var contentEndPos = (this.buffer.startPos + this.buffer.size < startPos + this.visibleRows) - ? this.buffer.startPos + this.buffer.size - : startPos + this.visibleRows; - var rowSize = contentEndPos - contentStartPos; - var rows = this.buffer.getRows(contentStartPos, rowSize ); - var blankSize = this.visibleRows - rowSize; - var blankOffset = viewPrecedesBuffer ? 0: rowSize; - var contentOffset = viewPrecedesBuffer ? blankSize: 0; - - for (var i=0; i < rows.length; i++) {//initialize what we have - this.populateRow(this.table.rows[i + contentOffset], rows[i]); - } - for (var i=0; i < blankSize; i++) {// blank out the rest - this.populateRow(this.table.rows[i + blankOffset], this.buffer.getBlankRow()); - } - this.isPartialBlank = blankSize > 0; - this.lastRowPos = startPos; - - this.liveGrid.table.className = this.liveGrid.options.tableClass; - // Check if user has set a onRefreshComplete function - var onRefreshComplete = this.liveGrid.options.onRefreshComplete; - if (onRefreshComplete != null) - onRefreshComplete(); - }, - - scrollTo: function(pixelOffset) { - if (this.lastPixelOffset == pixelOffset) - return; - - this.refreshContents(parseInt(pixelOffset / this.rowHeight)) - this.div.scrollTop = pixelOffset % this.rowHeight - - this.lastPixelOffset = pixelOffset; - }, - - visibleHeight: function() { - return parseInt(RicoUtil.getElementsComputedStyle(this.div, 'height')); - } - -}; - - -Rico.LiveGridRequest = Class.create(); -Rico.LiveGridRequest.prototype = { - initialize: function( requestOffset, options ) { - this.requestOffset = requestOffset; - } -}; - -// Rico.LiveGrid ----------------------------------------------------- - -Rico.LiveGrid = Class.create(); - -Rico.LiveGrid.prototype = { - - initialize: function( tableId, visibleRows, totalRows, url, options, ajaxOptions ) { - - this.options = { - tableClass: $(tableId).className, - loadingClass: $(tableId).className, - scrollerBorderRight: '1px solid #ababab', - bufferTimeout: 20000, - sortAscendImg: 'images/sort_asc.gif', - sortDescendImg: 'images/sort_desc.gif', - sortImageWidth: 9, - sortImageHeight: 5, - ajaxSortURLParms: [], - onRefreshComplete: null, - requestParameters: null, - inlineStyles: true - }; - Object.extend(this.options, options || {}); - - this.ajaxOptions = {parameters: null}; - Object.extend(this.ajaxOptions, ajaxOptions || {}); - - this.tableId = tableId; - this.table = $(tableId); - - this.addLiveGridHtml(); - - var columnCount = this.table.rows[0].cells.length; - this.metaData = new Rico.LiveGridMetaData(visibleRows, totalRows, columnCount, options); - this.buffer = new Rico.LiveGridBuffer(this.metaData); - - var rowCount = this.table.rows.length; - this.viewPort = new Rico.GridViewPort(this.table, - this.table.offsetHeight/rowCount, - visibleRows, - this.buffer, this); - this.scroller = new Rico.LiveGridScroller(this,this.viewPort); - this.options.sortHandler = this.sortHandler.bind(this); - - if ( $(tableId + '_header') ) - this.sort = new Rico.LiveGridSort(tableId + '_header', this.options) - - this.processingRequest = null; - this.unprocessedRequest = null; - - this.initAjax(url); - if ( this.options.prefetchBuffer || this.options.prefetchOffset > 0) { - var offset = 0; - if (this.options.offset ) { - offset = this.options.offset; - this.scroller.moveScroll(offset); - this.viewPort.scrollTo(this.scroller.rowToPixel(offset)); - } - if (this.options.sortCol) { - this.sortCol = options.sortCol; - this.sortDir = options.sortDir; - } - this.requestContentRefresh(offset); - } - }, - - addLiveGridHtml: function() { - // Check to see if need to create a header table. - if (this.table.getElementsByTagName("thead").length > 0){ - // Create Table this.tableId+'_header' - var tableHeader = this.table.cloneNode(true); - tableHeader.setAttribute('id', this.tableId+'_header'); - tableHeader.setAttribute('class', this.table.className+'_header'); - - // Clean up and insert - for( var i = 0; i < tableHeader.tBodies.length; i++ ) - tableHeader.removeChild(tableHeader.tBodies[i]); - this.table.deleteTHead(); - this.table.parentNode.insertBefore(tableHeader,this.table); - } - - new Insertion.Before(this.table, "<div id='"+this.tableId+"_container'></div>"); - this.table.previousSibling.appendChild(this.table); - new Insertion.Before(this.table,"<div id='"+this.tableId+"_viewport' style='float:left;'></div>"); - this.table.previousSibling.appendChild(this.table); - }, - - - resetContents: function() { - this.scroller.moveScroll(0); - this.buffer.clear(); - this.viewPort.clearContents(); - }, - - sortHandler: function(column) { - if(!column) return ; - this.sortCol = column.name; - this.sortDir = column.currentSort; - - this.resetContents(); - this.requestContentRefresh(0) - }, - - adjustRowSize: function() { - - }, - - setTotalRows: function( newTotalRows ) { - this.resetContents(); - this.metaData.setTotalRows(newTotalRows); - this.scroller.updateSize(); - }, - - initAjax: function(url) { - ajaxEngine.registerRequest( this.tableId + '_request', url ); - ajaxEngine.registerAjaxObject( this.tableId + '_updater', this ); - }, - - invokeAjax: function() { - }, - - handleTimedOut: function() { - //server did not respond in 4 seconds... assume that there could have been - //an error or something, and allow requests to be processed again... - this.processingRequest = null; - this.processQueuedRequest(); - }, - - fetchBuffer: function(offset) { - if ( this.buffer.isInRange(offset) && - !this.buffer.isNearingLimit(offset)) { - return; - } - if (this.processingRequest) { - this.unprocessedRequest = new Rico.LiveGridRequest(offset); - return; - } - var bufferStartPos = this.buffer.getFetchOffset(offset); - this.processingRequest = new Rico.LiveGridRequest(offset); - this.processingRequest.bufferOffset = bufferStartPos; - var fetchSize = this.buffer.getFetchSize(offset); - var partialLoaded = false; - - var queryString - if (this.options.requestParameters) - queryString = this._createQueryString(this.options.requestParameters, 0); - - queryString = (queryString == null) ? '' : queryString+'&'; - queryString = queryString+'id='+this.tableId+'&page_size='+fetchSize+'&offset='+bufferStartPos; - if (this.sortCol) - queryString = queryString+'&sort_col='+escape(this.sortCol)+'&sort_dir='+this.sortDir; - - this.ajaxOptions.parameters = queryString; - - ajaxEngine.sendRequest( this.tableId + '_request', this.ajaxOptions ); - - this.timeoutHandler = setTimeout( this.handleTimedOut.bind(this), this.options.bufferTimeout); - - }, - - setRequestParams: function() { - this.options.requestParameters = []; - for ( var i=0 ; i < arguments.length ; i++ ) - this.options.requestParameters[i] = arguments[i]; - }, - - requestContentRefresh: function(contentOffset) { - this.fetchBuffer(contentOffset); - }, - - ajaxUpdate: function(ajaxResponse) { - try { - clearTimeout( this.timeoutHandler ); - this.buffer.update(ajaxResponse,this.processingRequest.bufferOffset); - this.viewPort.bufferChanged(); - } - catch(err) {} - finally {this.processingRequest = null; } - this.processQueuedRequest(); - }, - - _createQueryString: function( theArgs, offset ) { - var queryString = "" - if (!theArgs) - return queryString; - - for ( var i = offset ; i < theArgs.length ; i++ ) { - if ( i != offset ) - queryString += "&"; - - var anArg = theArgs[i]; - - if ( anArg.name != undefined && anArg.value != undefined ) { - queryString += anArg.name + "=" + escape(anArg.value); - } - else { - var ePos = anArg.indexOf('='); - var argName = anArg.substring( 0, ePos ); - var argValue = anArg.substring( ePos + 1 ); - queryString += argName + "=" + escape(argValue); - } - } - return queryString; - }, - - processQueuedRequest: function() { - if (this.unprocessedRequest != null) { - this.requestContentRefresh(this.unprocessedRequest.requestOffset); - this.unprocessedRequest = null - } - } -}; - - -//-------------------- ricoLiveGridSort.js -Rico.LiveGridSort = Class.create(); - -Rico.LiveGridSort.prototype = { - - initialize: function(headerTableId, options) { - this.headerTableId = headerTableId; - this.headerTable = $(headerTableId); - this.options = options; - this.setOptions(); - this.applySortBehavior(); - - if ( this.options.sortCol ) { - this.setSortUI( this.options.sortCol, this.options.sortDir ); - } - }, - - setSortUI: function( columnName, sortDirection ) { - var cols = this.options.columns; - for ( var i = 0 ; i < cols.length ; i++ ) { - if ( cols[i].name == columnName ) { - this.setColumnSort(i, sortDirection); - break; - } - } - }, - - setOptions: function() { - // preload the images... - new Image().src = this.options.sortAscendImg; - new Image().src = this.options.sortDescendImg; - - this.sort = this.options.sortHandler; - if ( !this.options.columns ) - this.options.columns = this.introspectForColumnInfo(); - else { - // allow client to pass { columns: [ ["a", true], ["b", false] ] } - // and convert to an array of Rico.TableColumn objs... - this.options.columns = this.convertToTableColumns(this.options.columns); - } - }, - - applySortBehavior: function() { - var headerRow = this.headerTable.rows[0]; - var headerCells = headerRow.cells; - for ( var i = 0 ; i < headerCells.length ; i++ ) { - this.addSortBehaviorToColumn( i, headerCells[i] ); - } - }, - - addSortBehaviorToColumn: function( n, cell ) { - if ( this.options.columns[n].isSortable() ) { - cell.id = this.headerTableId + '_' + n; - cell.style.cursor = 'pointer'; - cell.onclick = this.headerCellClicked.bindAsEventListener(this); - cell.innerHTML = cell.innerHTML + '<span id="' + this.headerTableId + '_img_' + n + '">' - + ' </span>'; - } - }, - - // event handler.... - headerCellClicked: function(evt) { - var eventTarget = evt.target ? evt.target : evt.srcElement; - var cellId = eventTarget.id; - var columnNumber = parseInt(cellId.substring( cellId.lastIndexOf('_') + 1 )); - var sortedColumnIndex = this.getSortedColumnIndex(); - if ( sortedColumnIndex != -1 ) { - if ( sortedColumnIndex != columnNumber ) { - this.removeColumnSort(sortedColumnIndex); - this.setColumnSort(columnNumber, Rico.TableColumn.SORT_ASC); - } - else - this.toggleColumnSort(sortedColumnIndex); - } - else - this.setColumnSort(columnNumber, Rico.TableColumn.SORT_ASC); - - if (this.options.sortHandler) { - this.options.sortHandler(this.options.columns[columnNumber]); - } - }, - - removeColumnSort: function(n) { - this.options.columns[n].setUnsorted(); - this.setSortImage(n); - }, - - setColumnSort: function(n, direction) { - if(isNaN(n)) return ; - this.options.columns[n].setSorted(direction); - this.setSortImage(n); - }, - - toggleColumnSort: function(n) { - this.options.columns[n].toggleSort(); - this.setSortImage(n); - }, - - setSortImage: function(n) { - var sortDirection = this.options.columns[n].getSortDirection(); - - var sortImageSpan = $( this.headerTableId + '_img_' + n ); - if ( sortDirection == Rico.TableColumn.UNSORTED ) - sortImageSpan.innerHTML = ' '; - else if ( sortDirection == Rico.TableColumn.SORT_ASC ) - sortImageSpan.innerHTML = ' <img width="' + this.options.sortImageWidth + '" ' + - 'height="'+ this.options.sortImageHeight + '" ' + - 'src="' + this.options.sortAscendImg + '"/>'; - else if ( sortDirection == Rico.TableColumn.SORT_DESC ) - sortImageSpan.innerHTML = ' <img width="' + this.options.sortImageWidth + '" ' + - 'height="'+ this.options.sortImageHeight + '" ' + - 'src="' + this.options.sortDescendImg + '"/>'; - }, - - getSortedColumnIndex: function() { - var cols = this.options.columns; - for ( var i = 0 ; i < cols.length ; i++ ) { - if ( cols[i].isSorted() ) - return i; - } - - return -1; - }, - - introspectForColumnInfo: function() { - var columns = new Array(); - var headerRow = this.headerTable.rows[0]; - var headerCells = headerRow.cells; - for ( var i = 0 ; i < headerCells.length ; i++ ) - columns.push( new Rico.TableColumn( this.deriveColumnNameFromCell(headerCells[i],i), true ) ); - return columns; - }, - - convertToTableColumns: function(cols) { - var columns = new Array(); - for ( var i = 0 ; i < cols.length ; i++ ) - columns.push( new Rico.TableColumn( cols[i][0], cols[i][1] ) ); - return columns; - }, - - deriveColumnNameFromCell: function(cell,columnNumber) { - var cellContent = cell.innerText != undefined ? cell.innerText : cell.textContent; - return cellContent ? cellContent.toLowerCase().split(' ').join('_') : "col_" + columnNumber; - } -}; - -Rico.TableColumn = Class.create(); - -Rico.TableColumn.UNSORTED = 0; -Rico.TableColumn.SORT_ASC = "ASC"; -Rico.TableColumn.SORT_DESC = "DESC"; - -Rico.TableColumn.prototype = { - initialize: function(name, sortable) { - this.name = name; - this.sortable = sortable; - this.currentSort = Rico.TableColumn.UNSORTED; - }, - - isSortable: function() { - return this.sortable; - }, - - isSorted: function() { - return this.currentSort != Rico.TableColumn.UNSORTED; - }, - - getSortDirection: function() { - return this.currentSort; - }, - - toggleSort: function() { - if ( this.currentSort == Rico.TableColumn.UNSORTED || this.currentSort == Rico.TableColumn.SORT_DESC ) - this.currentSort = Rico.TableColumn.SORT_ASC; - else if ( this.currentSort == Rico.TableColumn.SORT_ASC ) - this.currentSort = Rico.TableColumn.SORT_DESC; - }, - - setUnsorted: function(direction) { - this.setSorted(Rico.TableColumn.UNSORTED); - }, - - setSorted: function(direction) { - // direction must by one of Rico.TableColumn.UNSORTED, .SORT_ASC, or .SORT_DESC... - this.currentSort = direction; - } - -}; - - -//-------------------- ricoUtil.js -var RicoUtil = { - - getElementsComputedStyle: function ( htmlElement, cssProperty, mozillaEquivalentCSS) { - if ( arguments.length == 2 ) - mozillaEquivalentCSS = cssProperty; - - var el = $(htmlElement); - if ( el.currentStyle ) - return el.currentStyle[cssProperty]; - else - return document.defaultView.getComputedStyle(el, null).getPropertyValue(mozillaEquivalentCSS); - }, - - createXmlDocument : function() { - if (document.implementation && document.implementation.createDocument) { - var doc = document.implementation.createDocument("", "", null); - - if (doc.readyState == null) { - doc.readyState = 1; - doc.addEventListener("load", function () { - doc.readyState = 4; - if (typeof doc.onreadystatechange == "function") - doc.onreadystatechange(); - }, false); - } - - return doc; - } - - if (window.ActiveXObject) - return Try.these( - function() { return new ActiveXObject('MSXML2.DomDocument') }, - function() { return new ActiveXObject('Microsoft.DomDocument')}, - function() { return new ActiveXObject('MSXML.DomDocument') }, - function() { return new ActiveXObject('MSXML3.DomDocument') } - ) || false; - - return null; - }, - - getContentAsString: function( parentNode ) { - return parentNode.xml != undefined ? - this._getContentAsStringIE(parentNode) : - this._getContentAsStringMozilla(parentNode); - }, - - _getContentAsStringIE: function(parentNode) { - var contentStr = ""; - for ( var i = 0 ; i < parentNode.childNodes.length ; i++ ) { - var n = parentNode.childNodes[i]; - if (n.nodeType == 4) { - contentStr += n.nodeValue; - } - else { - contentStr += n.xml; - } - } - return contentStr; - }, - - _getContentAsStringMozilla: function(parentNode) { - var xmlSerializer = new XMLSerializer(); - var contentStr = ""; - for ( var i = 0 ; i < parentNode.childNodes.length ; i++ ) { - var n = parentNode.childNodes[i]; - if (n.nodeType == 4) { // CDATA node - contentStr += n.nodeValue; - } - else { - contentStr += xmlSerializer.serializeToString(n); - } - } - return contentStr; - }, - - toViewportPosition: function(element) { - return this._toAbsolute(element,true); - }, - - toDocumentPosition: function(element) { - return this._toAbsolute(element,false); - }, - - /** - * Compute the elements position in terms of the window viewport - * so that it can be compared to the position of the mouse (dnd) - * This is additions of all the offsetTop,offsetLeft values up the - * offsetParent hierarchy, ...taking into account any scrollTop, - * scrollLeft values along the way... - * - * IE has a bug reporting a correct offsetLeft of elements within a - * a relatively positioned parent!!! - **/ - _toAbsolute: function(element,accountForDocScroll) { - - if ( navigator.userAgent.toLowerCase().indexOf("msie") == -1 ) - return this._toAbsoluteMozilla(element,accountForDocScroll); - - var x = 0; - var y = 0; - var parent = element; - while ( parent ) { - - var borderXOffset = 0; - var borderYOffset = 0; - if ( parent != element ) { - var borderXOffset = parseInt(this.getElementsComputedStyle(parent, "borderLeftWidth" )); - var borderYOffset = parseInt(this.getElementsComputedStyle(parent, "borderTopWidth" )); - borderXOffset = isNaN(borderXOffset) ? 0 : borderXOffset; - borderYOffset = isNaN(borderYOffset) ? 0 : borderYOffset; - } - - x += parent.offsetLeft - parent.scrollLeft + borderXOffset; - y += parent.offsetTop - parent.scrollTop + borderYOffset; - parent = parent.offsetParent; - } - - if ( accountForDocScroll ) { - x -= this.docScrollLeft(); - y -= this.docScrollTop(); - } - - return { x:x, y:y }; - }, - - /** - * Mozilla did not report all of the parents up the hierarchy via the - * offsetParent property that IE did. So for the calculation of the - * offsets we use the offsetParent property, but for the calculation of - * the scrollTop/scrollLeft adjustments we navigate up via the parentNode - * property instead so as to get the scroll offsets... - * - **/ - _toAbsoluteMozilla: function(element,accountForDocScroll) { - var x = 0; - var y = 0; - var parent = element; - while ( parent ) { - x += parent.offsetLeft; - y += parent.offsetTop; - parent = parent.offsetParent; - } - - parent = element; - while ( parent && - parent != document.body && - parent != document.documentElement ) { - if ( parent.scrollLeft ) - x -= parent.scrollLeft; - if ( parent.scrollTop ) - y -= parent.scrollTop; - parent = parent.parentNode; - } - - if ( accountForDocScroll ) { - x -= this.docScrollLeft(); - y -= this.docScrollTop(); - } - - return { x:x, y:y }; - }, - - docScrollLeft: function() { - if ( window.pageXOffset ) - return window.pageXOffset; - 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; - } - -}; diff --git a/javascript/libs/tabpane.js b/javascript/libs/tabpane.js deleted file mode 100644 index e4e1456..0000000 --- a/javascript/libs/tabpane.js +++ /dev/null @@ -1,383 +0,0 @@ -// $Header: /cvsroot/bitweaver/_bit_util/javascript/libs/tabpane.js,v 1.22 2010/05/13 23:38:40 spiderr Exp $ - -//------------------------------------------------------------------------- -// Tab Pane 1.02 -//------------------------------------------------------------------------- -// Created by Erik Arvidsson -// (http://webfx.eae.net/contact.html#erik) -// For WebFX (http://webfx.eae.net/) -//------------------------------------------------------------------------- -// Copyright (c) 1998 - 2003 Erik Arvidsson -//------------------------------------------------------------------------- - -// please modify this file and leave plenty of comments. This file will be -// compressed automatically. Please make sure you only use comments beginning -// with '//' and put comments on separate lines otherwise the packer will choke - -// Called to cause an FCKEditor to show. This fixes an incompatibility with -// tab pane and FCKEditor in Gecko browsers where the FCKEditor is created -// in a hidden tab. The editor fails to get focused without this. - -// see http://webfx.eae.net/dhtml/tabpane/tabpane.html for details - -function switchEditors(oNode) { - var i=0; - // We use this to avoid the error when this runs BEFORE - // FKCEditor has created the API object. - if (document.FCKEditorLoaded) { - for (i=0;i<oNode.childNodes.length;i++) { - childNode = oNode.childNodes.item(i); - editor = FCKeditorAPI.GetInstance(childNode.name); - if (editor && editor.EditorDocument && editor.EditMode == FCK_EDITMODE_WYSIWYG) { - editor.SwitchEditMode(); - editor.SwitchEditMode(); - } - switchEditors(childNode); - } - } -} - -// This function is used to define if the browser supports the needed -// features -function hasSupport() { - - if (typeof hasSupport.support != "undefined") { - return hasSupport.support; - } - - var ie55 = /msie 5\.[56789]/i.test( navigator.userAgent ); - - hasSupport.support = ( typeof document.implementation != "undefined" && document.implementation.hasFeature( "html", "1.0" ) || ie55 ); - - // IE55 has a serious DOM1 bug... Patch it! - if ( ie55 ) { - document._getElementsByTagName = document.getElementsByTagName; - document.getElementsByTagName = function ( sTagName ) { - if ( sTagName == "*" ) { - return document.all; - } else { - return document._getElementsByTagName( sTagName ); - } - }; - } - - return hasSupport.support; -} - - -// The constructor for tab panes -// el : HTMLElement The html element used to represent the tab pane -// bUseCookie : Boolean Optional. Default is true. Used to determine whether to us -// persistance using cookies or not - -function WebFXTabPane( el, bUseCookie ) { - if ( !hasSupport() || el == null ) { return; } - - this.element = el; - this.element.tabPane = this; - this.pages = []; - this.selectedIndex = null; - - this.useCookie = bUseCookie != null ? bUseCookie : true; - - // <--- quick hack to set persistence only on pages where referrer == location - var ref = document.referrer.split( /[#\?]/ ); - var loc = document.location.href.split( /[#\?]/ ); - if( loc[0] != ref[0] ) { - this.useCookie = false; - } - // end quick hack - xing ---> - - // add class name tag to class name - this.element.className = this.classNameTag + " " + this.element.className; - - // add tab row - this.tabRow = document.createElement( "div" ); - this.tabRow.className = "tabcontainer"; - el.insertBefore( this.tabRow, el.firstChild ); - - // loop through child nodes and add them - var cs = el.childNodes; - var n; - for (var i = 0; i < cs.length; i++) { - if (cs[i].nodeType == 1 && ( cs[i].className == "tabpage" || cs[i].className.substr(0,8) == "tabpage ") ) { - this.addTabPage( cs[i] ); - } - } - - var tabIndex = 0; - if ( this.useCookie ) { - tabIndex = Number( WebFXTabPane.getCookie( "webfxtab_" + this.element.id ) ); - if ( isNaN( tabIndex ) || !this.pages[ tabIndex ] ) { - tabIndex = 0; - } - } - this.setSelectedIndex( tabIndex ); -} - -WebFXTabPane.prototype.classNameTag = "tabsystem"; - -WebFXTabPane.prototype.setSelectedIndex = function ( n ) { - if (this.selectedIndex != n) { - if (this.selectedIndex != null && this.pages[ this.selectedIndex ] != null ) { - this.pages[ this.selectedIndex ].hide(); - } - this.selectedIndex = n; - if( this.pages[ this.selectedIndex ] != undefined ) { - this.pages[ this.selectedIndex ].show(); - } - - if ( this.useCookie ) { - WebFXTabPane.setCookie( "webfxtab_" + this.element.id, n, 1 ); - } - } -}; - -WebFXTabPane.prototype.getSelectedIndex = function () { - return this.selectedIndex; -}; - -WebFXTabPane.prototype.addTabPage = function ( oElement ) { - if ( !hasSupport() ) { return; } - - if ( oElement.tabPage == this ) { - return oElement.tabPage; - } - - var n = this.pages.length; - var tp = this.pages[n] = new WebFXTabPage( oElement, this, n ); - tp.tabPane = this; - - // move the tab out of the box - this.tabRow.appendChild( tp.tab ); - - if ( n == this.selectedIndex ) { - tp.show(); - } else { - tp.hide(); - } - - return tp; -}; - -WebFXTabPane.prototype.dispose = function () { - this.element.tabPane = null; - this.element = null; - this.tabRow = null; - - for (var i = 0; i < this.pages.length; i++) { - this.pages[i].dispose(); - this.pages[i] = null; - } - this.pages = null; -}; - - - -// Cookie handling -WebFXTabPane.setCookie = function ( sName, sValue, nDays ) { - var expires = ""; - if ( nDays ) { - var d = new Date(); - d.setTime( d.getTime() + nDays * 24 * 60 * 60 * 1000 ); - expires = "; expires=" + d.toGMTString(); - } - - document.cookie = sName + "=" + sValue + expires + "; path="+bitCookiePath; -}; - -WebFXTabPane.getCookie = function (sName) { - var re = new RegExp( "(\;|^)[^;]*(" + sName + ")\=([^;]*)(;|$)" ); - var res = re.exec( document.cookie ); - return res != null ? res[3] : null; -}; - -WebFXTabPane.removeCookie = function ( name ) { - setCookie( name, "", -1 ); -}; - - -// The constructor for tab pages. This one should not be used. -// Use WebFXTabPage.addTabPage instead -// el : HTMLElement The html element used to represent the tab pane -// tabPane : WebFXTabPane The parent tab pane -// nindex : Number The index of the page in the parent pane page array - -function WebFXTabPage( el, tabPane, nIndex ) { - if ( !hasSupport() || el == null ) { return; } - - this.element = el; - this.element.tabPage = this; - this.index = nIndex; - - var cs = el.childNodes; - for (var i = 0; i < cs.length; i++) { - if (cs[i].nodeType == 1 && ( cs[i].className == "tab" || cs[i].className.substr(0,4) == "tab ") ) { - this.tab = cs[i]; - break; - } - } - - // insert a tag around content to support keyboard navigation - - - var a = document.createElement( "A" ); - this.aElement = a; - a.href = "#"; - a.onclick = function () { return false; }; - while ( this.tab.hasChildNodes() ) { - a.appendChild( this.tab.firstChild ); - } - this.tab.appendChild( a ); - - - // hook up events, using DOM0 - var oThis = this; - // we can bind a custom onclick event to the tab by passing one in - this lets us associate additional events with the click of a tab -wjames5 - var oldOnclick = this.tab.onclick != null? this.tab.onclick:function(){}; - this.tab.onclick = function () { oThis.select(); oldOnclick(); }; - this.tab.onmouseover = function () { WebFXTabPage.tabOver( oThis ); }; - this.tab.onmouseout = function () { WebFXTabPage.tabOut( oThis ); }; -} - -WebFXTabPage.prototype.show = function () { - var el = this.tab; - var s = el.className + " tab-active"; - s = s.replace(/ +/g, " "); - el.className = s; - - // Fix for FCKEditor focus bug - switchEditors(this.element); - this.element.style.display = "block"; -}; - -WebFXTabPage.prototype.hide = function () { - var el = this.tab; - var s = el.className; - // Packer doesn't like \- in regexp for some reason - s = s.replace(/ tab.active/g, ""); - el.className = s; - - this.element.style.display = "none"; -}; - -WebFXTabPage.prototype.select = function () { - this.tabPane.setSelectedIndex( this.index ); -}; - -WebFXTabPage.prototype.dispose = function () { - // Safari only submits inputs which are not display:none - // I suspect this is for "security" but that is stupid since we - // can still hide it off screen like this. - var safari = /^Apple/; - // note the crazy 'unknown' check here. this is for IE (of course) whoes xmlhtml is not part of the js engine and willy nilly throws in crap outside the spec. - if (this.element.style.display == "none" && typeof( navigator.vendor ) != "unknown" && navigator.vendor == safari) { - this.element.style.position = "absolute"; - this.element.style.left = "-10000px"; - this.element.style.display = "block"; - } - this.aElement.onclick = null; - this.aElement = null; - this.element.tabPage = null; - this.tab.onclick = null; - this.tab.onmouseover = null; - this.tab.onmouseout = null; - this.tab = null; - this.tabPane = null; - this.element = null; -}; - -WebFXTabPage.tabOver = function ( tabpage ) { - var el = tabpage.tab; - var s = el.className + " tab-hover"; - s = s.replace(/ +/g, " "); - el.className = s; -}; - -WebFXTabPage.tabOut = function ( tabpage ) { - var el = tabpage.tab; - var s = el.className; - // Packer doesn't like \- in regexp for some reason - s = s.replace(/ tab.hover/g, ""); - el.className = s; -}; - - -// This function initializes all uninitialized tab panes and tab pages -function setupAllTabs() { - if ( !hasSupport() ) { return; } - - var all = document.getElementsByTagName( "*" ); - var l = all.length; - var tabPaneRe = /tabpane/; - var tabPageRe = /tabpage/; - var cn, el; - var parentTabPane; - - for ( var i = 0; i < l; i++ ) { - el = all[i]; - cn = el.className; - - // no className - if ( cn == "" ) { continue; } - - // uninitiated tab pane - if ( tabPaneRe.test( cn ) && !el.tabPane ) { - new WebFXTabPane( el ); - } - - // unitiated tab page wit a valid tab pane parent - else if ( tabPageRe.test( cn ) && !el.tabPage && tabPaneRe.test( el.parentNode.className ) ) { - el.parentNode.tabPane.addTabPage( el ); - } - } -} - -function disposeAllTabs() { - if ( !hasSupport() ) { return; } - - var all = document.getElementsByTagName( "*" ); - var l = all.length; - var tabPaneRe = /tabpane/; - var cn, el; - var tabPanes = []; - - for ( var i = 0; i < l; i++ ) { - el = all[i]; - cn = el.className; - - // no className - if ( cn == "" ) { continue; } - - // tab pane - if ( tabPaneRe.test( cn ) && el.tabPane ) { - tabPanes[tabPanes.length] = el.tabPane; - } - } - - for (var i = tabPanes.length - 1; i >= 0; i--) { - tabPanes[i].dispose(); - tabPanes[i] = null; - } -} - - -// initialization hook up - -// DOM2 -if ( typeof window.addEventListener != "undefined" ) { - window.addEventListener( "load", setupAllTabs, false ); -} else if ( typeof window.attachEvent != "undefined" ) { - window.attachEvent( "onload", setupAllTabs ); - window.attachEvent( "onunload", disposeAllTabs ); -} else { - if ( window.onload != null ) { - var oldOnload = window.onload; - window.onload = function ( e ) { - oldOnload( e ); - setupAllTabs(); - }; - } else { - window.onload = setupAllTabs; - } -} |
