(function($) { CKEDITOR.plugins.add( 'spoiler' , { icons: 'spoiler', init: function( editor ) { if ( editor.blockless ) return; function registerCssFile( url ) { var head = editor.document.getHead(); var link = editor.document.createElement( 'link' , { attributes: { type: 'text/css', rel: 'stylesheet', href: url } } ); head.append( link ); } function toggle( element ) { element.setStyle( 'display' , ( ( element.getStyle('display') == 'none' ) ? '' : 'none' ) ); } function toggleClass( element, className ) { if ( element.hasClass( className ) ) { element.removeClass( className ); } else { element.addClass( className ); } } function setSwitcher( element ) { toggleClass( element, 'hide-icon' ); toggleClass( element, 'show-icon' ); var content = element.getParent().getParent().getLast(); toggle( content ); } function createSpoiler() { var spoilerContainer = editor.document.createElement( 'div', { 'attributes' : { 'class': 'spoiler' } } ); var spoilerToggle = editor.document.createElement( 'div', { 'attributes' : { 'class': 'spoiler-toggle hide-icon' } } ); var spoilerTitle = editor.document.createElement( 'div', { 'attributes' : { 'class': 'spoiler-title' } } ); var spoilerContent = editor.document.createElement( 'div', { 'attributes' : { 'class': 'spoiler-content' } } ); spoilerToggle.on( 'click', function( event ) { setSwitcher( event.sender ); }); spoilerTitle.append( spoilerToggle ); spoilerTitle.appendHtml( 'Spoiler' ); spoilerContent.appendHtml( '
'+gethtml4()+'