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 // NOT WORKING for target = _blank: 79 // $(this).data('biggerlink').master.trigger({type:'click',source:'biggerlink'}); 80 81 // workaround 82 if ($(this).data('biggerlink').master.length > 0) { 83 var link = $(this).data('biggerlink').master.get(0); 84 if (link.click) { 85 link.click(); 86 } else { 87 $(this).data('biggerlink').master.click(); 88 } 89 } 90 91 event.stopPropagation(); 92 } 93 }); 94 95 96 97 // focus/blur 98 99 links.all 100 .bind('focus',function(){ 101 $(this).data('biggerlink').big.addClass(settings.hoverclass); 102 $(this).data('biggerlink').big.data('biggerlink').focused = true; 103 }).bind('blur',function(){ 104 if(!$(this).data('biggerlink').big.data('biggerlink').hovered) 105 { 106 $(this).data('biggerlink').big.removeClass(settings.hoverclass); 107 } 108 $(this).data('biggerlink').big.data('biggerlink').focused = false; 109 }); 110 111 112 113 // click/focus/blur event on master (first) link within biggerlink 114 115 links.master 116 .bind('click',function(event){ 117 if(event.source == 'biggerlink') 118 { 119 if(settings.follow === true || settings.follow == 'auto' && event.result !== false) 120 { 121 window.location = $(this).attr('href'); 122 } 123 else 124 { 125 event.stopPropagation(); 126 } 127 } 128 }); 129 130 131 // links other than the first (master) link also within biggerlink 132 133 // other links are independent 134 if(settings.otherstriggermaster) 135 { 136 links.other.addClass(settings.biggerclass) 137 .bind('click',function(event){ 138 // trigger click events on master link instead 139 $(this).data('biggerlink').master.trigger({type:'click',source:'biggerlink'}); 140 141 // stop this link being followed 142 event.preventDefault(); 143 144 // prevent events on parent elements being triggered 145 event.stopPropagation(); 146 }); 147 } 148 149 // other links are slaves of master link 150 else 151 {
152 links.other 153 .bind('focus',function(){ 154 $(this).data('biggerlink').big.addClass(settings.hoverclass2); 155 $(this).data('biggerlink').big.data('biggerlink').focused2 = true; 156 }) 157 .bind('blur',function(){ 158 if(!$(this).data('biggerlink').big.data('biggerlink').hovered2) 159 { 160 $(this).data('biggerlink').big.removeClass(settings.hoverclass2); 161 } 162 $(this).data('biggerlink').big.data('biggerlink').focused2 = false; 163 164 }) 165 .bind('mouseover',function(event){ 166 $(this).data('biggerlink').big.addClass(settings.hoverclass2); 167 $(this).data('biggerlink').big.data('biggerlink').hovered2 = true; 168 event.stopPropagation(); 169 }) 170 .bind('mouseout',function(event){ 171 if(!$(this).data('biggerlink').big.data('biggerlink').focused2) 172 { 173 $(this).data('biggerlink').big.removeClass(settings.hoverclass2); 174 } 175 $(this).data('biggerlink').big.data('biggerlink').hovered2 = false; 176 event.stopPropagation(); 177 }); 178 179 if(!links.other.attr('title')) 180 { 181 links.other.attr('title',''); 182 } 183 } 184 }); 185 return this; 186 }; 187})(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.