Skip to content

Commit

Permalink
ajax loader
Browse files Browse the repository at this point in the history
  • Loading branch information
halida committed Oct 21, 2011
1 parent e0a0d1a commit d0df4ce
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 6 deletions.
4 changes: 2 additions & 2 deletions main.rb
Expand Up @@ -44,8 +44,8 @@ def partial(page, options={})
end

get '/' do
starts = params[:starts] || 10000000
@articles = Article.first(5, :id.lt => starts, :order => :created.desc)
from = params[:from] || 10000000
@articles = Article.first(5, :id.lt => from, :order => :created.desc)
myhaml :index
end

Expand Down
Binary file added public/ajax-loader.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion views/_footer.haml
@@ -1,2 +1,2 @@
%footer
%p @2010 linjunhalida, all right reserved
%p @2011 linjunhalida, all right reserved
1 change: 1 addition & 0 deletions views/article.haml
@@ -1,4 +1,5 @@
#article
%h1= @article.title
=@article.get_content

= partial :_stamp, :locals => {:article => @article}
Expand Down
13 changes: 11 additions & 2 deletions views/index.haml
Expand Up @@ -8,5 +8,14 @@

= partial :_stamp, :locals => {:article => article}

#paginate
<a href="?starts=#{@articles[-1].id}" class="js-pjax btn primary">更多</a>
- if @articles.length > 0
#more
<img src="/ajax-loader.gif" id="more-display" />

:javascript
var more = function(){
$.get(window.location + (/\?/.test(window.location) ? "&" : "?") + "from=#{@articles[-1].id}&_pjax=true", function(data){
$('#more').replaceWith(data);
});
};
$('#more').appear(more);
3 changes: 2 additions & 1 deletion views/main.sass
Expand Up @@ -94,9 +94,10 @@ body
float: left
width: $grid * 8

#more
text-align: center

+sticky-footer(72px, "#layout", "#layout_footer", "footer")

footer
width: $content-width
margin: 20px auto
Expand Down

0 comments on commit d0df4ce

Please sign in to comment.