1/* 2 * boutonstexte.js (c) toggg http://toggg.com 2006 -- licence LGPL 3 */ 4 5// on dépend de jQuery 6if (typeof jQuery == 'function') 7(function($){ 8 $(function(){ 9 var boutonstexte = new boutonsTexte(boutonstexte_options); 10 11 var boutons = $('<span class="boutonstexte"></span>'); 12 13 if (!$(".textsizeup").length && boutonstexte.txtSizeUp) { 14 $('<a href="#" class="textsizeup auto"><img src="'+boutonstexte.imgPath+'fontsizeup.svg" alt="' + boutonstexte.txtSizeUp +'" /></a>') 15 .appendTo(boutons); 16 } 17 if (!$(".textsizedown").length && boutonstexte.txtSizeDown) { 18 $('<a href="#" class="textsizedown auto"><img src="'+boutonstexte.imgPath+'fontsizedown.svg" alt="' + boutonstexte.txtSizeDown +'" /></a>') 19 .appendTo(boutons); 20 } 21 if (!$(".textonly").length && boutonstexte.txtOnly) { 22 $('<a href="#" class="textonly auto"><img src="'+boutonstexte.imgPath+'textonly.svg" alt="' + boutonstexte.txtOnly +'" /></a>') 23 .appendTo(boutons); 24 } 25 26 if (boutons.html()) { 27 $(boutonstexte.selector).before(boutons); 28 } 29 30 $("img.textsizeup,a.textsizeup,button.textsizeup") 31 .click(function(e) { 32 boutonstexte.fontBigger($(this).is('.auto') ? this : null); 33 e.stopPropagation(); 34 return false; 35 }) 36 .attr({'title':boutonstexte.txtSizeUp}); 37 38 $("img.textsizedown,a.textsizedown,button.textsizedown") 39 .click(function(e) { 40 boutonstexte.fontSmaller($(this).is('.auto') ? this : null); 41 e.stopPropagation(); 42 return false; 43 }) 44 .attr({'title':boutonstexte.txtSizeDown}); 45 46 $("img.textonly,a.textonly,button.textonly") 47 .click(function(e) { 48 boutonstexte.texteOnly($(this).is('.auto') ? this : null); 49 e.stopPropagation(); 50 return false; 51 }) 52 .attr({'title':boutonstexte.txtOnly}); 53 54 }); 55})(jQuery); 56 57// le prototype boutons du contenu 58function boutonsTexte(options) 59{ 60 this.rate = 1.2; 61 this.selector = "#contenu .texte"; 62 for (opt in options) { 63 this[opt] = options[opt]; 64 } 65} 66boutonsTexte.prototype.texteOnly = function(elt) 67{ 68 var that = this; 69 var texte = jQuery(elt).parent().next(); 70 jQuery("body").toggleClass('onlytext_wrapper'); 71 if (this['backTextOnly']) { 72 texte.removeClass("onlytext"); 73 jQuery(elt).attr({ 'title': that.txtOnly }). 74 parent().insertBefore(jQuery("#marktextonly")).after(texte); 75 jQuery("#marktextonly").remove(); 76 jQuery('body').children().removeClass('onlytext_hide'); 77 this.backTextOnly = false; 78 return; 79 } 80 texte.addClass("onlytext"); 81 jQuery(texte[texte.length-1]).after('<div id="marktextonly">marktextonly</div>'); 82 $('body>*').addClass('onlytext_hide'); 83 jQuery(elt).attr({ 'title': that.txtBackSpip }). 84 parent().prependTo("body").after(texte); 85 this.backTextOnly = true; 86} 87boutonsTexte.prototype.fontBigger = function(elt) 88{ 89 var that = this; 90 var work = elt ? jQuery(elt).parent().next() : jQuery(this.selector); 91 work.each(function(){ 92 // avec IE : 93 // passer par un wrapper dans le .texte car le texte peut avoir 94 // un font-size:small qu'on ne peut multiplier brutalement 95 wrap = jQuery(this); 96 if (jQuery.browser.msie) { 97 var wrap=jQuery(this).children('.fontwrap'); 98 if (!wrap.length) { 99 jQuery(this).html("<span class='fontwrap' style='font-size:100%'>" 100 +jQuery(this).html()+"</span>"); 101 var wrap=jQuery(this).children('.fontwrap'); 102 } 103 } 104 var m = wrap.css('fontSize').match(/(\d+(?:\.\d+)?)(.*)/); 105 wrap.css('fontSize', (that.rate * parseFloat(m[1])) + m[2]); 106 }); 107} 108boutonsTexte.prototype.fontSmaller = function(elt) 109{ 110 var that = this; 111 var work = elt ? jQuery(elt).parent().next() : jQuery(this.selector); 112 work.each(function(){ 113 // avec IE : 114 // passer par un wrapper dans le .texte car le texte peut avoir 115 // un font-size:small qu'on ne peut multiplier brutalement 116 wrap = jQuery(this); 117 if (jQuery.browser.msie) { 118 var wrap=jQuery(this).children('.fontwrap'); 119 if (!wrap.length) { 120 jQuery(this).html("<span class='fontwrap' style='font-size:100%'>" 121 +jQuery(this).html()+"</span>"); 122 var wrap=jQuery(this).children('.fontwrap'); 123 } 124 } 125 var m = wrap.css('fontSize').match(/(\d+(?:\.\d+)?)(.*)/); 126 wrap.css('fontSize' , (parseFloat(m[1]) / that.rate) + m[2]); 127 }); 128} 129 130function dump(elt) 131{var txt=''; for (var prop in elt) {txt += prop+'='+elt[prop]+'/';} alert(txt);}
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.