Skip to content

Commit

Permalink
Update 0.05 Pagination
Browse files Browse the repository at this point in the history
Added Ajax Pagination to board screens.

Issue 13
Editing an item no longer moves it to the starting position.
  • Loading branch information
ploubser committed Oct 27, 2010
1 parent 869f402 commit f7dd2ec
Show file tree
Hide file tree
Showing 56 changed files with 3,646 additions and 88 deletions.
3 changes: 2 additions & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Bernard Board - version 0.04
Bernard Board - version 0.05
CHANGELOG 0.05 Pagination added to board screens
CHANGELOG 0.04 Client and server side form validation.
CHANGELOG 0.03 Complete reimplementation of plugins.

Expand Down
29 changes: 10 additions & 19 deletions app/controllers/boards_controller.rb
Original file line number Diff line number Diff line change
@@ -1,45 +1,38 @@
class BoardsController < ApplicationController
# GET /boards
# GET /boards.xml
def index
@boards = Board.all
@boards = Board.paginate :page => params[:page], :order => 'created_at DESC'

respond_to do |format|
format.html # index.html.erb
format.html
format.xml { render :xml => @boards }
format.js {
render :update do |page|
page.replace_html 'container', :partial => 'board_results'
page << "bindPaginate()"
end
}
end
end

# GET /boards/1
# GET /boards/1.xml

def show
@board = Board.find(params[:id])

redirect_to :controller => "griditems", :action => :index, :fullscreen => true, :load_board => @board.name
#respond_to do |format|
#format.html # show.html.erb
#format.xml { render :xml => @boards }
#end
end

# GET /boards/new
# GET /boards/new.xml
def new
@boards = Board.new

respond_to do |format|
format.html # new.html.erb
format.html
format.xml { render :xml => @boards }
end
end

# GET /boards/1/edit
def edit
@boards = Board.find(params[:id])
end

# POST /boards
# POST /boards.xml
def create
@boards = Board.new(params[:boards])

Expand All @@ -55,8 +48,6 @@ def create
end
end

# PUT /boards/1
# PUT /boards/1.xml
def update
@boards = Board.find(params[:id])

Expand Down
8 changes: 7 additions & 1 deletion app/controllers/griditems_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,15 @@ def index
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @griditems }
format.js {
render :update do |page|
page.replace_html 'content', :partial => 'boards'
page << "bindPaginate()"
end
}
end
end


def create_grid_item
@dimentions = [params[:height], params[:width]]
@type = params[:type]
Expand All @@ -27,6 +32,7 @@ def create_grid_item
render :update do |page|
page << "disablePopup();"
page.insert_html :bottom, :container, :partial => "item"
page << ""
end
end

Expand Down
2 changes: 2 additions & 0 deletions app/models/board.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
class Board < ActiveRecord::Base
cattr_reader :per_page
@@per_page = 5
end
26 changes: 26 additions & 0 deletions app/views/boards/_board_results.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<div class="ui-widget-header"><center>BernardBoard</center></div>
<center><div id="boards_table">
<table>
<tr>
<th>Name</th>
<th>Width</th>
<th>Height</th>
</tr>

<% @boards.each do |board| %>
<tr>
<td><%=h board.name %></td>
<td><%=h board.width %></td>
<td><%=h board.height %></td>
<td><%= link_to 'Show', board %></td>
<td> <%= link_to_remote "Delete Board",
:url => {:action => "delete_board"},
:html => {:class => "board_item"},
:with => "'name=' + '#{board.name}'" %> </td>
</tr>
<% end %>
</table>
<div id="board_paginate"><%= will_paginate @boards %></div>
</div></center>
<div style="position:absolute;bottom:10%;right:10%;"><%= link_to 'Edit and Create boards', :action => :index, :controller => :griditems %>

23 changes: 1 addition & 22 deletions app/views/boards/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,6 @@

<div id="screen" class="ui-widget ui-widget-content">
<div id="container">
<div class="ui-widget-header"><center>BernardBoard</center></div>
<center><div id="boards_table">
<table>
<tr>
<th>Name</th>
<th>Width</th>
<th>Height</th>
</tr>

<% @boards.each do |board| %>
<tr>
<td><%=h board.name %></td>
<td><%=h board.width %></td>
<td><%=h board.height %></td>
<td><%= link_to 'Show', board %></td>
<td> <%= link_to_remote "Delete Board", :url => {:action => "delete_board"}, :html => {:class => "board_item"}, :with => "'name=' + '#{board.name}'" %> </td>
</tr>
<% end %>
</table></center>
<div style="position:absolute;bottom:10%;right:10%;"><%= link_to 'Edit and Create boards', :action => :index, :controller => :griditems %><div>
</div>

