Skip to content
This repository has been archived by the owner on Jul 24, 2019. It is now read-only.

Fix hotkey support, add event namespaces, add hotkey enable callback #77

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
alan fixed a command cache bug
  • Loading branch information
jeffszusz committed Nov 29, 2013
commit 29e4ed90635dab379587058943132d9b1cb88c1e
19 changes: 12 additions & 7 deletions bootstrap-wysiwyg.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
}

},
updateToolbar = function (e) {
updateToolbar = function () {
if (options.activeToolbarClass) {
$(options.toolbarSelector).find(toolbarBtnSelector).each(function () {
var command = $(this).data(options.commandRole);
Expand All @@ -80,10 +80,9 @@
} else {
commandNoArgs = command;
}

if (commandNoArgs === "fontSize" && options.setRealFontSize != null) {
options.setRealFontSize(selectedRange, e);
} else if (document.queryCommandState(command)) {
if (commandNoArgs === "fontSize" && options.setRealFontSize != null) {
options.setRealFontSize(selectedRange);
} else if (document.queryCommandState(command)) {
$(this).addClass(options.activeToolbarClass);
} else if (commandNoArgs + ' ' + document.queryCommandValue(commandNoArgs) === command) {
$(this).addClass(options.activeToolbarClass);
Expand Down Expand Up @@ -156,6 +155,12 @@

var eventNamespace = options.eventNamespace + '-' + 'bindKeys';

editor.on(namespaceEvents('focus'), function(e) {
setTimeout(function() {
restoreCommandCache();
}, 0);
});

editor.on(namespaceEvents('keydown'), hotKeys, function (e) {
var command = '';

Expand Down Expand Up @@ -295,10 +300,10 @@
}
bindToolbar($(options.toolbarSelector), options);
editor.attr('contenteditable', true)
.on(namespaceEvents('mouseup keyup mouseout'), function (e) {
.on(namespaceEvents('mouseup keyup mouseout'), function () {
setTimeout(function() {
saveSelection();
updateToolbar(e);
updateToolbar();
}, 0);
});

Expand Down