0byt3m1n1
Path:
/
var
/
lib
/
vz
/
www
/
clients
/
client6
/
web11
/
web
/
wp-content
/
plugins
/
wp-google-maps
/
js
/
v8
/
[
Home
]
File: rest-api.js
/** * @namespace WPGMZA * @module WPGMZA.RestAPI * @requires WPGMZA */ jQuery(function($) { /** * Used to interact with the WordPress REST API. <strong>Please <em>do not</em> call this constructor directly. Always use createInstance rather than instantiating this class directly.</strong> Using createInstance allows this class to be externally extensible. * @class WPGMZA.RestAPI * @constructor WPGMZA.RestAPI * @memberof WPGMZA */ WPGMZA.RestAPI = function() { WPGMZA.RestAPI.URL = WPGMZA.resturl; } /** * Creates an instance of a RestAPI, <strong>please <em>always</em> use this function rather than calling the constructor directly</strong>. * @method * @memberof WPGMZA.RestAPI */ WPGMZA.RestAPI.createInstance = function() { return new WPGMZA.RestAPI(); } /** * Makes an AJAX to the REST API, this function is a wrapper for $.ajax * @method * @memberof WPGMZA.RestAPI * @param {string} route The REST API route * @param {object} params The request parameters, see http://api.jquery.com/jquery.ajax/ */ WPGMZA.RestAPI.prototype.call = function(route, params) { if(typeof route != "string" || !route.match(/^\//)) throw new Error("Invalid route"); if(WPGMZA.RestAPI.URL.match(/\/$/)) route = route.replace(/^\//, ""); if(!params) params = {}; params.beforeSend = function(xhr) { xhr.setRequestHeader('X-WP-Nonce', WPGMZA.restnonce); }; if(!params.error) params.error = function(xhr, status, message) { if(status == "abort") return; // Don't report abort, let it happen silently throw new Error(message); } return $.ajax(WPGMZA.RestAPI.URL + route, params); } var nativeCallFunction = WPGMZA.RestAPI.call; WPGMZA.RestAPI.call = function() { console.warn("WPGMZA.RestAPI.call was called statically, did you mean to call the function on WPGMZA.restAPI?"); nativeCallFunction.apply(this, arguments); } });