[Mapbender-commits] r1331 - trunk/mapbender/http/extensions

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon May 21 06:02:57 EDT 2007


Author: christoph
Date: 2007-05-21 06:02:57 -0400 (Mon, 21 May 2007)
New Revision: 1331

Modified:
   trunk/mapbender/http/extensions/jquery.js
Log:
latest version 1.1.2

Modified: trunk/mapbender/http/extensions/jquery.js
===================================================================
--- trunk/mapbender/http/extensions/jquery.js	2007-05-21 10:01:59 UTC (rev 1330)
+++ trunk/mapbender/http/extensions/jquery.js	2007-05-21 10:02:57 UTC (rev 1331)
@@ -1,14 +1,14 @@
 /* prevent execution of jQuery if included more than once */
 if(typeof window.jQuery == "undefined") {
 /*
- * jQuery 1.1 - New Wave Javascript
+ * jQuery 1.1.2 - New Wave Javascript
  *
  * Copyright (c) 2007 John Resig (jquery.com)
  * Dual licensed under the MIT (MIT-LICENSE.txt)
  * and GPL (GPL-LICENSE.txt) licenses.
  *
- * $Date: 2007-01-14 17:37:33 -0500 (Sun, 14 Jan 2007) $
- * $Rev: 1073 $
+ * $Date: 2007-02-28 12:03:00 -0500 (Wed, 28 Feb 2007) $
+ * $Rev: 1465 $
  */
 
 // Global undefined variable
@@ -23,22 +23,20 @@
 	
 	// HANDLE: $(function)
 	// Shortcut for document ready
-	// Safari reports typeof on DOM NodeLists as a function
-	if ( jQuery.isFunction(a) && !a.nodeType && a[0] == undefined )
+	if ( jQuery.isFunction(a) )
 		return new jQuery(document)[ jQuery.fn.ready ? "ready" : "load" ]( a );
 	
 	// Handle HTML strings
 	if ( typeof a  == "string" ) {
-		var m = /^[^<]*(<.+>)[^>]*$/.exec(a);
-
-		a = m ?
-			// HANDLE: $(html) -> $(array)
-			jQuery.clean( [ m[1] ] ) :
+		// HANDLE: $(html) -> $(array)
+		var m = /^[^<]*(<(.|\s)+>)[^>]*$/.exec(a);
+		if ( m )
+			a = jQuery.clean( [ m[1] ] );
 		
-			// HANDLE: $(expr)
-			jQuery.find( a, c );
+		// HANDLE: $(expr)
+		else
+			return new jQuery( c ).find( a );
 	}
-	
 	return this.setArray(
 		// HANDLE: $(array)
 		a.constructor == Array && a ||
@@ -59,7 +57,7 @@
 var $ = jQuery;
 
 jQuery.fn = jQuery.prototype = {
-	jquery: "1.1",
+	jquery: "1.1.2",
 
 	size: function() {
 		return this.length;
@@ -77,9 +75,9 @@
 			this[num];
 	},
 	pushStack: function( a ) {
-		var ret = jQuery(this);
+		var ret = jQuery(a);
 		ret.prevObject = this;
-		return ret.setArray( a );
+		return ret;
 	},
 	setArray: function( a ) {
 		this.length = 0;
@@ -103,19 +101,19 @@
 		// Look for the case where we're accessing a style value
 		if ( key.constructor == String )
 			if ( value == undefined )
-				return jQuery[ type || "attr" ]( this[0], key );
+				return this.length && jQuery[ type || "attr" ]( this[0], key ) || undefined;
 			else {
 				obj = {};
 				obj[ key ] = value;
 			}
 		
 		// Check to see if we're setting style values
-		return this.each(function(){
+		return this.each(function(index){
 			// Set all the styles
 			for ( var prop in obj )
 				jQuery.attr(
 					type ? this.style : this,
-					prop, jQuery.prop(this, obj[prop], type)
+					prop, jQuery.prop(this, obj[prop], type, index, prop)
 				);
 		});
 	},
@@ -185,11 +183,13 @@
 	find: function(t) {
 		return this.pushStack( jQuery.map( this, function(a){
 			return jQuery.find(t,a);
-		}) );
+		}), t );
 	},
 	clone: function(deep) {
 		return this.pushStack( jQuery.map( this, function(a){
-			return a.cloneNode( deep != undefined ? deep : true );
+			var a = a.cloneNode( deep != undefined ? deep : true );
+			a.$events = null; // drop $events expando to avoid firing incorrect events
+			return a;
 		}) );
 	},
 
@@ -206,20 +206,23 @@
 	not: function(t) {
 		return this.pushStack(
 			t.constructor == String &&
-			jQuery.multiFilter(t,this,true) ||
+			jQuery.multiFilter(t, this, true) ||
 
-			jQuery.grep(this,function(a){
-					if ( t.constructor == Array || t.jquery )
-						return jQuery.inArray( t, a ) < 0;
-					else
-						return a != t;
-			}) );
+			jQuery.grep(this, function(a) {
+				return ( t.constructor == Array || t.jquery )
+					? jQuery.inArray( a, t ) < 0
+					: a != t;
+			})
+		);
 	},
 
 	add: function(t) {
 		return this.pushStack( jQuery.merge(
 			this.get(),
-			typeof t == "string" ? jQuery(t).get() : t )
+			t.constructor == String ?
+				jQuery(t).get() :
+				t.length != undefined && (!t.nodeName || t.nodeName == "FORM") ?
+					t : [t] )
 		);
 	},
 	is: function(expr) {
@@ -246,7 +249,7 @@
 		return this.each(function(){
 			var obj = this;
 
-			if ( table && this.nodeName.toUpperCase() == "TABLE" && a[0].nodeName.toUpperCase() == "TR" )
+			if ( table && jQuery.nodeName(this, "table") && jQuery.nodeName(a[0], "tr") )
 				obj = this.getElementsByTagName("tbody")[0] || this.appendChild(document.createElement("tbody"));
 
 			jQuery.each( a, function(){
@@ -280,11 +283,24 @@
 	noConflict: function() {
 		if ( jQuery._$ )
 			$ = jQuery._$;
+		return jQuery;
 	},
 
+	// This may seem like some crazy code, but trust me when I say that this
+	// is the only cross-browser way to do this. --John
 	isFunction: function( fn ) {
-		return fn && typeof fn == "function";
+		return !!fn && typeof fn != "string" && !fn.nodeName && 
+			typeof fn[0] == "undefined" && /function/i.test( fn + "" );
 	},
+	
+	// check if an element is in a XML document
+	isXMLDoc: function(elem) {
+		return elem.tagName && elem.ownerDocument && !elem.ownerDocument.body;
+	},
+
+	nodeName: function( elem, name ) {
+		return elem.nodeName && elem.nodeName.toUpperCase() == name.toUpperCase();
+	},
 	// args is for internal usage only
 	each: function( obj, fn, args ) {
 		if ( obj.length == undefined )
@@ -296,16 +312,18 @@
 		return obj;
 	},
 	
-	prop: function(elem, value, type){
+	prop: function(elem, value, type, index, prop){
 			// Handle executable functions
 			if ( jQuery.isFunction( value ) )
-				return value.call( elem );
+				value = value.call( elem, [index] );
+				
+			// exclude the following css properties to add px
+			var exclude = /z-?index|font-?weight|opacity|zoom|line-?height/i;
 
 			// Handle passing in a number to a CSS property
-			if ( value.constructor == Number && type == "curCSS" )
-				return value + "px";
-
-			return value;
+			return value && value.constructor == Number && type == "curCSS" && !exclude.test(prop) ?
+				value + "px" :
+				value;
 	},
 
 	className: {
@@ -328,6 +346,8 @@
 		// internal only, use is(".class")
 		has: function( t, c ) {
 			t = t.className || t;
+			// escape regex characters
+			c = c.replace(/([\.\\\+\*\?\[\^\]\$\(\)\{\}\=\!\<\>\|\:])/g, "\\$1");
 			return t && new RegExp("(^|\\s)" + c + "(\\s|$)").test( t );
 		}
 	},
@@ -471,18 +491,20 @@
 						tb = div.childNodes;
 
 					for ( var n = tb.length-1; n >= 0 ; --n )
-						if ( tb[n].nodeName.toUpperCase() == "TBODY" && !tb[n].childNodes.length )
+						if ( jQuery.nodeName(tb[n], "tbody") && !tb[n].childNodes.length )
 							tb[n].parentNode.removeChild(tb[n]);
 					
 				}
 				
-				arg = div.childNodes;
+				arg = [];
+				for (var i=0, l=div.childNodes.length; i<l; i++)
+					arg.push(div.childNodes[i]);
 			}
 
-			if ( arg.length === 0 )
+			if ( arg.length === 0 && !jQuery.nodeName(arg, "form") )
 				return;
 			
-			if ( arg[0] == undefined )
+			if ( arg[0] == undefined || jQuery.nodeName(arg, "form") )
 				r.push( arg );
 			else
 				r = jQuery.merge( r, arg );
@@ -493,7 +515,7 @@
 	},
 	
 	attr: function(elem, name, value){
-		var fix = {
+		var fix = jQuery.isXMLDoc(elem) ? {} : {
 			"for": "htmlFor",
 			"class": "className",
 			"float": jQuery.browser.msie ? "styleFloat" : "cssFloat",
@@ -524,20 +546,24 @@
 		// Mozilla doesn't play well with opacity 1
 		if ( name == "opacity" && jQuery.browser.mozilla && value == 1 )
 			value = 0.9999;
+			
 
 		// Certain attributes only work when accessed via the old DOM 0 way
 		if ( fix[name] ) {
 			if ( value != undefined ) elem[fix[name]] = value;
 			return elem[fix[name]];
 
-		} else if ( value == undefined && jQuery.browser.msie && elem.nodeName && elem.nodeName.toUpperCase() == "FORM" && (name == "action" || name == "method") )
+		} else if ( value == undefined && jQuery.browser.msie && jQuery.nodeName(elem, "form") && (name == "action" || name == "method") )
 			return elem.getAttributeNode(name).nodeValue;
 
 		// IE elem.getAttribute passes even for style
 		else if ( elem.tagName ) {
 			if ( value != undefined ) elem.setAttribute( name, value );
+			if ( jQuery.browser.msie && /href|src/.test(name) && !jQuery.isXMLDoc(elem) ) 
+				return elem.getAttribute( name, 2 );
 			return elem.getAttribute( name );
 
+		// elem is actually elem.style ... set the style
 		} else {
 			name = name.replace(/-([a-z])/ig,function(z,b){return b.toUpperCase();});
 			if ( value != undefined ) elem[name] = value;
@@ -725,7 +751,7 @@
 });
 jQuery.extend({
 	expr: {
-		"": "m[2]=='*'||a.nodeName.toUpperCase()==m[2].toUpperCase()",
+		"": "m[2]=='*'||jQuery.nodeName(a,m[2])",
 		"#": "a.getAttribute('id')==m[2]",
 		":": {
 			// Position Checks
@@ -770,7 +796,7 @@
 			submit: "a.type=='submit'",
 			image: "a.type=='image'",
 			reset: "a.type=='reset'",
-			button: 'a.type=="button"||a.nodeName=="BUTTON"',
+			button: 'a.type=="button"||jQuery.nodeName(a,"button")',
 			input: "/input|select|textarea|button/i.test(a.nodeName)"
 		},
 		".": "jQuery.className.has(a,m[2])",
@@ -784,7 +810,7 @@
 			_resort: function(m){
 				return ["", m[1], m[3], m[2], m[5]];
 			},
-			_prefix: "z=a[m[3]]||jQuery.attr(a,m[3]);"
+			_prefix: "z=a[m[3]];if(!z||/href|src/.test(m[3]))z=jQuery.attr(a,m[3]);"
 		},
 		"[": "jQuery.find(m[2],a).length"
 	},
@@ -810,7 +836,7 @@
 		/^(\+)/, "jQuery.nth(a,2,'nextSibling')",
 		/^(~)/, function(a){
 			var s = jQuery.sibling(a.parentNode.firstChild);
-			return s.slice(0, jQuery.inArray(a,s));
+			return s.slice(jQuery.inArray(a,s) + 1);
 		}
 	],
 
@@ -873,12 +899,13 @@
 				// Perform our own iteration and filter
 				jQuery.each( ret, function(){
 					for ( var c = this.firstChild; c; c = c.nextSibling )
-						if ( c.nodeType == 1 && ( c.nodeName == m[1].toUpperCase() || m[1] == "*" ) )
+						if ( c.nodeType == 1 && ( jQuery.nodeName(c, m[1]) || m[1] == "*" ) )
 							r.push( c );
 				});
 
 				ret = r;
-				t = jQuery.trim( t.replace( re, "" ) );
+				t = t.replace( re, "" );
+				if ( t.indexOf(" ") == 0 ) continue;
 				foundToken = true;
 			} else {
 				// Look for pre-defined expression tokens
@@ -940,11 +967,15 @@
 					if ( m[1] == "#" && ret[ret.length-1].getElementById ) {
 						// Optimization for HTML document case
 						var oid = ret[ret.length-1].getElementById(m[2]);
+						
+						// Do a quick check for the existence of the actual ID attribute
+						// to avoid selecting by the name attribute in IE
+						if ( jQuery.browser.msie && oid && oid.id != m[2] )
+							oid = jQuery('[@id="'+m[2]+'"]', ret[ret.length-1])[0];
 
 						// Do a quick check for node name (where applicable) so
 						// that div#foo searches will be really fast
-						ret = r = oid && 
-						  (!m[3] || oid.nodeName == m[3].toUpperCase()) ? [oid] : [];
+						ret = r = oid && (!m[3] || jQuery.nodeName(oid, m[3])) ? [oid] : [];
 
 					} else {
 						// Pre-compile a regular expression to handle class searches
@@ -959,7 +990,7 @@
 							var tag = m[1] != "" || m[0] == "" ? "*" : m[2];
 
 							// Handle IE7 being really dumb about <object>s
-							if ( this.nodeName.toUpperCase() == "OBJECT" && tag == "*" )
+							if ( jQuery.nodeName(this, "object") && tag == "*" )
 								tag = "param";
 
 							jQuery.merge( r,
@@ -1012,7 +1043,6 @@
 
 		// And combine the results
 		jQuery.merge( done, ret );
-
 		return done;
 	},
 
@@ -1149,16 +1179,16 @@
 			handler.guid = this.guid++;
 
 		// Init the element's event structure
-		if (!element.events)
-			element.events = {};
+		if (!element.$events)
+			element.$events = {};
 
 		// Get the current list of functions bound to this event
-		var handlers = element.events[type];
+		var handlers = element.$events[type];
 
 		// If it hasn't been initialized yet
 		if (!handlers) {
 			// Init the event handler queue
-			handlers = element.events[type] = {};
+			handlers = element.$events[type] = {};
 
 			// Remember an existing handler, if it's already there
 			if (element["on" + type])
@@ -1182,47 +1212,73 @@
 
 	// Detach an event or set of events from an element
 	remove: function(element, type, handler) {
-		if (element.events)
-			if ( type && type.type )
-				delete element.events[ type.type ][ type.handler.guid ];
-			else if (type && element.events[type])
+		if (element.$events) {
+			var i,j,k;
+			if ( type && type.type ) { // type is actually an event object here
+				handler = type.handler;
+				type    = type.type;
+			}
+			
+			if (type && element.$events[type])
+				// remove the given handler for the given type
 				if ( handler )
-					delete element.events[type][handler.guid];
+					delete element.$events[type][handler.guid];
+					
+				// remove all handlers for the given type
 				else
-					for ( var i in element.events[type] )
-						delete element.events[type][i];
+					for ( i in element.$events[type] )
+						delete element.$events[type][i];
+						
+			// remove all handlers		
 			else
-				for ( var j in element.events )
+				for ( j in element.$events )
 					this.remove( element, j );
+			
+			// remove event handler if no more handlers exist
+			for ( k in element.$events[type] )
+				if (k) {
+					k = true;
+					break;
+				}
+			if (!k) element["on" + type] = null;
+		}
 	},
 
-	trigger: function(type,data,element) {
+	trigger: function(type, data, element) {
 		// Clone the incoming data, if any
 		data = jQuery.makeArray(data || []);
 
 		// Handle a global trigger
-		if ( !element ) {
-			var g = this.global[type];
-			if ( g )
-				jQuery.each( g, function(){
-					jQuery.event.trigger( type, data, this );
-				});
+		if ( !element )
+			jQuery.each( this.global[type] || [], function(){
+				jQuery.event.trigger( type, data, this );
+			});
 
 		// Handle triggering a single element
-		} else if ( element["on" + type] ) {
-			// Pass along a fake event
-			data.unshift( this.fix({ type: type, target: element }) );
+		else {
+			var handler = element["on" + type ], val,
+				fn = jQuery.isFunction( element[ type ] );
+
+			if ( handler ) {
+				// Pass along a fake event
+				data.unshift( this.fix({ type: type, target: element }) );
 	
-			// Trigger the event
-			var val = element["on" + type].apply( element, data );
+				// Trigger the event
+				if ( (val = handler.apply( element, data )) !== false )
+					this.triggered = true;
+			}
 
-			if ( val !== false && jQuery.isFunction( element[ type ] ) )
+			if ( fn && val !== false )
 				element[ type ]();
+
+			this.triggered = false;
 		}
 	},
 
 	handle: function(event) {
-		if ( typeof jQuery == "undefined" ) return false;
+		// Handle the second event of a trigger and when
+		// an event is called after a page has unloaded
+		if ( typeof jQuery == "undefined" || jQuery.event.triggered ) return;
 
 		// Empty object is for triggered events with no data
 		event = jQuery.event.fix( event || window.event || {} ); 
@@ -1230,7 +1286,7 @@
 		// returned undefined or false
 		var returnValue;
 
-		var c = this.events[event.type];
+		var c = this.$events[event.type];
 
 		var args = [].slice.call( arguments, 1 );
 		args.unshift( event );
@@ -1482,322 +1538,6 @@
 		}
 	});
 jQuery.fn.extend({
-
-	show: function(speed,callback){
-		var hidden = this.filter(":hidden");
-		return speed ?
-			hidden.animate({
-				height: "show", width: "show", opacity: "show"
-			}, speed, callback) :
-			
-			hidden.each(function(){
-				this.style.display = this.oldblock ? this.oldblock : "";
-				if ( jQuery.css(this,"display") == "none" )
-					this.style.display = "block";
-			});
-	},
-
-	hide: function(speed,callback){
-		var visible = this.filter(":visible");
-		return speed ?
-			visible.animate({
-				height: "hide", width: "hide", opacity: "hide"
-			}, speed, callback) :
-			
-			visible.each(function(){
-				this.oldblock = this.oldblock || jQuery.css(this,"display");
-				if ( this.oldblock == "none" )
-					this.oldblock = "block";
-				this.style.display = "none";
-			});
-	},
-
-	// Save the old toggle function
-	_toggle: jQuery.fn.toggle,
-	toggle: function( fn, fn2 ){
-		var args = arguments;
-		return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
-			this._toggle( fn, fn2 ) :
-			this.each(function(){
-				jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]
-					.apply( jQuery(this), args );
-			});
-	},
-	slideDown: function(speed,callback){
-		return this.animate({height: "show"}, speed, callback);
-	},
-	slideUp: function(speed,callback){
-		return this.animate({height: "hide"}, speed, callback);
-	},
-	slideToggle: function(speed, callback){
-		return this.each(function(){
-			var state = jQuery(this).is(":hidden") ? "show" : "hide";
-			jQuery(this).animate({height: state}, speed, callback);
-		});
-	},
-	fadeIn: function(speed, callback){
-		return this.animate({opacity: "show"}, speed, callback);
-	},
-	fadeOut: function(speed, callback){
-		return this.animate({opacity: "hide"}, speed, callback);
-	},
-	fadeTo: function(speed,to,callback){
-		return this.animate({opacity: to}, speed, callback);
-	},
-	animate: function( prop, speed, easing, callback ) {
-		return this.queue(function(){
-		
-			this.curAnim = jQuery.extend({}, prop);
-			var opt = jQuery.speed(speed, easing, callback);
-			
-			for ( var p in prop ) {
-				var e = new jQuery.fx( this, opt, p );
-				if ( prop[p].constructor == Number )
-					e.custom( e.cur(), prop[p] );
-				else
-					e[ prop[p] ]( prop );
-			}
-			
-		});
-	},
-	queue: function(type,fn){
-		if ( !fn ) {
-			fn = type;
-			type = "fx";
-		}
-	
-		return this.each(function(){
-			if ( !this.queue )
-				this.queue = {};
-	
-			if ( !this.queue[type] )
-				this.queue[type] = [];
-	
-			this.queue[type].push( fn );
-		
-			if ( this.queue[type].length == 1 )
-				fn.apply(this);
-		});
-	}
-
-});
-
-jQuery.extend({
-	
-	speed: function(speed, easing, fn) {
-		var opt = speed && speed.constructor == Object ? speed : {
-			complete: fn || !fn && easing || 
-				jQuery.isFunction( speed ) && speed,
-			duration: speed,
-			easing: fn && easing || easing && easing.constructor != Function && easing
-		};
-
-		opt.duration = (opt.duration && opt.duration.constructor == Number ? 
-			opt.duration : 
-			{ slow: 600, fast: 200 }[opt.duration]) || 400;
-	
-		// Queueing
-		opt.old = opt.complete;
-		opt.complete = function(){
-			jQuery.dequeue(this, "fx");
-			if ( jQuery.isFunction( opt.old ) )
-				opt.old.apply( this );
-		};
-	
-		return opt;
-	},
-	
-	easing: {},
-	
-	queue: {},
-	
-	dequeue: function(elem,type){
-		type = type || "fx";
-	
-		if ( elem.queue && elem.queue[type] ) {
-			// Remove self
-			elem.queue[type].shift();
-	
-			// Get next function
-			var f = elem.queue[type][0];
-		
-			if ( f ) f.apply( elem );
-		}
-	},
-
-	/*
-	 * I originally wrote fx() as a clone of moo.fx and in the process
-	 * of making it small in size the code became illegible to sane
-	 * people. You've been warned.
-	 */
-	
-	fx: function( elem, options, prop ){
-
-		var z = this;
-
-		// The styles
-		var y = elem.style;
-		
-		// Store display property
-		var oldDisplay = jQuery.css(elem, "display");
-
-		// Set display property to block for animation
-		y.display = "block";
-
-		// Make sure that nothing sneaks out
-		y.overflow = "hidden";
-
-		// Simple function for setting a style value
-		z.a = function(){
-			if ( options.step )
-				options.step.apply( elem, [ z.now ] );
-
-			if ( prop == "opacity" )
-				jQuery.attr(y, "opacity", z.now); // Let attr handle opacity
-			else if ( parseInt(z.now) ) // My hate for IE will never die
-				y[prop] = parseInt(z.now) + "px";
-		};
-
-		// Figure out the maximum number to run to
-		z.max = function(){
-			return parseFloat( jQuery.css(elem,prop) );
-		};
-
-		// Get the current size
-		z.cur = function(){
-			var r = parseFloat( jQuery.curCSS(elem, prop) );
-			return r && r > -10000 ? r : z.max();
-		};
-
-		// Start an animation from one number to another
-		z.custom = function(from,to){
-			z.startTime = (new Date()).getTime();
-			z.now = from;
-			z.a();
-
-			z.timer = setInterval(function(){
-				z.step(from, to);
-			}, 13);
-		};
-
-		// Simple 'show' function
-		z.show = function(){
-			if ( !elem.orig ) elem.orig = {};
-
-			// Remember where we started, so that we can go back to it later
-			elem.orig[prop] = this.cur();
-
-			options.show = true;
-
-			// Begin the animation
-			z.custom(0, elem.orig[prop]);
-
-			// Stupid IE, look what you made me do
-			if ( prop != "opacity" )
-				y[prop] = "1px";
-		};
-
-		// Simple 'hide' function
-		z.hide = function(){
-			if ( !elem.orig ) elem.orig = {};
-
-			// Remember where we started, so that we can go back to it later
-			elem.orig[prop] = this.cur();
-
-			options.hide = true;
-
-			// Begin the animation
-			z.custom(elem.orig[prop], 0);
-		};
-		
-		//Simple 'toggle' function
-		z.toggle = function() {
-			if ( !elem.orig ) elem.orig = {};
-
-			// Remember where we started, so that we can go back to it later
-			elem.orig[prop] = this.cur();
-
-			if(oldDisplay == "none")  {
-				options.show = true;
-				
-				// Stupid IE, look what you made me do
-				if ( prop != "opacity" )
-					y[prop] = "1px";
-
-				// Begin the animation
-				z.custom(0, elem.orig[prop]);	
-			} else {
-				options.hide = true;
-
-				// Begin the animation
-				z.custom(elem.orig[prop], 0);
-			}		
-		};
-
-		// Each step of an animation
-		z.step = function(firstNum, lastNum){
-			var t = (new Date()).getTime();
-
-			if (t > options.duration + z.startTime) {
-				// Stop the timer
-				clearInterval(z.timer);
-				z.timer = null;
-
-				z.now = lastNum;
-				z.a();
-
-				if (elem.curAnim) elem.curAnim[ prop ] = true;
-
-				var done = true;
-				for ( var i in elem.curAnim )
-					if ( elem.curAnim[i] !== true )
-						done = false;
-
-				if ( done ) {
-					// Reset the overflow
-					y.overflow = "";
-					
-					// Reset the display
-					y.display = oldDisplay;
-					if (jQuery.css(elem, "display") == "none")
-						y.display = "block";
-
-					// Hide the element if the "hide" operation was done
-					if ( options.hide ) 
-						y.display = "none";
-
-					// Reset the properties, if the item has been hidden or shown
-					if ( options.hide || options.show )
-						for ( var p in elem.curAnim )
-							if (p == "opacity")
-								jQuery.attr(y, p, elem.orig[p]);
-							else
-								y[p] = "";
-				}
-
-				// If a callback was provided, execute it
-				if ( done && jQuery.isFunction( options.complete ) )
-					// Execute the complete function
-					options.complete.apply( elem );
-			} else {
-				var n = t - this.startTime;
-				// Figure out where in the animation we are and set the number
-				var p = n / options.duration;
-				
-				// If the easing function exists, then use it 
-				z.now = options.easing && jQuery.easing[options.easing] ?
-					jQuery.easing[options.easing](p, n,  firstNum, (lastNum-firstNum), options.duration) :
-					// else use default linear easing
-					((-Math.cos(p*Math.PI)/2) + 0.5) * (lastNum-firstNum) + firstNum;
-
-				// Perform the next step of the animation
-				z.a();
-			}
-		};
-	
-	}
-});
-jQuery.fn.extend({
 	loadIfModified: function( url, params, callback ) {
 		this.load( url, params, callback, 1 );
 	},
@@ -1813,7 +1553,7 @@
 		// If the second parameter was provided
 		if ( params )
 			// If it's a function
-			if ( jQuery.isFunction( params.constructor ) ) {
+			if ( jQuery.isFunction( params ) ) {
 				// We assume that it's the callback
 				callback = params;
 				params = null;
@@ -1861,7 +1601,7 @@
 });
 
 // If IE is used, create a wrapper for the XMLHttpRequest object
-if ( jQuery.browser.msie && typeof XMLHttpRequest == "undefined" )
+if ( !window.XMLHttpRequest )
 	XMLHttpRequest = function(){
 		return new ActiveXObject("Microsoft.XMLHTTP");
 	};
@@ -1900,6 +1640,11 @@
 		return jQuery.get(url, data, callback, "json");
 	},
 	post: function( url, data, callback, type ) {
+		if ( jQuery.isFunction( data ) ) {
+			callback = data;
+			data = {};
+		}
+
 		return jQuery.ajax({
 			type: "POST",
 			url: url,
@@ -1940,9 +1685,12 @@
 			if (s.processData && typeof s.data != "string")
     			s.data = jQuery.param(s.data);
 			// append data to url for get requests
-			if( s.type.toLowerCase() == "get" )
+			if( s.type.toLowerCase() == "get" ) {
 				// "?" + data or "&" + data (in case there are already params)
 				s.url += ((s.url.indexOf("?") > -1) ? "&" : "?") + s.data;
+				// IE likes to send both get and post data, prevent this
+				s.data = null;
+			}
 		}
 
 		// Watch for a new set of requests
@@ -1985,6 +1733,13 @@
 			// The transfer is complete and the data is available, or the request timed out
 			if ( xml && (xml.readyState == 4 || isTimeout == "timeout") ) {
 				requestDone = true;
+				
+				// clear poll interval
+				if (ival) {
+					clearInterval(ival);
+					ival = null;
+				}
+				
 				var status;
 				try {
 					status = jQuery.httpSuccess( xml ) && isTimeout != "timeout" ?
@@ -2030,11 +1785,13 @@
 					s.complete(xml, status);
 
 				// Stop memory leaks
-				xml.onreadystatechange = function(){};
-				xml = null;
+				if(s.async)
+					xml = null;
 			}
 		};
-		xml.onreadystatechange = onreadystatechange;
+		
+		// don't attach the handler to the request, just poll it instead
+		var ival = setInterval(onreadystatechange, 13); 
 
 		// Timeout checker
 		if ( s.timeout > 0 )
@@ -2049,12 +1806,9 @@
 				}
 			}, s.timeout);
 			
-		// save non-leaking reference 
-		var xml2 = xml;
-
 		// Send the data
 		try {
-			xml2.send(s.data);
+			xml.send(s.data);
 		} catch(e) {
 			jQuery.handleError(s, xml, null, e);
 		}
@@ -2064,7 +1818,7 @@
 			onreadystatechange();
 		
 		// return XMLHttpRequest to allow aborting the request etc.
-		return xml2;
+		return xml;
 	},
 
 	handleError: function( s, xml, status, e ) {
@@ -2145,7 +1899,7 @@
 			// Serialize the key/values
 			for ( var j in a )
 				// If the value is an array then the key names need to be repeated
-				if ( a[j].constructor == Array )
+				if ( a[j] && a[j].constructor == Array )
 					jQuery.each( a[j], function(){
 						s.push( encodeURIComponent(j) + "=" + encodeURIComponent( this ) );
 					});
@@ -2169,4 +1923,321 @@
 	}
 
 });
+jQuery.fn.extend({
+
+	show: function(speed,callback){
+		var hidden = this.filter(":hidden");
+		speed ?
+			hidden.animate({
+				height: "show", width: "show", opacity: "show"
+			}, speed, callback) :
+			
+			hidden.each(function(){
+				this.style.display = this.oldblock ? this.oldblock : "";
+				if ( jQuery.css(this,"display") == "none" )
+					this.style.display = "block";
+			});
+		return this;
+	},
+
+	hide: function(speed,callback){
+		var visible = this.filter(":visible");
+		speed ?
+			visible.animate({
+				height: "hide", width: "hide", opacity: "hide"
+			}, speed, callback) :
+			
+			visible.each(function(){
+				this.oldblock = this.oldblock || jQuery.css(this,"display");
+				if ( this.oldblock == "none" )
+					this.oldblock = "block";
+				this.style.display = "none";
+			});
+		return this;
+	},
+
+	// Save the old toggle function
+	_toggle: jQuery.fn.toggle,
+	toggle: function( fn, fn2 ){
+		var args = arguments;
+		return jQuery.isFunction(fn) && jQuery.isFunction(fn2) ?
+			this._toggle( fn, fn2 ) :
+			this.each(function(){
+				jQuery(this)[ jQuery(this).is(":hidden") ? "show" : "hide" ]
+					.apply( jQuery(this), args );
+			});
+	},
+	slideDown: function(speed,callback){
+		return this.animate({height: "show"}, speed, callback);
+	},
+	slideUp: function(speed,callback){
+		return this.animate({height: "hide"}, speed, callback);
+	},
+	slideToggle: function(speed, callback){
+		return this.each(function(){
+			var state = jQuery(this).is(":hidden") ? "show" : "hide";
+			jQuery(this).animate({height: state}, speed, callback);
+		});
+	},
+	fadeIn: function(speed, callback){
+		return this.animate({opacity: "show"}, speed, callback);
+	},
+	fadeOut: function(speed, callback){
+		return this.animate({opacity: "hide"}, speed, callback);
+	},
+	fadeTo: function(speed,to,callback){
+		return this.animate({opacity: to}, speed, callback);
+	},
+	animate: function( prop, speed, easing, callback ) {
+		return this.queue(function(){
+		
+			this.curAnim = jQuery.extend({}, prop);
+			var opt = jQuery.speed(speed, easing, callback);
+			
+			for ( var p in prop ) {
+				var e = new jQuery.fx( this, opt, p );
+				if ( prop[p].constructor == Number )
+					e.custom( e.cur(), prop[p] );
+				else
+					e[ prop[p] ]( prop );
+			}
+			
+		});
+	},
+	queue: function(type,fn){
+		if ( !fn ) {
+			fn = type;
+			type = "fx";
+		}
+	
+		return this.each(function(){
+			if ( !this.queue )
+				this.queue = {};
+	
+			if ( !this.queue[type] )
+				this.queue[type] = [];
+	
+			this.queue[type].push( fn );
+		
+			if ( this.queue[type].length == 1 )
+				fn.apply(this);
+		});
+	}
+
+});
+
+jQuery.extend({
+	
+	speed: function(speed, easing, fn) {
+		var opt = speed && speed.constructor == Object ? speed : {
+			complete: fn || !fn && easing || 
+				jQuery.isFunction( speed ) && speed,
+			duration: speed,
+			easing: fn && easing || easing && easing.constructor != Function && easing
+		};
+
+		opt.duration = (opt.duration && opt.duration.constructor == Number ? 
+			opt.duration : 
+			{ slow: 600, fast: 200 }[opt.duration]) || 400;
+	
+		// Queueing
+		opt.old = opt.complete;
+		opt.complete = function(){
+			jQuery.dequeue(this, "fx");
+			if ( jQuery.isFunction( opt.old ) )
+				opt.old.apply( this );
+		};
+	
+		return opt;
+	},
+	
+	easing: {},
+	
+	queue: {},
+	
+	dequeue: function(elem,type){
+		type = type || "fx";
+	
+		if ( elem.queue && elem.queue[type] ) {
+			// Remove self
+			elem.queue[type].shift();
+	
+			// Get next function
+			var f = elem.queue[type][0];
+		
+			if ( f ) f.apply( elem );
+		}
+	},
+
+	/*
+	 * I originally wrote fx() as a clone of moo.fx and in the process
+	 * of making it small in size the code became illegible to sane
+	 * people. You've been warned.
+	 */
+	
+	fx: function( elem, options, prop ){
+
+		var z = this;
+
+		// The styles
+		var y = elem.style;
+		
+		// Store display property
+		var oldDisplay = jQuery.css(elem, "display");
+
+		// Make sure that nothing sneaks out
+		y.overflow = "hidden";
+
+		// Simple function for setting a style value
+		z.a = function(){
+			if ( options.step )
+				options.step.apply( elem, [ z.now ] );
+
+			if ( prop == "opacity" )
+				jQuery.attr(y, "opacity", z.now); // Let attr handle opacity
+			else if ( parseInt(z.now) ) // My hate for IE will never die
+				y[prop] = parseInt(z.now) + "px";
+			
+			y.display = "block"; // Set display property to block for animation
+		};
+
+		// Figure out the maximum number to run to
+		z.max = function(){
+			return parseFloat( jQuery.css(elem,prop) );
+		};
+
+		// Get the current size
+		z.cur = function(){
+			var r = parseFloat( jQuery.curCSS(elem, prop) );
+			return r && r > -10000 ? r : z.max();
+		};
+
+		// Start an animation from one number to another
+		z.custom = function(from,to){
+			z.startTime = (new Date()).getTime();
+			z.now = from;
+			z.a();
+
+			z.timer = setInterval(function(){
+				z.step(from, to);
+			}, 13);
+		};
+
+		// Simple 'show' function
+		z.show = function(){
+			if ( !elem.orig ) elem.orig = {};
+
+			// Remember where we started, so that we can go back to it later
+			elem.orig[prop] = this.cur();
+
+			options.show = true;
+
+			// Begin the animation
+			z.custom(0, elem.orig[prop]);
+
+			// Stupid IE, look what you made me do
+			if ( prop != "opacity" )
+				y[prop] = "1px";
+		};
+
+		// Simple 'hide' function
+		z.hide = function(){
+			if ( !elem.orig ) elem.orig = {};
+
+			// Remember where we started, so that we can go back to it later
+			elem.orig[prop] = this.cur();
+
+			options.hide = true;
+
+			// Begin the animation
+			z.custom(elem.orig[prop], 0);
+		};
+		
+		//Simple 'toggle' function
+		z.toggle = function() {
+			if ( !elem.orig ) elem.orig = {};
+
+			// Remember where we started, so that we can go back to it later
+			elem.orig[prop] = this.cur();
+
+			if(oldDisplay == "none")  {
+				options.show = true;
+				
+				// Stupid IE, look what you made me do
+				if ( prop != "opacity" )
+					y[prop] = "1px";
+
+				// Begin the animation
+				z.custom(0, elem.orig[prop]);	
+			} else {
+				options.hide = true;
+
+				// Begin the animation
+				z.custom(elem.orig[prop], 0);
+			}		
+		};
+
+		// Each step of an animation
+		z.step = function(firstNum, lastNum){
+			var t = (new Date()).getTime();
+
+			if (t > options.duration + z.startTime) {
+				// Stop the timer
+				clearInterval(z.timer);
+				z.timer = null;
+
+				z.now = lastNum;
+				z.a();
+
+				if (elem.curAnim) elem.curAnim[ prop ] = true;
+
+				var done = true;
+				for ( var i in elem.curAnim )
+					if ( elem.curAnim[i] !== true )
+						done = false;
+
+				if ( done ) {
+					// Reset the overflow
+					y.overflow = "";
+					
+					// Reset the display
+					y.display = oldDisplay;
+					if (jQuery.css(elem, "display") == "none")
+						y.display = "block";
+
+					// Hide the element if the "hide" operation was done
+					if ( options.hide ) 
+						y.display = "none";
+
+					// Reset the properties, if the item has been hidden or shown
+					if ( options.hide || options.show )
+						for ( var p in elem.curAnim )
+							if (p == "opacity")
+								jQuery.attr(y, p, elem.orig[p]);
+							else
+								y[p] = "";
+				}
+
+				// If a callback was provided, execute it
+				if ( done && jQuery.isFunction( options.complete ) )
+					// Execute the complete function
+					options.complete.apply( elem );
+			} else {
+				var n = t - this.startTime;
+				// Figure out where in the animation we are and set the number
+				var p = n / options.duration;
+				
+				// If the easing function exists, then use it 
+				z.now = options.easing && jQuery.easing[options.easing] ?
+					jQuery.easing[options.easing](p, n,  firstNum, (lastNum-firstNum), options.duration) :
+					// else use default linear easing
+					((-Math.cos(p*Math.PI)/2) + 0.5) * (lastNum-firstNum) + firstNum;
+
+				// Perform the next step of the animation
+				z.a();
+			}
+		};
+	
+	}
+});
 }



More information about the Mapbender_commits mailing list