scripts.js 2.6 KB

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