src/pyams_skin/resources/js/ext/tinymce/dev/classes/LegacyInput.js
changeset 69 a361355b55c7
equal deleted inserted replaced
68:fd8fb93e1b6a 69:a361355b55c7
       
     1 /**
       
     2  * LegacyInput.js
       
     3  *
       
     4  * Copyright, Moxiecode Systems AB
       
     5  * Released under LGPL License.
       
     6  *
       
     7  * License: http://www.tinymce.com/license
       
     8  * Contributing: http://www.tinymce.com/contributing
       
     9  */
       
    10 
       
    11 define("tinymce/LegacyInput", [
       
    12 	"tinymce/EditorManager",
       
    13 	"tinymce/util/Tools"
       
    14 ], function(EditorManager, Tools) {
       
    15 	var each = Tools.each, explode = Tools.explode;
       
    16 
       
    17 	EditorManager.on('AddEditor', function(e) {
       
    18 		var editor = e.editor;
       
    19 
       
    20 		editor.on('preInit', function() {
       
    21 			var filters, fontSizes, dom, settings = editor.settings;
       
    22 
       
    23 			function replaceWithSpan(node, styles) {
       
    24 				each(styles, function(value, name) {
       
    25 					if (value) {
       
    26 						dom.setStyle(node, name, value);
       
    27 					}
       
    28 				});
       
    29 
       
    30 				dom.rename(node, 'span');
       
    31 			}
       
    32 
       
    33 			function convert(e) {
       
    34 				dom = editor.dom;
       
    35 
       
    36 				if (settings.convert_fonts_to_spans) {
       
    37 					each(dom.select('font,u,strike', e.node), function(node) {
       
    38 						filters[node.nodeName.toLowerCase()](dom, node);
       
    39 					});
       
    40 				}
       
    41 			}
       
    42 
       
    43 			if (settings.inline_styles) {
       
    44 				fontSizes = explode(settings.font_size_legacy_values);
       
    45 
       
    46 				filters = {
       
    47 					font: function(dom, node) {
       
    48 						replaceWithSpan(node, {
       
    49 							backgroundColor: node.style.backgroundColor,
       
    50 							color: node.color,
       
    51 							fontFamily: node.face,
       
    52 							fontSize: fontSizes[parseInt(node.size, 10) - 1]
       
    53 						});
       
    54 					},
       
    55 
       
    56 					u: function(dom, node) {
       
    57 						// HTML5 allows U element
       
    58 						if (editor.settings.schema === "html4") {
       
    59 							replaceWithSpan(node, {
       
    60 								textDecoration: 'underline'
       
    61 							});
       
    62 						}
       
    63 					},
       
    64 
       
    65 					strike: function(dom, node) {
       
    66 						replaceWithSpan(node, {
       
    67 							textDecoration: 'line-through'
       
    68 						});
       
    69 					}
       
    70 				};
       
    71 
       
    72 				editor.on('PreProcess SetContent', convert);
       
    73 			}
       
    74 		});
       
    75 	});
       
    76 });