general.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. function screenClass() {
  2. // ADD A CLASS Start
  3. "use strict";
  4. if ($(window).innerWidth() <= 767) {
  5. $('body').addClass('mobile-screen').removeClass('desktop-screen');
  6. } else {
  7. $('body').addClass('desktop-screen').removeClass('mobile-screen');
  8. }
  9. // ADD A CLASS End
  10. // KOPIEREN EINES ELEMENTS AN EINE ANDERE STELLE Start
  11. // Icons
  12. if ($(window).innerWidth() <= 575.98) {
  13. $('#append').appendTo($('#append_paste'));
  14. }
  15. // KOPIEREN EINES ELEMENTS AN EINE ANDERE STELLE End
  16. // BUGFIX APPLE DEVICES 100vh Start
  17. const appHeight = () => {
  18. const doc = document.documentElement
  19. doc.style.setProperty('--app-height', `${window.innerHeight}px`)
  20. }
  21. window.addEventListener('resize', appHeight)
  22. appHeight()
  23. // BUGFIX APPLE DEVICES 100vh End
  24. }
  25. screenClass();
  26. $(document).ready(function () {
  27. // SHRINK Start
  28. $(window).scroll(function () {
  29. if ($(document).scrollTop() > 100) {
  30. $('.default-header').addClass('shrink');
  31. } else {
  32. $('.default-header').removeClass('shrink');
  33. }
  34. // SHRINK End
  35. /* BACK TO TOP PLUGIN */
  36. if ($(this).scrollTop() >= 1000) {
  37. $('.backtotop').fadeIn();
  38. } else {
  39. $('.backtotop').fadeOut();
  40. }
  41. });
  42. $('.backtotop').click(function () {
  43. $('body,html').animate(0, 800);
  44. $('body,html').animate({
  45. scrollTop: 0
  46. }, 800);
  47. return false;
  48. });
  49. /* CLOSE BACK TO TOP PLUGIN */
  50. // REPLACE SVG Start
  51. jQuery('img.svg').each(function(){
  52. var $img = jQuery(this);
  53. var imgID = $img.attr('id');
  54. var imgClass = $img.attr('class');
  55. var imgURL = $img.attr('src');
  56. jQuery.get(imgURL, function(data) {
  57. // Get the SVG tag, ignore the rest
  58. var $svg = jQuery(data).find('svg');
  59. // Add replaced image's ID to the new SVG
  60. if(typeof imgID !== 'undefined') {
  61. $svg = $svg.attr('id', imgID);
  62. }
  63. // Add replaced image's classes to the new SVG
  64. if(typeof imgClass !== 'undefined') {
  65. $svg = $svg.attr('class', imgClass+' replaced-svg');
  66. }
  67. // Remove any invalid XML tags as per http://validator.w3.org
  68. $svg = $svg.removeAttr('xmlns:a');
  69. // Replace image with new SVG
  70. $img.replaceWith($svg);
  71. }, 'xml');
  72. });
  73. /* REPLACE SVG End */
  74. // STACK MENU Start
  75. $('#stack-menu').stackMenu({
  76. //all: true, // add links to parents
  77. //allTitle: 'All' // parents links text
  78. });
  79. var trigger = $('.jumpmark_selector');
  80. var list = $('.jumpmark_container');
  81. trigger.click(function() {
  82. trigger.toggleClass('active');
  83. list.slideToggle(200);
  84. });
  85. // this is optional to close the list while the new page is loading
  86. list.click(function() {
  87. trigger.click();
  88. });
  89. // STACK MENU End
  90. // document.ready End
  91. });