Permalink
Browse files

Patch for jQ 1.4.2!

jQuery 1.4.2's .data() returns null instead of undefined. Issue #2.

Also updated jQuery version used for demo because... c'mon... 1.3?
  • Loading branch information...
1 parent a2cebc6 commit 86cd1578c2c39d3d2cdafed21d87915da30e910d @redoPop redoPop committed Dec 15, 2010
Showing with 14 additions and 14 deletions.
  1. +3 −3 demo/index.html
  2. +10 −10 jquery.loupe.js
  3. +1 −1 jquery.loupe.min.js
View
@@ -23,8 +23,8 @@
<img class="demo" src="http://farm3.static.flickr.com/2479/3549662506_4374920e94.jpg" width="191" height="240" />
</div>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="../jquery.loupe.js"></script>
- <script type="text/javascript">$('.demo').loupe()</script>
+ <script type="text/javascript">$('.demo').loupe();</script>
</body>
-</html>
+</html>
View
@@ -9,33 +9,33 @@
loupe: 'loupe',
width: 200,
height: 150
- }, arg || {}), undefined;
-
+ }, arg || {});
+
return this.length ? this.each(function () {
var $this = $(this), $big, $loupe,
$small = $this.is('img') ? $this : $this.find('img:first'),
move, hide = function () { $loupe.hide(); },
time;
-
- if ($this.data('loupe') !== undefined) {
+
+ if ($this.data('loupe') != null) {
return $this.data('loupe', arg);
}
-
+
move = function (e) {
var os = $small.offset(),
sW = $small.outerWidth(),
sH = $small.outerHeight(),
oW = options.width / 2,
oH = options.height / 2;
-
+
if (!$this.data('loupe') ||
e.pageX > sW + os.left + 10 || e.pageX < os.left - 10 ||
e.pageY > sH + os.top + 10 || e.pageY < os.top - 10) {
return hide();
}
-
+
time = time ? clearTimeout(time) : 0;
-
+
$loupe.show().css({
left: e.pageX - oW,
top: e.pageY - oH
@@ -45,7 +45,7 @@
top: -(((e.pageY - os.top) / sH) * $big.height() - oH)|0
});
};
-
+
$loupe = $('<div />')
.addClass(options.loupe)
.css({
@@ -58,7 +58,7 @@
.mousemove(move)
.hide()
.appendTo('body');
-
+
$this.data('loupe', true)
.mouseenter(move)
.mouseout(function () {
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

0 comments on commit 86cd157

Please sign in to comment.