main.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. $(window).scroll(function() {
  2. if ($(document).scrollTop() > 80) {
  3. $('nav').addClass('shrink');
  4. } else {
  5. $('nav').removeClass('shrink');
  6. }
  7. });
  8. $('#datepicker.input-daterange').datepicker({});
  9. $('#event-form').validator()
  10. $(function(){
  11. jQuery('img.svg').each(function(){
  12. var $img = jQuery(this);
  13. var imgID = $img.attr('id');
  14. var imgClass = $img.attr('class');
  15. var imgURL = $img.attr('src');
  16. jQuery.get(imgURL, function(data) {
  17. // Get the SVG tag, ignore the rest
  18. var $svg = jQuery(data).find('svg');
  19. // Add replaced image's ID to the new SVG
  20. if(typeof imgID !== 'undefined') {
  21. $svg = $svg.attr('id', imgID);
  22. }
  23. // Add replaced image's classes to the new SVG
  24. if(typeof imgClass !== 'undefined') {
  25. $svg = $svg.attr('class', imgClass+' replaced-svg');
  26. }
  27. // Remove any invalid XML tags as per http://validator.w3.org
  28. $svg = $svg.removeAttr('xmlns:a');
  29. // Check if the viewport is set, else we gonna set it if we can.
  30. if(!$svg.attr('viewBox') && $svg.attr('height') && $svg.attr('width')) {
  31. $svg.attr('viewBox', '0 0 ' + $svg.attr('height') + ' ' + $svg.attr('width'))
  32. }
  33. // Replace image with new SVG
  34. $img.replaceWith($svg);
  35. }, 'xml');
  36. });
  37. });