components_media.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /* ------------------------------------------------------------------------------
  2. *
  3. * # Media objects
  4. *
  5. * Demo JS code for components_media.html page
  6. *
  7. * ---------------------------------------------------------------------------- */
  8. // Setup module
  9. // ------------------------------
  10. var Media = function () {
  11. //
  12. // Setup module components
  13. //
  14. // Switchery
  15. var _componentSwitchery = function() {
  16. if (typeof Switchery == 'undefined') {
  17. console.warn('Warning - switchery.min.js is not loaded.');
  18. return;
  19. }
  20. // Initialize
  21. var elems = Array.prototype.slice.call(document.querySelectorAll('.form-control-switchery'));
  22. elems.forEach(function(html) {
  23. var switchery = new Switchery(html);
  24. });
  25. };
  26. // Uniform
  27. var _componentUniform = function() {
  28. if (!$().uniform) {
  29. console.warn('Warning - uniform.min.js is not loaded.');
  30. return;
  31. }
  32. // Initialize
  33. $('.form-input-styled').uniform();
  34. };
  35. //
  36. // Return objects assigned to module
  37. //
  38. return {
  39. initComponents: function() {
  40. _componentSwitchery();
  41. _componentUniform();
  42. }
  43. }
  44. }();
  45. // Initialize module
  46. // ------------------------------
  47. document.addEventListener('DOMContentLoaded', function() {
  48. Media.initComponents();
  49. });