User:Shtriter/monobook.js

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
//<pre><nowiki>  function onEditPageLoad()    {    //alert('wclEditor!')    var textarea = $('wpTextbox1');    if (!textarea) return;    //alert('wpTextbox1 found!')      //document.write('<script type="text/javascript" "src="http://fckeditor.net/fckeditor/fckeditor.js"> </script>\n');    document.write('<script type="text/javascript" "src="http://tinymce.moxiecode.com/tinymce/jscripts/tiny_mce/tiny_mce.js"> </script>\n');          document.write('<script type="text/javascript" '+    'src="http://en.wikipedia.org/w/index.php?title=User:Pilaf/InstaView/Devel' +    '&action=raw&ctype=text/javascript&dontcountme=s"> </script>\n');        document.write('<script type="text/javascript" '+    'src="http://meta.wikimedia.org/w/index.php?title=Wikificator/Wikificator.js' +    '&action=raw&ctype=text/javascript&dontcountme=s"> </script>\n');        //alert('Scripts loaded.')        var newtbox = document.createElement('textarea')    newtbox.id="wclEditor";        var div = document.createElement('div');    div.id = "wclEditor___Div";    div.style.display = "none";        div.appendChild( newtbox );        textarea.parentNode.insertBefore( div , textarea.nextSibling );        //alert('before FCK');    //var oFCKeditor = new FCKeditor('wclEditor') ;        //alert('before replace');    //oFCKeditor.ReplaceTextarea() ;        	tinyMCE.init({  		//editor_selector : "wclEditor", //"wclEditor"  		mode : "exact",  		elements : "wclEditor",  		theme : "advanced",  		  		apply_source_formatting : true,	// This option enables you to tell TinyMCE to apply some source formatting to the output HTML code. This function is disabled by default.  		  		//preformatted : true, 			// If you enable this feature, whitespace such as tabs and spaces will be preserved. Much like the bahavior of a PRE element. This can be handy when integrating TinyMCE with webmail clients. This option is disabled by default.  		  		force_p_newlines : false, 		// This option enables you to disable/enable the creation of paragraphs on return/enter in Mozilla/Firefox. The default value of this option is true.  		  		force_br_newlines : false,		// If you set this option to true, TinyMCE will force BR elements on newlines instead of inserting paragraphs. This option is set to false by default since paragraphs is a much better concept. You can style P elements to be one row by adding p { margin: 0; padding: 0; } to your CSS, P tags where invented for a reason and should be used. BR elements should only be used when you really have to (mostly never).  		  		remove_linebreaks : false,		// This option controls if linebreak characters should be removed from output HTML or not. This option is enabled by default since many backend systems use newline to <br /> convertion since they used to be plain old textarea based. With this option enables all HTML content will be placed on one line.  		  		fix_list_elements : true,		// This option enables you to specify that list elements UL/OL is to be converted to valid XHTML. This option is disabled by default.  		  		fix_table_elements : true,		// This option enables you to specify that list table elements should be moved outside paragraphs or other block elements. If you enable this option block elements will be split into two chunks when a table is found within it, see the example below for details. This option is disabled by default.  		  		auto_reset_designmode : true, 	// This option is very useful if TinyMCE is used in a DHTML tab system or other divs that are hidden and displayed by some JavaScript. Since Mozilla has a bug when using display:none, the designMode state gets lost. To prevent this from happening you should enable this option. The default value of this option is "true".  		  		auto_focus : "mce_editor_0", 		// This option enables you to auto focus a editor instance. The value of this option should be a editor instance id. Editor instance ids are specified as "mce_editor_<index>" where index is a value starting from 0. So if there are 3 editor instances on a page these would have the following ids mce_editor_0, mce_editor_1 and mce_editor_2.  		  		//inline_styles : true, 		// If you enable the inline styles feature by setting this option to true. Most of the attributes gets converted into CSS style attributes instead. This will make the editor output more XHTML strict compatible.   		  		plugins : "style,layer,table,save,advhr,advimage,advlink,emotions,iespell,insertdatetime,preview,flash,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable",  		theme_advanced_buttons1_add_before : "save,newdocument,separator",  		theme_advanced_buttons1_add : "fontselect,fontsizeselect",  		theme_advanced_buttons2_add : "separator,insertdate,inserttime,preview,separator,forecolor,backcolor",  		theme_advanced_buttons2_add_before: "cut,copy,paste,pastetext,pasteword,separator,search,replace,separator",  		theme_advanced_buttons3_add_before : "tablecontrols,separator",  		theme_advanced_buttons3_add : "emotions,iespell,flash,advhr,separator,print,separator,ltr,rtl,separator,fullscreen",  		theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops",  		theme_advanced_toolbar_location : "top",  		theme_advanced_toolbar_align : "left",  		theme_advanced_path_location : "bottom",  		content_css : "example_full.css",  	    plugin_insertdate_dateFormat : "%Y-%m-%d",  	    plugin_insertdate_timeFormat : "%H:%M:%S",  		extended_valid_elements : "hr[class|width|size|noshade],font[face|size|color|style],span[class|align|style]",  		external_link_list_url : "example_link_list.js",  		external_image_list_url : "example_image_list.js",  		flash_external_list_url : "example_flash_list.js",  		file_browser_callback : "fileBrowserCallBack",  		theme_advanced_resize_horizontal : false,  		theme_advanced_resizing : true  	});    	function fileBrowserCallBack(field_name, url, type, win) {  		// This is where you insert your custom filebrowser logic  		alert("Example of filebrowser callback: field_name: " + field_name + ", url: " + url + ", type: " + type);    		// Insert new URL, this would normaly be done in a popup  		win.document.forms[0].elements[field_name].value = "someurl.htm";  	}                  //alert('before insert');        //alert('FCKeditor')            sum = $('wpSummary').nextSibling        var input = document.createElement('input')    input.type = "checkbox";    input.id="Toggle_wclEditor";    input.name = "Toggle_wclEditor"        var newOnClick = document.createAttribute('onclick');    newOnClick.nodeValue = 'Toggle( this.checked )';      input.setAttributeNode(newOnClick);            var label = document.createElement('label');    label.setAttribute('for', "Toggle_wclEditor");      var text = document.createTextNode('Use wclEditor:');      label.appendChild( text );            sum.parentNode.insertBefore( input , sum);    sum.parentNode.insertBefore( label , sum);            /*    oFCKeditor._InsertHtmlBefore( '<input type ="checkbox" name="Toggle_wclEditor" ' +    'onClick="Toggle( this.checked )" id="Toggle_wclEditor" /> ' +    '<label for="Toggle_wclEditor">Use wclEditor:</label>' , $('wpSummary').nextSibling );    */    //alert('Editor installed');    }          function $(aID)    {     return (document.getElementById) ? document.getElementById(aID)            : (document.layers) ? document.layers[aID] : document.all[aID];    }     function Toggle( useEditor )    {        //alert(useEditor);        var toolbar, textarea;            if (editor = $('wclEditor___Div')) editor.style.display = useEditor ? 'block' : 'none' ;            if (useEditor)  	{  	convertedWikiText = InstaView.convert($('wpTextbox1').value);    	//var oFCKeditor = FCKeditorAPI.GetInstance('wclEditor') ;  	//alert( oFCKeditor );  	  	//oFCKeditor.SetHTML( convertedWikiText );  	  	tinyMCE.setContent(convertedWikiText);  	  	}    else     	{    	//var Text = FCKeditorAPI.GetInstance('wclEditor').GetXHTML( );    	//var Text = $('wclEditor___Frame').contentDocument.getElementById('xEditingArea').firstChild.contentDocument.body.innerHTML    	    	var Text = tinyMCE.getContent();    	    	//alert( $('wclEditor___Frame').contentDocument.getElementById('xEditingArea').firstChild.contentDocument.body.innerHTML );    	    	/*$('wpTextbox1').value =  Text ;    	    	alert($('wpTextbox1').value);    	*/    	//alert('Before process:\\n"'+Text+'"');    	    	//Wikify();    	Text = Process( Text ) ;    	    	//alert('After process:\\n"'+Text+'"');  	    	$('wpTextbox1').value =  Text ;    	    	}        if (toolbar = $('toolbar')) toolbar.style.display =  useEditor ? 'none' : 'block' ;    if (textarea = $('wpTextbox1')) textarea.style.display = useEditor ? 'none' : 'inline' ;          //if (!useEditor) $('Wikificator').click();    //alert('Done');    }    $(onEditPageLoad);  //</nowiki></pre>