API Docs for: 0.0.1
Show:

File: src/io/extra/io-assets.js

  1. "use strict";
  2.  
  3. /**
  4. * Extends io by adding the method `getCSS` and `getJS` to it.
  5. * (under construction)
  6. *
  7. * @example
  8. * var IO = require("io/extra/io-assets.js")(window);
  9. *
  10. *
  11. * <i>Copyright (c) 2014 ITSA - https://github.com/itsa</i>
  12. * New BSD License - http://choosealicense.com/licenses/bsd-3-clause/
  13. *
  14. * @module io
  15. * @submodule io-assets
  16. * @class IO
  17. * @since 0.0.1
  18. */
  19.  
  20. // var NAME = '[io-assets]: ';
  21.  
  22. require('js-ext/lib/object.js');
  23.  
  24. var createHashMap = require('js-ext/extra/hashmap.js').createMap;
  25.  
  26. module.exports = function (window) {
  27.  
  28. var IO = require('../io.js')(window);
  29.  
  30. window._ITSAmodules || Object.protectedProp(window, '_ITSAmodules', createHashMap());
  31.  
  32. if (window._ITSAmodules.IO_Assets) {
  33. return IO; // IO_Assets was already created
  34. }
  35.  
  36. window._ITSAmodules.IO_Assets = IO;
  37.  
  38. /**
  39. * Creates a `<style>` tag to load the CSS file at the given url.
  40. *
  41. * @method getCSS
  42. * @param url {String} URL of the style sheet to load
  43. * @param [options] {Object}
  44. * @param [options.sync=false] {boolean} By default, all requests are sent asynchronously. To send synchronous requests, set to true.
  45. * @param [options.headers] {Object} HTTP request headers.
  46. * @param [options.timeout=3000] {Number} to timeout the request, leading into a rejected Promise.
  47. * @return {Promise} Promise holding the request. Has an additional .abort() method to cancel the request.
  48. * <ul>
  49. * <li>on success: xhr {XMLHttpRequest1|XMLHttpRequest2} xhr-response</li>
  50. * <li>on failure: reason {Error}</li>
  51. * </ul>
  52. */
  53. IO.getCSS = function(/* url, options */) {
  54. };
  55.  
  56. /**
  57. * Creates a `<script>` tag to load the script at the given url.
  58. *
  59. * @method getJS
  60. * @param url {String} URL of the style sheet to load
  61. * @param [options] {Object}
  62. * @param [options.sync=false] {boolean} By default, all requests are sent asynchronously. To send synchronous requests, set to true.
  63. * @param [options.headers] {Object} HTTP request headers.
  64. * @param [options.timeout=3000] {Number} to timeout the request, leading into a rejected Promise.
  65. * @return {Promise} Promise holding the request. Has an additional .abort() method to cancel the request.
  66. * <ul>
  67. * <li>on success: xhr {XMLHttpRequest1|XMLHttpRequest2} xhr-response</li>
  68. * <li>on failure: reason {Error}</li>
  69. * </ul>
  70. */
  71. IO.getJS = function(/* url, options */) {
  72. };
  73.  
  74. return IO;
  75. };