PageRenderTime 102ms CodeModel.GetById 61ms app.highlight 5ms RepoModel.GetById 35ms app.codeStats 0ms

/static/scripts/tiny_mce/plugins/advhr/js/rule.js

http://n23.googlecode.com/
JavaScript | 43 lines | 33 code | 10 blank | 0 comment | 10 complexity | ef46d7c850c8bcc869ea84ed7ac00c49 MD5 | raw file
 1var AdvHRDialog = {
 2	init : function(ed) {
 3		var dom = ed.dom, f = document.forms[0], n = ed.selection.getNode(), w;
 4
 5		w = dom.getAttrib(n, 'width');
 6		f.width.value = w ? parseInt(w) : (dom.getStyle('width') || '');
 7		f.size.value = dom.getAttrib(n, 'size') || parseInt(dom.getStyle('height')) || '';
 8		f.noshade.checked = !!dom.getAttrib(n, 'noshade') || !!dom.getStyle('border-width');
 9		selectByValue(f, 'width2', w.indexOf('%') != -1 ? '%' : 'px');
10	},
11
12	update : function() {
13		var ed = tinyMCEPopup.editor, h, f = document.forms[0], st = '';
14
15		h = '<hr';
16
17		if (f.size.value) {
18			h += ' size="' + f.size.value + '"';
19			st += ' height:' + f.size.value + 'px;';
20		}
21
22		if (f.width.value) {
23			h += ' width="' + f.width.value + (f.width2.value == '%' ? '%' : '') + '"';
24			st += ' width:' + f.width.value + (f.width2.value == '%' ? '%' : 'px') + ';';
25		}
26
27		if (f.noshade.checked) {
28			h += ' noshade="noshade"';
29			st += ' border-width: 1px; border-style: solid; border-color: #CCCCCC; color: #ffffff;';
30		}
31
32		if (ed.settings.inline_styles)
33			h += ' style="' + tinymce.trim(st) + '"';
34
35		h += ' />';
36
37		ed.execCommand("mceInsertContent", false, h);
38		tinyMCEPopup.close();
39	}
40};
41
42tinyMCEPopup.requireLangPack();
43tinyMCEPopup.onInit.add(AdvHRDialog.init, AdvHRDialog);