1/* 2* PlusAnchor 3* A form component library 4* Version: "1.1.2" 5* Jamy Golden 6* https://github.com/JamyGolden/PlusAnchor 7* License: MIT 8*/ 9(function($){ 10 11 function scrollToEvent(base) { 12 return function(e) { 13 e.preventDefault(); 14 15 var $this = $(this); // Anchor el 16 var href = $this.attr('href'); 17 var $name = $('a[name="' + href.substring(1) + '"]'); 18 19 if ( $(href).length ){ 20 21 // onSlide callback 22 if ( base.options.onSlide && typeof( base.options.onSlide ) === 'function' ) { 23 base.options.onSlide( base ); 24 }; 25 26 // End onSlide callback 27 base.$el.animate({ 28 scrollTop: $(href).offset().top + base.options.offsetTop 29 }, base.options.speed, base.options.easing); 30 31 } else if ( $name.length ){ 32 33 // onSlide callback 34 if ( base.options.onSlide && typeof( base.options.onSlide ) === 'function' ) { 35 base.options.onSlide( base ); 36 }; 37 38 // End onSlide callback 39 base.$el.animate({ 40 scrollTop: $name.offset().top + base.options.offsetTop 41 }, base.options.speed, base.options.easing); 42 43 } 44 } 45 } 46 47 $.plusAnchor = function(el, options){ 48 // To avoid scope issues, use 'base' instead of 'this' 49 // to reference this class from internal events and functions. 50 var base = this; 51 var htmlEl = document.getElementsByTagName('html'); 52 var bodyEl = document.body; 53 // If the user selects body, make sure to use 'html, body' for 54 // cross browser compatibility reasons 55 base.el = el; 56 base.$el = (el === htmlEl || el === bodyEl) ? $('html, body') : $(el); 57 base.$el.data('plusAnchor', base); // Add a reverse reference to the DOM object 58 59 function _constructor() { 60 var anchorSelector = options.includeCssIndication ? '.js-plus-anchor' : 'a[href^="#"]'; 61 62 // Check for plusanchor disable 63 if (options === false) { 64 base.$el.find(anchorSelector).off('click.plusanchor'); 65 return; 66 }; 67 68 // Extend options with user preferences 69 base.options = $.extend({}, $.plusAnchor.defaults, options); 70 71 // onInit callback 72 if ( base.options.onInit && typeof( base.options.onInit ) === 'function' ) { 73 base.options.onInit( base ); 74 }; 75 // End onInit callback 76 77 if (!base.options.performance) { 78 base.$el.on('click', anchorSelector, scrollToEvent(base)); 79 } else { 80 base.$el.find(anchorSelector).on('click.plusanchor', scrollToEvent(base)); 81 } 82 }; // _constructor 83 84 // Run initializer 85 _constructor(); 86 }; 87 88 $.plusAnchor.defaults = { 89 easing: 'swing', // String: Anything other than "swing" or "linear" requires the easing.js plugin 90 offsetTop: 0, // Int: Top offset for anchor scrollto position. Can be positive or negative 91 speed: 1000, // Int: The speed, in miliseconds, it takes to complete a slide 92 onInit: null, // Function: Callback function on plugin initialize 93 onSlide: null, // Function: Callback function that runs just before the page starts animating 94 performance: false, // Boolean: Toggles between click and delegate events. 95 includeCssIndication: false //Boolean: set to true to bind anchors with 'js-plus-anchor' CSS class name only 96 }; 97 98 $.fn.plusAnchor = function(options){ 99 return this.each(function(){ 100 (new $.plusAnchor(this, options)); 101 }); 102 }; 103})(jQuery);
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.