1/* 2 * jQuery.BiggerLink v2.0.1 3 * http://www.ollicle.com/eg/jquery/biggerlink/ 4 * 5 * Copyright (c) 2009 Oliver Boermans 6 * http://creativecommons.org/licenses/MIT/ 7 * 8 * 2009-11-22 (22 Nov 2009) 9*/ 10(function($) { 11 $.fn.biggerlink = function(options) { 12 13 // Default settings 14 var settings = { 15 biggerclass:'bl-bigger', // class added to the first contained link and others that trigger it 16 hoverclass:'bl-hover', // class added to parent element on hover/focus 17 hoverclass2:'bl-hover2', // class added to parent element on hover/focus of other links 18 clickableclass:'bl-hot', // class added to parent element with behaviour 19 otherstriggermaster: true, // will all links in containing biggerlink element trigger the first link 20 follow: 'auto' // follow master link on click? : 'auto',true,false 21 }; 22 if(options) { 23 $.extend(settings, options); 24 } 25 $(this).filter(function(){ 26 return $('a',this).length > 0; 27 28 }).addClass(settings.clickableclass).css('cursor', 'pointer').each(function(i){ 29 30 // store element references 31 var big = $(this).data('biggerlink',{hovered:false,focused:false,hovered2:false,focused2:false}); 32 var links = { 33 all: $('a',this), 34 big: $(this), 35 master: $('a:first',this).data('biggerlink',{status:'master'}).addClass(settings.biggerclass), 36 other: $('a',this).not($('a:first',this)).data('biggerlink',{status:'other'}) 37 }; 38 39 40 $('a',this).andSelf().each(function(){ 41 var newdata = $.extend($(this).data('biggerlink'),links); 42 $(this).data('biggerlink',newdata); 43 }); 44 45 46 47 // Add title of first link with title to parent if not already set 48 var thistitle = big.attr('title'); 49 var newtitle = big.data('biggerlink').master.attr('title'); 50 if(newtitle && !thistitle) 51 { 52 big.attr('title', newtitle); 53 } 54 55 56 57 // events on biggerlink element 58 59 big 60 .mouseover(function(event){ 61 window.status = $(this).data('biggerlink').master.get(0).href; 62 $(this).addClass(settings.hoverclass); 63 $(this).data('biggerlink').hovered = true; 64 }) 65 .mouseout(function(event){ 66 window.status = ''; 67 if(!$(this).data('biggerlink').focused) 68 { 69 $(this).removeClass(settings.hoverclass); 70 } 71 $(this).data('biggerlink').hovered = false; 72 }) 73 .bind('click',function(event){ 74 75 // if clicked direct or non-link 76 if(!$(event.target).closest('a').length) 77 { 78 $(this).data('biggerlink').master.trigger({type:'click',source:'biggerlink'}); 79 event.stopPropagation(); 80 } 81 }); 82 83 84 85 // focus/blur 86 87 links.all 88 .bind('focus',function(){ 89 $(this).data('biggerlink').big.addClass(settings.hoverclass); 90 $(this).data('biggerlink').big.data('biggerlink').focused = true; 91 }).bind('blur',function(){ 92 if(!$(this).data('biggerlink').big.data('biggerlink').hovered) 93 { 94 $(this).data('biggerlink').big.removeClass(settings.hoverclass); 95 } 96 $(this).data('biggerlink').big.data('biggerlink').focused = false; 97 }); 98 99 100 101 // click/focus/blur event on master (first) link within biggerlink 102 103 links.master 104 .bind('click',function(event){ 105 if(event.source == 'biggerlink') 106 { 107 if(settings.follow === true || settings.follow == 'auto' && event.result !== false) 108 { 109 if ($(this).attr('target') == "_blank") { 110 window.open($(this).attr('href')); 111 } else { 112 window.location = $(this).attr('href'); 113 } 114 } 115 else 116 { 117 event.stopPropagation(); 118 } 119 } 120 }); 121 122 123 // links other than the first (master) link also within biggerlink 124 125 // other links are independent 126 if(settings.otherstriggermaster) 127 { 128 links.other.addClass(settings.biggerclass) 129 .bind('click',function(event){ 130 // trigger click events on master link instead 131 $(this).data('biggerlink').master.trigger({type:'click',source:'biggerlink'}); 132 133 // stop this link being followed 134 event.preventDefault(); 135 136 // prevent events on parent elements being triggered 137 event.stopPropagation(); 138 }); 139 } 140 141 // other links are slaves of master link 142 else 143 {
144 links.other 145 .bind('focus',function(){ 146 $(this).data('biggerlink').big.addClass(settings.hoverclass2); 147 $(this).data('biggerlink').big.data('biggerlink').focused2 = true; 148 }) 149 .bind('blur',function(){ 150 if(!$(this).data('biggerlink').big.data('biggerlink').hovered2) 151 { 152 $(this).data('biggerlink').big.removeClass(settings.hoverclass2); 153 } 154 $(this).data('biggerlink').big.data('biggerlink').focused2 = false; 155 156 }) 157 .bind('mouseover',function(event){ 158 $(this).data('biggerlink').big.addClass(settings.hoverclass2); 159 $(this).data('biggerlink').big.data('biggerlink').hovered2 = true; 160 event.stopPropagation(); 161 }) 162 .bind('mouseout',function(event){ 163 if(!$(this).data('biggerlink').big.data('biggerlink').focused2) 164 { 165 $(this).data('biggerlink').big.removeClass(settings.hoverclass2); 166 } 167 $(this).data('biggerlink').big.data('biggerlink').hovered2 = false; 168 event.stopPropagation(); 169 }); 170 171 if(!links.other.attr('title')) 172 { 173 links.other.attr('title',''); 174 } 175 } 176 }); 177 return this; 178 }; 179})(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.