tablesorter 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md ADDED
@@ -0,0 +1,53 @@
1
+ # Tablesorter
2
+
3
+ ==============================================================================================
4
+
5
+ ## View Helpers
6
+
7
+ sortable_column_headings(columns, options={})
8
+
9
+ so
10
+
11
+ <tr>
12
+ <%= sortable_column_headings(['name', 'age']) %>
13
+ </tr>
14
+
15
+ gives
16
+
17
+ <tr>
18
+ <th><a href="?dir=asc&sort=name">Name<span></span></a></th>
19
+ <th><a href="?dir=asc&sort=age">Age<span></span></a></th>
20
+ </tr>
21
+
22
+ When selected the link will be given a class of selected and either asc or desc.
23
+ You can use this to style the span with an arrow.
24
+
25
+ ## Styling
26
+
27
+ If you want different headings to be displayed in your table headings use translations under the tablesorter namespace.
28
+
29
+ en:
30
+ tablesorter:
31
+ age: 'Age (in years)'
32
+
33
+ ## Active Record
34
+ tablesort method
35
+
36
+ table_sort(sort_attr, dir, default_attr, default_dir)
37
+
38
+ eg
39
+
40
+ Person.scoped.table_sort(params[:sort], params[:dir], 'id', 'asc')
41
+
42
+ This project uses the MIT-LICENSE.
43
+
44
+ ## TODO
45
+ * Test!
46
+ * Add a note about translations for table headings
47
+ * maybe extend api of helper method so you can pass a hash rather then an array
48
+ * Improve readme and add some default css to show arrow styling
49
+ * twitter bootstrap arrows option
50
+ * Secondary sort
51
+ * Dont call order if no params passed
52
+ * mongoid?
53
+ * datamapper?
@@ -1,9 +1,9 @@
1
1
  module Tablesorter
2
2
  module ActiveRecord
3
- def table_sort(sort_attr, dir, default_attr, default_dir)
4
- sort_attr ||= default_attr
5
- dir ||= default_attr
6
- self.order("#{sort_attr} #{dir}")
3
+ def table_sort(sort_attr, dir_attr, default_sort, default_dir)
4
+ sort = sort_attr.presence || default_sort
5
+ dir = dir_attr.presence || default_dir
6
+ self.order("#{sort} #{dir}")
7
7
  end
8
8
  end
9
9
  end
@@ -1,3 +1,3 @@
1
1
  module Tablesorter
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tablesorter
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:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-23 00:00:00.000000000 Z
12
+ date: 2013-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -46,7 +46,7 @@ files:
46
46
  - lib/tablesorter.rb
47
47
  - MIT-LICENSE
48
48
  - Rakefile
49
- - README.rdoc
49
+ - README.md
50
50
  homepage: http://github.com/lukeroberts1990/tablesorter
51
51
  licenses: []
52
52
  post_install_message:
@@ -67,7 +67,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  version: '0'
68
68
  requirements: []
69
69
  rubyforge_project:
70
- rubygems_version: 1.8.24
70
+ rubygems_version: 1.8.23
71
71
  signing_key:
72
72
  specification_version: 3
73
73
  summary: A gem for creating sortable tables in rails applications
data/README.rdoc DELETED
@@ -1,3 +0,0 @@
1
- = Tablesorter
2
-
3
- This project rocks and uses MIT-LICENSE.