2009-01-02 10:08:58 -05:00
|
|
|
(function(c){var b=false,a={add:"ajaxAdd",del:"ajaxDel",dim:"ajaxDim",process:"process",recolor:"recolor"},d;d={settings:{url:wpListL10n.url,type:"POST",response:"ajax-response",what:"",alt:"alternate",altOffset:0,addColor:null,delColor:null,dimAddColor:null,dimDelColor:null,confirm:null,addBefore:null,addAfter:null,delBefore:null,delAfter:null,dimBefore:null,dimAfter:null},nonce:function(h,g){var f=wpAjax.unserialize(h.attr("href"));return g.nonce||f._ajax_nonce||c("#"+g.element+" input[name=_ajax_nonce]").val()||f._wpnonce||c("#"+g.element+" input[name=_wpnonce]").val()||0},parseClass:function(i,g){var j=[],f;try{f=c(i).attr("class")||"";f=f.match(new RegExp(g+":[\\S]+"));if(f){j=f[0].split(":")}}catch(h){}return j},pre:function(j,h,f){var g,i;h=c.extend({},this.wpList.settings,{element:null,nonce:0,target:j.get(0)},h||{});if(c.isFunction(h.confirm)){if("add"!=f){g=c("#"+h.element).css("backgroundColor");c("#"+h.element).css("backgroundColor","#FF9966")}i=h.confirm.call(this,j,h,f,g);if("add"!=f){c("#"+h.element).css("backgroundColor",g)}if(!i){return false}}return h},ajaxAdd:function(k,g){k=c(k);g=g||{};var i=this,f=d.parseClass(k,"add"),l,h,j;g=d.pre.call(i,k,g,"add");g.element=f[2]||k.attr("id")||g.element||null;if(f[3]){g.addColor="#"+f[3]}else{g.addColor=g.addColor||"#FFFF33"}if(!g){return false}if(!k.is("[class^=add:"+i.id+":]")){return !d.add.call(i,k,g)}if(!g.element){return true}g.action="add-"+g.what;g.nonce=d.nonce(k,g);l=c("#"+g.element+" :input").not("[name=_ajax_nonce], [name=_wpnonce], [name=action]");h=wpAjax.validateForm("#"+g.element);if(!h){return false}g.data=c.param(c.extend({_ajax_nonce:g.nonce,action:g.action},wpAjax.unserialize(f[4]||"")));j=c.isFunction(l.fieldSerialize)?l.fieldSerialize():l.serialize();if(j){g.data+="&"+j}if(c.isFunction(g.addBefore)){g=g.addBefore(g);if(!g){return true}}if(!g.data.match(/_ajax_nonce=[a-f0-9]+/)){return true}g.success=function(m){var e=wpAjax.parseAjaxResponse(m,g.response,g.element),n;if(!e||e.errors){return false}if(true===e){return true}jQuery.each(e.responses,function(){d.add.call(i,this.data,c.extend({},g,{pos:this.position||0,id:this.id||0,oldId:this.oldId||null}))});if(c.isFunction(g.addAfter)){n=this.complete;this.complete=function(o,p){var q=c.extend({xml:o,status:p,parsed:e},g);g.addAfter(m,q);if(c.isFunction(n)){n(o,p)}}}i.wpList.recolor();d.clear.call(i,"#"+g.element)};c.ajax(g);return false},ajaxDel:function(k,h){k=c(k);h=h||{};var j=this,f=d.parseClass(k,"delete"),g,i;h=d.pre.call(j,k,h,"delete");h.element=f[2]||h.element||null;if(f[3]){h.delColor="#"+f[3]}else{h.delColor=h.delColor||"#FF3333"}if(!h||!h.element){return false}h.action="delete-"+h.what;h.nonce=d.nonce(k,h);h.data=c.extend({action:h.action,id:h.element.split("-").pop(),_ajax_nonce:h.nonce},wpAjax.unserialize(f[4]||""));if(c.isFunction(h.delBefore)){h=h.delBefore(h);if(!h){return true}}if(!h.data._ajax_nonce){return true}g=c("#"+h.element);if("none"!=h.delColor){i="slideUp";if(g.css("display").match(/table/)){i="fadeOut"}g.animate({backgroundColor:h.delColor},"fast")[i]("fast").queue(function(){j.wpList.recolor();c(this).dequeue()})}else{j.wpList.recolor()}h.success=function(l){var e=wpAjax.parseAjaxResponse(l,h.response,h.element),m;if(!e||e.errors){g.stop().stop().css("backgroundColor","#FF3333").show().queue(function(){j.wpList.recolor();c(this).dequeue()});return false}if(c.isFunction(h.delAfter)){m=this.complete;this.complete=function(n,o){g.queue(function(){var p=c.extend({xml:n,status:o,parsed:e},h);h.delAfter(l,p);if(c.isFunction(m)){m(n,o)}}).dequeue()}}};c.ajax(h);return false},ajaxDim:function(l,i){if(c(l).parent().css("display")=="none"){return false}l=c(l);i=i||{};var k=this,f=d.parseClass(l,"dim"),h,m,g,j;i=d.pre.call(k,l,i,"dim");i.element=f[2]||i.element||null;i.dimClass=f[3]||i.dimClass||null;if(f[4]){i.dimAddColor="#"+f[4]}else{i.dimAddColor=i.dimAddColor||"#FFFF33"}if(f[5]){i.dimDelColor="#"+f[5]}else{i.dimDelColor=i.dimDelColor||"#FF3333"}if(!i||!i.element||!i.dimClass){return true}i.action="dim-"+i.what;i.nonce=d.nonce(l,i);i.data=c.extend({action:i.action,id:i.
|