2020-10-29 14:32:05 -04:00
|
|
|
!function(e){"use strict";e.wp=e.wp||{},wp.api=wp.api||new function(){this.models={},this.collections={},this.views={}},wp.api.versionString=wp.api.versionString||"wp/v2/",!_.isFunction(_.includes)&&_.isFunction(_.contains)&&(_.includes=_.contains)}(window),function(e){"use strict";var t,i;e.wp=e.wp||{},wp.api=wp.api||{},wp.api.utils=wp.api.utils||{},wp.api.getModelByRoute=function(t){return _.find(wp.api.models,function(e){return e.prototype.route&&t===e.prototype.route.index})},wp.api.getCollectionByRoute=function(t){return _.find(wp.api.collections,function(e){return e.prototype.route&&t===e.prototype.route.index})},Date.prototype.toISOString||(t=function(e){return 1===(i=String(e)).length&&(i="0"+i),i},Date.prototype.toISOString=function(){return this.getUTCFullYear()+"-"+t(this.getUTCMonth()+1)+"-"+t(this.getUTCDate())+"T"+t(this.getUTCHours())+":"+t(this.getUTCMinutes())+":"+t(this.getUTCSeconds())+"."+String((this.getUTCMilliseconds()/1e3).toFixed(3)).slice(2,5)+"Z"}),wp.api.utils.parseISO8601=function(e){var t,i,n,o,s=0,a=[1,4,5,6,7,10,11];if(i=/^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/.exec(e)){for(n=0;o=a[n];++n)i[o]=+i[o]||0;i[2]=(+i[2]||1)-1,i[3]=+i[3]||1,"Z"!==i[8]&&void 0!==i[9]&&(s=60*i[10]+i[11],"+"===i[9]&&(s=0-s)),t=Date.UTC(i[1],i[2],i[3],i[4],i[5]+s,i[6],i[7])}else t=Date.parse?Date.parse(e):NaN;return t},wp.api.utils.getRootUrl=function(){return e.location.origin?e.location.origin+"/":e.location.protocol+"//"+e.location.host+"/"},wp.api.utils.capitalize=function(e){return _.isUndefined(e)?e:e.charAt(0).toUpperCase()+e.slice(1)},wp.api.utils.capitalizeAndCamelCaseDashes=function(e){return _.isUndefined(e)?e:(e=wp.api.utils.capitalize(e),wp.api.utils.camelCaseDashes(e))},wp.api.utils.camelCaseDashes=function(e){return e.replace(/-([a-z])/g,function(e){return e[1].toUpperCase()})},wp.api.utils.extractRoutePart=function(e,t,i,n){var o;return t=t||1,i=i||wp.api.versionString,0===e.indexOf("/"+i)&&(e=e.substr(i.length+1)),o=e.split("/"),n&&(o=o.reverse()),_.isUndefined(o[--t])?"":o[t]},wp.api.utils.extractParentName=function(e){var t,i=e.lastIndexOf("_id>[\\d]+)/");return i<0?"":((t=(t=e.substr(0,i-1)).split("/")).pop(),t=t.pop())},wp.api.utils.decorateFromRoute=function(e,t){_.each(e,function(e){_.includes(e.methods,"POST")||_.includes(e.methods,"PUT")?_.isEmpty(e.args)||(_.isEmpty(t.prototype.args)?t.prototype.args=e.args:t.prototype.args=_.extend(t.prototype.args,e.args)):_.includes(e.methods,"GET")&&(_.isEmpty(e.args)||(_.isEmpty(t.prototype.options)?t.prototype.options=e.args:t.prototype.options=_.extend(t.prototype.options,e.args)))})},wp.api.utils.addMixinsAndHelpers=function(t,e,i){function n(e,t,i,n,o){var s,a,r,p;return p=jQuery.Deferred(),a=e.get("_embedded")||{},_.isNumber(t)&&0!==t?(a[n]&&(r=_.findWhere(a[n],{id:t})),r=r||{id:t},(s=new wp.api.models[i](r)).get(o)?p.resolve(s):s.fetch({success:function(e){p.resolve(e)},error:function(e,t){p.reject(t)}}),p.promise()):(p.reject(),p)}var o=!1,s=["date","modified","date_gmt","modified_gmt"],a={setDate:function(e,t){var i=t||"date";if(_.indexOf(s,i)<0)return!1;this.set(i,e.toISOString())},getDate:function(e){var t=e||"date",i=this.get(t);return!(_.indexOf(s,t)<0||_.isNull(i))&&new Date(wp.api.utils.parseISO8601(i))}},d=function(e,t){_.each(e.models,function(e){e.set("parent_post",t)})},r={getMeta:function(e){return this.get("meta")[e]},getMetas:function(){return this.get("meta")},setMetas:function(e){var t=this.get("meta");_.extend(t,e),this.set("meta",t)},setMeta:function(e,t){var i=this.get("meta");i[e]=t,this.set("meta",i)}},p={getRevisions:function(){return function(e,t,i,n){var o,s,a,r="",p="",c=jQuery.Deferred();return o=e.get("id"),s=e.get("_embedded")||{},_.isNumber(o)&&0!==o?(_.isUndefined(i)||_.isUndefined(s[i])?r={parent:o}:p=_.isUndefined(n)?s[i]:s[i][n],a=new wp.api.collections[t](p,r),_.isUndefined(a.models[0])?a.fetch({success:function(e){d(e,o),c.resolve(e)},error:function(e,t){c.reject(t)}}):(d(a,o),c.resolve(a)),c.promise()):(c.reject(),c)}(t
|