Skip to content

Commit

Permalink
Command link groups
Browse files Browse the repository at this point in the history
  • Loading branch information
Christopher Blum committed May 18, 2012
1 parent 253967b commit 94ea921
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/toolbar/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,20 @@
i = 0,
mapping = this[type + "Mapping"] = {},
link,
group,
name,
value,
dialog;
for (; i<length; i++) {
link = links[i];
name = link.getAttribute("data-wysihtml5-" + type);
value = link.getAttribute("data-wysihtml5-" + type + "-value");
group = this.container.querySelector("[data-wysihtml5-" + type + "-group='" + name + "']");
dialog = this._getDialog(link, name);

mapping[name + ":" + value] = {
link: link,
group: group,
name: name,
value: value,
dialog: dialog,
Expand Down Expand Up @@ -217,6 +220,9 @@
if (this.commandsDisabled) {
state = false;
dom.removeClass(command.link, CLASS_NAME_COMMAND_ACTIVE);
if (command.group) {
dom.removeClass(command.group, CLASS_NAME_COMMAND_ACTIVE);
}
if (command.dialog) {
command.dialog.hide();
}
Expand All @@ -230,6 +236,9 @@
state = state.length === 1 ? state[0] : true;
}
dom.removeClass(command.link, CLASS_NAME_COMMAND_DISABLED);
if (command.group) {
dom.removeClass(command.group, CLASS_NAME_COMMAND_DISABLED);
}
}

if (command.state === state) {
Expand All @@ -239,6 +248,9 @@
command.state = state;
if (state) {
dom.addClass(command.link, CLASS_NAME_COMMAND_ACTIVE);
if (command.group) {
dom.addClass(command.group, CLASS_NAME_COMMAND_ACTIVE);
}
if (command.dialog) {
if (typeof(state) === "object") {
command.dialog.show(state);
Expand All @@ -248,6 +260,9 @@
}
} else {
dom.removeClass(command.link, CLASS_NAME_COMMAND_ACTIVE);
if (command.group) {
dom.removeClass(command.group, CLASS_NAME_COMMAND_ACTIVE);
}
if (command.dialog) {
command.dialog.hide();
}
Expand Down

0 comments on commit 94ea921

Please sign in to comment.