zable 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,67 @@
1
+ module ZableHelper
2
+ include Zable::WillPaginate
3
+
4
+ def self.included(base)
5
+ base.send :include, Zable::Html
6
+ end
7
+
8
+ def zable(collection, klass, args={}, &block)
9
+ reset_cycle("zable_cycle")
10
+
11
+ html = stylesheet_link_tag("zable")
12
+ html << pagination_element(collection, args.slice(:entry_name, :params)) if args[:paginate]
13
+ html << zable_element(args, block, collection, klass, args[:params])
14
+ html << pagination_element(collection, args.slice(:entry_name, :params)) if args[:paginate]
15
+ html
16
+ end
17
+
18
+ def zable_element(args, block, collection, klass, params)
19
+ cols = columns(&block)
20
+ cols.instance_variable_set :@search_params, controller.request.params[:search]
21
+ cols.instance_variable_set :@_extra_params, params
22
+ content_tag(:table, tag_args(args)) do
23
+ table_header(klass, cols) << table_body(collection, cols, args)
24
+ end
25
+ end
26
+
27
+ def pagination_element(collection, options)
28
+ content_tag :div, :class => 'brownFilterResultsBox' do
29
+ page_entries_info(collection, options.slice(:entry_name)) <<
30
+ will_paginate(collection, :renderer => LinkWithParamsRenderer.new(options[:params] || {}))
31
+ end
32
+ end
33
+
34
+ def columns
35
+ controller.request.instance_variable_set :@zable_columns, []
36
+ yield
37
+ controller.request.instance_variable_get :@zable_columns
38
+ end
39
+
40
+ def sorted_column?(name)
41
+ params[:sort][:attr] == name.to_s rescue false
42
+ end
43
+
44
+ def current_sort_order
45
+ params[:sort][:order].downcase.to_sym rescue :asc
46
+ end
47
+
48
+ def link_sort_order(name)
49
+ return nil unless sorted_column?(name)
50
+ current_sort_order == :desc ? :asc : :desc
51
+ end
52
+
53
+ def column(name, options={}, &block)
54
+ col = {
55
+ :name => name,
56
+ :title => options[:title],
57
+ :sort => options.has_key?(:sort) ? options[:sort] : true,
58
+ :block => block,
59
+ :sorted? => sorted_column?(name),
60
+ :sort_order => link_sort_order(name)
61
+ }
62
+
63
+ zable_columns = controller.request.instance_variable_get :@zable_columns
64
+ zable_columns << col
65
+ end
66
+
67
+ end
@@ -0,0 +1,53 @@
1
+ /*Any changes made to this stylesheet should also go into "/public/zable.css" of app and vice versa */
2
+
3
+ /**************************************************************************************************/
4
+ /* Begin: Pagination styling */
5
+ /**************************************************************************************************/
6
+
7
+ div .brownFilterResultsBox {
8
+ text-align: right;
9
+ }
10
+
11
+ /* Div that pagination elements are contained in */
12
+ div .pagination {
13
+ padding: 3px 3px 3px 15px;
14
+ margin: 3px;
15
+ display: inline;
16
+ }
17
+
18
+ /* Next and/or previous links (whichever are active) and any active page links */
19
+ div .pagination a {
20
+ border: 2px solid #CECCB6;
21
+ color: #948A63;
22
+ padding: 0 8px;
23
+ margin: 0;
24
+ text-decoration: none;
25
+ }
26
+
27
+ /* Current page */
28
+ div .pagination em {
29
+ background-color: #94794E;
30
+ border: 2px solid #8C6B3E;
31
+ color: #FFFFFF;
32
+ padding: 0 8px;
33
+ margin: 0;
34
+ text-decoration: none;
35
+ font-style: normal;
36
+ }
37
+
38
+ /* Either next/previous if disabled */
39
+ div .pagination span.disabled {
40
+ background: url("../images/common/pagination_bg_dis.gif") repeat-x scroll center top transparent;
41
+ border: 1px solid #E7E7E7;
42
+ color: #A8A8A8;
43
+ padding: 0 8px;
44
+ }
45
+
46
+ div .pagination a:hover,
47
+ div .pagination a:active {
48
+ border: 2px solid #333333;
49
+ }
50
+
51
+ /**************************************************************************************************/
52
+ /* End: Pagination styling */
53
+ /**************************************************************************************************/
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -42,6 +42,9 @@ files:
42
42
  - lib/zable/will_paginate.rb
43
43
  - lib/zable/zable_test_helper.rb
44
44
  - lib/zable.rb
45
+ - app/helpers/zable_helper.rb
46
+ - public/images/common/pagination_bg_dis.gif
47
+ - public/stylesheets/zable.css
45
48
  - MIT-LICENSE
46
49
  - Rakefile
47
50
  - README.rdoc