Improved scroll to in ticket zoom if article_id is given.

This commit is contained in:
Martin Edenhofer 2012-07-10 14:06:58 +02:00
parent 5cd1012d88
commit 7d2bcd7b88
3 changed files with 12 additions and 2 deletions

View file

@ -14,7 +14,8 @@ class App.Controller extends Spine.Controller
scrollTo: ( x = 0, y = 0 ) ->
a = ->
window.scrollTo( 0,0 )
console.log('scollTo', x, y )
window.scrollTo( x, y )
@delay( a, 0 )

View file

@ -24,6 +24,7 @@ class Index extends App.Controller
@edit_form = undefined
# @render()
@ticket_id = params.ticket_id
@article_id = params.article_id
@fetch(@ticket_id)
fetch: (ticket_id) ->
@ -196,6 +197,14 @@ class Index extends App.Controller
ticket: @ticket,
)
# scrall to article if given
if @article_id
offset = document.getElementById( 'article-' + @article_id ).offsetTop
offset = offset - 45
scrollTo = ->
@scrollTo( 0, offset )
@delay( scrollTo, 100 )
@delay(@u, 200)
u: =>

View file

@ -18,7 +18,7 @@
<div class="span9">
<% for article in @articles: %>
<div class="row article" data-id="<%= article.id %>">
<div class="row article" data-id="<%= article.id %>" id="article-<%= article.id %>">
<div class="avatar span1 thumbnails">
<img class="thumbnail user-data" data-id="<%= article.created_by_id %>" src="<%= article.created_by.image %>" alt="">
<ul>