1/*** 2 * flexitClickable 3 * 4 * Plugin créeant un classe sur tous les blocs comportant un attribut data-goto-url (pour faire des blocs complétement cliquables) 5 */ 6 7( function( $ ){ 8 9 var fElemsClickables = null; 10 11 var methods = { 12 // initialisation des variables 13 init : function( options ) { 14 return this.each(function(){ 15 // Récupération de tous les éléments qui ont un data goto pour leur attribuer une classe si elle n'existe pas 16 fElemClickables = $(this).find('[data-goto-url]'); 17 for( i = 0, len = fElemClickables.length; i < len; i++ ) { 18 var currentTarget = $( fElemClickables[i] ); 19 if ( !currentTarget.hasClass('flexit-clickable-element') ) 20 currentTarget.addClass('flexit-clickable-element'); 21 currentTarget.attr('tabindex','0'); 22 currentTarget.find('a[href="'+currentTarget.attr('data-goto-url')+'"]').attr('tabindex','-1'); 23 } 24 25 // Ajout de l'événement de click (avec fonction "live") 26 $(this).on('click', '[data-goto-url]', function( event, a ) { 27 var currentTarget = $( event.currentTarget ); 28 var target = $( event.target ); 29 var gotoTarget = currentTarget.data('goto-target'); 30 var gotoUrl = currentTarget.data('goto-url'); 31 32 if( gotoUrl != "undefined" && gotoUrl != "") { 33 // permet d'ignorer le changement d'url si on clique dans un bloc addthis pour le partage 34 if( target.parents('.addthis_toolbox').length == 0 ) { 35 if( !gotoTarget || gotoTarget == "undefined" || gotoTarget == "" ) { 36 window.location.href = gotoUrl; 37 } else { 38 window.open ( gotoUrl, gotoTarget ); 39 } 40 } 41 } 42 }); 43 44 // Propagation dans les liens (en mode délégation pour gérer les multipages etc 45 $(this).on('click', '[data-goto-url] a,[data-goto-url] button,[data-goto-url] input,[data-goto-url] select,[data-goto-url] textarea', function( event ) { 46 event.stopPropagation(); 47 }); 48 }); 49 } 50 }; 51 52 $.fn.flexitClickable = function( method ) { 53 54 // Method calling logic 55 if ( methods[method] ) { 56 return methods[ method ].apply( this, Array.prototype.slice.call( arguments, 1 )); 57 } else if ( typeof method === 'object' || ! method ) { 58 return methods.init.apply( this, arguments ); 59 } else { 60 $.error( 'La méthode ' + method + ' est inexistante dans jQuery.flexitClickable' ); 61 } 62 63 }; 64 65 return this; 66 67})( jQuery ); 68 69jQuery(document).ready(function(){ 70 jQuery(document.body).flexitClickable(); 71});
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.