-
Notifications
You must be signed in to change notification settings - Fork 0
client
Client (Browser) properties and methods for HTTP interactions
if ($.client.ie && $.client.version < 10) alert("You should try Chrome or Firefox");
Quick way to see if a URI allows a specific command
@param {String} uri URI to query
@param {String} command Command to query for
@return {Boolean} True if the command is allowed
Prototype
String.prototype.allows
Example
if (uri.allows("DELETE")) uri.del(function () {…}, function () {…});
Boolean indicating if the Client is Google Android based
Boolean indicating if the Client is RIM BlackBerry based
Boolean indicating if the Client is Google Chrome
Boolean indicating if the Client has CSS3 support
Modernizr offers robust feature detection, which exceeds this boolean
Makes a DELETE request to a URI
@param {String} uri URI to query
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@param {Object} headers [Optional] Custom request headers (can be used to set withCredentials)
@return {String} URI to query
Prototype
String.prototype.del
Events
afterXHR Fires after the XmlHttpRequest response has been handled
afterDelete Fires after the XmlHttpRequest response has been handled, type specific
beforeXHR Fires before the XmlHttpRequest is made
beforeDelete Fires before the XmlHttpRequest is made, type specific
failedDelete Fires on error
progressDelete Fires on progress
receivedDelete Fires on XHR readystate 2, clears the timeout only!
timeoutDelete Fires 30s after XmlHttpRequest is made
Example
uri.del(function () {…}, function () {…});
Garbage collection timeout for cached URI responses; takes effect after the next run
Boolean indicating if the Client is Mozilla Firefox
Makes a GET request to a URI
@param {String} uri URI to query
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@param {Object} headers [Optional] Custom request headers (can be used to set withCredentials)
@return {String} URI to query
Prototype
String.prototype.get
Events
afterXHR Fires after the XmlHttpRequest response has been handled
afterGet Fires after the XmlHttpRequest response has been handled, type specific
beforeXHR Fires before the XmlHttpRequest is made
beforeGet Fires before the XmlHttpRequest is made, type specific
failedGet Fires on error
progressGet Fires on progress
receivedGet Fires on XHR readystate 2, clears the timeout only!
timeoutGet Fires 30s after XmlHttpRequest is made
Example
uri.get(function () {…}, function () {…}, {Accepts: "application/json"});
Makes a HEAD request to a URI
@param {String} uri URI to query
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@return {String} URI to query
Prototype
String.prototype.headers
Events
afterXHR Fires after the XmlHttpRequest response has been handled
afterHead Fires after the XmlHttpRequest response has been handled, type specific
beforeXHR Fires before the XmlHttpRequest is made
beforeHead Fires before the XmlHttpRequest is made, type specific
failedHead Fires on error
progressHead Fires on progress
receivedHead Fires on XHR readystate 2, clears the timeout only!
timeoutHead Fires 30s after XmlHttpRequest is made
Example
uri.headers(function (arg) { $.log(arg); }, function () {…}); // Attempts to write the HTTP Headers (Object) to the console
Boolean indicating if the Client is Microsoft Internet Explorer
Boolean indicating if the Client is Apple iOS based
Creates a JSONP request
@param {String} uri URI to request
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@param {Mixed} args Custom JSONP handler parameter name, default is "callback"; or custom headers for GET request (CORS)
@return {String} URI to query
Prototype
String.prototype.jsonp
Events
beforeJSONP Fires before the SCRIPT is made
afterJSONP Fires after the SCRIPT is received
failedJSONP Fires on error
timeoutJSONP Fires 30s after SCRIPT is made
Example
uri.jsonp(function () {…}, function () {…});
Boolean indicating if the Client is Linux based
Boolean indicating if the Client is a Mobile Phone
Boolean indicating if the Client is Opera
Makes an OPTIONS request to a URI
@param {String} uri URI to query
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@return {String} URI to query
Prototype
String.prototype.options
Events
afterXHR Fires after the XmlHttpRequest response has been handled
afterOptions Fires after the XmlHttpRequest response has been handled, type specific
beforeXHR Fires before the XmlHttpRequest is made
beforeOptions Fires before the XmlHttpRequest is made, type specific
failedOptions Fires on error
progressOptions Fires on progress
receivedOptions Fires on XHR readystate 2, clears the timeout only!
timeoutOptions Fires 30s after XmlHttpRequest is made
Example
uri.options(function () {…}, function () {…}, $.json.encode({…}));
Boolean indicating if the Client is Apple OSX based
Returns the permission of the cached URI
@param {String} uri URI to query
@return {Object} Contains an Array of available commands, the permission bit and a map
Prototype
String.prototype.permissions
Events
var uriPermissions = uri.permissions();
Boolean indicating if the Client is HP Playbook based
Makes a POST request to a URI
@param {String} uri URI to query
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@param {Mixed} args Data to send with the request
@param {Object} headers [Optional] Custom request headers (can be used to set withCredentials)
@return {String} URI to query
Prototype
String.prototype.post
Events
afterXHR Fires after the XmlHttpRequest response has been handled
afterPost Fires after the XmlHttpRequest response has been handled, type specific
beforeXHR Fires before the XmlHttpRequest is made
beforePost Fires before the XmlHttpRequest is made, type specific
failedPost Fires on error
progressPost Fires on progress
receivedPost Fires on XHR readystate 2, clears the timeout only!
timeoutPost Fires 30s after XmlHttpRequest is made
Example
uri.post(function () {…}, function () {…}, $.json.encode({…}), {Accept: "application/json", "Content-Type": "application/json"});
Makes a PUT request to a URI
@param {String} uri URI to query
@param {Function} success A handler function to execute when an appropriate response been received
@param {Function} failure [Optional] A handler function to execute on error
@param {Mixed} args Data to send with the request
@param {Object} headers [Optional] Custom request headers (can be used to set withCredentials)
@return {String} URI to query
Prototype
String.prototype.put
Events
afterXHR Fires after the XmlHttpRequest response has been handled
afterPut Fires after the XmlHttpRequest response has been handled, type specific
beforeXHR Fires before the XmlHttpRequest is made
beforePut Fires before the XmlHttpRequest is made, type specific
failedPut Fires on error
progressPut Fires on progress
receivedPut Fires on XHR readystate 2, clears the timeout only!
timeoutPut Fires 30s after XmlHttpRequest is made
Example
uri.put(function () {…}, function () {…}, $.json.encode({…}), {Accept: "application/json", "Content-Type": "application/json"});
Boolean indicating if the Client is Apple Safari
Returns the visible area of the View
@return {Object} Describes the View {x: ?, y: ?}
Example
alert("You can see " + $.client.size.y + "px vertically");
Boolean indicating if the Client is a Tablet
Integer indicating the primary version of the Client
Boolean indicating if the Client is webOS based
Boolean indicating if the Client is Microsoft Windows based