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 window.location = $(this).attr('href'); 110 } 111 else 112 { 113 event.stopPropagation(); 114 } 115 } 116 }); 117 118 119 // links other than the first (master) link also within biggerlink 120 121 // other links are independent 122 if(settings.otherstriggermaster) 123 { 124 links.other.addClass(settings.biggerclass) 125 .bind('click',function(event){ 126 // trigger click events on master link instead 127 $(this).data('biggerlink').master.trigger({type:'click',source:'biggerlink'}); 128 129 // stop this link being followed 130 event.preventDefault(); 131 132 // prevent events on parent elements being triggered 133 event.stopPropagation(); 134 }); 135 } 136 137 // other links are slaves of master link 138 else 139 { 140 links.other 141 .bind('focus',function(){ 142 $(this).data('biggerlink').big.addClass(settings.hoverclass2); 143 $(this).data('biggerlink').big.data('biggerlink').focused2 = true; 144 }) 145 .bind('blur',function(){ 146 if(!$(this).data('biggerlink').big.data('biggerlink').hovered2) 147 { 148 $(this).data('biggerlink').big.removeClass(settings.hoverclass2); 149 } 150 $(this).data('biggerlink').big.data('biggerlink').focused2 = false;
151 152 }) 153 .bind('mouseover',function(event){ 154 $(this).data('biggerlink').big.addClass(settings.hoverclass2); 155 $(this).data('biggerlink').big.data('biggerlink').hovered2 = true; 156 event.stopPropagation(); 157 }) 158 .bind('mouseout',function(event){ 159 if(!$(this).data('biggerlink').big.data('biggerlink').focused2) 160 { 161 $(this).data('biggerlink').big.removeClass(settings.hoverclass2); 162 } 163 $(this).data('biggerlink').big.data('biggerlink').hovered2 = false; 164 event.stopPropagation(); 165 }); 166 167 if(!links.other.attr('title')) 168 { 169 links.other.attr('title',''); 170 } 171 } 172 }); 173 return this; 174 }; 175})(jQuery); 176 177 $(function(){ 178 179 // Supporting target _blank 180 $('a[target="_blank"]').click(function(){ 181 window.open(this.href); 182 return false; 183 }); 184 185 // Same using the valid rel attribute 186 $('a[rel="external"]').click(function(){ 187 window.open(this.href); 188 return false; 189 }); 190 191 // Adding biggerlink 192 $('#links li').biggerlink(); 193 });
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.