Skip to content

Commit

Permalink
Merge pull request #89 from solomax/patch-2
Browse files Browse the repository at this point in the history
Update bootstrap-wysiwyg.js
  • Loading branch information
sebfz1 committed Feb 21, 2014
2 parents 3f26dd8 + e84bcbd commit fb25fe7
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,16 @@
updateToolbar = function () {
if (options.activeToolbarClass) {
$(options.toolbarSelector).find(toolbarBtnSelector).each(function () {
var command = $(this).data(options.commandRole);
if (document.queryCommandState(command)) {
var commandArr = $(this).data(options.commandRole).split(' '),
command = commandArr[0];

// If the command has an argument and its value matches this button. == used for string/number comparison
if (commandArr.length > 1 && document.queryCommandEnabled(command) && document.queryCommandValue(command) == commandArr[1]) {
$(this).addClass(options.activeToolbarClass);
// Else if the command has no arguments and it is active
} else if (commandArr.length === 1 && document.queryCommandEnabled(command) && document.queryCommandState(command)) {
$(this).addClass(options.activeToolbarClass);
// Else the command is not active
} else {
$(this).removeClass(options.activeToolbarClass);
}
Expand Down

0 comments on commit fb25fe7

Please sign in to comment.