Permalink
Browse files

trying to optimize picture preview for mobile

  • Loading branch information...
1 parent 3b105ea commit 385fc1bf1fb9be2d297042f2f25b7ed06b053053 @sukhada committed Mar 15, 2013
Showing with 30 additions and 12 deletions.
  1. +1 −2 home.html
  2. +29 −10 reddit.js
View
@@ -16,8 +16,7 @@
</nav>
<div class="modal hide">
- <label>Add Subreddit:</label>
- <input type="text" id="subreddit"></input>
+ <input type="text" id="subreddit" placeholder="Add Subreddit"></input>
<div id="listofsubreddits">
</div>
<button id="clear">Clear</button>
View
@@ -1,4 +1,4 @@
-var t;
+var r,t;
var count;
var counts = [];
var result1 = [];
@@ -20,25 +20,26 @@ setTimeout(function() {localStorage.clear();}, 1800000);
function addNewSubreddit() {
var temp = $("#subreddit").val();
- $("#submit").css("display", "block");
- $("#clear").css("display", "block");
+ $("#submit").css("display", "inline");
+ $("#clear").css("display", "inline");
array.push(temp);
counts.push(0);
- $("#listofsubreddits").append("<li>" + temp+ '<input type="text" class="new"></input>'+"</li>");
+ var placeholder = 100/(array.length);
+ $("#listofsubreddits").append("<li>" + temp+ '<input type="text" class="new" placeholder="'+ placeholder + '%"></input>'+"</li>");
$("#subreddit").val("");
localStorage.setItem('subreddits', array);
- localStorage.setItem('counts', counts);
- localStorage.removeItem('posts');
+ localStorage.setItem('counts', counts);
+ localStorage.removeItem('posts');
}
function loadSubreddit() {
console.log('loadSubreddit');
$("#listofsubreddits").empty();
console.log(array,weights,counts);
if (array.length > 0) {
- $("#submit").css("display", "block");
- $("#clear").css("display", "block");
+ $("#submit").css("display", "inline");
+ $("#clear").css("display", "inline");
}
for (var j = 0; j < array.length; j++) {
var temp = array[j];
@@ -59,6 +60,8 @@ function loadSubreddit() {
function loadModal() {
console.log('loadSubreddit');
$("#listofsubreddits").empty();
+ $("#submit").css("display", "inline");
+ $("#clear").css("display", "inline");
console.log(array,weights,counts);
for (var j = 0; j < array.length; j++) {
var temp = array[j];
@@ -245,8 +248,22 @@ window.onload = function() {
}
}
-$("#open").click(function() {
- $(".modal").toggleClass("hide");
+$("#open").on('mouseenter', function() {
+ clearTimeout(r);
+ $(".modal").removeClass("hide");
+});
+
+$(".modal").on('mouseleave', function() {
+ r = setTimeout(function() {$(".modal").addClass("hide");},500);
+});
+
+$(".modal").on('mouseenter', function() {
+ clearTimeout(r);
+ $(".modal").removeClass("hide");
+});
+
+$("#open").on('mouseleave', function() {
+ r=setTimeout(function() {$(".modal").addClass("hide");},500);
});
$(".close").click(function() {
@@ -336,6 +353,8 @@ $("#loadmore").click(function () {
loadPosts();
});
+
+
$("#listofsubreddits").on('click', ".remove", function () {
var temp = ($(this).siblings('a').text().substring(0,$(this).siblings('a').text().length-1)).replace(/[0-9]/g, '').replace(/\./g, "");
var index = array.indexOf(temp);

0 comments on commit 385fc1b

Please sign in to comment.