WordPress/wp-includes/js/wp-lists.min.js

1 line
7.1 KiB
JavaScript
Raw Normal View History

!function(r){var t={add:"ajaxAdd",del:"ajaxDel",dim:"ajaxDim",process:"process",recolor:"recolor"},d={settings:{url:ajaxurl,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(e,t){e=wpAjax.unserialize(e.attr("href"));return t.nonce||e._ajax_nonce||r("#"+t.element+' input[name="_ajax_nonce"]').val()||e._wpnonce||r("#"+t.element+' input[name="_wpnonce"]').val()||0},parseData:function(e,t){var n,s=[];try{(n=(n=r(e).attr("data-wp-lists")||"").match(new RegExp(t+":[\\S]+")))&&(s=n[0].split(":"))}catch(e){}return s},pre:function(e,t,n){var s;return t=r.extend({},this.wpList.settings,{element:null,nonce:0,target:e.get(0)},t||{}),!(r.isFunction(t.confirm)&&("add"!=n&&(s=r("#"+t.element).css("backgroundColor"),r("#"+t.element).css("backgroundColor","#FF9966")),e=t.confirm.call(this,e,t,n,s),"add"!=n&&r("#"+t.element).css("backgroundColor",s),!e))&&t},ajaxAdd:function(e,n){e=r(e),n=n||{};var t,s,i,a=this,o=d.parseData(e,"add");return(n=d.pre.call(a,e,n,"add")).element=o[2]||e.attr("id")||n.element||null,o[3]?n.addColor="#"+o[3]:n.addColor=n.addColor||"#FFFF33",!!n&&(e.is('[id="'+n.element+'-submit"]')?!n.element||(n.action="add-"+n.what,n.nonce=d.nonce(e,n),t=r("#"+n.element+" :input").not('[name="_ajax_nonce"], [name="_wpnonce"], [name="action"]'),!!wpAjax.validateForm("#"+n.element)&&(n.data=r.param(r.extend({_ajax_nonce:n.nonce,action:n.action},wpAjax.unserialize(o[4]||""))),(t=r.isFunction(t.fieldSerialize)?t.fieldSerialize():t.serialize())&&(n.data+="&"+t),!(!r.isFunction(n.addBefore)||(n=n.addBefore(n)))||(!n.data.match(/_ajax_nonce=[a-f0-9]+/)||(n.success=function(e){return s=wpAjax.parseAjaxResponse(e,n.response,n.element),i=e,!(!s||s.errors)&&(!0===s||(jQuery.each(s.responses,function(){d.add.call(a,this.data,r.extend({},n,{pos:this.position||0,id:this.id||0,oldId:this.oldId||null}))}),a.wpList.recolor(),r(a).trigger("wpListAddEnd",[n,a.wpList]),void d.clear.call(a,"#"+n.element)))},n.complete=function(e,t){r.isFunction(n.addAfter)&&(t=r.extend({xml:e,status:t,parsed:s},n),n.addAfter(i,t))},r.ajax(n),!1)))):!d.add.call(a,e,n))},ajaxDel:function(e,s){e=r(e),s=s||{};var i,a,o,t=this,n=d.parseData(e,"delete");return(s=d.pre.call(t,e,s,"delete")).element=n[2]||s.element||null,n[3]?s.delColor="#"+n[3]:s.delColor=s.delColor||"#faa",!(!s||!s.element)&&(s.action="delete-"+s.what,s.nonce=d.nonce(e,s),s.data=r.extend({action:s.action,id:s.element.split("-").pop(),_ajax_nonce:s.nonce},wpAjax.unserialize(n[4]||"")),!(!r.isFunction(s.delBefore)||(s=s.delBefore(s,t)))||(!s.data._ajax_nonce||(i=r("#"+s.element),"none"!=s.delColor?i.css("backgroundColor",s.delColor).fadeOut(350,function(){t.wpList.recolor(),r(t).trigger("wpListDelEnd",[s,t.wpList])}):(t.wpList.recolor(),r(t).trigger("wpListDelEnd",[s,t.wpList])),s.success=function(e){if(a=wpAjax.parseAjaxResponse(e,s.response,s.element),o=e,!a||a.errors)return i.stop().stop().css("backgroundColor","#faa").show().queue(function(){t.wpList.recolor(),r(this).dequeue()}),!1},s.complete=function(t,n){r.isFunction(s.delAfter)&&i.queue(function(){var e=r.extend({xml:t,status:n,parsed:a},s);s.delAfter(o,e)}).dequeue()},r.ajax(s),!1)))},ajaxDim:function(e,s){if("none"==r(e).parent().css("display"))return!1;e=r(e),s=s||{};var i,t,a,o,n=this,l=d.parseData(e,"dim");return(s=d.pre.call(n,e,s,"dim")).element=l[2]||s.element||null,s.dimClass=l[3]||s.dimClass||null,l[4]?s.dimAddColor="#"+l[4]:s.dimAddColor=s.dimAddColor||"#FFFF33",l[5]?s.dimDelColor="#"+l[5]:s.dimDelColor=s.dimDelColor||"#FF3333",!(s&&s.element&&s.dimClass)||(s.action="dim-"+s.what,s.nonce=d.nonce(e,s),s.data=r.extend({action:s.action,id:s.element.split("-").pop(),dimClass:s.dimClass,_ajax_nonce:s.nonce},wpAjax.unserialize(l[6]||"")),!(!r.isFunction(s.dimBefore)||(s=s.dimBefore(s)))||(i=r("#"+s.element),t=i.toggleClass(s.dimClass).is("."+s.dimClass),e=d.getColor(i),i.toggleClass(s.dimClass),"none"!=(l=t?s.dimAddColor:s.dimDelColor)?i.anima