]> scripts.mit.edu Git - autoinstalls/wordpress.git/blob - wp-includes/js/wp-lists.min.js
WordPress 4.5.1-scripts
[autoinstalls/wordpress.git] / wp-includes / js / wp-lists.min.js
1 !function(a){var b,c={add:"ajaxAdd",del:"ajaxDel",dim:"ajaxDim",process:"process",recolor:"recolor"};b={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(b,c){var d=wpAjax.unserialize(b.attr("href"));return c.nonce||d._ajax_nonce||a("#"+c.element+' input[name="_ajax_nonce"]').val()||d._wpnonce||a("#"+c.element+' input[name="_wpnonce"]').val()||0},parseData:function(b,c){var d,e=[];try{d=a(b).attr("data-wp-lists")||"",d=d.match(new RegExp(c+":[\\S]+")),d&&(e=d[0].split(":"))}catch(f){}return e},pre:function(b,c,d){var e,f;return c=a.extend({},this.wpList.settings,{element:null,nonce:0,target:b.get(0)},c||{}),a.isFunction(c.confirm)&&("add"!=d&&(e=a("#"+c.element).css("backgroundColor"),a("#"+c.element).css("backgroundColor","#FF9966")),f=c.confirm.call(this,b,c,d,e),"add"!=d&&a("#"+c.element).css("backgroundColor",e),!f)?!1:c},ajaxAdd:function(c,d){c=a(c),d=d||{};var e,f,g,h,i,j=this,k=b.parseData(c,"add");return d=b.pre.call(j,c,d,"add"),d.element=k[2]||c.attr("id")||d.element||null,k[3]?d.addColor="#"+k[3]:d.addColor=d.addColor||"#FFFF33",d?c.is('[id="'+d.element+'-submit"]')?d.element?(d.action="add-"+d.what,d.nonce=b.nonce(c,d),e=a("#"+d.element+" :input").not('[name="_ajax_nonce"], [name="_wpnonce"], [name="action"]'),(f=wpAjax.validateForm("#"+d.element))?(d.data=a.param(a.extend({_ajax_nonce:d.nonce,action:d.action},wpAjax.unserialize(k[4]||""))),g=a.isFunction(e.fieldSerialize)?e.fieldSerialize():e.serialize(),g&&(d.data+="&"+g),a.isFunction(d.addBefore)&&(d=d.addBefore(d),!d)?!0:d.data.match(/_ajax_nonce=[a-f0-9]+/)?(d.success=function(c){return h=wpAjax.parseAjaxResponse(c,d.response,d.element),i=c,!h||h.errors?!1:!0===h?!0:(jQuery.each(h.responses,function(){b.add.call(j,this.data,a.extend({},d,{pos:this.position||0,id:this.id||0,oldId:this.oldId||null}))}),j.wpList.recolor(),a(j).trigger("wpListAddEnd",[d,j.wpList]),void b.clear.call(j,"#"+d.element))},d.complete=function(b,c){if(a.isFunction(d.addAfter)){var e=a.extend({xml:b,status:c,parsed:h},d);d.addAfter(i,e)}},a.ajax(d),!1):!0):!1):!0:!b.add.call(j,c,d):!1},ajaxDel:function(c,d){c=a(c),d=d||{};var e,f,g,h=this,i=b.parseData(c,"delete");return d=b.pre.call(h,c,d,"delete"),d.element=i[2]||d.element||null,i[3]?d.delColor="#"+i[3]:d.delColor=d.delColor||"#faa",d&&d.element?(d.action="delete-"+d.what,d.nonce=b.nonce(c,d),d.data=a.extend({action:d.action,id:d.element.split("-").pop(),_ajax_nonce:d.nonce},wpAjax.unserialize(i[4]||"")),a.isFunction(d.delBefore)&&(d=d.delBefore(d,h),!d)?!0:d.data._ajax_nonce?(e=a("#"+d.element),"none"!=d.delColor?e.css("backgroundColor",d.delColor).fadeOut(350,function(){h.wpList.recolor(),a(h).trigger("wpListDelEnd",[d,h.wpList])}):(h.wpList.recolor(),a(h).trigger("wpListDelEnd",[d,h.wpList])),d.success=function(b){return f=wpAjax.parseAjaxResponse(b,d.response,d.element),g=b,!f||f.errors?(e.stop().stop().css("backgroundColor","#faa").show().queue(function(){h.wpList.recolor(),a(this).dequeue()}),!1):void 0},d.complete=function(b,c){a.isFunction(d.delAfter)&&e.queue(function(){var e=a.extend({xml:b,status:c,parsed:f},d);d.delAfter(g,e)}).dequeue()},a.ajax(d),!1):!0):!1},ajaxDim:function(c,d){if("none"==a(c).parent().css("display"))return!1;c=a(c),d=d||{};var e,f,g,h,i,j,k=this,l=b.parseData(c,"dim");return d=b.pre.call(k,c,d,"dim"),d.element=l[2]||d.element||null,d.dimClass=l[3]||d.dimClass||null,l[4]?d.dimAddColor="#"+l[4]:d.dimAddColor=d.dimAddColor||"#FFFF33",l[5]?d.dimDelColor="#"+l[5]:d.dimDelColor=d.dimDelColor||"#FF3333",d&&d.element&&d.dimClass?(d.action="dim-"+d.what,d.nonce=b.nonce(c,d),d.data=a.extend({action:d.action,id:d.element.split("-").pop(),dimClass:d.dimClass,_ajax_nonce:d.nonce},wpAjax.unserialize(l[6]||"")),a.isFunction(d.dimBefore)&&(d=d.dimBefore(d),!d)?!0:(e=a("#"+d.element),f=e.toggleClass(d.dimClass).is("."+d.dimClass),g=b.getColor(e),e.toggleClass(d.dimClass),h=f?d.dimAddColor:d.dimDelColor,"none"!=h?e.animate({backgroundColor:h},"fast").queue(function(){e.toggleClass(d.dimClass),a(this).dequeue()}).animate({backgroundColor:g},{complete:function(){a(this).css("backgroundColor",""),a(k).trigger("wpListDimEnd",[d,k.wpList])}}):a(k).trigger("wpListDimEnd",[d,k.wpList]),d.data._ajax_nonce?(d.success=function(b){return i=wpAjax.parseAjaxResponse(b,d.response,d.element),j=b,!i||i.errors?(e.stop().stop().css("backgroundColor","#FF3333")[f?"removeClass":"addClass"](d.dimClass).show().queue(function(){k.wpList.recolor(),a(this).dequeue()}),!1):void 0},d.complete=function(b,c){a.isFunction(d.dimAfter)&&e.queue(function(){var e=a.extend({xml:b,status:c,parsed:i},d);d.dimAfter(j,e)}).dequeue()},a.ajax(d),!1):!0)):!0},getColor:function(a){var b=jQuery(a).css("backgroundColor");return b||"#ffffff"},add:function(c,d){c=a("string"==typeof c?a.trim(c):c);var e,f,g,h=a(this),i=!1,j={pos:0,id:0,oldId:null};return"string"==typeof d&&(d={what:d}),d=a.extend(j,this.wpList.settings,d),c.length&&d.what?(d.oldId&&(i=a("#"+d.what+"-"+d.oldId)),!d.id||d.id==d.oldId&&i&&i.length||a("#"+d.what+"-"+d.id).remove(),i&&i.length?(i.before(c),i.remove()):isNaN(d.pos)?(e="after","-"==d.pos.substr(0,1)&&(d.pos=d.pos.substr(1),e="before"),f=h.find("#"+d.pos),1===f.length?f[e](c):h.append(c)):("comment"!=d.what||0===a("#"+d.element).length)&&(d.pos<0?h.prepend(c):h.append(c)),d.alt&&((h.children(":visible").index(c[0])+d.altOffset)%2?c.removeClass(d.alt):c.addClass(d.alt)),"none"!=d.addColor&&(g=b.getColor(c),c.css("backgroundColor",d.addColor).animate({backgroundColor:g},{complete:function(){a(this).css("backgroundColor","")}})),h.each(function(){this.wpList.process(c)}),c):!1},clear:function(b){var c,d,e=this;b=a(b),e.wpList&&b.parents("#"+e.id).length||b.find(":input").each(function(){a(this).parents(".form-no-clear").length||(c=this.type.toLowerCase(),d=this.tagName.toLowerCase(),"text"==c||"password"==c||"textarea"==d?this.value="":"checkbox"==c||"radio"==c?this.checked=!1:"select"==d&&(this.selectedIndex=null))})},process:function(b){var c=this,d=a(b||document);d.delegate('form[data-wp-lists^="add:'+c.id+':"]',"submit",function(){return c.wpList.add(this)}),d.delegate('a[data-wp-lists^="add:'+c.id+':"], input[data-wp-lists^="add:'+c.id+':"]',"click",function(){return c.wpList.add(this)}),d.delegate('[data-wp-lists^="delete:'+c.id+':"]',"click",function(){return c.wpList.del(this)}),d.delegate('[data-wp-lists^="dim:'+c.id+':"]',"click",function(){return c.wpList.dim(this)})},recolor:function(){var b,c,d=this;d.wpList.settings.alt&&(b=a(".list-item:visible",d),b.length||(b=a(d).children(":visible")),c=[":even",":odd"],d.wpList.settings.altOffset%2&&c.reverse(),b.filter(c[0]).addClass(d.wpList.settings.alt).end().filter(c[1]).removeClass(d.wpList.settings.alt))},init:function(){var a=this;a.wpList.process=function(b){a.each(function(){this.wpList.process(b)})},a.wpList.recolor=function(){a.each(function(){this.wpList.recolor()})}}},a.fn.wpList=function(d){return this.each(function(){var e=this;this.wpList={settings:a.extend({},b.settings,{what:b.parseData(this,"list")[1]||""},d)},a.each(c,function(a,c){e.wpList[a]=function(a,d){return b[c].call(e,a,d)}})}),b.init.call(this),this.wpList.process(),this}}(jQuery);