scripts.js 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /*
  2. Bones Scripts File
  3. Author: Eddie Machado
  4. This file should contain any js scripts you want to add to the site.
  5. Instead of calling it in the header or throwing it inside wp_head()
  6. this file will be called automatically in the footer so as not to
  7. slow the page load.
  8. */
  9. // as the page loads, call these scripts
  10. jQuery(document).ready(function($) {
  11. /*
  12. Responsive jQuery is a tricky thing.
  13. There's a bunch of different ways to handle
  14. it so, be sure to research and find the one
  15. that works for you best.
  16. */
  17. /* getting viewport width */
  18. var responsive_viewport = $(window).width();
  19. /* if is below 481px */
  20. if (responsive_viewport < 481) {
  21. } /* end smallest screen */
  22. /* if is larger than 481px */
  23. if (responsive_viewport > 481) {
  24. } /* end larger than 481px */
  25. /* if is above or equal to 768px */
  26. if (responsive_viewport >= 768) {
  27. /* load gravatars */
  28. $('.comment img[data-gravatar]').each(function(){
  29. $(this).attr('src',$(this).attr('data-gravatar'));
  30. });
  31. }
  32. /* off the bat large screen actions */
  33. if (responsive_viewport > 1030) {
  34. }
  35. // add all your scripts here
  36. }); /* end of as page load scripts */
  37. /*! A fix for the iOS orientationchange zoom bug.
  38. Script by @scottjehl, rebound by @wilto.
  39. MIT License.
  40. */
  41. (function(w){
  42. // This fix addresses an iOS bug, so return early if the UA claims it's something else.
  43. if( !( /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1 ) ){ return; }
  44. var doc = w.document;
  45. if( !doc.querySelector ){ return; }
  46. var meta = doc.querySelector( "meta[name=viewport]" ),
  47. initialContent = meta && meta.getAttribute( "content" ),
  48. disabledZoom = initialContent + ",maximum-scale=1",
  49. enabledZoom = initialContent + ",maximum-scale=10",
  50. enabled = true,
  51. x, y, z, aig;
  52. if( !meta ){ return; }
  53. function restoreZoom(){
  54. meta.setAttribute( "content", enabledZoom );
  55. enabled = true; }
  56. function disableZoom(){
  57. meta.setAttribute( "content", disabledZoom );
  58. enabled = false; }
  59. function checkTilt( e ){
  60. aig = e.accelerationIncludingGravity;
  61. x = Math.abs( aig.x );
  62. y = Math.abs( aig.y );
  63. z = Math.abs( aig.z );
  64. // If portrait orientation and in one of the danger zones
  65. if( !w.orientation && ( x > 7 || ( ( z > 6 && y < 8 || z < 8 && y > 6 ) && x > 5 ) ) ){
  66. if( enabled ){ disableZoom(); } }
  67. else if( !enabled ){ restoreZoom(); } }
  68. w.addEventListener( "orientationchange", restoreZoom, false );
  69. w.addEventListener( "devicemotion", checkTilt, false );
  70. })( this );