Permalink
Browse files

trying to optimize picture preview for mobile

  • Loading branch information...
sukhada committed Mar 15, 2013
1 parent d0229fd commit 22fbf754e665d81edee15d5975a49464bffc4f9b
Showing with 12 additions and 9 deletions.
  1. +12 −9 reddit.js
View
@@ -282,24 +282,27 @@ $("#clear").click(function() {
if ($(window).width() < 704) {
$(document).ready(function() {
var link = $(this).attr('href');
- if (link != undefined) {
- if (($(this).attr('href').indexOf("i.imgur") != -1) ||
- ($(this).attr('href').indexOf("jpg") != -1) ||
- ($(this).attr('href').indexOf("png") != -1) ||
- ($(this).attr('href').indexOf("gif") != -1)) {
- $('a').bind('touchstart touchend', function(e) {
- alert(this);
+ if (link != undefined) {
+ console.log('defined!');
+ $(document).on('touchstart touchend', 'a', function(e) {
+ if (($(this).attr('href').indexOf("i.imgur") != -1) ||
+ ($(this).attr('href').indexOf("jpg") != -1) ||
+ ($(this).attr('href').indexOf("png") != -1) ||
+ ($(this).attr('href').indexOf("gif") != -1)) {
+ console.log(this);
e.preventDefault();
$("#img").css("top", e.pageY - 10);
$("#img").css("left", 0);
console.log($("#img").css("left"));
$(this).css("color", "#05B8CC");
$("#img").append("<img class='image' src='"+ link +"'></img>");
- });
- }
+ }
+ });
}
+ localStorage.setItem("posts", $("#posts").html());
});
}
+
else {
$(document).on("mouseenter", "a", function(e) {
var link = $(this).attr('href');

0 comments on commit 22fbf75

Please sign in to comment.