Skip to content

Commit

Permalink
Replaced all bindWithEvent calls with an inline function that binds this
Browse files Browse the repository at this point in the history
and then calls methods manually with event object as parameter
  • Loading branch information
tatai committed Oct 14, 2011
1 parent 24d6f16 commit 36b5496
Showing 1 changed file with 31 additions and 23 deletions.
54 changes: 31 additions & 23 deletions Source/mooRainbow.js
@@ -1,19 +1,19 @@
/*
---
script: mooRainbow.js
version: 1.3
description: MooRainbow is a ColorPicker for MooTools 1.3
license: MIT-Style
authors:
- Djamil Legato (w00fz)
- Christopher Beloch
requires: [Core/*, More/Slider, More/Drag, More/Color]
provides: [mooRainbow]
...
/*
---
script: mooRainbow.js
version: 1.3
description: MooRainbow is a ColorPicker for MooTools 1.3
license: MIT-Style
authors:
- Djamil Legato (w00fz)
- Christopher Beloch
requires: [Core/*, More/Slider, More/Drag, More/Color]
provides: [mooRainbow]
...
*/

var MooRainbow = new Class({
Expand Down Expand Up @@ -270,15 +270,23 @@ var MooRainbow = new Class({

arrColors.each(function(el) {
el.addEvents({
'mousewheel': this.eventKeys.bindWithEvent(this, el),
'keydown': this.eventKeys.bindWithEvent(this, el)
'mousewheel': function(e) {
this.eventKeys(e, el);
}.bind(this),
'keydown': function(e) {
this.eventKeys(e, el);
}.bind(this),
});
}, this);

[this.layout.arrows, this.layout.slider].each(function(el) {
el.addEvents({
'mousewheel': this.eventKeys.bindWithEvent(this, [this.arrHSB[0], 'slider']),
'keydown': this.eventKeys.bindWithEvent(this, [this.arrHSB[0], 'slider'])
'mousewheel': function(e) {
this.eventKeys(e, this.arrHSB[0], 'slider');
}.bind(this),
'keydown': function(e) {
this.eventKeys(e, this.arrHSB[0], 'slider');
}.bind(this)
});
}, this);
},
Expand Down Expand Up @@ -502,7 +510,7 @@ var MooRainbow = new Class({
var overlays = $$('#' + idPrefix + 'overlay');
this.layout.overlay = overlays[0];
this.layout.overlay2 = overlays[1];
this.layout.cursor = Slick.find(document, '#' + idPrefix + 'cursor');
this.layout.cursor = Slick.find(document, '#' + idPrefix + 'cursor');
this.layout.arrows = Slick.find(document, '#' + idPrefix + 'arrows');
this.chooseColor = Slick.find(document, '#' + idPrefix + 'chooseColor');
this.layout.backup = Slick.find(document, '#' + idPrefix + 'currentColor');
Expand All @@ -517,8 +525,8 @@ var MooRainbow = new Class({
this.arrRGB = [this.RedInput, this.GreenInput, this.BlueInput];
this.arrHSB = [this.HueInput, this.SatuInput, this.BrighInput];
this.okButton = Slick.find(document, '#' + idPrefix + 'okButton');

this.layout.cursor.setStyle('background-image', 'url(' + this.options.imgPath + 'moor_cursor.gif)');

this.layout.cursor.setStyle('background-image', 'url(' + this.options.imgPath + 'moor_cursor.gif)');

if (!window.khtml) this.hide();
},
Expand Down

0 comments on commit 36b5496

Please sign in to comment.