web/wp-includes/js/wp-lists.dev.js
changeset 194 32102edaa81b
parent 136 bde1974c263b
equal deleted inserted replaced
193:2f6f6f7551ca 194:32102edaa81b
    16 		dimBefore: null, dimAfter: null
    16 		dimBefore: null, dimAfter: null
    17 	},
    17 	},
    18 
    18 
    19 	nonce: function(e,s) {
    19 	nonce: function(e,s) {
    20 		var url = wpAjax.unserialize(e.attr('href'));
    20 		var url = wpAjax.unserialize(e.attr('href'));
    21 		return s.nonce || url._ajax_nonce || $('#' + s.element + ' input[name=_ajax_nonce]').val() || url._wpnonce || $('#' + s.element + ' input[name=_wpnonce]').val() || 0;
    21 		return s.nonce || url._ajax_nonce || $('#' + s.element + ' input[name="_ajax_nonce"]').val() || url._wpnonce || $('#' + s.element + ' input[name="_wpnonce"]').val() || 0;
    22 	},
    22 	},
    23 
    23 
    24 	parseClass: function(e,t) {
    24 	parseClass: function(e,t) {
    25 		var c = [], cl;
    25 		var c = [], cl;
       
    26 
    26 		try {
    27 		try {
    27 			cl = $(e).attr('class') || '';
    28 			cl = $(e).attr('class') || '';
    28 			cl = cl.match(new RegExp(t+':[\\S]+'));
    29 			cl = cl.match(new RegExp(t+':[\\S]+'));
    29 			if ( cl ) { c = cl[0].split(':'); }
    30 
       
    31 			if ( cl )
       
    32 				c = cl[0].split(':');
    30 		} catch(r) {}
    33 		} catch(r) {}
       
    34 
    31 		return c;
    35 		return c;
    32 	},
    36 	},
    33 
    37 
    34 	pre: function(e,s,a) {
    38 	pre: function(e,s,a) {
    35 		var bg, r;
    39 		var bg, r;
       
    40 
    36 		s = $.extend( {}, this.wpList.settings, {
    41 		s = $.extend( {}, this.wpList.settings, {
    37 			element: null,
    42 			element: null,
    38 			nonce: 0,
    43 			nonce: 0,
    39 			target: e.get(0)
    44 			target: e.get(0)
    40 		}, s || {} );
    45 		}, s || {} );
       
    46 
    41 		if ( $.isFunction( s.confirm ) ) {
    47 		if ( $.isFunction( s.confirm ) ) {
    42 			if ( 'add' != a ) {
    48 			if ( 'add' != a ) {
    43 				bg = $('#' + s.element).css('backgroundColor');
    49 				bg = $('#' + s.element).css('backgroundColor');
    44 				$('#' + s.element).css('backgroundColor', '#FF9966');
    50 				$('#' + s.element).css('backgroundColor', '#FF9966');
    45 			}
    51 			}
    46 			r = s.confirm.call(this,e,s,a,bg);
    52 			r = s.confirm.call(this, e, s, a, bg);
    47 			if ( 'add' != a ) { $('#' + s.element).css('backgroundColor', bg ); }
    53 
    48 			if ( !r ) { return false; }
    54 			if ( 'add' != a )
    49 		}
    55 				$('#' + s.element).css('backgroundColor', bg );
       
    56 
       
    57 			if ( !r )
       
    58 				return false;
       
    59 		}
       
    60 
    50 		return s;
    61 		return s;
    51 	},
    62 	},
    52 
    63 
    53 	ajaxAdd: function( e, s ) {
    64 	ajaxAdd: function( e, s ) {
    54 		e = $(e);
    65 		e = $(e);
    55 		s = s || {};
    66 		s = s || {};
    56 		var list = this, cls = wpList.parseClass(e,'add'), es, valid, formData;
    67 		var list = this, cls = wpList.parseClass(e,'add'), es, valid, formData, res, rres;
       
    68 
    57 		s = wpList.pre.call( list, e, s, 'add' );
    69 		s = wpList.pre.call( list, e, s, 'add' );
    58 
    70 
    59 		s.element = cls[2] || e.attr( 'id' ) || s.element || null;
    71 		s.element = cls[2] || e.attr( 'id' ) || s.element || null;
    60 		if ( cls[3] ) { s.addColor = '#' + cls[3]; }
    72 
    61 		else { s.addColor = s.addColor || '#FFFF33'; }
    73 		if ( cls[3] )
    62 
    74 			s.addColor = '#' + cls[3];
    63 		if ( !s ) { return false; }
    75 		else
    64 
    76 			s.addColor = s.addColor || '#FFFF33';
    65 		if ( !e.is("[class^=add:" + list.id + ":]") ) { return !wpList.add.call( list, e, s ); }
    77 
    66 
    78 		if ( !s )
    67 		if ( !s.element ) { return true; }
    79 			return false;
       
    80 
       
    81 		if ( !e.is('[id="' + s.what + '-add-submit"]') )
       
    82 			return !wpList.add.call( list, e, s );
       
    83 
       
    84 		if ( !s.element )
       
    85 			return true;
    68 
    86 
    69 		s.action = 'add-' + s.what;
    87 		s.action = 'add-' + s.what;
    70 
    88 
    71 		s.nonce = wpList.nonce(e,s);
    89 		s.nonce = wpList.nonce(e,s);
    72 
    90 
    73 		es = $('#' + s.element + ' :input').not('[name=_ajax_nonce], [name=_wpnonce], [name=action]');
    91 		es = $('#' + s.element + ' :input').not('[name="_ajax_nonce"], [name="_wpnonce"], [name="action"]');
    74 		valid = wpAjax.validateForm( '#' + s.element );
    92 		valid = wpAjax.validateForm( '#' + s.element );
    75 		if ( !valid ) { return false; }
    93 
       
    94 		if ( !valid )
       
    95 			return false;
    76 
    96 
    77 		s.data = $.param( $.extend( { _ajax_nonce: s.nonce, action: s.action }, wpAjax.unserialize( cls[4] || '' ) ) );
    97 		s.data = $.param( $.extend( { _ajax_nonce: s.nonce, action: s.action }, wpAjax.unserialize( cls[4] || '' ) ) );
    78 		formData = $.isFunction(es.fieldSerialize) ? es.fieldSerialize() : es.serialize();
    98 		formData = $.isFunction(es.fieldSerialize) ? es.fieldSerialize() : es.serialize();
    79 		if ( formData ) { s.data += '&' + formData; }
    99 
       
   100 		if ( formData )
       
   101 			s.data += '&' + formData;
    80 
   102 
    81 		if ( $.isFunction(s.addBefore) ) {
   103 		if ( $.isFunction(s.addBefore) ) {
    82 			s = s.addBefore( s );
   104 			s = s.addBefore( s );
    83 			if ( !s ) { return true; }
   105 			if ( !s )
    84 		}
   106 				return true;
    85 		if ( !s.data.match(/_ajax_nonce=[a-f0-9]+/) ) { return true; }
   107 		}
       
   108 
       
   109 		if ( !s.data.match(/_ajax_nonce=[a-f0-9]+/) )
       
   110 			return true;
    86 
   111 
    87 		s.success = function(r) {
   112 		s.success = function(r) {
    88 			var res = wpAjax.parseAjaxResponse(r, s.response, s.element), o;
   113 			res = wpAjax.parseAjaxResponse(r, s.response, s.element);
    89 			if ( !res || res.errors ) { return false; }
   114 
    90 
   115 			rres = r;
    91 			if ( true === res ) { return true; }
   116 
       
   117 			if ( !res || res.errors )
       
   118 				return false;
       
   119 
       
   120 			if ( true === res )
       
   121 				return true;
    92 
   122 
    93 			jQuery.each( res.responses, function() {
   123 			jQuery.each( res.responses, function() {
    94 				wpList.add.call( list, this.data, $.extend( {}, s, { // this.firstChild.nodevalue
   124 				wpList.add.call( list, this.data, $.extend( {}, s, { // this.firstChild.nodevalue
    95 					pos: this.position || 0,
   125 					pos: this.position || 0,
    96 					id: this.id || 0,
   126 					id: this.id || 0,
    97 					oldId: this.oldId || null
   127 					oldId: this.oldId || null
    98 				} ) );
   128 				} ) );
    99 			} );
   129 			} );
   100 
   130 
   101 			if ( $.isFunction(s.addAfter) ) {
       
   102 				o = this.complete;
       
   103 				this.complete = function(x,st) {
       
   104 					var _s = $.extend( { xml: x, status: st, parsed: res }, s );
       
   105 					s.addAfter( r, _s );
       
   106 					if ( $.isFunction(o) ) { o(x,st); }
       
   107 				};
       
   108 			}
       
   109 			list.wpList.recolor();
   131 			list.wpList.recolor();
   110 			$(list).trigger( 'wpListAddEnd', [ s, list.wpList ] );
   132 			$(list).trigger( 'wpListAddEnd', [ s, list.wpList ] );
   111 			wpList.clear.call(list,'#' + s.element);
   133 			wpList.clear.call(list,'#' + s.element);
   112 		};
   134 		};
   113 
   135 
       
   136 		s.complete = function(x, st) {
       
   137 			if ( $.isFunction(s.addAfter) ) {
       
   138 				var _s = $.extend( { xml: x, status: st, parsed: res }, s );
       
   139 				s.addAfter( rres, _s );
       
   140 			}
       
   141 		};
       
   142 
   114 		$.ajax( s );
   143 		$.ajax( s );
   115 		return false;
   144 		return false;
   116 	},
   145 	},
   117 
   146 
   118 	ajaxDel: function( e, s ) {
   147 	ajaxDel: function( e, s ) {
   119 		e = $(e); s = s || {};
   148 		e = $(e);
   120 		var list = this, cls = wpList.parseClass(e,'delete'), element;
   149 		s = s || {};
       
   150 		var list = this, cls = wpList.parseClass(e,'delete'), element, res, rres;
       
   151 
   121 		s = wpList.pre.call( list, e, s, 'delete' );
   152 		s = wpList.pre.call( list, e, s, 'delete' );
   122 
   153 
   123 		s.element = cls[2] || s.element || null;
   154 		s.element = cls[2] || s.element || null;
   124 		if ( cls[3] ) { s.delColor = '#' + cls[3]; }
   155 
   125 		else { s.delColor = s.delColor || '#faa'; }
   156 		if ( cls[3] )
   126 
   157 			s.delColor = '#' + cls[3];
   127 		if ( !s || !s.element ) { return false; }
   158 		else
       
   159 			s.delColor = s.delColor || '#faa';
       
   160 
       
   161 		if ( !s || !s.element )
       
   162 			return false;
   128 
   163 
   129 		s.action = 'delete-' + s.what;
   164 		s.action = 'delete-' + s.what;
   130 
   165 
   131 		s.nonce = wpList.nonce(e,s);
   166 		s.nonce = wpList.nonce(e,s);
   132 
   167 
   135 			wpAjax.unserialize( cls[4] || '' )
   170 			wpAjax.unserialize( cls[4] || '' )
   136 		);
   171 		);
   137 
   172 
   138 		if ( $.isFunction(s.delBefore) ) {
   173 		if ( $.isFunction(s.delBefore) ) {
   139 			s = s.delBefore( s, list );
   174 			s = s.delBefore( s, list );
   140 			if ( !s ) { return true; }
   175 			if ( !s )
   141 		}
   176 				return true;
   142 		if ( !s.data._ajax_nonce ) { return true; }
   177 		}
       
   178 
       
   179 		if ( !s.data._ajax_nonce )
       
   180 			return true;
   143 
   181 
   144 		element = $('#' + s.element);
   182 		element = $('#' + s.element);
   145 
   183 
   146 		if ( 'none' != s.delColor ) {
   184 		if ( 'none' != s.delColor ) {
   147 			element.css( 'backgroundColor', s.delColor ).fadeOut( 350, function(){
   185 			element.css( 'backgroundColor', s.delColor ).fadeOut( 350, function(){
   152 			list.wpList.recolor();
   190 			list.wpList.recolor();
   153 			$(list).trigger( 'wpListDelEnd', [ s, list.wpList ] );
   191 			$(list).trigger( 'wpListDelEnd', [ s, list.wpList ] );
   154 		}
   192 		}
   155 
   193 
   156 		s.success = function(r) {
   194 		s.success = function(r) {
   157 			var res = wpAjax.parseAjaxResponse(r, s.response, s.element), o;
   195 			res = wpAjax.parseAjaxResponse(r, s.response, s.element);
       
   196 			rres = r;
       
   197 
   158 			if ( !res || res.errors ) {
   198 			if ( !res || res.errors ) {
   159 				element.stop().stop().css( 'backgroundColor', '#faa' ).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
   199 				element.stop().stop().css( 'backgroundColor', '#faa' ).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
   160 				return false;
   200 				return false;
   161 			}
   201 			}
       
   202 		};
       
   203 
       
   204 		s.complete = function(x, st) {
   162 			if ( $.isFunction(s.delAfter) ) {
   205 			if ( $.isFunction(s.delAfter) ) {
   163 				o = this.complete;
   206 				element.queue( function() {
   164 				this.complete = function(x,st) {
   207 					var _s = $.extend( { xml: x, status: st, parsed: res }, s );
   165 					element.queue( function() {
   208 					s.delAfter( rres, _s );
   166 						var _s = $.extend( { xml: x, status: st, parsed: res }, s );
   209 				}).dequeue();
   167 						s.delAfter( r, _s );
   210 			}
   168 						if ( $.isFunction(o) ) { o(x,st); }
   211 		}
   169 					} ).dequeue();
   212 
   170 				};
       
   171 			}
       
   172 		};
       
   173 		$.ajax( s );
   213 		$.ajax( s );
   174 		return false;
   214 		return false;
   175 	},
   215 	},
   176 
   216 
   177 	ajaxDim: function( e, s ) {
   217 	ajaxDim: function( e, s ) {
   178 		if ( $(e).parent().css('display') == 'none' ) // Prevent hidden links from being clicked by hotkeys
   218 		if ( $(e).parent().css('display') == 'none' ) // Prevent hidden links from being clicked by hotkeys
   179 			return false;
   219 			return false;
   180 		e = $(e); s = s || {};
   220 
   181 		var list = this, cls = wpList.parseClass(e,'dim'), element, isClass, color, dimColor;
   221 		e = $(e);
       
   222 		s = s || {};
       
   223 
       
   224 		var list = this, cls = wpList.parseClass(e,'dim'), element, isClass, color, dimColor, res, rres;
       
   225 
   182 		s = wpList.pre.call( list, e, s, 'dim' );
   226 		s = wpList.pre.call( list, e, s, 'dim' );
   183 
   227 
   184 		s.element = cls[2] || s.element || null;
   228 		s.element = cls[2] || s.element || null;
   185 		s.dimClass =  cls[3] || s.dimClass || null;
   229 		s.dimClass =  cls[3] || s.dimClass || null;
   186 		if ( cls[4] ) { s.dimAddColor = '#' + cls[4]; }
   230 
   187 		else { s.dimAddColor = s.dimAddColor || '#FFFF33'; }
   231 		if ( cls[4] )
   188 		if ( cls[5] ) { s.dimDelColor = '#' + cls[5]; }
   232 			s.dimAddColor = '#' + cls[4];
   189 		else { s.dimDelColor = s.dimDelColor || '#FF3333'; }
   233 		else
   190 
   234 			s.dimAddColor = s.dimAddColor || '#FFFF33';
   191 		if ( !s || !s.element || !s.dimClass ) { return true; }
   235 
       
   236 		if ( cls[5] )
       
   237 			s.dimDelColor = '#' + cls[5];
       
   238 		else
       
   239 			s.dimDelColor = s.dimDelColor || '#FF3333';
       
   240 
       
   241 		if ( !s || !s.element || !s.dimClass )
       
   242 			return true;
   192 
   243 
   193 		s.action = 'dim-' + s.what;
   244 		s.action = 'dim-' + s.what;
   194 
   245 
   195 		s.nonce = wpList.nonce(e,s);
   246 		s.nonce = wpList.nonce(e,s);
   196 
   247 
   199 			wpAjax.unserialize( cls[6] || '' )
   250 			wpAjax.unserialize( cls[6] || '' )
   200 		);
   251 		);
   201 
   252 
   202 		if ( $.isFunction(s.dimBefore) ) {
   253 		if ( $.isFunction(s.dimBefore) ) {
   203 			s = s.dimBefore( s );
   254 			s = s.dimBefore( s );
   204 			if ( !s ) { return true; }
   255 			if ( !s )
       
   256 				return true;
   205 		}
   257 		}
   206 
   258 
   207 		element = $('#' + s.element);
   259 		element = $('#' + s.element);
   208 		isClass = element.toggleClass(s.dimClass).is('.' + s.dimClass);
   260 		isClass = element.toggleClass(s.dimClass).is('.' + s.dimClass);
   209 		color = wpList.getColor( element );
   261 		color = wpList.getColor( element );
   210 		element.toggleClass( s.dimClass )
   262 		element.toggleClass( s.dimClass );
   211 		dimColor = isClass ? s.dimAddColor : s.dimDelColor;
   263 		dimColor = isClass ? s.dimAddColor : s.dimDelColor;
       
   264 
   212 		if ( 'none' != dimColor ) {
   265 		if ( 'none' != dimColor ) {
   213 			element
   266 			element
   214 				.animate( { backgroundColor: dimColor }, 'fast' )
   267 				.animate( { backgroundColor: dimColor }, 'fast' )
   215 				.queue( function() { element.toggleClass(s.dimClass); $(this).dequeue(); } )
   268 				.queue( function() { element.toggleClass(s.dimClass); $(this).dequeue(); } )
   216 				.animate( { backgroundColor: color }, { complete: function() { $(this).css( 'backgroundColor', '' ); $(list).trigger( 'wpListDimEnd', [ s, list.wpList ] ); } } );
   269 				.animate( { backgroundColor: color }, { complete: function() {
       
   270 						$(this).css( 'backgroundColor', '' );
       
   271 						$(list).trigger( 'wpListDimEnd', [ s, list.wpList ] );
       
   272 					}
       
   273 				});
   217 		} else {
   274 		} else {
   218 			$(list).trigger( 'wpListDimEnd', [ s, list.wpList ] );
   275 			$(list).trigger( 'wpListDimEnd', [ s, list.wpList ] );
   219 		}
   276 		}
   220 
   277 
   221 		if ( !s.data._ajax_nonce ) { return true; }
   278 		if ( !s.data._ajax_nonce )
       
   279 			return true;
   222 
   280 
   223 		s.success = function(r) {
   281 		s.success = function(r) {
   224 			var res = wpAjax.parseAjaxResponse(r, s.response, s.element), o;
   282 			res = wpAjax.parseAjaxResponse(r, s.response, s.element);
       
   283 			rres = r;
       
   284 
   225 			if ( !res || res.errors ) {
   285 			if ( !res || res.errors ) {
   226 				element.stop().stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
   286 				element.stop().stop().css( 'backgroundColor', '#FF3333' )[isClass?'removeClass':'addClass'](s.dimClass).show().queue( function() { list.wpList.recolor(); $(this).dequeue(); } );
   227 				return false;
   287 				return false;
   228 			}
   288 			}
       
   289 		};
       
   290 
       
   291 		s.complete = function(x, st) {
   229 			if ( $.isFunction(s.dimAfter) ) {
   292 			if ( $.isFunction(s.dimAfter) ) {
   230 				o = this.complete;
   293 				element.queue( function() {
   231 				this.complete = function(x,st) {
   294 					var _s = $.extend( { xml: x, status: st, parsed: res }, s );
   232 					element.queue( function() {
   295 					s.dimAfter( rres, _s );
   233 						var _s = $.extend( { xml: x, status: st, parsed: res }, s );
   296 				}).dequeue();
   234 						s.dimAfter( r, _s );
       
   235 						if ( $.isFunction(o) ) { o(x,st); }
       
   236 					} ).dequeue();
       
   237 				};
       
   238 			}
   297 			}
   239 		};
   298 		};
   240 
   299 
   241 		$.ajax( s );
   300 		$.ajax( s );
   242 		return false;
   301 		return false;
   243 	},
   302 	},
   244 
   303 
   245 	// From jquery.color.js: jQuery Color Animation by John Resig
       
   246 	getColor: function( el ) {
   304 	getColor: function( el ) {
   247 		if ( el.constructor == Object )
   305 		var color = jQuery(el).css('backgroundColor');
   248 			el = el.get(0);
   306 
   249 		var elem = el, color, rgbaTrans = new RegExp( "rgba\\(\\s*0,\\s*0,\\s*0,\\s*0\\s*\\)", "i" );
       
   250 		do {
       
   251 			color = jQuery.curCSS(elem, 'backgroundColor');
       
   252 			if ( color != '' && color != 'transparent' && !color.match(rgbaTrans) || jQuery.nodeName(elem, "body") )
       
   253 				break;
       
   254 		} while ( elem = elem.parentNode );
       
   255 		return color || '#ffffff';
   307 		return color || '#ffffff';
   256 	},
   308 	},
   257 
   309 
   258 	add: function( e, s ) {
   310 	add: function( e, s ) {
   259 		e = $(e);
   311 		e = $(e);
   260 
   312 
   261 		var list = $(this), old = false, _s = { pos: 0, id: 0, oldId: null }, ba, ref, color;
   313 		var list = $(this), old = false, _s = { pos: 0, id: 0, oldId: null }, ba, ref, color;
   262 		if ( 'string' == typeof s ) { s = { what: s }; }
   314 
       
   315 		if ( 'string' == typeof s )
       
   316 			s = { what: s };
       
   317 
   263 		s = $.extend(_s, this.wpList.settings, s);
   318 		s = $.extend(_s, this.wpList.settings, s);
   264 		if ( !e.size() || !s.what ) { return false; }
   319 
   265 		if ( s.oldId ) { old = $('#' + s.what + '-' + s.oldId); }
   320 		if ( !e.size() || !s.what )
   266 		if ( s.id && ( s.id != s.oldId || !old || !old.size() ) ) { $('#' + s.what + '-' + s.id).remove(); }
   321 			return false;
       
   322 
       
   323 		if ( s.oldId )
       
   324 			old = $('#' + s.what + '-' + s.oldId);
       
   325 
       
   326 		if ( s.id && ( s.id != s.oldId || !old || !old.size() ) )
       
   327 			$('#' + s.what + '-' + s.id).remove();
   267 
   328 
   268 		if ( old && old.size() ) {
   329 		if ( old && old.size() ) {
   269 			old.before(e);
   330 			old.before(e);
   270 			old.remove();
   331 			old.remove();
   271 		} else if ( isNaN(s.pos) ) {
   332 		} else if ( isNaN(s.pos) ) {
   272 			ba = 'after';
   333 			ba = 'after';
       
   334 
   273 			if ( '-' == s.pos.substr(0,1) ) {
   335 			if ( '-' == s.pos.substr(0,1) ) {
   274 				s.pos = s.pos.substr(1);
   336 				s.pos = s.pos.substr(1);
   275 				ba = 'before';
   337 				ba = 'before';
   276 			}
   338 			}
       
   339 
   277 			ref = list.find( '#' + s.pos );
   340 			ref = list.find( '#' + s.pos );
   278 			if ( 1 === ref.size() ) { ref[ba](e); }
   341 
   279 			else { list.append(e); }
   342 			if ( 1 === ref.size() )
   280 		} else if ( s.pos < 0 ) {
   343 				ref[ba](e);
   281 			list.prepend(e);
   344 			else
   282 		} else {
   345 				list.append(e);
   283 			list.append(e);
   346 
       
   347 		} else if ( 'comment' != s.what || 0 === $('#' + s.element).length ) {
       
   348 			if ( s.pos < 0 ) {
       
   349 				list.prepend(e);
       
   350 			} else {
       
   351 				list.append(e);
       
   352 			}
   284 		}
   353 		}
   285 
   354 
   286 		if ( s.alt ) {
   355 		if ( s.alt ) {
   287 			if ( ( list.children(':visible').index( e[0] ) + s.altOffset ) % 2 ) { e.removeClass( s.alt ); }
   356 			if ( ( list.children(':visible').index( e[0] ) + s.altOffset ) % 2 ) { e.removeClass( s.alt ); }
   288 			else { e.addClass( s.alt ); }
   357 			else { e.addClass( s.alt ); }
   296 		return e;
   365 		return e;
   297 	},
   366 	},
   298 
   367 
   299 	clear: function(e) {
   368 	clear: function(e) {
   300 		var list = this, t, tag;
   369 		var list = this, t, tag;
       
   370 
   301 		e = $(e);
   371 		e = $(e);
   302 		if ( list.wpList && e.parents( '#' + list.id ).size() ) { return; }
   372 
       
   373 		if ( list.wpList && e.parents( '#' + list.id ).size() )
       
   374 			return;
       
   375 
   303 		e.find(':input').each( function() {
   376 		e.find(':input').each( function() {
   304 			if ( $(this).parents('.form-no-clear').size() )
   377 			if ( $(this).parents('.form-no-clear').size() )
   305 				return;
   378 				return;
       
   379 
   306 			t = this.type.toLowerCase();
   380 			t = this.type.toLowerCase();
   307 			tag = this.tagName.toLowerCase();
   381 			tag = this.tagName.toLowerCase();
   308 			if ( 'text' == t || 'password' == t || 'textarea' == tag ) { this.value = ''; }
   382 
   309 			else if ( 'checkbox' == t || 'radio' == t ) { this.checked = false; }
   383 			if ( 'text' == t || 'password' == t || 'textarea' == tag )
   310 			else if ( 'select' == tag ) { this.selectedIndex = null; }
   384 				this.value = '';
       
   385 			else if ( 'checkbox' == t || 'radio' == t )
       
   386 				this.checked = false;
       
   387 			else if ( 'select' == tag )
       
   388 				this.selectedIndex = null;
   311 		});
   389 		});
   312 	},
   390 	},
   313 
   391 
   314 	process: function(el) {
   392 	process: function(el) {
   315 		var list = this;
   393 		var list = this,
   316 		$("[class^=add:" + list.id + ":]", el || null)
   394 			$el = $(el || document);
   317 			.filter('form').submit( function() { return list.wpList.add(this); } ).end()
   395 
   318 			.not('form').click( function() { return list.wpList.add(this); } );
   396 		$el.delegate( 'form[class^="add:' + list.id + ':"]', 'submit', function(){
   319 		$("[class^=delete:" + list.id + ":]", el || null).click( function() { return list.wpList.del(this); } );
   397 			return list.wpList.add(this);
   320 		$("[class^=dim:" + list.id + ":]", el || null).click( function() { return list.wpList.dim(this); } );
   398 		});
       
   399 
       
   400 		$el.delegate( 'a[class^="add:' + list.id + ':"], input[class^="add:' + list.id + ':"]', 'click', function(){
       
   401 			return list.wpList.add(this);
       
   402 		});
       
   403 
       
   404 		$el.delegate( '[class^="delete:' + list.id + ':"]', 'click', function(){
       
   405 			return list.wpList.del(this);
       
   406 		});
       
   407 
       
   408 		$el.delegate( '[class^="dim:' + list.id + ':"]', 'click', function(){
       
   409 			return list.wpList.dim(this);
       
   410 		});
   321 	},
   411 	},
   322 
   412 
   323 	recolor: function() {
   413 	recolor: function() {
   324 		var list = this, items, eo;
   414 		var list = this, items, eo;
   325 		if ( !list.wpList.settings.alt ) { return; }
   415 
       
   416 		if ( !list.wpList.settings.alt )
       
   417 			return;
       
   418 
   326 		items = $('.list-item:visible', list);
   419 		items = $('.list-item:visible', list);
   327 		if ( !items.size() ) { items = $(list).children(':visible'); }
   420 
       
   421 		if ( !items.size() )
       
   422 			items = $(list).children(':visible');
       
   423 
   328 		eo = [':even',':odd'];
   424 		eo = [':even',':odd'];
   329 		if ( list.wpList.settings.altOffset % 2 ) { eo.reverse(); }
   425 
       
   426 		if ( list.wpList.settings.altOffset % 2 )
       
   427 			eo.reverse();
       
   428 
   330 		items.filter(eo[0]).addClass(list.wpList.settings.alt).end().filter(eo[1]).removeClass(list.wpList.settings.alt);
   429 		items.filter(eo[0]).addClass(list.wpList.settings.alt).end().filter(eo[1]).removeClass(list.wpList.settings.alt);
   331 	},
   430 	},
   332 
   431 
   333 	init: function() {
   432 	init: function() {
   334 		var lists = this;
   433 		var lists = this;
       
   434 
   335 		lists.wpList.process = function(a) {
   435 		lists.wpList.process = function(a) {
   336 			lists.each( function() {
   436 			lists.each( function() {
   337 				this.wpList.process(a);
   437 				this.wpList.process(a);
   338 			} );
   438 			} );
   339 		};
   439 		};
       
   440 
   340 		lists.wpList.recolor = function() {
   441 		lists.wpList.recolor = function() {
   341 			lists.each( function() {
   442 			lists.each( function() {
   342 				this.wpList.recolor();
   443 				this.wpList.recolor();
   343 			} );
   444 			} );
   344 		};
   445 		};
   346 };
   447 };
   347 
   448 
   348 $.fn.wpList = function( settings ) {
   449 $.fn.wpList = function( settings ) {
   349 	this.each( function() {
   450 	this.each( function() {
   350 		var _this = this;
   451 		var _this = this;
       
   452 
   351 		this.wpList = { settings: $.extend( {}, wpList.settings, { what: wpList.parseClass(this,'list')[1] || '' }, settings ) };
   453 		this.wpList = { settings: $.extend( {}, wpList.settings, { what: wpList.parseClass(this,'list')[1] || '' }, settings ) };
   352 		$.each( fs, function(i,f) { _this.wpList[i] = function( e, s ) { return wpList[f].call( _this, e, s ); }; } );
   454 		$.each( fs, function(i,f) { _this.wpList[i] = function( e, s ) { return wpList[f].call( _this, e, s ); }; } );
   353 	} );
   455 	} );
       
   456 
   354 	wpList.init.call(this);
   457 	wpList.init.call(this);
       
   458 
   355 	this.wpList.process();
   459 	this.wpList.process();
       
   460 
   356 	return this;
   461 	return this;
   357 };
   462 };
   358 
   463 
   359 })(jQuery);
   464 })(jQuery);