1/* Définition des comportements javascript du site */ 2 3 4window.addEvent('domready', function() { 5 $$('.themes select').addEvent('change', function() { 6 this.form.submit(); 7 }); 8 $$('a.back, a.retour').addEvent('click', function(e) { 9 if (document.referrer.indexOf(location.protocol+'//'+location.hostname) == 0) { 10 history.back(); 11 return false; 12 } 13 }); 14 $$('#nav-contenu .print').addEvent('click', function(e) { 15 window.print(); 16 return false; 17 }); 18 // Vérification des liens 19 var uri = location.protocol+'//'+location.host; 20 $$('#preview a[href]').each( function(a) { 21 var ext, infos, flength; 22 if (a.hasClass('noauto')) return; 23 if (a.getElement('img')) return; 24 if (a.href.search(/(pdf|doc|rtf|xls|xla|ppt|pps|zip|rar|jpg|png|gif)$/i) != -1) { 25 ext = RegExp.$1; 26 infos = ext.toUpperCase(); 27 a.addClass('icone fichier '+ext); 28 if (a.href.indexOf('http') == -1) return; 29 flength = ''; 30 new Request({ 31 method: 'HEAD', 32 url: a.href, 33 emulation: false, 34 async: true, 35 onSuccess: function() { 36 if (flength = this.getHeader('Content-Length')) { 37 infos += ', '+(flength/1024).round()+' Ko'; 38 } 39 new Element('span').set('text', ' ('+infos+')').injectInside(a); 40 a.setProperty('title', a.title+' ('+infos+')'); 41 }, 42 onFailure: function() { 43 a.addClass('broken'); 44 new Element('span').set('text', ' ('+infos+')').injectInside(a); 45 a.setProperty('title', a.title+' ('+infos+')'); 46 } 47 }).send(); 48 } else if (a.href.indexOf(uri) != 0 && a.href.indexOf('http') == 0) { 49 a.addClass('icone url'); 50 if (!a.getProperty('target')) a.setProperty('target', '_blank'); 51 } else if (a.href.indexOf('mailto:') == 0) { 52 a.addClass('icone email'); 53 } 54 }); 55 56 57}); 58window.addEvent('load', function() { 59 $$('#preview img').each (function (img) { 60 if (img.hasClass('noauto')) return; 61 if (img.src.indexOf('INTERVAL') != -1) return; 62 legende = ''; 63 // Vérifier si on n'est pas dans un <div> gauche droite ou centre 64 var parent = img.getParent('div'); 65 if (parent.hasClass('gauche') || parent.hasClass('droite') || parent.hasClass('centre')) { 66 return; 67 } 68 // Mettre le TITLE de l'image en légende dessous 69 if (img.get('title') && !img.hasClass('nolegend')) { 70 legende = new Element('span').set('text', img.get('title')); 71 } 72 // Détecter les zooms 73 a = img.getParent(); 74 if (a.get('tag') == 'a') { 75 if (!a.getProperty('rel') && a.href.match(/(jpg|png|gif)$/i)) { 76 var title; 77 if (legende) { 78 title = legende.get('text'); 79 } 80 else { 81 title = img.getProperty('alt'); 82 } 83 a.setProperties({ 84 'rel': 'lightbox[]', 85 'title': title 86 }); 87 } 88 } else { 89 a = false; 90 } 91 92 // Mettre un conteneur div autour des images alignées 93 var iclass, align; 94 if (!img.getProperty('align') && img.getProperty('class')) { 95 iclass = img.getProperty('class'); 96 img.removeProperty('class'); 97 img.removeProperty('align'); 98 } else if (img.getProperty('align')) { 99 align = img.getProperty('align'); 100 if (align == 'left') { 101 iclass = 'gauche'; 102 } 103 else if (align == 'right') { 104 iclass = 'droite'; 105 } 106 else { 107 iclass = 'centre'; 108 } 109 img.removeProperty('align'); 110 } else iclass = 'centre'; 111 div = new Element('div', { 112 'class': iclass 113 }); 114 if (legende) { 115 div.setStyle('position', 'relative'); 116 legende.injectInside(div); 117 legende.setStyles({ 118 'padding': '5px', 119 'position': 'absolute', 120 'bottom': 0, 121 'right': 0, 122 'left': 0, 123 'color': '#FFF', 124 'background': 'transparent url(images/opacity.png)' 125 }); 126 } 127 if (a != false) { 128 // On injecte le lien 129 a.clone().inject(div,'top'); 130 div.replaces(a); 131 } else { 132 // Pas de lien, on injecte l'image 133 img.clone().inject(div,'top'); 134 div.replaces(img); 135 } 136 }); 137 if (typeof Slimbox != 'undefined') { 138 Slimbox.scanPage(); 139 } 140 141 // Mettre la taille des div droite & gauche à celle de l'image... 142 $$('div.gauche, div.droite, div.centre').each( function(div) { 143 // Trouver l'image 144 var img = div.getElement('img'); 145 if (img) { 146 img.addEvent('load', function(e) { 147 if (this.width > 0) { 148 div.setStyle('width', this.width+'px'); 149 } 150 }); 151 } 152 } ); 153}); 154 155 156function minipopup(html, style, noclose) { 157 if ($('minipopup')) { 158 $('minipopup').dispose(); 159 } 160 if ($('overlay')) { 161 $('overlay').dispose(); 162 } 163 var minipopup = new Element('div', { 164 'id': 'minipopup', 165 'style': "position:absolute;visibility:hidden;overflow:auto;z-index:9999;"+style, 166 'class': 'row' 167 }); 168 if (typeof html == 'string') { 169 minipopup.set('html', html); 170 } else { 171 minipopup.adopt(html); 172 } 173 if (!noclose) { 174 var a = new Element('a').set({ 175 'class': 'close', 176 'style': 'clear: both; float: none; display: block; text-align: right', 177 'href': '#', 178 'text': 'Fermer' 179 }); 180 a.clone().inject(minipopup,'top'); 181 } 182 minipopup.inject(document.getElement('body')); 183 // Overlay
184 var overlay = new Element('div', { 185 'id': 'overlay', 186 'style': 'position: absolute; z-index: 9998; left: 0; width: 100%; background-color: #000; cursor: pointer; opacity: 0' 187 }); 188 overlay.injectInside(document.getElement('body')); 189 overlay.tween('opacity', [0, 0.5]); 190 function repos() { 191 var w = window.getSize(); 192 var d = minipopup.getSize(); 193 var s = window.getScroll(); 194 overlay.setStyles({ 195 'top': s.y+'px', 196 'height':w.y+'px' 197 }); 198 console.log(w); 199 console.log(d); 200 var left = (w.x/2-d.x/2+s.x)+'px'; 201 var top = (w.y/2-d.y/2+s.y)+'px'; 202 minipopup.setStyles({ 203 'visibility': 'visible', 204 'left': left, 205 'top': top 206 }); 207 } 208 window.addEvents({ 209 'scroll': repos, 210 'resize': repos 211 }); 212 repos(); 213 var cleanup = function() { 214 minipopup.dispose(); 215 overlay.dispose(); 216 window.removeEvent('scroll', repos); 217 window.removeEvent('resize', repos); 218 return false; 219 } 220 minipopup.getElements('.close').addEvent('click', cleanup); 221 overlay.addEvent('click', cleanup); 222} 223 224function addtpl(url, tpl) { 225 if (url.indexOf('tpl=') != -1) return url.replace(/tpl=[^&]+/, 'tpl='+tpl); 226 if (url.indexOf('?') == -1) return url+'?tpl='+tpl; 227 else return url+'&tpl='+tpl; 228} 229 230if (typeof console != "object") { 231 var console = { 232 'log':function(){} 233 }; 234}
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.