Show:

src\classes\containerConfig.js File

  1. /* eslint-disable no-unused-vars */
  2. /**
  3. * An object containing configuration information for the
  4. * [container](../../container-development.html)
  5. * @class F2.ContainerConfig
  6. */
  7. export default {
  8. /**
  9. * True to enable debug mode in F2.js. Adds additional logging, resource cache busting, etc.
  10. * @property debugMode
  11. * @type bool
  12. * @default false
  13. */
  14. debugMode: false,
  15. /**
  16. * The default language and region specification for this container
  17. * represented as an IETF-defined standard language tag,
  18. * e.g. `"en-us"` or `"de-de"`. This value is passed to each app
  19. * registered as `containerLocale`.
  20. *
  21. * @property locale
  22. * @type string
  23. * @default null
  24. * @since 1.4.0
  25. */
  26. locale: null,
  27. /**
  28. * Milliseconds before F2 fires callback on script resource load errors. Due to issue with the way Internet Explorer attaches load events to script elements, the error event doesn't fire.
  29. * @property scriptErrorTimeout
  30. * @type milliseconds
  31. * @default 7000 (7 seconds)
  32. */
  33. scriptErrorTimeout: 7000,
  34. /**
  35. * Allows the container to fully override how the AppManifest request is
  36. * made inside of F2.
  37. *
  38. * @method xhr
  39. * @param {string} url The manifest url
  40. * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}}
  41. * objects
  42. * @param {function} success The function to be called if the request
  43. * succeeds
  44. * @param {function} error The function to be called if the request fails
  45. * @param {function} complete The function to be called when the request
  46. * finishes (after success and error callbacks have been executed)
  47. * @return {XMLHttpRequest} The XMLHttpRequest object
  48. *
  49. * @example
  50. *     F2.init({
  51. *         xhr: function(url, appConfigs,successCallback, errorCallback, completeCallback) {
  52. *          var jsonpCallback = F2.Constants.JSONP_CALLBACK + appConfigs[0].appId, // Unique function name
  53. * var fetchUrl = url + '?params=' + F2.stringify(appConfigs.apps, F2.appConfigReplacer);
  54. *          var fetchFunc = fetchJsonp(fetchUrl, {
  55. *                          timeout: 3000,
  56. *                          jsonpCallbackFunction: jsonpCallback
  57. *                          });
  58. *           fetchFunc.then(function(response) {
  59. *                          return response.json();
  60. *                      })
  61. *                      .then(function(data) {
  62. *                       successCallback(data);
  63. *                       completeCallback();
  64. *                  })
  65. *                  .catch(function(error) {
  66. *                      F2.log('Failed to load app(s)', error.toString());
  67. *                      errorCallback();
  68. *                  });
  69. *         }
  70. *     });
  71. *
  72. * @for F2.ContainerConfig
  73. */
  74. //xhr: function(url, appConfigs, success, error, complete) {},
  75. /**
  76. * Allows the container to override individual parts of the AppManifest
  77. * request. See properties and methods with the `xhr.` prefix.
  78. * @property xhr
  79. * @type Object
  80. *
  81. * @example
  82. * F2.init({
  83. * xhr: {
  84. * url: function(url, appConfigs) {
  85. * return 'http://example.com/proxy.php?url=' + encocdeURIComponent(url);
  86. * }
  87. * }
  88. * });
  89. */
  90. xhr: {
  91. /**
  92. * Allows the container to override the request data type (JSON or JSONP)
  93. * that is used for the request
  94. * @method xhr.dataType
  95. * @param {string} url The manifest url
  96. * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}}
  97. * objects
  98. * @return {string} The request data type that should be used
  99. *
  100. * @example
  101. * F2.init({
  102. * xhr: {
  103. * dataType: function(url) {
  104. * return F2.isLocalRequest(url) ? 'json' : 'jsonp';
  105. * },
  106. * type: function(url) {
  107. * return F2.isLocalRequest(url) ? 'POST' : 'GET';
  108. * }
  109. * }
  110. * });
  111. */
  112. dataType: function (url, appConfigs) {},
  113. /**
  114. * Allows the container to override the request method that is used.
  115. * @method xhr.type
  116. * @param {string} url The manifest url
  117. * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}}
  118. * objects
  119. * @return {string} The request method that should be used
  120. *
  121. * @example
  122. * F2.init({
  123. * xhr: {
  124. * dataType: function(url) {
  125. * return F2.isLocalRequest(url) ? 'json' : 'jsonp';
  126. * },
  127. * type: function(url) {
  128. * return F2.isLocalRequest(url) ? 'POST' : 'GET';
  129. * }
  130. * }
  131. * });
  132. */
  133. type: function (url, appConfigs) {},
  134. /**
  135. * Allows the container to override the url that is used to request an
  136. * app's F2.{{#crossLink "F2.AppManifest"}}{{/crossLink}}
  137. * @method xhr.url
  138. * @param {string} url The manifest url
  139. * @param {Array} appConfigs An array of {{#crossLink "F2.AppConfig"}}{{/crossLink}}
  140. * objects
  141. * @return {string} The url that should be used for the request
  142. *
  143. * @example
  144. * F2.init({
  145. * xhr: {
  146. * url: function(url, appConfigs) {
  147. * return 'http://example.com/proxy.php?url=' + encocdeURIComponent(url);
  148. * }
  149. * }
  150. * });
  151. */
  152. url: function (url, appConfigs) {}
  153. },
  154. /**
  155. * Allows the container to override the script loader which requests
  156. * dependencies defined in the {{#crossLink "F2.AppManifest"}}{{/crossLink}}.
  157. * @property loadScripts
  158. * @type function
  159. *
  160. * @example
  161. * F2.init({
  162. * loadScripts: function(scripts,inlines,callback){
  163. * //load scripts using $.load() for each script or require(scripts)
  164. * callback();
  165. * }
  166. * });
  167. */
  168. loadScripts: function (scripts, inlines, callback) {},
  169. /**
  170. * Allows the container to override the stylesheet loader which requests
  171. * dependencies defined in the {{#crossLink "F2.AppManifest"}}{{/crossLink}}.
  172. * @property loadStyles
  173. * @type function
  174. *
  175. * @example
  176. * F2.init({
  177. * loadStyles: function(styles,callback){
  178. * //load styles using $.load() for each stylesheet or another method
  179. * callback();
  180. * }
  181. * });
  182. */
  183. loadStyles: function (styles, callback) {}
  184. };