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

1 line
7.4 KiB
JavaScript
Raw Permalink 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,a,o=this,i=d.parseData(e,"add");return(n=d.pre.call(o,e,n,"add")).element=i[2]||e.attr("id")||n.element||null,i[3]?n.addColor="#"+i[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(i[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),a=e,!(!s||s.errors)&&(!0===s||(jQuery.each(s.responses,function(){d.add.call(o,this.data,r.extend({},n,{pos:this.position||0,id:this.id||0,oldId:this.oldId||null}))}),o.wpList.recolor(),r(o).trigger("wpListAddEnd",[n,o.wpList]),void d.clear.call(o,"#"+n.element)))},n.complete=function(e,t){r.isFunction(n.addAfter)&&(t=r.extend({xml:e,status:t,parsed:s},n),n.addAfter(a,t))},r.ajax(n),!1)))):!d.add.call(o,e,n))},ajaxDel:function(e,s){e=r(e),s=s||{};var a,o,i,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||(a=r("#"+s.element),"none"!=s.delColor?a.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(o=wpAjax.parseAjaxResponse(e,s.response,s.element),i=e,!o||o.errors)return a.stop().stop().css("backgroundColor","#faa").show().queue(function(){t.wpList.recolor(),r(this).dequeue()}),!1},s.complete=function(t,n){r.isFunction(s.delAfter)&&a.queue(function(){var e=r.extend({xml:t,status:n,parsed:o},s);s.delAfter(i,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 a,n,o,i,l=this,t=d.parseData(e,"dim");return(s=d.pre.call(l,e,s,"dim")).element=t[2]||s.element||null,s.dimClass=t[3]||s.dimClass||null,t[4]?s.dimAddColor="#"+t[4]:s.dimAddColor=s.dimAddColor||"#FFFF33",t[5]?s.dimDelColor="#"+t[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(t[6]||"")),!(!r.isFunction(s.dimBefore)||(s=s.dimBefore(s)))||(a=r("#"+s.element),n=a.toggleClass(s.dimClass).is("."+s.dimClass),e=d.getColor(a),a.toggleClass(s.dimClass),"none"!=(t=n?s.dimAddColor:s.dimDelColor)?a.anima