Skip to content

Commit

Permalink
fixed $ reference bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanlowdermilk committed Mar 13, 2012
1 parent b59bed5 commit 28e533f
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions example.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<head>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.17/jquery-ui.min.js"></script>
<script type="text/javascript" src="http://cdn.ryanlowdermilk.com/metro-tile.js"></script>
<link rel="stylesheet" type="text/css" href="http://cdn.ryanlowdermilk.com/metro-tile.css">
<script type="text/javascript" src="./metro-tile.js"></script>
<link rel="stylesheet" type="text/css" href="./metro-tile.css">
</head>
<body>
<h1>metro-tile - <i>A simple javascript UI library which creates Windows 8 Metro Tiles using CSS3</i></h1>
Expand Down
2 changes: 1 addition & 1 deletion metro-tile-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 19 additions & 19 deletions metro-tile.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
$(function () {
$(".metro-tile").bind('mousedown', function (e) {
jQuery(function () {
jQuery(".metro-tile").bind('mousedown', function (e) {
var touchLeft = 33;
var touchTop = 16;
var touchBottom = 72;
var touchRight = 66;
var x = e.pageX - this.offsetLeft - $(this).parent().offset().left;
var y = e.pageY - this.offsetTop - $(this).parent().offset().top;
var width = $(this).width();
var height = $(this).height();
var x = e.pageX - this.offsetLeft - jQuery(this).parent().offset().left;
var y = e.pageY - this.offsetTop - jQuery(this).parent().offset().top;
var width = jQuery(this).width();
var height = jQuery(this).height();
var wp = parseInt(x/width*100);
var hp = parseInt(y/height*100);
var left = (wp <= touchLeft && hp >= touchTop && hp < touchBottom);
var right = (wp >= touchRight && hp > touchTop && hp < touchBottom);
var top = (hp > 0 && hp <= touchTop);
var bottom = (hp > touchBottom);
var middle = (hp > touchTop && hp < touchBottom && wp > touchLeft && wp < touchRight);
if (right) $(this).addClass("tile_right");
else if (left) $(this).addClass("tile_left");
else if (bottom) $(this).addClass("tile_bottom");
else if (top) $(this).addClass("tile_top");
else if (middle) $(this).addClass("tile_middle");
if (right) jQuery(this).addClass("tile_right");
else if (left) jQuery(this).addClass("tile_left");
else if (bottom) jQuery(this).addClass("tile_bottom");
else if (top) jQuery(this).addClass("tile_top");
else if (middle) jQuery(this).addClass("tile_middle");
return false;
});
});

$(function () {
$(".metro-surface").mouseup(function (x) {
$(".metro-tile").removeClass("tile_left");
$(".metro-tile").removeClass("tile_right");
$(".metro-tile").removeClass("tile_bottom");
$(".metro-tile").removeClass("tile_top");
$(".metro-tile").removeClass("tile_middle");
$(".metro-tile").addClass("tile_reset");
jQuery(function () {
jQuery(".metro-surface").mouseup(function (x) {
jQuery(".metro-tile").removeClass("tile_left");
jQuery(".metro-tile").removeClass("tile_right");
jQuery(".metro-tile").removeClass("tile_bottom");
jQuery(".metro-tile").removeClass("tile_top");
jQuery(".metro-tile").removeClass("tile_middle");
jQuery(".metro-tile").addClass("tile_reset");
return false;
});
});

0 comments on commit 28e533f

Please sign in to comment.