Skip to content
Browse files

gallery-2014.07.31-18-26 juandopazo gallery-io-utils

  • Loading branch information...
1 parent 7d1ae40 commit a3dd7b3552a4dc20bf672f8d88483867b6ea4bd8 @tripp tripp committed Jul 31, 2014
View
4 build/gallery-io-utils/gallery-io-utils-coverage.js
@@ -1,6 +1,6 @@
if (typeof __coverage__ === 'undefined') { __coverage__ = {}; }
if (!__coverage__['build/gallery-io-utils/gallery-io-utils.js']) {
- __coverage__['build/gallery-io-utils/gallery-io-utils.js'] = {"path":"build/gallery-io-utils/gallery-io-utils.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0],"9":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":47}}},"2":{"name":"(anonymous_2)","line":34,"loc":{"start":{"line":34,"column":11},"end":{"line":34,"column":35}}},"3":{"name":"(anonymous_3)","line":37,"loc":{"start":{"line":37,"column":25},"end":{"line":37,"column":52}}},"4":{"name":"(anonymous_4)","line":47,"loc":{"start":{"line":47,"column":25},"end":{"line":47,"column":49}}},"5":{"name":"(anonymous_5)","line":50,"loc":{"start":{"line":50,"column":25},"end":{"line":50,"column":49}}},"6":{"name":"(anonymous_6)","line":105,"loc":{"start":{"line":105,"column":47},"end":{"line":105,"column":65}}},"7":{"name":"(anonymous_7)","line":106,"loc":{"start":{"line":106,"column":19},"end":{"line":106,"column":43}}},"8":{"name":"(anonymous_8)","line":145,"loc":{"start":{"line":145,"column":16},"end":{"line":145,"column":50}}},"9":{"name":"(anonymous_9)","line":176,"loc":{"start":{"line":176,"column":32},"end":{"line":176,"column":50}}},"10":{"name":"(anonymous_10)","line":177,"loc":{"start":{"line":177,"column":19},"end":{"line":177,"column":43}}},"11":{"name":"(anonymous_11)","line":178,"loc":{"start":{"line":178,"column":33},"end":{"line":178,"column":60}}},"12":{"name":"(anonymous_12)","line":179,"loc":{"start":{"line":179,"column":40},"end":{"line":179,"column":68}}},"13":{"name":"(anonymous_13)","line":206,"loc":{"start":{"line":206,"column":13},"end":{"line":206,"column":37}}},"14":{"name":"(anonymous_14)","line":209,"loc":{"start":{"line":209,"column":25},"end":{"line":209,"column":52}}},"15":{"name":"(anonymous_15)","line":212,"loc":{"start":{"line":212,"column":25},"end":{"line":212,"column":41}}},"16":{"name":"(anonymous_16)","line":241,"loc":{"start":{"line":241,"column":12},"end":{"line":241,"column":36}}},"17":{"name":"(anonymous_17)","line":244,"loc":{"start":{"line":244,"column":30},"end":{"line":244,"column":45}}},"18":{"name":"(anonymous_18)","line":276,"loc":{"start":{"line":276,"column":32},"end":{"line":276,"column":48}}},"19":{"name":"(anonymous_19)","line":277,"loc":{"start":{"line":277,"column":26},"end":{"line":277,"column":49}}},"20":{"name":"(anonymous_20)","line":311,"loc":{"start":{"line":311,"column":30},"end":{"line":311,"column":46}}},"21":{"name":"(anonymous_21)","line":312,"loc":{"start":{"line":312,"column":26},"end":{"line":312,"column":55}}},"22":{"name":"(anonymous_22)","line":316,"loc":{"start":{"line":316,"column":28},"end":{"line":316,"column":43}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":324,"column":69}},"2":{"start":{"line":34,"column":0},"end":{"line":59,"column":2}},"3":{"start":{"line":35,"column":4},"end":{"line":35,"column":28}},"4":{"start":{"line":37,"column":4},"end":{"line":58,"column":7}},"5":{"start":{"line":38,"column":8},"end":{"line":54,"column":11}},"6":{"start":{"line":48,"column":20},"end":{"line":48,"column":38}},"7":{"start":{"line":51,"column":20},"end":{"line":51,"column":37}},"8":{"start":{"line":57,"column":8},"end":{"line":57,"column":30}},"9":{"start":{"line":105,"column":0},"end":{"line":112,"column":3}},"10":{"start":{"line":106,"column":4},"end":{"line":111,"column":6}},"11":{"start":{"line":107,"column":8},"end":{"line":107,"column":32}},"12":{"start":{"line":108,"column":8},"end":{"line":108,"column":46}},"13":{"start":{"line":110,"column":8},"end":{"line":110,"column":38}},"14":{"start":{"line":129,"column":0},"end":{"line":129,"column":40}},"15":{"start":{"line":145,"column":0},"end":{"line":154,"column":2}},"16":{"start":{"line":146,"column":4},"end":{"line":146,"column":28}},"17":{"start":{"line":148,"column":4},"end":{"line":148,"column":28}},"18":{"start":{"line":149,"column":4},"end":{"line":151,"column":6}},"19":{"start":{"line":153,"column":4},"end":{"line":153,"column":34}},"20":{"start":{"line":176,"column":0},"end":{"line":188,"column":3}},"21":{"start":{"line":177,"column":4},"end":{"line":187,"column":6}},"22":{"start":{"line":178,"column":8},"end":{"line":186,"column":11}},"23":{"start":{"line":179,"column":12},"end":{"line":185,"column":15}},"24":{"start":{"line":180,"column":16},"end":{"line":184,"column":17}},"25":{"start":{"line":181,"column":20},"end":{"line":181,"column":32}},"26":{"start":{"line":183,"column":20},"end":{"line":183,"column":41}},"27":{"start":{"line":206,"column":0},"end":{"line":227,"column":2}},"28":{"start":{"line":207,"column":4},"end":{"line":207,"column":28}},"29":{"start":{"line":209,"column":4},"end":{"line":226,"column":7}},"30":{"start":{"line":210,"column":8},"end":{"line":218,"column":10}},"31":{"start":{"line":213,"column":20},"end":{"line":213,"column":34}},"32":{"start":{"line":219,"column":8},"end":{"line":221,"column":9}},"33":{"start":{"line":220,"column":12},"end":{"line":220,"column":45}},"34":{"start":{"line":222,"column":8},"end":{"line":224,"column":9}},"35":{"start":{"line":223,"column":12},"end":{"line":223,"column":43}},"36":{"start":{"line":225,"column":8},"end":{"line":225,"column":29}},"37":{"start":{"line":241,"column":0},"end":{"line":250,"column":2}},"38":{"start":{"line":242,"column":4},"end":{"line":242,"column":41}},"39":{"start":{"line":244,"column":4},"end":{"line":249,"column":7}},"40":{"start":{"line":245,"column":8},"end":{"line":245,"column":46}},"41":{"start":{"line":276,"column":0},"end":{"line":283,"column":3}},"42":{"start":{"line":277,"column":4},"end":{"line":282,"column":6}},"43":{"start":{"line":278,"column":8},"end":{"line":278,"column":30}},"44":{"start":{"line":279,"column":8},"end":{"line":279,"column":43}},"45":{"start":{"line":281,"column":8},"end":{"line":281,"column":38}},"46":{"start":{"line":311,"column":0},"end":{"line":321,"column":3}},"47":{"start":{"line":312,"column":4},"end":{"line":320,"column":6}},"48":{"start":{"line":313,"column":8},"end":{"line":313,"column":30}},"49":{"start":{"line":314,"column":8},"end":{"line":314,"column":43}},"50":{"start":{"line":316,"column":8},"end":{"line":319,"column":11}},"51":{"start":{"line":317,"column":12},"end":{"line":317,"column":48}},"52":{"start":{"line":318,"column":12},"end":{"line":318,"column":42}}},"branchMap":{"1":{"line":35,"type":"binary-expr","locations":[{"start":{"line":35,"column":14},"end":{"line":35,"column":21}},{"start":{"line":35,"column":25},"end":{"line":35,"column":27}}]},"2":{"line":107,"type":"binary-expr","locations":[{"start":{"line":107,"column":18},"end":{"line":107,"column":25}},{"start":{"line":107,"column":29},"end":{"line":107,"column":31}}]},"3":{"line":146,"type":"binary-expr","locations":[{"start":{"line":146,"column":14},"end":{"line":146,"column":21}},{"start":{"line":146,"column":25},"end":{"line":146,"column":27}}]},"4":{"line":180,"type":"if","locations":[{"start":{"line":180,"column":16},"end":{"line":180,"column":16}},{"start":{"line":180,"column":16},"end":{"line":180,"column":16}}]},"5":{"line":207,"type":"binary-expr","locations":[{"start":{"line":207,"column":14},"end":{"line":207,"column":21}},{"start":{"line":207,"column":25},"end":{"line":207,"column":27}}]},"6":{"line":219,"type":"if","locations":[{"start":{"line":219,"column":8},"end":{"line":219,"column":8}},{"start":{"line":219,"column":8},"end":{"line":219,"column":8}}]},"7":{"line":222,"type":"if","locations":[{"start":{"line":222,"column":8},"end":{"line":222,"column":8}},{"start":{"line":222,"column":8},"end":{"line":222,"column":8}}]},"8":{"line":278,"type":"binary-expr","locations":[{"start":{"line":278,"column":17},"end":{"line":278,"column":23}},{"start":{"line":278,"column":27},"end":{"line":278,"column":29}}]},"9":{"line":313,"type":"binary-expr","locations":[{"start":{"line":313,"column":17},"end":{"line":313,"column":23}},{"start":{"line":313,"column":27},"end":{"line":313,"column":29}}]}},"code":["(function () { YUI.add('gallery-io-utils', function (Y, NAME) {","","/**","Promise based methods for performing IO requests.","","@module gallery-io-utils","**/","","/**","Method for initiating an ajax call.","","@method xhr","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Configuration object for the transaction.","@param {String} [options.method=GET] HTTP method verb (e.g., GET or POST).","@param {Object|String} [options.data] This is the name-value string that will be"," sent as the transaction data. If the request is HTTP GET, the data become"," part of querystring. If HTTP POST, the data are sent in the message body.","@param {Object} [options.form] Form serialization configuration object. Its properties"," are:"," * `id` node object or id of HTML form"," * `useDisabled` true to also serialize disabled form field values (defaults"," to false)","@param {Object} [options.headers] Object map of transaction headers to send to"," the server. The object keys are the header names and the values are the"," header values.","@param {Number} [options.timeout] Millisecond threshold for the transaction"," before being automatically aborted.","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","Y.io.xhr = function (uri, options) {"," options = options || {};",""," return new Y.Promise(function (resolve, reject) {"," var io = Y.io(uri, {"," // reference options directly to avoid insertion of unwanted options"," // into Y.io()"," method: options.method,"," data: options.data,"," headers: options.headers,"," form: options.form,"," timeout: options.timeout,"," on: {"," success: function (id, response) {"," resolve(response);"," },"," failure: function (id, response) {"," reject(response);"," }"," }"," });",""," // expose abort. It is not a prototype function so it's ok to copy it"," this.abort = io.abort;"," });","};","","/**","Initiaites an AJAX call with the HTTP method GET.","","@method get","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","/**","Initiaites an AJAX call with the HTTP method POST.","","@method post","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","/**","Initiaites an AJAX call with the HTTP method PUT.","","@method put","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","/**","Initiaites an AJAX call with the HTTP method DELETE.","","@method delete","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","Y.Array.each(['get', 'post', 'put', 'delete'], function (method) {"," Y.io[method] = function (uri, options) {"," options = options || {};"," options.method = method.toUpperCase();",""," return Y.io.xhr(uri, options);"," };","});","","/**","Alias for Y.io.delete()","","@method DELETE","@for io","@static","@deprecated","**/","/**","Alias for Y.io.delete()","","@method del","@for io","@static","**/","Y.io.DELETE = Y.io.del = Y.io['delete'];","","/**","Initiaites an AJAX call with the HTTP method POST and sends the data contained","in the specified form element.","","@method postForm","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {String|Node} selector CSS selector or Y.Node instance pointing to a form"," element.","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","Y.io.postForm = function (uri, selector, options) {"," options = options || {};",""," options.method = 'POST';"," options.form = {"," id: Y.one(selector)"," };",""," return Y.io.xhr(uri, options);","};","","/**","Inserts one or more scripts tags.","","@method script","@for io","@static","@param {String|String[]} uri Path or array of paths to the scripts.","@param {Object} [options] Configuration options","@return {Promise} Promise for the response object.","**/","/**","Inserts one or more CSS files into the page.","","@method css","@for io","@static","@param {String|String[]} uri Path or array of paths to the CSS files.","@param {Object} [options] Configuration options","@return {Promise} Promise for the response object.","**/","Y.Array.each(['script', 'css'], function (method) {"," Y.io[method] = function (uri, options) {"," return this._transaction(function (resolve, reject) {"," Y.Get[method](uri, options, function (err, transaction) {"," if (err) {"," reject(err);"," } else {"," resolve(transaction);"," }"," });"," });"," };","});","","/**","Performs a JSONP request. Requires the JSONP module.","","@method jsonp","@for io","@static","@param {String} uri The url of the JSONP service with the {callback}"," placeholder where the callback function name typically goes","@param {Object} [options] Configuration options for the request","@param {Number} [options.timeout] Millisecond threshold for the transaction"," before being automatically aborted","@param {Function} [options.format] Preprocessor function to stitch together"," the supplied URL (first argument), the proxy function name (internally"," generated), and any additional arguments passed to JSONPRequest#send()","@return {Promise} Promise for the response object.","**/","Y.io.jsonp = function (uri, options) {"," options = options || {};",""," return new Y.Promise(function (resolve, reject) {"," var config = {"," on: {"," success: function (data) {"," resolve(data);"," },"," failure: reject,"," timeout: reject"," }"," };"," if (options.timeout) {"," config.timeout = options.timeout;"," }"," if (options.format) {"," config.format = options.format;"," }"," Y.jsonp(uri, config);"," });","};","","/**","Performs an AJAX request and parses the response as JSON notation.","Requires the JSON module.","","@method json","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","Y.io.json = function (uri, options) {"," var promise = Y.io.xhr(uri, options);",""," return Y.mix(promise.then(function (xhr) {"," return Y.JSON.parse(xhr.responseText);"," }), {"," // pass around the abort function"," abort: promise.abort"," });","};","","/**","Performs an AJAX request with the GET HTTP method and parses the response as","JSON notation. Requires the JSON module.","","@method getJSON","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","/**","Performs an AJAX request with the DELETE HTTP method and parses the response as","JSON notation. Requires the JSON module.","","@method deleteJSON","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","Y.Array.each(['get', 'delete'], function (verb) {"," Y.io[verb + 'JSON'] = function (uri, config) {"," config = config || {};"," config.method = verb.toUpperCase();",""," return Y.io.json(uri, config);"," };","});","","/**","Performs an AJAX request with the POST HTTP method and parses the response as","JSON notation. Requires the JSON module.","","@method postJSON","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object|Promise} data Data to send encoded as JSON","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","/**","Performs an AJAX request with the PUT HTTP method and parses the response as","JSON notation. Requires the JSON module.","","@method putJSON","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object|Promise} data Data to send encoded as JSON","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","Y.Array.each(['post', 'put'], function (verb) {"," Y.io[verb + 'JSON'] = function (uri, data, config) {"," config = config || {};"," config.method = verb.toUpperCase();",""," return Y.when(data, function (obj) {"," config.data = Y.JSON.stringify(obj);"," return Y.io.json(uri, config);"," });"," };","});","","","}, 'gallery-2013.05.29-23-38', {\"requires\": [\"io-base\", \"promise\"]});","","}());"]};
+ __coverage__['build/gallery-io-utils/gallery-io-utils.js'] = {"path":"build/gallery-io-utils/gallery-io-utils.js","s":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0,"23":0,"24":0,"25":0,"26":0,"27":0,"28":0,"29":0,"30":0,"31":0,"32":0,"33":0,"34":0,"35":0,"36":0,"37":0,"38":0,"39":0,"40":0,"41":0,"42":0,"43":0,"44":0,"45":0,"46":0,"47":0,"48":0,"49":0,"50":0,"51":0,"52":0,"53":0,"54":0,"55":0,"56":0,"57":0,"58":0,"59":0,"60":0,"61":0},"b":{"1":[0,0],"2":[0,0],"3":[0,0],"4":[0,0],"5":[0,0],"6":[0,0],"7":[0,0],"8":[0,0],"9":[0,0],"10":[0,0],"11":[0,0],"12":[0,0],"13":[0,0],"14":[0,0]},"f":{"1":0,"2":0,"3":0,"4":0,"5":0,"6":0,"7":0,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":0,"17":0,"18":0,"19":0,"20":0,"21":0,"22":0},"fnMap":{"1":{"name":"(anonymous_1)","line":1,"loc":{"start":{"line":1,"column":28},"end":{"line":1,"column":47}}},"2":{"name":"(anonymous_2)","line":37,"loc":{"start":{"line":37,"column":11},"end":{"line":37,"column":35}}},"3":{"name":"(anonymous_3)","line":40,"loc":{"start":{"line":40,"column":25},"end":{"line":40,"column":52}}},"4":{"name":"(anonymous_4)","line":50,"loc":{"start":{"line":50,"column":25},"end":{"line":50,"column":49}}},"5":{"name":"(anonymous_5)","line":53,"loc":{"start":{"line":53,"column":25},"end":{"line":53,"column":49}}},"6":{"name":"(anonymous_6)","line":108,"loc":{"start":{"line":108,"column":47},"end":{"line":108,"column":65}}},"7":{"name":"(anonymous_7)","line":109,"loc":{"start":{"line":109,"column":19},"end":{"line":109,"column":43}}},"8":{"name":"(anonymous_8)","line":140,"loc":{"start":{"line":140,"column":16},"end":{"line":140,"column":50}}},"9":{"name":"(anonymous_9)","line":171,"loc":{"start":{"line":171,"column":32},"end":{"line":171,"column":50}}},"10":{"name":"(anonymous_10)","line":172,"loc":{"start":{"line":172,"column":19},"end":{"line":172,"column":43}}},"11":{"name":"(anonymous_11)","line":173,"loc":{"start":{"line":173,"column":33},"end":{"line":173,"column":60}}},"12":{"name":"(anonymous_12)","line":174,"loc":{"start":{"line":174,"column":40},"end":{"line":174,"column":68}}},"13":{"name":"(anonymous_13)","line":201,"loc":{"start":{"line":201,"column":13},"end":{"line":201,"column":37}}},"14":{"name":"(anonymous_14)","line":204,"loc":{"start":{"line":204,"column":25},"end":{"line":204,"column":52}}},"15":{"name":"(anonymous_15)","line":207,"loc":{"start":{"line":207,"column":25},"end":{"line":207,"column":41}}},"16":{"name":"(anonymous_16)","line":238,"loc":{"start":{"line":238,"column":12},"end":{"line":238,"column":36}}},"17":{"name":"(anonymous_17)","line":250,"loc":{"start":{"line":250,"column":30},"end":{"line":250,"column":45}}},"18":{"name":"(anonymous_18)","line":282,"loc":{"start":{"line":282,"column":32},"end":{"line":282,"column":48}}},"19":{"name":"(anonymous_19)","line":283,"loc":{"start":{"line":283,"column":26},"end":{"line":283,"column":50}}},"20":{"name":"(anonymous_20)","line":317,"loc":{"start":{"line":317,"column":30},"end":{"line":317,"column":46}}},"21":{"name":"(anonymous_21)","line":318,"loc":{"start":{"line":318,"column":26},"end":{"line":318,"column":56}}},"22":{"name":"(anonymous_22)","line":329,"loc":{"start":{"line":329,"column":28},"end":{"line":329,"column":43}}}},"statementMap":{"1":{"start":{"line":1,"column":0},"end":{"line":338,"column":69}},"2":{"start":{"line":9,"column":0},"end":{"line":10,"column":34}},"3":{"start":{"line":37,"column":0},"end":{"line":62,"column":2}},"4":{"start":{"line":38,"column":4},"end":{"line":38,"column":28}},"5":{"start":{"line":40,"column":4},"end":{"line":61,"column":7}},"6":{"start":{"line":41,"column":8},"end":{"line":57,"column":11}},"7":{"start":{"line":51,"column":20},"end":{"line":51,"column":38}},"8":{"start":{"line":54,"column":20},"end":{"line":54,"column":37}},"9":{"start":{"line":60,"column":8},"end":{"line":60,"column":30}},"10":{"start":{"line":108,"column":0},"end":{"line":115,"column":3}},"11":{"start":{"line":109,"column":4},"end":{"line":114,"column":6}},"12":{"start":{"line":110,"column":8},"end":{"line":110,"column":32}},"13":{"start":{"line":111,"column":8},"end":{"line":111,"column":46}},"14":{"start":{"line":113,"column":8},"end":{"line":113,"column":38}},"15":{"start":{"line":124,"column":0},"end":{"line":124,"column":26}},"16":{"start":{"line":140,"column":0},"end":{"line":149,"column":2}},"17":{"start":{"line":141,"column":4},"end":{"line":141,"column":28}},"18":{"start":{"line":143,"column":4},"end":{"line":143,"column":28}},"19":{"start":{"line":144,"column":4},"end":{"line":146,"column":6}},"20":{"start":{"line":148,"column":4},"end":{"line":148,"column":34}},"21":{"start":{"line":171,"column":0},"end":{"line":183,"column":3}},"22":{"start":{"line":172,"column":4},"end":{"line":182,"column":6}},"23":{"start":{"line":173,"column":8},"end":{"line":181,"column":11}},"24":{"start":{"line":174,"column":12},"end":{"line":180,"column":15}},"25":{"start":{"line":175,"column":16},"end":{"line":179,"column":17}},"26":{"start":{"line":176,"column":20},"end":{"line":176,"column":32}},"27":{"start":{"line":178,"column":20},"end":{"line":178,"column":41}},"28":{"start":{"line":201,"column":0},"end":{"line":222,"column":2}},"29":{"start":{"line":202,"column":4},"end":{"line":202,"column":28}},"30":{"start":{"line":204,"column":4},"end":{"line":221,"column":7}},"31":{"start":{"line":205,"column":8},"end":{"line":213,"column":10}},"32":{"start":{"line":208,"column":20},"end":{"line":208,"column":34}},"33":{"start":{"line":214,"column":8},"end":{"line":216,"column":9}},"34":{"start":{"line":215,"column":12},"end":{"line":215,"column":45}},"35":{"start":{"line":217,"column":8},"end":{"line":219,"column":9}},"36":{"start":{"line":218,"column":12},"end":{"line":218,"column":43}},"37":{"start":{"line":220,"column":8},"end":{"line":220,"column":29}},"38":{"start":{"line":238,"column":0},"end":{"line":256,"column":2}},"39":{"start":{"line":239,"column":4},"end":{"line":239,"column":28}},"40":{"start":{"line":243,"column":4},"end":{"line":245,"column":5}},"41":{"start":{"line":244,"column":8},"end":{"line":244,"column":29}},"42":{"start":{"line":246,"column":4},"end":{"line":246,"column":39}},"43":{"start":{"line":248,"column":4},"end":{"line":248,"column":41}},"44":{"start":{"line":250,"column":4},"end":{"line":255,"column":7}},"45":{"start":{"line":251,"column":8},"end":{"line":251,"column":63}},"46":{"start":{"line":282,"column":0},"end":{"line":289,"column":3}},"47":{"start":{"line":283,"column":4},"end":{"line":288,"column":6}},"48":{"start":{"line":284,"column":8},"end":{"line":284,"column":32}},"49":{"start":{"line":285,"column":8},"end":{"line":285,"column":44}},"50":{"start":{"line":287,"column":8},"end":{"line":287,"column":39}},"51":{"start":{"line":317,"column":0},"end":{"line":335,"column":3}},"52":{"start":{"line":318,"column":4},"end":{"line":334,"column":6}},"53":{"start":{"line":319,"column":8},"end":{"line":319,"column":32}},"54":{"start":{"line":320,"column":8},"end":{"line":320,"column":44}},"55":{"start":{"line":322,"column":8},"end":{"line":324,"column":9}},"56":{"start":{"line":323,"column":12},"end":{"line":323,"column":33}},"57":{"start":{"line":325,"column":8},"end":{"line":327,"column":9}},"58":{"start":{"line":326,"column":12},"end":{"line":326,"column":54}},"59":{"start":{"line":329,"column":8},"end":{"line":333,"column":11}},"60":{"start":{"line":330,"column":12},"end":{"line":331,"column":56}},"61":{"start":{"line":332,"column":12},"end":{"line":332,"column":43}}},"branchMap":{"1":{"line":38,"type":"binary-expr","locations":[{"start":{"line":38,"column":14},"end":{"line":38,"column":21}},{"start":{"line":38,"column":25},"end":{"line":38,"column":27}}]},"2":{"line":110,"type":"binary-expr","locations":[{"start":{"line":110,"column":18},"end":{"line":110,"column":25}},{"start":{"line":110,"column":29},"end":{"line":110,"column":31}}]},"3":{"line":141,"type":"binary-expr","locations":[{"start":{"line":141,"column":14},"end":{"line":141,"column":21}},{"start":{"line":141,"column":25},"end":{"line":141,"column":27}}]},"4":{"line":175,"type":"if","locations":[{"start":{"line":175,"column":16},"end":{"line":175,"column":16}},{"start":{"line":175,"column":16},"end":{"line":175,"column":16}}]},"5":{"line":202,"type":"binary-expr","locations":[{"start":{"line":202,"column":14},"end":{"line":202,"column":21}},{"start":{"line":202,"column":25},"end":{"line":202,"column":27}}]},"6":{"line":214,"type":"if","locations":[{"start":{"line":214,"column":8},"end":{"line":214,"column":8}},{"start":{"line":214,"column":8},"end":{"line":214,"column":8}}]},"7":{"line":217,"type":"if","locations":[{"start":{"line":217,"column":8},"end":{"line":217,"column":8}},{"start":{"line":217,"column":8},"end":{"line":217,"column":8}}]},"8":{"line":239,"type":"binary-expr","locations":[{"start":{"line":239,"column":14},"end":{"line":239,"column":21}},{"start":{"line":239,"column":25},"end":{"line":239,"column":27}}]},"9":{"line":243,"type":"if","locations":[{"start":{"line":243,"column":4},"end":{"line":243,"column":4}},{"start":{"line":243,"column":4},"end":{"line":243,"column":4}}]},"10":{"line":284,"type":"binary-expr","locations":[{"start":{"line":284,"column":18},"end":{"line":284,"column":25}},{"start":{"line":284,"column":29},"end":{"line":284,"column":31}}]},"11":{"line":319,"type":"binary-expr","locations":[{"start":{"line":319,"column":18},"end":{"line":319,"column":25}},{"start":{"line":319,"column":29},"end":{"line":319,"column":31}}]},"12":{"line":322,"type":"if","locations":[{"start":{"line":322,"column":8},"end":{"line":322,"column":8}},{"start":{"line":322,"column":8},"end":{"line":322,"column":8}}]},"13":{"line":325,"type":"if","locations":[{"start":{"line":325,"column":8},"end":{"line":325,"column":8}},{"start":{"line":325,"column":8},"end":{"line":325,"column":8}}]},"14":{"line":330,"type":"cond-expr","locations":[{"start":{"line":331,"column":28},"end":{"line":331,"column":49}},{"start":{"line":331,"column":52},"end":{"line":331,"column":55}}]}},"code":["(function () { YUI.add('gallery-io-utils', function (Y, NAME) {","","/**","Promise based methods for performing IO requests.","","@module gallery-io-utils","**/","","var MIME_JSON = 'application/json',"," CONTENT_TYPE = 'Content-Type';","","/**","Method for initiating an ajax call.","","@method xhr","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Configuration object for the transaction.","@param {String} [options.method=GET] HTTP method verb (e.g., GET or POST).","@param {Object|String} [options.data] This is the name-value string that will be"," sent as the transaction data. If the request is HTTP GET, the data become"," part of querystring. If HTTP POST, the data are sent in the message body.","@param {Object} [options.form] Form serialization configuration object. Its properties"," are:"," * `id` node object or id of HTML form"," * `useDisabled` true to also serialize disabled form field values (defaults"," to false)","@param {Object} [options.headers] Object map of transaction headers to send to"," the server. The object keys are the header names and the values are the"," header values.","@param {Number} [options.timeout] Millisecond threshold for the transaction"," before being automatically aborted.","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","Y.io.xhr = function (uri, options) {"," options = options || {};",""," return new Y.Promise(function (resolve, reject) {"," var io = Y.io(uri, {"," // reference options directly to avoid insertion of unwanted options"," // into Y.io()"," method: options.method,"," data: options.data,"," headers: options.headers,"," form: options.form,"," timeout: options.timeout,"," on: {"," success: function (id, response) {"," resolve(response);"," },"," failure: function (id, response) {"," reject(response);"," }"," }"," });",""," // expose abort. It is not a prototype function so it's ok to copy it"," this.abort = io.abort;"," });","};","","/**","Initiaites an AJAX call with the HTTP method GET.","","@method get","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","/**","Initiaites an AJAX call with the HTTP method POST.","","@method post","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","/**","Initiaites an AJAX call with the HTTP method PUT.","","@method put","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","/**","Initiaites an AJAX call with the HTTP method DELETE.","","@method delete","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","Y.Array.each(['get', 'post', 'put', 'delete'], function (method) {"," Y.io[method] = function (uri, options) {"," options = options || {};"," options.method = method.toUpperCase();",""," return Y.io.xhr(uri, options);"," };","});","","/**","Alias for Y.io.delete()","","@method del","@for io","@static","**/","Y.io.del = Y.io['delete'];","","/**","Initiaites an AJAX call with the HTTP method POST and sends the data contained","in the specified form element.","","@method postForm","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {String|Node} selector CSS selector or Y.Node instance pointing to a form"," element.","@param {Object} [options] Same configuration options as Y.io.xhr()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","Y.io.postForm = function (uri, selector, options) {"," options = options || {};",""," options.method = 'POST';"," options.form = {"," id: Y.one(selector)"," };",""," return Y.io.xhr(uri, options);","};","","/**","Inserts one or more scripts tags.","","@method script","@for io","@static","@param {String|String[]} uri Path or array of paths to the scripts.","@param {Object} [options] Configuration options","@return {Promise} Promise for the response object.","**/","/**","Inserts one or more CSS files into the page.","","@method css","@for io","@static","@param {String|String[]} uri Path or array of paths to the CSS files.","@param {Object} [options] Configuration options","@return {Promise} Promise for the response object.","**/","Y.Array.each(['script', 'css'], function (method) {"," Y.io[method] = function (uri, options) {"," return this._transaction(function (resolve, reject) {"," Y.Get[method](uri, options, function (err, transaction) {"," if (err) {"," reject(err);"," } else {"," resolve(transaction);"," }"," });"," });"," };","});","","/**","Performs a JSONP request. Requires the JSONP module.","","@method jsonp","@for io","@static","@param {String} uri The url of the JSONP service with the {callback}"," placeholder where the callback function name typically goes","@param {Object} [options] Configuration options for the request","@param {Number} [options.timeout] Millisecond threshold for the transaction"," before being automatically aborted","@param {Function} [options.format] Preprocessor function to stitch together"," the supplied URL (first argument), the proxy function name (internally"," generated), and any additional arguments passed to JSONPRequest#send()","@return {Promise} Promise for the response object.","**/","Y.io.jsonp = function (uri, options) {"," options = options || {};",""," return new Y.Promise(function (resolve, reject) {"," var config = {"," on: {"," success: function (data) {"," resolve(data);"," },"," failure: reject,"," timeout: reject"," }"," };"," if (options.timeout) {"," config.timeout = options.timeout;"," }"," if (options.format) {"," config.format = options.format;"," }"," Y.jsonp(uri, config);"," });","};","","/**","Performs an AJAX request and parses the response as JSON notation.","Requires the JSON module.","","@method json","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Same configuration options as Y.io.xhr() with an extra"," `reviver` option which is a reviver function for the `JSON.parse`"," algorithm.","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","Y.io.json = function (uri, options) {"," options = options || {};",""," // Force the use of the correct headers"," // Since a JSON response is expected, ask for it with the Accept header"," if (!options.headers) {"," options.headers = {};"," }"," options.headers.Accept = MIME_JSON;",""," var promise = Y.io.xhr(uri, options);",""," return Y.mix(promise.then(function (xhr) {"," return Y.JSON.parse(xhr.responseText, options.reviver);"," }), {"," // pass around the abort function"," abort: promise.abort"," });","};","","/**","Performs an AJAX request with the GET HTTP method and parses the response as","JSON notation. Requires the JSON module.","","@method getJSON","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Same configuration options as Y.io.json()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","/**","Performs an AJAX request with the DELETE HTTP method and parses the response as","JSON notation. Requires the JSON module.","","@method deleteJSON","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object} [options] Same configuration options as Y.io.json()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","Y.Array.each(['get', 'delete'], function (verb) {"," Y.io[verb + 'JSON'] = function (uri, options) {"," options = options || {};"," options.method = verb.toUpperCase();",""," return Y.io.json(uri, options);"," };","});","","/**","Performs an AJAX request with the POST HTTP method and parses the response as","JSON notation. Requires the JSON module.","","@method postJSON","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object|Promise} data Data to send encoded as JSON","@param {Object} [options] Same configuration options as Y.io.json()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","/**","Performs an AJAX request with the PUT HTTP method and parses the response as","JSON notation. Requires the JSON module.","","@method putJSON","@for io","@static","@param {String} uri Qualified path to transaction resource.","@param {Object|Promise} data Data to send encoded as JSON","@param {Object} [options] Same configuration options as Y.io.json()","@return {Promise} Promise for the response object. Contains an extra"," `abort()` method to cancel the request.","**/","Y.Array.each(['post', 'put'], function (verb) {"," Y.io[verb + 'JSON'] = function (uri, data, options) {"," options = options || {};"," options.method = verb.toUpperCase();",""," if (!options.headers) {"," options.headers = {};"," }"," if (!options.headers[CONTENT_TYPE]) {"," options.headers[CONTENT_TYPE] = MIME_JSON;"," }",""," return Y.when(data, function (obj) {"," options.data = options.headers[CONTENT_TYPE] === MIME_JSON ?"," Y.JSON.stringify(obj) : obj;"," return Y.io.json(uri, options);"," });"," };","});","","","}, 'gallery-2014.07.31-18-26', {\"requires\": [\"io-base\", \"promise\"]});","","}());"]};
}
var __cov_ZDNunBkuHRbaig7uXTJwiA = __coverage__['build/gallery-io-utils/gallery-io-utils.js'];
-__cov_ZDNunBkuHRbaig7uXTJwiA.s['1']++;YUI.add('gallery-io-utils',function(Y,NAME){__cov_ZDNunBkuHRbaig7uXTJwiA.f['1']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['2']++;Y.io.xhr=function(uri,options){__cov_ZDNunBkuHRbaig7uXTJwiA.f['2']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['3']++;options=(__cov_ZDNunBkuHRbaig7uXTJwiA.b['1'][0]++,options)||(__cov_ZDNunBkuHRbaig7uXTJwiA.b['1'][1]++,{});__cov_ZDNunBkuHRbaig7uXTJwiA.s['4']++;return new Y.Promise(function(resolve,reject){__cov_ZDNunBkuHRbaig7uXTJwiA.f['3']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['5']++;var io=Y.io(uri,{method:options.method,data:options.data,headers:options.headers,form:options.form,timeout:options.timeout,on:{success:function(id,response){__cov_ZDNunBkuHRbaig7uXTJwiA.f['4']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['6']++;resolve(response);},failure:function(id,response){__cov_ZDNunBkuHRbaig7uXTJwiA.f['5']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['7']++;reject(response);}}});__cov_ZDNunBkuHRbaig7uXTJwiA.s['8']++;this.abort=io.abort;});};__cov_ZDNunBkuHRbaig7uXTJwiA.s['9']++;Y.Array.each(['get','post','put','delete'],function(method){__cov_ZDNunBkuHRbaig7uXTJwiA.f['6']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['10']++;Y.io[method]=function(uri,options){__cov_ZDNunBkuHRbaig7uXTJwiA.f['7']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['11']++;options=(__cov_ZDNunBkuHRbaig7uXTJwiA.b['2'][0]++,options)||(__cov_ZDNunBkuHRbaig7uXTJwiA.b['2'][1]++,{});__cov_ZDNunBkuHRbaig7uXTJwiA.s['12']++;options.method=method.toUpperCase();__cov_ZDNunBkuHRbaig7uXTJwiA.s['13']++;return Y.io.xhr(uri,options);};});__cov_ZDNunBkuHRbaig7uXTJwiA.s['14']++;Y.io.DELETE=Y.io.del=Y.io['delete'];__cov_ZDNunBkuHRbaig7uXTJwiA.s['15']++;Y.io.postForm=function(uri,selector,options){__cov_ZDNunBkuHRbaig7uXTJwiA.f['8']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['16']++;options=(__cov_ZDNunBkuHRbaig7uXTJwiA.b['3'][0]++,options)||(__cov_ZDNunBkuHRbaig7uXTJwiA.b['3'][1]++,{});__cov_ZDNunBkuHRbaig7uXTJwiA.s['17']++;options.method='POST';__cov_ZDNunBkuHRbaig7uXTJwiA.s['18']++;options.form={id:Y.one(selector)};__cov_ZDNunBkuHRbaig7uXTJwiA.s['19']++;return Y.io.xhr(uri,options);};__cov_ZDNunBkuHRbaig7uXTJwiA.s['20']++;Y.Array.each(['script','css'],function(method){__cov_ZDNunBkuHRbaig7uXTJwiA.f['9']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['21']++;Y.io[method]=function(uri,options){__cov_ZDNunBkuHRbaig7uXTJwiA.f['10']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['22']++;return this._transaction(function(resolve,reject){__cov_ZDNunBkuHRbaig7uXTJwiA.f['11']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['23']++;Y.Get[method](uri,options,function(err,transaction){__cov_ZDNunBkuHRbaig7uXTJwiA.f['12']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['24']++;if(err){__cov_ZDNunBkuHRbaig7uXTJwiA.b['4'][0]++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['25']++;reject(err);}else{__cov_ZDNunBkuHRbaig7uXTJwiA.b['4'][1]++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['26']++;resolve(transaction);}});});};});__cov_ZDNunBkuHRbaig7uXTJwiA.s['27']++;Y.io.jsonp=function(uri,options){__cov_ZDNunBkuHRbaig7uXTJwiA.f['13']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['28']++;options=(__cov_ZDNunBkuHRbaig7uXTJwiA.b['5'][0]++,options)||(__cov_ZDNunBkuHRbaig7uXTJwiA.b['5'][1]++,{});__cov_ZDNunBkuHRbaig7uXTJwiA.s['29']++;return new Y.Promise(function(resolve,reject){__cov_ZDNunBkuHRbaig7uXTJwiA.f['14']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['30']++;var config={on:{success:function(data){__cov_ZDNunBkuHRbaig7uXTJwiA.f['15']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['31']++;resolve(data);},failure:reject,timeout:reject}};__cov_ZDNunBkuHRbaig7uXTJwiA.s['32']++;if(options.timeout){__cov_ZDNunBkuHRbaig7uXTJwiA.b['6'][0]++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['33']++;config.timeout=options.timeout;}else{__cov_ZDNunBkuHRbaig7uXTJwiA.b['6'][1]++;}__cov_ZDNunBkuHRbaig7uXTJwiA.s['34']++;if(options.format){__cov_ZDNunBkuHRbaig7uXTJwiA.b['7'][0]++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['35']++;config.format=options.format;}else{__cov_ZDNunBkuHRbaig7uXTJwiA.b['7'][1]++;}__cov_ZDNunBkuHRbaig7uXTJwiA.s['36']++;Y.jsonp(uri,config);});};__cov_ZDNunBkuHRbaig7uXTJwiA.s['37']++;Y.io.json=function(uri,options){__cov_ZDNunBkuHRbaig7uXTJwiA.f['16']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['38']++;var promise=Y.io.xhr(uri,options);__cov_ZDNunBkuHRbaig7uXTJwiA.s['39']++;return Y.mix(promise.then(function(xhr){__cov_ZDNunBkuHRbaig7uXTJwiA.f['17']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['40']++;return Y.JSON.parse(xhr.responseText);}),{abort:promise.abort});};__cov_ZDNunBkuHRbaig7uXTJwiA.s['41']++;Y.Array.each(['get','delete'],function(verb){__cov_ZDNunBkuHRbaig7uXTJwiA.f['18']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['42']++;Y.io[verb+'JSON']=function(uri,config){__cov_ZDNunBkuHRbaig7uXTJwiA.f['19']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['43']++;config=(__cov_ZDNunBkuHRbaig7uXTJwiA.b['8'][0]++,config)||(__cov_ZDNunBkuHRbaig7uXTJwiA.b['8'][1]++,{});__cov_ZDNunBkuHRbaig7uXTJwiA.s['44']++;config.method=verb.toUpperCase();__cov_ZDNunBkuHRbaig7uXTJwiA.s['45']++;return Y.io.json(uri,config);};});__cov_ZDNunBkuHRbaig7uXTJwiA.s['46']++;Y.Array.each(['post','put'],function(verb){__cov_ZDNunBkuHRbaig7uXTJwiA.f['20']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['47']++;Y.io[verb+'JSON']=function(uri,data,config){__cov_ZDNunBkuHRbaig7uXTJwiA.f['21']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['48']++;config=(__cov_ZDNunBkuHRbaig7uXTJwiA.b['9'][0]++,config)||(__cov_ZDNunBkuHRbaig7uXTJwiA.b['9'][1]++,{});__cov_ZDNunBkuHRbaig7uXTJwiA.s['49']++;config.method=verb.toUpperCase();__cov_ZDNunBkuHRbaig7uXTJwiA.s['50']++;return Y.when(data,function(obj){__cov_ZDNunBkuHRbaig7uXTJwiA.f['22']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['51']++;config.data=Y.JSON.stringify(obj);__cov_ZDNunBkuHRbaig7uXTJwiA.s['52']++;return Y.io.json(uri,config);});};});},'gallery-2013.05.29-23-38',{'requires':['io-base','promise']});
+__cov_ZDNunBkuHRbaig7uXTJwiA.s['1']++;YUI.add('gallery-io-utils',function(Y,NAME){__cov_ZDNunBkuHRbaig7uXTJwiA.f['1']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['2']++;var MIME_JSON='application/json',CONTENT_TYPE='Content-Type';__cov_ZDNunBkuHRbaig7uXTJwiA.s['3']++;Y.io.xhr=function(uri,options){__cov_ZDNunBkuHRbaig7uXTJwiA.f['2']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['4']++;options=(__cov_ZDNunBkuHRbaig7uXTJwiA.b['1'][0]++,options)||(__cov_ZDNunBkuHRbaig7uXTJwiA.b['1'][1]++,{});__cov_ZDNunBkuHRbaig7uXTJwiA.s['5']++;return new Y.Promise(function(resolve,reject){__cov_ZDNunBkuHRbaig7uXTJwiA.f['3']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['6']++;var io=Y.io(uri,{method:options.method,data:options.data,headers:options.headers,form:options.form,timeout:options.timeout,on:{success:function(id,response){__cov_ZDNunBkuHRbaig7uXTJwiA.f['4']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['7']++;resolve(response);},failure:function(id,response){__cov_ZDNunBkuHRbaig7uXTJwiA.f['5']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['8']++;reject(response);}}});__cov_ZDNunBkuHRbaig7uXTJwiA.s['9']++;this.abort=io.abort;});};__cov_ZDNunBkuHRbaig7uXTJwiA.s['10']++;Y.Array.each(['get','post','put','delete'],function(method){__cov_ZDNunBkuHRbaig7uXTJwiA.f['6']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['11']++;Y.io[method]=function(uri,options){__cov_ZDNunBkuHRbaig7uXTJwiA.f['7']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['12']++;options=(__cov_ZDNunBkuHRbaig7uXTJwiA.b['2'][0]++,options)||(__cov_ZDNunBkuHRbaig7uXTJwiA.b['2'][1]++,{});__cov_ZDNunBkuHRbaig7uXTJwiA.s['13']++;options.method=method.toUpperCase();__cov_ZDNunBkuHRbaig7uXTJwiA.s['14']++;return Y.io.xhr(uri,options);};});__cov_ZDNunBkuHRbaig7uXTJwiA.s['15']++;Y.io.del=Y.io['delete'];__cov_ZDNunBkuHRbaig7uXTJwiA.s['16']++;Y.io.postForm=function(uri,selector,options){__cov_ZDNunBkuHRbaig7uXTJwiA.f['8']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['17']++;options=(__cov_ZDNunBkuHRbaig7uXTJwiA.b['3'][0]++,options)||(__cov_ZDNunBkuHRbaig7uXTJwiA.b['3'][1]++,{});__cov_ZDNunBkuHRbaig7uXTJwiA.s['18']++;options.method='POST';__cov_ZDNunBkuHRbaig7uXTJwiA.s['19']++;options.form={id:Y.one(selector)};__cov_ZDNunBkuHRbaig7uXTJwiA.s['20']++;return Y.io.xhr(uri,options);};__cov_ZDNunBkuHRbaig7uXTJwiA.s['21']++;Y.Array.each(['script','css'],function(method){__cov_ZDNunBkuHRbaig7uXTJwiA.f['9']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['22']++;Y.io[method]=function(uri,options){__cov_ZDNunBkuHRbaig7uXTJwiA.f['10']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['23']++;return this._transaction(function(resolve,reject){__cov_ZDNunBkuHRbaig7uXTJwiA.f['11']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['24']++;Y.Get[method](uri,options,function(err,transaction){__cov_ZDNunBkuHRbaig7uXTJwiA.f['12']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['25']++;if(err){__cov_ZDNunBkuHRbaig7uXTJwiA.b['4'][0]++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['26']++;reject(err);}else{__cov_ZDNunBkuHRbaig7uXTJwiA.b['4'][1]++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['27']++;resolve(transaction);}});});};});__cov_ZDNunBkuHRbaig7uXTJwiA.s['28']++;Y.io.jsonp=function(uri,options){__cov_ZDNunBkuHRbaig7uXTJwiA.f['13']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['29']++;options=(__cov_ZDNunBkuHRbaig7uXTJwiA.b['5'][0]++,options)||(__cov_ZDNunBkuHRbaig7uXTJwiA.b['5'][1]++,{});__cov_ZDNunBkuHRbaig7uXTJwiA.s['30']++;return new Y.Promise(function(resolve,reject){__cov_ZDNunBkuHRbaig7uXTJwiA.f['14']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['31']++;var config={on:{success:function(data){__cov_ZDNunBkuHRbaig7uXTJwiA.f['15']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['32']++;resolve(data);},failure:reject,timeout:reject}};__cov_ZDNunBkuHRbaig7uXTJwiA.s['33']++;if(options.timeout){__cov_ZDNunBkuHRbaig7uXTJwiA.b['6'][0]++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['34']++;config.timeout=options.timeout;}else{__cov_ZDNunBkuHRbaig7uXTJwiA.b['6'][1]++;}__cov_ZDNunBkuHRbaig7uXTJwiA.s['35']++;if(options.format){__cov_ZDNunBkuHRbaig7uXTJwiA.b['7'][0]++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['36']++;config.format=options.format;}else{__cov_ZDNunBkuHRbaig7uXTJwiA.b['7'][1]++;}__cov_ZDNunBkuHRbaig7uXTJwiA.s['37']++;Y.jsonp(uri,config);});};__cov_ZDNunBkuHRbaig7uXTJwiA.s['38']++;Y.io.json=function(uri,options){__cov_ZDNunBkuHRbaig7uXTJwiA.f['16']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['39']++;options=(__cov_ZDNunBkuHRbaig7uXTJwiA.b['8'][0]++,options)||(__cov_ZDNunBkuHRbaig7uXTJwiA.b['8'][1]++,{});__cov_ZDNunBkuHRbaig7uXTJwiA.s['40']++;if(!options.headers){__cov_ZDNunBkuHRbaig7uXTJwiA.b['9'][0]++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['41']++;options.headers={};}else{__cov_ZDNunBkuHRbaig7uXTJwiA.b['9'][1]++;}__cov_ZDNunBkuHRbaig7uXTJwiA.s['42']++;options.headers.Accept=MIME_JSON;__cov_ZDNunBkuHRbaig7uXTJwiA.s['43']++;var promise=Y.io.xhr(uri,options);__cov_ZDNunBkuHRbaig7uXTJwiA.s['44']++;return Y.mix(promise.then(function(xhr){__cov_ZDNunBkuHRbaig7uXTJwiA.f['17']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['45']++;return Y.JSON.parse(xhr.responseText,options.reviver);}),{abort:promise.abort});};__cov_ZDNunBkuHRbaig7uXTJwiA.s['46']++;Y.Array.each(['get','delete'],function(verb){__cov_ZDNunBkuHRbaig7uXTJwiA.f['18']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['47']++;Y.io[verb+'JSON']=function(uri,options){__cov_ZDNunBkuHRbaig7uXTJwiA.f['19']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['48']++;options=(__cov_ZDNunBkuHRbaig7uXTJwiA.b['10'][0]++,options)||(__cov_ZDNunBkuHRbaig7uXTJwiA.b['10'][1]++,{});__cov_ZDNunBkuHRbaig7uXTJwiA.s['49']++;options.method=verb.toUpperCase();__cov_ZDNunBkuHRbaig7uXTJwiA.s['50']++;return Y.io.json(uri,options);};});__cov_ZDNunBkuHRbaig7uXTJwiA.s['51']++;Y.Array.each(['post','put'],function(verb){__cov_ZDNunBkuHRbaig7uXTJwiA.f['20']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['52']++;Y.io[verb+'JSON']=function(uri,data,options){__cov_ZDNunBkuHRbaig7uXTJwiA.f['21']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['53']++;options=(__cov_ZDNunBkuHRbaig7uXTJwiA.b['11'][0]++,options)||(__cov_ZDNunBkuHRbaig7uXTJwiA.b['11'][1]++,{});__cov_ZDNunBkuHRbaig7uXTJwiA.s['54']++;options.method=verb.toUpperCase();__cov_ZDNunBkuHRbaig7uXTJwiA.s['55']++;if(!options.headers){__cov_ZDNunBkuHRbaig7uXTJwiA.b['12'][0]++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['56']++;options.headers={};}else{__cov_ZDNunBkuHRbaig7uXTJwiA.b['12'][1]++;}__cov_ZDNunBkuHRbaig7uXTJwiA.s['57']++;if(!options.headers[CONTENT_TYPE]){__cov_ZDNunBkuHRbaig7uXTJwiA.b['13'][0]++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['58']++;options.headers[CONTENT_TYPE]=MIME_JSON;}else{__cov_ZDNunBkuHRbaig7uXTJwiA.b['13'][1]++;}__cov_ZDNunBkuHRbaig7uXTJwiA.s['59']++;return Y.when(data,function(obj){__cov_ZDNunBkuHRbaig7uXTJwiA.f['22']++;__cov_ZDNunBkuHRbaig7uXTJwiA.s['60']++;options.data=options.headers[CONTENT_TYPE]===MIME_JSON?(__cov_ZDNunBkuHRbaig7uXTJwiA.b['14'][0]++,Y.JSON.stringify(obj)):(__cov_ZDNunBkuHRbaig7uXTJwiA.b['14'][1]++,obj);__cov_ZDNunBkuHRbaig7uXTJwiA.s['61']++;return Y.io.json(uri,options);});};});},'gallery-2014.07.31-18-26',{'requires':['io-base','promise']});
View
64 build/gallery-io-utils/gallery-io-utils-debug.js
@@ -6,6 +6,9 @@ Promise based methods for performing IO requests.
@module gallery-io-utils
**/
+var MIME_JSON = 'application/json',
+ CONTENT_TYPE = 'Content-Type';
+
/**
Method for initiating an ajax call.
@@ -114,19 +117,11 @@ Y.Array.each(['get', 'post', 'put', 'delete'], function (method) {
/**
Alias for Y.io.delete()
-@method DELETE
-@for io
-@static
-@deprecated
-**/
-/**
-Alias for Y.io.delete()
-
@method del
@for io
@static
**/
-Y.io.DELETE = Y.io.del = Y.io['delete'];
+Y.io.del = Y.io['delete'];
/**
Initiaites an AJAX call with the HTTP method POST and sends the data contained
@@ -234,15 +229,26 @@ Requires the JSON module.
@for io
@static
@param {String} uri Qualified path to transaction resource.
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.xhr() with an extra
+ `reviver` option which is a reviver function for the `JSON.parse`
+ algorithm.
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
Y.io.json = function (uri, options) {
+ options = options || {};
+
+ // Force the use of the correct headers
+ // Since a JSON response is expected, ask for it with the Accept header
+ if (!options.headers) {
+ options.headers = {};
+ }
+ options.headers.Accept = MIME_JSON;
+
var promise = Y.io.xhr(uri, options);
return Y.mix(promise.then(function (xhr) {
- return Y.JSON.parse(xhr.responseText);
+ return Y.JSON.parse(xhr.responseText, options.reviver);
}), {
// pass around the abort function
abort: promise.abort
@@ -257,7 +263,7 @@ JSON notation. Requires the JSON module.
@for io
@static
@param {String} uri Qualified path to transaction resource.
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.json()
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
@@ -269,16 +275,16 @@ JSON notation. Requires the JSON module.
@for io
@static
@param {String} uri Qualified path to transaction resource.
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.json()
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
Y.Array.each(['get', 'delete'], function (verb) {
- Y.io[verb + 'JSON'] = function (uri, config) {
- config = config || {};
- config.method = verb.toUpperCase();
+ Y.io[verb + 'JSON'] = function (uri, options) {
+ options = options || {};
+ options.method = verb.toUpperCase();
- return Y.io.json(uri, config);
+ return Y.io.json(uri, options);
};
});
@@ -291,7 +297,7 @@ JSON notation. Requires the JSON module.
@static
@param {String} uri Qualified path to transaction resource.
@param {Object|Promise} data Data to send encoded as JSON
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.json()
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
@@ -304,21 +310,29 @@ JSON notation. Requires the JSON module.
@static
@param {String} uri Qualified path to transaction resource.
@param {Object|Promise} data Data to send encoded as JSON
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.json()
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
Y.Array.each(['post', 'put'], function (verb) {
- Y.io[verb + 'JSON'] = function (uri, data, config) {
- config = config || {};
- config.method = verb.toUpperCase();
+ Y.io[verb + 'JSON'] = function (uri, data, options) {
+ options = options || {};
+ options.method = verb.toUpperCase();
+
+ if (!options.headers) {
+ options.headers = {};
+ }
+ if (!options.headers[CONTENT_TYPE]) {
+ options.headers[CONTENT_TYPE] = MIME_JSON;
+ }
return Y.when(data, function (obj) {
- config.data = Y.JSON.stringify(obj);
- return Y.io.json(uri, config);
+ options.data = options.headers[CONTENT_TYPE] === MIME_JSON ?
+ Y.JSON.stringify(obj) : obj;
+ return Y.io.json(uri, options);
});
};
});
-}, 'gallery-2013.05.29-23-38', {"requires": ["io-base", "promise"]});
+}, 'gallery-2014.07.31-18-26', {"requires": ["io-base", "promise"]});
View
2 build/gallery-io-utils/gallery-io-utils-min.js
@@ -1 +1 @@
-YUI.add("gallery-io-utils",function(e,t){e.io.xhr=function(t,n){return n=n||{},new e.Promise(function(r,i){var s=e.io(t,{method:n.method,data:n.data,headers:n.headers,form:n.form,timeout:n.timeout,on:{success:function(e,t){r(t)},failure:function(e,t){i(t)}}});this.abort=s.abort})},e.Array.each(["get","post","put","delete"],function(t){e.io[t]=function(n,r){return r=r||{},r.method=t.toUpperCase(),e.io.xhr(n,r)}}),e.io.DELETE=e.io.del=e.io["delete"],e.io.postForm=function(t,n,r){return r=r||{},r.method="POST",r.form={id:e.one(n)},e.io.xhr(t,r)},e.Array.each(["script","css"],function(t){e.io[t]=function(n,r){return this._transaction(function(i,s){e.Get[t](n,r,function(e,t){e?s(e):i(t)})})}}),e.io.jsonp=function(t,n){return n=n||{},new e.Promise(function(r,i){var s={on:{success:function(e){r(e)},failure:i,timeout:i}};n.timeout&&(s.timeout=n.timeout),n.format&&(s.format=n.format),e.jsonp(t,s)})},e.io.json=function(t,n){var r=e.io.xhr(t,n);return e.mix(r.then(function(t){return e.JSON.parse(t.responseText)}),{abort:r.abort})},e.Array.each(["get","delete"],function(t){e.io[t+"JSON"]=function(n,r){return r=r||{},r.method=t.toUpperCase(),e.io.json(n,r)}}),e.Array.each(["post","put"],function(t){e.io[t+"JSON"]=function(n,r,i){return i=i||{},i.method=t.toUpperCase(),e.when(r,function(t){return i.data=e.JSON.stringify(t),e.io.json(n,i)})}})},"gallery-2013.05.29-23-38",{requires:["io-base","promise"]});
+YUI.add("gallery-io-utils",function(e,t){var n="application/json",r="Content-Type";e.io.xhr=function(t,n){return n=n||{},new e.Promise(function(r,i){var s=e.io(t,{method:n.method,data:n.data,headers:n.headers,form:n.form,timeout:n.timeout,on:{success:function(e,t){r(t)},failure:function(e,t){i(t)}}});this.abort=s.abort})},e.Array.each(["get","post","put","delete"],function(t){e.io[t]=function(n,r){return r=r||{},r.method=t.toUpperCase(),e.io.xhr(n,r)}}),e.io.del=e.io["delete"],e.io.postForm=function(t,n,r){return r=r||{},r.method="POST",r.form={id:e.one(n)},e.io.xhr(t,r)},e.Array.each(["script","css"],function(t){e.io[t]=function(n,r){return this._transaction(function(i,s){e.Get[t](n,r,function(e,t){e?s(e):i(t)})})}}),e.io.jsonp=function(t,n){return n=n||{},new e.Promise(function(r,i){var s={on:{success:function(e){r(e)},failure:i,timeout:i}};n.timeout&&(s.timeout=n.timeout),n.format&&(s.format=n.format),e.jsonp(t,s)})},e.io.json=function(t,r){r=r||{},r.headers||(r.headers={}),r.headers.Accept=n;var i=e.io.xhr(t,r);return e.mix(i.then(function(t){return e.JSON.parse(t.responseText,r.reviver)}),{abort:i.abort})},e.Array.each(["get","delete"],function(t){e.io[t+"JSON"]=function(n,r){return r=r||{},r.method=t.toUpperCase(),e.io.json(n,r)}}),e.Array.each(["post","put"],function(t){e.io[t+"JSON"]=function(i,s,o){return o=o||{},o.method=t.toUpperCase(),o.headers||(o.headers={}),o.headers[r]||(o.headers[r]=n),e.when(s,function(t){return o.data=o.headers[r]===n?e.JSON.stringify(t):t,e.io.json(i,o)})}})},"gallery-2014.07.31-18-26",{requires:["io-base","promise"]});
View
64 build/gallery-io-utils/gallery-io-utils.js
@@ -6,6 +6,9 @@ Promise based methods for performing IO requests.
@module gallery-io-utils
**/
+var MIME_JSON = 'application/json',
+ CONTENT_TYPE = 'Content-Type';
+
/**
Method for initiating an ajax call.
@@ -114,19 +117,11 @@ Y.Array.each(['get', 'post', 'put', 'delete'], function (method) {
/**
Alias for Y.io.delete()
-@method DELETE
-@for io
-@static
-@deprecated
-**/
-/**
-Alias for Y.io.delete()
-
@method del
@for io
@static
**/
-Y.io.DELETE = Y.io.del = Y.io['delete'];
+Y.io.del = Y.io['delete'];
/**
Initiaites an AJAX call with the HTTP method POST and sends the data contained
@@ -234,15 +229,26 @@ Requires the JSON module.
@for io
@static
@param {String} uri Qualified path to transaction resource.
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.xhr() with an extra
+ `reviver` option which is a reviver function for the `JSON.parse`
+ algorithm.
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
Y.io.json = function (uri, options) {
+ options = options || {};
+
+ // Force the use of the correct headers
+ // Since a JSON response is expected, ask for it with the Accept header
+ if (!options.headers) {
+ options.headers = {};
+ }
+ options.headers.Accept = MIME_JSON;
+
var promise = Y.io.xhr(uri, options);
return Y.mix(promise.then(function (xhr) {
- return Y.JSON.parse(xhr.responseText);
+ return Y.JSON.parse(xhr.responseText, options.reviver);
}), {
// pass around the abort function
abort: promise.abort
@@ -257,7 +263,7 @@ JSON notation. Requires the JSON module.
@for io
@static
@param {String} uri Qualified path to transaction resource.
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.json()
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
@@ -269,16 +275,16 @@ JSON notation. Requires the JSON module.
@for io
@static
@param {String} uri Qualified path to transaction resource.
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.json()
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
Y.Array.each(['get', 'delete'], function (verb) {
- Y.io[verb + 'JSON'] = function (uri, config) {
- config = config || {};
- config.method = verb.toUpperCase();
+ Y.io[verb + 'JSON'] = function (uri, options) {
+ options = options || {};
+ options.method = verb.toUpperCase();
- return Y.io.json(uri, config);
+ return Y.io.json(uri, options);
};
});
@@ -291,7 +297,7 @@ JSON notation. Requires the JSON module.
@static
@param {String} uri Qualified path to transaction resource.
@param {Object|Promise} data Data to send encoded as JSON
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.json()
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
@@ -304,21 +310,29 @@ JSON notation. Requires the JSON module.
@static
@param {String} uri Qualified path to transaction resource.
@param {Object|Promise} data Data to send encoded as JSON
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.json()
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
Y.Array.each(['post', 'put'], function (verb) {
- Y.io[verb + 'JSON'] = function (uri, data, config) {
- config = config || {};
- config.method = verb.toUpperCase();
+ Y.io[verb + 'JSON'] = function (uri, data, options) {
+ options = options || {};
+ options.method = verb.toUpperCase();
+
+ if (!options.headers) {
+ options.headers = {};
+ }
+ if (!options.headers[CONTENT_TYPE]) {
+ options.headers[CONTENT_TYPE] = MIME_JSON;
+ }
return Y.when(data, function (obj) {
- config.data = Y.JSON.stringify(obj);
- return Y.io.json(uri, config);
+ options.data = options.headers[CONTENT_TYPE] === MIME_JSON ?
+ Y.JSON.stringify(obj) : obj;
+ return Y.io.json(uri, options);
});
};
});
-}, 'gallery-2013.05.29-23-38', {"requires": ["io-base", "promise"]});
+}, 'gallery-2014.07.31-18-26', {"requires": ["io-base", "promise"]});
View
2 src/gallery-io-utils/README.md
@@ -14,7 +14,7 @@ Create a new YUI instance for your application and populate it with the modules
<script>
YUI({
gallery: 'gallery-2013.05.15-21-12'
-}).use('gallery-affix', function (Y) {
+}).use('gallery-io-utils', function (Y) {
Y.io.getJSON('/foo/bar').then(function (data) {
console.log(data);
View
7 src/gallery-io-utils/docs/index.mustache
@@ -13,7 +13,7 @@ YUI({
node = Y.one('#foo');
Y.io.getJSON('/foo').then(function (data) {
- foo.setHTML(template(data)));
+ node.setHTML(template(data)));
});
});
@@ -103,6 +103,11 @@ YUI({
<td>Loads a CSS stylesheet</td>
<td></td>
</tr>
+ <tr clas="yui3-table-odd">
+ <td>Y.io.postForm</td>
+ <td>Makes a POST Ajax request with the content of the provided form</td>
+ <td></td>
+ </tr>
</tbody>
</table>
View
62 src/gallery-io-utils/js/io-utils.js
@@ -4,6 +4,9 @@ Promise based methods for performing IO requests.
@module gallery-io-utils
**/
+var MIME_JSON = 'application/json',
+ CONTENT_TYPE = 'Content-Type';
+
/**
Method for initiating an ajax call.
@@ -112,19 +115,11 @@ Y.Array.each(['get', 'post', 'put', 'delete'], function (method) {
/**
Alias for Y.io.delete()
-@method DELETE
-@for io
-@static
-@deprecated
-**/
-/**
-Alias for Y.io.delete()
-
@method del
@for io
@static
**/
-Y.io.DELETE = Y.io.del = Y.io['delete'];
+Y.io.del = Y.io['delete'];
/**
Initiaites an AJAX call with the HTTP method POST and sends the data contained
@@ -232,15 +227,26 @@ Requires the JSON module.
@for io
@static
@param {String} uri Qualified path to transaction resource.
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.xhr() with an extra
+ `reviver` option which is a reviver function for the `JSON.parse`
+ algorithm.
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
Y.io.json = function (uri, options) {
+ options = options || {};
+
+ // Force the use of the correct headers
+ // Since a JSON response is expected, ask for it with the Accept header
+ if (!options.headers) {
+ options.headers = {};
+ }
+ options.headers.Accept = MIME_JSON;
+
var promise = Y.io.xhr(uri, options);
return Y.mix(promise.then(function (xhr) {
- return Y.JSON.parse(xhr.responseText);
+ return Y.JSON.parse(xhr.responseText, options.reviver);
}), {
// pass around the abort function
abort: promise.abort
@@ -255,7 +261,7 @@ JSON notation. Requires the JSON module.
@for io
@static
@param {String} uri Qualified path to transaction resource.
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.json()
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
@@ -267,16 +273,16 @@ JSON notation. Requires the JSON module.
@for io
@static
@param {String} uri Qualified path to transaction resource.
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.json()
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
Y.Array.each(['get', 'delete'], function (verb) {
- Y.io[verb + 'JSON'] = function (uri, config) {
- config = config || {};
- config.method = verb.toUpperCase();
+ Y.io[verb + 'JSON'] = function (uri, options) {
+ options = options || {};
+ options.method = verb.toUpperCase();
- return Y.io.json(uri, config);
+ return Y.io.json(uri, options);
};
});
@@ -289,7 +295,7 @@ JSON notation. Requires the JSON module.
@static
@param {String} uri Qualified path to transaction resource.
@param {Object|Promise} data Data to send encoded as JSON
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.json()
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
@@ -302,18 +308,26 @@ JSON notation. Requires the JSON module.
@static
@param {String} uri Qualified path to transaction resource.
@param {Object|Promise} data Data to send encoded as JSON
-@param {Object} [options] Same configuration options as Y.io.xhr()
+@param {Object} [options] Same configuration options as Y.io.json()
@return {Promise} Promise for the response object. Contains an extra
`abort()` method to cancel the request.
**/
Y.Array.each(['post', 'put'], function (verb) {
- Y.io[verb + 'JSON'] = function (uri, data, config) {
- config = config || {};
- config.method = verb.toUpperCase();
+ Y.io[verb + 'JSON'] = function (uri, data, options) {
+ options = options || {};
+ options.method = verb.toUpperCase();
+
+ if (!options.headers) {
+ options.headers = {};
+ }
+ if (!options.headers[CONTENT_TYPE]) {
+ options.headers[CONTENT_TYPE] = MIME_JSON;
+ }
return Y.when(data, function (obj) {
- config.data = Y.JSON.stringify(obj);
- return Y.io.json(uri, config);
+ options.data = options.headers[CONTENT_TYPE] === MIME_JSON ?
+ Y.JSON.stringify(obj) : obj;
+ return Y.io.json(uri, options);
});
};
});
View
65 src/gallery-io-utils/logs/tests.json
@@ -1,11 +1,11 @@
{
"name": "io-utils",
- "passed": 48,
- "failed": 0,
+ "passed": 32,
+ "failed": 2,
"errors": 0,
"ignored": 0,
- "total": 48,
- "duration": 600,
+ "total": 34,
+ "duration": 684,
"type": "report",
"Y.io.xhr() tests": {
"name": "Y.io.xhr() tests",
@@ -14,21 +14,21 @@
"errors": 0,
"ignored": 0,
"total": 4,
- "duration": 46,
+ "duration": 50,
"type": "testcase",
"simple XHR request": {
"result": "pass",
"message": "Test passed",
"type": "test",
"name": "simple XHR request",
- "duration": 8
+ "duration": 11
},
"request timeout": {
"result": "pass",
"message": "Test passed",
"type": "test",
"name": "request timeout",
- "duration": 5
+ "duration": 6
},
"request failure": {
"result": "pass",
@@ -42,69 +42,76 @@
"message": "Test passed",
"type": "test",
"name": "abort() should reject the promise",
- "duration": 14
+ "duration": 12
}
},
"HTTP verbs": {
"name": "HTTP verbs",
- "passed": 4,
- "failed": 0,
+ "passed": 3,
+ "failed": 1,
"errors": 0,
"ignored": 0,
"total": 4,
- "duration": 35,
+ "duration": 32,
"type": "testcase",
"GET HTTP request": {
"result": "pass",
"message": "Test passed",
"type": "test",
"name": "GET HTTP request",
- "duration": 5
+ "duration": 6
},
"POST HTTP request": {
"result": "pass",
"message": "Test passed",
"type": "test",
"name": "POST HTTP request",
- "duration": 5
+ "duration": 6
},
"PUT HTTP request": {
"result": "pass",
"message": "Test passed",
"type": "test",
"name": "PUT HTTP request",
- "duration": 6
+ "duration": 5
},
"DELETE HTTP request": {
- "result": "pass",
- "message": "Test passed",
+ "result": "fail",
+ "message": "Unexpected error: 'undefined' is not a function (evaluating 'Y.io.DELETE('echo/delete/?response=helloworld')')",
"type": "test",
"name": "DELETE HTTP request",
- "duration": 4
+ "duration": 0
}
},
"JSON requests": {
"name": "JSON requests",
- "passed": 2,
+ "passed": 3,
"failed": 0,
"errors": 0,
"ignored": 0,
- "total": 2,
- "duration": 14,
+ "total": 3,
+ "duration": 30,
"type": "testcase",
"simple JSON request": {
"result": "pass",
"message": "Test passed",
"type": "test",
"name": "simple JSON request",
- "duration": 6
+ "duration": 7
},
"catching parse error": {
"result": "pass",
"message": "Test passed",
"type": "test",
"name": "catching parse error",
"duration": 5
+ },
+ "reviver function": {
+ "result": "pass",
+ "message": "Test passed",
+ "type": "test",
+ "name": "reviver function",
+ "duration": 5
}
},
"HTTP verbs with JSON": {
@@ -114,35 +121,35 @@
"errors": 0,
"ignored": 0,
"total": 4,
- "duration": 79,
+ "duration": 206,
"type": "testcase",
"GET JSON request": {
"result": "pass",
"message": "Test passed",
"type": "test",
"name": "GET JSON request",
- "duration": 5
+ "duration": 7
},
"POST JSON request": {
"result": "pass",
"message": "Test passed",
"type": "test",
"name": "POST JSON request",
- "duration": 17
+ "duration": 102
},
"PUT JSON request": {
"result": "pass",
"message": "Test passed",
"type": "test",
"name": "PUT JSON request",
- "duration": 18
+ "duration": 58
},
"DELETE JSON request": {
"result": "pass",
"message": "Test passed",
"type": "test",
"name": "DELETE JSON request",
- "duration": 6
+ "duration": 7
}
},
"jsonp requests": {
@@ -152,14 +159,14 @@
"errors": 0,
"ignored": 0,
"total": 2,
- "duration": 22,
+ "duration": 21,
"type": "testcase",
"simple jsonp request": {
"result": "pass",
"message": "Test passed",
"type": "test",
"name": "simple jsonp request",
- "duration": 6
+ "duration": 5
},
"jsonp request timeout": {
"result": "pass",
@@ -169,6 +176,6 @@
"duration": 4
}
},
- "timestamp": "Wed 29 May 2013 04:31:16 PM PDT",
+ "timestamp": "Thu 31 Jul 2014 11:27:11 AM PDT",
"consoleInfo": []
}
View
24 src/gallery-io-utils/logs/yogi.stdout.log
@@ -1,4 +1,4 @@
-yogi [info] using yogi@0.1.9 on node@0.8.23
+yogi [info] using yogi@0.1.12 on node@0.10.26
yogi [info] using module: gallery-io-utils
yogi [info] running with shifter
shifter [info] racing to find the closest .shifter.json file
@@ -19,25 +19,19 @@ shifter [info] istanbul providing coverage
shifter [queu] instrumenting with istanbul
shifter [queu] writing coverage file to gallery-io-utils/gallery-io-utils-coverage.js
shifter [info] done racing, the gears are toast
-shifter [info] finished in 0.107 seconds, pretty fast huh?
+shifter [info] finished in 0.11 seconds, pretty fast huh?
yogi [info] build complete
yogi [info] testing module now
yogi [info] prepping grover tests
yogi [info] adding tests route
+yogi [info] launching xdr server on port 5001
+yogi [info] listening on: http://127.0.0.1:5000
yogi [info] turning on coverage support in grover
-yogi [info] launching xdr server on port 5005
-yogi [info] listening on: http://127.0.0.1:5004
-Starting Grover on 1 files with PhantomJS@1.7.0
+Starting Grover on 1 files with PhantomJS@1.9.7
Running 15 concurrent tests at a time.
Using a 120 second timeout per test.
-✔ [io-utils]: Passed: 16 Failed: 0 Total: 16 (ignored 0) (0.2 seconds)
+✖ [io-utils]: Passed: 16 Failed: 1 Total: 17 (ignored 0) (0.342 seconds)
+ DELETE HTTP request
+ Unexpected error: 'undefined' is not a function (evaluating 'Y.io.DELETE('echo/delete/?response=helloworld')')
Writing files in JSON format to: /src/gallery-io-utils/logs/tests.json
-┌─────────┬─────────┬────────┬─────────────┬────────┐
-│ path │ lines │ % │ functions │ % │
-├─────────┼─────────┼────────┼─────────────┼────────┤
-│ total │ 0/0 │ NaN% │ 0/0 │ NaN% │
-└─────────┴─────────┴────────┴─────────────┴────────┘
-----------------------------------------------------------------
-✔ [Total]: Passed: 16 Failed: 0 Total: 16 (ignored 0) (0.2 seconds)
- [Grover Execution Timer] 1.004 seconds
-yogi [info] grover tests complete
+yogi [bail] grover returned a failure
View
6 src/gallery-io-utils/package.json
@@ -1,6 +1,6 @@
{
"name": "gallery-io-utils",
- "version": "0.0.1",
+ "version": "0.0.4",
"description": "YUI 3 promise based IO utilities",
"author": "Juan Ignacio Dopazo <dopazo.juan@gmail.com>",
"bugs": {
@@ -11,8 +11,8 @@
},
"dependencies": {},
"devDependencies": {
- "shifter": "0.3.3",
- "grover": "0.1.14"
+ "shifter": "0.4.3",
+ "grover": "0.1.17"
},
"scripts": {
"test": "shifter --build-dir ./build && grover --server tests/unit/*.html"
View
25 src/gallery-io-utils/tests/unit/js/tests.js
@@ -13,6 +13,7 @@ YUI.add('module-tests', function(Y) {
});
}, function (err) {
test.resume(function () {
+ Assert.fail('Promise rejected instead of fulfilled');
throw err;
});
});
@@ -25,7 +26,7 @@ YUI.add('module-tests', function(Y) {
promise.then(function (value) {
test.resume(function () {
- throw new Error('Fulfilled instead of rejecting');
+ Assert.fail('Promise fulfilled instead of rejected');
});
}, function (err) {
test.resume(function () {
@@ -132,6 +133,24 @@ YUI.add('module-tests', function(Y) {
});
this.wait();
+ },
+
+ 'reviver function': function () {
+ var date = new Date().toJSON(),
+ DATEPATTERN = /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z/;
+
+ var request = Y.io.json('echo/get/?response={"date":"' + date + '"}', {
+ reviver: function(key, value) {
+ return DATEPATTERN.test(value) ? new Date(value) : value;
+ }
+ });
+
+ this.success(request, function (data) {
+ Assert.isInstanceOf(Date, data.date, 'Date was not revived');
+ Assert.areSame(date, data.date.toJSON(), 'Date was not properly parsed');
+ });
+
+ this.wait();
}
}));
@@ -147,15 +166,15 @@ YUI.add('module-tests', function(Y) {
},
'POST JSON request': function () {
- this.success(Y.io.postJSON('echo/post/?response={"foo":"bar"}'), function (data) {
+ this.success(Y.io.postJSON('echo/json/', {"foo":"bar"}), function (data) {
Assert.areEqual('bar', data.foo, 'POST request failure');
});
this.wait();
},
'PUT JSON request': function () {
- this.success(Y.io.putJSON('echo/put/?response={"foo":"bar"}'), function (data) {
+ this.success(Y.io.putJSON('echo/json/', {"foo":"bar"}), function (data) {
Assert.areEqual('bar', data.foo, 'PUT request failure');
});

0 comments on commit a3dd7b3

Please sign in to comment.
Something went wrong with that request. Please try again.