]> git.mxchange.org Git - friendica.git/blobdiff - library/tinymce/jscripts/tiny_mce/plugins/style/js/props.js
update tinymce to 3.5b2 to fix issues with FF 11 and pasting into code blocks
[friendica.git] / library / tinymce / jscripts / tiny_mce / plugins / style / js / props.js
old mode 100755 (executable)
new mode 100644 (file)
index a8dd93d..0a8a8ec
@@ -27,10 +27,41 @@ var defaultBorderStyle = "none;solid;dashed;dotted;double;groove;ridge;inset;out
 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
@@ -144,6 +175,8 @@ function setupFormData() {
        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
@@ -177,11 +210,7 @@ function setupFormData() {
 \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
@@ -370,13 +399,41 @@ function hasEqualValues(a) {
        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
@@ -440,9 +497,7 @@ function generateCSS() {
        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
@@ -638,4 +693,17 @@ function synch(fr, to) {
                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