Permalink
Browse files

[colorwidget] Do not set element colour if it has not changed

  • Loading branch information...
gabrielschulhof committed Apr 10, 2012
1 parent 157b82d commit 1a55ddcc6bd647356974d619ea81b451f10e99d8
Showing with 10 additions and 8 deletions.
  1. +10 −8 src/widgets/010_colorwidget/js/colorwidget.js
@@ -43,17 +43,19 @@ $.widget("todons.colorwidget", $.todons.widgetex, {
},
_setElementColor: function(el, hsl, cssProp) {
- var clrlib = $.todons.colorwidget.clrlib,
+ var old = el.jqmData("hsl") || [-1, -1, -1];
+ if (!(old[0] === hsl[0] && old[1] === hsl[1] && old[2] === hsl[2])) {
+ var clrlib = $.todons.colorwidget.clrlib,
clr = clrlib.RGBToHTML(clrlib.HSLToRGB(hsl)),
dclr = clrlib.RGBToHTML(clrlib.HSLToGray(hsl));
- el.jqmData("clr", clr);
- el.jqmData("dclr", dclr);
- el.jqmData("cssProp", cssProp);
- el.attr("data-" + ($.mobile.ns || "") + "has-dclr", true);
- el.css(cssProp, this.options.disabled ? dclr : clr);
-
- return { clr: clr, dclr: dclr };
+ el.jqmData("hsl", hsl);
+ el.jqmData("clr", clr);
+ el.jqmData("dclr", dclr);
+ el.jqmData("cssProp", cssProp);
+ el.attr("data-" + ($.mobile.ns || "") + "has-dclr", true);
+ el.css(cssProp, this.options.disabled ? dclr : clr);
+ }
},
_displayDisabledState: function(toplevel) {

0 comments on commit 1a55ddc

Please sign in to comment.