<%= render :partial => "board_results" %>
</div>
</div>
3 changes: 2 additions & 1 deletion app/views/griditems/_boards.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% list = Board.find(:all) %>
<% list = Board.paginate :page => params[:page], :order => 'created_at DESC' %>
<table>
<th> Name </th>
<th> Created on </th>
Expand All @@ -13,3 +13,4 @@
</tr>
<% end %>
</table>
<%= will_paginate list %>
1 change: 0 additions & 1 deletion app/views/griditems/_item.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
<%= @parameter_list = "" %>
<div class="item" id="item<%= @timestamp%>" style="height:<%= @dimentions[0]%>px;width:<%=@dimentions[1] %>px;border:solid 2px;position:absolute;" onmousemove="if(!'<%=@state%>' == 'view'){enableEvents('item<%= @timestamp%>')};" >
<%= render :partial => "griditems/plugins/#{@type.downcase}/#{@type.downcase}", :locals => {:parameters => @parameters, :itemid => "item" + @timestamp}%>
<%= javascript_tag "positionItem('item#{@timestamp}', 100 , 100)" %>
<%= form_tag 'index' %>
<% @parameters.each do |p| %>
<% unless p.to_s =~/.*authenticity.*|.*action.*|.*controller.*|.*height.*|.*refresh_rate.*|.*width.*|.*create.*|.*type.*|.*title.*|.*update.*/ %>
Expand Down
9 changes: 9 additions & 0 deletions public/javascripts/bernard.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
var popup = 0; //show popup = false
var lastTarget = ""; //last clicked item

//Allows for ajax pagination with the will_paginate plugin
function bindPaginate(){
jQuery('.pagination a').click(function(e) {
new Ajax.Request(jQuery(this).attr('href'), {method: 'get'});
e.preventDefault();
});
}

jQuery(document).ready(function() {

bindPaginate();
jQuery('.options').draggable({'revert' : false, 'zindex' : 350})
jQuery('.minimise').dblclick(function() {
jQuery('.optionscontents').toggle();
Expand Down
1 change: 0 additions & 1 deletion public/javascripts/feed.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
//Update feed item periodically.
// - currently hardcoded at 10s.
function update_feed(size, id){
alert(id);
jQuery('#feed0' + id).show();
var feedSize = size;
var currentFeed = 0;
Expand Down
46 changes: 4 additions & 42 deletions public/stylesheets/bernard.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,53 +55,11 @@
width:33.33334%;
}

.footer{
position:absolute;
bottom:0%;
width:100%;
}

.item{
font-style:bold;
overflow:hidden;
}

/************************************/
.gfg-title{
visibility:hidden;
}

.gf-title{
}

.gf-author{
}

.gf-spacer{
}

.gf-relativePublishedDate{
}

.gf-snippet{
}

.gfg-entry{
visibility:false;
font-size:100%;
padding:0px 0px 5px;
}

.gfg-listentry{
visibility:false;
font-size:75%;
}

.gfg-listentry-highlight{
font-size:100%
}
/**********************************/

.popup{
display:none;
position:fixed;
Expand All @@ -115,6 +73,10 @@
font-size:13px;
}

.pagination a{
color:#6FA5FD
}

.popup h1{
text-align:left;
color:#6FA5FD;
Expand Down
43 changes: 43 additions & 0 deletions vendor/plugins/will_paginate/.manifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
CHANGELOG.rdoc
LICENSE
README.rdoc
Rakefile
examples/apple-circle.gif
examples/index.haml
examples/index.html
examples/pagination.css
examples/pagination.sass
init.rb
lib/will_paginate.rb
lib/will_paginate/array.rb
lib/will_paginate/collection.rb
lib/will_paginate/core_ext.rb
lib/will_paginate/finder.rb
lib/will_paginate/named_scope.rb
lib/will_paginate/named_scope_patch.rb
lib/will_paginate/version.rb
lib/will_paginate/view_helpers.rb
test/boot.rb
test/collection_test.rb
test/console
test/database.yml
test/finder_test.rb
test/fixtures/admin.rb
test/fixtures/developer.rb
test/fixtures/developers_projects.yml
test/fixtures/project.rb
test/fixtures/projects.yml
test/fixtures/replies.yml
test/fixtures/reply.rb
test/fixtures/schema.rb
test/fixtures/topic.rb
test/fixtures/topics.yml
test/fixtures/user.rb
test/fixtures/users.yml
test/helper.rb
test/lib/activerecord_test_case.rb
test/lib/activerecord_test_connector.rb
test/lib/load_fixtures.rb
test/lib/view_test_process.rb
test/tasks.rake
test/view_test.rb
Loading

0 comments on commit f7dd2ec

Please sign in to comment.