PageRenderTime 166ms CodeModel.GetById 155ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/static/scripts/tiny_mce/plugins/fullscreen/fullscreen.htm

http://n23.googlecode.com/
HTML | 111 lines | 89 code | 22 blank | 0 comment | 0 complexity | 2055014b9a2e994bdbe69cc971d442df MD5 | raw file
  1<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2<html xmlns="http://www.w3.org/1999/xhtml">
  3<head>
  4	<title></title>
  5	<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  6	<script type="text/javascript" src="../../tiny_mce.js"></script>
  7	<script type="text/javascript">
  8		function patchCallback(settings, key) {
  9			if (settings[key])
 10				settings[key] = "window.opener." + settings[key];
 11		}
 12
 13		var settings = {}, paSe = window.opener.tinyMCE.activeEditor.settings;
 14
 15		// Clone array
 16		for (var n in paSe)
 17			settings[n] = paSe[n];
 18
 19		// Override options for fullscreen
 20		for (var n in paSe.fullscreen_settings)
 21			settings[n] = paSe.fullscreen_settings[n];
 22
 23		// Patch callbacks, make them point to window.opener
 24		patchCallback(settings, 'urlconverter_callback');
 25		patchCallback(settings, 'insertlink_callback');
 26		patchCallback(settings, 'insertimage_callback');
 27		patchCallback(settings, 'setupcontent_callback');
 28		patchCallback(settings, 'save_callback');
 29		patchCallback(settings, 'onchange_callback');
 30		patchCallback(settings, 'init_instance_callback');
 31		patchCallback(settings, 'file_browser_callback');
 32		patchCallback(settings, 'cleanup_callback');
 33		patchCallback(settings, 'execcommand_callback');
 34		patchCallback(settings, 'oninit');
 35
 36		// Set options
 37		delete settings.id;
 38		settings['mode'] = 'exact';
 39		settings['elements'] = 'fullscreenarea';
 40		settings['add_unload_trigger'] = false;
 41		settings['ask'] = false;
 42		settings['document_base_url'] = window.opener.tinyMCE.activeEditor.documentBaseURI.getURI();
 43		settings['fullscreen_is_enabled'] = true;
 44		settings['fullscreen_editor_id'] = window.opener.tinyMCE.activeEditor.id;
 45		settings['theme_advanced_resizing'] = false;
 46		settings['strict_loading_mode'] = true;
 47
 48		settings.save_onsavecallback = function() {
 49			window.opener.tinyMCE.activeEditor.setContent(tinyMCE.get('fullscreenarea').getContent({format : 'raw'}), {format : 'raw'});
 50			window.opener.tinyMCE.activeEditor.execCommand('mceSave');
 51			window.close();
 52		};
 53
 54		function unloadHandler(e) {
 55			moveContent();
 56		}
 57
 58		function moveContent() {
 59			window.opener.tinyMCE.activeEditor.setContent(tinyMCE.activeEditor.getContent());
 60		}
 61
 62		function closeFullscreen() {
 63			moveContent();
 64			window.close();
 65		}
 66
 67		function doParentSubmit() {
 68			moveContent();
 69
 70			if (window.opener.tinyMCE.selectedInstance.formElement.form)
 71				window.opener.tinyMCE.selectedInstance.formElement.form.submit();
 72
 73			window.close();
 74
 75			return false;
 76		}
 77
 78		function render() {
 79			var e = document.getElementById('fullscreenarea'), vp, ed, ow, oh, dom = tinymce.DOM;
 80
 81			e.value = window.opener.tinyMCE.activeEditor.getContent();
 82
 83			vp = dom.getViewPort();
 84			settings.width = vp.w;
 85			settings.height = vp.h - 15;
 86
 87			tinymce.dom.Event.add(window, 'resize', function() {
 88				var vp = dom.getViewPort();
 89
 90				tinyMCE.activeEditor.theme.resizeTo(vp.w, vp.h);
 91			});
 92
 93			tinyMCE.init(settings);
 94		}
 95
 96		// Add onunload
 97		tinymce.dom.Event.add(window, "beforeunload", unloadHandler);
 98	</script>
 99	<base target="_self" />
100</head>
101<body style="margin:0;overflow:hidden;width:100%;height:100%" scrolling="no" scroll="no">
102<form onsubmit="doParentSubmit();">
103<textarea id="fullscreenarea" style="width:100%; height:100%"></textarea>
104</form>
105
106<script type="text/javascript">
107	render();
108</script>
109
110</body>
111</html>