scripts.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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. /******** RESPONSIVE GOODNESS *********/
  12. /* getting viewport width */
  13. var responsive_viewport = $(window).width();
  14. /* if is below 481px */
  15. if (responsive_viewport < 481) {
  16. } /* end smallest screen */
  17. /* if is larger than 481px */
  18. if (responsive_viewport > 481) {
  19. } /* end larger than 481px */
  20. /* if is above 768px */
  21. if (responsive_viewport > 768) {
  22. /* load gravatars */
  23. $('.comment img[data-gravatar]').each(function(){
  24. $(this).attr('src',$(this).attr('data-gravatar'));
  25. });
  26. }
  27. /* off the bat large screen actions */
  28. if (responsive_viewport > 1030) {
  29. }
  30. // add all your scripts here
  31. }); /* end of as page load scripts */
  32. // HTML5 Fallbacks for older browsers
  33. $(function() {
  34. // check placeholder browser support
  35. if (!Modernizr.input.placeholder) {
  36. // set placeholder values
  37. $(this).find('[placeholder]').each(function() {
  38. $(this).val( $(this).attr('placeholder') );
  39. });
  40. // focus and blur of placeholders
  41. $('[placeholder]').focus(function() {
  42. if ($(this).val() === $(this).attr('placeholder')) {
  43. $(this).val('');
  44. $(this).removeClass('placeholder');
  45. }
  46. }).blur(function() {
  47. if ($(this).val() === '' || $(this).val() === $(this).attr('placeholder')) {
  48. $(this).val($(this).attr('placeholder'));
  49. $(this).addClass('placeholder');
  50. }
  51. });
  52. // remove placeholders on submit
  53. $('[placeholder]').closest('form').submit(function() {
  54. $(this).find('[placeholder]').each(function() {
  55. if ($(this).val() === $(this).attr('placeholder')) {
  56. $(this).val('');
  57. }
  58. });
  59. });
  60. }
  61. });
  62. /*! A fix for the iOS orientationchange zoom bug.
  63. Script by @scottjehl, rebound by @wilto.
  64. MIT License.
  65. */
  66. (function(w){
  67. // This fix addresses an iOS bug, so return early if the UA claims it's something else.
  68. if( !( /iPhone|iPad|iPod/.test( navigator.platform ) && navigator.userAgent.indexOf( "AppleWebKit" ) > -1 ) ){
  69. return;
  70. }
  71. var doc = w.document;
  72. if( !doc.querySelector ){ return; }
  73. var meta = doc.querySelector( "meta[name=viewport]" ),
  74. initialContent = meta && meta.getAttribute( "content" ),
  75. disabledZoom = initialContent + ",maximum-scale=1",
  76. enabledZoom = initialContent + ",maximum-scale=10",
  77. enabled = true,
  78. x, y, z, aig;
  79. if( !meta ){ return; }
  80. function restoreZoom(){
  81. meta.setAttribute( "content", enabledZoom );
  82. enabled = true;
  83. }
  84. function disableZoom(){
  85. meta.setAttribute( "content", disabledZoom );
  86. enabled = false;
  87. }
  88. function checkTilt( e ){
  89. aig = e.accelerationIncludingGravity;
  90. x = Math.abs( aig.x );
  91. y = Math.abs( aig.y );
  92. z = Math.abs( aig.z );
  93. // If portrait orientation and in one of the danger zones
  94. if( !w.orientation && ( x > 7 || ( ( z > 6 && y < 8 || z < 8 && y > 6 ) && x > 5 ) ) ){
  95. if( enabled ){
  96. disableZoom();
  97. }
  98. }
  99. else if( !enabled ){
  100. restoreZoom();
  101. }
  102. }
  103. w.addEventListener( "orientationchange", restoreZoom, false );
  104. w.addEventListener( "devicemotion", checkTilt, false );
  105. })( this );