📄 editor_template_src.js
字号:
DOM.get(s.theme_advanced_toolbar_container).appendChild(p);
else
DOM.insertAfter(p, n);
Event.add(ed.id + '_path_row', 'click', function(e) {
e = e.target;
if (e.nodeName == 'A') {
t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/, '$1'));
return Event.cancel(e);
}
});
/*
if (DOM.get(ed.id + '_path_row')) {
Event.add(ed.id + '_tbl', 'mouseover', function(e) {
var re;
e = e.target;
if (e.nodeName == 'SPAN' && DOM.hasClass(e.parentNode, 'mceButton')) {
re = DOM.get(ed.id + '_path_row');
t.lastPath = re.innerHTML;
DOM.setHTML(re, e.parentNode.title);
}
});
Event.add(ed.id + '_tbl', 'mouseout', function(e) {
if (t.lastPath) {
DOM.setHTML(ed.id + '_path_row', t.lastPath);
t.lastPath = 0;
}
});
}
*/
if (!ed.getParam('accessibility_focus') || ed.getParam('tab_focus'))
Event.add(DOM.add(p, 'a', {href : '#'}, '<!-- IE -->'), 'focus', function() {tinyMCE.get(ed.id).focus();});
if (s.theme_advanced_toolbar_location == 'external')
o.deltaHeight = 0;
t.deltaHeight = o.deltaHeight;
o.targetNode = null;
return {
iframeContainer : ic,
editorContainer : ed.id + '_parent',
sizeContainer : sc,
deltaHeight : o.deltaHeight
};
},
getInfo : function() {
return {
longname : 'Advanced theme',
author : 'Moxiecode Systems AB',
authorurl : 'http://tinymce.moxiecode.com',
version : tinymce.majorVersion + "." + tinymce.minorVersion
}
},
resizeBy : function(dw, dh) {
var e = DOM.get(this.editor.id + '_tbl');
this.resizeTo(e.clientWidth + dw, e.clientHeight + dh);
},
resizeTo : function(w, h) {
var ed = this.editor, s = ed.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr'), dh;
// Boundery fix box
w = Math.max(s.theme_advanced_resizing_min_width || 100, w);
h = Math.max(s.theme_advanced_resizing_min_height || 100, h);
w = Math.min(s.theme_advanced_resizing_max_width || 0xFFFF, w);
h = Math.min(s.theme_advanced_resizing_max_height || 0xFFFF, h);
// Calc difference between iframe and container
dh = e.clientHeight - ifr.clientHeight;
// Resize iframe and container
DOM.setStyle(ifr, 'height', h - dh);
DOM.setStyles(e, {width : w, height : h});
},
destroy : function() {
var id = this.editor.id;
Event.clear(id + '_resize');
Event.clear(id + '_path_row');
Event.clear(id + '_external_close');
},
// Internal functions
_simpleLayout : function(s, tb, o, p) {
var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c;
// Create toolbar container at top
if (lo == 'top')
t._addToolbars(tb, o);
// Create external toolbar
if (lo == 'external') {
n = c = DOM.create('div', {style : 'position:relative'});
n = DOM.add(n, 'div', {id : ed.id + '_external', 'class' : 'mceExternalToolbar'});
DOM.add(n, 'a', {id : ed.id + '_external_close', href : 'javascript:;', 'class' : 'mceExternalClose'});
n = DOM.add(n, 'table', {id : ed.id + '_tblext', cellSpacing : 0, cellPadding : 0});
etb = DOM.add(n, 'tbody');
if (p.firstChild.className == 'mceOldBoxModel')
p.firstChild.appendChild(c);
else
p.insertBefore(c, p.firstChild);
t._addToolbars(etb, o);
ed.onMouseUp.add(function() {
var e = DOM.get(ed.id + '_external');
DOM.show(e);
DOM.hide(lastExtID);
var f = Event.add(ed.id + '_external_close', 'click', function() {
DOM.hide(ed.id + '_external');
Event.remove(ed.id + '_external_close', 'click', f);
});
DOM.show(e);
DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1);
// Fixes IE rendering bug
DOM.hide(e);
DOM.show(e);
e.style.filter = '';
lastExtID = ed.id + '_external';
e = null;
});
}
if (sl == 'top')
t._addStatusBar(tb, o);
// Create iframe container
if (!s.theme_advanced_toolbar_container) {
n = DOM.add(tb, 'tr');
n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
}
// Create toolbar container at bottom
if (lo == 'bottom')
t._addToolbars(tb, o);
if (sl == 'bottom')
t._addStatusBar(tb, o);
return ic;
},
_rowLayout : function(s, tb, o) {
var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to, a;
dc = s.theme_advanced_containers_default_class || '';
da = s.theme_advanced_containers_default_align || 'center';
each(explode(s.theme_advanced_containers || ''), function(c, i) {
var v = s['theme_advanced_container_' + c] || '';
switch (v.toLowerCase()) {
case 'mceeditor':
n = DOM.add(tb, 'tr');
n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
break;
case 'mceelementpath':
t._addStatusBar(tb, o);
break;
default:
a = (s['theme_advanced_container_' + c + '_align'] || da).toLowerCase();
a = 'mce' + t._ufirst(a);
n = DOM.add(DOM.add(tb, 'tr'), 'td', {
'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + a || da
});
to = cf.createToolbar("toolbar" + i);
t._addControls(v, to);
DOM.setHTML(n, to.renderHTML());
o.deltaHeight -= s.theme_advanced_row_height;
}
});
return ic;
},
_addControls : function(v, tb) {
var t = this, s = t.settings, di, cf = t.editor.controlManager;
if (s.theme_advanced_disable && !t._disabled) {
di = {};
each(explode(s.theme_advanced_disable), function(v) {
di[v] = 1;
});
t._disabled = di;
} else
di = t._disabled;
each(explode(v), function(n) {
var c;
if (di && di[n])
return;
// Compatiblity with 2.x
if (n == 'tablecontrols') {
each(["table","|","row_props","cell_props","|","row_before","row_after","delete_row","|","col_before","col_after","delete_col","|","split_cells","merge_cells"], function(n) {
n = t.createControl(n, cf);
if (n)
tb.add(n);
});
return;
}
c = t.createControl(n, cf);
if (c)
tb.add(c);
});
},
_addToolbars : function(c, o) {
var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a;
a = s.theme_advanced_toolbar_align.toLowerCase();
a = 'mce' + t._ufirst(a);
n = DOM.add(DOM.add(c, 'tr'), 'td', {'class' : 'mceToolbar ' + a});
if (!ed.getParam('accessibility_focus') || ed.getParam('tab_focus'))
h.push(DOM.createHTML('a', {href : '#', onfocus : 'tinyMCE.get(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
h.push(DOM.createHTML('a', {href : '#', accesskey : 'q', title : ed.getLang("advanced.toolbar_focus")}, '<!-- IE -->'));
// Create toolbar and add the controls
for (i=1; (v = s['theme_advanced_buttons' + i]); i++) {
tb = cf.createToolbar("toolbar" + i, {'class' : 'mceToolbarRow' + i});
if (s['theme_advanced_buttons' + i + '_add'])
v += ',' + s['theme_advanced_buttons' + i + '_add'];
if (s['theme_advanced_buttons' + i + '_add_before'])
v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v;
t._addControls(v, tb);
//n.appendChild(n = tb.render());
h.push(tb.renderHTML());
o.deltaHeight -= s.theme_advanced_row_height;
}
h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
DOM.setHTML(n, h.join(''));
},
_addStatusBar : function(tb, o) {
var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td;
n = DOM.add(tb, 'tr');
n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'});
n = DOM.add(n, 'div', {id : ed.id + '_path_row'}, s.theme_advanced_path ? ed.translate('advanced.path') + ': ' : ' ');
DOM.add(n, 'a', {href : '#', accesskey : 'x'});
if (s.theme_advanced_resizing && !tinymce.isOldWebKit) {
DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize'});
if (s.theme_advanced_resizing_use_cookie) {
ed.onPostRender.add(function() {
var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl');
if (!o)
return;
if (s.theme_advanced_resize_horizontal)
c.style.width = Math.max(10, o.cw) + 'px';
c.style.height = Math.max(10, o.ch) + 'px';
DOM.get(ed.id + '_ifr').style.height = Math.max(10, parseInt(o.ch) + t.deltaHeight) + 'px';
});
}
ed.onPostRender.add(function() {
Event.add(ed.id + '_resize', 'mousedown', function(e) {
var c, p, w, h, n, pa;
// Measure container
c = DOM.get(ed.id + '_tbl');
w = c.clientWidth;
h = c.clientHeight;
miw = s.theme_advanced_resizing_min_width || 100;
mih = s.theme_advanced_resizing_min_height || 100;
maw = s.theme_advanced_resizing_max_width || 0xFFFF;
mah = s.theme_advanced_resizing_max_height || 0xFFFF;
// Setup placeholder
p = DOM.add(DOM.get(ed.id + '_parent'), 'div', {'class' : 'mcePlaceHolder'});
DOM.setStyles(p, {width : w, height : h});
// Replace with placeholder
DOM.hide(c);
DOM.show(p);
// Create internal resize obj
r = {
x : e.screenX,
y : e.screenY,
w : w,
h : h,
dx : null,
dy : null
};
// Start listening
mf = Event.add(DOM.doc, 'mousemove', function(e) {
var w, h;
// Calc delta values
r.dx = e.screenX - r.x;
r.dy = e.screenY - r.y;
// Boundery fix box
w = Math.max(miw, r.w + r.dx);
h = Math.max(mih, r.h + r.dy);
w = Math.min(maw, w);
h = Math.min(mah, h);
// Resize placeholder
if (s.theme_advanced_resize_horizontal)
p.style.width = w + 'px';
p.style.height = h + 'px';
return Event.cancel(e);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -