PageSourceSearch

https://www.alverno.edu/cms3t/res/tinymce/js/tinymce/tinymce.morweb.js

js alverno.edu collected 2026-10-02 03:27:59 UTC 12,636 bytes, 373 lines download raw bytes

1/** //** ----= mwTinyMCE	=--------------------------------------------------------------------------------------\**//** \
2*
3* 	Morweb common tinyMCE init wrapper.
4*
5* 	@param	object	[$options]	- Custom options. Will extend defaults on object.
6*
7* 	@return	object			- TinyMCE initialization object.
8*
9\**//** ---------------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
10function mwTinyMCE($options) {
11
12	$options	= $options || {};
13
14	var $class = {
15
16// ==== CLASS ==================================================================================================================
17	
18	DefaultTheme		: 'default',		// Default theme to use
19		
20	Defaults		: {			// Default init options
21	
22		theme			: 'modern', 
23		skin			: 'morweb',
24	//	toolbar_items_size	: 'small',
25
26		menubar			: false,
27		resize			: false,
28		statusbar		: false,
29
30		convert_urls		: false,
31	//	relative_urls		: false,
32	
33	//	relative_urls		: true,
34	//	convert_urls		: true,
35	//	remove_script_host	: true,
36	//	document_base_url	: 'http://localhost:82/',
37			
38		delta_height		: 0,
39		width			: '100%',
40		height			: '100%',
41
42		link_list		: '/site/call/system/links_json',
43
44
45		fontsize_formats	: '8pt 9pt 10pt 11pt 12pt 13pt 14pt 18pt 24pt 36pt',	
46			
47	// ---- Intersting options to check and test
48		
49	//	preview_styles		: false,
50	//	convert_fonts_to_spans	: true,
51	//	entity_encoding		: 'raw',
52	//	indentation		: '20pt',
53	//	keep_styles		: false,
54
55	// ---- Browser spellcheck
56	
57	//	browser_spellcheck	: true,
58	//	gecko_spellcheck	: true,
59	
60	// ---- Custom spellchecks
61		
62	//	ed.execCommand('mceSpellCheck');
63		
64	/**/	
65		// ---- PHP "native" Enchant based
66		// URL: http://www.tinymce.com/wiki.php/PHP_Spellchecker
67		// URL: http://www.tinymce.com/wiki.php/Plugin:spellchecker
68		// URL: http://blog.iwanluijks.nl/?!=/post/1-using-enchant-with-php-on-windowspart-1.html	
69		// URL: https://stackoverflow.com/questions/16728842/php-enchant-spell-checking-not-working-configuration-in-windows
70		// DIC: https://github.com/titoBouzout/Dictionaries
71		// DIC: https://github.com/mercutiodesign/texmaker-3.3.3/tree/master/dictionaries
72		// Native, thus good availability, but requires additional php configuration and setup (and dictionaries search, install)
73		// CMD: apt install aspell-en aspell-fr aspell-de aspell-es aspell-it ; apt install hunspell hunspell-en-us hunspell-fr-classical hunspell-fr hunspell-de-de hunspell-es hunspell-it
74		
75		
76		browser_spellcheck	: false,
77		
78	//	plugins			: ['spellchecker'],
79	//	toolbar			: 'spellchecker',
80	/**/
81		spellchecker_language	: 'en_US',
82		spellchecker_languages	: 'English=en_US,French=fr_FR,German=de_DE,Spanish=es_ES,Italian=it_IT',
83
84		// There is a bug when tinyMCE ends up with fake host full url. Supplying full url to make sure it behaves
85		// https://github.com/tinymce/tinymce/issues/841
86		spellchecker_rpc_url	: window.location.origin+mwUrl().res('tinymce/spellchecker/spellchecker.php'),
87	/**/
88	
89	/*/
90		// ---- Yandex.speller 
91		// URL: https://tech.yandex.ru/speller/doc/dg/tasks/how-to-spellcheck-tinymce-docpage/
92		// Simple to use, but requires additional setup on server (optional redirect) and is based on russian service
93	//	plugins			: ['spellchecker'],
94	//	toolbar			: 'spellchecker',
95		spellchecker_languages	: 'English=en,French=fr,Russian=ru',
96		spellchecker_rpc_url	: 'http://speller.yandex.net/services/tinyspell?options=514',
97	/**/
98
99	/*/	
100		// ---- nanospell
101		// URL: http://tinymcespellcheck.com/
102		// Simple and fast, but costs money
103		
104		external_plugins	: {"nanospell": "/nanospell/plugin.js"},
105		nanospell_server	: "php", // choose "php" "asp" "asp.net" or "java"	
106	/**/
107	
108	// ---- P behavior options
109
110		// Not totally sure if I want to disable those P it creates left and right :)
111		// Needs to be tested
112	//	force_p_newlines	: false,
113	//	forced_root_block	: false,
114
115	// ---- Inline use options (might be used as replace of content editing in liveEd)
116
117	//	inline			: true,
118	//	selector		: 'div#edit',
119	//	fixed_toolbar_container : '#mytoolbar',
120
121		// Default tinyMCE dimensions corrections
122		oninit	: function ($ed) {
123
124			//contentAreaContainer
125			//editorContainer
126			
127			var $editor	= jQuery($ed.editorContainer);		// Shortcut to container
128			var $content	= jQuery($ed.contentAreaContainer);			
129			var $txt	= jQuery($ed.getElement());
130			
131			// Applying autowidth + mwInput class
132			$editor.addClass('mwInput').css('width', '');
133
134			// Applying class modifiers from source text area
135			$editor.addClass( $txt.attr('class') );
136			
137			// Copying size attribute. It will be used to calculate height by mwInput
138			if ( $txt.attr('size') )
139				$editor.attr('size', $txt.attr('size') );
140			
141			// Always using dynamic height on tinyMce, but if static height given - copying it to mwInput
142			$content.css({
143		 		'position'	: 'absolute',
144		 		'left'		: '0px',
145		 		'right'		: '0px',
146		 		'top'		: $ed.settings.tools_height,
147		 		'bottom'	: '0px'
148			});//OBJECT conent.css
149
150			if ( $ed.settings.sourceHeight )
151				$editor.css('height', $ed.settings.sourceHeight);								
152									
153			// Removing tiny skin classes
154			$editor.removeClass('mce-container mce-panel').css('border-width', '');
155
156			// Removing iframe hint
157			jQuery('#' + $ed.id + '_ifr').removeAttr('title');
158
159			// Tricky events capturing for focus and blur
160			// Actually capturing from iframe body, cuz Tiny does not have proper focus/blur events
161			
162			if ( isFunction($ed.getDoc) ) {
163			
164				jQuery($ed.getDoc()).contents().find('body').focus( function() {
165					$editor.addClass('focus');
166				}); //jQuery.onFocus
167	
168				jQuery($ed.getDoc()).contents().find('body').blur( function() {
169					$editor.removeClass('focus');
170				}); //jQuery.onBlur
171
172			} //IF getDoc exists
173
174		}, //FUNC oninit
175
176	}, //OBJECT Defaults
177
178	Themes		: {	// Available themes 
179
180		// Default morweb layout (fits 700px)
181		'default'	: {
182
183			plugins		: ['advlist lists link image mwgallery hr anchor searchreplace code media table contextmenu paste textcolor colorpicker charmap visualblocks visualchars insertdatetime spellchecker_rt'],
184
185			toolbar1	: 'undo redo | pastetext pasteword searchreplace | bold italic underline strikethrough | alignleft aligncenter alignright al
185ignjustify | forecolor backcolor | spellchecker | formatselect ', 
186			toolbar2	: 'bullist numlist | outdent indent blockquote | hr charmap inserttime | table | link unlink anchor image media mwgallery | visualchars code | fontsizeselect', // visualchars visualblocks removeformat
187
188			tools_height	: 67
189
190		}, //OBJECT default
191
192		// Extra layout, when have free space (fits 800px)
193		'extra'	: {
194
195			plugins		: ['advlist link image hr anchor searchreplace code media table contextmenu paste textcolor colorpicker charmap visualblocks visualchars insertdatetime mwgallery spellchecker_rt'],
196
197			toolbar1	: 'bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | forecolor backcolor | subscript superscript | formatselect fontselect fontsizeselect', 
198			toolbar2	: 'undo redo pastetext pasteword searchreplace | spellchecker | bullist numlist | outdent indent blockquote | hr charmap inserttime | table | link unlink anchor image media mwgallery | visualchars visualblocks removeformat code',
199			
200			tools_height	: 67
201
202		}, //OBJECT default
203
204		'modern'	: {
205			menubar			: true,
206			tools_height		: 71
207		}, //OBJECT modern 
208
209		// Default tiny MCE init (3.x classic), most controls
210		'full'		: {
211			plugins		: [
212				'advlist autolink autosave link image lists charmap print preview hr anchor pagebreak spellchecker_rt',
213				'searchreplace wordcount visualblocks visualchars code fullscreen insertdatetime media nonbreaking',
214				'table contextmenu directionality emoticons template textcolor colorpicker paste fullpage mwgallery'
215			],
216			
217			toolbar1	: 'newdocument fullpage | bold italic underline strikethrough | alignleft aligncenter alignright al
217ignjustify | styleselect formatselect fontselect fontsizeselect',
218			toolbar2	: 'cut copy paste | searchreplace | bullist numlist | outdent indent blockquote | undo redo | link unlink anchor image media code | inserttime preview | forecolor backcolor',
219			toolbar3	: 'table | hr removeformat | subscript superscript | charmap emoticons | print fullscreen | ltr rtl | spellchecker | visualchars visualblocks nonbreaking template pagebreak restoredraft | mwgallery',
220
221			tools_height	: 101
222			
223		}, //OBJECT full 
224		
225		// Compact layout, for limited space (350px fit, 2 lines) 
226		'compact'	: {
227
228			plugins		: ['lists link hr anchor code contextmenu paste'],
229
230			toolbar1	: 'bold italic underline | alignleft aligncenter alignright alignjustify | formatselect', 
231			toolbar2	: 'bullist numlist | outdent indent blockquote | hr | link unlink | removeformat code',
232			
233			tools_height	: 67
234
235		}, //OBJECT compact
236
237		// Compact 1 row layout (400px fit with 1 line)
238		'simple'	: {
239			plugins		: ['lists link hr anchor code contextmenu paste'],
240
241			toolbar1	: 'bold italic underline | alignleft aligncenter alignright al
241ignjustify | bullist numlist | link unlink | code', 
242			
243			tools_height	: 34
244
245		} //OBJECT compact
246
247	}, //OBJECT Themes
248	
249	/** //** ----= getTheme	=--------------------------------------------------------------------------------------\**//** \
250	*
251	*	Searches theme by given className
252	*
253	*	@param	string	$class	- Class name to search in.
254	*
255	*	@return string		- Found theme name, or default if nothing found.
256	*
257	\**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
258	getTheme	: function ($class) {
259
260	// ---- Theme ----
261
262		// If just existing theme specified - using it
263		if ( this.Themes[$class] )
264			return this.Themes[$class];
265		
266		// Collecting theme, for futher modification
267		var $theme	= false; 
268		
269		// Looping through each theme and checking if specified.
270		// First found will be result, none found will be default
271		$class = ' '+$class+' ';
272		for ( var $i in this.Themes ) {
273		
274			if ( $class.indexOf(' '+$i+' ') != -1 ) {
275				$theme = this.Themes[$i];
276				break;
277			} //IF 
278			
279		} //FOR each Theme
280		
281		// If nothing found - using default theme
282		if ( !$theme )
283			$theme = this.Themes[this.DefaultTheme];
284	
285	// ---- Modifiers -----
286	
287		// Frontend modifier. Removes backend/admin speciefic 
288		if ( $class.indexOf(' front ') != -1 ) {
289
290			// Removing dangerous or backend only plugins
291			// Defining search subjects to simlify code
292			var $tmp	= [$theme, $theme.plugins];
293			
294			for ( var $j in $tmp ) {
295				for ( var $i in $tmp[$j] ) {
296					
297					// Skipping non-strings
298					if ( !isString($tmp[$j][$i]) )
299						continue;
300					
301					// Replacing 
302					$tmp[$j][$i] = $tmp[$j][$i].replace( new RegExp('mwgallery', 'g'), '');
303					
304				} //FOR each theme setting
305			} //FOR each search subject
306			
307		} //IF front modifier
308	
309		return $theme;
310		
311	}, //FUNC getTheme
312
313	/** //** ----= getOptions	=------------------------------------------------------------------------------\**//** \
314	*
315	*	Compiles tinyMCE init options, based on theme given. Includes customized options. 
316	*
317	*	@param	string	$theme	- Theme to use.
318	*
319	*	@return object		- Init options.
320	*
321	\**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
322	getOptions	: function ($theme) {
323
324		// Getting theme options
325		var $t = this.getTheme($theme);
326		
327		// Composing new init object, from defaults, theme and options given
328		return jQuery.extend({}, this.Defaults, $t, $options);
329	}, //FUNC getOptions
330
331	/** //** ----= init	=--------------------------------------------------------------------------------------\**//** \
332	*
333	*	Initiates tinyMCE for given element. 
334	*
335	*	@param	jQuery	$el	- jQuery to element to init.
336	*
337	*	@return object		- Init options.
338	*
339	\**//** -------------------------------------------------------------------= by Mr.V!T @ Morad Media Inc. =----/** //**/
340	init		: function ($el) {
341
342		$el = _jq($el);
343		
344		// If no elements, no need to do smth.
345		if ( !$el.length )
346			return this;
347		
348		// Getting options based on elmeent class
349		var $class	= $el.get(0).className;
350		var $o		= this.getOptions($class);
351	
352		// Setting height, based on source element
353		var $h = $el.get(0).style.height;
354		if ( $el.is('[style*=height]') && $h && $o.tools_height ) {
355			// Saving source height for init
356			$o.sourceHeight = $h;
357		} //IF static height
358
359		// Marking element
360		$el.addClass('mwTinyMCE');
361
362		// Running tiny
363		$el.tinymce($o);
364
365		return this;
366	}, //FUNC init
367
368// ==== END OF CLASS ===========================================================================================================
369		 
370	}; //CLASS 
371	
372	return $class;
373} //FUNC mwTinyMCE

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.