scripts.js 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // var doTheScroll = true;
  2. function debugRow(y, height) {
  3. if(y === undefined) y = 0;
  4. if(height === undefined) height = 1;
  5. $('body').append('<div class="debugrow" style="top: '+y+'px; height: '+height+'px; background: blue; position: absolute; width: 100%; opacity: 0.5;"></div>');
  6. }
  7. $(function() {
  8. // EU COOKIE MONSTER
  9. var eupref = Cookies.get('eu-disable');
  10. if(eupref == undefined) {
  11. var cmaside = $('<aside id="cookie_monster">'+
  12. ' <div class="content">'+
  13. ' <p>Hello, did you know that I am using <strong>cookies</strong> in this website? I promise they are not tracking you, but I can disable them if you want.</p>'+
  14. ' <button class="button yes" type="button" data-disable="true">Disable them</button><button class="button no" data-disable="false">It\'s ok</button>'+
  15. ' </div>'+
  16. '</aside>');
  17. $('#top_banner').prepend(cmaside)
  18. $('#cookie_monster button').click(function(e) {
  19. debugger;
  20. t = $(e.target);
  21. if(t.data('disable')) {
  22. Cookies.set('eu-disable', true, { expires: 365 });
  23. } else {
  24. Cookies.set('eu-disable', false, { expires: 365 });
  25. }
  26. cmaside.fadeOut();
  27. });
  28. } else {
  29. Cookies.set('eu-disable', Cookies.get('eu-disable'), {expires: 365});
  30. if(Cookies.get('eu-disable') == "true") {
  31. window['ga-disable-UA-1176762-5'] = true;
  32. } else {
  33. window['ga-disable-UA-1176762-5'] = false;
  34. }
  35. }
  36. // EU COOKIE MONSTER
  37. if(screen.width > 1024 && screen.height > 768 && window.devicePixelRatio > 1) {
  38. $('[data-hq]').each(function() {
  39. t = $(this);
  40. if(t.is('img')) {
  41. t.attr('src', t.data('hq'));
  42. } else {
  43. t.css('background-image', 'url(' + t.data('hq') + ')');
  44. }
  45. });
  46. }
  47. baseline = 28;//parseFloat($('body').data('baseline'));
  48. $('figure').each(function(i, e) {
  49. figure = $(e);
  50. realTop = figure.offset().top;
  51. // debugRow(realTop);
  52. realBottom = realTop + figure.height() + parseFloat(figure.css('margin-bottom'));
  53. // debugRow(realBottom);
  54. gap = baseline - ((realBottom - $('article.body').offset().top) % baseline);
  55. figure.css('margin-top', '+=' + gap/2.0 + 'px');
  56. figure.css('margin-bottom', '+=' + gap/2.0 + 'px');
  57. });
  58. /**
  59. h = $(document).height();
  60. b = 28;
  61. c = $('#content_box').offset().top + b;
  62. $('body').append('<div id="baseline_overlay" style="position: absolute; top: '+c+'px; width: 100%; height: ' + h + 'px; opacity: 0.4;"></div>');
  63. bs = $('#baseline_overlay');
  64. cl = 0;
  65. while(cl < h) {
  66. bs.append('<div style="position: absolute; top: ' +cl+ 'px; height: 1px; background: red; width: 100%;"></div>');
  67. cl += b;
  68. }
  69. /**/
  70. });