Skip to content

Commit

Permalink
Touch optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
martent committed May 29, 2014
1 parent 13c29a8 commit a48791e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
2 changes: 0 additions & 2 deletions app/assets/javascripts/recommendations.js.coffee

This file was deleted.

18 changes: 18 additions & 0 deletions app/assets/javascripts/search.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
$ ->
# Scroll to set search field on top on touch devices
$("body.touch #q").focus ->
y = $("#q").offset().top - 6
times = 0
i = setInterval ->
window.scrollTo(0, y)
if times++ > 100
clearInterval(i)
, 1
$("#malmo-masthead").css("position", "absolute")

$("body.touch #q").blur ->
$("#malmo-masthead").css("position", "fixed")

# Focus empty search field on non touch devices
$("body:not(.touch) #q").focus() unless !$("#q").length or $("#q").val().length

0 comments on commit a48791e

Please sign in to comment.