mirror of
https://github.com/WordPress/WordPress.git
synced 2024-11-15 07:05:37 +01:00
b3eb7b301c
Add labels; change Enter new/Cancel link to a button; move focus to input when creating new field; move Add Custom Field out of fields table. Props jane, batmoo, karmatosed, franrosa, sabernhardt, annashopina, oglekler, joedolson. Fixes #15631. Built from https://develop.svn.wordpress.org/trunk@56018 git-svn-id: http://core.svn.wordpress.org/trunk@55530 1a063a9b-81f0-0310-95a4-ce76da25c4cd
2 lines
7.3 KiB
JavaScript
2 lines
7.3 KiB
JavaScript
/*! This file is auto-generated */
|
|
!function(d){var n={add:"ajaxAdd",del:"ajaxDel",dim:"ajaxDim",process:"process",recolor:"recolor"},c={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 e=wpAjax.unserialize(e.attr("href")),n=d("#"+t.element);return t.nonce||e._ajax_nonce||n.find('input[name="_ajax_nonce"]').val()||e._wpnonce||n.find('input[name="_wpnonce"]').val()||0},parseData:function(e,t){var n,o=[];try{(n=(n=d(e).data("wp-lists")||"").match(new RegExp(t+":[\\S]+")))&&(o=n[0].split(":"))}catch(e){}return o},pre:function(e,t,n){var o,i;return!("function"==typeof(t=d.extend({},this.wpList.settings,{element:null,nonce:0,target:e.get(0)},t||{})).confirm&&(o=d("#"+t.element),"add"!==n&&(i=o.css("backgroundColor"),o.css("backgroundColor","#ff9966")),e=t.confirm.call(this,e,t,n,i),"add"!==n&&o.css("backgroundColor",i),!e))&&t},ajaxAdd:function(e,n){var o,i,t=this,e=d(e),a=c.parseData(e,"add");if(n=n||{},(n=c.pre.call(t,e,n,"add")).element=a[2]||e.prop("id")||n.element||null,n.addColor=a[3]?"#"+a[3]:n.addColor,n){if(!e.is('[id="'+n.element+'-submit"]'))return!c.add.call(t,e,n);if(!n.element)return!0;if(n.action="add-"+n.what,n.nonce=c.nonce(e,n),wpAjax.validateForm("#"+n.element)){if(n.data=d.param(d.extend({_ajax_nonce:n.nonce,action:n.action},wpAjax.unserialize(a[4]||""))),(a="function"==typeof(e=d("#"+n.element+" :input").not('[name="_ajax_nonce"], [name="_wpnonce"], [name="action"]')).fieldSerialize?e.fieldSerialize():e.serialize())&&(n.data+="&"+a),"function"==typeof n.addBefore&&!(n=n.addBefore(n)))return!0;if(!n.data.match(/_ajax_nonce=[a-f0-9]+/))return!0;n.success=function(e){return o=wpAjax.parseAjaxResponse(e,n.response,n.element),i=e,!(!o||o.errors)&&(!0===o||(d.each(o.responses,function(){c.add.call(t,this.data,d.extend({},n,{position:this.position||0,id:this.id||0,oldId:this.oldId||null}))}),t.wpList.recolor(),d(t).trigger("wpListAddEnd",[n,t.wpList]),void c.clear.call(t,"#"+n.element)))},n.complete=function(e,t){"function"==typeof n.addAfter&&n.addAfter(i,d.extend({xml:e,status:t,parsed:o},n))},d.ajax(n)}}return!1},ajaxDel:function(e,n){var o,i,a,t=this,e=d(e),s=c.parseData(e,"delete");if(n=n||{},(n=c.pre.call(t,e,n,"delete")).element=s[2]||n.element||null,n.delColor=s[3]?"#"+s[3]:n.delColor,n&&n.element){if(n.action="delete-"+n.what,n.nonce=c.nonce(e,n),n.data=d.extend({_ajax_nonce:n.nonce,action:n.action,id:n.element.split("-").pop()},wpAjax.unserialize(s[4]||"")),"function"==typeof n.delBefore&&!(n=n.delBefore(n,t)))return!0;if(!n.data._ajax_nonce)return!0;o=d("#"+n.element),"none"!==n.delColor?o.css("backgroundColor",n.delColor).fadeOut(350,function(){t.wpList.recolor(),d(t).trigger("wpListDelEnd",[n,t.wpList])}):(t.wpList.recolor(),d(t).trigger("wpListDelEnd",[n,t.wpList])),n.success=function(e){if(i=wpAjax.parseAjaxResponse(e,n.response,n.element),a=e,!i||i.errors)return o.stop().stop().css("backgroundColor","#faa").show().queue(function(){t.wpList.recolor(),d(this).dequeue()}),!1},n.complete=function(e,t){"function"==typeof n.delAfter&&o.queue(function(){n.delAfter(a,d.extend({xml:e,status:t,parsed:i},n))}).dequeue()},d.ajax(n)}return!1},ajaxDim:function(e,n){var o,i,t,a,s,r=this,l=d(e),e=c.parseData(l,"dim");if("none"!==l.parent().css("display")){if(n=n||{},(n=c.pre.call(r,l,n,"dim")).element=e[2]||n.element||null,n.dimClass=e[3]||n.dimClass||null,n.dimAddColor=e[4]?"#"+e[4]:n.dimAddColor,n.dimDelColor=e[5]?"#"+e[5]:n.dimDelColor,!n||!n.element||!n.dimClass)return!0;if(n.action="dim-"+n.what,n.nonce=c.nonce(l,n),n.data=d.extend({_ajax_nonce:n.nonce,action:n.action,id:n.element.split("-").pop(),dimClass:n.dimClass},wpAjax.unserialize(e[6]||"")),"function"==typeof n.dimBefore&&!(n=n.dimBefore(n)))return!0;if(o=d("#"+n.element),i=o.toggleClass(n.dimClass).is("."+n.dimClass),e=c.getColor(o),t=i?n.dimAddColor:n.dimDelColor,o.toggleClass(n.dimClass),"none"!==t?o.animate({backgroundColor:t},"fast").queue(function(){o.toggleClass(n.dimClass),d(this).dequeue()}).animate({backgroundColor:e},{complete:function(){d(this).css("backgroundColor",""),d(r).trigger("wpListDimEnd",[n,r.wpList])}}):d(r).trigger("wpListDimEnd",[n,r.wpList]),!n.data._ajax_nonce)return!0;n.success=function(e){var t;return a=wpAjax.parseAjaxResponse(e,n.response,n.element),s=e,!0===a||(!a||a.errors?(o.stop().stop().css("backgroundColor","#ff3333")[i?"removeClass":"addClass"](n.dimClass).show().queue(function(){r.wpList.recolor(),d(this).dequeue()}),!1):void(void 0!==a.responses[0].supplemental.comment_link&&(t=(e=l.find(".submitted-on")).find("a"),""!==a.responses[0].supplemental.comment_link?e.html(d("<a></a>").text(e.text()).prop("href",a.responses[0].supplemental.comment_link)):t.length&&e.text(t.text()))))},n.complete=function(e,t){"function"==typeof n.dimAfter&&o.queue(function(){n.dimAfter(s,d.extend({xml:e,status:t,parsed:a},n))}).dequeue()},d.ajax(n)}return!1},getColor:function(e){return d(e).css("backgroundColor")||"#ffffff"},add:function(e,t){var n,o=d(this),i=d(e),e=!1;return t=d.extend({position:0,id:0,oldId:null},this.wpList.settings,t="string"==typeof t?{what:t}:t),!(!i.length||!t.what)&&(t.oldId&&(e=d("#"+t.what+"-"+t.oldId)),!t.id||t.id===t.oldId&&e&&e.length||d("#"+t.what+"-"+t.id).remove(),e&&e.length?(e.before(i),e.remove()):isNaN(t.position)?(e="after","-"===t.position.substr(0,1)&&(t.position=t.position.substr(1),e="before"),1===(n=o.find("#"+t.position)).length?n[e](i):o.append(i)):"comment"===t.what&&0!==d("#"+t.element).length||(t.position<0?o.prepend(i):o.append(i)),t.alt&&i.toggleClass(t.alt,(o.children(":visible").index(i[0])+t.altOffset)%2),"none"!==t.addColor&&i.css("backgroundColor",t.addColor).animate({backgroundColor:c.getColor(i)},{complete:function(){d(this).css("backgroundColor","")}}),o.each(function(e,t){t.wpList.process(i)}),i)},clear:function(e){var n,o,e=d(e);this.wpList&&e.parents("#"+this.id).length||e.find(":input").each(function(e,t){d(t).parents(".form-no-clear").length||(n=t.type.toLowerCase(),o=t.tagName.toLowerCase(),"text"===n||"password"===n||"textarea"===o?t.value="":"checkbox"===n||"radio"===n?t.checked=!1:"select"===o&&(t.selectedIndex=null))})},process:function(e){var t=this,e=d(e||document);e.on("submit",'form[data-wp-lists^="add:'+t.id+':"]',function(){return t.wpList.add(this)}),e.on("click",'[data-wp-lists^="add:'+t.id+':"], input[data-wp-lists^="add:'+t.id+':"]',function(){return t.wpList.add(this)}),e.on("click",'[data-wp-lists^="delete:'+t.id+':"]',function(){return t.wpList.del(this)}),e.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=d(".list-item:visible",t)).length||(e=d(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()})}}};d.fn.wpList=function(t){return this.each(function(e,o){o.wpList={settings:d.extend({},c.settings,{what:c.parseData(o,"list")[1]||""},t)},d.each(n,function(e,n){o.wpList[e]=function(e,t){return c[n].call(o,e,t)}})}),c.init.call(this),this.wpList.process(),this}}(jQuery); |