summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormr <mr@mrautenberg.de>2011-10-17 12:32:27 +0200
committermr <mr@mrautenberg.de>2011-10-17 12:32:27 +0200
commitf60f559c98343b36ed50cfba1a365f2738f59a68 (patch)
treec1546dd60d29d16093986de5f4bff8167c3333fb
parent3740f8be9d43a874f87a1757857f55d3662f60ff (diff)
clean code for navigation
-rw-r--r--application.rb2
-rw-r--r--views/models_navigation.haml18
-rw-r--r--views/models_navigation_bottom.haml77
-rw-r--r--views/style.sass2
4 files changed, 47 insertions, 52 deletions
diff --git a/application.rb b/application.rb
index 019592c..6cdfcfb 100644
--- a/application.rb
+++ b/application.rb
@@ -202,7 +202,7 @@ end
get '/predict/?' do
@models = ToxCreateModel.all.sort
@models = @models.collect{|m| m if m.status == 'Completed'}.compact
- @models = @models.sort_by{|x| [x.endpoint,x.name.downcase] }
+ @models = @models.sort_by{|x| [x.endpoint ? x.endpoint : "",x.name.downcase]}
haml :predict
end
diff --git a/views/models_navigation.haml b/views/models_navigation.haml
index 6bf05bd..c5eda97 100644
--- a/views/models_navigation.haml
+++ b/views/models_navigation.haml
@@ -26,7 +26,7 @@
- last = @models.size
- else
- last = 5*@page+5
-
+
= "#{5*@page+1}-#{last} / #{@models.size}"
| Page:
@@ -39,10 +39,10 @@
- (0..(@models.size/5).to_f.ceil-1).each do |p|
-if p != @page.to_f
%a{:href => '#', :id => "page_link_#{p}", :class => "page page_link"} #{p+1}
- - js += "$('#page_link_#{p}').click(function() \{ \n "
- - js += " $('#page').val('#{p}');\n "
- - js += " $('#nav').submit();\n "
- - js += "});\n "
+ - js += "$('#page_link_#{p}').click(function() \{ \n"
+ - js += " $('#page').val('#{p}');\n"
+ - js += " $('#nav').submit();\n"
+ - js += "});\n"
-else
%span{:class => "page page_active"} #{p+1}
@@ -54,10 +54,10 @@
- ["created_at","name","type","endpoint"].each do |s|
- idname = s == "created_at" ? "date" : s
- - js += "$('##{idname}').click(function() \{ \n "
- - js += " $('#sort_by').val('#{s}');\n "
- - js += " $('#nav').submit();\n "
- - js += "});\n "
+ - js += "$('##{idname}').click(function() \{ \n"
+ - js += " $('#sort_by').val('#{s}');\n"
+ - js += " $('#nav').submit();\n"
+ - js += "});\n"
:javascript
$("#prev").click(function() {
diff --git a/views/models_navigation_bottom.haml b/views/models_navigation_bottom.haml
index abea2d4..b2425fa 100644
--- a/views/models_navigation_bottom.haml
+++ b/views/models_navigation_bottom.haml
@@ -1,47 +1,42 @@
.models_navigation
- js = ""
- %form{:name => "nav_bottom", :action => url_for('/models'), :method => "get", :id => "nav"}
- %input{:type => :hidden, :name => :sort_by, :id => "sort_by", :value => params[:sort_by]}
- %input{:type => :hidden, :name => :order, :id => "order", :value => params[:order]}
- %input{:type => :hidden, :name => :page, :id => "page", :value => params[:page]}
+ - if @models.size > 5
+ Models:
+ - if @models.size < 5*@page+5
+ - last = @models.size
+ - else
+ - last = 5*@page+5
+ = "#{5*@page+1}-#{last} / #{@models.size}"
+ | Page:
+ - unless @page.to_i == 0
+ #prevbot{:class => "link"}
+ %img{:src => "arrow_left.png", :alt => 'previous', :title => 'previous'}/
+ -else
+ %img{:src => "arrow_left_inactive.png", :alt => '', :title => ''}/
- - if @models.size > 5
- Models:
- - if @models.size < 5*@page+5
- - last = @models.size
- - else
- - last = 5*@page+5
- = "#{5*@page+1}-#{last} / #{@models.size}"
- | Page:
- - unless @page.to_i == 0
- #prevbot{:class => "link"}
- %img{:src => "arrow_left.png", :alt => 'previous', :title => 'previous'}/
+ - (0..(@models.size/5).to_f.ceil-1).each do |p|
+ -if p != @page.to_f
+ %a{:href => '#', :id => "page_linkbot_#{p}", :class => "page page_link"} #{p+1}
+ - js += "$('#page_linkbot_#{p}').click(function() \{ \n"
+ - js += " $('#page').val('#{p}');\n"
+ - js += " $('#nav').submit();\n"
+ - js += "});\n"
-else
- %img{:src => "arrow_left_inactive.png", :alt => '', :title => ''}/
+ %span{:class => "page page_active"} #{p+1}
- - (0..(@models.size/5).to_f.ceil-1).each do |p|
- -if p != @page.to_f
- %a{:href => '#', :id => "page_linkbot_#{p}", :class => "page page_link"} #{p+1}
- - js += "$('#page_linkbot_#{p}').click(function() \{ \n"
- - js += " $('#page').val('#{p}');\n"
- - js += " $('#nav').submit();\n"
- - js += "});\n"
- -else
- %span{:class => "page page_active"} #{p+1}
+ - unless 5*@page.to_i+5 >= @models.size
+ #nextbot{:class => "link"}
+ %img{:src => "arrow_right.png", :alt => 'next', :title => 'next'}/
+ -else
+ %img{:src => "arrow_right_inactive.png", :alt => '', :title => ''}/
- - unless 5*@page.to_i+5 >= @models.size
- #nextbot{:class => "link"}
- %img{:src => "arrow_right.png", :alt => 'next', :title => 'next'}/
- -else
- %img{:src => "arrow_right_inactive.png", :alt => '', :title => ''}/
-
- :javascript
- $("#prevbot").click(function() {
- $("#page").val(#{@page-1});
- $("#nav").submit();
- });
- $("#nextbot").click(function() {
- $("#page").val(#{@page+1});
- $("#nav").submit();
- });
- #{js} \ No newline at end of file
+ :javascript
+ $("#prevbot").click(function() {
+ $("#page").val(#{@page-1});
+ $("#nav").submit();
+ });
+ $("#nextbot").click(function() {
+ $("#page").val(#{@page+1});
+ $("#nav").submit();
+ });
+ #{js} \ No newline at end of file
diff --git a/views/style.sass b/views/style.sass
index c14f164..f7fb7ac 100644
--- a/views/style.sass
+++ b/views/style.sass
@@ -286,7 +286,7 @@ dl
background-color: #FFF
padding: 0px 3px
font-size: 94%
- foont-weight: normal
+ font-weight: normal
.page_link:hover
border-color: #000
color: #000