Skip to content

Commit

Permalink
Add class to active toolbar action link
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Blum committed May 1, 2012
1 parent 0fe58a7 commit bcfc23a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/toolbar/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit bcfc23a

Please sign in to comment.