1;(function($) { 2 $.fn.previsu_spip = function(settings) { 3 var options; 4 5 options = { 6 previewParserPath: '' , 7 previewParserVar: 'data', 8 textEditer: 'Editer', 9 textVoir: 'Voir' 10 }; 11 $.extend(options, settings); 12 13 return this.each(function() { 14 15 var $$, textarea, tabs, preview; 16 $$ = $(this); 17 textarea = this; 18 19 // init and build previsu buttons 20 function init() { 21 $$.addClass("pp_previsualisation"); 22 tabs = $('<div class="markItUpTabs"></div>').prependTo($$.parent()); 23 $(tabs).append( 24 '<a href="#previsuVoir" class="previsuVoir">' + options.textVoir + '</a>' + 25 '<a href="#previsuEditer" class="previsuEditer on">' + options.textEditer + '</a>' 26 ); 27 28 preview = $('<div class="markItUpPreview"></div>').insertAfter(tabs); 29 preview.hide(); 30 31 $('.previsuVoir').click(function(){ 32 mark = $(this).parent().parent(); 33 objet = mark.parents('.formulaire_spip')[0].className.match(/formulaire_editer_(\w+)/); 34 champ = mark.parents('li')[0].className.match(/editer_(\w+)/); 35 dir = mark.find('textarea').attr('dir'); 36 $(mark).find('.markItUpPreview').height( 37 $(mark).find('.markItUpHeader').height() 38 + $(mark).find('.markItUpEditor').height() 39 + $(mark).find('.markItUpFooter').height() 40 ); 41 42 $(mark).find('.markItUpHeader,.markItUpEditor,.markItUpFooter').hide(); 43 $(this).addClass('on').next().removeClass('on'); 44 $(mark).find('.markItUpPreview').show() 45 .addClass('ajaxLoad') 46 .html(renderPreview( 47 $(mark).find('textarea.pp_previsualisation').val(), 48 champ[1].toUpperCase(), 49 (objet ? objet[1] : '')) 50 ) 51 .removeClass('ajaxLoad'); 52 if(dir) 53 $(mark).find('.markItUpPreview').attr('dir',dir); 54 55 //ouvre un nouvel onglet lorsqu'on clique sur un lien dans la prévisualisation 56 $(".markItUpPreview a").attr("target","blank"); 57 58 return false; 59 }); 60 $('.previsuEditer').click(function(){ 61 mark = $(this).parent().parent(); 62 $(mark).find('.markItUpPreview').hide(); 63 $(mark).find('.markItUpHeader,.markItUpEditor,.markItUpFooter').show(); 64 $(this).addClass('on').prev().removeClass('on'); 65 return false; 66 }); 67 } 68 69 function renderPreview(val, champ, objet) { 70 var phtml; 71 if (options.previewParserPath !== '') { 72 $.ajax( { 73 type: 'POST', 74 async: false, 75 url: options.previewParserPath, 76 data: 'champ='+champ 77 +'&objet='+objet 78 +'&' + options.previewParserVar+'='+encodeURIComponent(val), 79 success: function(data) { 80 phtml = data; 81 } 82 } ); 83 } 84 return phtml; 85 } 86 87 init(); 88 }); 89 }; 90})(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.