1(function ($, window, Drupal) { 2 3 Drupal.behaviors.scrollTopButton = { 4 attach: function (context, settings) { 5 6 var button_text = drupalSettings.button_text; 7 var button_style = drupalSettings.button_style; 8 var button_animation = drupalSettings.button_animation; 9 var button_animation_speed = parseInt(drupalSettings.button_animation_speed); 10 var scroll_distance = parseInt(drupalSettings.scroll_distance); 11 var scroll_speed = parseInt(drupalSettings.scroll_speed); 12 13 var element_name = 'scrollTopButton-' + button_style; 14 15 if (button_style == 'image') { 16 button_text = ''; 17 } 18 19 var $element = $('<a/>', {id: element_name, href: '#', class:'scroll-top-button'}); 20 21 if ($('#' + element_name).length === 0) { 22 $element.appendTo('body'); 23 } 24 25 $element.html(button_text); 26 27 var animationIn = 'show'; 28 var animationOut = 'hide'; 29 var animationSpeed = 0; 30 var buttonVisible = false; 31 32 // set animation for the button 33 if (button_animation == 'fade') { 34 animationIn = 'fadeIn'; 35 animationOut = 'fadeOut'; 36 animationSpeed = button_animation_speed; 37 } 38 39 if (button_animation == 'slide') { 40 animationIn = 'slideDown'; 41 animationOut = 'slideUp'; 42 animationSpeed = button_animation_speed; 43 } 44 45 $(window).scroll(function () { 46 if ($(window).scrollTop() > scroll_distance) { 47 if (!buttonVisible) { 48 $element[animationIn](animationSpeed); 49 buttonVisible = true; 50 } 51 } else { 52 if (buttonVisible) { 53 $element[animationOut](animationSpeed); 54 buttonVisible = false; 55 } 56 } 57 }); 58 59 // Scroll to top after click on button 60 $element.click(function (event) { 61 event.preventDefault(); 62 63 $('html, body').animate({ scrollTop: 0}, scroll_speed, 'linear'); 64 }); 65 66 } 67 }; 68 69 })(jQuery, window, Drupal);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.