config-debug.js 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* global mixitup, h */
  2. /**
  3. * A group of properties allowing the toggling of various debug features.
  4. *
  5. * @constructor
  6. * @memberof mixitup.Config
  7. * @name debug
  8. * @namespace
  9. * @public
  10. * @since 3.0.0
  11. */
  12. mixitup.ConfigDebug = function() {
  13. mixitup.Base.call(this);
  14. this.callActions('beforeConstruct');
  15. /**
  16. * A boolean dictating whether or not the mixer instance returned by the
  17. * `mixitup()` factory function should expose private properties and methods.
  18. *
  19. * By default, mixer instances only expose their public API, but enabling
  20. * debug mode will give you access to various mixer internals which may aid
  21. * in debugging, or the authoring of extensions.
  22. *
  23. * @example <caption>Example: Enabling debug mode</caption>
  24. *
  25. * var mixer = mixitup(containerEl, {
  26. * debug: {
  27. * enable: true
  28. * }
  29. * });
  30. *
  31. * // Private properties and methods will now be visible on the mixer instance:
  32. *
  33. * console.log(mixer);
  34. *
  35. * @name enable
  36. * @memberof mixitup.Config.debug
  37. * @instance
  38. * @type {boolean}
  39. * @default false
  40. */
  41. this.enable = false;
  42. /**
  43. * A boolean dictating whether or not warnings should be shown when various
  44. * common gotchas occur.
  45. *
  46. * Warnings are intended to provide insights during development when something
  47. * occurs that is not a fatal, but may indicate an issue with your integration,
  48. * and are therefore turned on by default. However, you may wish to disable
  49. * them in production.
  50. *
  51. * @example <caption>Example 1: Disabling warnings</caption>
  52. *
  53. * var mixer = mixitup(containerEl, {
  54. * debug: {
  55. * showWarnings: false
  56. * }
  57. * });
  58. *
  59. * @example <caption>Example 2: Disabling warnings based on environment</caption>
  60. *
  61. * var showWarnings = myAppConfig.environment === 'development' ? true : false;
  62. *
  63. * var mixer = mixitup(containerEl, {
  64. * debug: {
  65. * showWarnings: showWarnings
  66. * }
  67. * });
  68. *
  69. * @name showWarnings
  70. * @memberof mixitup.Config.debug
  71. * @instance
  72. * @type {boolean}
  73. * @default true
  74. */
  75. this.showWarnings = true;
  76. /**
  77. * Used for server-side testing only.
  78. *
  79. * @private
  80. * @name fauxAsync
  81. * @memberof mixitup.Config.debug
  82. * @instance
  83. * @type {boolean}
  84. * @default false
  85. */
  86. this.fauxAsync = false;
  87. this.callActions('afterConstruct');
  88. h.seal(this);
  89. };
  90. mixitup.BaseStatic.call(mixitup.ConfigDebug);
  91. mixitup.ConfigDebug.prototype = Object.create(mixitup.Base.prototype);
  92. mixitup.ConfigDebug.prototype.constructor = mixitup.ConfigDebug;