174 } else |
177 } else |
175 ed.execCommand('mceSetCSSClass', 0, v); |
178 ed.execCommand('mceSetCSSClass', 0, v); |
176 } |
179 } |
177 }); |
180 }); |
178 |
181 |
179 each((t.settings.theme_advanced_styles || '').split(';'), function(v) { |
182 each(ed.getParam('theme_advanced_styles', '', 'hash'), function(v, k) { |
180 var p = v.split('='); |
|
181 |
|
182 if (v) |
183 if (v) |
183 c.add(t.editor.translate(p[0]), p[1]); |
184 c.add(t.editor.translate(k), v); |
184 }); |
185 }); |
185 |
186 |
186 c.onPostRender.add(function(ed, n) { |
187 c.onPostRender.add(function(ed, n) { |
187 Event.add(n, 'focus', t._importClasses, t); |
188 Event.add(n, 'focus', t._importClasses, t); |
188 Event.add(n, 'mousedown', t._importClasses, t); |
189 Event.add(n, 'mousedown', t._importClasses, t); |
190 |
191 |
191 return c; |
192 return c; |
192 }, |
193 }, |
193 |
194 |
194 _createFontSelect : function() { |
195 _createFontSelect : function() { |
195 var c, t = this; |
196 var c, t = this, ed = t.editor; |
196 |
197 |
197 c = t.editor.controlManager.createListBox('fontselect', {title : 'advanced.fontdefault', cmd : 'FontName'}); |
198 c = ed.controlManager.createListBox('fontselect', {title : 'advanced.fontdefault', cmd : 'FontName'}); |
198 |
199 |
199 each(t.settings.theme_advanced_fonts.split(';'), function(v) { |
200 each(ed.getParam('theme_advanced_fonts', t.settings.theme_advanced_fonts, 'hash'), function(v, k) { |
200 var p = v.split('='), st; |
201 c.add(ed.translate(k), v, {style : v.indexOf('dings') == -1 ? 'font-family:' + v : ''}); |
201 |
|
202 if (p[1].indexOf('dings') == -1) |
|
203 st = 'font-family:' + p[1]; |
|
204 |
|
205 c.add(t.editor.translate(p[0]), p[1], {style : st}); |
|
206 }); |
202 }); |
207 |
203 |
208 return c; |
204 return c; |
209 }, |
205 }, |
210 |
206 |
220 ], fz = [8, 10, 12, 14, 18, 24, 36]; |
216 ], fz = [8, 10, 12, 14, 18, 24, 36]; |
221 |
217 |
222 c = t.editor.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', cmd : 'FontSize'}); |
218 c = t.editor.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', cmd : 'FontSize'}); |
223 |
219 |
224 each(t.settings.theme_advanced_font_sizes.split(','), function(v) { |
220 each(t.settings.theme_advanced_font_sizes.split(','), function(v) { |
225 c.add(lo[parseInt(v) - 1], v, {'style' : 'font-size:' + fz[v - 1] + 'pt', 'class' : 'fontSize' + v}); |
221 c.add(lo[parseInt(v) - 1], v, {'style' : 'font-size:' + fz[v - 1] + 'pt', 'class' : 'mceFontSize' + v}); |
226 }); |
222 }); |
227 |
223 |
228 return c; |
224 return c; |
229 }, |
225 }, |
230 |
226 |
248 }, t = this; |
244 }, t = this; |
249 |
245 |
250 c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', cmd : 'FormatBlock'}); |
246 c = t.editor.controlManager.createListBox('formatselect', {title : 'advanced.block', cmd : 'FormatBlock'}); |
251 |
247 |
252 each(t.settings.theme_advanced_blockformats.split(','), function(v) { |
248 each(t.settings.theme_advanced_blockformats.split(','), function(v) { |
253 c.add(t.editor.translate(fmts[v]), v, {element : v, 'class' : v.indexOf('h') == 0 ? '' : 'preview'}); |
249 c.add(t.editor.translate(fmts[v]), v, {element : v, 'class' : v.indexOf('h') == 0 ? '' : 'mcePreview'}); |
254 }); |
250 }); |
255 |
251 |
256 return c; |
252 return c; |
257 }, |
253 }, |
258 |
254 |
309 }, |
305 }, |
310 |
306 |
311 renderUI : function(o) { |
307 renderUI : function(o) { |
312 var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl; |
308 var n, ic, tb, t = this, ed = t.editor, s = t.settings, sc, p, nl; |
313 |
309 |
314 n = p = DOM.create('div', {id : ed.id + '_parent', 'class' : 'mceEditor ' + ed.settings.skin + 'Skin'}); |
310 n = p = DOM.create('span', {id : ed.id + '_parent', 'class' : 'mceEditor ' + ed.settings.skin + 'Skin' + (s.skin_variant ? ' ' + ed.settings.skin + 'Skin' + t._ufirst(s.skin_variant) : '')}); |
315 |
311 |
316 if (!DOM.boxModel) |
312 if (!DOM.boxModel) |
317 n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'}); |
313 n = DOM.add(n, 'div', {'class' : 'mceOldBoxModel'}); |
318 |
314 |
319 n = sc = DOM.add(n, 'table', {id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0}); |
315 n = sc = DOM.add(n, 'table', {id : ed.id + '_tbl', 'class' : 'mceLayout', cellSpacing : 0, cellPadding : 0}); |
334 |
330 |
335 n = o.targetNode; |
331 n = o.targetNode; |
336 |
332 |
337 // Add classes to first and last TRs |
333 // Add classes to first and last TRs |
338 nl = sc.rows; |
334 nl = sc.rows; |
339 DOM.addClass(nl[0], 'first'); |
335 DOM.addClass(nl[0], 'mceFirst'); |
340 DOM.addClass(nl[nl.length - 1], 'last'); |
336 DOM.addClass(nl[nl.length - 1], 'mceLast'); |
341 |
337 |
342 // Add classes to first and last TDs |
338 // Add classes to first and last TDs |
343 each(DOM.select('tr', tb), function(n) { |
339 each(DOM.select('tr', tb), function(n) { |
344 DOM.addClass(n.firstChild, 'first'); |
340 DOM.addClass(n.firstChild, 'mceFirst'); |
345 DOM.addClass(n.childNodes[n.childNodes.length - 1], 'last'); |
341 DOM.addClass(n.childNodes[n.childNodes.length - 1], 'mceLast'); |
346 }); |
342 }); |
347 |
343 |
348 if (DOM.get(s.theme_advanced_toolbar_container)) |
344 if (DOM.get(s.theme_advanced_toolbar_container)) |
349 DOM.get(s.theme_advanced_toolbar_container).appendChild(p); |
345 DOM.get(s.theme_advanced_toolbar_container).appendChild(p); |
350 else |
346 else |
399 }; |
395 }; |
400 }, |
396 }, |
401 |
397 |
402 getInfo : function() { |
398 getInfo : function() { |
403 return { |
399 return { |
404 longname : 'Simple theme', |
400 longname : 'Advanced theme', |
405 author : 'Moxiecode Systems AB', |
401 author : 'Moxiecode Systems AB', |
406 authorurl : 'http://tinymce.moxiecode.com', |
402 authorurl : 'http://tinymce.moxiecode.com', |
407 version : tinymce.majorVersion + "." + tinymce.minorVersion |
403 version : tinymce.majorVersion + "." + tinymce.minorVersion |
408 } |
404 } |
409 }, |
405 }, |
|
406 |
|
407 resizeBy : function(dw, dh) { |
|
408 var e = DOM.get(this.editor.id + '_tbl'); |
|
409 |
|
410 this.resizeTo(e.clientWidth + dw, e.clientHeight + dh); |
|
411 }, |
|
412 |
|
413 resizeTo : function(w, h) { |
|
414 var ed = this.editor, s = ed.settings, e = DOM.get(ed.id + '_tbl'), ifr = DOM.get(ed.id + '_ifr'), dh; |
|
415 |
|
416 // Boundery fix box |
|
417 w = Math.max(s.theme_advanced_resizing_min_width || 100, w); |
|
418 h = Math.max(s.theme_advanced_resizing_min_height || 100, h); |
|
419 w = Math.min(s.theme_advanced_resizing_max_width || 0xFFFF, w); |
|
420 h = Math.min(s.theme_advanced_resizing_max_height || 0xFFFF, h); |
|
421 |
|
422 // Calc difference between iframe and container |
|
423 dh = e.clientHeight - ifr.clientHeight; |
|
424 |
|
425 // Resize iframe and container |
|
426 DOM.setStyle(ifr, 'height', h - dh); |
|
427 DOM.setStyles(e, {width : w, height : h}); |
|
428 }, |
|
429 |
|
430 // Internal functions |
410 |
431 |
411 _simpleLayout : function(s, tb, o, p) { |
432 _simpleLayout : function(s, tb, o, p) { |
412 var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c; |
433 var t = this, ed = t.editor, lo = s.theme_advanced_toolbar_location, sl = s.theme_advanced_statusbar_location, n, ic, etb, c; |
413 |
434 |
414 // Create toolbar container at top |
435 // Create toolbar container at top |
473 |
494 |
474 return ic; |
495 return ic; |
475 }, |
496 }, |
476 |
497 |
477 _rowLayout : function(s, tb, o) { |
498 _rowLayout : function(s, tb, o) { |
478 var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to; |
499 var t = this, ed = t.editor, dc, da, cf = ed.controlManager, n, ic, to, a; |
479 |
500 |
480 dc = s.theme_advanced_containers_default_class || ''; |
501 dc = s.theme_advanced_containers_default_class || ''; |
481 da = s.theme_advanced_containers_default_align || 'center'; |
502 da = s.theme_advanced_containers_default_align || 'center'; |
482 |
503 |
483 each((s.theme_advanced_containers || '').split(','), function(c, i) { |
504 each((s.theme_advanced_containers || '').split(','), function(c, i) { |
492 case 'mceelementpath': |
513 case 'mceelementpath': |
493 t._addStatusBar(tb, o); |
514 t._addStatusBar(tb, o); |
494 break; |
515 break; |
495 |
516 |
496 default: |
517 default: |
|
518 a = s['theme_advanced_container_' + c + '_align'].toLowerCase(); |
|
519 a = 'mce' + t._ufirst(a); |
|
520 |
497 n = DOM.add(DOM.add(tb, 'tr'), 'td', { |
521 n = DOM.add(DOM.add(tb, 'tr'), 'td', { |
498 'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + s['theme_advanced_container_' + c + '_align'] || da |
522 'class' : 'mceToolbar ' + (s['theme_advanced_container_' + c + '_class'] || dc) + ' ' + a || da |
499 }); |
523 }); |
500 |
524 |
501 to = cf.createToolbar("toolbar" + i); |
525 to = cf.createToolbar("toolbar" + i); |
502 t._addControls(v, to); |
526 t._addControls(v, to); |
503 DOM.setHTML(n, to.renderHTML()); |
527 DOM.setHTML(n, to.renderHTML()); |
546 tb.add(c); |
570 tb.add(c); |
547 }); |
571 }); |
548 }, |
572 }, |
549 |
573 |
550 _addToolbars : function(c, o) { |
574 _addToolbars : function(c, o) { |
551 var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = []; |
575 var t = this, i, tb, ed = t.editor, s = t.settings, v, cf = ed.controlManager, di, n, h = [], a; |
552 |
576 |
553 n = DOM.add(DOM.add(c, 'tr'), 'td', {'class' : 'mceToolbar ' + s.theme_advanced_toolbar_align}); |
577 a = s.theme_advanced_toolbar_align.toLowerCase(); |
|
578 a = 'mce' + t._ufirst(a); |
|
579 |
|
580 n = DOM.add(DOM.add(c, 'tr'), 'td', {'class' : 'mceToolbar ' + a}); |
554 |
581 |
555 if (!ed.getParam('accessibility_focus') || ed.getParam('tab_focus')) |
582 if (!ed.getParam('accessibility_focus') || ed.getParam('tab_focus')) |
556 h.push(DOM.createHTML('a', {href : '#', onfocus : 'tinyMCE.get(\'' + ed.id + '\').focus();'}, '<!-- IE -->')); |
583 h.push(DOM.createHTML('a', {href : '#', onfocus : 'tinyMCE.get(\'' + ed.id + '\').focus();'}, '<!-- IE -->')); |
557 |
584 |
558 h.push(DOM.createHTML('a', {href : '#', accesskey : 'q', title : ed.getLang("advanced.toolbar_focus")}, '<!-- IE -->')); |
585 h.push(DOM.createHTML('a', {href : '#', accesskey : 'q', title : ed.getLang("advanced.toolbar_focus")}, '<!-- IE -->')); |
586 n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'}); |
613 n = td = DOM.add(n, 'td', {'class' : 'mceStatusbar'}); |
587 n = DOM.add(n, 'div', {id : ed.id + '_path_row'}, s.theme_advanced_path ? ed.translate('advanced.path') + ': ' : ' '); |
614 n = DOM.add(n, 'div', {id : ed.id + '_path_row'}, s.theme_advanced_path ? ed.translate('advanced.path') + ': ' : ' '); |
588 DOM.add(n, 'a', {href : '#', accesskey : 'x'}); |
615 DOM.add(n, 'a', {href : '#', accesskey : 'x'}); |
589 |
616 |
590 if (s.theme_advanced_resizing && !tinymce.isOldWebKit) { |
617 if (s.theme_advanced_resizing && !tinymce.isOldWebKit) { |
591 DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'resize'}); |
618 DOM.add(td, 'a', {id : ed.id + '_resize', href : 'javascript:;', onclick : "return false;", 'class' : 'mceResize'}); |
592 |
619 |
593 if (s.theme_advanced_resizing_use_cookie) { |
620 if (s.theme_advanced_resizing_use_cookie) { |
594 ed.onPostRender.add(function() { |
621 ed.onPostRender.add(function() { |
595 var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl'); |
622 var o = Cookie.getHash("TinyMCE_" + ed.id + "_size"), c = DOM.get(ed.id + '_tbl'); |
596 |
623 |
847 t.onResolveName.dispatch(t, na); |
874 t.onResolveName.dispatch(t, na); |
848 ti = na.title; |
875 ti = na.title; |
849 na = na.name; |
876 na = na.name; |
850 |
877 |
851 //u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');"; |
878 //u = "javascript:tinymce.EditorManager.get('" + ed.id + "').theme._sel('" + (de++) + "');"; |
852 pi = DOM.create('a', {'href' : "#" + (de++) + "", onmousedown : "return false;", title : ti}, na); |
879 pi = DOM.create('a', {'href' : "javascript:;", onmousedown : "return false;", title : ti, 'class' : 'mcePath_' + (de++)}, na); |
853 |
880 |
854 if (p.hasChildNodes()) { |
881 if (p.hasChildNodes()) { |
855 p.insertBefore(document.createTextNode(' \u00bb '), p.firstChild); |
882 p.insertBefore(document.createTextNode(' \u00bb '), p.firstChild); |
856 p.insertBefore(pi, p.firstChild); |
883 p.insertBefore(pi, p.firstChild); |
857 } else |
884 } else |
989 this._mceColorPicker(0, { |
1016 this._mceColorPicker(0, { |
990 func : function(co) { |
1017 func : function(co) { |
991 t.editor.execCommand('HiliteColor', false, co); |
1018 t.editor.execCommand('HiliteColor', false, co); |
992 } |
1019 } |
993 }); |
1020 }); |
|
1021 }, |
|
1022 |
|
1023 _ufirst : function(s) { |
|
1024 return s.substring(0, 1).toUpperCase() + s.substring(1); |
994 } |
1025 } |
995 }); |
1026 }); |
996 |
1027 |
997 tinymce.ThemeManager.add('advanced', tinymce.themes.AdvancedTheme); |
1028 tinymce.ThemeManager.add('advanced', tinymce.themes.AdvancedTheme); |
998 }()); |
1029 }()); |