mirror of
https://github.com/e107inc/e107.git
synced 2025-10-11 04:54:26 +02:00
TinyMce upgrade and e107bbcode plugin work
This commit is contained in:
@@ -63,6 +63,11 @@ function init() {
|
||||
function updateAction() {
|
||||
var el, inst = ed, tdElm, trElm, tableElm, formObj = document.forms[0];
|
||||
|
||||
if (!AutoValidator.validate(formObj)) {
|
||||
tinyMCEPopup.alert(AutoValidator.getErrorMessages(formObj).join('. ') + '.');
|
||||
return false;
|
||||
}
|
||||
|
||||
tinyMCEPopup.restoreSelection();
|
||||
el = ed.selection.getStart();
|
||||
tdElm = ed.dom.getParent(el, "td,th");
|
||||
@@ -123,6 +128,36 @@ function updateAction() {
|
||||
|
||||
break;
|
||||
|
||||
case "col":
|
||||
var curr, col = 0, cell = trElm.firstChild, rows = tableElm.getElementsByTagName("tr");
|
||||
|
||||
if (cell.nodeName != "TD" && cell.nodeName != "TH")
|
||||
cell = nextCell(cell);
|
||||
|
||||
do {
|
||||
if (cell == tdElm)
|
||||
break;
|
||||
col += cell.getAttribute("colspan");
|
||||
} while ((cell = nextCell(cell)) != null);
|
||||
|
||||
for (var i=0; i<rows.length; i++) {
|
||||
cell = rows[i].firstChild;
|
||||
|
||||
if (cell.nodeName != "TD" && cell.nodeName != "TH")
|
||||
cell = nextCell(cell);
|
||||
|
||||
curr = 0;
|
||||
do {
|
||||
if (curr == col) {
|
||||
cell = updateCell(cell, true);
|
||||
break;
|
||||
}
|
||||
curr += cell.getAttribute("colspan");
|
||||
} while ((cell = nextCell(cell)) != null);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case "all":
|
||||
var rows = tableElm.getElementsByTagName("tr");
|
||||
|
||||
|
@@ -56,6 +56,11 @@ function updateAction() {
|
||||
var inst = tinyMCEPopup.editor, dom = inst.dom, trElm, tableElm, formObj = document.forms[0];
|
||||
var action = getSelectValue(formObj, 'action');
|
||||
|
||||
if (!AutoValidator.validate(formObj)) {
|
||||
tinyMCEPopup.alert(AutoValidator.getErrorMessages(formObj).join('. ') + '.');
|
||||
return false;
|
||||
}
|
||||
|
||||
tinyMCEPopup.restoreSelection();
|
||||
trElm = dom.getParent(inst.selection.getStart(), "tr");
|
||||
tableElm = dom.getParent(inst.selection.getStart(), "table");
|
||||
|
@@ -60,7 +60,19 @@ function insertTable() {
|
||||
if (action == "update") {
|
||||
dom.setAttrib(elm, 'cellPadding', cellpadding, true);
|
||||
dom.setAttrib(elm, 'cellSpacing', cellspacing, true);
|
||||
dom.setAttrib(elm, 'border', border);
|
||||
|
||||
if (!isCssSize(border)) {
|
||||
dom.setAttrib(elm, 'border', border);
|
||||
} else {
|
||||
dom.setAttrib(elm, 'border', '');
|
||||
}
|
||||
|
||||
if (border == '') {
|
||||
dom.setStyle(elm, 'border-width', '');
|
||||
dom.setStyle(elm, 'border', '');
|
||||
dom.setAttrib(elm, 'border', '');
|
||||
}
|
||||
|
||||
dom.setAttrib(elm, 'align', align);
|
||||
dom.setAttrib(elm, 'frame', frame);
|
||||
dom.setAttrib(elm, 'rules', rules);
|
||||
@@ -119,7 +131,7 @@ function insertTable() {
|
||||
if (bordercolor != "") {
|
||||
elm.style.borderColor = bordercolor;
|
||||
elm.style.borderStyle = elm.style.borderStyle == "" ? "solid" : elm.style.borderStyle;
|
||||
elm.style.borderWidth = border == "" ? "1px" : border;
|
||||
elm.style.borderWidth = cssSize(border);
|
||||
} else
|
||||
elm.style.borderColor = '';
|
||||
|
||||
@@ -132,7 +144,7 @@ function insertTable() {
|
||||
//elm.outerHTML = elm.outerHTML;
|
||||
|
||||
inst.nodeChanged();
|
||||
inst.execCommand('mceEndUndoLevel');
|
||||
inst.execCommand('mceEndUndoLevel', false, {}, {skip_undo: true});
|
||||
|
||||
// Repaint if dimensions changed
|
||||
if (formObj.width.value != orgTableWidth || formObj.height.value != orgTableHeight)
|
||||
@@ -146,7 +158,10 @@ function insertTable() {
|
||||
html += '<table';
|
||||
|
||||
html += makeAttrib('id', id);
|
||||
html += makeAttrib('border', border);
|
||||
if (!isCssSize(border)) {
|
||||
html += makeAttrib('border', border);
|
||||
}
|
||||
|
||||
html += makeAttrib('cellpadding', cellpadding);
|
||||
html += makeAttrib('cellspacing', cellspacing);
|
||||
html += makeAttrib('data-mce-new', '1');
|
||||
@@ -228,12 +243,15 @@ function insertTable() {
|
||||
inst.execCommand('mceInsertContent', false, html);
|
||||
|
||||
tinymce.each(dom.select('table[data-mce-new]'), function(node) {
|
||||
var td = dom.select('td', node);
|
||||
// Fixes a bug in IE where the caret cannot be placed after the table if the table is at the end of the document
|
||||
if (tinymce.isIE && node.nextSibling == null) {
|
||||
dom.insertAfter(dom.create('p'), node);
|
||||
}
|
||||
|
||||
var tdorth = dom.select('td,th', node);
|
||||
try {
|
||||
// IE9 might fail to do this selection
|
||||
inst.selection.select(td[0], true);
|
||||
inst.selection.collapse();
|
||||
// IE9 might fail to do this selection
|
||||
inst.selection.setCursorLocation(tdorth[0], 0);
|
||||
} catch (ex) {
|
||||
// Ignore
|
||||
}
|
||||
@@ -242,7 +260,7 @@ function insertTable() {
|
||||
});
|
||||
|
||||
inst.addVisual();
|
||||
inst.execCommand('mceEndUndoLevel');
|
||||
inst.execCommand('mceEndUndoLevel', false, {}, {skip_undo: true});
|
||||
|
||||
tinyMCEPopup.close();
|
||||
}
|
||||
@@ -384,6 +402,20 @@ function changedSize() {
|
||||
formObj.style.value = dom.serializeStyle(st);
|
||||
}
|
||||
|
||||
function isCssSize(value) {
|
||||
return /^[0-9.]+(%|in|cm|mm|em|ex|pt|pc|px)$/.test(value);
|
||||
}
|
||||
|
||||
function cssSize(value, def) {
|
||||
value = tinymce.trim(value || def);
|
||||
|
||||
if (!isCssSize(value)) {
|
||||
return parseInt(value, 10) + 'px';
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
function changedBackgroundImage() {
|
||||
var formObj = document.forms[0];
|
||||
var st = dom.parseStyle(formObj.style.value);
|
||||
@@ -398,8 +430,14 @@ function changedBorder() {
|
||||
var st = dom.parseStyle(formObj.style.value);
|
||||
|
||||
// Update border width if the element has a color
|
||||
if (formObj.border.value != "" && formObj.bordercolor.value != "")
|
||||
st['border-width'] = formObj.border.value + "px";
|
||||
if (formObj.border.value != "" && (isCssSize(formObj.border.value) || formObj.bordercolor.value != ""))
|
||||
st['border-width'] = cssSize(formObj.border.value);
|
||||
else {
|
||||
if (!formObj.border.value) {
|
||||
st['border'] = '';
|
||||
st['border-width'] = '';
|
||||
}
|
||||
}
|
||||
|
||||
formObj.style.value = dom.serializeStyle(st);
|
||||
}
|
||||
@@ -415,7 +453,7 @@ function changedColor() {
|
||||
|
||||
// Add border-width if it's missing
|
||||
if (!st['border-width'])
|
||||
st['border-width'] = formObj.border.value == "" ? "1px" : formObj.border.value + "px";
|
||||
st['border-width'] = cssSize(formObj.border.value, 1);
|
||||
}
|
||||
|
||||
formObj.style.value = dom.serializeStyle(st);
|
||||
|
Reference in New Issue
Block a user