- stop: function(){
- if (this.overed && !this.out) this.overed.fireEvent('drop', [this.element, this]);
- else this.element.fireEvent('emptydrop', this);
- this.parent();
- return this;
- }
-
-});
-
-/*
-Class: Element
- Custom class to allow all of its methods to be used with any DOM element via the dollar function <$>.
-*/
-
-Element.extend({
-
- /*
- Property: makeDraggable
- Makes an element draggable with the supplied options.
-
- Arguments:
- options - see <Drag.Move> and <Drag.Base> for acceptable options.
- */
-
- makeDraggable: function(options){
- return new Drag.Move(this, options);
- }
-
-});
-
-/*
-Script: XHR.js
- Contains the basic XMLHttpRequest Class Wrapper.
-
-License:
- MIT-style license.
-*/
-
-/*
-Class: XHR
- Basic XMLHttpRequest Wrapper.
-
-Arguments:
- options - an object with options names as keys. See options below.
-
-Options:
- method - 'post' or 'get' - the protocol for the request; optional, defaults to 'post'.
- async - boolean: asynchronous option; true uses asynchronous requests. Defaults to true.
- encoding - the encoding, defaults to utf-8.
- autoCancel - cancels the already running request if another one is sent. defaults to false.
- headers - accepts an object, that will be set to request headers.
-
-Events:
- onRequest - function to execute when the XHR request is fired.
- onSuccess - function to execute when the XHR request completes.
- onStateChange - function to execute when the state of the XMLHttpRequest changes.
- onFailure - function to execute when the state of the XMLHttpRequest changes.
-
-Properties:
- running - true if the request is running.
- response - object, text and xml as keys. You can access this property in the onSuccess event.
-
-Example:
- >var myXHR = new XHR({method: 'get'}).send('http://site.com/requestHandler.php', 'name=john&lastname=dorian');
-*/
-
-var XHR = new Class({
-
- options: {
- method: 'post',
- async: true,
- onRequest: Class.empty,
- onSuccess: Class.empty,
- onFailure: Class.empty,
- urlEncoded: true,
- encoding: 'utf-8',
- autoCancel: false,
- headers: {}
- },
-
- setTransport: function(){
- this.transport = (window.XMLHttpRequest) ? new XMLHttpRequest() : (window.ie ? new ActiveXObject('Microsoft.XMLHTTP') : false);
- return this;
- },
-
- initialize: function(options){
- this.setTransport().setOptions(options);
- this.options.isSuccess = this.options.isSuccess || this.isSuccess;
- this.headers = {};
- if (this.options.urlEncoded && this.options.method == 'post'){
- var encoding = (this.options.encoding) ? '; charset=' + this.options.encoding : '';
- this.setHeader('Content-type', 'application/x-www-form-urlencoded' + encoding);
- }
- if (this.options.initialize) this.options.initialize.call(this);
- },
-
- onStateChange: function(){
- if (this.transport.readyState != 4 || !this.running) return;
- this.running = false;
- var status = 0;
- try {status = this.transport.status;} catch(e){};
- if (this.options.isSuccess.call(this, status)) this.onSuccess();
- else this.onFailure();
- this.transport.onreadystatechange = Class.empty;
- },
-
- isSuccess: function(status){
- return ((status >= 200) && (status < 300));
- },
-
- onSuccess: function(){
- this.response = {
- 'text': this.transport.responseText,
- 'xml': this.transport.responseXML
- };
- this.fireEvent('onSuccess', [this.response.text, this.response.xml]);
- this.callChain();
- },
-
- onFailure: function(){
- this.fireEvent('onFailure', this.transport);
- },
-
- /*
- Property: setHeader
- Add/modify an header for the request. It will not override headers from the options.
-
- Example:
- >var myXhr = new XHR(url, {method: 'get', headers: {'X-Request': 'JSON'}});
- >myXhr.setHeader('Last-Modified','Sat, 1 Jan 2005 05:00:00 GMT');
- */
-
- setHeader: function(name, value){
- this.headers[name] = value;
- return this;
- },
-
- /*
- Property: send
- Opens the XHR connection and sends the data. Data has to be null or a string.
-
- Example:
- >var myXhr = new XHR({method: 'post'});
- >myXhr.send(url, querystring);
- >
- >var syncXhr = new XHR({async: false, method: 'post'});
- >syncXhr.send(url, null);
- >
- */
-
- send: function(url, data){
- if (this.options.autoCancel) this.cancel();
- else if (this.running) return this;
- this.running = true;
- if (data && this.options.method == 'get'){
- url = url + (url.contains('?') ? '&' : '?') + data;
- data = null;
- }
- this.transport.open(this.options.method.toUpperCase(), url, this.options.async);
- this.transport.onreadystatechange = this.onStateChange.bind(this);
- if ((this.options.method == 'post') && this.transport.overrideMimeType) this.setHeader('Connection', 'close');
- $extend(this.headers, this.options.headers);
- for (var type in this.headers) try {this.transport.setRequestHeader(type, this.headers[type]);} catch(e){};
- this.fireEvent('onRequest');
- this.transport.send($pick(data, null));
- return this;
- },
-
- /*
- Property: cancel
- Cancels the running request. No effect if the request is not running.
-
- Example:
- >var myXhr = new XHR({method: 'get'}).send(url);
- >myXhr.cancel();
- */
-
- cancel: function(){
- if (!this.running) return this;
- this.running = false;
- this.transport.abort();
- this.transport.onreadystatechange = Class.empty;
- this.setTransport();
- this.fireEvent('onCancel');
- return this;
- }
-
-});
-
-XHR.implement(new Chain, new Events, new Options);
-
-/*
-Script: Ajax.js
- Contains the <Ajax> class. Also contains methods to generate querystings from forms and Objects.
-
-Credits:
- Loosely based on the version from prototype.js <http://prototype.conio.net>
-
-License:
- MIT-style license.
-*/
-
-/*
-Class: Ajax
- An Ajax class, For all your asynchronous needs.
- Inherits methods, properties, options and events from <XHR>.
-
-Arguments:
- url - the url pointing to the server-side script.
- options - optional, an object containing options.
-
-Options:
- data - you can write parameters here. Can be a querystring, an object or a Form element.
- update - $(element) to insert the response text of the XHR into, upon completion of the request.
- evalScripts - boolean; default is false. Execute scripts in the response text onComplete. When the response is javascript the whole response is evaluated.
- evalResponse - boolean; default is false. Force global evalulation of the whole response, no matter what content-type it is.
-
-Events:
- onComplete - function to execute when the ajax request completes.
-
-Example:
- >var myAjax = new Ajax(url, {method: 'get'}).request();
-*/
-
-var Ajax = XHR.extend({
-
- options: {
- data: null,
- update: null,
- onComplete: Class.empty,
- evalScripts: false,
- evalResponse: false
- },
-
- initialize: function(url, options){
- this.addEvent('onSuccess', this.onComplete);
- this.setOptions(options);
- /*compatibility*/
- this.options.data = this.options.data || this.options.postBody;
- /*end compatibility*/
- if (!['post', 'get'].contains(this.options.method)){
- this._method = '_method=' + this.options.method;
- this.options.method = 'post';
- }
- this.parent();
- this.setHeader('X-Requested-With', 'XMLHttpRequest');
- this.setHeader('Accept', 'text/javascript, text/html, application/xml, text/xml, */*');
- this.url = url;
- },
-
- onComplete: function(){
- if (this.options.update) $(this.options.update).empty().setHTML(this.response.text);
- if (this.options.evalScripts || this.options.evalResponse) this.evalScripts();
- this.fireEvent('onComplete', [this.response.text, this.response.xml], 20);
- },
-
- /*
- Property: request
- Executes the ajax request.
-
- Example:
- >var myAjax = new Ajax(url, {method: 'get'});
- >myAjax.request();
-
- OR
-
- >new Ajax(url, {method: 'get'}).request();
- */
-
- request: function(data){
- data = data || this.options.data;
- switch($type(data)){
- case 'element': data = $(data).toQueryString(); break;
- case 'object': data = Object.toQueryString(data);
- }
- if (this._method) data = (data) ? [this._method, data].join('&') : this._method;
- return this.send(this.url, data);
- },
-
- /*
- Property: evalScripts
- Executes scripts in the response text
- */
-
- evalScripts: function(){
- var script, scripts;
- if (this.options.evalResponse || (/(ecma|java)script/).test(this.getHeader('Content-type'))) scripts = this.response.text;
- else {
- scripts = [];
- var regexp = /<script[^>]*>([\s\S]*?)<\/script>/gi;
- while ((script = regexp.exec(this.response.text))) scripts.push(script[1]);
- scripts = scripts.join('\n');
- }
- if (scripts) (window.execScript) ? window.execScript(scripts) : window.setTimeout(scripts, 0);
- },
-
- /*
- Property: getHeader
- Returns the given response header or null
- */
-
- getHeader: function(name){
- try {return this.transport.getResponseHeader(name);} catch(e){};
- return null;
- }
-
-});
-
-/* Section: Object related Functions */
-
-/*
-Function: Object.toQueryString
- Generates a querystring from key/pair values in an object
-
-Arguments:
- source - the object to generate the querystring from.
-
-Returns:
- the query string.
-
-Example:
- >Object.toQueryString({apple: "red", lemon: "yellow"}); //returns "apple=red&lemon=yellow"
-*/
-
-Object.toQueryString = function(source){
- var queryString = [];
- for (var property in source) queryString.push(encodeURIComponent(property) + '=' + encodeURIComponent(source[property]));
- return queryString.join('&');
-};
-
-/*
-Class: Element
- Custom class to allow all of its methods to be used with any DOM element via the dollar function <$>.
-*/
-
-Element.extend({
-
- /*
- Property: send
- Sends a form with an ajax post request
-
- Arguments:
- options - option collection for ajax request. See <Ajax> for the options list.
-
- Returns:
- The Ajax Class Instance
-
- Example:
- (start code)
- <form id="myForm" action="submit.php">
- <input name="email" value="bob@bob.com">
- <input name="zipCode" value="90210">
- </form>
- <script>
- $('myForm').send()
- </script>
- (end)
- */
-
- send: function(options){
- return new Ajax(this.getProperty('action'), $merge({data: this.toQueryString()}, options, {method: 'post'})).request();
- }
-
-});
-
-/*
-Script: Cookie.js
- A cookie reader/creator
-
-Credits:
- based on the functions by Peter-Paul Koch (http://quirksmode.org)
-*/
-
-/*
-Class: Cookie
- Class for creating, getting, and removing cookies.
-*/
-
-var Cookie = new Abstract({
-
- options: {
- domain: false,
- path: false,
- duration: false,
- secure: false
- },
-
- /*
- Property: set
- Sets a cookie in the browser.
-
- Arguments:
- key - the key (name) for the cookie
- value - the value to set, cannot contain semicolons
- options - an object representing the Cookie options. See Options below. Default values are stored in Cookie.options.
-
- Options:
- domain - the domain the Cookie belongs to. If you want to share the cookie with pages located on a different domain, you have to set this value. Defaults to the current domain.
- path - the path the Cookie belongs to. If you want to share the cookie with pages located in a different path, you have to set this value, for example to "/" to share the cookie with all pages on the domain. Defaults to the current path.
- duration - the duration of the Cookie before it expires, in days.
- If set to false or 0, the cookie will be a session cookie that expires when the browser is closed. This is default.
- secure - Stored cookie information can be accessed only from a secure environment.
-
- Returns:
- An object with the options, the key and the value. You can give it as first parameter to Cookie.remove.
-
- Example:
- >Cookie.set('username', 'Harald'); // session cookie (duration is false), or ...
- >Cookie.set('username', 'JackBauer', {duration: 1}); // save this for 1 day
-
- */
-
- set: function(key, value, options){
- options = $merge(this.options, options);
- value = encodeURIComponent(value);
- if (options.domain) value += '; domain=' + options.domain;
- if (options.path) value += '; path=' + options.path;
- if (options.duration){
- var date = new Date();
- date.setTime(date.getTime() + options.duration * 24 * 60 * 60 * 1000);
- value += '; expires=' + date.toGMTString();
- }
- if (options.secure) value += '; secure';
- document.cookie = key + '=' + value;
- return $extend(options, {'key': key, 'value': value});
- },
-
- /*
- Property: get
- Gets the value of a cookie.
-
- Arguments:
- key - the name of the cookie you wish to retrieve.
-
- Returns:
- The cookie string value, or false if not found.
-
- Example:
- >Cookie.get("username") //returns JackBauer
- */
-
- get: function(key){
- var value = document.cookie.match('(?:^|;)\\s*' + key.escapeRegExp() + '=([^;]*)');
- return value ? decodeURIComponent(value[1]) : false;
- },
-
- /*
- Property: remove
- Removes a cookie from the browser.
-
- Arguments:
- cookie - the name of the cookie to remove or a previous cookie (for domains)
- options - optional. you can also pass the domain and path here. Same as options in <Cookie.set>
-
- Examples:
- >Cookie.remove('username') //bye-bye JackBauer, cya in 24 hours
- >
- >var myCookie = Cookie.set('username', 'Aaron', {domain: 'mootools.net'}); // Cookie.set returns an object with all values need to remove the cookie
- >Cookie.remove(myCookie);
- */
-
- remove: function(cookie, options){
- if ($type(cookie) == 'object') this.set(cookie.key, '', $merge(cookie, {duration: -1}));
- else this.set(cookie, '', $merge(options, {duration: -1}));
- }
-
-});
-
-/*
-Script: Json.js
- Simple Json parser and Stringyfier, See: <http://www.json.org/>
-
-License:
- MIT-style license.
-*/
-
-/*
-Class: Json
- Simple Json parser and Stringyfier, See: <http://www.json.org/>
-*/
-
-var Json = {
-
- /*
- Property: toString
- Converts an object to a string, to be passed in server-side scripts as a parameter. Although its not normal usage for this class, this method can also be used to convert functions and arrays to strings.
-
- Arguments:
- obj - the object to convert to string
-
- Returns:
- A json string
-
- Example:
- (start code)
- Json.toString({apple: 'red', lemon: 'yellow'}); '{"apple":"red","lemon":"yellow"}'
- (end)
- */
-
- toString: function(obj){
- switch($type(obj)){
- case 'string':
- return '"' + obj.replace(/(["\\])/g, '\\$1') + '"';
- case 'array':
- return '[' + obj.map(Json.toString).join(',') + ']';
- case 'object':
- var string = [];
- for (var property in obj) string.push(Json.toString(property) + ':' + Json.toString(obj[property]));
- return '{' + string.join(',') + '}';
- case 'number':
- if (isFinite(obj)) break;
- case false:
- return 'null';
- }
- return String(obj);
- },
-
- /*
- Property: evaluate
- converts a json string to an javascript Object.
-
- Arguments:
- str - the string to evaluate. if its not a string, it returns false.
- secure - optionally, performs syntax check on json string. Defaults to false.
-
- Credits:
- Json test regexp is by Douglas Crockford <http://crockford.org>.
-
- Example:
- >var myObject = Json.evaluate('{"apple":"red","lemon":"yellow"}');
- >//myObject will become {apple: 'red', lemon: 'yellow'}
- */
-
- evaluate: function(str, secure){
- return (($type(str) != 'string') || (secure && !str.test(/^("(\\.|[^"\\\n\r])*?"|[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t])+?$/))) ? null : eval('(' + str + ')');
- }
-
-};
-
-/*
-Script: Json.Remote.js
- Contains <Json.Remote>.
-
-License:
- MIT-style license.
-*/
-
-/*
-Class: Json.Remote
- Wrapped XHR with automated sending and receiving of Javascript Objects in Json Format.
- Inherits methods, properties, options and events from <XHR>.
-
-Arguments:
- url - the url you want to send your object to.
- options - see <XHR> options
-
-Example:
- this code will send user information based on name/last name
- (start code)
- var jSonRequest = new Json.Remote("http://site.com/tellMeAge.php", {onComplete: function(person){
- alert(person.age); //is 25 years
- alert(person.height); //is 170 cm
- alert(person.weight); //is 120 kg
- }}).send({'name': 'John', 'lastName': 'Doe'});
- (end)
-*/
-
-Json.Remote = XHR.extend({
-
- initialize: function(url, options){
- this.url = url;
- this.addEvent('onSuccess', this.onComplete);
- this.parent(options);
- this.setHeader('X-Request', 'JSON');
- },
-
- send: function(obj){
- return this.parent(this.url, 'json=' + Json.toString(obj));
- },
-
- onComplete: function(){
- this.fireEvent('onComplete', [Json.evaluate(this.response.text, this.options.secure)]);
- }
-
-});
-
-/*
-Script: Assets.js
- provides dynamic loading for images, css and javascript files.
-
-License:
- MIT-style license.
-*/
-
-var Asset = new Abstract({
-
- /*
- Property: javascript
- Injects a javascript file in the page.
-
- Arguments:
- source - the path of the javascript file
- properties - some additional attributes you might want to add to the script element
-
- Example:
- > new Asset.javascript('/scripts/myScript.js', {id: 'myScript'});
- */
-
- javascript: function(source, properties){
- properties = $merge({
- 'onload': Class.empty
- }, properties);
- var script = new Element('script', {'src': source}).addEvents({
- 'load': properties.onload,
- 'readystatechange': function(){
- if (this.readyState == 'complete') this.fireEvent('load');