improve design patterns example
This commit is contained in:
parent
0b2a94778f
commit
fe548c60f4
1 changed files with 15 additions and 24 deletions
|
@ -173,6 +173,7 @@ Ox.load(['Image', 'UI'], function() {
|
||||||
|
|
||||||
that.invert = function() {
|
that.invert = function() {
|
||||||
that.options({inverted: !self.options.inverted});
|
that.options({inverted: !self.options.inverted});
|
||||||
|
return that;
|
||||||
};
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
@ -187,9 +188,13 @@ Ox.load(['Image', 'UI'], function() {
|
||||||
color: [[[128, 128, 128]]]
|
color: [[[128, 128, 128]]]
|
||||||
}))
|
}))
|
||||||
.options(options || {})
|
.options(options || {})
|
||||||
.update({color: setColor});
|
.update({color: setColor})
|
||||||
|
.bindEvent({
|
||||||
|
doubleclick: function() {
|
||||||
|
that.invert();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
self.inverting = false;
|
|
||||||
self.sizes = [
|
self.sizes = [
|
||||||
Ox.splitInt(self.options.size[0], self.options.color[0].length),
|
Ox.splitInt(self.options.size[0], self.options.color[0].length),
|
||||||
Ox.splitInt(self.options.size[1], self.options.color.length)
|
Ox.splitInt(self.options.size[1], self.options.color.length)
|
||||||
|
@ -201,11 +206,7 @@ Ox.load(['Image', 'UI'], function() {
|
||||||
color: color,
|
color: color,
|
||||||
size: [self.sizes[0][x], self.sizes[1][y]]
|
size: [self.sizes[0][x], self.sizes[1][y]]
|
||||||
})
|
})
|
||||||
.update({
|
.unbindEvent('doubleclick')
|
||||||
inverted: function() {
|
|
||||||
return that.invert(x, y);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.appendTo(that);
|
.appendTo(that);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -222,18 +223,12 @@ Ox.load(['Image', 'UI'], function() {
|
||||||
$box.invert();
|
$box.invert();
|
||||||
};
|
};
|
||||||
|
|
||||||
that.invert = function(x, y) {
|
that.invert = function() {
|
||||||
if (!self.inverting) {
|
self.$boxes.forEach(function(array) {
|
||||||
self.inverting = true;
|
array.forEach(self.invertBox);
|
||||||
arguments.length && self.$boxes[y][x].invert();
|
});
|
||||||
self.$boxes.forEach(function(array) {
|
that.triggerEvent('invert');
|
||||||
array.forEach(self.invertBox);
|
return that;
|
||||||
});
|
|
||||||
self.inverting = false;
|
|
||||||
that.triggerEvent('invert')
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return that; // fixme
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return that;
|
return that;
|
||||||
|
@ -299,11 +294,7 @@ Ox.load(['Image', 'UI'], function() {
|
||||||
color: image.pixel(x, y).slice(0, 3),
|
color: image.pixel(x, y).slice(0, 3),
|
||||||
size: [self.sizes[0][x], self.sizes[1][y]]
|
size: [self.sizes[0][x], self.sizes[1][y]]
|
||||||
})
|
})
|
||||||
.bindEvent({
|
.unbindEvent('doubleclick')
|
||||||
invert: function() {
|
|
||||||
return that.invert(x, y);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.appendTo(that);
|
.appendTo(that);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue