init.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. const init = {
  2. floatingButton: null,
  3. modal: null,
  4. tooltip: null,
  5. scope: {}
  6. };
  7. init.exec = function (print) {
  8. // Load floating button
  9. init.floatingButton = M.FloatingActionButton.init(document.querySelectorAll('.fixed-action-btn'))[0];
  10. // Load modal
  11. init.modal = M.Modal.init(document.querySelectorAll('.modal'))[0];
  12. // Load tooltip
  13. init.tooltip = M.Tooltip.init(document.querySelectorAll('.tooltipped'))[0];
  14. // Load data
  15. init.scope = binder({
  16. card: DataService.data
  17. });
  18. init.scope.username = UserService.username;
  19. // Set the link to edit
  20. $('#float-add-btn').attr('href', RouterService.path('edit'));
  21. // Print data
  22. print(init.scope);
  23. // Hide loader
  24. loader();
  25. //Show discovery the first time
  26. if (!localStorage.discovery) {
  27. // Load discovery
  28. const discovery = M.TapTarget.init(document.querySelectorAll('.tap-target'), {onClose: () => {
  29. localStorage.setItem('discovery', true)
  30. }})[0];
  31. setTimeout(() => {discovery.open();}, 500);
  32. }
  33. }
  34. module.exports = init;