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

2 lines
7.3 KiB
JavaScript

/*! This file is auto-generated */
!function(u){var p,n={add:"ajaxAdd",del:"ajaxDel",dim:"ajaxDim",process:"process",recolor:"recolor"};p={settings:{url:ajaxurl,type:"POST",response:"ajax-response",what:"",alt:"alternate",altOffset:0,addColor:"#ffff33",delColor:"#faafaa",dimAddColor:"#ffff33",dimDelColor:"#ff3333",confirm:null,addBefore:null,addAfter:null,delBefore:null,delAfter:null,dimBefore:null,dimAfter:null},nonce:function(e,t){var n=wpAjax.unserialize(e.attr("href")),i=u("#"+t.element);return t.nonce||n._ajax_nonce||i.find('input[name="_ajax_nonce"]').val()||n._wpnonce||i.find('input[name="_wpnonce"]').val()||0},parseData:function(e,t){var n,i=[];try{(n=(n=u(e).data("wp-lists")||"").match(new RegExp(t+":[\\S]+")))&&(i=n[0].split(":"))}catch(e){}return i},pre:function(e,t,n){var i,o,s;return t=u.extend({},this.wpList.settings,{element:null,nonce:0,target:e.get(0)},t||{}),!(u.isFunction(t.confirm)&&(i=u("#"+t.element),"add"!==n&&(o=i.css("backgroundColor"),i.css("backgroundColor","#ff9966")),s=t.confirm.call(this,e,t,n,o),"add"!==n&&i.css("backgroundColor",o),!s))&&t},ajaxAdd:function(e,n){var t,i,o,s,a=this,l=u(e),r=p.parseData(l,"add");return n=n||{},(n=p.pre.call(a,l,n,"add")).element=r[2]||l.prop("id")||n.element||null,n.addColor=r[3]?"#"+r[3]:n.addColor,!!n&&(l.is('[id="'+n.element+'-submit"]')?!n.element||(n.action="add-"+n.what,n.nonce=p.nonce(l,n),!!wpAjax.validateForm("#"+n.element)&&(n.data=u.param(u.extend({_ajax_nonce:n.nonce,action:n.action},wpAjax.unserialize(r[4]||""))),t=u("#"+n.element+" :input").not('[name="_ajax_nonce"], [name="_wpnonce"], [name="action"]'),(i=u.isFunction(t.fieldSerialize)?t.fieldSerialize():t.serialize())&&(n.data+="&"+i),!(!u.isFunction(n.addBefore)||(n=n.addBefore(n)))||(!n.data.match(/_ajax_nonce=[a-f0-9]+/)||(n.success=function(e){return o=wpAjax.parseAjaxResponse(e,n.response,n.element),s=e,!(!o||o.errors)&&(!0===o||(u.each(o.responses,function(){p.add.call(a,this.data,u.extend({},n,{position:this.position||0,id:this.id||0,oldId:this.oldId||null}))}),a.wpList.recolor(),u(a).trigger("wpListAddEnd",[n,a.wpList]),void p.clear.call(a,"#"+n.element)))},n.complete=function(e,t){u.isFunction(n.addAfter)&&n.addAfter(s,u.extend({xml:e,status:t,parsed:o},n))},u.ajax(n),!1)))):!p.add.call(a,l,n))},ajaxDel:function(e,n){var i,o,s,t=this,a=u(e),l=p.parseData(a,"delete");return n=n||{},(n=p.pre.call(t,a,n,"delete")).element=l[2]||n.element||null,n.delColor=l[3]?"#"+l[3]:n.delColor,!(!n||!n.element)&&(n.action="delete-"+n.what,n.nonce=p.nonce(a,n),n.data=u.extend({_ajax_nonce:n.nonce,action:n.action,id:n.element.split("-").pop()},wpAjax.unserialize(l[4]||"")),!(!u.isFunction(n.delBefore)||(n=n.delBefore(n,t)))||(!n.data._ajax_nonce||(i=u("#"+n.element),"none"!==n.delColor?i.css("backgroundColor",n.delColor).fadeOut(350,function(){t.wpList.recolor(),u(t).trigger("wpListDelEnd",[n,t.wpList])}):(t.wpList.recolor(),u(t).trigger("wpListDelEnd",[n,t.wpList])),n.success=function(e){if(o=wpAjax.parseAjaxResponse(e,n.response,n.element),s=e,!o||o.errors)return i.stop().stop().css("backgroundColor","#faa").show().queue(function(){t.wpList.recolor(),u(this).dequeue()}),!1},n.complete=function(e,t){u.isFunction(n.delAfter)&&i.queue(function(){n.delAfter(s,u.extend({xml:e,status:t,parsed:o},n))}).dequeue()},u.ajax(n),!1)))},ajaxDim:function(e,i){var o,s,t,n,a,l,r=this,d=u(e),c=p.parseData(d,"dim");return"none"!==d.parent().css("display")&&(i=i||{},(i=p.pre.call(r,d,i,"dim")).element=c[2]||i.element||null,i.dimClass=c[3]||i.dimClass||null,i.dimAddColor=c[4]?"#"+c[4]:i.dimAddColor,i.dimDelColor=c[5]?"#"+c[5]:i.dimDelColor,!(i&&i.element&&i.dimClass)||(i.action="dim-"+i.what,i.nonce=p.nonce(d,i),i.data=u.extend({_ajax_nonce:i.nonce,action:i.action,id:i.element.split("-").pop(),dimClass:i.dimClass},wpAjax.unserialize(c[6]||"")),!(!u.isFunction(i.dimBefore)||(i=i.dimBefore(i)))||(o=u("#"+i.element),s=o.toggleClass(i.dimClass).is("."+i.dimClass),t=p.getColor(o),n=s?i.dimAddColor:i.dimDelColor,o.toggleClass(i.dimClass),"none"!==n?o.animate({backgroundColor:n},"fast").queue(function(){o.toggleClass(i.dimClass),u(this).dequeue()}).animate({backgroundColor:t},{complete:function(){u(this).css("backgroundColor",""),u(r).trigger("wpListDimEnd",[i,r.wpList])}}):u(r).trigger("wpListDimEnd",[i,r.wpList]),!i.data._ajax_nonce||(i.success=function(e){if(a=wpAjax.parseAjaxResponse(e,i.response,i.element),l=e,!0===a)return!0;if(!a||a.errors)return o.stop().stop().css("backgroundColor","#ff3333")[s?"removeClass":"addClass"](i.dimClass).show().queue(function(){r.wpList.recolor(),u(this).dequeue()}),!1;if(void 0!==a.responses[0].supplemental.comment_link){var t=d.find(".submitted-on"),n=t.find("a");""!==a.responses[0].supplemental.comment_link?t.html(u("<a></a>").text(t.text()).prop("href",a.responses[0].supplemental.comment_link)):n.length&&t.text(n.text())}},i.complete=function(e,t){u.isFunction(i.dimAfter)&&o.queue(function(){i.dimAfter(l,u.extend({xml:e,status:t,parsed:a},i))}).dequeue()},u.ajax(i),!1))))},getColor:function(e){return u(e).css("backgroundColor")||"#ffffff"},add:function(e,t){var n,i,o=u(this),s=u(e),a=!1;return"string"==typeof t&&(t={what:t}),t=u.extend({position:0,id:0,oldId:null},this.wpList.settings,t),!(!s.length||!t.what)&&(t.oldId&&(a=u("#"+t.what+"-"+t.oldId)),!t.id||t.id===t.oldId&&a&&a.length||u("#"+t.what+"-"+t.id).remove(),a&&a.length?(a.before(s),a.remove()):isNaN(t.position)?(n="after","-"===t.position.substr(0,1)&&(t.position=t.position.substr(1),n="before"),1===(i=o.find("#"+t.position)).length?i[n](s):o.append(s)):"comment"===t.what&&0!==u("#"+t.element).length||(t.position<0?o.prepend(s):o.append(s)),t.alt&&s.toggleClass(t.alt,(o.children(":visible").index(s[0])+t.altOffset)%2),"none"!==t.addColor&&s.css("backgroundColor",t.addColor).animate({backgroundColor:p.getColor(s)},{complete:function(){u(this).css("backgroundColor","")}}),o.each(function(e,t){t.wpList.process(s)}),s)},clear:function(e){var n,i,t=u(e);this.wpList&&t.parents("#"+this.id).length||t.find(":input").each(function(e,t){u(t).parents(".form-no-clear").length||(n=t.type.toLowerCase(),i=t.tagName.toLowerCase(),"text"===n||"password"===n||"textarea"===i?t.value="":"checkbox"===n||"radio"===n?t.checked=!1:"select"===i&&(t.selectedIndex=null))})},process:function(e){var t=this,n=u(e||document);n.on("submit",'form[data-wp-lists^="add:'+t.id+':"]',function(){return t.wpList.add(this)}),n.on("click",'a[data-wp-lists^="add:'+t.id+':"], input[data-wp-lists^="add:'+t.id+':"]',function(){return t.wpList.add(this)}),n.on("click",'[data-wp-lists^="delete:'+t.id+':"]',function(){return t.wpList.del(this)}),n.on("click",'[data-wp-lists^="dim:'+t.id+':"]',function(){return t.wpList.dim(this)})},recolor:function(){var e,t=this,n=[":even",":odd"];t.wpList.settings.alt&&((e=u(".list-item:visible",t)).length||(e=u(t).children(":visible")),t.wpList.settings.altOffset%2&&n.reverse(),e.filter(n[0]).addClass(t.wpList.settings.alt).end(),e.filter(n[1]).removeClass(t.wpList.settings.alt))},init:function(){var t=this;t.wpList.process=function(e){t.each(function(){this.wpList.process(e)})},t.wpList.recolor=function(){t.each(function(){this.wpList.recolor()})}}},u.fn.wpList=function(t){return this.each(function(e,i){i.wpList={settings:u.extend({},p.settings,{what:p.parseData(i,"list")[1]||""},t)},u.each(n,function(e,n){i.wpList[e]=function(e,t){return p[n].call(i,e,t)}})}),p.init.call(this),this.wpList.process(),this}}(jQuery);