From 2011bef155aacdfa8461a4d5c2cd3988d946d135 Mon Sep 17 00:00:00 2001
From: alecpl <alec@alec.pl>
Date: Thu, 24 Jun 2010 09:22:08 -0400
Subject: [PATCH] - TinyMCE 3.3.7

---
 program/js/tiny_mce/themes/advanced/editor_template_src.js |   49 ++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 38 insertions(+), 11 deletions(-)

diff --git a/program/js/tiny_mce/themes/advanced/editor_template_src.js b/program/js/tiny_mce/themes/advanced/editor_template_src.js
index b7dc85b..279ca35 100644
--- a/program/js/tiny_mce/themes/advanced/editor_template_src.js
+++ b/program/js/tiny_mce/themes/advanced/editor_template_src.js
@@ -203,7 +203,7 @@
 
 					ed.formatter.register(name, {
 						inline : 'span',
-						classes : o['class'],
+						attributes : {'class' : o['class']},
 						selector : '*'
 					});
 
@@ -219,7 +219,24 @@
 			ctrl = ctrlMan.createListBox('styleselect', {
 				title : 'advanced.style_select',
 				onselect : function(name) {
-					ed.execCommand('mceToggleFormat', false, name);
+					var matches, formatNames = [];
+
+					each(ctrl.items, function(item) {
+						formatNames.push(item.value);
+					});
+
+					ed.focus();
+					ed.undoManager.add();
+
+					// Toggle off the current format
+					matches = ed.formatter.matchAll(formatNames);
+					if (matches[0] == name)
+						ed.formatter.remove(name);
+					else
+						ed.formatter.apply(name);
+
+					ed.undoManager.add();
+					ed.nodeChanged();
 
 					return false; // No auto select
 				}
@@ -251,7 +268,8 @@
 
 							ed.formatter.register(name, {
 								inline : 'span',
-								classes : val
+								classes : val,
+								selector : '*'
 							});
 
 							ctrl.add(t.editor.translate(key), name);
@@ -283,6 +301,12 @@
 				title : 'advanced.fontdefault',
 				onselect : function(v) {
 					ed.execCommand('FontName', false, v);
+
+					// Fake selection, execCommand will fire a nodeChange and update the selection
+					c.select(function(sv) {
+						return v == sv;
+					});
+
 					return false; // No auto select
 				}
 			});
@@ -300,16 +324,19 @@
 			var t = this, ed = t.editor, c, i = 0, cl = [];
 
 			c = ed.controlManager.createListBox('fontsizeselect', {title : 'advanced.font_size', onselect : function(v) {
-				if (v.fontSize)
+				if (v['class']) {
+					ed.focus();
+					ed.undoManager.add();
+					ed.formatter.toggle('fontsize_class', {value : v['class']});
+					ed.undoManager.add();
+					ed.nodeChanged();
+				} else
 					ed.execCommand('FontSize', false, v.fontSize);
-				else {
-					each(t.settings.theme_advanced_font_sizes, function(v, k) {
-						if (v['class'])
-							cl.push(v['class']);
-					});
 
-					ed.editorCommands._applyInlineStyle('span', {'class' : v['class']}, {check_classes : cl});
-				}
+				// Fake selection, execCommand will fire a nodeChange and update the selection
+				c.select(function(sv) {
+					return v == sv;
+				});
 
 				return false; // No auto select
 			}});

--
Gitblit v1.9.1