1$(document).ready(function(){ 2 3 function initSpoilers(context) { 4 var $context = context ? $(context) : $(document); 5 6 $context.find('.spoiler').each(function () { 7 var $this = $(this); 8 9 if( $this.parents('.cke_wysiwyg_div').length ){ 10 return; 11 } 12 13 if( $this.data('spoiler-inited') ){ 14 return; 15 } 16 $this.data('spoiler-inited', true); 17 18 /* Do we have an existing citation/header block? */ 19 var existingHeader = $this.children('.spoiler_title, .spoiler-title'); 20 21 var spTitle = ''; 22 if ( existingHeader.length ) { 23 var clone = existingHeader.clone(); 24 var nonToggleText = clone.children().not('.spoiler-toggle').text().trim(); 25 var directText = clone.contents().filter(function() { 26 return this.nodeType === 3; 27 }).text().trim(); 28 29 var outsideText = (directText + ' ' + nonToggleText).trim(); 30 if (outsideText) { 31 spTitle = outsideText; 32 } else { 33 spTitle = existingHeader.text().replace(/\u00a0/g, ' ').trim(); 34 } 35 } 36 37 /* Hide the contents */ 38 $this.contents().hide(); 39 40 /* Build the header block */ 41 var headerHtml = '<div class="spoiler_title spoiler_closed">' + 42 '<a href="#" data-action="toggleSpoiler"> </a>' + 43 '<span class="spoiler_action_text">ÐоказаÑÑ</span>' + (spTitle ? ': <span>' + spTitle + '</span>' : '') + 44 '</div>'; 45 var $header = $(headerHtml); 46 47 /* Add or replace it */ 48 if ( existingHeader.length ) { 49 existingHeader.replaceWith( $header ); 50 } else { 51 $this.prepend( $header ); 52 } 53 54 var $body = $this.find('> .spoiler_body, > .spoiler-content'); 55 if ( $body.length ) { 56 $body.addClass('spoiler_body'); 57 if ( !$body.find('> .spoiler_fold').length ) { 58 $body.append('<div class="spoiler_fold">[ÑвеÑнÑÑÑ]</div>'); 59 } 60 } 61 62 /* Set the event handler for opening/closing */ 63 $header.on( 'click', _toggleSpoiler ); 64 }); 65 } 66 67 initSpoilers(); 68 69 $(document).on('click', '.spoiler_fold', function(e) { 70 e.preventDefault(); 71 e.stopPropagation(); 72 var $spoiler = $(this).closest('.spoiler'); 73 var $header = $spoiler.find('> .spoiler_title'); 74 $header.siblings().hide(); 75 $header.removeClass('spoiler_open').addClass('spoiler_closed').find('.spoiler_action_text').text('ÐоказаÑÑ'); 76 }); 77 78 function _toggleSpoiler(e) { 79 var header = $( e.currentTarget ); 80 var target = $( e.target ); 81 var spoiler = header.closest('.spoiler'); 82 83 if( target.is('a:not( [data-action="toggleSpoiler"] )') || ( target.closest('a').length && !target.closest('a').is('[data-action="toggleSpoiler"]') ) ){ 84 return; 85 } 86 87 e.preventDefault(); 88 89 if( header.hasClass('spoiler_closed') ){ 90 header.siblings().fadeIn(300); 91 header.removeClass('spoiler_closed').addClass('spoiler_open').find('.spoiler_action_text').text('СкÑÑÑÑ'); 92 $( document ).trigger('contentChange', [ spoiler ] ); 93 94 var iframes = spoiler.find('iframe[data-embedcontent]'); 95 if( iframes.length ){ 96 $.each( iframes, function () { 97 this.src = this.src; 98 }); 99 } 100 } else { 101 header.siblings().hide(); 102 header.removeClass('spoiler_open').addClass('spoiler_closed').find('.spoiler_action_text').text('ÐоказаÑÑ'); 103 } 104 105 e.stopPropagation(); 106 } 107});
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.