Permalink
Browse files

patched multiple css property bug for toolbar active states

  • Loading branch information...
1 parent 83872fe commit 0b95e1f7ffdca6eaf5ec49875f5fdbac39bfb088 @biegel biegel committed Dec 13, 2012
Showing with 25 additions and 12 deletions.
  1. +25 −12 jquery.wysiwyg.js
View
@@ -859,18 +859,31 @@ html: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.o
elm,
css,
el,
- checkActiveStatus = function (cssProperty, cssValue) {
- var handler;
-
- if ("function" === typeof (cssValue)) {
- handler = cssValue;
- if (handler(el.css(cssProperty).toString().toLowerCase(), self)) {
- self.ui.toolbar.find("." + className).addClass("active");
- }
- } else {
- if (el.css(cssProperty).toString().toLowerCase() === cssValue) {
- self.ui.toolbar.find("." + className).addClass("active");
+ // need to check multiple properties for the toolbar
+ // if we check one-by-one, a single property match
+ // on toolbar elements that have multiple css properties
+ // will trigger the button as "active"
+ checkActiveStatus = function (cssObject) {
+ // set a count flag for how many matches we've encountered
+ var matches = 0;
+
+ // set an iterator to count the number of properties
+ var total = 0;
+
+ $.each(cssObject, function(cssProperty, cssValue) {
+ if ( "function" === typeof cssValue ) {
+ if ( cssValue.apply(self, [el.css(cssProperty).toString().toLowerCase(), self]) ) {
+ matches += 1;
+ }
+ } else {
+ if ( el.css(cssProperty).toString().toLowerCase() === cssValue ) {
+ matches += 1;
+ }
}
+ total += 1;
+ });
+ if ( total === matches ) {
+ self.ui.toolbar.find("." + className).addClass("active");
}
};
@@ -905,7 +918,7 @@ html: '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.o
if (el[0].nodeType !== 1) {
break;
}
- $.each(css, checkActiveStatus);
+ checkActiveStatus(css);
el = el.parent();
}

0 comments on commit 0b95e1f

Please sign in to comment.