web/static/admin/js/jquery.js
author wakimd
Tue, 16 Nov 2010 14:15:07 +0100
changeset 9 22ab430e9b64
permissions -rw-r--r--
Corrections on models and general structure
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
9
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     1
/*!
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     2
 * jQuery JavaScript Library v1.4.2
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     3
 * http://jquery.com/
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     4
 *
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     5
 * Copyright 2010, John Resig
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     6
 * Dual licensed under the MIT or GPL Version 2 licenses.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     7
 * http://jquery.org/license
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     8
 *
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
     9
 * Includes Sizzle.js
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    10
 * http://sizzlejs.com/
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    11
 * Copyright 2010, The Dojo Foundation
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    12
 * Released under the MIT, BSD, and GPL Licenses.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    13
 *
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    14
 * Date: Sat Feb 13 22:33:48 2010 -0500
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    15
 */
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    16
(function( window, undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    17
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    18
// Define a local copy of jQuery
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    19
var jQuery = function( selector, context ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    20
		// The jQuery object is actually just the init constructor 'enhanced'
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    21
		return new jQuery.fn.init( selector, context );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    22
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    23
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    24
	// Map over jQuery in case of overwrite
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    25
	_jQuery = window.jQuery,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    26
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    27
	// Map over the $ in case of overwrite
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    28
	_$ = window.$,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    29
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    30
	// Use the correct document accordingly with window argument (sandbox)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    31
	document = window.document,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    32
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    33
	// A central reference to the root jQuery(document)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    34
	rootjQuery,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    35
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    36
	// A simple way to check for HTML strings or ID strings
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    37
	// (both of which we optimize for)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    38
	quickExpr = /^[^<]*(<[\w\W]+>)[^>]*$|^#([\w-]+)$/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    39
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    40
	// Is it a simple selector
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    41
	isSimple = /^.[^:#\[\.,]*$/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    42
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    43
	// Check if a string has a non-whitespace character in it
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    44
	rnotwhite = /\S/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    45
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    46
	// Used for trimming whitespace
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    47
	rtrim = /^(\s|\u00A0)+|(\s|\u00A0)+$/g,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    48
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    49
	// Match a standalone tag
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    50
	rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    51
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    52
	// Keep a UserAgent string for use with jQuery.browser
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    53
	userAgent = navigator.userAgent,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    54
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    55
	// For matching the engine and version of the browser
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    56
	browserMatch,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    57
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    58
	// Has the ready events already been bound?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    59
	readyBound = false,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    60
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    61
	// The functions to execute on DOM ready
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    62
	readyList = [],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    63
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    64
	// The ready event handler
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    65
	DOMContentLoaded,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    66
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    67
	// Save a reference to some core methods
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    68
	toString = Object.prototype.toString,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    69
	hasOwnProperty = Object.prototype.hasOwnProperty,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    70
	push = Array.prototype.push,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    71
	slice = Array.prototype.slice,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    72
	indexOf = Array.prototype.indexOf;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    73
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    74
jQuery.fn = jQuery.prototype = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    75
	init: function( selector, context ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    76
		var match, elem, ret, doc;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    77
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    78
		// Handle $(""), $(null), or $(undefined)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    79
		if ( !selector ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    80
			return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    81
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    82
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    83
		// Handle $(DOMElement)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    84
		if ( selector.nodeType ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    85
			this.context = this[0] = selector;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    86
			this.length = 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    87
			return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    88
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    89
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    90
		// The body element only exists once, optimize finding it
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    91
		if ( selector === "body" && !context ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    92
			this.context = document;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    93
			this[0] = document.body;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    94
			this.selector = "body";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    95
			this.length = 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    96
			return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    97
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    98
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
    99
		// Handle HTML strings
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   100
		if ( typeof selector === "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   101
			// Are we dealing with HTML string or an ID?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   102
			match = quickExpr.exec( selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   103
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   104
			// Verify a match, and that no context was specified for #id
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   105
			if ( match && (match[1] || !context) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   106
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   107
				// HANDLE: $(html) -> $(array)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   108
				if ( match[1] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   109
					doc = (context ? context.ownerDocument || context : document);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   110
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   111
					// If a single string is passed in and it's a single tag
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   112
					// just do a createElement and skip the rest
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   113
					ret = rsingleTag.exec( selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   114
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   115
					if ( ret ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   116
						if ( jQuery.isPlainObject( context ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   117
							selector = [ document.createElement( ret[1] ) ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   118
							jQuery.fn.attr.call( selector, context, true );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   119
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   120
						} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   121
							selector = [ doc.createElement( ret[1] ) ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   122
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   123
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   124
					} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   125
						ret = buildFragment( [ match[1] ], [ doc ] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   126
						selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   127
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   128
					
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   129
					return jQuery.merge( this, selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   130
					
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   131
				// HANDLE: $("#id")
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   132
				} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   133
					elem = document.getElementById( match[2] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   134
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   135
					if ( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   136
						// Handle the case where IE and Opera return items
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   137
						// by name instead of ID
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   138
						if ( elem.id !== match[2] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   139
							return rootjQuery.find( selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   140
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   141
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   142
						// Otherwise, we inject the element directly into the jQuery object
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   143
						this.length = 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   144
						this[0] = elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   145
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   146
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   147
					this.context = document;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   148
					this.selector = selector;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   149
					return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   150
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   151
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   152
			// HANDLE: $("TAG")
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   153
			} else if ( !context && /^\w+$/.test( selector ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   154
				this.selector = selector;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   155
				this.context = document;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   156
				selector = document.getElementsByTagName( selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   157
				return jQuery.merge( this, selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   158
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   159
			// HANDLE: $(expr, $(...))
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   160
			} else if ( !context || context.jquery ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   161
				return (context || rootjQuery).find( selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   162
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   163
			// HANDLE: $(expr, context)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   164
			// (which is just equivalent to: $(context).find(expr)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   165
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   166
				return jQuery( context ).find( selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   167
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   168
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   169
		// HANDLE: $(function)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   170
		// Shortcut for document ready
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   171
		} else if ( jQuery.isFunction( selector ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   172
			return rootjQuery.ready( selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   173
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   174
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   175
		if (selector.selector !== undefined) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   176
			this.selector = selector.selector;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   177
			this.context = selector.context;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   178
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   179
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   180
		return jQuery.makeArray( selector, this );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   181
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   182
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   183
	// Start with an empty selector
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   184
	selector: "",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   185
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   186
	// The current version of jQuery being used
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   187
	jquery: "1.4.2",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   188
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   189
	// The default length of a jQuery object is 0
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   190
	length: 0,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   191
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   192
	// The number of elements contained in the matched element set
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   193
	size: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   194
		return this.length;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   195
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   196
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   197
	toArray: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   198
		return slice.call( this, 0 );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   199
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   200
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   201
	// Get the Nth element in the matched element set OR
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   202
	// Get the whole matched element set as a clean array
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   203
	get: function( num ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   204
		return num == null ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   205
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   206
			// Return a 'clean' array
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   207
			this.toArray() :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   208
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   209
			// Return just the object
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   210
			( num < 0 ? this.slice(num)[ 0 ] : this[ num ] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   211
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   212
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   213
	// Take an array of elements and push it onto the stack
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   214
	// (returning the new matched element set)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   215
	pushStack: function( elems, name, selector ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   216
		// Build a new jQuery matched element set
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   217
		var ret = jQuery();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   218
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   219
		if ( jQuery.isArray( elems ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   220
			push.apply( ret, elems );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   221
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   222
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   223
			jQuery.merge( ret, elems );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   224
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   225
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   226
		// Add the old object onto the stack (as a reference)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   227
		ret.prevObject = this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   228
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   229
		ret.context = this.context;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   230
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   231
		if ( name === "find" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   232
			ret.selector = this.selector + (this.selector ? " " : "") + selector;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   233
		} else if ( name ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   234
			ret.selector = this.selector + "." + name + "(" + selector + ")";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   235
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   236
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   237
		// Return the newly-formed element set
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   238
		return ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   239
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   240
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   241
	// Execute a callback for every element in the matched set.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   242
	// (You can seed the arguments with an array of args, but this is
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   243
	// only used internally.)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   244
	each: function( callback, args ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   245
		return jQuery.each( this, callback, args );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   246
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   247
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   248
	ready: function( fn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   249
		// Attach the listeners
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   250
		jQuery.bindReady();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   251
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   252
		// If the DOM is already ready
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   253
		if ( jQuery.isReady ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   254
			// Execute the function immediately
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   255
			fn.call( document, jQuery );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   256
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   257
		// Otherwise, remember the function for later
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   258
		} else if ( readyList ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   259
			// Add the function to the wait list
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   260
			readyList.push( fn );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   261
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   262
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   263
		return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   264
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   265
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   266
	eq: function( i ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   267
		return i === -1 ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   268
			this.slice( i ) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   269
			this.slice( i, +i + 1 );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   270
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   271
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   272
	first: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   273
		return this.eq( 0 );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   274
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   275
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   276
	last: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   277
		return this.eq( -1 );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   278
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   279
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   280
	slice: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   281
		return this.pushStack( slice.apply( this, arguments ),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   282
			"slice", slice.call(arguments).join(",") );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   283
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   284
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   285
	map: function( callback ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   286
		return this.pushStack( jQuery.map(this, function( elem, i ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   287
			return callback.call( elem, i, elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   288
		}));
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   289
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   290
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   291
	end: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   292
		return this.prevObject || jQuery(null);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   293
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   294
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   295
	// For internal use only.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   296
	// Behaves like an Array's method, not like a jQuery method.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   297
	push: push,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   298
	sort: [].sort,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   299
	splice: [].splice
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   300
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   301
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   302
// Give the init function the jQuery prototype for later instantiation
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   303
jQuery.fn.init.prototype = jQuery.fn;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   304
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   305
jQuery.extend = jQuery.fn.extend = function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   306
	// copy reference to target object
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   307
	var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options, name, src, copy;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   308
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   309
	// Handle a deep copy situation
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   310
	if ( typeof target === "boolean" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   311
		deep = target;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   312
		target = arguments[1] || {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   313
		// skip the boolean and the target
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   314
		i = 2;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   315
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   316
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   317
	// Handle case when target is a string or something (possible in deep copy)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   318
	if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   319
		target = {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   320
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   321
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   322
	// extend jQuery itself if only one argument is passed
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   323
	if ( length === i ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   324
		target = this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   325
		--i;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   326
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   327
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   328
	for ( ; i < length; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   329
		// Only deal with non-null/undefined values
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   330
		if ( (options = arguments[ i ]) != null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   331
			// Extend the base object
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   332
			for ( name in options ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   333
				src = target[ name ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   334
				copy = options[ name ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   335
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   336
				// Prevent never-ending loop
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   337
				if ( target === copy ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   338
					continue;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   339
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   340
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   341
				// Recurse if we're merging object literal values or arrays
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   342
				if ( deep && copy && ( jQuery.isPlainObject(copy) || jQuery.isArray(copy) ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   343
					var clone = src && ( jQuery.isPlainObject(src) || jQuery.isArray(src) ) ? src
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   344
						: jQuery.isArray(copy) ? [] : {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   345
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   346
					// Never move original objects, clone them
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   347
					target[ name ] = jQuery.extend( deep, clone, copy );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   348
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   349
				// Don't bring in undefined values
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   350
				} else if ( copy !== undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   351
					target[ name ] = copy;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   352
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   353
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   354
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   355
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   356
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   357
	// Return the modified object
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   358
	return target;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   359
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   360
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   361
jQuery.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   362
	noConflict: function( deep ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   363
		window.$ = _$;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   364
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   365
		if ( deep ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   366
			window.jQuery = _jQuery;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   367
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   368
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   369
		return jQuery;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   370
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   371
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   372
	// Is the DOM ready to be used? Set to true once it occurs.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   373
	isReady: false,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   374
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   375
	// Handle when the DOM is ready
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   376
	ready: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   377
		// Make sure that the DOM is not already loaded
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   378
		if ( !jQuery.isReady ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   379
			// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   380
			if ( !document.body ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   381
				return setTimeout( jQuery.ready, 13 );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   382
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   383
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   384
			// Remember that the DOM is ready
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   385
			jQuery.isReady = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   386
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   387
			// If there are functions bound, to execute
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   388
			if ( readyList ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   389
				// Execute all of them
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   390
				var fn, i = 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   391
				while ( (fn = readyList[ i++ ]) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   392
					fn.call( document, jQuery );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   393
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   394
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   395
				// Reset the list of functions
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   396
				readyList = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   397
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   398
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   399
			// Trigger any bound ready events
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   400
			if ( jQuery.fn.triggerHandler ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   401
				jQuery( document ).triggerHandler( "ready" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   402
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   403
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   404
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   405
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   406
	bindReady: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   407
		if ( readyBound ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   408
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   409
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   410
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   411
		readyBound = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   412
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   413
		// Catch cases where $(document).ready() is called after the
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   414
		// browser event has already occurred.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   415
		if ( document.readyState === "complete" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   416
			return jQuery.ready();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   417
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   418
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   419
		// Mozilla, Opera and webkit nightlies currently support this event
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   420
		if ( document.addEventListener ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   421
			// Use the handy event callback
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   422
			document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   423
			
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   424
			// A fallback to window.onload, that will always work
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   425
			window.addEventListener( "load", jQuery.ready, false );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   426
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   427
		// If IE event model is used
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   428
		} else if ( document.attachEvent ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   429
			// ensure firing before onload,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   430
			// maybe late but safe also for iframes
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   431
			document.attachEvent("onreadystatechange", DOMContentLoaded);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   432
			
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   433
			// A fallback to window.onload, that will always work
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   434
			window.attachEvent( "onload", jQuery.ready );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   435
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   436
			// If IE and not a frame
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   437
			// continually check to see if the document is ready
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   438
			var toplevel = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   439
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   440
			try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   441
				toplevel = window.frameElement == null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   442
			} catch(e) {}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   443
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   444
			if ( document.documentElement.doScroll && toplevel ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   445
				doScrollCheck();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   446
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   447
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   448
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   449
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   450
	// See test/unit/core.js for details concerning isFunction.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   451
	// Since version 1.3, DOM methods and functions like alert
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   452
	// aren't supported. They return false on IE (#2968).
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   453
	isFunction: function( obj ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   454
		return toString.call(obj) === "[object Function]";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   455
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   456
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   457
	isArray: function( obj ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   458
		return toString.call(obj) === "[object Array]";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   459
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   460
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   461
	isPlainObject: function( obj ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   462
		// Must be an Object.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   463
		// Because of IE, we also have to check the presence of the constructor property.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   464
		// Make sure that DOM nodes and window objects don't pass through, as well
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   465
		if ( !obj || toString.call(obj) !== "[object Object]" || obj.nodeType || obj.setInterval ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   466
			return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   467
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   468
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   469
		// Not own constructor property must be Object
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   470
		if ( obj.constructor
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   471
			&& !hasOwnProperty.call(obj, "constructor")
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   472
			&& !hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf") ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   473
			return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   474
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   475
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   476
		// Own properties are enumerated firstly, so to speed up,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   477
		// if last one is own, then all properties are own.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   478
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   479
		var key;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   480
		for ( key in obj ) {}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   481
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   482
		return key === undefined || hasOwnProperty.call( obj, key );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   483
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   484
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   485
	isEmptyObject: function( obj ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   486
		for ( var name in obj ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   487
			return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   488
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   489
		return true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   490
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   491
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   492
	error: function( msg ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   493
		throw msg;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   494
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   495
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   496
	parseJSON: function( data ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   497
		if ( typeof data !== "string" || !data ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   498
			return null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   499
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   500
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   501
		// Make sure leading/trailing whitespace is removed (IE can't handle it)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   502
		data = jQuery.trim( data );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   503
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   504
		// Make sure the incoming data is actual JSON
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   505
		// Logic borrowed from http://json.org/json2.js
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   506
		if ( /^[\],:{}\s]*$/.test(data.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, "@")
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   507
			.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, "]")
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   508
			.replace(/(?:^|:|,)(?:\s*\[)+/g, "")) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   509
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   510
			// Try to use the native JSON parser first
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   511
			return window.JSON && window.JSON.parse ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   512
				window.JSON.parse( data ) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   513
				(new Function("return " + data))();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   514
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   515
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   516
			jQuery.error( "Invalid JSON: " + data );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   517
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   518
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   519
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   520
	noop: function() {},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   521
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   522
	// Evalulates a script in a global context
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   523
	globalEval: function( data ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   524
		if ( data && rnotwhite.test(data) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   525
			// Inspired by code by Andrea Giammarchi
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   526
			// http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   527
			var head = document.getElementsByTagName("head")[0] || document.documentElement,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   528
				script = document.createElement("script");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   529
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   530
			script.type = "text/javascript";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   531
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   532
			if ( jQuery.support.scriptEval ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   533
				script.appendChild( document.createTextNode( data ) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   534
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   535
				script.text = data;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   536
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   537
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   538
			// Use insertBefore instead of appendChild to circumvent an IE6 bug.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   539
			// This arises when a base node is used (#2709).
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   540
			head.insertBefore( script, head.firstChild );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   541
			head.removeChild( script );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   542
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   543
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   544
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   545
	nodeName: function( elem, name ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   546
		return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   547
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   548
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   549
	// args is for internal usage only
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   550
	each: function( object, callback, args ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   551
		var name, i = 0,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   552
			length = object.length,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   553
			isObj = length === undefined || jQuery.isFunction(object);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   554
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   555
		if ( args ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   556
			if ( isObj ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   557
				for ( name in object ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   558
					if ( callback.apply( object[ name ], args ) === false ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   559
						break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   560
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   561
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   562
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   563
				for ( ; i < length; ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   564
					if ( callback.apply( object[ i++ ], args ) === false ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   565
						break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   566
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   567
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   568
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   569
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   570
		// A special, fast, case for the most common use of each
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   571
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   572
			if ( isObj ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   573
				for ( name in object ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   574
					if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   575
						break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   576
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   577
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   578
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   579
				for ( var value = object[0];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   580
					i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   581
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   582
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   583
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   584
		return object;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   585
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   586
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   587
	trim: function( text ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   588
		return (text || "").replace( rtrim, "" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   589
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   590
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   591
	// results is for internal usage only
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   592
	makeArray: function( array, results ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   593
		var ret = results || [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   594
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   595
		if ( array != null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   596
			// The window, strings (and functions) also have 'length'
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   597
			// The extra typeof function check is to prevent crashes
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   598
			// in Safari 2 (See: #3039)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   599
			if ( array.length == null || typeof array === "string" || jQuery.isFunction(array) || (typeof array !== "function" && array.setInterval) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   600
				push.call( ret, array );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   601
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   602
				jQuery.merge( ret, array );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   603
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   604
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   605
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   606
		return ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   607
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   608
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   609
	inArray: function( elem, array ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   610
		if ( array.indexOf ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   611
			return array.indexOf( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   612
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   613
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   614
		for ( var i = 0, length = array.length; i < length; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   615
			if ( array[ i ] === elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   616
				return i;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   617
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   618
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   619
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   620
		return -1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   621
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   622
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   623
	merge: function( first, second ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   624
		var i = first.length, j = 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   625
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   626
		if ( typeof second.length === "number" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   627
			for ( var l = second.length; j < l; j++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   628
				first[ i++ ] = second[ j ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   629
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   630
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   631
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   632
			while ( second[j] !== undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   633
				first[ i++ ] = second[ j++ ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   634
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   635
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   636
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   637
		first.length = i;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   638
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   639
		return first;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   640
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   641
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   642
	grep: function( elems, callback, inv ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   643
		var ret = [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   644
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   645
		// Go through the array, only saving the items
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   646
		// that pass the validator function
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   647
		for ( var i = 0, length = elems.length; i < length; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   648
			if ( !inv !== !callback( elems[ i ], i ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   649
				ret.push( elems[ i ] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   650
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   651
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   652
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   653
		return ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   654
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   655
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   656
	// arg is for internal usage only
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   657
	map: function( elems, callback, arg ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   658
		var ret = [], value;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   659
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   660
		// Go through the array, translating each of the items to their
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   661
		// new value (or values).
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   662
		for ( var i = 0, length = elems.length; i < length; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   663
			value = callback( elems[ i ], i, arg );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   664
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   665
			if ( value != null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   666
				ret[ ret.length ] = value;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   667
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   668
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   669
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   670
		return ret.concat.apply( [], ret );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   671
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   672
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   673
	// A global GUID counter for objects
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   674
	guid: 1,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   675
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   676
	proxy: function( fn, proxy, thisObject ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   677
		if ( arguments.length === 2 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   678
			if ( typeof proxy === "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   679
				thisObject = fn;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   680
				fn = thisObject[ proxy ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   681
				proxy = undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   682
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   683
			} else if ( proxy && !jQuery.isFunction( proxy ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   684
				thisObject = proxy;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   685
				proxy = undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   686
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   687
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   688
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   689
		if ( !proxy && fn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   690
			proxy = function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   691
				return fn.apply( thisObject || this, arguments );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   692
			};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   693
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   694
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   695
		// Set the guid of unique handler to the same of original handler, so it can be removed
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   696
		if ( fn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   697
			proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   698
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   699
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   700
		// So proxy can be declared as an argument
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   701
		return proxy;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   702
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   703
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   704
	// Use of jQuery.browser is frowned upon.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   705
	// More details: http://docs.jquery.com/Utilities/jQuery.browser
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   706
	uaMatch: function( ua ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   707
		ua = ua.toLowerCase();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   708
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   709
		var match = /(webkit)[ \/]([\w.]+)/.exec( ua ) ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   710
			/(opera)(?:.*version)?[ \/]([\w.]+)/.exec( ua ) ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   711
			/(msie) ([\w.]+)/.exec( ua ) ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   712
			!/compatible/.test( ua ) && /(mozilla)(?:.*? rv:([\w.]+))?/.exec( ua ) ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   713
		  	[];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   714
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   715
		return { browser: match[1] || "", version: match[2] || "0" };
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   716
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   717
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   718
	browser: {}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   719
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   720
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   721
browserMatch = jQuery.uaMatch( userAgent );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   722
if ( browserMatch.browser ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   723
	jQuery.browser[ browserMatch.browser ] = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   724
	jQuery.browser.version = browserMatch.version;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   725
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   726
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   727
// Deprecated, use jQuery.browser.webkit instead
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   728
if ( jQuery.browser.webkit ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   729
	jQuery.browser.safari = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   730
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   731
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   732
if ( indexOf ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   733
	jQuery.inArray = function( elem, array ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   734
		return indexOf.call( array, elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   735
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   736
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   737
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   738
// All jQuery objects should point back to these
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   739
rootjQuery = jQuery(document);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   740
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   741
// Cleanup functions for the document ready method
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   742
if ( document.addEventListener ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   743
	DOMContentLoaded = function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   744
		document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   745
		jQuery.ready();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   746
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   747
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   748
} else if ( document.attachEvent ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   749
	DOMContentLoaded = function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   750
		// Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   751
		if ( document.readyState === "complete" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   752
			document.detachEvent( "onreadystatechange", DOMContentLoaded );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   753
			jQuery.ready();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   754
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   755
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   756
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   757
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   758
// The DOM ready check for Internet Explorer
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   759
function doScrollCheck() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   760
	if ( jQuery.isReady ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   761
		return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   762
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   763
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   764
	try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   765
		// If IE is used, use the trick by Diego Perini
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   766
		// http://javascript.nwbox.com/IEContentLoaded/
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   767
		document.documentElement.doScroll("left");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   768
	} catch( error ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   769
		setTimeout( doScrollCheck, 1 );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   770
		return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   771
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   772
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   773
	// and execute any waiting functions
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   774
	jQuery.ready();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   775
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   776
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   777
function evalScript( i, elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   778
	if ( elem.src ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   779
		jQuery.ajax({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   780
			url: elem.src,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   781
			async: false,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   782
			dataType: "script"
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   783
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   784
	} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   785
		jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   786
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   787
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   788
	if ( elem.parentNode ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   789
		elem.parentNode.removeChild( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   790
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   791
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   792
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   793
// Mutifunctional method to get and set values to a collection
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   794
// The value/s can be optionally by executed if its a function
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   795
function access( elems, key, value, exec, fn, pass ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   796
	var length = elems.length;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   797
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   798
	// Setting many attributes
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   799
	if ( typeof key === "object" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   800
		for ( var k in key ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   801
			access( elems, k, key[k], exec, fn, value );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   802
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   803
		return elems;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   804
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   805
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   806
	// Setting one attribute
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   807
	if ( value !== undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   808
		// Optionally, function values get executed if exec is true
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   809
		exec = !pass && exec && jQuery.isFunction(value);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   810
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   811
		for ( var i = 0; i < length; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   812
			fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   813
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   814
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   815
		return elems;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   816
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   817
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   818
	// Getting an attribute
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   819
	return length ? fn( elems[0], key ) : undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   820
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   821
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   822
function now() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   823
	return (new Date).getTime();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   824
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   825
(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   826
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   827
	jQuery.support = {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   828
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   829
	var root = document.documentElement,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   830
		script = document.createElement("script"),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   831
		div = document.createElement("div"),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   832
		id = "script" + now();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   833
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   834
	div.style.display = "none";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   835
	div.innerHTML = "   <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   836
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   837
	var all = div.getElementsByTagName("*"),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   838
		a = div.getElementsByTagName("a")[0];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   839
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   840
	// Can't get basic test support
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   841
	if ( !all || !all.length || !a ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   842
		return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   843
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   844
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   845
	jQuery.support = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   846
		// IE strips leading whitespace when .innerHTML is used
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   847
		leadingWhitespace: div.firstChild.nodeType === 3,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   848
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   849
		// Make sure that tbody elements aren't automatically inserted
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   850
		// IE will insert them into empty tables
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   851
		tbody: !div.getElementsByTagName("tbody").length,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   852
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   853
		// Make sure that link elements get serialized correctly by innerHTML
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   854
		// This requires a wrapper element in IE
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   855
		htmlSerialize: !!div.getElementsByTagName("link").length,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   856
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   857
		// Get the style information from getAttribute
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   858
		// (IE uses .cssText insted)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   859
		style: /red/.test( a.getAttribute("style") ),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   860
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   861
		// Make sure that URLs aren't manipulated
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   862
		// (IE normalizes it by default)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   863
		hrefNormalized: a.getAttribute("href") === "/a",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   864
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   865
		// Make sure that element opacity exists
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   866
		// (IE uses filter instead)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   867
		// Use a regex to work around a WebKit issue. See #5145
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   868
		opacity: /^0.55$/.test( a.style.opacity ),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   869
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   870
		// Verify style float existence
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   871
		// (IE uses styleFloat instead of cssFloat)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   872
		cssFloat: !!a.style.cssFloat,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   873
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   874
		// Make sure that if no value is specified for a checkbox
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   875
		// that it defaults to "on".
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   876
		// (WebKit defaults to "" instead)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   877
		checkOn: div.getElementsByTagName("input")[0].value === "on",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   878
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   879
		// Make sure that a selected-by-default option has a working selected property.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   880
		// (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   881
		optSelected: document.createElement("select").appendChild( document.createElement("option") ).selected,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   882
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   883
		parentNode: div.removeChild( div.appendChild( document.createElement("div") ) ).parentNode === null,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   884
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   885
		// Will be defined later
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   886
		deleteExpando: true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   887
		checkClone: false,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   888
		scriptEval: false,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   889
		noCloneEvent: true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   890
		boxModel: null
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   891
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   892
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   893
	script.type = "text/javascript";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   894
	try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   895
		script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   896
	} catch(e) {}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   897
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   898
	root.insertBefore( script, root.firstChild );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   899
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   900
	// Make sure that the execution of code works by injecting a script
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   901
	// tag with appendChild/createTextNode
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   902
	// (IE doesn't support this, fails, and uses .text instead)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   903
	if ( window[ id ] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   904
		jQuery.support.scriptEval = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   905
		delete window[ id ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   906
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   907
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   908
	// Test to see if it's possible to delete an expando from an element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   909
	// Fails in Internet Explorer
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   910
	try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   911
		delete script.test;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   912
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   913
	} catch(e) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   914
		jQuery.support.deleteExpando = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   915
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   916
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   917
	root.removeChild( script );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   918
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   919
	if ( div.attachEvent && div.fireEvent ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   920
		div.attachEvent("onclick", function click() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   921
			// Cloning a node shouldn't copy over any
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   922
			// bound event handlers (IE does this)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   923
			jQuery.support.noCloneEvent = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   924
			div.detachEvent("onclick", click);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   925
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   926
		div.cloneNode(true).fireEvent("onclick");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   927
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   928
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   929
	div = document.createElement("div");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   930
	div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   931
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   932
	var fragment = document.createDocumentFragment();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   933
	fragment.appendChild( div.firstChild );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   934
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   935
	// WebKit doesn't clone checked state correctly in fragments
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   936
	jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   937
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   938
	// Figure out if the W3C box model works as expected
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   939
	// document.body must exist before we can do this
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   940
	jQuery(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   941
		var div = document.createElement("div");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   942
		div.style.width = div.style.paddingLeft = "1px";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   943
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   944
		document.body.appendChild( div );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   945
		jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   946
		document.body.removeChild( div ).style.display = 'none';
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   947
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   948
		div = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   949
	});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   950
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   951
	// Technique from Juriy Zaytsev
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   952
	// http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   953
	var eventSupported = function( eventName ) { 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   954
		var el = document.createElement("div"); 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   955
		eventName = "on" + eventName; 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   956
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   957
		var isSupported = (eventName in el); 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   958
		if ( !isSupported ) { 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   959
			el.setAttribute(eventName, "return;"); 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   960
			isSupported = typeof el[eventName] === "function"; 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   961
		} 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   962
		el = null; 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   963
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   964
		return isSupported; 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   965
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   966
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   967
	jQuery.support.submitBubbles = eventSupported("submit");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   968
	jQuery.support.changeBubbles = eventSupported("change");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   969
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   970
	// release memory in IE
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   971
	root = script = div = all = a = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   972
})();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   973
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   974
jQuery.props = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   975
	"for": "htmlFor",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   976
	"class": "className",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   977
	readonly: "readOnly",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   978
	maxlength: "maxLength",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   979
	cellspacing: "cellSpacing",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   980
	rowspan: "rowSpan",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   981
	colspan: "colSpan",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   982
	tabindex: "tabIndex",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   983
	usemap: "useMap",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   984
	frameborder: "frameBorder"
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   985
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   986
var expando = "jQuery" + now(), uuid = 0, windowData = {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   987
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   988
jQuery.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   989
	cache: {},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   990
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   991
	expando:expando,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   992
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   993
	// The following elements throw uncatchable exceptions if you
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   994
	// attempt to add expando properties to them.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   995
	noData: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   996
		"embed": true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   997
		"object": true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   998
		"applet": true
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
   999
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1000
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1001
	data: function( elem, name, data ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1002
		if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1003
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1004
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1005
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1006
		elem = elem == window ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1007
			windowData :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1008
			elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1009
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1010
		var id = elem[ expando ], cache = jQuery.cache, thisCache;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1011
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1012
		if ( !id && typeof name === "string" && data === undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1013
			return null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1014
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1015
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1016
		// Compute a unique ID for the element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1017
		if ( !id ) { 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1018
			id = ++uuid;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1019
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1020
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1021
		// Avoid generating a new cache unless none exists and we
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1022
		// want to manipulate it.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1023
		if ( typeof name === "object" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1024
			elem[ expando ] = id;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1025
			thisCache = cache[ id ] = jQuery.extend(true, {}, name);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1026
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1027
		} else if ( !cache[ id ] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1028
			elem[ expando ] = id;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1029
			cache[ id ] = {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1030
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1031
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1032
		thisCache = cache[ id ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1033
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1034
		// Prevent overriding the named cache with undefined values
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1035
		if ( data !== undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1036
			thisCache[ name ] = data;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1037
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1038
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1039
		return typeof name === "string" ? thisCache[ name ] : thisCache;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1040
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1041
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1042
	removeData: function( elem, name ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1043
		if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1044
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1045
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1046
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1047
		elem = elem == window ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1048
			windowData :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1049
			elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1050
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1051
		var id = elem[ expando ], cache = jQuery.cache, thisCache = cache[ id ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1052
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1053
		// If we want to remove a specific section of the element's data
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1054
		if ( name ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1055
			if ( thisCache ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1056
				// Remove the section of cache data
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1057
				delete thisCache[ name ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1058
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1059
				// If we've removed all the data, remove the element's cache
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1060
				if ( jQuery.isEmptyObject(thisCache) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1061
					jQuery.removeData( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1062
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1063
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1064
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1065
		// Otherwise, we want to remove all of the element's data
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1066
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1067
			if ( jQuery.support.deleteExpando ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1068
				delete elem[ jQuery.expando ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1069
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1070
			} else if ( elem.removeAttribute ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1071
				elem.removeAttribute( jQuery.expando );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1072
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1073
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1074
			// Completely remove the data cache
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1075
			delete cache[ id ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1076
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1077
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1078
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1079
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1080
jQuery.fn.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1081
	data: function( key, value ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1082
		if ( typeof key === "undefined" && this.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1083
			return jQuery.data( this[0] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1084
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1085
		} else if ( typeof key === "object" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1086
			return this.each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1087
				jQuery.data( this, key );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1088
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1089
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1090
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1091
		var parts = key.split(".");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1092
		parts[1] = parts[1] ? "." + parts[1] : "";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1093
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1094
		if ( value === undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1095
			var data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1096
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1097
			if ( data === undefined && this.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1098
				data = jQuery.data( this[0], key );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1099
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1100
			return data === undefined && parts[1] ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1101
				this.data( parts[0] ) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1102
				data;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1103
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1104
			return this.trigger("setData" + parts[1] + "!", [parts[0], value]).each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1105
				jQuery.data( this, key, value );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1106
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1107
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1108
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1109
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1110
	removeData: function( key ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1111
		return this.each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1112
			jQuery.removeData( this, key );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1113
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1114
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1115
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1116
jQuery.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1117
	queue: function( elem, type, data ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1118
		if ( !elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1119
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1120
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1121
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1122
		type = (type || "fx") + "queue";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1123
		var q = jQuery.data( elem, type );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1124
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1125
		// Speed up dequeue by getting out quickly if this is just a lookup
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1126
		if ( !data ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1127
			return q || [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1128
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1129
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1130
		if ( !q || jQuery.isArray(data) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1131
			q = jQuery.data( elem, type, jQuery.makeArray(data) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1132
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1133
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1134
			q.push( data );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1135
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1136
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1137
		return q;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1138
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1139
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1140
	dequeue: function( elem, type ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1141
		type = type || "fx";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1142
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1143
		var queue = jQuery.queue( elem, type ), fn = queue.shift();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1144
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1145
		// If the fx queue is dequeued, always remove the progress sentinel
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1146
		if ( fn === "inprogress" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1147
			fn = queue.shift();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1148
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1149
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1150
		if ( fn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1151
			// Add a progress sentinel to prevent the fx queue from being
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1152
			// automatically dequeued
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1153
			if ( type === "fx" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1154
				queue.unshift("inprogress");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1155
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1156
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1157
			fn.call(elem, function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1158
				jQuery.dequeue(elem, type);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1159
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1160
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1161
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1162
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1163
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1164
jQuery.fn.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1165
	queue: function( type, data ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1166
		if ( typeof type !== "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1167
			data = type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1168
			type = "fx";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1169
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1170
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1171
		if ( data === undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1172
			return jQuery.queue( this[0], type );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1173
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1174
		return this.each(function( i, elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1175
			var queue = jQuery.queue( this, type, data );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1176
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1177
			if ( type === "fx" && queue[0] !== "inprogress" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1178
				jQuery.dequeue( this, type );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1179
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1180
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1181
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1182
	dequeue: function( type ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1183
		return this.each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1184
			jQuery.dequeue( this, type );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1185
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1186
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1187
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1188
	// Based off of the plugin by Clint Helfers, with permission.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1189
	// http://blindsignals.com/index.php/2009/07/jquery-delay/
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1190
	delay: function( time, type ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1191
		time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1192
		type = type || "fx";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1193
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1194
		return this.queue( type, function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1195
			var elem = this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1196
			setTimeout(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1197
				jQuery.dequeue( elem, type );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1198
			}, time );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1199
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1200
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1201
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1202
	clearQueue: function( type ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1203
		return this.queue( type || "fx", [] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1204
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1205
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1206
var rclass = /[\n\t]/g,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1207
	rspace = /\s+/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1208
	rreturn = /\r/g,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1209
	rspecialurl = /href|src|style/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1210
	rtype = /(button|input)/i,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1211
	rfocusable = /(button|input|object|select|textarea)/i,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1212
	rclickable = /^(a|area)$/i,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1213
	rradiocheck = /radio|checkbox/;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1214
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1215
jQuery.fn.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1216
	attr: function( name, value ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1217
		return access( this, name, value, true, jQuery.attr );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1218
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1219
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1220
	removeAttr: function( name, fn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1221
		return this.each(function(){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1222
			jQuery.attr( this, name, "" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1223
			if ( this.nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1224
				this.removeAttribute( name );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1225
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1226
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1227
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1228
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1229
	addClass: function( value ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1230
		if ( jQuery.isFunction(value) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1231
			return this.each(function(i) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1232
				var self = jQuery(this);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1233
				self.addClass( value.call(this, i, self.attr("class")) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1234
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1235
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1236
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1237
		if ( value && typeof value === "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1238
			var classNames = (value || "").split( rspace );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1239
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1240
			for ( var i = 0, l = this.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1241
				var elem = this[i];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1242
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1243
				if ( elem.nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1244
					if ( !elem.className ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1245
						elem.className = value;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1246
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1247
					} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1248
						var className = " " + elem.className + " ", setClass = elem.className;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1249
						for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1250
							if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1251
								setClass += " " + classNames[c];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1252
							}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1253
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1254
						elem.className = jQuery.trim( setClass );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1255
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1256
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1257
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1258
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1259
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1260
		return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1261
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1262
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1263
	removeClass: function( value ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1264
		if ( jQuery.isFunction(value) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1265
			return this.each(function(i) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1266
				var self = jQuery(this);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1267
				self.removeClass( value.call(this, i, self.attr("class")) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1268
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1269
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1270
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1271
		if ( (value && typeof value === "string") || value === undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1272
			var classNames = (value || "").split(rspace);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1273
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1274
			for ( var i = 0, l = this.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1275
				var elem = this[i];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1276
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1277
				if ( elem.nodeType === 1 && elem.className ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1278
					if ( value ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1279
						var className = (" " + elem.className + " ").replace(rclass, " ");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1280
						for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1281
							className = className.replace(" " + classNames[c] + " ", " ");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1282
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1283
						elem.className = jQuery.trim( className );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1284
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1285
					} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1286
						elem.className = "";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1287
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1288
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1289
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1290
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1291
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1292
		return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1293
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1294
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1295
	toggleClass: function( value, stateVal ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1296
		var type = typeof value, isBool = typeof stateVal === "boolean";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1297
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1298
		if ( jQuery.isFunction( value ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1299
			return this.each(function(i) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1300
				var self = jQuery(this);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1301
				self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1302
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1303
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1304
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1305
		return this.each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1306
			if ( type === "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1307
				// toggle individual class names
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1308
				var className, i = 0, self = jQuery(this),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1309
					state = stateVal,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1310
					classNames = value.split( rspace );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1311
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1312
				while ( (className = classNames[ i++ ]) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1313
					// check each className given, space seperated list
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1314
					state = isBool ? state : !self.hasClass( className );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1315
					self[ state ? "addClass" : "removeClass" ]( className );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1316
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1317
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1318
			} else if ( type === "undefined" || type === "boolean" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1319
				if ( this.className ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1320
					// store className if set
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1321
					jQuery.data( this, "__className__", this.className );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1322
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1323
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1324
				// toggle whole className
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1325
				this.className = this.className || value === false ? "" : jQuery.data( this, "__className__" ) || "";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1326
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1327
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1328
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1329
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1330
	hasClass: function( selector ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1331
		var className = " " + selector + " ";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1332
		for ( var i = 0, l = this.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1333
			if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1334
				return true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1335
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1336
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1337
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1338
		return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1339
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1340
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1341
	val: function( value ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1342
		if ( value === undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1343
			var elem = this[0];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1344
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1345
			if ( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1346
				if ( jQuery.nodeName( elem, "option" ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1347
					return (elem.attributes.value || {}).specified ? elem.value : elem.text;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1348
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1349
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1350
				// We need to handle select boxes special
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1351
				if ( jQuery.nodeName( elem, "select" ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1352
					var index = elem.selectedIndex,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1353
						values = [],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1354
						options = elem.options,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1355
						one = elem.type === "select-one";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1356
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1357
					// Nothing was selected
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1358
					if ( index < 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1359
						return null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1360
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1361
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1362
					// Loop through all the selected options
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1363
					for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1364
						var option = options[ i ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1365
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1366
						if ( option.selected ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1367
							// Get the specifc value for the option
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1368
							value = jQuery(option).val();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1369
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1370
							// We don't need an array for one selects
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1371
							if ( one ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1372
								return value;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1373
							}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1374
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1375
							// Multi-Selects return an array
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1376
							values.push( value );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1377
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1378
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1379
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1380
					return values;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1381
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1382
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1383
				// Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1384
				if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1385
					return elem.getAttribute("value") === null ? "on" : elem.value;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1386
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1387
				
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1388
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1389
				// Everything else, we just grab the value
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1390
				return (elem.value || "").replace(rreturn, "");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1391
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1392
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1393
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1394
			return undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1395
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1396
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1397
		var isFunction = jQuery.isFunction(value);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1398
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1399
		return this.each(function(i) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1400
			var self = jQuery(this), val = value;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1401
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1402
			if ( this.nodeType !== 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1403
				return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1404
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1405
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1406
			if ( isFunction ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1407
				val = value.call(this, i, self.val());
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1408
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1409
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1410
			// Typecast each time if the value is a Function and the appended
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1411
			// value is therefore different each time.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1412
			if ( typeof val === "number" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1413
				val += "";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1414
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1415
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1416
			if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1417
				this.checked = jQuery.inArray( self.val(), val ) >= 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1418
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1419
			} else if ( jQuery.nodeName( this, "select" ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1420
				var values = jQuery.makeArray(val);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1421
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1422
				jQuery( "option", this ).each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1423
					this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1424
				});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1425
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1426
				if ( !values.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1427
					this.selectedIndex = -1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1428
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1429
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1430
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1431
				this.value = val;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1432
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1433
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1434
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1435
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1436
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1437
jQuery.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1438
	attrFn: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1439
		val: true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1440
		css: true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1441
		html: true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1442
		text: true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1443
		data: true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1444
		width: true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1445
		height: true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1446
		offset: true
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1447
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1448
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1449
	attr: function( elem, name, value, pass ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1450
		// don't set attributes on text and comment nodes
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1451
		if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1452
			return undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1453
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1454
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1455
		if ( pass && name in jQuery.attrFn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1456
			return jQuery(elem)[name](value);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1457
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1458
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1459
		var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1460
			// Whether we are setting (or getting)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1461
			set = value !== undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1462
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1463
		// Try to normalize/fix the name
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1464
		name = notxml && jQuery.props[ name ] || name;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1465
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1466
		// Only do all the following if this is a node (faster for style)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1467
		if ( elem.nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1468
			// These attributes require special treatment
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1469
			var special = rspecialurl.test( name );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1470
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1471
			// Safari mis-reports the default selected property of an option
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1472
			// Accessing the parent's selectedIndex property fixes it
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1473
			if ( name === "selected" && !jQuery.support.optSelected ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1474
				var parent = elem.parentNode;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1475
				if ( parent ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1476
					parent.selectedIndex;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1477
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1478
					// Make sure that it also works with optgroups, see #5701
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1479
					if ( parent.parentNode ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1480
						parent.parentNode.selectedIndex;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1481
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1482
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1483
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1484
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1485
			// If applicable, access the attribute via the DOM 0 way
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1486
			if ( name in elem && notxml && !special ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1487
				if ( set ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1488
					// We can't allow the type property to be changed (since it causes problems in IE)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1489
					if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1490
						jQuery.error( "type property can't be changed" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1491
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1492
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1493
					elem[ name ] = value;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1494
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1495
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1496
				// browsers index elements by id/name on forms, give priority to attributes.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1497
				if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1498
					return elem.getAttributeNode( name ).nodeValue;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1499
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1500
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1501
				// elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1502
				// http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1503
				if ( name === "tabIndex" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1504
					var attributeNode = elem.getAttributeNode( "tabIndex" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1505
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1506
					return attributeNode && attributeNode.specified ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1507
						attributeNode.value :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1508
						rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1509
							0 :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1510
							undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1511
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1512
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1513
				return elem[ name ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1514
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1515
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1516
			if ( !jQuery.support.style && notxml && name === "style" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1517
				if ( set ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1518
					elem.style.cssText = "" + value;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1519
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1520
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1521
				return elem.style.cssText;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1522
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1523
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1524
			if ( set ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1525
				// convert the value to a string (all browsers do this but IE) see #1070
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1526
				elem.setAttribute( name, "" + value );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1527
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1528
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1529
			var attr = !jQuery.support.hrefNormalized && notxml && special ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1530
					// Some attributes require a special call on IE
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1531
					elem.getAttribute( name, 2 ) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1532
					elem.getAttribute( name );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1533
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1534
			// Non-existent attributes return null, we normalize to undefined
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1535
			return attr === null ? undefined : attr;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1536
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1537
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1538
		// elem is actually elem.style ... set the style
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1539
		// Using attr for specific style information is now deprecated. Use style instead.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1540
		return jQuery.style( elem, name, value );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1541
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1542
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1543
var rnamespaces = /\.(.*)$/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1544
	fcleanup = function( nm ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1545
		return nm.replace(/[^\w\s\.\|`]/g, function( ch ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1546
			return "\\" + ch;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1547
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1548
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1549
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1550
/*
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1551
 * A number of helper functions used for managing events.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1552
 * Many of the ideas behind this code originated from
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1553
 * Dean Edwards' addEvent library.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1554
 */
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1555
jQuery.event = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1556
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1557
	// Bind an event to an element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1558
	// Original by Dean Edwards
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1559
	add: function( elem, types, handler, data ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1560
		if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1561
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1562
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1563
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1564
		// For whatever reason, IE has trouble passing the window object
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1565
		// around, causing it to be cloned in the process
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1566
		if ( elem.setInterval && ( elem !== window && !elem.frameElement ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1567
			elem = window;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1568
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1569
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1570
		var handleObjIn, handleObj;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1571
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1572
		if ( handler.handler ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1573
			handleObjIn = handler;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1574
			handler = handleObjIn.handler;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1575
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1576
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1577
		// Make sure that the function being executed has a unique ID
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1578
		if ( !handler.guid ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1579
			handler.guid = jQuery.guid++;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1580
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1581
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1582
		// Init the element's event structure
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1583
		var elemData = jQuery.data( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1584
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1585
		// If no elemData is found then we must be trying to bind to one of the
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1586
		// banned noData elements
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1587
		if ( !elemData ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1588
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1589
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1590
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1591
		var events = elemData.events = elemData.events || {},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1592
			eventHandle = elemData.handle, eventHandle;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1593
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1594
		if ( !eventHandle ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1595
			elemData.handle = eventHandle = function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1596
				// Handle the second event of a trigger and when
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1597
				// an event is called after a page has unloaded
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1598
				return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1599
					jQuery.event.handle.apply( eventHandle.elem, arguments ) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1600
					undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1601
			};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1602
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1603
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1604
		// Add elem as a property of the handle function
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1605
		// This is to prevent a memory leak with non-native events in IE.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1606
		eventHandle.elem = elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1607
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1608
		// Handle multiple events separated by a space
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1609
		// jQuery(...).bind("mouseover mouseout", fn);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1610
		types = types.split(" ");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1611
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1612
		var type, i = 0, namespaces;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1613
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1614
		while ( (type = types[ i++ ]) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1615
			handleObj = handleObjIn ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1616
				jQuery.extend({}, handleObjIn) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1617
				{ handler: handler, data: data };
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1618
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1619
			// Namespaced event handlers
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1620
			if ( type.indexOf(".") > -1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1621
				namespaces = type.split(".");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1622
				type = namespaces.shift();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1623
				handleObj.namespace = namespaces.slice(0).sort().join(".");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1624
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1625
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1626
				namespaces = [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1627
				handleObj.namespace = "";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1628
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1629
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1630
			handleObj.type = type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1631
			handleObj.guid = handler.guid;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1632
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1633
			// Get the current list of functions bound to this event
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1634
			var handlers = events[ type ],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1635
				special = jQuery.event.special[ type ] || {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1636
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1637
			// Init the event handler queue
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1638
			if ( !handlers ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1639
				handlers = events[ type ] = [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1640
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1641
				// Check for a special event handler
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1642
				// Only use addEventListener/attachEvent if the special
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1643
				// events handler returns false
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1644
				if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1645
					// Bind the global event handler to the element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1646
					if ( elem.addEventListener ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1647
						elem.addEventListener( type, eventHandle, false );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1648
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1649
					} else if ( elem.attachEvent ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1650
						elem.attachEvent( "on" + type, eventHandle );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1651
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1652
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1653
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1654
			
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1655
			if ( special.add ) { 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1656
				special.add.call( elem, handleObj ); 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1657
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1658
				if ( !handleObj.handler.guid ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1659
					handleObj.handler.guid = handler.guid;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1660
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1661
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1662
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1663
			// Add the function to the element's handler list
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1664
			handlers.push( handleObj );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1665
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1666
			// Keep track of which events have been used, for global triggering
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1667
			jQuery.event.global[ type ] = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1668
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1669
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1670
		// Nullify elem to prevent memory leaks in IE
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1671
		elem = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1672
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1673
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1674
	global: {},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1675
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1676
	// Detach an event or set of events from an element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1677
	remove: function( elem, types, handler, pos ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1678
		// don't do events on text and comment nodes
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1679
		if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1680
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1681
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1682
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1683
		var ret, type, fn, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1684
			elemData = jQuery.data( elem ),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1685
			events = elemData && elemData.events;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1686
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1687
		if ( !elemData || !events ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1688
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1689
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1690
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1691
		// types is actually an event object here
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1692
		if ( types && types.type ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1693
			handler = types.handler;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1694
			types = types.type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1695
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1696
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1697
		// Unbind all events for the element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1698
		if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1699
			types = types || "";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1700
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1701
			for ( type in events ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1702
				jQuery.event.remove( elem, type + types );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1703
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1704
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1705
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1706
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1707
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1708
		// Handle multiple events separated by a space
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1709
		// jQuery(...).unbind("mouseover mouseout", fn);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1710
		types = types.split(" ");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1711
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1712
		while ( (type = types[ i++ ]) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1713
			origType = type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1714
			handleObj = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1715
			all = type.indexOf(".") < 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1716
			namespaces = [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1717
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1718
			if ( !all ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1719
				// Namespaced event handlers
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1720
				namespaces = type.split(".");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1721
				type = namespaces.shift();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1722
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1723
				namespace = new RegExp("(^|\\.)" + 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1724
					jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)")
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1725
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1726
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1727
			eventType = events[ type ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1728
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1729
			if ( !eventType ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1730
				continue;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1731
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1732
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1733
			if ( !handler ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1734
				for ( var j = 0; j < eventType.length; j++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1735
					handleObj = eventType[ j ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1736
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1737
					if ( all || namespace.test( handleObj.namespace ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1738
						jQuery.event.remove( elem, origType, handleObj.handler, j );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1739
						eventType.splice( j--, 1 );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1740
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1741
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1742
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1743
				continue;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1744
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1745
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1746
			special = jQuery.event.special[ type ] || {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1747
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1748
			for ( var j = pos || 0; j < eventType.length; j++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1749
				handleObj = eventType[ j ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1750
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1751
				if ( handler.guid === handleObj.guid ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1752
					// remove the given handler for the given type
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1753
					if ( all || namespace.test( handleObj.namespace ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1754
						if ( pos == null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1755
							eventType.splice( j--, 1 );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1756
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1757
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1758
						if ( special.remove ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1759
							special.remove.call( elem, handleObj );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1760
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1761
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1762
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1763
					if ( pos != null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1764
						break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1765
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1766
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1767
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1768
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1769
			// remove generic event handler if no more handlers exist
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1770
			if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1771
				if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1772
					removeEvent( elem, type, elemData.handle );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1773
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1774
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1775
				ret = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1776
				delete events[ type ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1777
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1778
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1779
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1780
		// Remove the expando if it's no longer used
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1781
		if ( jQuery.isEmptyObject( events ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1782
			var handle = elemData.handle;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1783
			if ( handle ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1784
				handle.elem = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1785
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1786
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1787
			delete elemData.events;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1788
			delete elemData.handle;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1789
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1790
			if ( jQuery.isEmptyObject( elemData ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1791
				jQuery.removeData( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1792
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1793
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1794
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1795
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1796
	// bubbling is internal
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1797
	trigger: function( event, data, elem /*, bubbling */ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1798
		// Event object or event type
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1799
		var type = event.type || event,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1800
			bubbling = arguments[3];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1801
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1802
		if ( !bubbling ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1803
			event = typeof event === "object" ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1804
				// jQuery.Event object
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1805
				event[expando] ? event :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1806
				// Object literal
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1807
				jQuery.extend( jQuery.Event(type), event ) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1808
				// Just the event type (string)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1809
				jQuery.Event(type);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1810
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1811
			if ( type.indexOf("!") >= 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1812
				event.type = type = type.slice(0, -1);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1813
				event.exclusive = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1814
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1815
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1816
			// Handle a global trigger
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1817
			if ( !elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1818
				// Don't bubble custom events when global (to avoid too much overhead)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1819
				event.stopPropagation();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1820
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1821
				// Only trigger if we've ever bound an event for it
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1822
				if ( jQuery.event.global[ type ] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1823
					jQuery.each( jQuery.cache, function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1824
						if ( this.events && this.events[type] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1825
							jQuery.event.trigger( event, data, this.handle.elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1826
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1827
					});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1828
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1829
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1830
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1831
			// Handle triggering a single element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1832
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1833
			// don't do events on text and comment nodes
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1834
			if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1835
				return undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1836
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1837
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1838
			// Clean up in case it is reused
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1839
			event.result = undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1840
			event.target = elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1841
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1842
			// Clone the incoming data, if any
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1843
			data = jQuery.makeArray( data );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1844
			data.unshift( event );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1845
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1846
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1847
		event.currentTarget = elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1848
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1849
		// Trigger the event, it is assumed that "handle" is a function
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1850
		var handle = jQuery.data( elem, "handle" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1851
		if ( handle ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1852
			handle.apply( elem, data );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1853
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1854
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1855
		var parent = elem.parentNode || elem.ownerDocument;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1856
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1857
		// Trigger an inline bound script
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1858
		try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1859
			if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1860
				if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1861
					event.result = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1862
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1863
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1864
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1865
		// prevent IE from throwing an error for some elements with some event types, see #3533
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1866
		} catch (e) {}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1867
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1868
		if ( !event.isPropagationStopped() && parent ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1869
			jQuery.event.trigger( event, data, parent, true );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1870
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1871
		} else if ( !event.isDefaultPrevented() ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1872
			var target = event.target, old,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1873
				isClick = jQuery.nodeName(target, "a") && type === "click",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1874
				special = jQuery.event.special[ type ] || {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1875
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1876
			if ( (!special._default || special._default.call( elem, event ) === false) && 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1877
				!isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1878
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1879
				try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1880
					if ( target[ type ] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1881
						// Make sure that we don't accidentally re-trigger the onFOO events
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1882
						old = target[ "on" + type ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1883
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1884
						if ( old ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1885
							target[ "on" + type ] = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1886
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1887
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1888
						jQuery.event.triggered = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1889
						target[ type ]();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1890
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1891
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1892
				// prevent IE from throwing an error for some elements with some event types, see #3533
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1893
				} catch (e) {}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1894
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1895
				if ( old ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1896
					target[ "on" + type ] = old;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1897
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1898
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1899
				jQuery.event.triggered = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1900
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1901
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1902
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1903
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1904
	handle: function( event ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1905
		var all, handlers, namespaces, namespace, events;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1906
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1907
		event = arguments[0] = jQuery.event.fix( event || window.event );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1908
		event.currentTarget = this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1909
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1910
		// Namespaced event handlers
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1911
		all = event.type.indexOf(".") < 0 && !event.exclusive;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1912
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1913
		if ( !all ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1914
			namespaces = event.type.split(".");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1915
			event.type = namespaces.shift();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1916
			namespace = new RegExp("(^|\\.)" + namespaces.slice(0).sort().join("\\.(?:.*\\.)?") + "(\\.|$)");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1917
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1918
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1919
		var events = jQuery.data(this, "events"), handlers = events[ event.type ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1920
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1921
		if ( events && handlers ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1922
			// Clone the handlers to prevent manipulation
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1923
			handlers = handlers.slice(0);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1924
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1925
			for ( var j = 0, l = handlers.length; j < l; j++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1926
				var handleObj = handlers[ j ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1927
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1928
				// Filter the functions by class
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1929
				if ( all || namespace.test( handleObj.namespace ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1930
					// Pass in a reference to the handler function itself
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1931
					// So that we can later remove it
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1932
					event.handler = handleObj.handler;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1933
					event.data = handleObj.data;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1934
					event.handleObj = handleObj;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1935
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1936
					var ret = handleObj.handler.apply( this, arguments );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1937
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1938
					if ( ret !== undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1939
						event.result = ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1940
						if ( ret === false ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1941
							event.preventDefault();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1942
							event.stopPropagation();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1943
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1944
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1945
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1946
					if ( event.isImmediatePropagationStopped() ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1947
						break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1948
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1949
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1950
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1951
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1952
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1953
		return event.result;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1954
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1955
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1956
	props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY originalTarget pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1957
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1958
	fix: function( event ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1959
		if ( event[ expando ] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1960
			return event;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1961
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1962
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1963
		// store a copy of the original event object
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1964
		// and "clone" to set read-only properties
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1965
		var originalEvent = event;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1966
		event = jQuery.Event( originalEvent );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1967
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1968
		for ( var i = this.props.length, prop; i; ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1969
			prop = this.props[ --i ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1970
			event[ prop ] = originalEvent[ prop ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1971
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1972
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1973
		// Fix target property, if necessary
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1974
		if ( !event.target ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1975
			event.target = event.srcElement || document; // Fixes #1925 where srcElement might not be defined either
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1976
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1977
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1978
		// check if target is a textnode (safari)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1979
		if ( event.target.nodeType === 3 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1980
			event.target = event.target.parentNode;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1981
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1982
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1983
		// Add relatedTarget, if necessary
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1984
		if ( !event.relatedTarget && event.fromElement ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1985
			event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1986
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1987
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1988
		// Calculate pageX/Y if missing and clientX/Y available
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1989
		if ( event.pageX == null && event.clientX != null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1990
			var doc = document.documentElement, body = document.body;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1991
			event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1992
			event.pageY = event.clientY + (doc && doc.scrollTop  || body && body.scrollTop  || 0) - (doc && doc.clientTop  || body && body.clientTop  || 0);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1993
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1994
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1995
		// Add which for key events
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1996
		if ( !event.which && ((event.charCode || event.charCode === 0) ? event.charCode : event.keyCode) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1997
			event.which = event.charCode || event.keyCode;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1998
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  1999
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2000
		// Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2001
		if ( !event.metaKey && event.ctrlKey ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2002
			event.metaKey = event.ctrlKey;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2003
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2004
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2005
		// Add which for click: 1 === left; 2 === middle; 3 === right
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2006
		// Note: button is not normalized, so don't use it
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2007
		if ( !event.which && event.button !== undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2008
			event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2009
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2010
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2011
		return event;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2012
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2013
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2014
	// Deprecated, use jQuery.guid instead
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2015
	guid: 1E8,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2016
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2017
	// Deprecated, use jQuery.proxy instead
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2018
	proxy: jQuery.proxy,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2019
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2020
	special: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2021
		ready: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2022
			// Make sure the ready event is setup
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2023
			setup: jQuery.bindReady,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2024
			teardown: jQuery.noop
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2025
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2026
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2027
		live: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2028
			add: function( handleObj ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2029
				jQuery.event.add( this, handleObj.origType, jQuery.extend({}, handleObj, {handler: liveHandler}) ); 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2030
			},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2031
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2032
			remove: function( handleObj ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2033
				var remove = true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2034
					type = handleObj.origType.replace(rnamespaces, "");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2035
				
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2036
				jQuery.each( jQuery.data(this, "events").live || [], function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2037
					if ( type === this.origType.replace(rnamespaces, "") ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2038
						remove = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2039
						return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2040
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2041
				});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2042
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2043
				if ( remove ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2044
					jQuery.event.remove( this, handleObj.origType, liveHandler );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2045
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2046
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2047
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2048
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2049
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2050
		beforeunload: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2051
			setup: function( data, namespaces, eventHandle ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2052
				// We only want to do this special case on windows
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2053
				if ( this.setInterval ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2054
					this.onbeforeunload = eventHandle;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2055
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2056
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2057
				return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2058
			},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2059
			teardown: function( namespaces, eventHandle ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2060
				if ( this.onbeforeunload === eventHandle ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2061
					this.onbeforeunload = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2062
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2063
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2064
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2065
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2066
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2067
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2068
var removeEvent = document.removeEventListener ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2069
	function( elem, type, handle ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2070
		elem.removeEventListener( type, handle, false );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2071
	} : 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2072
	function( elem, type, handle ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2073
		elem.detachEvent( "on" + type, handle );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2074
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2075
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2076
jQuery.Event = function( src ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2077
	// Allow instantiation without the 'new' keyword
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2078
	if ( !this.preventDefault ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2079
		return new jQuery.Event( src );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2080
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2081
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2082
	// Event object
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2083
	if ( src && src.type ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2084
		this.originalEvent = src;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2085
		this.type = src.type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2086
	// Event type
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2087
	} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2088
		this.type = src;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2089
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2090
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2091
	// timeStamp is buggy for some events on Firefox(#3843)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2092
	// So we won't rely on the native value
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2093
	this.timeStamp = now();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2094
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2095
	// Mark it as fixed
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2096
	this[ expando ] = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2097
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2098
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2099
function returnFalse() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2100
	return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2101
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2102
function returnTrue() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2103
	return true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2104
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2105
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2106
// jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2107
// http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2108
jQuery.Event.prototype = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2109
	preventDefault: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2110
		this.isDefaultPrevented = returnTrue;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2111
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2112
		var e = this.originalEvent;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2113
		if ( !e ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2114
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2115
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2116
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2117
		// if preventDefault exists run it on the original event
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2118
		if ( e.preventDefault ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2119
			e.preventDefault();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2120
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2121
		// otherwise set the returnValue property of the original event to false (IE)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2122
		e.returnValue = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2123
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2124
	stopPropagation: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2125
		this.isPropagationStopped = returnTrue;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2126
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2127
		var e = this.originalEvent;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2128
		if ( !e ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2129
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2130
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2131
		// if stopPropagation exists run it on the original event
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2132
		if ( e.stopPropagation ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2133
			e.stopPropagation();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2134
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2135
		// otherwise set the cancelBubble property of the original event to true (IE)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2136
		e.cancelBubble = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2137
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2138
	stopImmediatePropagation: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2139
		this.isImmediatePropagationStopped = returnTrue;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2140
		this.stopPropagation();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2141
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2142
	isDefaultPrevented: returnFalse,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2143
	isPropagationStopped: returnFalse,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2144
	isImmediatePropagationStopped: returnFalse
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2145
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2146
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2147
// Checks if an event happened on an element within another element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2148
// Used in jQuery.event.special.mouseenter and mouseleave handlers
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2149
var withinElement = function( event ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2150
	// Check if mouse(over|out) are still within the same parent element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2151
	var parent = event.relatedTarget;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2152
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2153
	// Firefox sometimes assigns relatedTarget a XUL element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2154
	// which we cannot access the parentNode property of
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2155
	try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2156
		// Traverse up the tree
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2157
		while ( parent && parent !== this ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2158
			parent = parent.parentNode;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2159
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2160
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2161
		if ( parent !== this ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2162
			// set the correct event type
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2163
			event.type = event.data;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2164
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2165
			// handle event if we actually just moused on to a non sub-element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2166
			jQuery.event.handle.apply( this, arguments );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2167
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2168
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2169
	// assuming we've left the element since we most likely mousedover a xul element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2170
	} catch(e) { }
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2171
},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2172
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2173
// In case of event delegation, we only need to rename the event.type,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2174
// liveHandler will take care of the rest.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2175
delegate = function( event ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2176
	event.type = event.data;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2177
	jQuery.event.handle.apply( this, arguments );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2178
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2179
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2180
// Create mouseenter and mouseleave events
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2181
jQuery.each({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2182
	mouseenter: "mouseover",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2183
	mouseleave: "mouseout"
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2184
}, function( orig, fix ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2185
	jQuery.event.special[ orig ] = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2186
		setup: function( data ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2187
			jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2188
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2189
		teardown: function( data ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2190
			jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2191
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2192
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2193
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2194
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2195
// submit delegation
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2196
if ( !jQuery.support.submitBubbles ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2197
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2198
	jQuery.event.special.submit = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2199
		setup: function( data, namespaces ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2200
			if ( this.nodeName.toLowerCase() !== "form" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2201
				jQuery.event.add(this, "click.specialSubmit", function( e ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2202
					var elem = e.target, type = elem.type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2203
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2204
					if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2205
						return trigger( "submit", this, arguments );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2206
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2207
				});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2208
	 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2209
				jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2210
					var elem = e.target, type = elem.type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2211
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2212
					if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2213
						return trigger( "submit", this, arguments );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2214
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2215
				});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2216
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2217
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2218
				return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2219
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2220
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2221
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2222
		teardown: function( namespaces ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2223
			jQuery.event.remove( this, ".specialSubmit" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2224
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2225
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2226
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2227
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2228
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2229
// change delegation, happens here so we have bind.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2230
if ( !jQuery.support.changeBubbles ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2231
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2232
	var formElems = /textarea|input|select/i,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2233
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2234
	changeFilters,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2235
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2236
	getVal = function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2237
		var type = elem.type, val = elem.value;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2238
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2239
		if ( type === "radio" || type === "checkbox" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2240
			val = elem.checked;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2241
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2242
		} else if ( type === "select-multiple" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2243
			val = elem.selectedIndex > -1 ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2244
				jQuery.map( elem.options, function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2245
					return elem.selected;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2246
				}).join("-") :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2247
				"";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2248
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2249
		} else if ( elem.nodeName.toLowerCase() === "select" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2250
			val = elem.selectedIndex;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2251
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2252
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2253
		return val;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2254
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2255
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2256
	testChange = function testChange( e ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2257
		var elem = e.target, data, val;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2258
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2259
		if ( !formElems.test( elem.nodeName ) || elem.readOnly ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2260
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2261
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2262
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2263
		data = jQuery.data( elem, "_change_data" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2264
		val = getVal(elem);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2265
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2266
		// the current data will be also retrieved by beforeactivate
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2267
		if ( e.type !== "focusout" || elem.type !== "radio" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2268
			jQuery.data( elem, "_change_data", val );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2269
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2270
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2271
		if ( data === undefined || val === data ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2272
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2273
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2274
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2275
		if ( data != null || val ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2276
			e.type = "change";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2277
			return jQuery.event.trigger( e, arguments[1], elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2278
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2279
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2280
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2281
	jQuery.event.special.change = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2282
		filters: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2283
			focusout: testChange, 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2284
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2285
			click: function( e ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2286
				var elem = e.target, type = elem.type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2287
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2288
				if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2289
					return testChange.call( this, e );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2290
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2291
			},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2292
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2293
			// Change has to be called before submit
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2294
			// Keydown will be called before keypress, which is used in submit-event delegation
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2295
			keydown: function( e ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2296
				var elem = e.target, type = elem.type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2297
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2298
				if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2299
					(e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2300
					type === "select-multiple" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2301
					return testChange.call( this, e );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2302
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2303
			},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2304
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2305
			// Beforeactivate happens also before the previous element is blurred
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2306
			// with this event you can't trigger a change event, but you can store
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2307
			// information/focus[in] is not needed anymore
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2308
			beforeactivate: function( e ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2309
				var elem = e.target;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2310
				jQuery.data( elem, "_change_data", getVal(elem) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2311
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2312
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2313
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2314
		setup: function( data, namespaces ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2315
			if ( this.type === "file" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2316
				return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2317
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2318
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2319
			for ( var type in changeFilters ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2320
				jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2321
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2322
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2323
			return formElems.test( this.nodeName );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2324
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2325
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2326
		teardown: function( namespaces ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2327
			jQuery.event.remove( this, ".specialChange" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2328
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2329
			return formElems.test( this.nodeName );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2330
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2331
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2332
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2333
	changeFilters = jQuery.event.special.change.filters;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2334
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2335
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2336
function trigger( type, elem, args ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2337
	args[0].type = type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2338
	return jQuery.event.handle.apply( elem, args );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2339
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2340
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2341
// Create "bubbling" focus and blur events
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2342
if ( document.addEventListener ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2343
	jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2344
		jQuery.event.special[ fix ] = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2345
			setup: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2346
				this.addEventListener( orig, handler, true );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2347
			}, 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2348
			teardown: function() { 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2349
				this.removeEventListener( orig, handler, true );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2350
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2351
		};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2352
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2353
		function handler( e ) { 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2354
			e = jQuery.event.fix( e );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2355
			e.type = fix;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2356
			return jQuery.event.handle.call( this, e );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2357
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2358
	});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2359
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2360
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2361
jQuery.each(["bind", "one"], function( i, name ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2362
	jQuery.fn[ name ] = function( type, data, fn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2363
		// Handle object literals
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2364
		if ( typeof type === "object" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2365
			for ( var key in type ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2366
				this[ name ](key, data, type[key], fn);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2367
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2368
			return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2369
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2370
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2371
		if ( jQuery.isFunction( data ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2372
			fn = data;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2373
			data = undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2374
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2375
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2376
		var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2377
			jQuery( this ).unbind( event, handler );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2378
			return fn.apply( this, arguments );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2379
		}) : fn;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2380
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2381
		if ( type === "unload" && name !== "one" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2382
			this.one( type, data, fn );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2383
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2384
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2385
			for ( var i = 0, l = this.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2386
				jQuery.event.add( this[i], type, handler, data );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2387
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2388
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2389
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2390
		return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2391
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2392
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2393
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2394
jQuery.fn.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2395
	unbind: function( type, fn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2396
		// Handle object literals
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2397
		if ( typeof type === "object" && !type.preventDefault ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2398
			for ( var key in type ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2399
				this.unbind(key, type[key]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2400
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2401
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2402
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2403
			for ( var i = 0, l = this.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2404
				jQuery.event.remove( this[i], type, fn );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2405
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2406
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2407
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2408
		return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2409
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2410
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2411
	delegate: function( selector, types, data, fn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2412
		return this.live( types, data, fn, selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2413
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2414
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2415
	undelegate: function( selector, types, fn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2416
		if ( arguments.length === 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2417
				return this.unbind( "live" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2418
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2419
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2420
			return this.die( types, null, fn, selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2421
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2422
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2423
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2424
	trigger: function( type, data ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2425
		return this.each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2426
			jQuery.event.trigger( type, data, this );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2427
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2428
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2429
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2430
	triggerHandler: function( type, data ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2431
		if ( this[0] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2432
			var event = jQuery.Event( type );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2433
			event.preventDefault();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2434
			event.stopPropagation();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2435
			jQuery.event.trigger( event, data, this[0] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2436
			return event.result;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2437
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2438
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2439
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2440
	toggle: function( fn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2441
		// Save reference to arguments for access in closure
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2442
		var args = arguments, i = 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2443
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2444
		// link all the functions, so any of them can unbind this click handler
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2445
		while ( i < args.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2446
			jQuery.proxy( fn, args[ i++ ] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2447
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2448
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2449
		return this.click( jQuery.proxy( fn, function( event ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2450
			// Figure out which function to execute
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2451
			var lastToggle = ( jQuery.data( this, "lastToggle" + fn.guid ) || 0 ) % i;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2452
			jQuery.data( this, "lastToggle" + fn.guid, lastToggle + 1 );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2453
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2454
			// Make sure that clicks stop
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2455
			event.preventDefault();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2456
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2457
			// and execute the function
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2458
			return args[ lastToggle ].apply( this, arguments ) || false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2459
		}));
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2460
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2461
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2462
	hover: function( fnOver, fnOut ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2463
		return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2464
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2465
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2466
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2467
var liveMap = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2468
	focus: "focusin",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2469
	blur: "focusout",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2470
	mouseenter: "mouseover",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2471
	mouseleave: "mouseout"
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2472
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2473
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2474
jQuery.each(["live", "die"], function( i, name ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2475
	jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2476
		var type, i = 0, match, namespaces, preType,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2477
			selector = origSelector || this.selector,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2478
			context = origSelector ? this : jQuery( this.context );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2479
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2480
		if ( jQuery.isFunction( data ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2481
			fn = data;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2482
			data = undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2483
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2484
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2485
		types = (types || "").split(" ");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2486
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2487
		while ( (type = types[ i++ ]) != null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2488
			match = rnamespaces.exec( type );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2489
			namespaces = "";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2490
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2491
			if ( match )  {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2492
				namespaces = match[0];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2493
				type = type.replace( rnamespaces, "" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2494
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2495
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2496
			if ( type === "hover" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2497
				types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2498
				continue;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2499
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2500
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2501
			preType = type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2502
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2503
			if ( type === "focus" || type === "blur" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2504
				types.push( liveMap[ type ] + namespaces );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2505
				type = type + namespaces;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2506
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2507
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2508
				type = (liveMap[ type ] || type) + namespaces;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2509
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2510
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2511
			if ( name === "live" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2512
				// bind live handler
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2513
				context.each(function(){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2514
					jQuery.event.add( this, liveConvert( type, selector ),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2515
						{ data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2516
				});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2517
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2518
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2519
				// unbind live handler
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2520
				context.unbind( liveConvert( type, selector ), fn );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2521
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2522
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2523
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2524
		return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2525
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2526
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2527
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2528
function liveHandler( event ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2529
	var stop, elems = [], selectors = [], args = arguments,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2530
		related, match, handleObj, elem, j, i, l, data,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2531
		events = jQuery.data( this, "events" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2532
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2533
	// Make sure we avoid non-left-click bubbling in Firefox (#3861)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2534
	if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2535
		return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2536
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2537
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2538
	event.liveFired = this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2539
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2540
	var live = events.live.slice(0);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2541
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2542
	for ( j = 0; j < live.length; j++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2543
		handleObj = live[j];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2544
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2545
		if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2546
			selectors.push( handleObj.selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2547
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2548
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2549
			live.splice( j--, 1 );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2550
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2551
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2552
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2553
	match = jQuery( event.target ).closest( selectors, event.currentTarget );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2554
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2555
	for ( i = 0, l = match.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2556
		for ( j = 0; j < live.length; j++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2557
			handleObj = live[j];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2558
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2559
			if ( match[i].selector === handleObj.selector ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2560
				elem = match[i].elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2561
				related = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2562
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2563
				// Those two events require additional checking
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2564
				if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2565
					related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2566
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2567
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2568
				if ( !related || related !== elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2569
					elems.push({ elem: elem, handleObj: handleObj });
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2570
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2571
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2572
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2573
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2574
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2575
	for ( i = 0, l = elems.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2576
		match = elems[i];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2577
		event.currentTarget = match.elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2578
		event.data = match.handleObj.data;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2579
		event.handleObj = match.handleObj;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2580
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2581
		if ( match.handleObj.origHandler.apply( match.elem, args ) === false ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2582
			stop = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2583
			break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2584
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2585
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2586
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2587
	return stop;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2588
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2589
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2590
function liveConvert( type, selector ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2591
	return "live." + (type && type !== "*" ? type + "." : "") + selector.replace(/\./g, "`").replace(/ /g, "&");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2592
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2593
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2594
jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2595
	"mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2596
	"change select submit keydown keypress keyup error").split(" "), function( i, name ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2597
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2598
	// Handle event binding
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2599
	jQuery.fn[ name ] = function( fn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2600
		return fn ? this.bind( name, fn ) : this.trigger( name );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2601
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2602
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2603
	if ( jQuery.attrFn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2604
		jQuery.attrFn[ name ] = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2605
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2606
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2607
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2608
// Prevent memory leaks in IE
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2609
// Window isn't included so as not to unbind existing unload events
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2610
// More info:
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2611
//  - http://isaacschlueter.com/2006/10/msie-memory-leaks/
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2612
if ( window.attachEvent && !window.addEventListener ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2613
	window.attachEvent("onunload", function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2614
		for ( var id in jQuery.cache ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2615
			if ( jQuery.cache[ id ].handle ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2616
				// Try/Catch is to handle iframes being unloaded, see #4280
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2617
				try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2618
					jQuery.event.remove( jQuery.cache[ id ].handle.elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2619
				} catch(e) {}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2620
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2621
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2622
	});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2623
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2624
/*!
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2625
 * Sizzle CSS Selector Engine - v1.0
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2626
 *  Copyright 2009, The Dojo Foundation
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2627
 *  Released under the MIT, BSD, and GPL Licenses.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2628
 *  More information: http://sizzlejs.com/
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2629
 */
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2630
(function(){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2631
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2632
var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2633
	done = 0,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2634
	toString = Object.prototype.toString,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2635
	hasDuplicate = false,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2636
	baseHasDuplicate = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2637
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2638
// Here we check if the JavaScript engine is using some sort of
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2639
// optimization where it does not always call our comparision
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2640
// function. If that is the case, discard the hasDuplicate value.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2641
//   Thus far that includes Google Chrome.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2642
[0, 0].sort(function(){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2643
	baseHasDuplicate = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2644
	return 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2645
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2646
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2647
var Sizzle = function(selector, context, results, seed) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2648
	results = results || [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2649
	var origContext = context = context || document;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2650
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2651
	if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2652
		return [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2653
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2654
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2655
	if ( !selector || typeof selector !== "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2656
		return results;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2657
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2658
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2659
	var parts = [], m, set, checkSet, extra, prune = true, contextXML = isXML(context),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2660
		soFar = selector;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2661
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2662
	// Reset the position of the chunker regexp (start from head)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2663
	while ( (chunker.exec(""), m = chunker.exec(soFar)) !== null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2664
		soFar = m[3];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2665
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2666
		parts.push( m[1] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2667
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2668
		if ( m[2] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2669
			extra = m[3];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2670
			break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2671
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2672
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2673
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2674
	if ( parts.length > 1 && origPOS.exec( selector ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2675
		if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2676
			set = posProcess( parts[0] + parts[1], context );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2677
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2678
			set = Expr.relative[ parts[0] ] ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2679
				[ context ] :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2680
				Sizzle( parts.shift(), context );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2681
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2682
			while ( parts.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2683
				selector = parts.shift();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2684
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2685
				if ( Expr.relative[ selector ] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2686
					selector += parts.shift();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2687
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2688
				
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2689
				set = posProcess( selector, set );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2690
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2691
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2692
	} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2693
		// Take a shortcut and set the context if the root selector is an ID
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2694
		// (but not if it'll be faster if the inner selector is an ID)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2695
		if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2696
				Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2697
			var ret = Sizzle.find( parts.shift(), context, contextXML );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2698
			context = ret.expr ? Sizzle.filter( ret.expr, ret.set )[0] : ret.set[0];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2699
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2700
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2701
		if ( context ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2702
			var ret = seed ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2703
				{ expr: parts.pop(), set: makeArray(seed) } :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2704
				Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2705
			set = ret.expr ? Sizzle.filter( ret.expr, ret.set ) : ret.set;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2706
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2707
			if ( parts.length > 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2708
				checkSet = makeArray(set);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2709
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2710
				prune = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2711
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2712
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2713
			while ( parts.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2714
				var cur = parts.pop(), pop = cur;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2715
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2716
				if ( !Expr.relative[ cur ] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2717
					cur = "";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2718
				} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2719
					pop = parts.pop();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2720
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2721
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2722
				if ( pop == null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2723
					pop = context;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2724
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2725
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2726
				Expr.relative[ cur ]( checkSet, pop, contextXML );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2727
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2728
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2729
			checkSet = parts = [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2730
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2731
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2732
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2733
	if ( !checkSet ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2734
		checkSet = set;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2735
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2736
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2737
	if ( !checkSet ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2738
		Sizzle.error( cur || selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2739
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2740
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2741
	if ( toString.call(checkSet) === "[object Array]" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2742
		if ( !prune ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2743
			results.push.apply( results, checkSet );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2744
		} else if ( context && context.nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2745
			for ( var i = 0; checkSet[i] != null; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2746
				if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && contains(context, checkSet[i])) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2747
					results.push( set[i] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2748
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2749
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2750
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2751
			for ( var i = 0; checkSet[i] != null; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2752
				if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2753
					results.push( set[i] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2754
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2755
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2756
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2757
	} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2758
		makeArray( checkSet, results );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2759
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2760
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2761
	if ( extra ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2762
		Sizzle( extra, origContext, results, seed );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2763
		Sizzle.uniqueSort( results );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2764
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2765
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2766
	return results;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2767
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2768
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2769
Sizzle.uniqueSort = function(results){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2770
	if ( sortOrder ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2771
		hasDuplicate = baseHasDuplicate;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2772
		results.sort(sortOrder);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2773
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2774
		if ( hasDuplicate ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2775
			for ( var i = 1; i < results.length; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2776
				if ( results[i] === results[i-1] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2777
					results.splice(i--, 1);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2778
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2779
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2780
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2781
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2782
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2783
	return results;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2784
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2785
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2786
Sizzle.matches = function(expr, set){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2787
	return Sizzle(expr, null, null, set);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2788
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2789
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2790
Sizzle.find = function(expr, context, isXML){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2791
	var set, match;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2792
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2793
	if ( !expr ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2794
		return [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2795
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2796
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2797
	for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2798
		var type = Expr.order[i], match;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2799
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2800
		if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2801
			var left = match[1];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2802
			match.splice(1,1);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2803
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2804
			if ( left.substr( left.length - 1 ) !== "\\" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2805
				match[1] = (match[1] || "").replace(/\\/g, "");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2806
				set = Expr.find[ type ]( match, context, isXML );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2807
				if ( set != null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2808
					expr = expr.replace( Expr.match[ type ], "" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2809
					break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2810
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2811
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2812
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2813
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2814
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2815
	if ( !set ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2816
		set = context.getElementsByTagName("*");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2817
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2818
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2819
	return {set: set, expr: expr};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2820
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2821
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2822
Sizzle.filter = function(expr, set, inplace, not){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2823
	var old = expr, result = [], curLoop = set, match, anyFound,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2824
		isXMLFilter = set && set[0] && isXML(set[0]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2825
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2826
	while ( expr && set.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2827
		for ( var type in Expr.filter ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2828
			if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2829
				var filter = Expr.filter[ type ], found, item, left = match[1];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2830
				anyFound = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2831
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2832
				match.splice(1,1);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2833
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2834
				if ( left.substr( left.length - 1 ) === "\\" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2835
					continue;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2836
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2837
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2838
				if ( curLoop === result ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2839
					result = [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2840
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2841
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2842
				if ( Expr.preFilter[ type ] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2843
					match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2844
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2845
					if ( !match ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2846
						anyFound = found = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2847
					} else if ( match === true ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2848
						continue;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2849
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2850
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2851
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2852
				if ( match ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2853
					for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2854
						if ( item ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2855
							found = filter( item, match, i, curLoop );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2856
							var pass = not ^ !!found;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2857
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2858
							if ( inplace && found != null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2859
								if ( pass ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2860
									anyFound = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2861
								} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2862
									curLoop[i] = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2863
								}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2864
							} else if ( pass ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2865
								result.push( item );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2866
								anyFound = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2867
							}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2868
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2869
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2870
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2871
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2872
				if ( found !== undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2873
					if ( !inplace ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2874
						curLoop = result;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2875
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2876
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2877
					expr = expr.replace( Expr.match[ type ], "" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2878
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2879
					if ( !anyFound ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2880
						return [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2881
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2882
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2883
					break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2884
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2885
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2886
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2887
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2888
		// Improper expression
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2889
		if ( expr === old ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2890
			if ( anyFound == null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2891
				Sizzle.error( expr );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2892
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2893
				break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2894
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2895
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2896
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2897
		old = expr;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2898
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2899
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2900
	return curLoop;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2901
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2902
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2903
Sizzle.error = function( msg ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2904
	throw "Syntax error, unrecognized expression: " + msg;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2905
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2906
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2907
var Expr = Sizzle.selectors = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2908
	order: [ "ID", "NAME", "TAG" ],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2909
	match: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2910
		ID: /#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2911
		CLASS: /\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2912
		NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2913
		ATTR: /\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2914
		TAG: /^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2915
		CHILD: /:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2916
		POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2917
		PSEUDO: /:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2918
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2919
	leftMatch: {},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2920
	attrMap: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2921
		"class": "className",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2922
		"for": "htmlFor"
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2923
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2924
	attrHandle: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2925
		href: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2926
			return elem.getAttribute("href");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2927
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2928
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2929
	relative: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2930
		"+": function(checkSet, part){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2931
			var isPartStr = typeof part === "string",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2932
				isTag = isPartStr && !/\W/.test(part),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2933
				isPartStrNotTag = isPartStr && !isTag;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2934
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2935
			if ( isTag ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2936
				part = part.toLowerCase();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2937
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2938
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2939
			for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2940
				if ( (elem = checkSet[i]) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2941
					while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2942
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2943
					checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2944
						elem || false :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2945
						elem === part;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2946
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2947
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2948
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2949
			if ( isPartStrNotTag ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2950
				Sizzle.filter( part, checkSet, true );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2951
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2952
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2953
		">": function(checkSet, part){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2954
			var isPartStr = typeof part === "string";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2955
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2956
			if ( isPartStr && !/\W/.test(part) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2957
				part = part.toLowerCase();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2958
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2959
				for ( var i = 0, l = checkSet.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2960
					var elem = checkSet[i];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2961
					if ( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2962
						var parent = elem.parentNode;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2963
						checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2964
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2965
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2966
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2967
				for ( var i = 0, l = checkSet.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2968
					var elem = checkSet[i];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2969
					if ( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2970
						checkSet[i] = isPartStr ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2971
							elem.parentNode :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2972
							elem.parentNode === part;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2973
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2974
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2975
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2976
				if ( isPartStr ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2977
					Sizzle.filter( part, checkSet, true );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2978
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2979
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2980
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2981
		"": function(checkSet, part, isXML){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2982
			var doneName = done++, checkFn = dirCheck;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2983
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2984
			if ( typeof part === "string" && !/\W/.test(part) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2985
				var nodeCheck = part = part.toLowerCase();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2986
				checkFn = dirNodeCheck;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2987
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2988
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2989
			checkFn("parentNode", part, doneName, checkSet, nodeCheck, isXML);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2990
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2991
		"~": function(checkSet, part, isXML){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2992
			var doneName = done++, checkFn = dirCheck;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2993
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2994
			if ( typeof part === "string" && !/\W/.test(part) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2995
				var nodeCheck = part = part.toLowerCase();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2996
				checkFn = dirNodeCheck;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2997
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2998
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  2999
			checkFn("previousSibling", part, doneName, checkSet, nodeCheck, isXML);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3000
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3001
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3002
	find: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3003
		ID: function(match, context, isXML){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3004
			if ( typeof context.getElementById !== "undefined" && !isXML ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3005
				var m = context.getElementById(match[1]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3006
				return m ? [m] : [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3007
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3008
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3009
		NAME: function(match, context){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3010
			if ( typeof context.getElementsByName !== "undefined" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3011
				var ret = [], results = context.getElementsByName(match[1]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3012
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3013
				for ( var i = 0, l = results.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3014
					if ( results[i].getAttribute("name") === match[1] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3015
						ret.push( results[i] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3016
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3017
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3018
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3019
				return ret.length === 0 ? null : ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3020
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3021
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3022
		TAG: function(match, context){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3023
			return context.getElementsByTagName(match[1]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3024
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3025
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3026
	preFilter: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3027
		CLASS: function(match, curLoop, inplace, result, not, isXML){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3028
			match = " " + match[1].replace(/\\/g, "") + " ";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3029
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3030
			if ( isXML ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3031
				return match;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3032
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3033
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3034
			for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3035
				if ( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3036
					if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n]/g, " ").indexOf(match) >= 0) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3037
						if ( !inplace ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3038
							result.push( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3039
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3040
					} else if ( inplace ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3041
						curLoop[i] = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3042
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3043
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3044
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3045
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3046
			return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3047
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3048
		ID: function(match){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3049
			return match[1].replace(/\\/g, "");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3050
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3051
		TAG: function(match, curLoop){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3052
			return match[1].toLowerCase();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3053
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3054
		CHILD: function(match){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3055
			if ( match[1] === "nth" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3056
				// parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3057
				var test = /(-?)(\d*)n((?:\+|-)?\d*)/.exec(
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3058
					match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3059
					!/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3060
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3061
				// calculate the numbers (first)n+(last) including if they are negative
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3062
				match[2] = (test[1] + (test[2] || 1)) - 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3063
				match[3] = test[3] - 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3064
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3065
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3066
			// TODO: Move to normal caching system
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3067
			match[0] = done++;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3068
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3069
			return match;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3070
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3071
		ATTR: function(match, curLoop, inplace, result, not, isXML){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3072
			var name = match[1].replace(/\\/g, "");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3073
			
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3074
			if ( !isXML && Expr.attrMap[name] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3075
				match[1] = Expr.attrMap[name];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3076
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3077
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3078
			if ( match[2] === "~=" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3079
				match[4] = " " + match[4] + " ";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3080
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3081
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3082
			return match;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3083
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3084
		PSEUDO: function(match, curLoop, inplace, result, not){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3085
			if ( match[1] === "not" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3086
				// If we're dealing with a complex expression, or a simple one
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3087
				if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3088
					match[3] = Sizzle(match[3], null, null, curLoop);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3089
				} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3090
					var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3091
					if ( !inplace ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3092
						result.push.apply( result, ret );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3093
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3094
					return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3095
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3096
			} else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3097
				return true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3098
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3099
			
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3100
			return match;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3101
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3102
		POS: function(match){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3103
			match.unshift( true );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3104
			return match;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3105
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3106
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3107
	filters: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3108
		enabled: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3109
			return elem.disabled === false && elem.type !== "hidden";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3110
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3111
		disabled: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3112
			return elem.disabled === true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3113
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3114
		checked: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3115
			return elem.checked === true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3116
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3117
		selected: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3118
			// Accessing this property makes selected-by-default
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3119
			// options in Safari work properly
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3120
			elem.parentNode.selectedIndex;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3121
			return elem.selected === true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3122
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3123
		parent: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3124
			return !!elem.firstChild;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3125
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3126
		empty: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3127
			return !elem.firstChild;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3128
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3129
		has: function(elem, i, match){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3130
			return !!Sizzle( match[3], elem ).length;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3131
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3132
		header: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3133
			return /h\d/i.test( elem.nodeName );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3134
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3135
		text: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3136
			return "text" === elem.type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3137
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3138
		radio: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3139
			return "radio" === elem.type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3140
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3141
		checkbox: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3142
			return "checkbox" === elem.type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3143
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3144
		file: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3145
			return "file" === elem.type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3146
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3147
		password: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3148
			return "password" === elem.type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3149
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3150
		submit: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3151
			return "submit" === elem.type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3152
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3153
		image: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3154
			return "image" === elem.type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3155
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3156
		reset: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3157
			return "reset" === elem.type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3158
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3159
		button: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3160
			return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3161
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3162
		input: function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3163
			return /input|select|textarea|button/i.test(elem.nodeName);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3164
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3165
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3166
	setFilters: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3167
		first: function(elem, i){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3168
			return i === 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3169
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3170
		last: function(elem, i, match, array){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3171
			return i === array.length - 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3172
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3173
		even: function(elem, i){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3174
			return i % 2 === 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3175
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3176
		odd: function(elem, i){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3177
			return i % 2 === 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3178
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3179
		lt: function(elem, i, match){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3180
			return i < match[3] - 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3181
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3182
		gt: function(elem, i, match){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3183
			return i > match[3] - 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3184
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3185
		nth: function(elem, i, match){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3186
			return match[3] - 0 === i;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3187
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3188
		eq: function(elem, i, match){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3189
			return match[3] - 0 === i;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3190
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3191
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3192
	filter: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3193
		PSEUDO: function(elem, match, i, array){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3194
			var name = match[1], filter = Expr.filters[ name ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3195
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3196
			if ( filter ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3197
				return filter( elem, i, match, array );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3198
			} else if ( name === "contains" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3199
				return (elem.textContent || elem.innerText || getText([ elem ]) || "").indexOf(match[3]) >= 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3200
			} else if ( name === "not" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3201
				var not = match[3];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3202
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3203
				for ( var i = 0, l = not.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3204
					if ( not[i] === elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3205
						return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3206
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3207
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3208
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3209
				return true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3210
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3211
				Sizzle.error( "Syntax error, unrecognized expression: " + name );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3212
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3213
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3214
		CHILD: function(elem, match){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3215
			var type = match[1], node = elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3216
			switch (type) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3217
				case 'only':
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3218
				case 'first':
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3219
					while ( (node = node.previousSibling) )	 {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3220
						if ( node.nodeType === 1 ) { 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3221
							return false; 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3222
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3223
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3224
					if ( type === "first" ) { 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3225
						return true; 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3226
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3227
					node = elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3228
				case 'last':
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3229
					while ( (node = node.nextSibling) )	 {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3230
						if ( node.nodeType === 1 ) { 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3231
							return false; 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3232
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3233
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3234
					return true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3235
				case 'nth':
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3236
					var first = match[2], last = match[3];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3237
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3238
					if ( first === 1 && last === 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3239
						return true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3240
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3241
					
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3242
					var doneName = match[0],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3243
						parent = elem.parentNode;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3244
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3245
					if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3246
						var count = 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3247
						for ( node = parent.firstChild; node; node = node.nextSibling ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3248
							if ( node.nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3249
								node.nodeIndex = ++count;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3250
							}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3251
						} 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3252
						parent.sizcache = doneName;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3253
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3254
					
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3255
					var diff = elem.nodeIndex - last;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3256
					if ( first === 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3257
						return diff === 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3258
					} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3259
						return ( diff % first === 0 && diff / first >= 0 );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3260
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3261
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3262
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3263
		ID: function(elem, match){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3264
			return elem.nodeType === 1 && elem.getAttribute("id") === match;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3265
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3266
		TAG: function(elem, match){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3267
			return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3268
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3269
		CLASS: function(elem, match){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3270
			return (" " + (elem.className || elem.getAttribute("class")) + " ")
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3271
				.indexOf( match ) > -1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3272
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3273
		ATTR: function(elem, match){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3274
			var name = match[1],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3275
				result = Expr.attrHandle[ name ] ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3276
					Expr.attrHandle[ name ]( elem ) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3277
					elem[ name ] != null ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3278
						elem[ name ] :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3279
						elem.getAttribute( name ),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3280
				value = result + "",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3281
				type = match[2],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3282
				check = match[4];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3283
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3284
			return result == null ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3285
				type === "!=" :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3286
				type === "=" ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3287
				value === check :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3288
				type === "*=" ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3289
				value.indexOf(check) >= 0 :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3290
				type === "~=" ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3291
				(" " + value + " ").indexOf(check) >= 0 :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3292
				!check ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3293
				value && result !== false :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3294
				type === "!=" ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3295
				value !== check :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3296
				type === "^=" ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3297
				value.indexOf(check) === 0 :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3298
				type === "$=" ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3299
				value.substr(value.length - check.length) === check :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3300
				type === "|=" ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3301
				value === check || value.substr(0, check.length + 1) === check + "-" :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3302
				false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3303
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3304
		POS: function(elem, match, i, array){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3305
			var name = match[2], filter = Expr.setFilters[ name ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3306
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3307
			if ( filter ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3308
				return filter( elem, i, match, array );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3309
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3310
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3311
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3312
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3313
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3314
var origPOS = Expr.match.POS;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3315
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3316
for ( var type in Expr.match ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3317
	Expr.match[ type ] = new RegExp( Expr.match[ type ].source + /(?![^\[]*\])(?![^\(]*\))/.source );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3318
	Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, function(all, num){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3319
		return "\\" + (num - 0 + 1);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3320
	}));
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3321
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3322
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3323
var makeArray = function(array, results) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3324
	array = Array.prototype.slice.call( array, 0 );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3325
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3326
	if ( results ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3327
		results.push.apply( results, array );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3328
		return results;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3329
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3330
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3331
	return array;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3332
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3333
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3334
// Perform a simple check to determine if the browser is capable of
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3335
// converting a NodeList to an array using builtin methods.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3336
// Also verifies that the returned array holds DOM nodes
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3337
// (which is not the case in the Blackberry browser)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3338
try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3339
	Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3340
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3341
// Provide a fallback method if it does not work
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3342
} catch(e){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3343
	makeArray = function(array, results) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3344
		var ret = results || [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3345
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3346
		if ( toString.call(array) === "[object Array]" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3347
			Array.prototype.push.apply( ret, array );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3348
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3349
			if ( typeof array.length === "number" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3350
				for ( var i = 0, l = array.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3351
					ret.push( array[i] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3352
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3353
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3354
				for ( var i = 0; array[i]; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3355
					ret.push( array[i] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3356
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3357
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3358
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3359
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3360
		return ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3361
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3362
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3363
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3364
var sortOrder;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3365
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3366
if ( document.documentElement.compareDocumentPosition ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3367
	sortOrder = function( a, b ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3368
		if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3369
			if ( a == b ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3370
				hasDuplicate = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3371
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3372
			return a.compareDocumentPosition ? -1 : 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3373
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3374
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3375
		var ret = a.compareDocumentPosition(b) & 4 ? -1 : a === b ? 0 : 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3376
		if ( ret === 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3377
			hasDuplicate = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3378
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3379
		return ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3380
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3381
} else if ( "sourceIndex" in document.documentElement ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3382
	sortOrder = function( a, b ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3383
		if ( !a.sourceIndex || !b.sourceIndex ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3384
			if ( a == b ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3385
				hasDuplicate = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3386
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3387
			return a.sourceIndex ? -1 : 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3388
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3389
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3390
		var ret = a.sourceIndex - b.sourceIndex;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3391
		if ( ret === 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3392
			hasDuplicate = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3393
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3394
		return ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3395
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3396
} else if ( document.createRange ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3397
	sortOrder = function( a, b ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3398
		if ( !a.ownerDocument || !b.ownerDocument ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3399
			if ( a == b ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3400
				hasDuplicate = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3401
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3402
			return a.ownerDocument ? -1 : 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3403
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3404
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3405
		var aRange = a.ownerDocument.createRange(), bRange = b.ownerDocument.createRange();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3406
		aRange.setStart(a, 0);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3407
		aRange.setEnd(a, 0);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3408
		bRange.setStart(b, 0);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3409
		bRange.setEnd(b, 0);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3410
		var ret = aRange.compareBoundaryPoints(Range.START_TO_END, bRange);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3411
		if ( ret === 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3412
			hasDuplicate = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3413
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3414
		return ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3415
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3416
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3417
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3418
// Utility function for retreiving the text value of an array of DOM nodes
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3419
function getText( elems ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3420
	var ret = "", elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3421
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3422
	for ( var i = 0; elems[i]; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3423
		elem = elems[i];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3424
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3425
		// Get the text from text nodes and CDATA nodes
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3426
		if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3427
			ret += elem.nodeValue;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3428
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3429
		// Traverse everything else, except comment nodes
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3430
		} else if ( elem.nodeType !== 8 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3431
			ret += getText( elem.childNodes );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3432
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3433
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3434
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3435
	return ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3436
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3437
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3438
// Check to see if the browser returns elements by name when
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3439
// querying by getElementById (and provide a workaround)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3440
(function(){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3441
	// We're going to inject a fake input element with a specified name
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3442
	var form = document.createElement("div"),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3443
		id = "script" + (new Date).getTime();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3444
	form.innerHTML = "<a name='" + id + "'/>";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3445
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3446
	// Inject it into the root element, check its status, and remove it quickly
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3447
	var root = document.documentElement;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3448
	root.insertBefore( form, root.firstChild );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3449
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3450
	// The workaround has to do additional checks after a getElementById
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3451
	// Which slows things down for other browsers (hence the branching)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3452
	if ( document.getElementById( id ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3453
		Expr.find.ID = function(match, context, isXML){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3454
			if ( typeof context.getElementById !== "undefined" && !isXML ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3455
				var m = context.getElementById(match[1]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3456
				return m ? m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ? [m] : undefined : [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3457
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3458
		};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3459
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3460
		Expr.filter.ID = function(elem, match){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3461
			var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3462
			return elem.nodeType === 1 && node && node.nodeValue === match;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3463
		};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3464
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3465
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3466
	root.removeChild( form );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3467
	root = form = null; // release memory in IE
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3468
})();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3469
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3470
(function(){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3471
	// Check to see if the browser returns only elements
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3472
	// when doing getElementsByTagName("*")
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3473
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3474
	// Create a fake element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3475
	var div = document.createElement("div");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3476
	div.appendChild( document.createComment("") );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3477
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3478
	// Make sure no comments are found
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3479
	if ( div.getElementsByTagName("*").length > 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3480
		Expr.find.TAG = function(match, context){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3481
			var results = context.getElementsByTagName(match[1]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3482
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3483
			// Filter out possible comments
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3484
			if ( match[1] === "*" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3485
				var tmp = [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3486
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3487
				for ( var i = 0; results[i]; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3488
					if ( results[i].nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3489
						tmp.push( results[i] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3490
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3491
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3492
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3493
				results = tmp;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3494
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3495
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3496
			return results;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3497
		};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3498
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3499
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3500
	// Check to see if an attribute returns normalized href attributes
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3501
	div.innerHTML = "<a href='#'></a>";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3502
	if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3503
			div.firstChild.getAttribute("href") !== "#" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3504
		Expr.attrHandle.href = function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3505
			return elem.getAttribute("href", 2);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3506
		};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3507
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3508
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3509
	div = null; // release memory in IE
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3510
})();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3511
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3512
if ( document.querySelectorAll ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3513
	(function(){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3514
		var oldSizzle = Sizzle, div = document.createElement("div");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3515
		div.innerHTML = "<p class='TEST'></p>";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3516
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3517
		// Safari can't handle uppercase or unicode characters when
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3518
		// in quirks mode.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3519
		if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3520
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3521
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3522
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3523
		Sizzle = function(query, context, extra, seed){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3524
			context = context || document;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3525
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3526
			// Only use querySelectorAll on non-XML documents
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3527
			// (ID selectors don't work in non-HTML documents)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3528
			if ( !seed && context.nodeType === 9 && !isXML(context) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3529
				try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3530
					return makeArray( context.querySelectorAll(query), extra );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3531
				} catch(e){}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3532
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3533
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3534
			return oldSizzle(query, context, extra, seed);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3535
		};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3536
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3537
		for ( var prop in oldSizzle ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3538
			Sizzle[ prop ] = oldSizzle[ prop ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3539
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3540
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3541
		div = null; // release memory in IE
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3542
	})();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3543
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3544
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3545
(function(){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3546
	var div = document.createElement("div");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3547
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3548
	div.innerHTML = "<div class='test e'></div><div class='test'></div>";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3549
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3550
	// Opera can't find a second classname (in 9.6)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3551
	// Also, make sure that getElementsByClassName actually exists
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3552
	if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3553
		return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3554
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3555
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3556
	// Safari caches class attributes, doesn't catch changes (in 3.2)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3557
	div.lastChild.className = "e";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3558
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3559
	if ( div.getElementsByClassName("e").length === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3560
		return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3561
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3562
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3563
	Expr.order.splice(1, 0, "CLASS");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3564
	Expr.find.CLASS = function(match, context, isXML) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3565
		if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3566
			return context.getElementsByClassName(match[1]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3567
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3568
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3569
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3570
	div = null; // release memory in IE
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3571
})();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3572
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3573
function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3574
	for ( var i = 0, l = checkSet.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3575
		var elem = checkSet[i];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3576
		if ( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3577
			elem = elem[dir];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3578
			var match = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3579
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3580
			while ( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3581
				if ( elem.sizcache === doneName ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3582
					match = checkSet[elem.sizset];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3583
					break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3584
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3585
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3586
				if ( elem.nodeType === 1 && !isXML ){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3587
					elem.sizcache = doneName;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3588
					elem.sizset = i;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3589
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3590
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3591
				if ( elem.nodeName.toLowerCase() === cur ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3592
					match = elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3593
					break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3594
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3595
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3596
				elem = elem[dir];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3597
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3598
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3599
			checkSet[i] = match;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3600
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3601
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3602
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3603
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3604
function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3605
	for ( var i = 0, l = checkSet.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3606
		var elem = checkSet[i];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3607
		if ( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3608
			elem = elem[dir];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3609
			var match = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3610
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3611
			while ( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3612
				if ( elem.sizcache === doneName ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3613
					match = checkSet[elem.sizset];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3614
					break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3615
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3616
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3617
				if ( elem.nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3618
					if ( !isXML ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3619
						elem.sizcache = doneName;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3620
						elem.sizset = i;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3621
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3622
					if ( typeof cur !== "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3623
						if ( elem === cur ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3624
							match = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3625
							break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3626
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3627
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3628
					} else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3629
						match = elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3630
						break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3631
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3632
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3633
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3634
				elem = elem[dir];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3635
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3636
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3637
			checkSet[i] = match;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3638
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3639
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3640
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3641
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3642
var contains = document.compareDocumentPosition ? function(a, b){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3643
	return !!(a.compareDocumentPosition(b) & 16);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3644
} : function(a, b){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3645
	return a !== b && (a.contains ? a.contains(b) : true);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3646
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3647
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3648
var isXML = function(elem){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3649
	// documentElement is verified for cases where it doesn't yet exist
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3650
	// (such as loading iframes in IE - #4833) 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3651
	var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3652
	return documentElement ? documentElement.nodeName !== "HTML" : false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3653
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3654
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3655
var posProcess = function(selector, context){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3656
	var tmpSet = [], later = "", match,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3657
		root = context.nodeType ? [context] : context;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3658
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3659
	// Position selectors must be done after the filter
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3660
	// And so must :not(positional) so we move all PSEUDOs to the end
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3661
	while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3662
		later += match[0];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3663
		selector = selector.replace( Expr.match.PSEUDO, "" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3664
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3665
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3666
	selector = Expr.relative[selector] ? selector + "*" : selector;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3667
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3668
	for ( var i = 0, l = root.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3669
		Sizzle( selector, root[i], tmpSet );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3670
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3671
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3672
	return Sizzle.filter( later, tmpSet );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3673
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3674
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3675
// EXPOSE
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3676
jQuery.find = Sizzle;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3677
jQuery.expr = Sizzle.selectors;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3678
jQuery.expr[":"] = jQuery.expr.filters;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3679
jQuery.unique = Sizzle.uniqueSort;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3680
jQuery.text = getText;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3681
jQuery.isXMLDoc = isXML;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3682
jQuery.contains = contains;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3683
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3684
return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3685
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3686
window.Sizzle = Sizzle;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3687
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3688
})();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3689
var runtil = /Until$/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3690
	rparentsprev = /^(?:parents|prevUntil|prevAll)/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3691
	// Note: This RegExp should be improved, or likely pulled from Sizzle
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3692
	rmultiselector = /,/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3693
	slice = Array.prototype.slice;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3694
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3695
// Implement the identical functionality for filter and not
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3696
var winnow = function( elements, qualifier, keep ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3697
	if ( jQuery.isFunction( qualifier ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3698
		return jQuery.grep(elements, function( elem, i ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3699
			return !!qualifier.call( elem, i, elem ) === keep;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3700
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3701
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3702
	} else if ( qualifier.nodeType ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3703
		return jQuery.grep(elements, function( elem, i ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3704
			return (elem === qualifier) === keep;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3705
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3706
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3707
	} else if ( typeof qualifier === "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3708
		var filtered = jQuery.grep(elements, function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3709
			return elem.nodeType === 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3710
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3711
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3712
		if ( isSimple.test( qualifier ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3713
			return jQuery.filter(qualifier, filtered, !keep);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3714
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3715
			qualifier = jQuery.filter( qualifier, filtered );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3716
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3717
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3718
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3719
	return jQuery.grep(elements, function( elem, i ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3720
		return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3721
	});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3722
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3723
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3724
jQuery.fn.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3725
	find: function( selector ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3726
		var ret = this.pushStack( "", "find", selector ), length = 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3727
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3728
		for ( var i = 0, l = this.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3729
			length = ret.length;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3730
			jQuery.find( selector, this[i], ret );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3731
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3732
			if ( i > 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3733
				// Make sure that the results are unique
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3734
				for ( var n = length; n < ret.length; n++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3735
					for ( var r = 0; r < length; r++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3736
						if ( ret[r] === ret[n] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3737
							ret.splice(n--, 1);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3738
							break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3739
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3740
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3741
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3742
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3743
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3744
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3745
		return ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3746
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3747
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3748
	has: function( target ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3749
		var targets = jQuery( target );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3750
		return this.filter(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3751
			for ( var i = 0, l = targets.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3752
				if ( jQuery.contains( this, targets[i] ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3753
					return true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3754
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3755
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3756
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3757
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3758
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3759
	not: function( selector ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3760
		return this.pushStack( winnow(this, selector, false), "not", selector);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3761
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3762
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3763
	filter: function( selector ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3764
		return this.pushStack( winnow(this, selector, true), "filter", selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3765
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3766
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3767
	is: function( selector ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3768
		return !!selector && jQuery.filter( selector, this ).length > 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3769
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3770
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3771
	closest: function( selectors, context ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3772
		if ( jQuery.isArray( selectors ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3773
			var ret = [], cur = this[0], match, matches = {}, selector;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3774
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3775
			if ( cur && selectors.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3776
				for ( var i = 0, l = selectors.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3777
					selector = selectors[i];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3778
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3779
					if ( !matches[selector] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3780
						matches[selector] = jQuery.expr.match.POS.test( selector ) ? 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3781
							jQuery( selector, context || this.context ) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3782
							selector;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3783
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3784
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3785
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3786
				while ( cur && cur.ownerDocument && cur !== context ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3787
					for ( selector in matches ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3788
						match = matches[selector];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3789
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3790
						if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3791
							ret.push({ selector: selector, elem: cur });
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3792
							delete matches[selector];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3793
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3794
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3795
					cur = cur.parentNode;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3796
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3797
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3798
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3799
			return ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3800
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3801
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3802
		var pos = jQuery.expr.match.POS.test( selectors ) ? 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3803
			jQuery( selectors, context || this.context ) : null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3804
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3805
		return this.map(function( i, cur ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3806
			while ( cur && cur.ownerDocument && cur !== context ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3807
				if ( pos ? pos.index(cur) > -1 : jQuery(cur).is(selectors) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3808
					return cur;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3809
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3810
				cur = cur.parentNode;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3811
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3812
			return null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3813
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3814
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3815
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3816
	// Determine the position of an element within
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3817
	// the matched set of elements
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3818
	index: function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3819
		if ( !elem || typeof elem === "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3820
			return jQuery.inArray( this[0],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3821
				// If it receives a string, the selector is used
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3822
				// If it receives nothing, the siblings are used
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3823
				elem ? jQuery( elem ) : this.parent().children() );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3824
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3825
		// Locate the position of the desired element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3826
		return jQuery.inArray(
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3827
			// If it receives a jQuery object, the first element is used
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3828
			elem.jquery ? elem[0] : elem, this );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3829
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3830
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3831
	add: function( selector, context ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3832
		var set = typeof selector === "string" ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3833
				jQuery( selector, context || this.context ) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3834
				jQuery.makeArray( selector ),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3835
			all = jQuery.merge( this.get(), set );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3836
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3837
		return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3838
			all :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3839
			jQuery.unique( all ) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3840
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3841
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3842
	andSelf: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3843
		return this.add( this.prevObject );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3844
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3845
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3846
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3847
// A painfully simple check to see if an element is disconnected
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3848
// from a document (should be improved, where feasible).
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3849
function isDisconnected( node ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3850
	return !node || !node.parentNode || node.parentNode.nodeType === 11;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3851
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3852
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3853
jQuery.each({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3854
	parent: function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3855
		var parent = elem.parentNode;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3856
		return parent && parent.nodeType !== 11 ? parent : null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3857
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3858
	parents: function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3859
		return jQuery.dir( elem, "parentNode" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3860
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3861
	parentsUntil: function( elem, i, until ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3862
		return jQuery.dir( elem, "parentNode", until );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3863
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3864
	next: function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3865
		return jQuery.nth( elem, 2, "nextSibling" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3866
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3867
	prev: function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3868
		return jQuery.nth( elem, 2, "previousSibling" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3869
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3870
	nextAll: function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3871
		return jQuery.dir( elem, "nextSibling" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3872
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3873
	prevAll: function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3874
		return jQuery.dir( elem, "previousSibling" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3875
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3876
	nextUntil: function( elem, i, until ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3877
		return jQuery.dir( elem, "nextSibling", until );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3878
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3879
	prevUntil: function( elem, i, until ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3880
		return jQuery.dir( elem, "previousSibling", until );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3881
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3882
	siblings: function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3883
		return jQuery.sibling( elem.parentNode.firstChild, elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3884
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3885
	children: function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3886
		return jQuery.sibling( elem.firstChild );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3887
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3888
	contents: function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3889
		return jQuery.nodeName( elem, "iframe" ) ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3890
			elem.contentDocument || elem.contentWindow.document :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3891
			jQuery.makeArray( elem.childNodes );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3892
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3893
}, function( name, fn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3894
	jQuery.fn[ name ] = function( until, selector ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3895
		var ret = jQuery.map( this, fn, until );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3896
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3897
		if ( !runtil.test( name ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3898
			selector = until;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3899
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3900
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3901
		if ( selector && typeof selector === "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3902
			ret = jQuery.filter( selector, ret );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3903
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3904
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3905
		ret = this.length > 1 ? jQuery.unique( ret ) : ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3906
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3907
		if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3908
			ret = ret.reverse();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3909
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3910
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3911
		return this.pushStack( ret, name, slice.call(arguments).join(",") );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3912
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3913
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3914
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3915
jQuery.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3916
	filter: function( expr, elems, not ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3917
		if ( not ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3918
			expr = ":not(" + expr + ")";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3919
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3920
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3921
		return jQuery.find.matches(expr, elems);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3922
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3923
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3924
	dir: function( elem, dir, until ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3925
		var matched = [], cur = elem[dir];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3926
		while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3927
			if ( cur.nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3928
				matched.push( cur );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3929
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3930
			cur = cur[dir];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3931
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3932
		return matched;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3933
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3934
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3935
	nth: function( cur, result, dir, elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3936
		result = result || 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3937
		var num = 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3938
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3939
		for ( ; cur; cur = cur[dir] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3940
			if ( cur.nodeType === 1 && ++num === result ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3941
				break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3942
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3943
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3944
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3945
		return cur;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3946
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3947
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3948
	sibling: function( n, elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3949
		var r = [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3950
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3951
		for ( ; n; n = n.nextSibling ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3952
			if ( n.nodeType === 1 && n !== elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3953
				r.push( n );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3954
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3955
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3956
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3957
		return r;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3958
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3959
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3960
var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3961
	rleadingWhitespace = /^\s+/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3962
	rxhtmlTag = /(<([\w:]+)[^>]*?)\/>/g,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3963
	rselfClosing = /^(?:area|br|col|embed|hr|img|input|link|meta|param)$/i,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3964
	rtagName = /<([\w:]+)/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3965
	rtbody = /<tbody/i,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3966
	rhtml = /<|&#?\w+;/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3967
	rnocache = /<script|<object|<embed|<option|<style/i,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3968
	rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,  // checked="checked" or checked (html5)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3969
	fcloseTag = function( all, front, tag ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3970
		return rselfClosing.test( tag ) ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3971
			all :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3972
			front + "></" + tag + ">";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3973
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3974
	wrapMap = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3975
		option: [ 1, "<select multiple='multiple'>", "</select>" ],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3976
		legend: [ 1, "<fieldset>", "</fieldset>" ],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3977
		thead: [ 1, "<table>", "</table>" ],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3978
		tr: [ 2, "<table><tbody>", "</tbody></table>" ],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3979
		td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3980
		col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3981
		area: [ 1, "<map>", "</map>" ],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3982
		_default: [ 0, "", "" ]
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3983
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3984
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3985
wrapMap.optgroup = wrapMap.option;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3986
wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3987
wrapMap.th = wrapMap.td;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3988
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3989
// IE can't serialize <link> and <script> tags normally
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3990
if ( !jQuery.support.htmlSerialize ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3991
	wrapMap._default = [ 1, "div<div>", "</div>" ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3992
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3993
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3994
jQuery.fn.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3995
	text: function( text ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3996
		if ( jQuery.isFunction(text) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3997
			return this.each(function(i) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3998
				var self = jQuery(this);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  3999
				self.text( text.call(this, i, self.text()) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4000
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4001
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4002
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4003
		if ( typeof text !== "object" && text !== undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4004
			return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4005
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4006
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4007
		return jQuery.text( this );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4008
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4009
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4010
	wrapAll: function( html ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4011
		if ( jQuery.isFunction( html ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4012
			return this.each(function(i) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4013
				jQuery(this).wrapAll( html.call(this, i) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4014
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4015
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4016
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4017
		if ( this[0] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4018
			// The elements to wrap the target around
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4019
			var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4020
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4021
			if ( this[0].parentNode ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4022
				wrap.insertBefore( this[0] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4023
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4024
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4025
			wrap.map(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4026
				var elem = this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4027
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4028
				while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4029
					elem = elem.firstChild;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4030
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4031
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4032
				return elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4033
			}).append(this);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4034
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4035
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4036
		return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4037
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4038
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4039
	wrapInner: function( html ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4040
		if ( jQuery.isFunction( html ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4041
			return this.each(function(i) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4042
				jQuery(this).wrapInner( html.call(this, i) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4043
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4044
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4045
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4046
		return this.each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4047
			var self = jQuery( this ), contents = self.contents();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4048
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4049
			if ( contents.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4050
				contents.wrapAll( html );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4051
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4052
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4053
				self.append( html );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4054
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4055
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4056
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4057
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4058
	wrap: function( html ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4059
		return this.each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4060
			jQuery( this ).wrapAll( html );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4061
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4062
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4063
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4064
	unwrap: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4065
		return this.parent().each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4066
			if ( !jQuery.nodeName( this, "body" ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4067
				jQuery( this ).replaceWith( this.childNodes );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4068
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4069
		}).end();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4070
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4071
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4072
	append: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4073
		return this.domManip(arguments, true, function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4074
			if ( this.nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4075
				this.appendChild( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4076
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4077
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4078
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4079
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4080
	prepend: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4081
		return this.domManip(arguments, true, function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4082
			if ( this.nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4083
				this.insertBefore( elem, this.firstChild );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4084
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4085
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4086
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4087
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4088
	before: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4089
		if ( this[0] && this[0].parentNode ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4090
			return this.domManip(arguments, false, function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4091
				this.parentNode.insertBefore( elem, this );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4092
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4093
		} else if ( arguments.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4094
			var set = jQuery(arguments[0]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4095
			set.push.apply( set, this.toArray() );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4096
			return this.pushStack( set, "before", arguments );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4097
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4098
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4099
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4100
	after: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4101
		if ( this[0] && this[0].parentNode ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4102
			return this.domManip(arguments, false, function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4103
				this.parentNode.insertBefore( elem, this.nextSibling );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4104
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4105
		} else if ( arguments.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4106
			var set = this.pushStack( this, "after", arguments );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4107
			set.push.apply( set, jQuery(arguments[0]).toArray() );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4108
			return set;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4109
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4110
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4111
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4112
	// keepData is for internal use only--do not document
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4113
	remove: function( selector, keepData ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4114
		for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4115
			if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4116
				if ( !keepData && elem.nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4117
					jQuery.cleanData( elem.getElementsByTagName("*") );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4118
					jQuery.cleanData( [ elem ] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4119
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4120
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4121
				if ( elem.parentNode ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4122
					 elem.parentNode.removeChild( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4123
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4124
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4125
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4126
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4127
		return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4128
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4129
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4130
	empty: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4131
		for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4132
			// Remove element nodes and prevent memory leaks
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4133
			if ( elem.nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4134
				jQuery.cleanData( elem.getElementsByTagName("*") );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4135
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4136
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4137
			// Remove any remaining nodes
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4138
			while ( elem.firstChild ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4139
				elem.removeChild( elem.firstChild );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4140
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4141
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4142
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4143
		return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4144
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4145
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4146
	clone: function( events ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4147
		// Do the clone
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4148
		var ret = this.map(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4149
			if ( !jQuery.support.noCloneEvent && !jQuery.isXMLDoc(this) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4150
				// IE copies events bound via attachEvent when
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4151
				// using cloneNode. Calling detachEvent on the
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4152
				// clone will also remove the events from the orignal
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4153
				// In order to get around this, we use innerHTML.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4154
				// Unfortunately, this means some modifications to
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4155
				// attributes in IE that are actually only stored
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4156
				// as properties will not be copied (such as the
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4157
				// the name attribute on an input).
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4158
				var html = this.outerHTML, ownerDocument = this.ownerDocument;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4159
				if ( !html ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4160
					var div = ownerDocument.createElement("div");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4161
					div.appendChild( this.cloneNode(true) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4162
					html = div.innerHTML;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4163
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4164
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4165
				return jQuery.clean([html.replace(rinlinejQuery, "")
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4166
					// Handle the case in IE 8 where action=/test/> self-closes a tag
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4167
					.replace(/=([^="'>\s]+\/)>/g, '="$1">')
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4168
					.replace(rleadingWhitespace, "")], ownerDocument)[0];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4169
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4170
				return this.cloneNode(true);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4171
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4172
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4173
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4174
		// Copy the events from the original to the clone
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4175
		if ( events === true ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4176
			cloneCopyEvent( this, ret );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4177
			cloneCopyEvent( this.find("*"), ret.find("*") );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4178
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4179
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4180
		// Return the cloned set
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4181
		return ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4182
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4183
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4184
	html: function( value ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4185
		if ( value === undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4186
			return this[0] && this[0].nodeType === 1 ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4187
				this[0].innerHTML.replace(rinlinejQuery, "") :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4188
				null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4189
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4190
		// See if we can take a shortcut and just use innerHTML
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4191
		} else if ( typeof value === "string" && !rnocache.test( value ) &&
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4192
			(jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4193
			!wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4194
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4195
			value = value.replace(rxhtmlTag, fcloseTag);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4196
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4197
			try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4198
				for ( var i = 0, l = this.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4199
					// Remove element nodes and prevent memory leaks
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4200
					if ( this[i].nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4201
						jQuery.cleanData( this[i].getElementsByTagName("*") );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4202
						this[i].innerHTML = value;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4203
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4204
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4205
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4206
			// If using innerHTML throws an exception, use the fallback method
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4207
			} catch(e) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4208
				this.empty().append( value );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4209
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4210
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4211
		} else if ( jQuery.isFunction( value ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4212
			this.each(function(i){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4213
				var self = jQuery(this), old = self.html();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4214
				self.empty().append(function(){
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4215
					return value.call( this, i, old );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4216
				});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4217
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4218
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4219
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4220
			this.empty().append( value );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4221
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4222
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4223
		return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4224
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4225
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4226
	replaceWith: function( value ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4227
		if ( this[0] && this[0].parentNode ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4228
			// Make sure that the elements are removed from the DOM before they are inserted
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4229
			// this can help fix replacing a parent with child elements
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4230
			if ( jQuery.isFunction( value ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4231
				return this.each(function(i) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4232
					var self = jQuery(this), old = self.html();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4233
					self.replaceWith( value.call( this, i, old ) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4234
				});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4235
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4236
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4237
			if ( typeof value !== "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4238
				value = jQuery(value).detach();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4239
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4240
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4241
			return this.each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4242
				var next = this.nextSibling, parent = this.parentNode;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4243
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4244
				jQuery(this).remove();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4245
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4246
				if ( next ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4247
					jQuery(next).before( value );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4248
				} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4249
					jQuery(parent).append( value );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4250
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4251
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4252
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4253
			return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4254
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4255
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4256
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4257
	detach: function( selector ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4258
		return this.remove( selector, true );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4259
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4260
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4261
	domManip: function( args, table, callback ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4262
		var results, first, value = args[0], scripts = [], fragment, parent;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4263
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4264
		// We can't cloneNode fragments that contain checked, in WebKit
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4265
		if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4266
			return this.each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4267
				jQuery(this).domManip( args, table, callback, true );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4268
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4269
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4270
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4271
		if ( jQuery.isFunction(value) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4272
			return this.each(function(i) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4273
				var self = jQuery(this);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4274
				args[0] = value.call(this, i, table ? self.html() : undefined);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4275
				self.domManip( args, table, callback );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4276
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4277
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4278
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4279
		if ( this[0] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4280
			parent = value && value.parentNode;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4281
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4282
			// If we're in a fragment, just use that instead of building a new one
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4283
			if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4284
				results = { fragment: parent };
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4285
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4286
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4287
				results = buildFragment( args, this, scripts );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4288
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4289
			
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4290
			fragment = results.fragment;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4291
			
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4292
			if ( fragment.childNodes.length === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4293
				first = fragment = fragment.firstChild;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4294
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4295
				first = fragment.firstChild;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4296
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4297
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4298
			if ( first ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4299
				table = table && jQuery.nodeName( first, "tr" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4300
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4301
				for ( var i = 0, l = this.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4302
					callback.call(
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4303
						table ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4304
							root(this[i], first) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4305
							this[i],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4306
						i > 0 || results.cacheable || this.length > 1  ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4307
							fragment.cloneNode(true) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4308
							fragment
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4309
					);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4310
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4311
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4312
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4313
			if ( scripts.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4314
				jQuery.each( scripts, evalScript );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4315
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4316
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4317
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4318
		return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4319
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4320
		function root( elem, cur ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4321
			return jQuery.nodeName(elem, "table") ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4322
				(elem.getElementsByTagName("tbody")[0] ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4323
				elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4324
				elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4325
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4326
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4327
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4328
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4329
function cloneCopyEvent(orig, ret) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4330
	var i = 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4331
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4332
	ret.each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4333
		if ( this.nodeName !== (orig[i] && orig[i].nodeName) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4334
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4335
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4336
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4337
		var oldData = jQuery.data( orig[i++] ), curData = jQuery.data( this, oldData ), events = oldData && oldData.events;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4338
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4339
		if ( events ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4340
			delete curData.handle;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4341
			curData.events = {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4342
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4343
			for ( var type in events ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4344
				for ( var handler in events[ type ] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4345
					jQuery.event.add( this, type, events[ type ][ handler ], events[ type ][ handler ].data );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4346
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4347
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4348
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4349
	});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4350
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4351
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4352
function buildFragment( args, nodes, scripts ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4353
	var fragment, cacheable, cacheresults,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4354
		doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4355
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4356
	// Only cache "small" (1/2 KB) strings that are associated with the main document
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4357
	// Cloning options loses the selected state, so don't cache them
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4358
	// IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4359
	// Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4360
	if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4361
		!rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4362
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4363
		cacheable = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4364
		cacheresults = jQuery.fragments[ args[0] ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4365
		if ( cacheresults ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4366
			if ( cacheresults !== 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4367
				fragment = cacheresults;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4368
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4369
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4370
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4371
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4372
	if ( !fragment ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4373
		fragment = doc.createDocumentFragment();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4374
		jQuery.clean( args, doc, fragment, scripts );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4375
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4376
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4377
	if ( cacheable ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4378
		jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4379
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4380
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4381
	return { fragment: fragment, cacheable: cacheable };
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4382
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4383
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4384
jQuery.fragments = {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4385
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4386
jQuery.each({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4387
	appendTo: "append",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4388
	prependTo: "prepend",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4389
	insertBefore: "before",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4390
	insertAfter: "after",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4391
	replaceAll: "replaceWith"
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4392
}, function( name, original ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4393
	jQuery.fn[ name ] = function( selector ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4394
		var ret = [], insert = jQuery( selector ),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4395
			parent = this.length === 1 && this[0].parentNode;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4396
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4397
		if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4398
			insert[ original ]( this[0] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4399
			return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4400
			
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4401
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4402
			for ( var i = 0, l = insert.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4403
				var elems = (i > 0 ? this.clone(true) : this).get();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4404
				jQuery.fn[ original ].apply( jQuery(insert[i]), elems );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4405
				ret = ret.concat( elems );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4406
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4407
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4408
			return this.pushStack( ret, name, insert.selector );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4409
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4410
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4411
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4412
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4413
jQuery.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4414
	clean: function( elems, context, fragment, scripts ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4415
		context = context || document;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4416
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4417
		// !context.createElement fails in IE with an error but returns typeof 'object'
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4418
		if ( typeof context.createElement === "undefined" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4419
			context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4420
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4421
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4422
		var ret = [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4423
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4424
		for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4425
			if ( typeof elem === "number" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4426
				elem += "";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4427
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4428
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4429
			if ( !elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4430
				continue;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4431
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4432
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4433
			// Convert html string into DOM nodes
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4434
			if ( typeof elem === "string" && !rhtml.test( elem ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4435
				elem = context.createTextNode( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4436
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4437
			} else if ( typeof elem === "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4438
				// Fix "XHTML"-style tags in all browsers
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4439
				elem = elem.replace(rxhtmlTag, fcloseTag);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4440
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4441
				// Trim whitespace, otherwise indexOf won't work as expected
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4442
				var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4443
					wrap = wrapMap[ tag ] || wrapMap._default,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4444
					depth = wrap[0],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4445
					div = context.createElement("div");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4446
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4447
				// Go to html and back, then peel off extra wrappers
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4448
				div.innerHTML = wrap[1] + elem + wrap[2];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4449
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4450
				// Move to the right depth
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4451
				while ( depth-- ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4452
					div = div.lastChild;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4453
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4454
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4455
				// Remove IE's autoinserted <tbody> from table fragments
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4456
				if ( !jQuery.support.tbody ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4457
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4458
					// String was a <table>, *may* have spurious <tbody>
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4459
					var hasBody = rtbody.test(elem),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4460
						tbody = tag === "table" && !hasBody ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4461
							div.firstChild && div.firstChild.childNodes :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4462
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4463
							// String was a bare <thead> or <tfoot>
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4464
							wrap[1] === "<table>" && !hasBody ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4465
								div.childNodes :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4466
								[];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4467
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4468
					for ( var j = tbody.length - 1; j >= 0 ; --j ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4469
						if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4470
							tbody[ j ].parentNode.removeChild( tbody[ j ] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4471
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4472
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4473
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4474
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4475
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4476
				// IE completely kills leading whitespace when innerHTML is used
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4477
				if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4478
					div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4479
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4480
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4481
				elem = div.childNodes;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4482
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4483
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4484
			if ( elem.nodeType ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4485
				ret.push( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4486
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4487
				ret = jQuery.merge( ret, elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4488
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4489
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4490
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4491
		if ( fragment ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4492
			for ( var i = 0; ret[i]; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4493
				if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4494
					scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4495
				
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4496
				} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4497
					if ( ret[i].nodeType === 1 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4498
						ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4499
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4500
					fragment.appendChild( ret[i] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4501
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4502
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4503
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4504
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4505
		return ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4506
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4507
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4508
	cleanData: function( elems ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4509
		var data, id, cache = jQuery.cache,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4510
			special = jQuery.event.special,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4511
			deleteExpando = jQuery.support.deleteExpando;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4512
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4513
		for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4514
			id = elem[ jQuery.expando ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4515
			
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4516
			if ( id ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4517
				data = cache[ id ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4518
				
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4519
				if ( data.events ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4520
					for ( var type in data.events ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4521
						if ( special[ type ] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4522
							jQuery.event.remove( elem, type );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4523
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4524
						} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4525
							removeEvent( elem, type, data.handle );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4526
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4527
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4528
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4529
				
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4530
				if ( deleteExpando ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4531
					delete elem[ jQuery.expando ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4532
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4533
				} else if ( elem.removeAttribute ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4534
					elem.removeAttribute( jQuery.expando );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4535
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4536
				
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4537
				delete cache[ id ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4538
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4539
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4540
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4541
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4542
// exclude the following css properties to add px
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4543
var rexclude = /z-?index|font-?weight|opacity|zoom|line-?height/i,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4544
	ralpha = /alpha\([^)]*\)/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4545
	ropacity = /opacity=([^)]*)/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4546
	rfloat = /float/i,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4547
	rdashAlpha = /-([a-z])/ig,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4548
	rupper = /([A-Z])/g,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4549
	rnumpx = /^-?\d+(?:px)?$/i,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4550
	rnum = /^-?\d/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4551
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4552
	cssShow = { position: "absolute", visibility: "hidden", display:"block" },
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4553
	cssWidth = [ "Left", "Right" ],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4554
	cssHeight = [ "Top", "Bottom" ],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4555
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4556
	// cache check for defaultView.getComputedStyle
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4557
	getComputedStyle = document.defaultView && document.defaultView.getComputedStyle,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4558
	// normalize float css property
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4559
	styleFloat = jQuery.support.cssFloat ? "cssFloat" : "styleFloat",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4560
	fcamelCase = function( all, letter ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4561
		return letter.toUpperCase();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4562
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4563
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4564
jQuery.fn.css = function( name, value ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4565
	return access( this, name, value, true, function( elem, name, value ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4566
		if ( value === undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4567
			return jQuery.curCSS( elem, name );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4568
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4569
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4570
		if ( typeof value === "number" && !rexclude.test(name) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4571
			value += "px";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4572
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4573
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4574
		jQuery.style( elem, name, value );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4575
	});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4576
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4577
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4578
jQuery.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4579
	style: function( elem, name, value ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4580
		// don't set styles on text and comment nodes
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4581
		if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4582
			return undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4583
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4584
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4585
		// ignore negative width and height values #1599
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4586
		if ( (name === "width" || name === "height") && parseFloat(value) < 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4587
			value = undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4588
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4589
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4590
		var style = elem.style || elem, set = value !== undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4591
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4592
		// IE uses filters for opacity
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4593
		if ( !jQuery.support.opacity && name === "opacity" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4594
			if ( set ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4595
				// IE has trouble with opacity if it does not have layout
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4596
				// Force it by setting the zoom level
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4597
				style.zoom = 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4598
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4599
				// Set the alpha filter to set the opacity
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4600
				var opacity = parseInt( value, 10 ) + "" === "NaN" ? "" : "alpha(opacity=" + value * 100 + ")";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4601
				var filter = style.filter || jQuery.curCSS( elem, "filter" ) || "";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4602
				style.filter = ralpha.test(filter) ? filter.replace(ralpha, opacity) : opacity;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4603
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4604
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4605
			return style.filter && style.filter.indexOf("opacity=") >= 0 ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4606
				(parseFloat( ropacity.exec(style.filter)[1] ) / 100) + "":
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4607
				"";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4608
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4609
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4610
		// Make sure we're using the right name for getting the float value
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4611
		if ( rfloat.test( name ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4612
			name = styleFloat;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4613
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4614
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4615
		name = name.replace(rdashAlpha, fcamelCase);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4616
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4617
		if ( set ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4618
			style[ name ] = value;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4619
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4620
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4621
		return style[ name ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4622
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4623
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4624
	css: function( elem, name, force, extra ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4625
		if ( name === "width" || name === "height" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4626
			var val, props = cssShow, which = name === "width" ? cssWidth : cssHeight;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4627
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4628
			function getWH() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4629
				val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4630
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4631
				if ( extra === "border" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4632
					return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4633
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4634
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4635
				jQuery.each( which, function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4636
					if ( !extra ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4637
						val -= parseFloat(jQuery.curCSS( elem, "padding" + this, true)) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4638
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4639
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4640
					if ( extra === "margin" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4641
						val += parseFloat(jQuery.curCSS( elem, "margin" + this, true)) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4642
					} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4643
						val -= parseFloat(jQuery.curCSS( elem, "border" + this + "Width", true)) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4644
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4645
				});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4646
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4647
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4648
			if ( elem.offsetWidth !== 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4649
				getWH();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4650
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4651
				jQuery.swap( elem, props, getWH );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4652
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4653
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4654
			return Math.max(0, Math.round(val));
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4655
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4656
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4657
		return jQuery.curCSS( elem, name, force );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4658
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4659
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4660
	curCSS: function( elem, name, force ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4661
		var ret, style = elem.style, filter;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4662
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4663
		// IE uses filters for opacity
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4664
		if ( !jQuery.support.opacity && name === "opacity" && elem.currentStyle ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4665
			ret = ropacity.test(elem.currentStyle.filter || "") ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4666
				(parseFloat(RegExp.$1) / 100) + "" :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4667
				"";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4668
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4669
			return ret === "" ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4670
				"1" :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4671
				ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4672
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4673
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4674
		// Make sure we're using the right name for getting the float value
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4675
		if ( rfloat.test( name ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4676
			name = styleFloat;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4677
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4678
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4679
		if ( !force && style && style[ name ] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4680
			ret = style[ name ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4681
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4682
		} else if ( getComputedStyle ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4683
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4684
			// Only "float" is needed here
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4685
			if ( rfloat.test( name ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4686
				name = "float";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4687
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4688
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4689
			name = name.replace( rupper, "-$1" ).toLowerCase();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4690
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4691
			var defaultView = elem.ownerDocument.defaultView;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4692
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4693
			if ( !defaultView ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4694
				return null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4695
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4696
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4697
			var computedStyle = defaultView.getComputedStyle( elem, null );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4698
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4699
			if ( computedStyle ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4700
				ret = computedStyle.getPropertyValue( name );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4701
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4702
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4703
			// We should always get a number back from opacity
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4704
			if ( name === "opacity" && ret === "" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4705
				ret = "1";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4706
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4707
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4708
		} else if ( elem.currentStyle ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4709
			var camelCase = name.replace(rdashAlpha, fcamelCase);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4710
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4711
			ret = elem.currentStyle[ name ] || elem.currentStyle[ camelCase ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4712
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4713
			// From the awesome hack by Dean Edwards
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4714
			// http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4715
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4716
			// If we're not dealing with a regular pixel number
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4717
			// but a number that has a weird ending, we need to convert it to pixels
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4718
			if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4719
				// Remember the original values
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4720
				var left = style.left, rsLeft = elem.runtimeStyle.left;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4721
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4722
				// Put in the new values to get a computed value out
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4723
				elem.runtimeStyle.left = elem.currentStyle.left;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4724
				style.left = camelCase === "fontSize" ? "1em" : (ret || 0);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4725
				ret = style.pixelLeft + "px";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4726
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4727
				// Revert the changed values
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4728
				style.left = left;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4729
				elem.runtimeStyle.left = rsLeft;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4730
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4731
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4732
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4733
		return ret;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4734
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4735
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4736
	// A method for quickly swapping in/out CSS properties to get correct calculations
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4737
	swap: function( elem, options, callback ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4738
		var old = {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4739
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4740
		// Remember the old values, and insert the new ones
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4741
		for ( var name in options ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4742
			old[ name ] = elem.style[ name ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4743
			elem.style[ name ] = options[ name ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4744
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4745
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4746
		callback.call( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4747
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4748
		// Revert the old values
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4749
		for ( var name in options ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4750
			elem.style[ name ] = old[ name ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4751
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4752
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4753
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4754
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4755
if ( jQuery.expr && jQuery.expr.filters ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4756
	jQuery.expr.filters.hidden = function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4757
		var width = elem.offsetWidth, height = elem.offsetHeight,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4758
			skip = elem.nodeName.toLowerCase() === "tr";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4759
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4760
		return width === 0 && height === 0 && !skip ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4761
			true :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4762
			width > 0 && height > 0 && !skip ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4763
				false :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4764
				jQuery.curCSS(elem, "display") === "none";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4765
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4766
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4767
	jQuery.expr.filters.visible = function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4768
		return !jQuery.expr.filters.hidden( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4769
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4770
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4771
var jsc = now(),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4772
	rscript = /<script(.|\s)*?\/script>/gi,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4773
	rselectTextarea = /select|textarea/i,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4774
	rinput = /color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week/i,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4775
	jsre = /=\?(&|$)/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4776
	rquery = /\?/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4777
	rts = /(\?|&)_=.*?(&|$)/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4778
	rurl = /^(\w+:)?\/\/([^\/?#]+)/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4779
	r20 = /%20/g,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4780
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4781
	// Keep a copy of the old load method
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4782
	_load = jQuery.fn.load;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4783
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4784
jQuery.fn.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4785
	load: function( url, params, callback ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4786
		if ( typeof url !== "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4787
			return _load.call( this, url );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4788
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4789
		// Don't do a request if no elements are being requested
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4790
		} else if ( !this.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4791
			return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4792
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4793
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4794
		var off = url.indexOf(" ");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4795
		if ( off >= 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4796
			var selector = url.slice(off, url.length);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4797
			url = url.slice(0, off);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4798
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4799
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4800
		// Default to a GET request
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4801
		var type = "GET";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4802
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4803
		// If the second parameter was provided
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4804
		if ( params ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4805
			// If it's a function
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4806
			if ( jQuery.isFunction( params ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4807
				// We assume that it's the callback
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4808
				callback = params;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4809
				params = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4810
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4811
			// Otherwise, build a param string
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4812
			} else if ( typeof params === "object" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4813
				params = jQuery.param( params, jQuery.ajaxSettings.traditional );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4814
				type = "POST";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4815
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4816
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4817
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4818
		var self = this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4819
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4820
		// Request the remote document
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4821
		jQuery.ajax({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4822
			url: url,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4823
			type: type,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4824
			dataType: "html",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4825
			data: params,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4826
			complete: function( res, status ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4827
				// If successful, inject the HTML into all the matched elements
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4828
				if ( status === "success" || status === "notmodified" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4829
					// See if a selector was specified
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4830
					self.html( selector ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4831
						// Create a dummy div to hold the results
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4832
						jQuery("<div />")
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4833
							// inject the contents of the document in, removing the scripts
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4834
							// to avoid any 'Permission Denied' errors in IE
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4835
							.append(res.responseText.replace(rscript, ""))
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4836
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4837
							// Locate the specified elements
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4838
							.find(selector) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4839
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4840
						// If not, just inject the full result
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4841
						res.responseText );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4842
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4843
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4844
				if ( callback ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4845
					self.each( callback, [res.responseText, status, res] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4846
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4847
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4848
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4849
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4850
		return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4851
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4852
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4853
	serialize: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4854
		return jQuery.param(this.serializeArray());
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4855
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4856
	serializeArray: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4857
		return this.map(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4858
			return this.elements ? jQuery.makeArray(this.elements) : this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4859
		})
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4860
		.filter(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4861
			return this.name && !this.disabled &&
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4862
				(this.checked || rselectTextarea.test(this.nodeName) ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4863
					rinput.test(this.type));
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4864
		})
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4865
		.map(function( i, elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4866
			var val = jQuery(this).val();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4867
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4868
			return val == null ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4869
				null :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4870
				jQuery.isArray(val) ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4871
					jQuery.map( val, function( val, i ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4872
						return { name: elem.name, value: val };
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4873
					}) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4874
					{ name: elem.name, value: val };
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4875
		}).get();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4876
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4877
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4878
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4879
// Attach a bunch of functions for handling common AJAX events
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4880
jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "), function( i, o ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4881
	jQuery.fn[o] = function( f ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4882
		return this.bind(o, f);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4883
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4884
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4885
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4886
jQuery.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4887
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4888
	get: function( url, data, callback, type ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4889
		// shift arguments if data argument was omited
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4890
		if ( jQuery.isFunction( data ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4891
			type = type || callback;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4892
			callback = data;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4893
			data = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4894
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4895
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4896
		return jQuery.ajax({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4897
			type: "GET",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4898
			url: url,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4899
			data: data,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4900
			success: callback,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4901
			dataType: type
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4902
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4903
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4904
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4905
	getScript: function( url, callback ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4906
		return jQuery.get(url, null, callback, "script");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4907
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4908
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4909
	getJSON: function( url, data, callback ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4910
		return jQuery.get(url, data, callback, "json");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4911
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4912
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4913
	post: function( url, data, callback, type ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4914
		// shift arguments if data argument was omited
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4915
		if ( jQuery.isFunction( data ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4916
			type = type || callback;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4917
			callback = data;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4918
			data = {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4919
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4920
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4921
		return jQuery.ajax({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4922
			type: "POST",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4923
			url: url,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4924
			data: data,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4925
			success: callback,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4926
			dataType: type
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4927
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4928
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4929
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4930
	ajaxSetup: function( settings ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4931
		jQuery.extend( jQuery.ajaxSettings, settings );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4932
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4933
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4934
	ajaxSettings: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4935
		url: location.href,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4936
		global: true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4937
		type: "GET",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4938
		contentType: "application/x-www-form-urlencoded",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4939
		processData: true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4940
		async: true,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4941
		/*
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4942
		timeout: 0,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4943
		data: null,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4944
		username: null,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4945
		password: null,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4946
		traditional: false,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4947
		*/
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4948
		// Create the request object; Microsoft failed to properly
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4949
		// implement the XMLHttpRequest in IE7 (can't request local files),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4950
		// so we use the ActiveXObject when it is available
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4951
		// This function can be overriden by calling jQuery.ajaxSetup
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4952
		xhr: window.XMLHttpRequest && (window.location.protocol !== "file:" || !window.ActiveXObject) ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4953
			function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4954
				return new window.XMLHttpRequest();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4955
			} :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4956
			function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4957
				try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4958
					return new window.ActiveXObject("Microsoft.XMLHTTP");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4959
				} catch(e) {}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4960
			},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4961
		accepts: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4962
			xml: "application/xml, text/xml",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4963
			html: "text/html",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4964
			script: "text/javascript, application/javascript",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4965
			json: "application/json, text/javascript",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4966
			text: "text/plain",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4967
			_default: "*/*"
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4968
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4969
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4970
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4971
	// Last-Modified header cache for next request
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4972
	lastModified: {},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4973
	etag: {},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4974
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4975
	ajax: function( origSettings ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4976
		var s = jQuery.extend(true, {}, jQuery.ajaxSettings, origSettings);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4977
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4978
		var jsonp, status, data,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4979
			callbackContext = origSettings && origSettings.context || s,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4980
			type = s.type.toUpperCase();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4981
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4982
		// convert data if not already a string
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4983
		if ( s.data && s.processData && typeof s.data !== "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4984
			s.data = jQuery.param( s.data, s.traditional );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4985
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4986
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4987
		// Handle JSONP Parameter Callbacks
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4988
		if ( s.dataType === "jsonp" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4989
			if ( type === "GET" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4990
				if ( !jsre.test( s.url ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4991
					s.url += (rquery.test( s.url ) ? "&" : "?") + (s.jsonp || "callback") + "=?";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4992
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4993
			} else if ( !s.data || !jsre.test(s.data) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4994
				s.data = (s.data ? s.data + "&" : "") + (s.jsonp || "callback") + "=?";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4995
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4996
			s.dataType = "json";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4997
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4998
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  4999
		// Build temporary JSONP function
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5000
		if ( s.dataType === "json" && (s.data && jsre.test(s.data) || jsre.test(s.url)) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5001
			jsonp = s.jsonpCallback || ("jsonp" + jsc++);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5002
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5003
			// Replace the =? sequence both in the query string and the data
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5004
			if ( s.data ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5005
				s.data = (s.data + "").replace(jsre, "=" + jsonp + "$1");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5006
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5007
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5008
			s.url = s.url.replace(jsre, "=" + jsonp + "$1");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5009
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5010
			// We need to make sure
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5011
			// that a JSONP style response is executed properly
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5012
			s.dataType = "script";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5013
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5014
			// Handle JSONP-style loading
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5015
			window[ jsonp ] = window[ jsonp ] || function( tmp ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5016
				data = tmp;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5017
				success();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5018
				complete();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5019
				// Garbage collect
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5020
				window[ jsonp ] = undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5021
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5022
				try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5023
					delete window[ jsonp ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5024
				} catch(e) {}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5025
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5026
				if ( head ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5027
					head.removeChild( script );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5028
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5029
			};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5030
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5031
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5032
		if ( s.dataType === "script" && s.cache === null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5033
			s.cache = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5034
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5035
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5036
		if ( s.cache === false && type === "GET" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5037
			var ts = now();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5038
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5039
			// try replacing _= if it is there
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5040
			var ret = s.url.replace(rts, "$1_=" + ts + "$2");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5041
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5042
			// if nothing was replaced, add timestamp to the end
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5043
			s.url = ret + ((ret === s.url) ? (rquery.test(s.url) ? "&" : "?") + "_=" + ts : "");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5044
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5045
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5046
		// If data is available, append data to url for get requests
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5047
		if ( s.data && type === "GET" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5048
			s.url += (rquery.test(s.url) ? "&" : "?") + s.data;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5049
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5050
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5051
		// Watch for a new set of requests
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5052
		if ( s.global && ! jQuery.active++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5053
			jQuery.event.trigger( "ajaxStart" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5054
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5055
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5056
		// Matches an absolute URL, and saves the domain
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5057
		var parts = rurl.exec( s.url ),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5058
			remote = parts && (parts[1] && parts[1] !== location.protocol || parts[2] !== location.host);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5059
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5060
		// If we're requesting a remote document
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5061
		// and trying to load JSON or Script with a GET
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5062
		if ( s.dataType === "script" && type === "GET" && remote ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5063
			var head = document.getElementsByTagName("head")[0] || document.documentElement;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5064
			var script = document.createElement("script");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5065
			script.src = s.url;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5066
			if ( s.scriptCharset ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5067
				script.charset = s.scriptCharset;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5068
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5069
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5070
			// Handle Script loading
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5071
			if ( !jsonp ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5072
				var done = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5073
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5074
				// Attach handlers for all browsers
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5075
				script.onload = script.onreadystatechange = function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5076
					if ( !done && (!this.readyState ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5077
							this.readyState === "loaded" || this.readyState === "complete") ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5078
						done = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5079
						success();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5080
						complete();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5081
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5082
						// Handle memory leak in IE
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5083
						script.onload = script.onreadystatechange = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5084
						if ( head && script.parentNode ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5085
							head.removeChild( script );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5086
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5087
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5088
				};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5089
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5090
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5091
			// Use insertBefore instead of appendChild  to circumvent an IE6 bug.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5092
			// This arises when a base node is used (#2709 and #4378).
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5093
			head.insertBefore( script, head.firstChild );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5094
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5095
			// We handle everything using the script element injection
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5096
			return undefined;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5097
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5098
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5099
		var requestDone = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5100
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5101
		// Create the request object
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5102
		var xhr = s.xhr();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5103
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5104
		if ( !xhr ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5105
			return;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5106
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5107
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5108
		// Open the socket
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5109
		// Passing null username, generates a login popup on Opera (#2865)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5110
		if ( s.username ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5111
			xhr.open(type, s.url, s.async, s.username, s.password);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5112
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5113
			xhr.open(type, s.url, s.async);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5114
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5115
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5116
		// Need an extra try/catch for cross domain requests in Firefox 3
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5117
		try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5118
			// Set the correct header, if data is being sent
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5119
			if ( s.data || origSettings && origSettings.contentType ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5120
				xhr.setRequestHeader("Content-Type", s.contentType);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5121
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5122
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5123
			// Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5124
			if ( s.ifModified ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5125
				if ( jQuery.lastModified[s.url] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5126
					xhr.setRequestHeader("If-Modified-Since", jQuery.lastModified[s.url]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5127
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5128
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5129
				if ( jQuery.etag[s.url] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5130
					xhr.setRequestHeader("If-None-Match", jQuery.etag[s.url]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5131
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5132
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5133
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5134
			// Set header so the called script knows that it's an XMLHttpRequest
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5135
			// Only send the header if it's not a remote XHR
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5136
			if ( !remote ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5137
				xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5138
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5139
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5140
			// Set the Accepts header for the server, depending on the dataType
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5141
			xhr.setRequestHeader("Accept", s.dataType && s.accepts[ s.dataType ] ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5142
				s.accepts[ s.dataType ] + ", */*" :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5143
				s.accepts._default );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5144
		} catch(e) {}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5145
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5146
		// Allow custom headers/mimetypes and early abort
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5147
		if ( s.beforeSend && s.beforeSend.call(callbackContext, xhr, s) === false ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5148
			// Handle the global AJAX counter
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5149
			if ( s.global && ! --jQuery.active ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5150
				jQuery.event.trigger( "ajaxStop" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5151
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5152
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5153
			// close opended socket
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5154
			xhr.abort();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5155
			return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5156
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5157
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5158
		if ( s.global ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5159
			trigger("ajaxSend", [xhr, s]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5160
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5161
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5162
		// Wait for a response to come back
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5163
		var onreadystatechange = xhr.onreadystatechange = function( isTimeout ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5164
			// The request was aborted
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5165
			if ( !xhr || xhr.readyState === 0 || isTimeout === "abort" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5166
				// Opera doesn't call onreadystatechange before this point
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5167
				// so we simulate the call
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5168
				if ( !requestDone ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5169
					complete();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5170
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5171
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5172
				requestDone = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5173
				if ( xhr ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5174
					xhr.onreadystatechange = jQuery.noop;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5175
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5176
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5177
			// The transfer is complete and the data is available, or the request timed out
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5178
			} else if ( !requestDone && xhr && (xhr.readyState === 4 || isTimeout === "timeout") ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5179
				requestDone = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5180
				xhr.onreadystatechange = jQuery.noop;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5181
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5182
				status = isTimeout === "timeout" ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5183
					"timeout" :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5184
					!jQuery.httpSuccess( xhr ) ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5185
						"error" :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5186
						s.ifModified && jQuery.httpNotModified( xhr, s.url ) ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5187
							"notmodified" :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5188
							"success";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5189
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5190
				var errMsg;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5191
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5192
				if ( status === "success" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5193
					// Watch for, and catch, XML document parse errors
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5194
					try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5195
						// process the data (runs the xml through httpData regardless of callback)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5196
						data = jQuery.httpData( xhr, s.dataType, s );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5197
					} catch(err) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5198
						status = "parsererror";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5199
						errMsg = err;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5200
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5201
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5202
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5203
				// Make sure that the request was successful or notmodified
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5204
				if ( status === "success" || status === "notmodified" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5205
					// JSONP handles its own success callback
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5206
					if ( !jsonp ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5207
						success();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5208
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5209
				} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5210
					jQuery.handleError(s, xhr, status, errMsg);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5211
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5212
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5213
				// Fire the complete handlers
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5214
				complete();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5215
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5216
				if ( isTimeout === "timeout" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5217
					xhr.abort();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5218
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5219
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5220
				// Stop memory leaks
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5221
				if ( s.async ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5222
					xhr = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5223
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5224
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5225
		};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5226
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5227
		// Override the abort handler, if we can (IE doesn't allow it, but that's OK)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5228
		// Opera doesn't fire onreadystatechange at all on abort
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5229
		try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5230
			var oldAbort = xhr.abort;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5231
			xhr.abort = function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5232
				if ( xhr ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5233
					oldAbort.call( xhr );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5234
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5235
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5236
				onreadystatechange( "abort" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5237
			};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5238
		} catch(e) { }
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5239
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5240
		// Timeout checker
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5241
		if ( s.async && s.timeout > 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5242
			setTimeout(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5243
				// Check to see if the request is still happening
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5244
				if ( xhr && !requestDone ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5245
					onreadystatechange( "timeout" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5246
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5247
			}, s.timeout);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5248
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5249
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5250
		// Send the data
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5251
		try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5252
			xhr.send( type === "POST" || type === "PUT" || type === "DELETE" ? s.data : null );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5253
		} catch(e) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5254
			jQuery.handleError(s, xhr, null, e);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5255
			// Fire the complete handlers
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5256
			complete();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5257
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5258
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5259
		// firefox 1.5 doesn't fire statechange for sync requests
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5260
		if ( !s.async ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5261
			onreadystatechange();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5262
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5263
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5264
		function success() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5265
			// If a local callback was specified, fire it and pass it the data
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5266
			if ( s.success ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5267
				s.success.call( callbackContext, data, status, xhr );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5268
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5269
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5270
			// Fire the global callback
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5271
			if ( s.global ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5272
				trigger( "ajaxSuccess", [xhr, s] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5273
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5274
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5275
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5276
		function complete() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5277
			// Process result
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5278
			if ( s.complete ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5279
				s.complete.call( callbackContext, xhr, status);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5280
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5281
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5282
			// The request was completed
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5283
			if ( s.global ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5284
				trigger( "ajaxComplete", [xhr, s] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5285
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5286
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5287
			// Handle the global AJAX counter
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5288
			if ( s.global && ! --jQuery.active ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5289
				jQuery.event.trigger( "ajaxStop" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5290
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5291
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5292
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5293
		function trigger(type, args) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5294
			(s.context ? jQuery(s.context) : jQuery.event).trigger(type, args);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5295
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5296
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5297
		// return XMLHttpRequest to allow aborting the request etc.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5298
		return xhr;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5299
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5300
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5301
	handleError: function( s, xhr, status, e ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5302
		// If a local callback was specified, fire it
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5303
		if ( s.error ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5304
			s.error.call( s.context || s, xhr, status, e );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5305
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5306
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5307
		// Fire the global callback
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5308
		if ( s.global ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5309
			(s.context ? jQuery(s.context) : jQuery.event).trigger( "ajaxError", [xhr, s, e] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5310
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5311
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5312
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5313
	// Counter for holding the number of active queries
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5314
	active: 0,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5315
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5316
	// Determines if an XMLHttpRequest was successful or not
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5317
	httpSuccess: function( xhr ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5318
		try {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5319
			// IE error sometimes returns 1223 when it should be 204 so treat it as success, see #1450
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5320
			return !xhr.status && location.protocol === "file:" ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5321
				// Opera returns 0 when status is 304
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5322
				( xhr.status >= 200 && xhr.status < 300 ) ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5323
				xhr.status === 304 || xhr.status === 1223 || xhr.status === 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5324
		} catch(e) {}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5325
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5326
		return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5327
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5328
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5329
	// Determines if an XMLHttpRequest returns NotModified
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5330
	httpNotModified: function( xhr, url ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5331
		var lastModified = xhr.getResponseHeader("Last-Modified"),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5332
			etag = xhr.getResponseHeader("Etag");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5333
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5334
		if ( lastModified ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5335
			jQuery.lastModified[url] = lastModified;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5336
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5337
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5338
		if ( etag ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5339
			jQuery.etag[url] = etag;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5340
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5341
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5342
		// Opera returns 0 when status is 304
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5343
		return xhr.status === 304 || xhr.status === 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5344
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5345
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5346
	httpData: function( xhr, type, s ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5347
		var ct = xhr.getResponseHeader("content-type") || "",
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5348
			xml = type === "xml" || !type && ct.indexOf("xml") >= 0,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5349
			data = xml ? xhr.responseXML : xhr.responseText;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5350
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5351
		if ( xml && data.documentElement.nodeName === "parsererror" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5352
			jQuery.error( "parsererror" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5353
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5354
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5355
		// Allow a pre-filtering function to sanitize the response
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5356
		// s is checked to keep backwards compatibility
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5357
		if ( s && s.dataFilter ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5358
			data = s.dataFilter( data, type );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5359
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5360
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5361
		// The filter can actually parse the response
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5362
		if ( typeof data === "string" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5363
			// Get the JavaScript object, if JSON is used.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5364
			if ( type === "json" || !type && ct.indexOf("json") >= 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5365
				data = jQuery.parseJSON( data );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5366
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5367
			// If the type is "script", eval it in global context
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5368
			} else if ( type === "script" || !type && ct.indexOf("javascript") >= 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5369
				jQuery.globalEval( data );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5370
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5371
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5372
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5373
		return data;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5374
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5375
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5376
	// Serialize an array of form elements or a set of
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5377
	// key/values into a query string
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5378
	param: function( a, traditional ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5379
		var s = [];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5380
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5381
		// Set traditional to true for jQuery <= 1.3.2 behavior.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5382
		if ( traditional === undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5383
			traditional = jQuery.ajaxSettings.traditional;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5384
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5385
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5386
		// If an array was passed in, assume that it is an array of form elements.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5387
		if ( jQuery.isArray(a) || a.jquery ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5388
			// Serialize the form elements
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5389
			jQuery.each( a, function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5390
				add( this.name, this.value );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5391
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5392
			
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5393
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5394
			// If traditional, encode the "old" way (the way 1.3.2 or older
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5395
			// did it), otherwise encode params recursively.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5396
			for ( var prefix in a ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5397
				buildParams( prefix, a[prefix] );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5398
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5399
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5400
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5401
		// Return the resulting serialization
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5402
		return s.join("&").replace(r20, "+");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5403
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5404
		function buildParams( prefix, obj ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5405
			if ( jQuery.isArray(obj) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5406
				// Serialize array item.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5407
				jQuery.each( obj, function( i, v ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5408
					if ( traditional || /\[\]$/.test( prefix ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5409
						// Treat each array item as a scalar.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5410
						add( prefix, v );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5411
					} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5412
						// If array item is non-scalar (array or object), encode its
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5413
						// numeric index to resolve deserialization ambiguity issues.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5414
						// Note that rack (as of 1.0.0) can't currently deserialize
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5415
						// nested arrays properly, and attempting to do so may cause
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5416
						// a server error. Possible fixes are to modify rack's
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5417
						// deserialization algorithm or to provide an option or flag
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5418
						// to force array serialization to be shallow.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5419
						buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5420
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5421
				});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5422
					
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5423
			} else if ( !traditional && obj != null && typeof obj === "object" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5424
				// Serialize object item.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5425
				jQuery.each( obj, function( k, v ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5426
					buildParams( prefix + "[" + k + "]", v );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5427
				});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5428
					
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5429
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5430
				// Serialize scalar item.
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5431
				add( prefix, obj );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5432
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5433
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5434
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5435
		function add( key, value ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5436
			// If value is a function, invoke it and return its value
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5437
			value = jQuery.isFunction(value) ? value() : value;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5438
			s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5439
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5440
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5441
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5442
var elemdisplay = {},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5443
	rfxtypes = /toggle|show|hide/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5444
	rfxnum = /^([+-]=)?([\d+-.]+)(.*)$/,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5445
	timerId,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5446
	fxAttrs = [
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5447
		// height animations
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5448
		[ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5449
		// width animations
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5450
		[ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5451
		// opacity animations
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5452
		[ "opacity" ]
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5453
	];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5454
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5455
jQuery.fn.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5456
	show: function( speed, callback ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5457
		if ( speed || speed === 0) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5458
			return this.animate( genFx("show", 3), speed, callback);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5459
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5460
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5461
			for ( var i = 0, l = this.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5462
				var old = jQuery.data(this[i], "olddisplay");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5463
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5464
				this[i].style.display = old || "";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5465
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5466
				if ( jQuery.css(this[i], "display") === "none" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5467
					var nodeName = this[i].nodeName, display;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5468
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5469
					if ( elemdisplay[ nodeName ] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5470
						display = elemdisplay[ nodeName ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5471
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5472
					} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5473
						var elem = jQuery("<" + nodeName + " />").appendTo("body");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5474
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5475
						display = elem.css("display");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5476
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5477
						if ( display === "none" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5478
							display = "block";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5479
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5480
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5481
						elem.remove();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5482
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5483
						elemdisplay[ nodeName ] = display;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5484
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5485
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5486
					jQuery.data(this[i], "olddisplay", display);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5487
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5488
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5489
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5490
			// Set the display of the elements in a second loop
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5491
			// to avoid the constant reflow
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5492
			for ( var j = 0, k = this.length; j < k; j++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5493
				this[j].style.display = jQuery.data(this[j], "olddisplay") || "";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5494
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5495
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5496
			return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5497
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5498
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5499
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5500
	hide: function( speed, callback ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5501
		if ( speed || speed === 0 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5502
			return this.animate( genFx("hide", 3), speed, callback);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5503
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5504
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5505
			for ( var i = 0, l = this.length; i < l; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5506
				var old = jQuery.data(this[i], "olddisplay");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5507
				if ( !old && old !== "none" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5508
					jQuery.data(this[i], "olddisplay", jQuery.css(this[i], "display"));
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5509
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5510
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5511
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5512
			// Set the display of the elements in a second loop
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5513
			// to avoid the constant reflow
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5514
			for ( var j = 0, k = this.length; j < k; j++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5515
				this[j].style.display = "none";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5516
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5517
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5518
			return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5519
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5520
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5521
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5522
	// Save the old toggle function
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5523
	_toggle: jQuery.fn.toggle,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5524
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5525
	toggle: function( fn, fn2 ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5526
		var bool = typeof fn === "boolean";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5527
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5528
		if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5529
			this._toggle.apply( this, arguments );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5530
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5531
		} else if ( fn == null || bool ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5532
			this.each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5533
				var state = bool ? fn : jQuery(this).is(":hidden");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5534
				jQuery(this)[ state ? "show" : "hide" ]();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5535
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5536
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5537
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5538
			this.animate(genFx("toggle", 3), fn, fn2);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5539
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5540
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5541
		return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5542
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5543
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5544
	fadeTo: function( speed, to, callback ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5545
		return this.filter(":hidden").css("opacity", 0).show().end()
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5546
					.animate({opacity: to}, speed, callback);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5547
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5548
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5549
	animate: function( prop, speed, easing, callback ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5550
		var optall = jQuery.speed(speed, easing, callback);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5551
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5552
		if ( jQuery.isEmptyObject( prop ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5553
			return this.each( optall.complete );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5554
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5555
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5556
		return this[ optall.queue === false ? "each" : "queue" ](function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5557
			var opt = jQuery.extend({}, optall), p,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5558
				hidden = this.nodeType === 1 && jQuery(this).is(":hidden"),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5559
				self = this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5560
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5561
			for ( p in prop ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5562
				var name = p.replace(rdashAlpha, fcamelCase);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5563
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5564
				if ( p !== name ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5565
					prop[ name ] = prop[ p ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5566
					delete prop[ p ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5567
					p = name;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5568
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5569
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5570
				if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5571
					return opt.complete.call(this);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5572
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5573
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5574
				if ( ( p === "height" || p === "width" ) && this.style ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5575
					// Store display property
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5576
					opt.display = jQuery.css(this, "display");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5577
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5578
					// Make sure that nothing sneaks out
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5579
					opt.overflow = this.style.overflow;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5580
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5581
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5582
				if ( jQuery.isArray( prop[p] ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5583
					// Create (if needed) and add to specialEasing
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5584
					(opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5585
					prop[p] = prop[p][0];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5586
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5587
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5588
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5589
			if ( opt.overflow != null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5590
				this.style.overflow = "hidden";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5591
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5592
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5593
			opt.curAnim = jQuery.extend({}, prop);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5594
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5595
			jQuery.each( prop, function( name, val ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5596
				var e = new jQuery.fx( self, opt, name );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5597
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5598
				if ( rfxtypes.test(val) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5599
					e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5600
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5601
				} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5602
					var parts = rfxnum.exec(val),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5603
						start = e.cur(true) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5604
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5605
					if ( parts ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5606
						var end = parseFloat( parts[2] ),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5607
							unit = parts[3] || "px";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5608
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5609
						// We need to compute starting value
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5610
						if ( unit !== "px" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5611
							self.style[ name ] = (end || 1) + unit;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5612
							start = ((end || 1) / e.cur(true)) * start;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5613
							self.style[ name ] = start + unit;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5614
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5615
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5616
						// If a +=/-= token was provided, we're doing a relative animation
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5617
						if ( parts[1] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5618
							end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5619
						}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5620
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5621
						e.custom( start, end, unit );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5622
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5623
					} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5624
						e.custom( start, val, "" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5625
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5626
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5627
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5628
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5629
			// For JS strict compliance
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5630
			return true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5631
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5632
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5633
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5634
	stop: function( clearQueue, gotoEnd ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5635
		var timers = jQuery.timers;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5636
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5637
		if ( clearQueue ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5638
			this.queue([]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5639
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5640
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5641
		this.each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5642
			// go in reverse order so anything added to the queue during the loop is ignored
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5643
			for ( var i = timers.length - 1; i >= 0; i-- ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5644
				if ( timers[i].elem === this ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5645
					if (gotoEnd) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5646
						// force the next step to be the last
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5647
						timers[i](true);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5648
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5649
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5650
					timers.splice(i, 1);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5651
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5652
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5653
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5654
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5655
		// start the next in the queue if the last step wasn't forced
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5656
		if ( !gotoEnd ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5657
			this.dequeue();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5658
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5659
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5660
		return this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5661
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5662
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5663
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5664
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5665
// Generate shortcuts for custom animations
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5666
jQuery.each({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5667
	slideDown: genFx("show", 1),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5668
	slideUp: genFx("hide", 1),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5669
	slideToggle: genFx("toggle", 1),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5670
	fadeIn: { opacity: "show" },
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5671
	fadeOut: { opacity: "hide" }
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5672
}, function( name, props ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5673
	jQuery.fn[ name ] = function( speed, callback ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5674
		return this.animate( props, speed, callback );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5675
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5676
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5677
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5678
jQuery.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5679
	speed: function( speed, easing, fn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5680
		var opt = speed && typeof speed === "object" ? speed : {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5681
			complete: fn || !fn && easing ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5682
				jQuery.isFunction( speed ) && speed,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5683
			duration: speed,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5684
			easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5685
		};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5686
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5687
		opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5688
			jQuery.fx.speeds[opt.duration] || jQuery.fx.speeds._default;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5689
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5690
		// Queueing
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5691
		opt.old = opt.complete;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5692
		opt.complete = function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5693
			if ( opt.queue !== false ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5694
				jQuery(this).dequeue();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5695
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5696
			if ( jQuery.isFunction( opt.old ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5697
				opt.old.call( this );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5698
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5699
		};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5700
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5701
		return opt;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5702
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5703
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5704
	easing: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5705
		linear: function( p, n, firstNum, diff ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5706
			return firstNum + diff * p;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5707
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5708
		swing: function( p, n, firstNum, diff ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5709
			return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5710
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5711
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5712
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5713
	timers: [],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5714
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5715
	fx: function( elem, options, prop ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5716
		this.options = options;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5717
		this.elem = elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5718
		this.prop = prop;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5719
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5720
		if ( !options.orig ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5721
			options.orig = {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5722
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5723
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5724
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5725
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5726
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5727
jQuery.fx.prototype = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5728
	// Simple function for setting a style value
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5729
	update: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5730
		if ( this.options.step ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5731
			this.options.step.call( this.elem, this.now, this );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5732
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5733
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5734
		(jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5735
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5736
		// Set display property to block for height/width animations
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5737
		if ( ( this.prop === "height" || this.prop === "width" ) && this.elem.style ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5738
			this.elem.style.display = "block";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5739
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5740
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5741
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5742
	// Get the current size
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5743
	cur: function( force ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5744
		if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5745
			return this.elem[ this.prop ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5746
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5747
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5748
		var r = parseFloat(jQuery.css(this.elem, this.prop, force));
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5749
		return r && r > -10000 ? r : parseFloat(jQuery.curCSS(this.elem, this.prop)) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5750
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5751
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5752
	// Start an animation from one number to another
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5753
	custom: function( from, to, unit ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5754
		this.startTime = now();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5755
		this.start = from;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5756
		this.end = to;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5757
		this.unit = unit || this.unit || "px";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5758
		this.now = this.start;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5759
		this.pos = this.state = 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5760
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5761
		var self = this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5762
		function t( gotoEnd ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5763
			return self.step(gotoEnd);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5764
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5765
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5766
		t.elem = this.elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5767
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5768
		if ( t() && jQuery.timers.push(t) && !timerId ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5769
			timerId = setInterval(jQuery.fx.tick, 13);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5770
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5771
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5772
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5773
	// Simple 'show' function
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5774
	show: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5775
		// Remember where we started, so that we can go back to it later
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5776
		this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5777
		this.options.show = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5778
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5779
		// Begin the animation
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5780
		// Make sure that we start at a small width/height to avoid any
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5781
		// flash of content
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5782
		this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5783
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5784
		// Start by showing the element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5785
		jQuery( this.elem ).show();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5786
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5787
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5788
	// Simple 'hide' function
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5789
	hide: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5790
		// Remember where we started, so that we can go back to it later
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5791
		this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5792
		this.options.hide = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5793
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5794
		// Begin the animation
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5795
		this.custom(this.cur(), 0);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5796
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5797
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5798
	// Each step of an animation
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5799
	step: function( gotoEnd ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5800
		var t = now(), done = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5801
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5802
		if ( gotoEnd || t >= this.options.duration + this.startTime ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5803
			this.now = this.end;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5804
			this.pos = this.state = 1;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5805
			this.update();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5806
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5807
			this.options.curAnim[ this.prop ] = true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5808
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5809
			for ( var i in this.options.curAnim ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5810
				if ( this.options.curAnim[i] !== true ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5811
					done = false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5812
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5813
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5814
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5815
			if ( done ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5816
				if ( this.options.display != null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5817
					// Reset the overflow
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5818
					this.elem.style.overflow = this.options.overflow;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5819
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5820
					// Reset the display
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5821
					var old = jQuery.data(this.elem, "olddisplay");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5822
					this.elem.style.display = old ? old : this.options.display;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5823
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5824
					if ( jQuery.css(this.elem, "display") === "none" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5825
						this.elem.style.display = "block";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5826
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5827
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5828
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5829
				// Hide the element if the "hide" operation was done
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5830
				if ( this.options.hide ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5831
					jQuery(this.elem).hide();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5832
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5833
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5834
				// Reset the properties, if the item has been hidden or shown
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5835
				if ( this.options.hide || this.options.show ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5836
					for ( var p in this.options.curAnim ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5837
						jQuery.style(this.elem, p, this.options.orig[p]);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5838
					}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5839
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5840
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5841
				// Execute the complete function
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5842
				this.options.complete.call( this.elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5843
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5844
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5845
			return false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5846
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5847
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5848
			var n = t - this.startTime;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5849
			this.state = n / this.options.duration;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5850
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5851
			// Perform the easing function, defaults to swing
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5852
			var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5853
			var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5854
			this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5855
			this.now = this.start + ((this.end - this.start) * this.pos);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5856
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5857
			// Perform the next step of the animation
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5858
			this.update();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5859
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5860
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5861
		return true;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5862
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5863
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5864
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5865
jQuery.extend( jQuery.fx, {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5866
	tick: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5867
		var timers = jQuery.timers;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5868
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5869
		for ( var i = 0; i < timers.length; i++ ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5870
			if ( !timers[i]() ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5871
				timers.splice(i--, 1);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5872
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5873
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5874
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5875
		if ( !timers.length ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5876
			jQuery.fx.stop();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5877
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5878
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5879
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5880
	stop: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5881
		clearInterval( timerId );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5882
		timerId = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5883
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5884
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5885
	speeds: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5886
		slow: 600,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5887
 		fast: 200,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5888
 		// Default speed
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5889
 		_default: 400
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5890
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5891
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5892
	step: {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5893
		opacity: function( fx ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5894
			jQuery.style(fx.elem, "opacity", fx.now);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5895
		},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5896
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5897
		_default: function( fx ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5898
			if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5899
				fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5900
			} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5901
				fx.elem[ fx.prop ] = fx.now;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5902
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5903
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5904
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5905
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5906
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5907
if ( jQuery.expr && jQuery.expr.filters ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5908
	jQuery.expr.filters.animated = function( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5909
		return jQuery.grep(jQuery.timers, function( fn ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5910
			return elem === fn.elem;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5911
		}).length;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5912
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5913
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5914
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5915
function genFx( type, num ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5916
	var obj = {};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5917
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5918
	jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5919
		obj[ this ] = type;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5920
	});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5921
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5922
	return obj;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5923
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5924
if ( "getBoundingClientRect" in document.documentElement ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5925
	jQuery.fn.offset = function( options ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5926
		var elem = this[0];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5927
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5928
		if ( options ) { 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5929
			return this.each(function( i ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5930
				jQuery.offset.setOffset( this, options, i );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5931
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5932
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5933
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5934
		if ( !elem || !elem.ownerDocument ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5935
			return null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5936
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5937
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5938
		if ( elem === elem.ownerDocument.body ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5939
			return jQuery.offset.bodyOffset( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5940
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5941
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5942
		var box = elem.getBoundingClientRect(), doc = elem.ownerDocument, body = doc.body, docElem = doc.documentElement,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5943
			clientTop = docElem.clientTop || body.clientTop || 0, clientLeft = docElem.clientLeft || body.clientLeft || 0,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5944
			top  = box.top  + (self.pageYOffset || jQuery.support.boxModel && docElem.scrollTop  || body.scrollTop ) - clientTop,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5945
			left = box.left + (self.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft) - clientLeft;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5946
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5947
		return { top: top, left: left };
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5948
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5949
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5950
} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5951
	jQuery.fn.offset = function( options ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5952
		var elem = this[0];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5953
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5954
		if ( options ) { 
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5955
			return this.each(function( i ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5956
				jQuery.offset.setOffset( this, options, i );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5957
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5958
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5959
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5960
		if ( !elem || !elem.ownerDocument ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5961
			return null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5962
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5963
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5964
		if ( elem === elem.ownerDocument.body ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5965
			return jQuery.offset.bodyOffset( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5966
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5967
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5968
		jQuery.offset.initialize();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5969
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5970
		var offsetParent = elem.offsetParent, prevOffsetParent = elem,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5971
			doc = elem.ownerDocument, computedStyle, docElem = doc.documentElement,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5972
			body = doc.body, defaultView = doc.defaultView,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5973
			prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5974
			top = elem.offsetTop, left = elem.offsetLeft;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5975
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5976
		while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5977
			if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5978
				break;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5979
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5980
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5981
			computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5982
			top  -= elem.scrollTop;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5983
			left -= elem.scrollLeft;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5984
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5985
			if ( elem === offsetParent ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5986
				top  += elem.offsetTop;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5987
				left += elem.offsetLeft;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5988
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5989
				if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && /^t(able|d|h)$/i.test(elem.nodeName)) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5990
					top  += parseFloat( computedStyle.borderTopWidth  ) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5991
					left += parseFloat( computedStyle.borderLeftWidth ) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5992
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5993
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5994
				prevOffsetParent = offsetParent, offsetParent = elem.offsetParent;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5995
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5996
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5997
			if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5998
				top  += parseFloat( computedStyle.borderTopWidth  ) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  5999
				left += parseFloat( computedStyle.borderLeftWidth ) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6000
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6001
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6002
			prevComputedStyle = computedStyle;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6003
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6004
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6005
		if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6006
			top  += body.offsetTop;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6007
			left += body.offsetLeft;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6008
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6009
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6010
		if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6011
			top  += Math.max( docElem.scrollTop, body.scrollTop );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6012
			left += Math.max( docElem.scrollLeft, body.scrollLeft );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6013
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6014
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6015
		return { top: top, left: left };
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6016
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6017
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6018
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6019
jQuery.offset = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6020
	initialize: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6021
		var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.curCSS(body, "marginTop", true) ) || 0,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6022
			html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6023
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6024
		jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6025
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6026
		container.innerHTML = html;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6027
		body.insertBefore( container, body.firstChild );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6028
		innerDiv = container.firstChild;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6029
		checkDiv = innerDiv.firstChild;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6030
		td = innerDiv.nextSibling.firstChild.firstChild;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6031
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6032
		this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6033
		this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6034
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6035
		checkDiv.style.position = "fixed", checkDiv.style.top = "20px";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6036
		// safari subtracts parent border width here which is 5px
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6037
		this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6038
		checkDiv.style.position = checkDiv.style.top = "";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6039
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6040
		innerDiv.style.overflow = "hidden", innerDiv.style.position = "relative";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6041
		this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6042
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6043
		this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6044
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6045
		body.removeChild( container );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6046
		body = container = innerDiv = checkDiv = table = td = null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6047
		jQuery.offset.initialize = jQuery.noop;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6048
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6049
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6050
	bodyOffset: function( body ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6051
		var top = body.offsetTop, left = body.offsetLeft;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6052
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6053
		jQuery.offset.initialize();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6054
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6055
		if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6056
			top  += parseFloat( jQuery.curCSS(body, "marginTop",  true) ) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6057
			left += parseFloat( jQuery.curCSS(body, "marginLeft", true) ) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6058
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6059
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6060
		return { top: top, left: left };
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6061
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6062
	
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6063
	setOffset: function( elem, options, i ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6064
		// set position first, in-case top/left are set even on static elem
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6065
		if ( /static/.test( jQuery.curCSS( elem, "position" ) ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6066
			elem.style.position = "relative";
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6067
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6068
		var curElem   = jQuery( elem ),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6069
			curOffset = curElem.offset(),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6070
			curTop    = parseInt( jQuery.curCSS( elem, "top",  true ), 10 ) || 0,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6071
			curLeft   = parseInt( jQuery.curCSS( elem, "left", true ), 10 ) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6072
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6073
		if ( jQuery.isFunction( options ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6074
			options = options.call( elem, i, curOffset );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6075
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6076
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6077
		var props = {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6078
			top:  (options.top  - curOffset.top)  + curTop,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6079
			left: (options.left - curOffset.left) + curLeft
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6080
		};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6081
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6082
		if ( "using" in options ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6083
			options.using.call( elem, props );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6084
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6085
			curElem.css( props );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6086
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6087
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6088
};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6089
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6090
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6091
jQuery.fn.extend({
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6092
	position: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6093
		if ( !this[0] ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6094
			return null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6095
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6096
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6097
		var elem = this[0],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6098
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6099
		// Get *real* offsetParent
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6100
		offsetParent = this.offsetParent(),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6101
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6102
		// Get correct offsets
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6103
		offset       = this.offset(),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6104
		parentOffset = /^body|html$/i.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6105
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6106
		// Subtract element margins
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6107
		// note: when an element has margin: auto the offsetLeft and marginLeft
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6108
		// are the same in Safari causing offset.left to incorrectly be 0
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6109
		offset.top  -= parseFloat( jQuery.curCSS(elem, "marginTop",  true) ) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6110
		offset.left -= parseFloat( jQuery.curCSS(elem, "marginLeft", true) ) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6111
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6112
		// Add offsetParent borders
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6113
		parentOffset.top  += parseFloat( jQuery.curCSS(offsetParent[0], "borderTopWidth",  true) ) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6114
		parentOffset.left += parseFloat( jQuery.curCSS(offsetParent[0], "borderLeftWidth", true) ) || 0;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6115
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6116
		// Subtract the two offsets
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6117
		return {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6118
			top:  offset.top  - parentOffset.top,
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6119
			left: offset.left - parentOffset.left
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6120
		};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6121
	},
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6122
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6123
	offsetParent: function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6124
		return this.map(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6125
			var offsetParent = this.offsetParent || document.body;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6126
			while ( offsetParent && (!/^body|html$/i.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6127
				offsetParent = offsetParent.offsetParent;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6128
			}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6129
			return offsetParent;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6130
		});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6131
	}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6132
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6133
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6134
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6135
// Create scrollLeft and scrollTop methods
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6136
jQuery.each( ["Left", "Top"], function( i, name ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6137
	var method = "scroll" + name;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6138
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6139
	jQuery.fn[ method ] = function(val) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6140
		var elem = this[0], win;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6141
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6142
		if ( !elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6143
			return null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6144
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6145
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6146
		if ( val !== undefined ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6147
			// Set the scroll offset
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6148
			return this.each(function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6149
				win = getWindow( this );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6150
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6151
				if ( win ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6152
					win.scrollTo(
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6153
						!i ? val : jQuery(win).scrollLeft(),
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6154
						 i ? val : jQuery(win).scrollTop()
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6155
					);
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6156
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6157
				} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6158
					this[ method ] = val;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6159
				}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6160
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6161
		} else {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6162
			win = getWindow( elem );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6163
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6164
			// Return the scroll offset
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6165
			return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6166
				jQuery.support.boxModel && win.document.documentElement[ method ] ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6167
					win.document.body[ method ] :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6168
				elem[ method ];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6169
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6170
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6171
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6172
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6173
function getWindow( elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6174
	return ("scrollTo" in elem && elem.document) ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6175
		elem :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6176
		elem.nodeType === 9 ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6177
			elem.defaultView || elem.parentWindow :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6178
			false;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6179
}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6180
// Create innerHeight, innerWidth, outerHeight and outerWidth methods
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6181
jQuery.each([ "Height", "Width" ], function( i, name ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6182
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6183
	var type = name.toLowerCase();
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6184
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6185
	// innerHeight and innerWidth
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6186
	jQuery.fn["inner" + name] = function() {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6187
		return this[0] ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6188
			jQuery.css( this[0], type, false, "padding" ) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6189
			null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6190
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6191
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6192
	// outerHeight and outerWidth
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6193
	jQuery.fn["outer" + name] = function( margin ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6194
		return this[0] ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6195
			jQuery.css( this[0], type, false, margin ? "margin" : "border" ) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6196
			null;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6197
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6198
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6199
	jQuery.fn[ type ] = function( size ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6200
		// Get window width or height
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6201
		var elem = this[0];
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6202
		if ( !elem ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6203
			return size == null ? null : this;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6204
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6205
		
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6206
		if ( jQuery.isFunction( size ) ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6207
			return this.each(function( i ) {
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6208
				var self = jQuery( this );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6209
				self[ type ]( size.call( this, i, self[ type ]() ) );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6210
			});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6211
		}
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6212
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6213
		return ("scrollTo" in elem && elem.document) ? // does it walk and quack like a window?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6214
			// Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6215
			elem.document.compatMode === "CSS1Compat" && elem.document.documentElement[ "client" + name ] ||
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6216
			elem.document.body[ "client" + name ] :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6217
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6218
			// Get document width or height
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6219
			(elem.nodeType === 9) ? // is it a document
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6220
				// Either scroll[Width/Height] or offset[Width/Height], whichever is greater
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6221
				Math.max(
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6222
					elem.documentElement["client" + name],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6223
					elem.body["scroll" + name], elem.documentElement["scroll" + name],
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6224
					elem.body["offset" + name], elem.documentElement["offset" + name]
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6225
				) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6226
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6227
				// Get or set width or height on the element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6228
				size === undefined ?
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6229
					// Get width or height on the element
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6230
					jQuery.css( elem, type ) :
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6231
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6232
					// Set the width or height on the element (default to pixels if value is unitless)
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6233
					this.css( type, typeof size === "string" ? size : size + "px" );
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6234
	};
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6235
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6236
});
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6237
// Expose jQuery to the global object
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6238
window.jQuery = window.$ = jQuery;
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6239
22ab430e9b64 Corrections on models and general structure
wakimd
parents:
diff changeset
  6240
})(window);