Revize 1938
Přidáno uživatelem Michal Kliment před více než 11 roky(ů)
freenetis/branches/1.1/media/js/tinymce/plugins/safari/editor_plugin_src.js | ||
---|---|---|
/**
|
||
* $Id: editor_plugin_src.js 264 2007-04-26 20:53:09Z spocke $
|
||
*
|
||
* @author Moxiecode
|
||
* @copyright Copyright ? 2004-2008, Moxiecode Systems AB, All rights reserved.
|
||
*/
|
||
|
||
(function() {
|
||
var Event = tinymce.dom.Event, grep = tinymce.grep, each = tinymce.each, inArray = tinymce.inArray, isOldWebKit = tinymce.isOldWebKit;
|
||
|
||
function isEmpty(d, e, f) {
|
||
var w, n;
|
||
|
||
w = d.createTreeWalker(e, NodeFilter.SHOW_ALL, null, false);
|
||
while (n = w.nextNode()) {
|
||
// Filter func
|
||
if (f) {
|
||
if (!f(n))
|
||
return false;
|
||
}
|
||
|
||
// Non whitespace text node
|
||
if (n.nodeType == 3 && n.nodeValue && /[^\s\u00a0]+/.test(n.nodeValue))
|
||
return false;
|
||
|
||
// Is non text element byt still content
|
||
if (n.nodeType == 1 && /^(HR|IMG|TABLE)$/.test(n.nodeName))
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
};
|
||
|
||
tinymce.create('tinymce.plugins.Safari', {
|
||
init : function(ed) {
|
||
var t = this, dom;
|
||
|
||
// Ignore on non webkit
|
||
if (!tinymce.isWebKit)
|
||
return;
|
||
|
||
t.editor = ed;
|
||
t.webKitFontSizes = ['x-small', 'small', 'medium', 'large', 'x-large', 'xx-large', '-webkit-xxx-large'];
|
||
t.namedFontSizes = ['xx-small', 'x-small','small','medium','large','x-large', 'xx-large'];
|
||
|
||
// Safari CreateLink command will not work correctly on images that is aligned
|
||
ed.addCommand('CreateLink', function(u, v) {
|
||
var n = ed.selection.getNode(), dom = ed.dom, a;
|
||
|
||
if (n && (/^(left|right)$/i.test(dom.getStyle(n, 'float', 1)) || /^(left|right)$/i.test(dom.getAttrib(n, 'align')))) {
|
||
a = dom.create('a', {href : v}, n.cloneNode());
|
||
n.parentNode.replaceChild(a, n);
|
||
ed.selection.select(a);
|
||
} else
|
||
ed.getDoc().execCommand("CreateLink", false, v);
|
||
});
|
||
|
||
ed.onPaste.add(function(ed, e) {
|
||
function removeStyles(e) {
|
||
e = e.target;
|
||
|
||
if (e.nodeType == 1) {
|
||
e.style.cssText = '';
|
||
|
||
each(ed.dom.select('*', e), function(e) {
|
||
e.style.cssText = '';
|
||
});
|
||
}
|
||
};
|
||
|
||
Event.add(ed.getDoc(), 'DOMNodeInserted', removeStyles);
|
||
|
||
window.setTimeout(function() {
|
||
Event.remove(ed.getDoc(), 'DOMNodeInserted', removeStyles);
|
||
}, 0);
|
||
});
|
||
|
||
ed.onKeyUp.add(function(ed, e) {
|
||
var h, b, r, n, s;
|
||
|
||
// If backspace or delete key
|
||
if (e.keyCode == 46 || e.keyCode == 8) {
|
||
b = ed.getBody();
|
||
h = b.innerHTML;
|
||
s = ed.selection;
|
||
|
||
// If there is no text content or images or hr elements then remove everything
|
||
if (b.childNodes.length == 1 && !/<(img|hr)/.test(h) && tinymce.trim(h.replace(/<[^>]+>/g, '')).length == 0) {
|
||
// Inject paragrah and bogus br
|
||
ed.setContent('<p><br mce_bogus="1" /></p>', {format : 'raw'});
|
||
|
||
// Move caret before bogus br
|
||
n = b.firstChild;
|
||
r = s.getRng();
|
||
r.setStart(n, 0);
|
||
r.setEnd(n, 0);
|
||
s.setRng(r);
|
||
}
|
||
}
|
||
});
|
||
|
||
// Workaround for FormatBlock bug, http://bugs.webkit.org/show_bug.cgi?id=16004
|
||
ed.addCommand('FormatBlock', function(u, v) {
|
||
var dom = ed.dom, e = dom.getParent(ed.selection.getNode(), dom.isBlock);
|
||
|
||
if (e)
|
||
dom.replace(dom.create(v), e, 1);
|
||
else
|
||
ed.getDoc().execCommand("FormatBlock", false, v);
|
||
});
|
||
|
||
// Workaround for InsertHTML bug, http://bugs.webkit.org/show_bug.cgi?id=16382
|
||
ed.addCommand('mceInsertContent', function(u, v) {
|
||
ed.getDoc().execCommand("InsertText", false, 'mce_marker');
|
||
ed.getBody().innerHTML = ed.getBody().innerHTML.replace(/mce_marker/g, ed.dom.processHTML(v) + '<span id="_mce_tmp">XX</span>');
|
||
ed.selection.select(ed.dom.get('_mce_tmp'));
|
||
ed.getDoc().execCommand("Delete", false, ' ');
|
||
});
|
||
|
||
ed.onKeyPress.add(function(ed, e) {
|
||
var se, li, lic, r1, r2, n, sel, doc, be, af, pa;
|
||
|
||
if (e.keyCode == 13) {
|
||
sel = ed.selection;
|
||
se = sel.getNode();
|
||
|
||
// Workaround for missing shift+enter support, http://bugs.webkit.org/show_bug.cgi?id=16973
|
||
if (e.shiftKey || ed.settings.force_br_newlines && se.nodeName != 'LI') {
|
||
t._insertBR(ed);
|
||
Event.cancel(e);
|
||
}
|
||
|
||
// Workaround for DIV elements produced by Safari
|
||
if (li = dom.getParent(se, 'LI')) {
|
||
lic = dom.getParent(li, 'OL,UL');
|
||
doc = ed.getDoc();
|
||
|
||
pa = dom.create('p');
|
||
dom.add(pa, 'br', {mce_bogus : "1"});
|
||
|
||
if (isEmpty(doc, li)) {
|
||
// If list in list then use browser default behavior
|
||
if (n = dom.getParent(lic.parentNode, 'LI,OL,UL'))
|
||
return;
|
||
|
||
n = dom.getParent(lic, 'p,h1,h2,h3,h4,h5,h6,div') || lic;
|
||
|
||
// Create range from the start of block element to the list item
|
||
r1 = doc.createRange();
|
||
r1.setStartBefore(n);
|
||
r1.setEndBefore(li);
|
||
|
||
// Create range after the list to the end of block element
|
||
r2 = doc.createRange();
|
||
r2.setStartAfter(li);
|
||
r2.setEndAfter(n);
|
||
|
||
be = r1.cloneContents();
|
||
af = r2.cloneContents();
|
||
|
||
if (!isEmpty(doc, af))
|
||
dom.insertAfter(af, n);
|
||
|
||
dom.insertAfter(pa, n);
|
||
|
||
if (!isEmpty(doc, be))
|
||
dom.insertAfter(be, n);
|
||
|
||
dom.remove(n);
|
||
|
||
n = pa.firstChild;
|
||
r1 = doc.createRange();
|
||
r1.setStartBefore(n);
|
||
r1.setEndBefore(n);
|
||
sel.setRng(r1);
|
||
|
||
return Event.cancel(e);
|
||
}
|
||
}
|
||
}
|
||
});
|
||
|
||
// Safari doesn't place lists outside block elements
|
||
ed.onExecCommand.add(function(ed, cmd) {
|
||
var sel, dom, bl, bm;
|
||
|
||
if (cmd == 'InsertUnorderedList' || cmd == 'InsertOrderedList') {
|
||
sel = ed.selection;
|
||
dom = ed.dom;
|
||
|
||
if (bl = dom.getParent(sel.getNode(), function(n) {return /^(H[1-6]|P|ADDRESS|PRE)$/.test(n.nodeName);})) {
|
||
bm = sel.getBookmark();
|
||
dom.remove(bl, 1);
|
||
sel.moveToBookmark(bm);
|
||
}
|
||
}
|
||
});
|
||
|
||
// Workaround for bug, http://bugs.webkit.org/show_bug.cgi?id=12250
|
||
ed.onClick.add(function(ed, e) {
|
||
e = e.target;
|
||
|
||
if (e.nodeName == 'IMG') {
|
||
t.selElm = e;
|
||
ed.selection.select(e);
|
||
} else
|
||
t.selElm = null;
|
||
});
|
||
|
||
ed.onInit.add(function() {
|
||
t._fixWebKitSpans();
|
||
|
||
if (isOldWebKit)
|
||
t._patchSafari2x(ed);
|
||
});
|
||
|
||
ed.onSetContent.add(function() {
|
||
dom = ed.dom;
|
||
|
||
// Convert strong,b,em,u,strike to spans
|
||
each(['strong','b','em','u','strike','sub','sup','a'], function(v) {
|
||
each(grep(dom.select(v)).reverse(), function(n) {
|
||
var nn = n.nodeName.toLowerCase(), st;
|
||
|
||
// Convert anchors into images
|
||
if (nn == 'a') {
|
||
if (n.name)
|
||
dom.replace(dom.create('img', {mce_name : 'a', name : n.name, 'class' : 'mceItemAnchor'}), n);
|
||
|
||
return;
|
||
}
|
||
|
||
switch (nn) {
|
||
case 'b':
|
||
case 'strong':
|
||
if (nn == 'b')
|
||
nn = 'strong';
|
||
|
||
st = 'font-weight: bold;';
|
||
break;
|
||
|
||
case 'em':
|
||
st = 'font-style: italic;';
|
||
break;
|
||
|
||
case 'u':
|
||
st = 'text-decoration: underline;';
|
||
break;
|
||
|
||
case 'sub':
|
||
st = 'vertical-align: sub;';
|
||
break;
|
||
|
||
case 'sup':
|
||
st = 'vertical-align: super;';
|
||
break;
|
||
|
||
case 'strike':
|
||
st = 'text-decoration: line-through;';
|
||
break;
|
||
}
|
||
|
||
dom.replace(dom.create('span', {mce_name : nn, style : st, 'class' : 'Apple-style-span'}), n, 1);
|
||
});
|
||
});
|
||
});
|
||
|
||
ed.onPreProcess.add(function(ed, o) {
|
||
dom = ed.dom;
|
||
|
||
each(grep(o.node.getElementsByTagName('span')).reverse(), function(n) {
|
||
var v, bg;
|
||
|
||
if (o.get) {
|
||
if (dom.hasClass(n, 'Apple-style-span')) {
|
||
bg = n.style.backgroundColor;
|
||
|
||
switch (dom.getAttrib(n, 'mce_name')) {
|
||
case 'font':
|
||
if (!ed.settings.convert_fonts_to_spans)
|
||
dom.setAttrib(n, 'style', '');
|
||
break;
|
||
|
||
case 'strong':
|
||
case 'em':
|
||
case 'sub':
|
||
case 'sup':
|
||
dom.setAttrib(n, 'style', '');
|
||
break;
|
||
|
||
case 'strike':
|
||
case 'u':
|
||
if (!ed.settings.inline_styles)
|
||
dom.setAttrib(n, 'style', '');
|
||
else
|
||
dom.setAttrib(n, 'mce_name', '');
|
||
|
||
break;
|
||
|
||
default:
|
||
if (!ed.settings.inline_styles)
|
||
dom.setAttrib(n, 'style', '');
|
||
}
|
||
|
||
|
||
if (bg)
|
||
n.style.backgroundColor = bg;
|
||
}
|
||
}
|
||
|
||
if (dom.hasClass(n, 'mceItemRemoved'))
|
||
dom.remove(n, 1);
|
||
});
|
||
});
|
||
|
||
ed.onPostProcess.add(function(ed, o) {
|
||
// Safari adds BR at end of all block elements
|
||
o.content = o.content.replace(/<br \/><\/(h[1-6]|div|p|address|pre)>/g, '</$1>');
|
||
|
||
// Safari adds id="undefined" to HR elements
|
||
o.content = o.content.replace(/ id=\"undefined\"/g, '');
|
||
});
|
||
},
|
||
|
||
getInfo : function() {
|
||
return {
|
||
longname : 'Safari compatibility',
|
||
author : 'Moxiecode Systems AB',
|
||
authorurl : 'http://tinymce.moxiecode.com',
|
||
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/safari',
|
||
version : tinymce.majorVersion + "." + tinymce.minorVersion
|
||
};
|
||
},
|
||
|
||
// Internal methods
|
||
|
||
_fixWebKitSpans : function() {
|
||
var t = this, ed = t.editor;
|
||
|
||
if (!isOldWebKit) {
|
||
// Use mutator events on new WebKit
|
||
Event.add(ed.getDoc(), 'DOMNodeInserted', function(e) {
|
||
e = e.target;
|
||
|
||
if (e && e.nodeType == 1)
|
||
t._fixAppleSpan(e);
|
||
});
|
||
} else {
|
||
// Do post command processing in old WebKit since the browser crashes on Mutator events :(
|
||
ed.onExecCommand.add(function() {
|
||
each(ed.dom.select('span'), function(n) {
|
||
t._fixAppleSpan(n);
|
||
});
|
||
|
||
ed.nodeChanged();
|
||
});
|
||
}
|
||
},
|
||
|
||
_fixAppleSpan : function(e) {
|
||
var ed = this.editor, dom = ed.dom, fz = this.webKitFontSizes, fzn = this.namedFontSizes, s = ed.settings, st, p;
|
||
|
||
if (dom.getAttrib(e, 'mce_fixed'))
|
||
return;
|
||
|
||
// Handle Apple style spans
|
||
if (e.nodeName == 'SPAN' && e.className == 'Apple-style-span') {
|
||
st = e.style;
|
||
|
||
if (!s.convert_fonts_to_spans) {
|
||
if (st.fontSize) {
|
||
dom.setAttrib(e, 'mce_name', 'font');
|
||
dom.setAttrib(e, 'size', inArray(fz, st.fontSize) + 1);
|
||
}
|
||
|
||
if (st.fontFamily) {
|
||
dom.setAttrib(e, 'mce_name', 'font');
|
||
dom.setAttrib(e, 'face', st.fontFamily);
|
||
}
|
||
|
||
if (st.color) {
|
||
dom.setAttrib(e, 'mce_name', 'font');
|
||
dom.setAttrib(e, 'color', dom.toHex(st.color));
|
||
}
|
||
|
||
if (st.backgroundColor) {
|
||
dom.setAttrib(e, 'mce_name', 'font');
|
||
dom.setStyle(e, 'background-color', st.backgroundColor);
|
||
}
|
||
} else {
|
||
if (st.fontSize)
|
||
dom.setStyle(e, 'fontSize', fzn[inArray(fz, st.fontSize)]);
|
||
}
|
||
|
||
if (st.fontWeight == 'bold')
|
||
dom.setAttrib(e, 'mce_name', 'strong');
|
||
|
||
if (st.fontStyle == 'italic')
|
||
dom.setAttrib(e, 'mce_name', 'em');
|
||
|
||
if (st.textDecoration == 'underline')
|
||
dom.setAttrib(e, 'mce_name', 'u');
|
||
|
||
if (st.textDecoration == 'line-through')
|
||
dom.setAttrib(e, 'mce_name', 'strike');
|
||
|
||
if (st.verticalAlign == 'super')
|
||
dom.setAttrib(e, 'mce_name', 'sup');
|
||
|
||
if (st.verticalAlign == 'sub')
|
||
dom.setAttrib(e, 'mce_name', 'sub');
|
||
|
||
dom.setAttrib(e, 'mce_fixed', '1');
|
||
}
|
||
},
|
||
|
||
_patchSafari2x : function(ed) {
|
||
var t = this, setContent, getNode, dom = ed.dom, lr;
|
||
|
||
// Inline dialogs
|
||
if (ed.windowManager.onBeforeOpen) {
|
||
ed.windowManager.onBeforeOpen.add(function() {
|
||
r = ed.selection.getRng();
|
||
});
|
||
}
|
||
|
||
// Fake select on 2.x
|
||
ed.selection.select = function(n) {
|
||
this.getSel().setBaseAndExtent(n, 0, n, 1);
|
||
};
|
||
|
||
getNode = ed.selection.getNode;
|
||
ed.selection.getNode = function() {
|
||
return t.selElm || getNode.call(this);
|
||
};
|
||
|
||
// Fake range on Safari 2.x
|
||
ed.selection.getRng = function() {
|
||
var t = this, s = t.getSel(), d = ed.getDoc(), r, rb, ra, di;
|
||
|
||
// Fake range on Safari 2.x
|
||
if (s.anchorNode) {
|
||
r = d.createRange();
|
||
|
||
try {
|
||
// Setup before range
|
||
rb = d.createRange();
|
||
rb.setStart(s.anchorNode, s.anchorOffset);
|
||
rb.collapse(1);
|
||
|
||
// Setup after range
|
||
ra = d.createRange();
|
||
ra.setStart(s.focusNode, s.focusOffset);
|
||
ra.collapse(1);
|
||
|
||
// Setup start/end points by comparing locations
|
||
di = rb.compareBoundaryPoints(rb.START_TO_END, ra) < 0;
|
||
r.setStart(di ? s.anchorNode : s.focusNode, di ? s.anchorOffset : s.focusOffset);
|
||
r.setEnd(di ? s.focusNode : s.anchorNode, di ? s.focusOffset : s.anchorOffset);
|
||
|
||
lr = r;
|
||
} catch (ex) {
|
||
// Sometimes fails, at least we tried to do it by the book. I hope Safari 2.x will go disappear soooon!!!
|
||
}
|
||
}
|
||
|
||
return r || lr;
|
||
};
|
||
|
||
// Fix setContent so it works
|
||
setContent = ed.selection.setContent;
|
||
ed.selection.setContent = function(h, s) {
|
||
var r = this.getRng(), b;
|
||
|
||
try {
|
||
setContent.call(this, h, s);
|
||
} catch (ex) {
|
||
// Workaround for Safari 2.x
|
||
b = dom.create('body');
|
||
b.innerHTML = h;
|
||
|
||
each(b.childNodes, function(n) {
|
||
r.insertNode(n.cloneNode(true));
|
||
});
|
||
}
|
||
};
|
||
},
|
||
|
||
_insertBR : function(ed) {
|
||
var dom = ed.dom, s = ed.selection, r = s.getRng(), br;
|
||
|
||
// Insert BR element
|
||
r.insertNode(br = dom.create('br'));
|
||
|
||
// Place caret after BR
|
||
r.setStartAfter(br);
|
||
r.setEndAfter(br);
|
||
s.setRng(r);
|
||
|
||
// Could not place caret after BR then insert an nbsp entity and move the caret
|
||
if (s.getSel().focusNode == br.previousSibling) {
|
||
s.select(dom.insertAfter(dom.doc.createTextNode('\u00a0'), br));
|
||
s.collapse(1);
|
||
}
|
||
|
||
// Scroll to new position, scrollIntoView can't be used due to bug: http://bugs.webkit.org/show_bug.cgi?id=16117
|
||
ed.getWin().scrollTo(0, dom.getPos(s.getRng().startContainer).y);
|
||
}
|
||
});
|
||
|
||
// Register plugin
|
||
tinymce.PluginManager.add('safari', tinymce.plugins.Safari);
|
||
})();
|
||
|
freenetis/branches/1.1/media/js/tinymce/plugins/safari/editor_plugin.js | ||
---|---|---|
(function(){var Event=tinymce.dom.Event,grep=tinymce.grep,each=tinymce.each,inArray=tinymce.inArray,isOldWebKit=tinymce.isOldWebKit;function isEmpty(d,e,f){var w,n;w=d.createTreeWalker(e,NodeFilter.SHOW_ALL,null,false);while(n=w.nextNode()){if(f){if(!f(n))return false;}if(n.nodeType==3&&n.nodeValue&&/[^\s\u00a0]+/.test(n.nodeValue))return false;if(n.nodeType==1&&/^(HR|IMG|TABLE)$/.test(n.nodeName))return false;}return true;};tinymce.create('tinymce.plugins.Safari',{init:function(ed){var t=this,dom;if(!tinymce.isWebKit)return;t.editor=ed;t.webKitFontSizes=['x-small','small','medium','large','x-large','xx-large','-webkit-xxx-large'];t.namedFontSizes=['xx-small','x-small','small','medium','large','x-large','xx-large'];ed.addCommand('CreateLink',function(u,v){var n=ed.selection.getNode(),dom=ed.dom,a;if(n&&(/^(left|right)$/i.test(dom.getStyle(n,'float',1))||/^(left|right)$/i.test(dom.getAttrib(n,'align')))){a=dom.create('a',{href:v},n.cloneNode());n.parentNode.replaceChild(a,n);ed.selection.select(a);}else ed.getDoc().execCommand("CreateLink",false,v);});ed.onPaste.add(function(ed,e){function removeStyles(e){e=e.target;if(e.nodeType==1){e.style.cssText='';each(ed.dom.select('*',e),function(e){e.style.cssText='';});}};Event.add(ed.getDoc(),'DOMNodeInserted',removeStyles);window.setTimeout(function(){Event.remove(ed.getDoc(),'DOMNodeInserted',removeStyles);},0);});ed.onKeyUp.add(function(ed,e){var h,b,r,n,s;if(e.keyCode==46||e.keyCode==8){b=ed.getBody();h=b.innerHTML;s=ed.selection;if(b.childNodes.length==1&&!/<(img|hr)/.test(h)&&tinymce.trim(h.replace(/<[^>]+>/g,'')).length==0){ed.setContent('<p><br mce_bogus="1" /></p>',{format:'raw'});n=b.firstChild;r=s.getRng();r.setStart(n,0);r.setEnd(n,0);s.setRng(r);}}});ed.addCommand('FormatBlock',function(u,v){var dom=ed.dom,e=dom.getParent(ed.selection.getNode(),dom.isBlock);if(e)dom.replace(dom.create(v),e,1);else ed.getDoc().execCommand("FormatBlock",false,v);});ed.addCommand('mceInsertContent',function(u,v){ed.getDoc().execCommand("InsertText",false,'mce_marker');ed.getBody().innerHTML=ed.getBody().innerHTML.replace(/mce_marker/g,ed.dom.processHTML(v)+'<span id="_mce_tmp">XX</span>');ed.selection.select(ed.dom.get('_mce_tmp'));ed.getDoc().execCommand("Delete",false,' ');});ed.onKeyPress.add(function(ed,e){var se,li,lic,r1,r2,n,sel,doc,be,af,pa;if(e.keyCode==13){sel=ed.selection;se=sel.getNode();if(e.shiftKey||ed.settings.force_br_newlines&&se.nodeName!='LI'){t._insertBR(ed);Event.cancel(e);}if(li=dom.getParent(se,'LI')){lic=dom.getParent(li,'OL,UL');doc=ed.getDoc();pa=dom.create('p');dom.add(pa,'br',{mce_bogus:"1"});if(isEmpty(doc,li)){if(n=dom.getParent(lic.parentNode,'LI,OL,UL'))return;n=dom.getParent(lic,'p,h1,h2,h3,h4,h5,h6,div')||lic;r1=doc.createRange();r1.setStartBefore(n);r1.setEndBefore(li);r2=doc.createRange();r2.setStartAfter(li);r2.setEndAfter(n);be=r1.cloneContents();af=r2.cloneContents();if(!isEmpty(doc,af))dom.insertAfter(af,n);dom.insertAfter(pa,n);if(!isEmpty(doc,be))dom.insertAfter(be,n);dom.remove(n);n=pa.firstChild;r1=doc.createRange();r1.setStartBefore(n);r1.setEndBefore(n);sel.setRng(r1);return Event.cancel(e);}}}});ed.onExecCommand.add(function(ed,cmd){var sel,dom,bl,bm;if(cmd=='InsertUnorderedList'||cmd=='InsertOrderedList'){sel=ed.selection;dom=ed.dom;if(bl=dom.getParent(sel.getNode(),function(n){return/^(H[1-6]|P|ADDRESS|PRE)$/.test(n.nodeName);})){bm=sel.getBookmark();dom.remove(bl,1);sel.moveToBookmark(bm);}}});ed.onClick.add(function(ed,e){e=e.target;if(e.nodeName=='IMG'){t.selElm=e;ed.selection.select(e);}else t.selElm=null;});ed.onInit.add(function(){t._fixWebKitSpans();if(isOldWebKit)t._patchSafari2x(ed);});ed.onSetContent.add(function(){dom=ed.dom;each(['strong','b','em','u','strike','sub','sup','a'],function(v){each(grep(dom.select(v)).reverse(),function(n){var nn=n.nodeName.toLowerCase(),st;if(nn=='a'){if(n.name)dom.replace(dom.create('img',{mce_name:'a',name:n.name,'class':'mceItemAnchor'}),n);return;}switch(nn){case'b':case'strong':if(nn=='b')nn='strong';st='font-weight: bold;';break;case'em':st='font-style: italic;';break;case'u':st='text-decoration: underline;';break;case'sub':st='vertical-align: sub;';break;case'sup':st='vertical-align: super;';break;case'strike':st='text-decoration: line-through;';break;}dom.replace(dom.create('span',{mce_name:nn,style:st,'class':'Apple-style-span'}),n,1);});});});ed.onPreProcess.add(function(ed,o){dom=ed.dom;each(grep(o.node.getElementsByTagName('span')).reverse(),function(n){var v,bg;if(o.get){if(dom.hasClass(n,'Apple-style-span')){bg=n.style.backgroundColor;switch(dom.getAttrib(n,'mce_name')){case'font':if(!ed.settings.convert_fonts_to_spans)dom.setAttrib(n,'style','');break;case'strong':case'em':case'sub':case'sup':dom.setAttrib(n,'style','');break;case'strike':case'u':if(!ed.settings.inline_styles)dom.setAttrib(n,'style','');else dom.setAttrib(n,'mce_name','');break;default:if(!ed.settings.inline_styles)dom.setAttrib(n,'style','');}if(bg)n.style.backgroundColor=bg;}}if(dom.hasClass(n,'mceItemRemoved'))dom.remove(n,1);});});ed.onPostProcess.add(function(ed,o){o.content=o.content.replace(/<br \/><\/(h[1-6]|div|p|address|pre)>/g,'</$1>');o.content=o.content.replace(/ id=\"undefined\"/g,'');});},getInfo:function(){return{longname:'Safari compatibility',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/safari',version:tinymce.majorVersion+"."+tinymce.minorVersion};},_fixWebKitSpans:function(){var t=this,ed=t.editor;if(!isOldWebKit){Event.add(ed.getDoc(),'DOMNodeInserted',function(e){e=e.target;if(e&&e.nodeType==1)t._fixAppleSpan(e);});}else{ed.onExecCommand.add(function(){each(ed.dom.select('span'),function(n){t._fixAppleSpan(n);});ed.nodeChanged();});}},_fixAppleSpan:function(e){var ed=this.editor,dom=ed.dom,fz=this.webKitFontSizes,fzn=this.namedFontSizes,s=ed.settings,st,p;if(dom.getAttrib(e,'mce_fixed'))return;if(e.nodeName=='SPAN'&&e.className=='Apple-style-span'){st=e.style;if(!s.convert_fonts_to_spans){if(st.fontSize){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'size',inArray(fz,st.fontSize)+1);}if(st.fontFamily){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'face',st.fontFamily);}if(st.color){dom.setAttrib(e,'mce_name','font');dom.setAttrib(e,'color',dom.toHex(st.color));}if(st.backgroundColor){dom.setAttrib(e,'mce_name','font');dom.setStyle(e,'background-color',st.backgroundColor);}}else{if(st.fontSize)dom.setStyle(e,'fontSize',fzn[inArray(fz,st.fontSize)]);}if(st.fontWeight=='bold')dom.setAttrib(e,'mce_name','strong');if(st.fontStyle=='italic')dom.setAttrib(e,'mce_name','em');if(st.textDecoration=='underline')dom.setAttrib(e,'mce_name','u');if(st.textDecoration=='line-through')dom.setAttrib(e,'mce_name','strike');if(st.verticalAlign=='super')dom.setAttrib(e,'mce_name','sup');if(st.verticalAlign=='sub')dom.setAttrib(e,'mce_name','sub');dom.setAttrib(e,'mce_fixed','1');}},_patchSafari2x:function(ed){var t=this,setContent,getNode,dom=ed.dom,lr;if(ed.windowManager.onBeforeOpen){ed.windowManager.onBeforeOpen.add(function(){r=ed.selection.getRng();});}ed.selection.select=function(n){this.getSel().setBaseAndExtent(n,0,n,1);};getNode=ed.selection.getNode;ed.selection.getNode=function(){return t.selElm||getNode.call(this);};ed.selection.getRng=function(){var t=this,s=t.getSel(),d=ed.getDoc(),r,rb,ra,di;if(s.anchorNode){r=d.createRange();try{rb=d.createRange();rb.setStart(s.anchorNode,s.anchorOffset);rb.collapse(1);ra=d.createRange();ra.setStart(s.focusNode,s.focusOffset);ra.collapse(1);di=rb.compareBoundaryPoints(rb.START_TO_END,ra)<0;r.setStart(di?s.anchorNode:s.focusNode,di?s.anchorOffset:s.focusOffset);r.setEnd(di?s.focusNode:s.anchorNode,di?s.focusOffset:s.anchorOffset);lr=r;}catch(ex){}}return r||lr;};setContent=ed.selection.setContent;ed.selection.setContent=function(h,s){var r=this.getRng(),b;try{setContent.call(this,h,s);}catch(ex){b=dom.create('body');b.innerHTML=h;each(b.childNodes,function(n){r.insertNode(n.cloneNode(true));});}};},_insertBR:function(ed){var dom=ed.dom,s=ed.selection,r=s.getRng(),br;r.insertNode(br=dom.create('br'));r.setStartAfter(br);r.setEndAfter(br);s.setRng(r);if(s.getSel().focusNode==br.previousSibling){s.select(dom.insertAfter(dom.doc.createTextNode('\u00a0'),br));s.collapse(1);}ed.getWin().scrollTo(0,dom.getPos(s.getRng().startContainer).y);}});tinymce.PluginManager.add('safari',tinymce.plugins.Safari);})();
|
freenetis/branches/1.1/media/js/tinymce/plugins/safari/blank.htm | ||
---|---|---|
<!-- WebKit -->
|
freenetis/branches/1.1/media/js/tinymce/plugins/compat2x/editor_plugin_src.js | ||
---|---|---|
/**
|
||
* $Id: editor_plugin_src.js 264 2007-04-26 20:53:09Z spocke $
|
||
*
|
||
* @author Moxiecode
|
||
* @copyright Copyright ? 2004-2008, Moxiecode Systems AB, All rights reserved.
|
||
*/
|
||
|
||
(function() {
|
||
var DOM = tinymce.DOM, Event = tinymce.dom.Event, each = tinymce.each, is = tinymce.is;
|
||
|
||
tinymce.create('tinymce.plugins.Compat2x', {
|
||
getInfo : function() {
|
||
return {
|
||
longname : 'Compat2x',
|
||
author : 'Moxiecode Systems AB',
|
||
authorurl : 'http://tinymce.moxiecode.com',
|
||
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/compat2x',
|
||
version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
|
||
};
|
||
}
|
||
});
|
||
|
||
(function() {
|
||
// Extend tinyMCE/EditorManager
|
||
tinymce.extend(tinyMCE, {
|
||
addToLang : function(p, l) {
|
||
each(l, function(v, k) {
|
||
tinyMCE.i18n[(tinyMCE.settings.language || 'en') + '.' + (p ? p + '_' : '') + k] = v;
|
||
});
|
||
},
|
||
|
||
getInstanceById : function(n) {
|
||
return this.get(n);
|
||
}
|
||
});
|
||
})();
|
||
|
||
(function() {
|
||
var EditorManager = tinymce.EditorManager;
|
||
|
||
tinyMCE.instances = {};
|
||
tinyMCE.plugins = {};
|
||
tinymce.PluginManager.onAdd.add(function(pm, n, p) {
|
||
tinyMCE.plugins[n] = p;
|
||
});
|
||
|
||
tinyMCE.majorVersion = tinymce.majorVersion;
|
||
tinyMCE.minorVersion = tinymce.minorVersion;
|
||
tinyMCE.releaseDate = tinymce.releaseDate;
|
||
tinyMCE.baseURL = tinymce.baseURL;
|
||
tinyMCE.isIE = tinyMCE.isMSIE = tinymce.isIE || tinymce.isOpera;
|
||
tinyMCE.isMSIE5 = tinymce.isIE;
|
||
tinyMCE.isMSIE5_0 = tinymce.isIE;
|
||
tinyMCE.isMSIE7 = tinymce.isIE;
|
||
tinyMCE.isGecko = tinymce.isGecko;
|
||
tinyMCE.isSafari = tinymce.isWebKit;
|
||
tinyMCE.isOpera = tinymce.isOpera;
|
||
tinyMCE.isMac = false;
|
||
tinyMCE.isNS7 = false;
|
||
tinyMCE.isNS71 = false;
|
||
tinyMCE.compat = true;
|
||
|
||
// Extend tinyMCE class
|
||
TinyMCE_Engine = tinyMCE;
|
||
tinymce.extend(tinyMCE, {
|
||
getParam : function(n, dv) {
|
||
return this.activeEditor.getParam(n, dv);
|
||
},
|
||
|
||
addEvent : function(e, na, f, sc) {
|
||
tinymce.dom.Event.add(e, na, f, sc || this);
|
||
},
|
||
|
||
getControlHTML : function(n) {
|
||
return EditorManager.activeEditor.controlManager.createControl(n);
|
||
},
|
||
|
||
loadCSS : function(u) {
|
||
tinymce.DOM.loadCSS(u);
|
||
},
|
||
|
||
importCSS : function(doc, u) {
|
||
if (doc == document)
|
||
this.loadCSS(u);
|
||
else
|
||
new tinymce.dom.DOMUtils(doc).loadCSS(u);
|
||
},
|
||
|
||
log : function() {
|
||
console.debug.apply(console, arguments);
|
||
},
|
||
|
||
getLang : function(n, dv) {
|
||
var v = EditorManager.activeEditor.getLang(n.replace(/^lang_/g, ''), dv);
|
||
|
||
// Is number
|
||
if (/^[0-9\-.]+$/g.test(v))
|
||
return parseInt(v);
|
||
|
||
return v;
|
||
},
|
||
|
||
isInstance : function(o) {
|
||
return o != null && typeof(o) == "object" && o.execCommand;
|
||
},
|
||
|
||
triggerNodeChange : function() {
|
||
EditorManager.activeEditor.nodeChanged();
|
||
},
|
||
|
||
regexpReplace : function(in_str, reg_exp, replace_str, opts) {
|
||
var re;
|
||
|
||
if (in_str == null)
|
||
return in_str;
|
||
|
||
if (typeof(opts) == "undefined")
|
||
opts = 'g';
|
||
|
||
re = new RegExp(reg_exp, opts);
|
||
|
||
return in_str.replace(re, replace_str);
|
||
},
|
||
|
||
trim : function(s) {
|
||
return tinymce.trim(s);
|
||
},
|
||
|
||
xmlEncode : function(s) {
|
||
return tinymce.DOM.encode(s);
|
||
},
|
||
|
||
explode : function(s, d) {
|
||
var o = [];
|
||
|
||
tinymce.each(s.split(d), function(v) {
|
||
if (v != '')
|
||
o.push(v);
|
||
});
|
||
|
||
return o;
|
||
},
|
||
|
||
switchClass : function(id, cls) {
|
||
var b;
|
||
|
||
if (/^mceButton/.test(cls)) {
|
||
b = EditorManager.activeEditor.controlManager.get(id);
|
||
|
||
if (!b)
|
||
return;
|
||
|
||
switch (cls) {
|
||
case "mceButtonNormal":
|
||
b.setDisabled(false);
|
||
b.setActive(false);
|
||
return;
|
||
|
||
case "mceButtonDisabled":
|
||
b.setDisabled(true);
|
||
return;
|
||
|
||
case "mceButtonSelected":
|
||
b.setActive(true);
|
||
b.setDisabled(false);
|
||
return;
|
||
}
|
||
}
|
||
},
|
||
|
||
addCSSClass : function(e, n, b) {
|
||
return tinymce.DOM.addClass(e, n, b);
|
||
},
|
||
|
||
hasCSSClass : function(e, n) {
|
||
return tinymce.DOM.hasClass(e, n);
|
||
},
|
||
|
||
removeCSSClass : function(e, n) {
|
||
return tinymce.DOM.removeClass(e, n);
|
||
},
|
||
|
||
getCSSClasses : function() {
|
||
var cl = EditorManager.activeEditor.dom.getClasses(), o = [];
|
||
|
||
each(cl, function(c) {
|
||
o.push(c['class']);
|
||
});
|
||
|
||
return o;
|
||
},
|
||
|
||
setWindowArg : function(n, v) {
|
||
EditorManager.activeEditor.windowManager.params[n] = v;
|
||
},
|
||
|
||
getWindowArg : function(n, dv) {
|
||
var wm = EditorManager.activeEditor.windowManager, v;
|
||
|
||
v = wm.getParam(n);
|
||
if (v === '')
|
||
return '';
|
||
|
||
return v || wm.getFeature(n) || dv;
|
||
},
|
||
|
||
getParentNode : function(n, f) {
|
||
return this._getDOM().getParent(n, f);
|
||
},
|
||
|
||
selectElements : function(n, na, f) {
|
||
var i, a = [], nl, x;
|
||
|
||
for (x=0, na = na.split(','); x<na.length; x++)
|
||
for (i=0, nl = n.getElementsByTagName(na[x]); i<nl.length; i++)
|
||
(!f || f(nl[i])) && a.push(nl[i]);
|
||
|
||
return a;
|
||
},
|
||
|
||
getNodeTree : function(n, na, t, nn) {
|
||
return this.selectNodes(n, function(n) {
|
||
return (!t || n.nodeType == t) && (!nn || n.nodeName == nn);
|
||
}, na ? na : []);
|
||
},
|
||
|
||
getAttrib : function(e, n, dv) {
|
||
return this._getDOM().getAttrib(e, n, dv);
|
||
},
|
||
|
||
setAttrib : function(e, n, v) {
|
||
return this._getDOM().setAttrib(e, n, v);
|
||
},
|
||
|
||
getElementsByAttributeValue : function(n, e, a, v) {
|
||
var i, nl = n.getElementsByTagName(e), o = [];
|
||
|
||
for (i=0; i<nl.length; i++) {
|
||
if (tinyMCE.getAttrib(nl[i], a).indexOf(v) != -1)
|
||
o[o.length] = nl[i];
|
||
}
|
||
|
||
return o;
|
||
},
|
||
|
||
selectNodes : function(n, f, a) {
|
||
var i;
|
||
|
||
if (!a)
|
||
a = [];
|
||
|
||
if (f(n))
|
||
a[a.length] = n;
|
||
|
||
if (n.hasChildNodes()) {
|
||
for (i=0; i<n.childNodes.length; i++)
|
||
tinyMCE.selectNodes(n.childNodes[i], f, a);
|
||
}
|
||
|
||
return a;
|
||
},
|
||
|
||
getContent : function() {
|
||
return EditorManager.activeEditor.getContent();
|
||
},
|
||
|
||
getParentElement : function(n, na, f) {
|
||
if (na)
|
||
na = new RegExp('^(' + na.toUpperCase().replace(/,/g, '|') + ')$', 'g');
|
||
|
||
return this._getDOM().getParent(n, function(n) {
|
||
return n.nodeType == 1 && (!na || na.test(n.nodeName)) && (!f || f(n));
|
||
}, this.activeEditor.getBody());
|
||
},
|
||
|
||
importPluginLanguagePack : function(n) {
|
||
tinymce.PluginManager.requireLangPack(n);
|
||
},
|
||
|
||
getButtonHTML : function(cn, lang, img, c, u, v) {
|
||
var ed = EditorManager.activeEditor;
|
||
|
||
img = img.replace(/\{\$pluginurl\}/g, tinyMCE.pluginURL);
|
||
img = img.replace(/\{\$themeurl\}/g, tinyMCE.themeURL);
|
||
lang = lang.replace(/^lang_/g, '');
|
||
|
||
return ed.controlManager.createButton(cn, {
|
||
title : lang,
|
||
command : c,
|
||
ui : u,
|
||
value : v,
|
||
scope : this,
|
||
'class' : 'compat',
|
||
image : img
|
||
});
|
||
},
|
||
|
||
addSelectAccessibility : function(e, s, w) {
|
||
// Add event handlers
|
||
if (!s._isAccessible) {
|
||
s.onkeydown = tinyMCE.accessibleEventHandler;
|
||
s.onblur = tinyMCE.accessibleEventHandler;
|
||
s._isAccessible = true;
|
||
s._win = w;
|
||
}
|
||
|
||
return false;
|
||
},
|
||
|
||
accessibleEventHandler : function(e) {
|
||
var elm, win = this._win;
|
||
|
||
e = tinymce.isIE ? win.event : e;
|
||
elm = tinymce.isIE ? e.srcElement : e.target;
|
||
|
||
// Unpiggyback onchange on blur
|
||
if (e.type == "blur") {
|
||
if (elm.oldonchange) {
|
||
elm.onchange = elm.oldonchange;
|
||
elm.oldonchange = null;
|
||
}
|
||
|
||
return true;
|
||
}
|
||
|
||
// Piggyback onchange
|
||
if (elm.nodeName == "SELECT" && !elm.oldonchange) {
|
||
elm.oldonchange = elm.onchange;
|
||
elm.onchange = null;
|
||
}
|
||
|
||
// Execute onchange and remove piggyback
|
||
if (e.keyCode == 13 || e.keyCode == 32) {
|
||
elm.onchange = elm.oldonchange;
|
||
elm.onchange();
|
||
elm.oldonchange = null;
|
||
|
||
tinyMCE.cancelEvent(e);
|
||
return false;
|
||
}
|
||
|
||
return true;
|
||
},
|
||
|
||
cancelEvent : function(e) {
|
||
return tinymce.dom.Event.cancel(e);
|
||
},
|
||
|
||
handleVisualAid : function(e) {
|
||
EditorManager.activeEditor.addVisual(e);
|
||
},
|
||
|
||
getAbsPosition : function(n, r) {
|
||
return tinymce.DOM.getPos(n, r);
|
||
},
|
||
|
||
cleanupEventStr : function(s) {
|
||
s = "" + s;
|
||
s = s.replace('function anonymous()\n{\n', '');
|
||
s = s.replace('\n}', '');
|
||
s = s.replace(/^return true;/gi, ''); // Remove event blocker
|
||
|
||
return s;
|
||
},
|
||
|
||
getVisualAidClass : function(s) {
|
||
// TODO: Implement
|
||
return s;
|
||
},
|
||
|
||
parseStyle : function(s) {
|
||
return this._getDOM().parseStyle(s);
|
||
},
|
||
|
||
serializeStyle : function(s) {
|
||
return this._getDOM().serializeStyle(s);
|
||
},
|
||
|
||
openWindow : function(tpl, args) {
|
||
var ed = EditorManager.activeEditor, o = {}, n;
|
||
|
||
// Convert name/value array to object
|
||
for (n in tpl)
|
||
o[n] = tpl[n];
|
||
|
||
tpl = o;
|
||
|
||
args = args || {};
|
||
tpl.url = new tinymce.util.URI(tinymce.ThemeManager.themeURLs[ed.settings.theme]).toAbsolute(tpl.file);
|
||
tpl.inline = tpl.inline || args.inline;
|
||
|
||
ed.windowManager.open(tpl, args);
|
||
},
|
||
|
||
closeWindow : function(win) {
|
||
EditorManager.activeEditor.windowManager.close(win);
|
||
},
|
||
|
||
getOuterHTML : function(e) {
|
||
return tinymce.DOM.getOuterHTML(e);
|
||
},
|
||
|
||
setOuterHTML : function(e, h, d) {
|
||
return tinymce.DOM.setOuterHTML(e, h, d);
|
||
},
|
||
|
||
hasPlugin : function(n) {
|
||
return tinymce.PluginManager.get(n) != null;
|
||
},
|
||
|
||
_setEventsEnabled : function() {
|
||
// Ignore it!!
|
||
},
|
||
|
||
addPlugin : function(pn, f) {
|
||
var t = this;
|
||
|
||
function PluginWrapper(ed) {
|
||
tinyMCE.selectedInstance = ed;
|
||
|
||
ed.onInit.add(function() {
|
||
t.settings = ed.settings;
|
||
t.settings['base_href'] = tinyMCE.documentBasePath;
|
||
tinyMCE.settings = t.settings;
|
||
tinyMCE.documentBasePath = ed.documentBasePath;
|
||
//ed.formElement = DOM.get(ed.id);
|
||
|
||
if (f.initInstance)
|
||
f.initInstance(ed);
|
||
|
||
ed.contentDocument = ed.getDoc();
|
||
ed.contentWindow = ed.getWin();
|
||
ed.undoRedo = ed.undoManager;
|
||
ed.startContent = ed.getContent({format : 'raw'});
|
||
|
||
tinyMCE.instances[ed.id] = ed;
|
||
tinyMCE.loadedFiles = [];
|
||
});
|
||
|
||
ed.onActivate.add(function() {
|
||
tinyMCE.settings = ed.settings;
|
||
tinyMCE.selectedInstance = ed;
|
||
});
|
||
|
||
/* if (f.removeInstance) {
|
||
ed.onDestroy.add(function() {
|
||
return f.removeInstance(ed.id);
|
||
});
|
||
}*/
|
||
|
||
if (f.handleNodeChange) {
|
||
ed.onNodeChange.add(function(ed, cm, n) {
|
||
f.handleNodeChange(ed.id, n, 0, 0, false, !ed.selection.isCollapsed());
|
||
});
|
||
}
|
||
|
||
if (f.onChange) {
|
||
ed.onChange.add(function(ed, n) {
|
||
return f.onChange(ed);
|
||
});
|
||
}
|
||
|
||
if (f.cleanup) {
|
||
ed.onGetContent.add(function() {
|
||
//f.cleanup(type, content, inst);
|
||
});
|
||
}
|
||
|
||
this.getInfo = function() {
|
||
return f.getInfo();
|
||
};
|
||
|
||
this.createControl = function(n) {
|
||
tinyMCE.pluginURL = tinymce.baseURL + '/plugins/' + pn;
|
||
tinyMCE.themeURL = tinymce.baseURL + '/themes/' + tinyMCE.activeEditor.settings.theme;
|
||
|
||
if (f.getControlHTML)
|
||
return f.getControlHTML(n);
|
||
|
||
return null;
|
||
};
|
||
|
||
this.execCommand = function(cmd, ui, val) {
|
||
if (f.execCommand)
|
||
return f.execCommand(ed.id, ed.getBody(), cmd, ui, val);
|
||
|
||
return false;
|
||
};
|
||
};
|
||
|
||
tinymce.PluginManager.add(pn, PluginWrapper);
|
||
},
|
||
|
||
_getDOM : function() {
|
||
return tinyMCE.activeEditor ? tinyMCE.activeEditor.dom : tinymce.DOM;
|
||
},
|
||
|
||
convertRelativeToAbsoluteURL : function(b, u) {
|
||
return new tinymce.util.URI(b).toAbsolute(u);
|
||
},
|
||
|
||
convertAbsoluteURLToRelativeURL : function(b, u) {
|
||
return new tinymce.util.URI(b).toRelative(u);
|
||
}
|
||
});
|
||
|
||
// Extend Editor class
|
||
tinymce.extend(tinymce.Editor.prototype, {
|
||
getFocusElement : function() {
|
||
return this.selection.getNode();
|
||
},
|
||
|
||
getData : function(n) {
|
||
if (!this.data)
|
||
this.data = [];
|
||
|
||
if (!this.data[n])
|
||
this.data[n] = [];
|
||
|
||
return this.data[n];
|
||
},
|
||
|
||
hasPlugin : function(n) {
|
||
return this.plugins[n] != null;
|
||
},
|
||
|
||
getContainerWin : function() {
|
||
return window;
|
||
},
|
||
|
||
getHTML : function(raw) {
|
||
return this.getContent({ format : raw ? 'raw' : 'html'});
|
||
},
|
||
|
||
setHTML : function(h) {
|
||
this.setContent(h);
|
||
},
|
||
|
||
getSel : function() {
|
||
return this.selection.getSel();
|
||
},
|
||
|
||
getRng : function() {
|
||
return this.selection.getRng();
|
||
},
|
||
|
||
isHidden : function() {
|
||
var s;
|
||
|
||
if (!tinymce.isGecko)
|
||
return false;
|
||
|
||
s = this.getSel();
|
||
|
||
// Weird, wheres that cursor selection?
|
||
return (!s || !s.rangeCount || s.rangeCount == 0);
|
||
},
|
||
|
||
translate : function(s) {
|
||
var c = this.settings.language, o;
|
||
|
||
if (!s)
|
||
return s;
|
||
|
||
o = tinymce.EditorManager.i18n[c + '.' + s] || s.replace(/{\#([^}]+)\}/g, function(a, b) {
|
||
return tinymce.EditorManager.i18n[c + '.' + b] || '{#' + b + '}';
|
||
});
|
||
|
||
o = o.replace(/{\$lang_([^}]+)\}/g, function(a, b) {
|
||
return tinymce.EditorManager.i18n[c + '.' + b] || '{$lang_' + b + '}';
|
||
});
|
||
|
||
return o;
|
||
},
|
||
|
||
repaint : function() {
|
||
this.execCommand('mceRepaint');
|
||
}
|
||
});
|
||
|
||
// Extend selection
|
||
tinymce.extend(tinymce.dom.Selection.prototype, {
|
||
getSelectedText : function() {
|
||
return this.getContent({format : 'text'});
|
||
},
|
||
|
||
getSelectedHTML : function() {
|
||
return this.getContent({format : 'html'});
|
||
},
|
||
|
||
getFocusElement : function() {
|
||
return this.getNode();
|
||
},
|
||
|
||
selectNode : function(node, collapse, select_text_node, to_start) {
|
||
var t = this;
|
||
|
||
t.select(node, select_text_node || 0);
|
||
|
||
if (!is(collapse))
|
||
collapse = true;
|
||
|
||
if (collapse) {
|
||
if (!is(to_start))
|
||
to_start = true;
|
||
|
||
t.collapse(to_start);
|
||
}
|
||
}
|
||
});
|
||
}).call(this);
|
||
|
||
// Register plugin
|
||
tinymce.PluginManager.add('compat2x', tinymce.plugins.Compat2x);
|
||
})();
|
||
|
freenetis/branches/1.1/media/js/tinymce/plugins/compat2x/editor_plugin.js | ||
---|---|---|
(function(){var DOM=tinymce.DOM,Event=tinymce.dom.Event,each=tinymce.each,is=tinymce.is;tinymce.create('tinymce.plugins.Compat2x',{getInfo:function(){return{longname:'Compat2x',author:'Moxiecode Systems AB',authorurl:'http://tinymce.moxiecode.com',infourl:'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/compat2x',version:tinyMCE.majorVersion+"."+tinyMCE.minorVersion};}});(function(){tinymce.extend(tinyMCE,{addToLang:function(p,l){each(l,function(v,k){tinyMCE.i18n[(tinyMCE.settings.language||'en')+'.'+(p?p+'_':'')+k]=v;});},getInstanceById:function(n){return this.get(n);}});})();(function(){var EditorManager=tinymce.EditorManager;tinyMCE.instances={};tinyMCE.plugins={};tinymce.PluginManager.onAdd.add(function(pm,n,p){tinyMCE.plugins[n]=p;});tinyMCE.majorVersion=tinymce.majorVersion;tinyMCE.minorVersion=tinymce.minorVersion;tinyMCE.releaseDate=tinymce.releaseDate;tinyMCE.baseURL=tinymce.baseURL;tinyMCE.isIE=tinyMCE.isMSIE=tinymce.isIE||tinymce.isOpera;tinyMCE.isMSIE5=tinymce.isIE;tinyMCE.isMSIE5_0=tinymce.isIE;tinyMCE.isMSIE7=tinymce.isIE;tinyMCE.isGecko=tinymce.isGecko;tinyMCE.isSafari=tinymce.isWebKit;tinyMCE.isOpera=tinymce.isOpera;tinyMCE.isMac=false;tinyMCE.isNS7=false;tinyMCE.isNS71=false;tinyMCE.compat=true;TinyMCE_Engine=tinyMCE;tinymce.extend(tinyMCE,{getParam:function(n,dv){return this.activeEditor.getParam(n,dv);},addEvent:function(e,na,f,sc){tinymce.dom.Event.add(e,na,f,sc||this);},getControlHTML:function(n){return EditorManager.activeEditor.controlManager.createControl(n);},loadCSS:function(u){tinymce.DOM.loadCSS(u);},importCSS:function(doc,u){if(doc==document)this.loadCSS(u);else new tinymce.dom.DOMUtils(doc).loadCSS(u);},log:function(){console.debug.apply(console,arguments);},getLang:function(n,dv){var v=EditorManager.activeEditor.getLang(n.replace(/^lang_/g,''),dv);if(/^[0-9\-.]+$/g.test(v))return parseInt(v);return v;},isInstance:function(o){return o!=null&&typeof(o)=="object"&&o.execCommand;},triggerNodeChange:function(){EditorManager.activeEditor.nodeChanged();},regexpReplace:function(in_str,reg_exp,replace_str,opts){var re;if(in_str==null)return in_str;if(typeof(opts)=="undefined")opts='g';re=new RegExp(reg_exp,opts);return in_str.replace(re,replace_str);},trim:function(s){return tinymce.trim(s);},xmlEncode:function(s){return tinymce.DOM.encode(s);},explode:function(s,d){var o=[];tinymce.each(s.split(d),function(v){if(v!='')o.push(v);});return o;},switchClass:function(id,cls){var b;if(/^mceButton/.test(cls)){b=EditorManager.activeEditor.controlManager.get(id);if(!b)return;switch(cls){case"mceButtonNormal":b.setDisabled(false);b.setActive(false);return;case"mceButtonDisabled":b.setDisabled(true);return;case"mceButtonSelected":b.setActive(true);b.setDisabled(false);return;}}},addCSSClass:function(e,n,b){return tinymce.DOM.addClass(e,n,b);},hasCSSClass:function(e,n){return tinymce.DOM.hasClass(e,n);},removeCSSClass:function(e,n){return tinymce.DOM.removeClass(e,n);},getCSSClasses:function(){var cl=EditorManager.activeEditor.dom.getClasses(),o=[];each(cl,function(c){o.push(c['class']);});return o;},setWindowArg:function(n,v){EditorManager.activeEditor.windowManager.params[n]=v;},getWindowArg:function(n,dv){var wm=EditorManager.activeEditor.windowManager,v;v=wm.getParam(n);if(v==='')return'';return v||wm.getFeature(n)||dv;},getParentNode:function(n,f){return this._getDOM().getParent(n,f);},selectElements:function(n,na,f){var i,a=[],nl,x;for(x=0,na=na.split(',');x<na.length;x++)for(i=0,nl=n.getElementsByTagName(na[x]);i<nl.length;i++)(!f||f(nl[i]))&&a.push(nl[i]);return a;},getNodeTree:function(n,na,t,nn){return this.selectNodes(n,function(n){return(!t||n.nodeType==t)&&(!nn||n.nodeName==nn);},na?na:[]);},getAttrib:function(e,n,dv){return this._getDOM().getAttrib(e,n,dv);},setAttrib:function(e,n,v){return this._getDOM().setAttrib(e,n,v);},getElementsByAttributeValue:function(n,e,a,v){var i,nl=n.getElementsByTagName(e),o=[];for(i=0;i<nl.length;i++){if(tinyMCE.getAttrib(nl[i],a).indexOf(v)!=-1)o[o.length]=nl[i];}return o;},selectNodes:function(n,f,a){var i;if(!a)a=[];if(f(n))a[a.length]=n;if(n.hasChildNodes()){for(i=0;i<n.childNodes.length;i++)tinyMCE.selectNodes(n.childNodes[i],f,a);}return a;},getContent:function(){return EditorManager.activeEditor.getContent();},getParentElement:function(n,na,f){if(na)na=new RegExp('^('+na.toUpperCase().replace(/,/g,'|')+')$','g');return this._getDOM().getParent(n,function(n){return n.nodeType==1&&(!na||na.test(n.nodeName))&&(!f||f(n));},this.activeEditor.getBody());},importPluginLanguagePack:function(n){tinymce.PluginManager.requireLangPack(n);},getButtonHTML:function(cn,lang,img,c,u,v){var ed=EditorManager.activeEditor;img=img.replace(/\{\$pluginurl\}/g,tinyMCE.pluginURL);img=img.replace(/\{\$themeurl\}/g,tinyMCE.themeURL);lang=lang.replace(/^lang_/g,'');return ed.controlManager.createButton(cn,{title:lang,command:c,ui:u,value:v,scope:this,'class':'compat',image:img});},addSelectAccessibility:function(e,s,w){if(!s._isAccessible){s.onkeydown=tinyMCE.accessibleEventHandler;s.onblur=tinyMCE.accessibleEventHandler;s._isAccessible=true;s._win=w;}return false;},accessibleEventHandler:function(e){var elm,win=this._win;e=tinymce.isIE?win.event:e;elm=tinymce.isIE?e.srcElement:e.target;if(e.type=="blur"){if(elm.oldonchange){elm.onchange=elm.oldonchange;elm.oldonchange=null;}return true;}if(elm.nodeName=="SELECT"&&!elm.oldonchange){elm.oldonchange=elm.onchange;elm.onchange=null;}if(e.keyCode==13||e.keyCode==32){elm.onchange=elm.oldonchange;elm.onchange();elm.oldonchange=null;tinyMCE.cancelEvent(e);return false;}return true;},cancelEvent:function(e){return tinymce.dom.Event.cancel(e);},handleVisualAid:function(e){EditorManager.activeEditor.addVisual(e);},getAbsPosition:function(n,r){return tinymce.DOM.getPos(n,r);},cleanupEventStr:function(s){s=""+s;s=s.replace('function anonymous()\n{\n','');s=s.replace('\n}','');s=s.replace(/^return true;/gi,'');return s;},getVisualAidClass:function(s){return s;},parseStyle:function(s){return this._getDOM().parseStyle(s);},serializeStyle:function(s){return this._getDOM().serializeStyle(s);},openWindow:function(tpl,args){var ed=EditorManager.activeEditor,o={},n;for(n in tpl)o[n]=tpl[n];tpl=o;args=args||{};tpl.url=new tinymce.util.URI(tinymce.ThemeManager.themeURLs[ed.settings.theme]).toAbsolute(tpl.file);tpl.inline=tpl.inline||args.inline;ed.windowManager.open(tpl,args);},closeWindow:function(win){EditorManager.activeEditor.windowManager.close(win);},getOuterHTML:function(e){return tinymce.DOM.getOuterHTML(e);},setOuterHTML:function(e,h,d){return tinymce.DOM.setOuterHTML(e,h,d);},hasPlugin:function(n){return tinymce.PluginManager.get(n)!=null;},_setEventsEnabled:function(){},addPlugin:function(pn,f){var t=this;function PluginWrapper(ed){tinyMCE.selectedInstance=ed;ed.onInit.add(function(){t.settings=ed.settings;t.settings['base_href']=tinyMCE.documentBasePath;tinyMCE.settings=t.settings;tinyMCE.documentBasePath=ed.documentBasePath;if(f.initInstance)f.initInstance(ed);ed.contentDocument=ed.getDoc();ed.contentWindow=ed.getWin();ed.undoRedo=ed.undoManager;ed.startContent=ed.getContent({format:'raw'});tinyMCE.instances[ed.id]=ed;tinyMCE.loadedFiles=[];});ed.onActivate.add(function(){tinyMCE.settings=ed.settings;tinyMCE.selectedInstance=ed;});if(f.handleNodeChange){ed.onNodeChange.add(function(ed,cm,n){f.handleNodeChange(ed.id,n,0,0,false,!ed.selection.isCollapsed());});}if(f.onChange){ed.onChange.add(function(ed,n){return f.onChange(ed);});}if(f.cleanup){ed.onGetContent.add(function(){});}this.getInfo=function(){return f.getInfo();};this.createControl=function(n){tinyMCE.pluginURL=tinymce.baseURL+'/plugins/'+pn;tinyMCE.themeURL=tinymce.baseURL+'/themes/'+tinyMCE.activeEditor.settings.theme;if(f.getControlHTML)return f.getControlHTML(n);return null;};this.execCommand=function(cmd,ui,val){if(f.execCommand)return f.execCommand(ed.id,ed.getBody(),cmd,ui,val);return false;};};tinymce.PluginManager.add(pn,PluginWrapper);},_getDOM:function(){return tinyMCE.activeEditor?tinyMCE.activeEditor.dom:tinymce.DOM;},convertRelativeToAbsoluteURL:function(b,u){return new tinymce.util.URI(b).toAbsolute(u);},convertAbsoluteURLToRelativeURL:function(b,u){return new tinymce.util.URI(b).toRelative(u);}});tinymce.extend(tinymce.Editor.prototype,{getFocusElement:function(){return this.selection.getNode();},getData:function(n){if(!this.data)this.data=[];if(!this.data[n])this.data[n]=[];return this.data[n];},hasPlugin:function(n){return this.plugins[n]!=null;},getContainerWin:function(){return window;},getHTML:function(raw){return this.getContent({format:raw?'raw':'html'});},setHTML:function(h){this.setContent(h);},getSel:function(){return this.selection.getSel();},getRng:function(){return this.selection.getRng();},isHidden:function(){var s;if(!tinymce.isGecko)return false;s=this.getSel();return(!s||!s.rangeCount||s.rangeCount==0);},translate:function(s){var c=this.settings.language,o;if(!s)return s;o=tinymce.EditorManager.i18n[c+'.'+s]||s.replace(/{\#([^}]+)\}/g,function(a,b){return tinymce.EditorManager.i18n[c+'.'+b]||'{#'+b+'}';});o=o.replace(/{\$lang_([^}]+)\}/g,function(a,b){return tinymce.EditorManager.i18n[c+'.'+b]||'{$lang_'+b+'}';});return o;},repaint:function(){this.execCommand('mceRepaint');}});tinymce.extend(tinymce.dom.Selection.prototype,{getSelectedText:function(){return this.getContent({format:'text'});},getSelectedHTML:function(){return this.getContent({format:'html'});},getFocusElement:function(){return this.getNode();},selectNode:function(node,collapse,select_text_node,to_start){var t=this;t.select(node,select_text_node||0);if(!is(collapse))collapse=true;if(collapse){if(!is(to_start))to_start=true;t.collapse(to_start);}}});}).call(this);tinymce.PluginManager.add('compat2x',tinymce.plugins.Compat2x);})();
|
freenetis/branches/1.1/media/js/tinymce/plugins/pagebreak/css/content.css | ||
---|---|---|
.mcePageBreak {display:block;border:0;width:100%;height:12px;border-top:1px dotted #ccc;margin-top:15px;background:#fff url(../img/pagebreak.gif) no-repeat center top;}
|
freenetis/branches/1.1/media/js/tinymce/plugins/paste/css/blank.css | ||
---|---|---|
html, body {height:98%}
|
||
body {
|
||
background-color: #FFFFFF;
|
||
font-family: Verdana, Arial, Helvetica, sans-serif;
|
||
font-size: 10px;
|
||
scrollbar-3dlight-color: #F0F0EE;
|
||
scrollbar-arrow-color: #676662;
|
||
scrollbar-base-color: #F0F0EE;
|
||
scrollbar-darkshadow-color: #DDDDDD;
|
||
scrollbar-face-color: #E0E0DD;
|
||
scrollbar-highlight-color: #F0F0EE;
|
||
scrollbar-shadow-color: #F0F0EE;
|
||
scrollbar-track-color: #F5F5F5;
|
||
}
|
freenetis/branches/1.1/media/js/tinymce/plugins/paste/css/pasteword.css | ||
---|---|---|
.sourceIframe {
|
||
border: 1px solid #808080;
|
||
}
|
Také k dispozici: Unified diff
Opravy:
- fixes #576: Internacionalizace a aktualizace WYSIWYG editoru