Wordpress/wp-includes/js/wp-util.min.js

1 line
1005 B
JavaScript
Raw Normal View History

window.wp=window.wp||{};(function(b){var a=typeof _wpUtilSettings==="undefined"?{}:_wpUtilSettings;wp.template=_.memoize(function(e){var d,c={evaluate:/<#([\s\S]+?)#>/g,interpolate:/\{\{\{([\s\S]+?)\}\}\}/g,escape:/\{\{([^\}]+?)\}\}(?!\})/g,variable:"data"};return function(f){d=d||_.template(b("#tmpl-"+e).html(),null,c);return d(f)}});wp.xhr={settings:a.xhr||{},post:function(d,c){return wp.xhr.send({data:_.isObject(d)?d:_.extend(c||{},{action:d})})},send:function(d,c){if(_.isObject(d)){c=d}else{c=c||{};c.data=_.extend(c.data||{},{action:d})}c=_.defaults(c||{},{type:"POST",url:wp.xhr.settings.url,context:this});return b.Deferred(function(e){if(c.success){e.done(c.success)}if(c.error){e.fail(c.error)}delete c.success;delete c.error;b.ajax(c).done(function(f){if(f==="1"||f===1){f={success:true}}if(_.isObject(f)&&!_.isUndefined(f.success)){e[f.success?"resolveWith":"rejectWith"](this,[f.data])}else{e.rejectWith(this,[f])}}).fail(function(){e.rejectWith(this,arguments)})}).promise()}}}(jQuery));