var defaultBorderWidth = "thin;medium;thick";\r
var defaultListType = "disc;circle;square;decimal;lower-roman;upper-roman;lower-alpha;upper-alpha;none";\r
\r
-function init() {\r
+function aggregateStyles(allStyles) {\r
+ var mergedStyles = {};\r
+\r
+ tinymce.each(allStyles, function(style) {\r
+ if (style !== '') {\r
+ var parsedStyles = tinyMCEPopup.editor.dom.parseStyle(style);\r
+ for (var name in parsedStyles) {\r
+ if (parsedStyles.hasOwnProperty(name)) {\r
+ if (mergedStyles[name] === undefined) {\r
+ mergedStyles[name] = parsedStyles[name];\r
+ }\r
+ else if (name === 'text-decoration') {\r
+ if (mergedStyles[name].indexOf(parsedStyles[name]) === -1) {\r
+ mergedStyles[name] = mergedStyles[name] +' '+ parsedStyles[name];\r
+ }\r
+ }\r
+ }\r
+ }\r
+ }\r
+ });\r
+\r
+ return mergedStyles;\r
+}\r
+\r
+var applyActionIsInsert;\r
+var existingStyles;\r
+\r
+function init(ed) {\r
var ce = document.getElementById('container'), h;\r
\r
- ce.style.cssText = tinyMCEPopup.getWindowArg('style_text');\r
+ existingStyles = aggregateStyles(tinyMCEPopup.getWindowArg('styles'));\r
+ ce.style.cssText = tinyMCEPopup.editor.dom.serializeStyle(existingStyles);\r
+\r
+ applyActionIsInsert = ed.getParam("edit_css_style_insert_span", false);\r
+ document.getElementById('toggle_insert_span').checked = applyActionIsInsert;\r
\r
h = getBrowserHTML('background_image_browser','background_image','image','advimage');\r
document.getElementById("background_image_browser").innerHTML = h;\r
f.text_overline.checked = inStr(ce.style.textDecoration, 'overline');\r
f.text_linethrough.checked = inStr(ce.style.textDecoration, 'line-through');\r
f.text_blink.checked = inStr(ce.style.textDecoration, 'blink');\r
+ f.text_none.checked = inStr(ce.style.textDecoration, 'none');\r
+ updateTextDecorations();\r
\r
// Setup background fields\r
\r
\r
f.box_height.value = getNum(ce.style.height);\r
selectByValue(f, 'box_height_measurement', getMeasurement(ce.style.height));\r
-\r
- if (tinymce.isGecko)\r
- selectByValue(f, 'box_float', ce.style.cssFloat, true, true);\r
- else\r
- selectByValue(f, 'box_float', ce.style.styleFloat, true, true);\r
+ selectByValue(f, 'box_float', ce.style.cssFloat || ce.style.styleFloat, true, true);\r
\r
selectByValue(f, 'box_clear', ce.style.clear, true, true);\r
\r
return true;\r
}\r
\r
+function toggleApplyAction() {\r
+ applyActionIsInsert = ! applyActionIsInsert;\r
+}\r
+\r
function applyAction() {\r
var ce = document.getElementById('container'), ed = tinyMCEPopup.editor;\r
\r
generateCSS();\r
\r
tinyMCEPopup.restoreSelection();\r
- ed.dom.setAttrib(ed.selection.getNode(), 'style', tinyMCEPopup.editor.dom.serializeStyle(tinyMCEPopup.editor.dom.parseStyle(ce.style.cssText)));\r
+\r
+ var newStyles = tinyMCEPopup.editor.dom.parseStyle(ce.style.cssText);\r
+\r
+ if (applyActionIsInsert) {\r
+ ed.formatter.register('plugin_style', {\r
+ inline: 'span', styles: existingStyles\r
+ });\r
+ ed.formatter.remove('plugin_style');\r
+\r
+ ed.formatter.register('plugin_style', {\r
+ inline: 'span', styles: newStyles\r
+ });\r
+ ed.formatter.apply('plugin_style');\r
+ } else {\r
+ var nodes;\r
+\r
+ if (tinyMCEPopup.getWindowArg('applyStyleToBlocks')) {\r
+ nodes = ed.selection.getSelectedBlocks();\r
+ }\r
+ else {\r
+ nodes = ed.selection.getNode();\r
+ }\r
+\r
+ ed.dom.setAttrib(nodes, 'style', tinyMCEPopup.editor.dom.serializeStyle(newStyles));\r
+ }\r
}\r
\r
function updateAction() {\r
ce.style.width = f.box_width.value + (isNum(f.box_width.value) ? f.box_width_measurement.value : "");\r
ce.style.height = f.box_height.value + (isNum(f.box_height.value) ? f.box_height_measurement.value : "");\r
ce.style.styleFloat = f.box_float.value;\r
-\r
- if (tinymce.isGecko)\r
- ce.style.cssFloat = f.box_float.value;\r
+ ce.style.cssFloat = f.box_float.value;\r
\r
ce.style.clear = f.box_clear.value;\r
\r
selectByValue(f, to + "_measurement", f.elements[fr + "_measurement"].value);\r
}\r
\r
+function updateTextDecorations(){\r
+ var el = document.forms[0].elements;\r
+\r
+ var textDecorations = ["text_underline", "text_overline", "text_linethrough", "text_blink"];\r
+ var noneChecked = el["text_none"].checked;\r
+ tinymce.each(textDecorations, function(id) {\r
+ el[id].disabled = noneChecked;\r
+ if (noneChecked) {\r
+ el[id].checked = false;\r
+ }\r
+ });\r
+}\r
+\r
tinyMCEPopup.onInit.add(init);\r