scripts.js 2.4 KB

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