header.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /**
  2. * @description This module takes care of the header.
  3. * @copyright 2015 by Tobias Reich
  4. */
  5. header = {
  6. _dom: $('header')
  7. }
  8. header.dom = function(selector) {
  9. if (selector===undefined||selector===null||selector==='') return header._dom;
  10. return header._dom.find(selector);
  11. }
  12. header.show = function() {
  13. var newMargin = -1*($('#imageview #image').height()/2)+20;
  14. clearTimeout($(window).data('timeout'));
  15. lychee.imageview.removeClass('full');
  16. header.dom().removeClass('hidden');
  17. lychee.loadingBar.css('opacity', 1);
  18. // Adjust position or size of photo
  19. if ($('#imageview #image.small').length>0) $('#imageview #image').css('margin-top', newMargin);
  20. else $('#imageview #image').removeClass('full');
  21. }
  22. header.hide = function(e, delay) {
  23. var newMargin = -1*($('#imageview #image').height()/2);
  24. if (delay===undefined) delay = 500;
  25. if (visible.photo()&&!visible.infobox()&&!visible.contextMenu()&&!visible.message()) {
  26. clearTimeout($(window).data('timeout'));
  27. $(window).data('timeout', setTimeout(function() {
  28. lychee.imageview.addClass('full');
  29. header.dom().addClass('hidden');
  30. lychee.loadingBar.css('opacity', 0);
  31. // Adjust position or size of photo
  32. if ($('#imageview #image.small').length>0) $('#imageview #image').css('margin-top', newMargin);
  33. else $('#imageview #image').addClass('full');
  34. }, delay));
  35. }
  36. }
  37. header.setMode = function(mode) {
  38. var albumID = album.getID();
  39. switch (mode) {
  40. case 'albums':
  41. header.dom().removeClass('view');
  42. $('#tools_album, #tools_photo').hide();
  43. $('#tools_albums').show();
  44. break;
  45. case 'album':
  46. header.dom().removeClass('view');
  47. $('#tools_albums, #tools_photo').hide();
  48. $('#tools_album').show();
  49. // Hide download button when album empty
  50. album.json.content === false ? $('#button_archive').hide() : $('#button_archive').show();
  51. // Hide download button when not logged in and album not downloadable
  52. if (lychee.publicMode&&album.json.downloadable==='0') $('#button_archive').hide();
  53. if (albumID==='s'||albumID==='f'||albumID==='r') {
  54. $('#button_info_album, #button_trash_album, #button_share_album').hide();
  55. } else if (albumID==='0') {
  56. $('#button_info_album, #button_share_album').hide();
  57. $('#button_trash_album').show();
  58. } else {
  59. $('#button_info_album, #button_trash_album, #button_share_album').show();
  60. }
  61. break;
  62. case 'photo':
  63. header.dom().addClass('view');
  64. $('#tools_albums, #tools_album').hide();
  65. $('#tools_photo').show();
  66. break;
  67. }
  68. }