PageRenderTime 50ms CodeModel.GetById 35ms app.highlight 10ms RepoModel.GetById 2ms app.codeStats 0ms

/source/Plug-in/kind/plugins/wordpaste/wordpaste.js

http://prosporous.googlecode.com/
JavaScript | 51 lines | 42 code | 1 blank | 8 comment | 3 complexity | 4de03ae43389c5d3dc4a1af091252acf MD5 | raw file
 1/*******************************************************************************
 2* KindEditor - WYSIWYG HTML Editor for Internet
 3* Copyright (C) 2006-2011 kindsoft.net
 4*
 5* @author Roddy <luolonghao@gmail.com>
 6* @site http://www.kindsoft.net/
 7* @licence http://www.kindsoft.net/license.php
 8*******************************************************************************/
 9
10KindEditor.plugin('wordpaste', function(K) {
11	var self = this, name = 'wordpaste';
12	self.clickToolbar(name, function() {
13		var lang = self.lang(name + '.'),
14			html = '<div style="padding:10px 20px;">' +
15				'<div style="margin-bottom:10px;">' + lang.comment + '</div>' +
16				'<iframe class="ke-textarea" frameborder="0" style="width:408px;height:260px;"></iframe>' +
17				'</div>',
18			dialog = self.createDialog({
19				name : name,
20				width : 450,
21				title : self.lang(name),
22				body : html,
23				yesBtn : {
24					name : self.lang('yes'),
25					click : function(e) {
26						var str = doc.body.innerHTML;
27						str = K.clearMsWord(str, self.filterMode ? self.htmlTags : K.options.htmlTags);
28						self.insertHtml(str).hideDialog().focus();
29					}
30				}
31			}),
32			div = dialog.div,
33			iframe = K('iframe', div),
34			doc = K.iframeDoc(iframe);
35		if (!K.IE) {
36			doc.designMode = 'on';
37		}
38		doc.open();
39		doc.write('<!doctype html><html><head><title>WordPaste</title></head>');
40		doc.write('<body style="background-color:#FFF;font-size:12px;margin:2px;">');
41		if (!K.IE) {
42			doc.write('<br />');
43		}
44		doc.write('</body></html>');
45		doc.close();
46		if (K.IE) {
47			doc.body.contentEditable = 'true';
48		}
49		iframe[0].contentWindow.focus();
50	});
51});