scripts.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. t = $(e.target);
  20. if(t.data('disable')) {
  21. Cookies.set('eu-disable', true, { expires: 30 });
  22. } else {
  23. Cookies.set('eu-disable', false, { expires: 30 });
  24. }
  25. cmaside.fadeOut();
  26. });
  27. } else {
  28. window['ga-disable-UA-1176762-5'] = Cookies.get('eu-disable');
  29. }
  30. // EU COOKIE MONSTER
  31. if(screen.width > 1024 && screen.height > 768 && window.devicePixelRatio > 1) {
  32. $('[data-hq]').each(function() {
  33. t = $(this);
  34. if(t.is('img')) {
  35. t.attr('src', t.data('hq'));
  36. } else {
  37. t.css('background-image', 'url(' + t.data('hq') + ')');
  38. }
  39. });
  40. }
  41. baseline = 28;//parseFloat($('body').data('baseline'));
  42. $('figure').each(function(i, e) {
  43. figure = $(e);
  44. realTop = figure.offset().top;
  45. // debugRow(realTop);
  46. realBottom = realTop + figure.height() + parseFloat(figure.css('margin-bottom'));
  47. // debugRow(realBottom);
  48. gap = baseline - ((realBottom - $('article.body').offset().top) % baseline);
  49. figure.css('margin-top', '+=' + gap/2.0 + 'px');
  50. figure.css('margin-bottom', '+=' + gap/2.0 + 'px');
  51. });
  52. /**
  53. h = $(document).height();
  54. b = 28;
  55. c = $('#content_box').offset().top + b;
  56. $('body').append('<div id="baseline_overlay" style="position: absolute; top: '+c+'px; width: 100%; height: ' + h + 'px; opacity: 0.4;"></div>');
  57. bs = $('#baseline_overlay');
  58. cl = 0;
  59. while(cl < h) {
  60. bs.append('<div style="position: absolute; top: ' +cl+ 'px; height: 1px; background: red; width: 100%;"></div>');
  61. cl += b;
  62. }
  63. /**/
  64. });