Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Correct context for events on F instance. Add some tests for this. Fi…

…x tests for image css position.
  • Loading branch information...
commit fd6267064bbbf959b6073d372d4765275e08216d 1 parent e0698d4
Alex Michael authored
View
9 filtrr2/src/filtrr2.js
@@ -53,7 +53,7 @@ var F = function(el, callback, timestamp)
canv = c[0];
this.canvas = c;
-
+
canv.width = img.width;
canv.height = img.height;
canv.getContext("2d").drawImage(img, 0, 0);
@@ -86,9 +86,14 @@ var F = function(el, callback, timestamp)
// Reference to the image processor.
this.processor = null;
+ // Reference to the canvas element.
+ this.canvas = null;
+
// Events
events = new Filtrr2.Events();
- this.on = events.on;
+ this.on = $.proxy(function(ev, callback) {
+ events.on(ev, callback, this);
+ }, this);
this.off = events.off;
this.trigger = events.trigger;
View
1  filtrr2/test/all.html
@@ -37,5 +37,6 @@ <h2 id="qunit-userAgent"></h2>
<img style="visibility:hidden" id="test-img211231" src="pic.jpg" />
<img style="visibility:hidden" id="test-img2112312" src="pic.jpg" />
<img style="visibility:hidden" id="test-img21123123" src="pic.jpg" />
+ <img style="visibility:hidden" id="events-img" src="pic.jpg" />
</body>
</html>
View
12 filtrr2/test/events-test.js
@@ -60,7 +60,6 @@ $(document).ready(function(){
b: 2
};
events.on("ev1", function(ev) {
- console.log(this);
equal(this.a, 1);
}, ctxa);
events.on("ev2", function(ev) {
@@ -125,4 +124,15 @@ $(document).ready(function(){
equal(ev2c, 5);
});
+ test("Filtrr2 events context is F instance.", function() {
+ var my = Filtrr2("#events-img");
+ my.on("hello", function() {
+ ok(typeof this == 'object');
+ ok(this.constructor.toString().indexOf("F") > -1);
+ ok(this.el);
+ ok(this.ready);
+ });
+ my.trigger("hello");
+ });
+
});
View
1  filtrr2/test/events.html
@@ -19,5 +19,6 @@ <h2 id="qunit-banner"></h2>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
+ <img style="visibility:hidden" id="events-img" src="pic.jpg" />
</body>
</html>
View
4 filtrr2/test/filtrr2-test.js
@@ -113,9 +113,7 @@ $(document).ready(function(){
ok(f.processor);
equal(c.height(), e.height());
equal(c.width(), e.width());
- if (e[0].nodeName.toLowerCase() === "img") {
- equal(c.css("position"), "absolute");
- }
+ equal(c.css("position"), e.css("position"));
}
asyncTest("Image id.", function() {

0 comments on commit fd62670

Please sign in to comment.
Something went wrong with that request. Please try again.