]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/javascript/tiny_mce/classes/LegacyInput.js
Release 6.5.0
[Github/sugarcrm.git] / include / javascript / tiny_mce / classes / LegacyInput.js
1 /**
2  * LegacyInput.js
3  *
4  * Copyright 2009, Moxiecode Systems AB
5  * Released under LGPL License.
6  *
7  * License: http://tinymce.moxiecode.com/license
8  * Contributing: http://tinymce.moxiecode.com/contributing
9  */
10
11 tinymce.onAddEditor.add(function(tinymce, ed) {
12         var filters, fontSizes, dom, settings = ed.settings;
13
14         if (settings.inline_styles) {
15                 fontSizes = tinymce.explode(settings.font_size_style_values);
16
17                 function replaceWithSpan(node, styles) {
18                         tinymce.each(styles, function(value, name) {
19                                 if (value)
20                                         dom.setStyle(node, name, value);
21                         });
22
23                         dom.rename(node, 'span');
24                 };
25
26                 filters = {
27                         font : function(dom, node) {
28                                 replaceWithSpan(node, {
29                                         backgroundColor : node.style.backgroundColor,
30                                         color : node.color,
31                                         fontFamily : node.face,
32                                         fontSize : fontSizes[parseInt(node.size) - 1]
33                                 });
34                         },
35
36                         u : function(dom, node) {
37                                 replaceWithSpan(node, {
38                                         textDecoration : 'underline'
39                                 });
40                         },
41
42                         strike : function(dom, node) {
43                                 replaceWithSpan(node, {
44                                         textDecoration : 'line-through'
45                                 });
46                         }
47                 };
48
49                 function convert(editor, params) {
50                         dom = editor.dom;
51
52                         if (settings.convert_fonts_to_spans) {
53                                 tinymce.each(dom.select('font,u,strike', params.node), function(node) {
54                                         filters[node.nodeName.toLowerCase()](ed.dom, node);
55                                 });
56                         }
57                 };
58
59                 ed.onPreProcess.add(convert);
60                 ed.onSetContent.add(convert);
61
62                 ed.onInit.add(function() {
63                         ed.selection.onSetContent.add(convert);
64                 });
65         }
66 });