editor_template_src.js 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359
  1. /**
  2. * editor_template_src.js
  3. *
  4. * Copyright 2009, Moxiecode Systems AB
  5. * Released under LGPL License.
  6. *
  7. * License: http://tinymce.moxiecode.com/license
  8. * Contributing: http://tinymce.moxiecode.com/contributing
  9. */
  10. (function(tinymce) {
  11. var DOM = tinymce.DOM, Event = tinymce.dom.Event, extend = tinymce.extend, each = tinymce.each, Cookie = tinymce.util.Cookie, lastExtID, explode = tinymce.explode;
  12. // Tell it to load theme specific language pack(s)
  13. tinymce.ThemeManager.requireLangPack('advanced');
  14. tinymce.create('tinymce.themes.AdvancedTheme', {
  15. sizes : [8, 10, 12, 14, 18, 24, 36],
  16. // Control name lookup, format: title, command
  17. controls : {
  18. bold : ['bold_desc', 'Bold'],
  19. italic : ['italic_desc', 'Italic'],
  20. underline : ['underline_desc', 'Underline'],
  21. strikethrough : ['striketrough_desc', 'Strikethrough'],
  22. justifyleft : ['justifyleft_desc', 'JustifyLeft'],
  23. justifycenter : ['justifycenter_desc', 'JustifyCenter'],
  24. justifyright : ['justifyright_desc', 'JustifyRight'],
  25. justifyfull : ['justifyfull_desc', 'JustifyFull'],
  26. bullist : ['bullist_desc', 'InsertUnorderedList'],
  27. numlist : ['numlist_desc', 'InsertOrderedList'],
  28. outdent : ['outdent_desc', 'Outdent'],
  29. indent : ['indent_desc', 'Indent'],
  30. cut : ['cut_desc', 'Cut'],
  31. copy : ['copy_desc', 'Copy'],
  32. paste : ['paste_desc', 'Paste'],
  33. undo : ['undo_desc', 'Undo'],
  34. redo : ['redo_desc', 'Redo'],
  35. link : ['link_desc', 'mceLink'],
  36. unlink : ['unlink_desc', 'unlink'],
  37. image : ['image_desc', 'mceImage'],
  38. cleanup : ['cleanup_desc', 'mceCleanup'],
  39. help : ['help_desc', 'mceHelp'],
  40. code : ['code_desc', 'mceCodeEditor'],
  41. hr : ['hr_desc', 'InsertHorizontalRule'],
  42. removeformat : ['removeformat_desc', 'RemoveFormat'],
  43. sub : ['sub_desc', 'subscript'],
  44. sup : ['sup_desc', 'superscript'],
  45. forecolor : ['forecolor_desc', 'ForeColor'],
  46. forecolorpicker : ['forecolor_desc', 'mceForeColor'],
  47. backcolor : ['backcolor_desc', 'HiliteColor'],
  48. backcolorpicker : ['backcolor_desc', 'mceBackColor'],
  49. charmap : ['charmap_desc', 'mceCharMap'],
  50. visualaid : ['visualaid_desc', 'mceToggleVisualAid'],
  51. anchor : ['anchor_desc', 'mceInsertAnchor'],
  52. newdocument : ['newdocument_desc', 'mceNewDocument'],
  53. blockquote : ['blockquote_desc', 'mceBlockQuote']
  54. },
  55. stateControls : ['bold', 'italic', 'underline', 'strikethrough', 'bullist', 'numlist', 'justifyleft', 'justifycenter', 'justifyright', 'justifyfull', 'sub', 'sup', 'blockquote'],
  56. init : function(ed, url) {
  57. var t = this, s, v, o;
  58. t.editor = ed;
  59. t.url = url;
  60. t.onResolveName = new tinymce.util.Dispatcher(this);
  61. ed.forcedHighContrastMode = ed.settings.detect_highcontrast && t._isHighContrast();
  62. ed.settings.skin = ed.forcedHighContrastMode ? 'highcontrast' : ed.settings.skin;
  63. // Default settings
  64. t.settings = s = extend({
  65. theme_advanced_path : true,
  66. theme_advanced_toolbar_location : 'bottom',
  67. theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect",
  68. theme_advanced_buttons2 : "bullist,numlist,|,outdent,indent,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code",
  69. theme_advanced_buttons3 : "hr,removeformat,visualaid,|,sub,sup,|,charmap",
  70. theme_advanced_blockformats : "p,address,pre,h1,h2,h3,h4,h5,h6",
  71. theme_advanced_toolbar_align : "center",
  72. theme_advanced_fonts : "Andale Mono=andale mono,times;Arial=arial,helvetica,sans-serif;Arial Black=arial black,avant garde;Book Antiqua=book antiqua,palatino;Comic Sans MS=comic sans ms,sans-serif;Courier New=courier new,courier;Georgia=georgia,palatino;Helvetica=helvetica;Impact=impact,chicago;Symbol=symbol;Tahoma=tahoma,arial,helvetica,sans-serif;Terminal=terminal,monaco;Times New Roman=times new roman,times;Trebuchet MS=trebuchet ms,geneva;Verdana=verdana,geneva;Webdings=webdings;Wingdings=wingdings,zapf dingbats",
  73. theme_advanced_more_colors : 1,
  74. theme_advanced_row_height : 23,
  75. theme_advanced_resize_horizontal : 1,
  76. theme_advanced_resizing_use_cookie : 1,
  77. theme_advanced_font_sizes : "1,2,3,4,5,6,7",
  78. theme_advanced_font_selector : "span",
  79. theme_advanced_show_current_color: 0,
  80. readonly : ed.settings.readonly
  81. }, ed.settings);
  82. // Setup default font_size_style_values
  83. if (!s.font_size_style_values)
  84. s.font_size_style_values = "8pt,10pt,12pt,14pt,18pt,24pt,36pt";
  85. if (tinymce.is(s.theme_advanced_font_sizes, 'string')) {
  86. s.font_size_style_values = tinymce.explode(s.font_size_style_values);
  87. s.font_size_classes = tinymce.explode(s.font_size_classes || '');
  88. // Parse string value
  89. o = {};
  90. ed.settings.theme_advanced_font_sizes = s.theme_advanced_font_sizes;
  91. each(ed.getParam('theme_advanced_font_sizes', '', 'hash'), function(v, k) {
  92. var cl;
  93. if (k == v && v >= 1 && v <= 7) {
  94. k = v + ' (' + t.sizes[v - 1] + 'pt)';
  95. cl = s.font_size_classes[v - 1];
  96. v = s.font_size_style_values[v - 1] || (t.sizes[v - 1] + 'pt');
  97. }
  98. if (/^\s*\./.test(v))
  99. cl = v.replace(/\./g, '');
  100. o[k] = cl ? {'class' : cl} : {fontSize : v};
  101. });
  102. s.theme_advanced_font_sizes = o;
  103. }
  104. if ((v = s.theme_advanced_path_location) && v != 'none')
  105. s.theme_advanced_statusbar_location = s.theme_advanced_path_location;
  106. if (s.theme_advanced_statusbar_location == 'none')
  107. s.theme_advanced_statusbar_location = 0;
  108. if (ed.settings.content_css !== false)
  109. ed.contentCSS.push(ed.baseURI.toAbsolute(url + "/skins/" + ed.settings.skin + "/content.css"));
  110. // Init editor
  111. ed.onInit.add(function() {
  112. if (!ed.settings.readonly) {
  113. ed.onNodeChange.add(t._nodeChanged, t);
  114. ed.onKeyUp.add(t._updateUndoStatus, t);
  115. ed.onMouseUp.add(t._updateUndoStatus, t);
  116. ed.dom.bind(ed.dom.getRoot(), 'dragend', function() {
  117. t._updateUndoStatus(ed);
  118. });
  119. }
  120. });
  121. ed.onSetProgressState.add(function(ed, b, ti) {
  122. var co, id = ed.id, tb;
  123. if (b) {
  124. t.progressTimer = setTimeout(function() {
  125. co = ed.getContainer();
  126. co = co.insertBefore(DOM.create('DIV', {style : 'position:relative'}), co.firstChild);
  127. tb = DOM.get(ed.id + '_tbl');
  128. DOM.add(co, 'div', {id : id + '_blocker', 'class' : 'mceBlocker', style : {width : tb.clientWidth + 2, height : tb.clientHeight + 2}});
  129. DOM.add(co, 'div', {id : id + '_progress', 'class' : 'mceProgress', style : {left : tb.clientWidth / 2, top : tb.clientHeight / 2}});
  130. }, ti || 0);
  131. } else {
  132. DOM.remove(id + '_blocker');
  133. DOM.remove(id + '_progress');
  134. clearTimeout(t.progressTimer);
  135. }
  136. });
  137. DOM.loadCSS(s.editor_css ? ed.documentBaseURI.toAbsolute(s.editor_css) : url + "/skins/" + ed.settings.skin + "/ui.css");
  138. if (s.skin_variant)
  139. DOM.loadCSS(url + "/skins/" + ed.settings.skin + "/ui_" + s.skin_variant + ".css");
  140. },
  141. _isHighContrast : function() {
  142. var actualColor, div = DOM.add(DOM.getRoot(), 'div', {'style': 'background-color: rgb(171,239,86);'});
  143. actualColor = (DOM.getStyle(div, 'background-color', true) + '').toLowerCase().replace(/ /g, '');
  144. DOM.remove(div);
  145. return actualColor != 'rgb(171,239,86)' && actualColor != '#abef56';
  146. },
  147. createControl : function(n, cf) {
  148. var cd, c;
  149. if (c = cf.createControl(n))
  150. return c;
  151. switch (n) {
  152. case "styleselect":
  153. return this._createStyleSelect();
  154. case "formatselect":
  155. return this._createBlockFormats();
  156. case "fontselect":
  157. return this._createFontSelect();
  158. case "fontsizeselect":
  159. return this._createFontSizeSelect();
  160. case "forecolor":
  161. return this._createForeColorMenu();
  162. case "backcolor":
  163. return this._createBackColorMenu();
  164. }
  165. if ((cd = this.controls[n]))
  166. return cf.createButton(n, {title : "advanced." + cd[0], cmd : cd[1], ui : cd[2], value : cd[3]});
  167. },
  168. execCommand : function(cmd, ui, val) {
  169. var f = this['_' + cmd];
  170. if (f) {
  171. f.call(this, ui, val);
  172. return true;
  173. }
  174. return false;
  175. },
  176. _importClasses : function(e) {
  177. var ed = this.editor, ctrl = ed.controlManager.get('styleselect');
  178. if (ctrl.getLength() == 0) {
  179. each(ed.dom.getClasses(), function(o, idx) {
  180. var name = 'style_' + idx;
  181. ed.formatter.register(name, {
  182. inline : 'span',
  183. attributes : {'class' : o['class']},
  184. selector : '*'
  185. });
  186. ctrl.add(o['class'], name);
  187. });
  188. }
  189. },
  190. _createStyleSelect : function(n) {
  191. var t = this, ed = t.editor, ctrlMan = ed.controlManager, ctrl;
  192. // Setup style select box
  193. ctrl = ctrlMan.createListBox('styleselect', {
  194. title : 'advanced.style_select',
  195. onselect : function(name) {
  196. var matches, formatNames = [];
  197. each(ctrl.items, function(item) {
  198. formatNames.push(item.value);
  199. });
  200. ed.focus();
  201. ed.undoManager.add();
  202. // Toggle off the current format
  203. matches = ed.formatter.matchAll(formatNames);
  204. if (!name || matches[0] == name) {
  205. if (matches[0])
  206. ed.formatter.remove(matches[0]);
  207. } else
  208. ed.formatter.apply(name);
  209. ed.undoManager.add();
  210. ed.nodeChanged();
  211. return false; // No auto select
  212. }
  213. });
  214. // Handle specified format
  215. ed.onInit.add(function() {
  216. var counter = 0, formats = ed.getParam('style_formats');
  217. if (formats) {
  218. each(formats, function(fmt) {
  219. var name, keys = 0;
  220. each(fmt, function() {keys++;});
  221. if (keys > 1) {
  222. name = fmt.name = fmt.name || 'style_' + (counter++);
  223. ed.formatter.register(name, fmt);
  224. ctrl.add(fmt.title, name);
  225. } else
  226. ctrl.add(fmt.title);
  227. });
  228. } else {
  229. each(ed.getParam('theme_advanced_styles', '', 'hash'), function(val, key) {
  230. var name;
  231. if (val) {
  232. name = 'style_' + (counter++);
  233. ed.formatter.register(name, {
  234. inline : 'span',
  235. classes : val,
  236. selector : '*'
  237. });
  238. ctrl.add(t.editor.translate(key), name);
  239. }
  240. });
  241. }
  242. });
  243. // Auto import classes if the ctrl box is empty
  244. if (ctrl.getLength() == 0) {
  245. ctrl.onPostRender.add(function(ed, n) {
  246. if (!ctrl.NativeListBox) {
  247. Event.add(n.id + '_text', 'focus', t._importClasses, t);
  248. Event.add(n.id + '_text', 'mousedown', t._importClasses, t);
  249. Event.add(n.id + '_open', 'focus', t._importClasses, t);
  250. Event.add(n.id + '_open', 'mousedown', t._importClasses, t);
  251. } else
  252. Event.add(n.id, 'focus', t._importClasses, t);
  253. });
  254. }
  255. return ctrl;
  256. },
  257. _createFontSelect : function() {
  258. var c, t = this, ed = t.editor;
  259. c = ed.controlManager.createListBox('fontselect', {
  260. title : 'advanced.fontdefault',
  261. onselect : function(v) {
  262. var cur = c.items[c.selectedIndex];
  263. if (!v && cur) {
  264. ed.execCommand('FontName', false, cur.value);
  265. return;
  266. }
  267. ed.execCommand('FontName', false, v);
  268. // Fake selection, execCommand will fire a nodeChange and update the selection
  269. c.select(function(sv) {
  270. return v == sv;
  271. });
  272. if (cur && cur.value == v) {
  273. c.select(null);
  274. }
  275. return false; // No auto select
  276. }
  277. });
  278. if (c) {
  279. each(ed.getParam('theme_advanced_fonts', t.settings.theme_advanced_fonts, 'hash'), function(v, k) {
  280. c.add(ed.translate(k), v, {style : v.indexOf('dings') == -1 ? 'font-family:' + v : ''});
  281. });
  282. }
  283. return c;
  284. },
  285. _createFontSizeSelect : function() {
  286. var t = this, ed = t.editor, c, i = 0, cl = [];
  287. c = ed.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', onselect : function(v) {
  288. var cur = c.items[c.selectedIndex];
  289. if (!v && cur) {
  290. cur = cur.value;
  291. if (cur['class']) {
  292. ed.formatter.toggle('fontsize_class', {value : cur['class']});
  293. ed.undoManager.add();
  294. ed.nodeChanged();
  295. } else {
  296. ed.execCommand('FontSize', false, cur.fontSize);
  297. }
  298. return;
  299. }
  300. if (v['class']) {
  301. ed.focus();
  302. ed.undoManager.add();
  303. ed.formatter.toggle('fontsize_class', {value : v['class']});
  304. ed.undoManager.add();
  305. ed.nodeChanged();
  306. } else
  307. ed.execCommand('FontSize', false, v.fontSize);
  308. // Fake selection, execCommand will fire a nodeChange and update the selection
  309. c.select(function(sv) {
  310. return v == sv;
  311. });
  312. if (cur && (cur.value.fontSize == v.fontSize || cur.value['class'] == v['class'])) {
  313. c.select(null);
  314. }
  315. return false; // No auto select
  316. }});
  317. if (c) {
  318. each(t.settings.theme_advanced_font_sizes, function(v, k) {
  319. var fz = v.fontSize;
  320. if (fz >= 1 && fz <= 7)
  321. fz = t.sizes[parseInt(fz) - 1] + 'pt';
  322. c.add(k, v, {'style' : 'font-size:' + fz, 'class' : 'mceFontSize' + (i++) + (' ' + (v['class'] || ''))});
  323. });
  324. }
  325. return c;
  326. },
  327. _createBlockFormats : function() {
  328. var c, fmts = {
  329. p : 'advanced.paragraph',
  330. address : 'advanced.address',
  331. pre : 'advanced.pre',
  332. h1 : 'advanced.h1',
  333. h2 : 'advanced.h2',
  334. h3 : 'advanced.h3',
  335. h4 : 'advanced.h4',
  336. h5 : 'advanced.h5',
  337. h6 : 'advanced.h6',
  338. div : 'advanced.div',
  339. blockquote : 'advanced.blockquote',
  340. code : 'advanced.code',
  341. dt : 'advanced.dt',
  342. dd : 'advanced.dd',
  343. samp : 'advanced.samp'
  344. }, t = this;
  345. c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', onselect : function(v) {
  346. t.editor.execCommand('FormatBlock', false, v);
  347. return false;
  348. }});
  349. if (c) {
  350. each(t.editor.getParam('theme_advanced_blockformats', t.settings.theme_advanced_blockformats, 'hash'), function(v, k) {
  351. c.add(t.editor.translate(k != v ? k : fmts[v]), v, {'class' : 'mce_formatPreview mce_' + v});
  352. });
  353. }
  354. return c;
  355. },
  356. _createForeColorMenu : function() {
  357. var c, t = this, s = t.settings, o = {}, v;
  358. if (s.theme_advanced_more_colors) {
  359. o.more_colors_func = function() {
  360. t._mceColorPicker(0, {
  361. color : c.value,
  362. func : function(co) {
  363. c.setColor(co);
  364. }
  365. });
  366. };
  367. }
  368. if (v = s.theme_advanced_text_colors)
  369. o.colors = v;
  370. if (s.theme_advanced_default_foreground_color)
  371. o.default_color = s.theme_advanced_default_foreground_color;
  372. o.title = 'advanced.forecolor_desc';
  373. o.cmd = 'ForeColor';
  374. o.scope = this;
  375. c = t.editor.controlManager.createColorSplitButton('forecolor', o);
  376. return c;
  377. },
  378. _createBackColorMenu : function() {
  379. var c, t = this, s = t.settings, o = {}, v;
  380. if (s.theme_advanced_more_colors) {
  381. o.more_colors_func = function() {
  382. t._mceColorPicker(0, {
  383. color : c.value,
  384. func : function(co) {
  385. c.setColor(co);
  386. }
  387. });
  388. };
  389. }
  390. if (v = s.theme_advanced_background_colors)
  391. o.colors = v;
  392. if (s.theme_advanced_default_background_color)
  393. o.default_color = s.theme_advanced_default_background_color;
  394. o.title = 'advanced.backcolor_desc';
  395. o.cmd = 'HiliteColor';
  396. o.scope = this;
  397. c = t.editor.controlManager.createColorSplitButton('backcolor', o);
  398. return c;
  399. },
  400. renderUI : function(o) {
  401. var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl;
  402. if (ed.settings) {
  403. ed.settings.aria_label = s.aria_label + ed.getLang('advanced.help_shortcut');
  404. }
  405. // TODO: ACC Should have an aria-describedby attribute which is user-configurable to describe what this field is actually for.
  406. // Maybe actually inherit it from the original textara?
  407. n = p = DOM.create('span', {role : 'application', 'aria-labelledby' : ed.id + '_voice', id : ed.id + '_parent', 'class' : 'mceEditor ' + ed.settings.skin + 'Skin' + (s.skin_variant ? ' ' + ed.settings.skin + 'Skin' + t._ufirst(s.skin_variant) : '')});
  408. DOM.add(n, 'span', {'class': 'mceVoiceLabel', 'style': 'display:none;', id: ed.id + '_voice'}, s.aria_label);
  409. if (!DOM.boxModel)
  410. n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'});
  411. n = sc = DOM.add(n, 'table', {role : "presentation", id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0});
  412. n = tb = DOM.add(n, 'tbody');
  413. switch ((s.theme_advanced_layout_manager || '').toLowerCase()) {
  414. case "rowlayout":
  415. ic = t._rowLayout(s, tb, o);
  416. break;
  417. case "customlayout":
  418. ic = ed.execCallback("theme_advanced_custom_layout", s, tb, o, p);
  419. break;
  420. default:
  421. ic = t._simpleLayout(s, tb, o, p);
  422. }
  423. n = o.targetNode;
  424. // Add classes to first and last TRs
  425. nl = sc.rows;
  426. DOM.addClass(nl[0], 'mceFirst');
  427. DOM.addClass(nl[nl.length - 1], 'mceLast');
  428. // Add classes to first and last TDs
  429. each(DOM.select('tr', tb), function(n) {
  430. DOM.addClass(n.firstChild, 'mceFirst');
  431. DOM.addClass(n.childNodes[n.childNodes.length - 1], 'mceLast');
  432. });
  433. if (DOM.get(s.theme_advanced_toolbar_container))
  434. DOM.get(s.theme_advanced_toolbar_container).appendChild(p);
  435. else
  436. DOM.insertAfter(p, n);
  437. Event.add(ed.id + '_path_row', 'click', function(e) {
  438. e = e.target;
  439. if (e.nodeName == 'A') {
  440. t._sel(e.className.replace(/^.*mcePath_([0-9]+).*$/, '$1'));
  441. return Event.cancel(e);
  442. }
  443. });
  444. /*
  445. if (DOM.get(ed.id + '_path_row')) {
  446. Event.add(ed.id + '_tbl', 'mouseover', function(e) {
  447. var re;
  448. e = e.target;
  449. if (e.nodeName == 'SPAN' && DOM.hasClass(e.parentNode, 'mceButton')) {
  450. re = DOM.get(ed.id + '_path_row');
  451. t.lastPath = re.innerHTML;
  452. DOM.setHTML(re, e.parentNode.title);
  453. }
  454. });
  455. Event.add(ed.id + '_tbl', 'mouseout', function(e) {
  456. if (t.lastPath) {
  457. DOM.setHTML(ed.id + '_path_row', t.lastPath);
  458. t.lastPath = 0;
  459. }
  460. });
  461. }
  462. */
  463. if (!ed.getParam('accessibility_focus'))
  464. Event.add(DOM.add(p, 'a', {href : '#'}, '<!-- IE -->'), 'focus', function() {tinyMCE.get(ed.id).focus();});
  465. if (s.theme_advanced_toolbar_location == 'external')
  466. o.deltaHeight = 0;
  467. t.deltaHeight = o.deltaHeight;
  468. o.targetNode = null;
  469. ed.onKeyDown.add(function(ed, evt) {
  470. var DOM_VK_F10 = 121, DOM_VK_F11 = 122;
  471. if (evt.altKey) {
  472. if (evt.keyCode === DOM_VK_F10) {
  473. window.focus();
  474. t.toolbarGroup.focus();
  475. return Event.cancel(evt);
  476. } else if (evt.keyCode === DOM_VK_F11) {
  477. DOM.get(ed.id + '_path_row').focus();
  478. return Event.cancel(evt);
  479. }
  480. }
  481. });
  482. // alt+0 is the UK recommended shortcut for accessing the list of access controls.
  483. ed.addShortcut('alt+0', '', 'mceShortcuts', t);
  484. return {
  485. iframeContainer : ic,
  486. editorContainer : ed.id + '_parent',
  487. sizeContainer : sc,
  488. deltaHeight : o.deltaHeight
  489. };
  490. },
  491. getInfo : function() {
  492. return {
  493. longname : 'Advanced theme',
  494. author : 'Moxiecode Systems AB',
  495. authorurl : 'http://tinymce.moxiecode.com',
  496. version : tinymce.majorVersion + "." + tinymce.minorVersion
  497. }
  498. },
  499. resizeBy : function(dw, dh) {
  500. var e = DOM.get(this.editor.id + '_ifr');
  501. this.resizeTo(e.clientWidth + dw, e.clientHeight + dh);
  502. },
  503. resizeTo : function(w, h, store) {
  504. var ed = this.editor, s = this.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr');
  505. // Boundery fix box
  506. w = Math.max(s.theme_advanced_resizing_min_width || 100, w);
  507. h = Math.max(s.theme_advanced_resizing_min_height || 100, h);
  508. w = Math.min(s.theme_advanced_resizing_max_width || 0xFFFF, w);
  509. h = Math.min(s.theme_advanced_resizing_max_height || 0xFFFF, h);
  510. // Resize iframe and container
  511. DOM.setStyle(e, 'height', '');
  512. DOM.setStyle(ifr, 'height', h);
  513. if (s.theme_advanced_resize_horizontal) {
  514. DOM.setStyle(e, 'width', '');
  515. DOM.setStyle(ifr, 'width', w);
  516. // Make sure that the size is never smaller than the over all ui
  517. if (w < e.clientWidth) {
  518. w = e.clientWidth;
  519. DOM.setStyle(ifr, 'width', e.clientWidth);
  520. }
  521. }
  522. // Store away the size
  523. if (store && s.theme_advanced_resizing_use_cookie) {
  524. Cookie.setHash("TinyMCE_" + ed.id + "_size", {
  525. cw : w,
  526. ch : h
  527. });
  528. }
  529. },
  530. destroy : function() {
  531. var id = this.editor.id;
  532. Event.clear(id + '_resize');
  533. Event.clear(id + '_path_row');
  534. Event.clear(id + '_external_close');
  535. },
  536. // Internal functions
  537. _simpleLayout : function(s, tb, o, p) {
  538. var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c;
  539. if (s.readonly) {
  540. n = DOM.add(tb, 'tr');
  541. n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
  542. return ic;
  543. }
  544. // Create toolbar container at top
  545. if (lo == 'top')
  546. t._addToolbars(tb, o);
  547. // Create external toolbar
  548. if (lo == 'external') {
  549. n = c = DOM.create('div', {style : 'position:relative'});
  550. n = DOM.add(n, 'div', {id : ed.id + '_external', 'class' : 'mceExternalToolbar'});
  551. DOM.add(n, 'a', {id : ed.id + '_external_close', href : 'javascript:;', 'class' : 'mceExternalClose'});
  552. n = DOM.add(n, 'table', {id : ed.id + '_tblext', cellSpacing : 0, cellPadding : 0});
  553. etb = DOM.add(n, 'tbody');
  554. if (p.firstChild.className == 'mceOldBoxModel')
  555. p.firstChild.appendChild(c);
  556. else
  557. p.insertBefore(c, p.firstChild);
  558. t._addToolbars(etb, o);
  559. ed.onMouseUp.add(function() {
  560. var e = DOM.get(ed.id + '_external');
  561. DOM.show(e);
  562. DOM.hide(lastExtID);
  563. var f = Event.add(ed.id + '_external_close', 'click', function() {
  564. DOM.hide(ed.id + '_external');
  565. Event.remove(ed.id + '_external_close', 'click', f);
  566. });
  567. DOM.show(e);
  568. DOM.setStyle(e, 'top', 0 - DOM.getRect(ed.id + '_tblext').h - 1);
  569. // Fixes IE rendering bug
  570. DOM.hide(e);
  571. DOM.show(e);
  572. e.style.filter = '';
  573. lastExtID = ed.id + '_external';
  574. e = null;
  575. });
  576. }
  577. if (sl == 'top')
  578. t._addStatusBar(tb, o);
  579. // Create iframe container
  580. if (!s.theme_advanced_toolbar_container) {
  581. n = DOM.add(tb, 'tr');
  582. n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
  583. }
  584. // Create toolbar container at bottom
  585. if (lo == 'bottom')
  586. t._addToolbars(tb, o);
  587. if (sl == 'bottom')
  588. t._addStatusBar(tb, o);
  589. return ic;
  590. },
  591. _rowLayout : function(s, tb, o) {
  592. var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to, a;
  593. dc = s.theme_advanced_containers_default_class || '';
  594. da = s.theme_advanced_containers_default_align || 'center';
  595. each(explode(s.theme_advanced_containers || ''), function(c, i) {
  596. var v = s['theme_advanced_container_' + c] || '';
  597. switch (c.toLowerCase()) {
  598. case 'mceeditor':
  599. n = DOM.add(tb, 'tr');
  600. n = ic = DOM.add(n, 'td', {'class' : 'mceIframeContainer'});
  601. break;
  602. case 'mceelementpath':
  603. t._addStatusBar(tb, o);
  604. break;
  605. default:
  606. a = (s['theme_advanced_container_' + c + '_align'] || da).toLowerCase();
  607. a = 'mce' + t._ufirst(a);
  608. n = DOM.add(DOM.add(tb, 'tr'), 'td', {
  609. 'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + a || da
  610. });
  611. to = cf.createToolbar("toolbar" + i);
  612. t._addControls(v, to);
  613. DOM.setHTML(n, to.renderHTML());
  614. o.deltaHeight -= s.theme_advanced_row_height;
  615. }
  616. });
  617. return ic;
  618. },
  619. _addControls : function(v, tb) {
  620. var t = this, s = t.settings, di, cf = t.editor.controlManager;
  621. if (s.theme_advanced_disable && !t._disabled) {
  622. di = {};
  623. each(explode(s.theme_advanced_disable), function(v) {
  624. di[v] = 1;
  625. });
  626. t._disabled = di;
  627. } else
  628. di = t._disabled;
  629. each(explode(v), function(n) {
  630. var c;
  631. if (di && di[n])
  632. return;
  633. // Compatiblity with 2.x
  634. if (n == 'tablecontrols') {
  635. each(["table","|","row_props","cell_props","|","row_before","row_after","delete_row","|","col_before","col_after","delete_col","|","split_cells","merge_cells"], function(n) {
  636. n = t.createControl(n, cf);
  637. if (n)
  638. tb.add(n);
  639. });
  640. return;
  641. }
  642. c = t.createControl(n, cf);
  643. if (c)
  644. tb.add(c);
  645. });
  646. },
  647. _addToolbars : function(c, o) {
  648. var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a, toolbarGroup;
  649. toolbarGroup = cf.createToolbarGroup('toolbargroup', {
  650. 'name': ed.getLang('advanced.toolbar'),
  651. 'tab_focus_toolbar':ed.getParam('theme_advanced_tab_focus_toolbar')
  652. });
  653. t.toolbarGroup = toolbarGroup;
  654. a = s.theme_advanced_toolbar_align.toLowerCase();
  655. a = 'mce' + t._ufirst(a);
  656. n = DOM.add(DOM.add(c, 'tr', {role: 'presentation'}), 'td', {'class' : 'mceToolbar ' + a, "role":"presentation"});
  657. // Create toolbar and add the controls
  658. for (i=1; (v = s['theme_advanced_buttons' + i]); i++) {
  659. tb = cf.createToolbar("toolbar" + i, {'class' : 'mceToolbarRow' + i});
  660. if (s['theme_advanced_buttons' + i + '_add'])
  661. v += ',' + s['theme_advanced_buttons' + i + '_add'];
  662. if (s['theme_advanced_buttons' + i + '_add_before'])
  663. v = s['theme_advanced_buttons' + i + '_add_before'] + ',' + v;
  664. t._addControls(v, tb);
  665. toolbarGroup.add(tb);
  666. o.deltaHeight -= s.theme_advanced_row_height;
  667. }
  668. h.push(toolbarGroup.renderHTML());
  669. h.push(DOM.createHTML('a', {href : '#', accesskey : 'z', title : ed.getLang("advanced.toolbar_focus"), onfocus : 'tinyMCE.getInstanceById(\'' + ed.id + '\').focus();'}, '<!-- IE -->'));
  670. DOM.setHTML(n, h.join(''));
  671. },
  672. _addStatusBar : function(tb, o) {
  673. var n, t = this, ed = t.editor, s = t.settings, r, mf, me, td;
  674. n = DOM.add(tb, 'tr');
  675. n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'});
  676. n = DOM.add(n, 'div', {id : ed.id + '_path_row', 'role': 'group', 'aria-labelledby': ed.id + '_path_voice'});
  677. if (s.theme_advanced_path) {
  678. DOM.add(n, 'span', {id: ed.id + '_path_voice'}, ed.translate('advanced.path'));
  679. DOM.add(n, 'span', {}, ': ');
  680. } else {
  681. DOM.add(n, 'span', {}, '&#160;');
  682. }
  683. if (s.theme_advanced_resizing) {
  684. DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize'});
  685. if (s.theme_advanced_resizing_use_cookie) {
  686. ed.onPostRender.add(function() {
  687. var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl');
  688. if (!o)
  689. return;
  690. t.resizeTo(o.cw, o.ch);
  691. });
  692. }
  693. ed.onPostRender.add(function() {
  694. Event.add(ed.id + '_resize', 'click', function(e) {
  695. e.preventDefault();
  696. });
  697. Event.add(ed.id + '_resize', 'mousedown', function(e) {
  698. var mouseMoveHandler1, mouseMoveHandler2,
  699. mouseUpHandler1, mouseUpHandler2,
  700. startX, startY, startWidth, startHeight, width, height, ifrElm;
  701. function resizeOnMove(e) {
  702. e.preventDefault();
  703. width = startWidth + (e.screenX - startX);
  704. height = startHeight + (e.screenY - startY);
  705. t.resizeTo(width, height);
  706. };
  707. function endResize(e) {
  708. // Stop listening
  709. Event.remove(DOM.doc, 'mousemove', mouseMoveHandler1);
  710. Event.remove(ed.getDoc(), 'mousemove', mouseMoveHandler2);
  711. Event.remove(DOM.doc, 'mouseup', mouseUpHandler1);
  712. Event.remove(ed.getDoc(), 'mouseup', mouseUpHandler2);
  713. width = startWidth + (e.screenX - startX);
  714. height = startHeight + (e.screenY - startY);
  715. t.resizeTo(width, height, true);
  716. };
  717. e.preventDefault();
  718. // Get the current rect size
  719. startX = e.screenX;
  720. startY = e.screenY;
  721. ifrElm = DOM.get(t.editor.id + '_ifr');
  722. startWidth = width = ifrElm.clientWidth;
  723. startHeight = height = ifrElm.clientHeight;
  724. // Register envent handlers
  725. mouseMoveHandler1 = Event.add(DOM.doc, 'mousemove', resizeOnMove);
  726. mouseMoveHandler2 = Event.add(ed.getDoc(), 'mousemove', resizeOnMove);
  727. mouseUpHandler1 = Event.add(DOM.doc, 'mouseup', endResize);
  728. mouseUpHandler2 = Event.add(ed.getDoc(), 'mouseup', endResize);
  729. });
  730. });
  731. }
  732. o.deltaHeight -= 21;
  733. n = tb = null;
  734. },
  735. _updateUndoStatus : function(ed) {
  736. var cm = ed.controlManager, um = ed.undoManager;
  737. cm.setDisabled('undo', !um.hasUndo() && !um.typing);
  738. cm.setDisabled('redo', !um.hasRedo());
  739. },
  740. _nodeChanged : function(ed, cm, n, co, ob) {
  741. var t = this, p, de = 0, v, c, s = t.settings, cl, fz, fn, fc, bc, formatNames, matches;
  742. tinymce.each(t.stateControls, function(c) {
  743. cm.setActive(c, ed.queryCommandState(t.controls[c][1]));
  744. });
  745. function getParent(name) {
  746. var i, parents = ob.parents, func = name;
  747. if (typeof(name) == 'string') {
  748. func = function(node) {
  749. return node.nodeName == name;
  750. };
  751. }
  752. for (i = 0; i < parents.length; i++) {
  753. if (func(parents[i]))
  754. return parents[i];
  755. }
  756. };
  757. cm.setActive('visualaid', ed.hasVisual);
  758. t._updateUndoStatus(ed);
  759. cm.setDisabled('outdent', !ed.queryCommandState('Outdent'));
  760. p = getParent('A');
  761. if (c = cm.get('link')) {
  762. if (!p || !p.name) {
  763. c.setDisabled(!p && co);
  764. c.setActive(!!p);
  765. }
  766. }
  767. if (c = cm.get('unlink')) {
  768. c.setDisabled(!p && co);
  769. c.setActive(!!p && !p.name);
  770. }
  771. if (c = cm.get('anchor')) {
  772. c.setActive(!co && !!p && p.name);
  773. }
  774. p = getParent('IMG');
  775. if (c = cm.get('image'))
  776. c.setActive(!co && !!p && n.className.indexOf('mceItem') == -1);
  777. if (c = cm.get('styleselect')) {
  778. t._importClasses();
  779. formatNames = [];
  780. each(c.items, function(item) {
  781. formatNames.push(item.value);
  782. });
  783. matches = ed.formatter.matchAll(formatNames);
  784. c.select(matches[0]);
  785. }
  786. if (c = cm.get('formatselect')) {
  787. p = getParent(DOM.isBlock);
  788. if (p)
  789. c.select(p.nodeName.toLowerCase());
  790. }
  791. // Find out current fontSize, fontFamily and fontClass
  792. getParent(function(n) {
  793. if (n.nodeName === 'SPAN') {
  794. if (!cl && n.className)
  795. cl = n.className;
  796. }
  797. if (ed.dom.is(n, s.theme_advanced_font_selector)) {
  798. if (!fz && n.style.fontSize)
  799. fz = n.style.fontSize;
  800. if (!fn && n.style.fontFamily)
  801. fn = n.style.fontFamily.replace(/[\"\']+/g, '').replace(/^([^,]+).*/, '$1').toLowerCase();
  802. if (!fc && n.style.color)
  803. fc = n.style.color;
  804. if (!bc && n.style.backgroundColor)
  805. bc = n.style.backgroundColor;
  806. }
  807. return false;
  808. });
  809. if (c = cm.get('fontselect')) {
  810. c.select(function(v) {
  811. return v.replace(/^([^,]+).*/, '$1').toLowerCase() == fn;
  812. });
  813. }
  814. // Select font size
  815. if (c = cm.get('fontsizeselect')) {
  816. // Use computed style
  817. if (s.theme_advanced_runtime_fontsize && !fz && !cl)
  818. fz = ed.dom.getStyle(n, 'fontSize', true);
  819. c.select(function(v) {
  820. if (v.fontSize && v.fontSize === fz)
  821. return true;
  822. if (v['class'] && v['class'] === cl)
  823. return true;
  824. });
  825. }
  826. if (s.theme_advanced_show_current_color) {
  827. function updateColor(controlId, color) {
  828. if (c = cm.get(controlId)) {
  829. if (!color)
  830. color = c.settings.default_color;
  831. if (color !== c.value) {
  832. c.displayColor(color);
  833. }
  834. }
  835. }
  836. updateColor('forecolor', fc);
  837. updateColor('backcolor', bc);
  838. }
  839. if (s.theme_advanced_show_current_color) {
  840. function updateColor(controlId, color) {
  841. if (c = cm.get(controlId)) {
  842. if (!color)
  843. color = c.settings.default_color;
  844. if (color !== c.value) {
  845. c.displayColor(color);
  846. }
  847. }
  848. };
  849. updateColor('forecolor', fc);
  850. updateColor('backcolor', bc);
  851. }
  852. if (s.theme_advanced_path && s.theme_advanced_statusbar_location) {
  853. p = DOM.get(ed.id + '_path') || DOM.add(ed.id + '_path_row', 'span', {id : ed.id + '_path'});
  854. if (t.statusKeyboardNavigation) {
  855. t.statusKeyboardNavigation.destroy();
  856. t.statusKeyboardNavigation = null;
  857. }
  858. DOM.setHTML(p, '');
  859. getParent(function(n) {
  860. var na = n.nodeName.toLowerCase(), u, pi, ti = '';
  861. // Ignore non element and bogus/hidden elements
  862. if (n.nodeType != 1 || na === 'br' || n.getAttribute('data-mce-bogus') || DOM.hasClass(n, 'mceItemHidden') || DOM.hasClass(n, 'mceItemRemoved'))
  863. return;
  864. // Handle prefix
  865. if (tinymce.isIE && n.scopeName !== 'HTML')
  866. na = n.scopeName + ':' + na;
  867. // Remove internal prefix
  868. na = na.replace(/mce\:/g, '');
  869. // Handle node name
  870. switch (na) {
  871. case 'b':
  872. na = 'strong';
  873. break;
  874. case 'i':
  875. na = 'em';
  876. break;
  877. case 'img':
  878. if (v = DOM.getAttrib(n, 'src'))
  879. ti += 'src: ' + v + ' ';
  880. break;
  881. case 'a':
  882. if (v = DOM.getAttrib(n, 'name')) {
  883. ti += 'name: ' + v + ' ';
  884. na += '#' + v;
  885. }
  886. if (v = DOM.getAttrib(n, 'href'))
  887. ti += 'href: ' + v + ' ';
  888. break;
  889. case 'font':
  890. if (v = DOM.getAttrib(n, 'face'))
  891. ti += 'font: ' + v + ' ';
  892. if (v = DOM.getAttrib(n, 'size'))
  893. ti += 'size: ' + v + ' ';
  894. if (v = DOM.getAttrib(n, 'color'))
  895. ti += 'color: ' + v + ' ';
  896. break;
  897. case 'span':
  898. if (v = DOM.getAttrib(n, 'style'))
  899. ti += 'style: ' + v + ' ';
  900. break;
  901. }
  902. if (v = DOM.getAttrib(n, 'id'))
  903. ti += 'id: ' + v + ' ';
  904. if (v = n.className) {
  905. v = v.replace(/\b\s*(webkit|mce|Apple-)\w+\s*\b/g, '')
  906. if (v) {
  907. ti += 'class: ' + v + ' ';
  908. if (DOM.isBlock(n) || na == 'img' || na == 'span')
  909. na += '.' + v;
  910. }
  911. }
  912. na = na.replace(/(html:)/g, '');
  913. na = {name : na, node : n, title : ti};
  914. t.onResolveName.dispatch(t, na);
  915. ti = na.title;
  916. na = na.name;
  917. //u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');";
  918. pi = DOM.create('a', {'href' : "javascript:;", role: 'button', onmousedown : "return false;", title : ti, 'class' : 'mcePath_' + (de++)}, na);
  919. if (p.hasChildNodes()) {
  920. p.insertBefore(DOM.create('span', {'aria-hidden': 'true'}, '\u00a0\u00bb '), p.firstChild);
  921. p.insertBefore(pi, p.firstChild);
  922. } else
  923. p.appendChild(pi);
  924. }, ed.getBody());
  925. if (DOM.select('a', p).length > 0) {
  926. t.statusKeyboardNavigation = new tinymce.ui.KeyboardNavigation({
  927. root: ed.id + "_path_row",
  928. items: DOM.select('a', p),
  929. excludeFromTabOrder: true,
  930. onCancel: function() {
  931. ed.focus();
  932. }
  933. }, DOM);
  934. }
  935. }
  936. },
  937. // Commands gets called by execCommand
  938. _sel : function(v) {
  939. this.editor.execCommand('mceSelectNodeDepth', false, v);
  940. },
  941. _mceInsertAnchor : function(ui, v) {
  942. var ed = this.editor;
  943. ed.windowManager.open({
  944. url : this.url + '/anchor.htm',
  945. width : 320 + parseInt(ed.getLang('advanced.anchor_delta_width', 0)),
  946. height : 90 + parseInt(ed.getLang('advanced.anchor_delta_height', 0)),
  947. inline : true
  948. }, {
  949. theme_url : this.url
  950. });
  951. },
  952. _mceCharMap : function() {
  953. var ed = this.editor;
  954. ed.windowManager.open({
  955. url : this.url + '/charmap.htm',
  956. width : 550 + parseInt(ed.getLang('advanced.charmap_delta_width', 0)),
  957. height : 250 + parseInt(ed.getLang('advanced.charmap_delta_height', 0)),
  958. inline : true
  959. }, {
  960. theme_url : this.url
  961. });
  962. },
  963. _mceHelp : function() {
  964. var ed = this.editor;
  965. ed.windowManager.open({
  966. url : this.url + '/about.htm',
  967. width : 480,
  968. height : 380,
  969. inline : true
  970. }, {
  971. theme_url : this.url
  972. });
  973. },
  974. _mceShortcuts : function() {
  975. var ed = this.editor;
  976. ed.windowManager.open({
  977. url: this.url + '/shortcuts.htm',
  978. width: 480,
  979. height: 380,
  980. inline: true
  981. }, {
  982. theme_url: this.url
  983. });
  984. },
  985. _mceColorPicker : function(u, v) {
  986. var ed = this.editor;
  987. v = v || {};
  988. ed.windowManager.open({
  989. url : this.url + '/color_picker.htm',
  990. width : 375 + parseInt(ed.getLang('advanced.colorpicker_delta_width', 0)),
  991. height : 250 + parseInt(ed.getLang('advanced.colorpicker_delta_height', 0)),
  992. close_previous : false,
  993. inline : true
  994. }, {
  995. input_color : v.color,
  996. func : v.func,
  997. theme_url : this.url
  998. });
  999. },
  1000. _mceCodeEditor : function(ui, val) {
  1001. var ed = this.editor;
  1002. ed.windowManager.open({
  1003. url : this.url + '/source_editor.htm',
  1004. width : parseInt(ed.getParam("theme_advanced_source_editor_width", 720)),
  1005. height : parseInt(ed.getParam("theme_advanced_source_editor_height", 580)),
  1006. inline : true,
  1007. resizable : true,
  1008. maximizable : true
  1009. }, {
  1010. theme_url : this.url
  1011. });
  1012. },
  1013. _mceImage : function(ui, val) {
  1014. var ed = this.editor;
  1015. // Internal image object like a flash placeholder
  1016. if (ed.dom.getAttrib(ed.selection.getNode(), 'class').indexOf('mceItem') != -1)
  1017. return;
  1018. ed.windowManager.open({
  1019. url : this.url + '/image.htm',
  1020. width : 355 + parseInt(ed.getLang('advanced.image_delta_width', 0)),
  1021. height : 275 + parseInt(ed.getLang('advanced.image_delta_height', 0)),
  1022. inline : true
  1023. }, {
  1024. theme_url : this.url
  1025. });
  1026. },
  1027. _mceLink : function(ui, val) {
  1028. var ed = this.editor;
  1029. ed.windowManager.open({
  1030. url : this.url + '/link.htm',
  1031. width : 310 + parseInt(ed.getLang('advanced.link_delta_width', 0)),
  1032. height : 200 + parseInt(ed.getLang('advanced.link_delta_height', 0)),
  1033. inline : true
  1034. }, {
  1035. theme_url : this.url
  1036. });
  1037. },
  1038. _mceNewDocument : function() {
  1039. var ed = this.editor;
  1040. ed.windowManager.confirm('advanced.newdocument', function(s) {
  1041. if (s)
  1042. ed.execCommand('mceSetContent', false, '');
  1043. });
  1044. },
  1045. _mceForeColor : function() {
  1046. var t = this;
  1047. this._mceColorPicker(0, {
  1048. color: t.fgColor,
  1049. func : function(co) {
  1050. t.fgColor = co;
  1051. t.editor.execCommand('ForeColor', false, co);
  1052. }
  1053. });
  1054. },
  1055. _mceBackColor : function() {
  1056. var t = this;
  1057. this._mceColorPicker(0, {
  1058. color: t.bgColor,
  1059. func : function(co) {
  1060. t.bgColor = co;
  1061. t.editor.execCommand('HiliteColor', false, co);
  1062. }
  1063. });
  1064. },
  1065. _ufirst : function(s) {
  1066. return s.substring(0, 1).toUpperCase() + s.substring(1);
  1067. }
  1068. });
  1069. tinymce.ThemeManager.add('advanced', tinymce.themes.AdvancedTheme);
  1070. }(tinymce));