-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Working on Ajax modal+pagination status delivery messages - Does not …
…work yet
- Loading branch information
Ryan Neufeld
committed
Aug 5, 2009
1 parent
e8aaec8
commit c043e1f
Showing
3 changed files
with
61 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,50 @@ | ||
module FreemailerCampaignsHelper | ||
end | ||
|
||
class StatusPaginationModalSwitchRenderer < WillPaginate::LinkRenderer | ||
def to_html | ||
links = @options[:page_links] ? windowed_links : [] | ||
|
||
links.unshift(page_link_or_span(@collection.previous_page, 'previous', @options[:previous_label])) | ||
links.push(page_link_or_span(@collection.next_page, 'next', @options[:next_label])) | ||
|
||
html = links.join(@options[:separator]) | ||
end | ||
|
||
protected | ||
|
||
def windowed_links | ||
visible_page_numbers.map { |n| page_link_or_span(n, (n == current_page ? 'current' : nil)) } | ||
end | ||
|
||
def page_link_or_span(page, span_class, text = nil) | ||
text ||= page.to_s | ||
if page && page != current_page | ||
page_link(page, text, :class => span_class) | ||
else | ||
page_span(page, text, :class => span_class) | ||
end | ||
end | ||
|
||
def page_link(page, text, attributes = {}) | ||
onclick = <<-EOS | ||
var old_page=Modalbox.content; | ||
var new_page; | ||
if(old_page.endsWith('statuses')){ | ||
new_page=old_page+'?page='+#{page}; | ||
}else{ | ||
new_page=old_page.gsub(/(\d+)$/,#{page}); | ||
} | ||
alert(new_page); | ||
EOS | ||
|
||
<<-EOS | ||
<a onclick="#{onclick}; Modalbox.show(text,new_page,{title: Modalbox.title, width: '450'});" href="#">#{text}</a> | ||
EOS | ||
end | ||
|
||
def page_span(page, text, attributes = {}) | ||
@template.content_tag(:span, text, attributes) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,12 @@ | ||
%table | ||
%tr | ||
%th Contact | ||
%th Email | ||
%th Status | ||
- statuses.each do |status| | ||
#delivery_statuses | ||
%table | ||
%tr | ||
%td= status.contact.name_for_display | ||
%td= status.contact.primary_email | ||
%td= status.delivery_status || "Pending" | ||
= will_paginate(statuses) | ||
%th Contact | ||
%th Email | ||
%th Status | ||
- statuses.each do |status| | ||
%tr | ||
%td= status.contact.name_for_display | ||
%td= status.contact.primary_email | ||
%td= status.delivery_status || "Pending" | ||
= will_paginate(statuses, :renderer => StatusPaginationModalSwitchRenderer) |