1 2;(function ($, window, document, undefined ) { 3 4 var pluginName = "ikissToggleToAnchor", 5 defaults = { 6 windowEvents : "load hashchange", 7 titleSelector : "h2.toggler-title", 8 containerSelector : "div.toggler-container", 9 activeCls : "active" 10 }; 11 12 function Plugin (element, options) { 13 14 $.extend(this, { 15 element : element, 16 options : $.extend({}, defaults, options), 17 _defaults : defaults, 18 _name : pluginName 19 }); 20 21 this.init(); 22 } 23 24 Plugin.prototype = { 25 26 onEvent: function(e) { 27 var sc = e.data.scope, 28 fn = e.data.fn, 29 args = [e].concat(e.data.args || []); 30 31 sc[fn] && sc[fn].apply(sc, args); 32 }, 33 34 init: function() { 35 var me = this, 36 op = me.options; 37 38 $(window).on(op.windowEvents, {fn: 'checkHash', scope: me}, me.onEvent); 39 }, 40 41 checkHash: function() { 42 var hash = window.location.hash, 43 trgEl = hash && $(hash, this.element).get(0), 44 op = this.options; 45 46 if (!trgEl) 47 return; 48 49 var hitEls = $(trgEl).parentsUntil(this.element, op.containerSelector).get(), 50 hit = 0, 51 i = 0, 52 cur; 53 54 if (!hitEls || !hitEls.length) 55 return; 56 57 for (; i < hitEls.length; i++) { 58 cur = hitEls[i]; 59 if (!$(cur).is(":visible")){ 60 $(cur).css('display', ''); 61 $($(cur).prev(op.titleSelector).get(0)).addClass(op.activeCls); 62 hit = 1; 63 } 64 } 65 66 if (hit) { 67 var topPos = parseInt($(trgEl).offset().top, 10); 68 $('html, body').animate({scrollTop: topPos}, 500); 69 } 70 } 71 72 }; 73 74 $.fn[pluginName] = function ( options ) { 75 var pKey = "ikissplugin_"+pluginName; 76 return this.each(function() { 77 if (!$.data(this, pKey)) { 78 $.data(this, pKey, new Plugin(this, options)); 79 } 80 }); 81 }; 82 83})(jQuery, window, document);
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.