From bcfc23ac7b25111e37c579e3f351f768ed295249 Mon Sep 17 00:00:00 2001 From: Christopher Blum Date: Tue, 1 May 2012 17:58:09 +0200 Subject: [PATCH] Add class to active toolbar action link --- src/toolbar/toolbar.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/toolbar/toolbar.js b/src/toolbar/toolbar.js index a7ae9246..47702606 100644 --- a/src/toolbar/toolbar.js +++ b/src/toolbar/toolbar.js @@ -18,6 +18,7 @@ var CLASS_NAME_COMMAND_DISABLED = "wysihtml5-command-disabled", CLASS_NAME_COMMANDS_DISABLED = "wysihtml5-commands-disabled", CLASS_NAME_COMMAND_ACTIVE = "wysihtml5-command-active", + CLASS_NAME_ACTION_ACTIVE = "wysihtml5-action-active", dom = wysihtml5.dom; wysihtml5.toolbar.Toolbar = Base.extend( @@ -205,8 +206,10 @@ _updateLinkStates: function() { var element = this.composer.element, commandMapping = this.commandMapping, + actionMapping = this.actionMapping, i, state, + action, command; // every millisecond counts... this is executed quite often for (i in commandMapping) { @@ -250,6 +253,19 @@ } } } + + for (i in actionMapping) { + action = actionMapping[i]; + + if (action.name === "change_view") { + action.state = this.editor.currentView === editor.textarea; + if (action.state) { + dom.addClass(action.link, CLASS_NAME_ACTION_ACTIVE); + } else { + dom.removeClass(action.link, CLASS_NAME_ACTION_ACTIVE); + } + } + } }, show: function() {