header.js 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. Meteor.subscribe('user-admin');
  2. Meteor.subscribe('boards');
  3. Meteor.subscribe('setting');
  4. Meteor.subscribe('announcements');
  5. Template.header.onCreated(function(){
  6. const templateInstance = this;
  7. templateInstance.currentSetting = new ReactiveVar();
  8. templateInstance.isLoading = new ReactiveVar(false);
  9. Meteor.subscribe('setting', {
  10. onReady() {
  11. templateInstance.currentSetting.set(Settings.findOne());
  12. let currSetting = templateInstance.currentSetting.curValue;
  13. if(currSetting && currSetting !== undefined && currSetting.customLoginLogoImageUrl !== undefined && document.getElementById("headerIsSettingDatabaseCallDone") != null)
  14. document.getElementById("headerIsSettingDatabaseCallDone").style.display = 'none';
  15. else if(document.getElementById("headerIsSettingDatabaseCallDone") != null)
  16. document.getElementById("headerIsSettingDatabaseCallDone").style.display = 'block';
  17. return this.stop();
  18. },
  19. });
  20. });
  21. Template.header.helpers({
  22. wrappedHeader() {
  23. return !Session.get('currentBoard');
  24. },
  25. currentSetting() {
  26. return Settings.findOne();
  27. },
  28. hideLogo() {
  29. return Utils.isMiniScreen() && Session.get('currentBoard');
  30. },
  31. appIsOffline() {
  32. return !Meteor.status().connected;
  33. },
  34. hasAnnouncement() {
  35. const announcements = Announcements.findOne();
  36. return announcements && announcements.enabled;
  37. },
  38. announcement() {
  39. $('.announcement').show();
  40. const announcements = Announcements.findOne();
  41. return announcements && announcements.body;
  42. },
  43. });
  44. Template.header.events({
  45. 'click .js-create-board': Popup.open('headerBarCreateBoard'),
  46. 'click .js-close-announcement'() {
  47. $('.announcement').hide();
  48. },
  49. 'click .js-select-list'() {
  50. Session.set('currentList', this._id);
  51. Session.set('currentCard', null);
  52. },
  53. 'click .js-toggle-desktop-drag-handles'() {
  54. //currentUser = Meteor.user();
  55. //if (currentUser) {
  56. // Meteor.call('toggleDesktopDragHandles');
  57. //} else if (window.localStorage.getItem('showDesktopDragHandles')) {
  58. if (window.localStorage.getItem('showDesktopDragHandles')) {
  59. window.localStorage.removeItem('showDesktopDragHandles');
  60. location.reload();
  61. } else {
  62. window.localStorage.setItem('showDesktopDragHandles', 'true');
  63. location.reload();
  64. }
  65. },
  66. });
  67. Template.offlineWarning.events({
  68. 'click a.app-try-reconnect'(event) {
  69. event.preventDefault();
  70. Meteor.reconnect();
  71. },
  72. });