g_already_grid 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -1
- data/History.txt +6 -1
- data/README.rdoc +32 -12
- data/Rakefile +16 -7
- data/VERSION +1 -1
- data/g_already_grid.gemspec +20 -3
- data/lib/g_already_grid.rb +1 -1
- data/lib/g_already_grid/templates/guilded.already_grid.html.erb +10 -10
- data/lib/g_already_grid/view_helpers.rb +8 -5
- data/lib/generators/already_grid_assets/already_grid_assets_generator.rb +19 -0
- data/lib/generators/already_grid_assets/templates/default.css +61 -0
- data/lib/generators/already_grid_assets/templates/gridHeadBg.gif +0 -0
- data/lib/generators/already_grid_assets/templates/gridSort.gif +0 -0
- data/lib/generators/already_grid_assets/templates/gridSortAsc.gif +0 -0
- data/lib/generators/already_grid_assets/templates/gridSortDesc.gif +0 -0
- data/lib/generators/already_grid_assets/templates/guilded.already_grid.js +15 -0
- data/lib/generators/already_grid_assets/templates/guilded.already_grid.min.js +4 -0
- data/lib/generators/already_grid_assets/templates/jquery-already_grid-0.1.js +66 -0
- data/lib/generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js +66 -0
- data/spec/generators/already_grid_assets_generator_spec.rb +33 -0
- data/spec/spec.opts +7 -0
- data/spec/spec_helper.rb +10 -0
- metadata +56 -23
data/.gitignore
CHANGED
data/History.txt
CHANGED
@@ -1,9 +1,14 @@
|
|
1
|
+
== 1.0.8 2010-05-09
|
2
|
+
|
3
|
+
* Updated the generator to be Rails 3 compliant.
|
4
|
+
* Updated component to work with Rails 3.
|
5
|
+
|
1
6
|
== 1.0.7 2009-10-27
|
2
7
|
|
3
8
|
* Added a use_polymorphic_path option to the grid view helper to enable the polymorphic path helper to determine the path of
|
4
9
|
each object in the collection to use as the link for each grid record. Used when the AR object is STI'ed and one would like
|
5
10
|
to generate show links that are correctly pathed to the specific type (not the base class).
|
6
|
-
|
11
|
+
* Added :use_sti_base_index option to allow the base STI class' index to be used in lieu of the specific STI class.
|
7
12
|
|
8
13
|
== 1.0.5 2009-10-27
|
9
14
|
|
data/README.rdoc
CHANGED
@@ -18,47 +18,66 @@ ActiveRecord collection.
|
|
18
18
|
* Automatically renders a check all and adds check all behavior if check box column option
|
19
19
|
|
20
20
|
|
21
|
+
== COMPATABILITY
|
22
|
+
|
23
|
+
* Ruby 1.9
|
24
|
+
* Ruby 1.8
|
25
|
+
* Rails 3
|
26
|
+
* Rails 2
|
27
|
+
|
28
|
+
|
21
29
|
== INSTALL:
|
22
30
|
|
23
|
-
|
31
|
+
gem install g_already_grid
|
32
|
+
|
24
33
|
|
25
|
-
|
34
|
+
== INSTALL FOR RAILS
|
26
35
|
|
27
|
-
|
36
|
+
Configure the Gem for use:
|
28
37
|
|
38
|
+
gem 'g_already_grid' # Rails 3
|
39
|
+
config.gem 'g_already_grid' # Rails 2
|
40
|
+
|
41
|
+
Install the Gem:
|
42
|
+
|
43
|
+
bundle install # Rails 3
|
44
|
+
rake gems:install # Rails 2
|
45
|
+
|
29
46
|
Generate:
|
30
47
|
|
31
|
-
|
48
|
+
rails generate already_grid_assets_generator # Rails 3
|
49
|
+
script/generate already_grid_assets_generator # Rails 2
|
32
50
|
|
33
51
|
|
34
52
|
== USAGE:
|
35
53
|
|
36
54
|
Simplest case:
|
37
55
|
|
38
|
-
|
56
|
+
<%= raw g_already_grid( @items, :id => "items-grid", :cols => [:name, :is_active] ) %> # Rails 3
|
57
|
+
<%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active] %> # Rails 2
|
39
58
|
|
40
59
|
Add sorting (by name column only):
|
41
60
|
|
42
|
-
<%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name] %>
|
61
|
+
<%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name] %> # Rails 2
|
43
62
|
|
44
63
|
Add scoping for nested models (deeply nested):
|
45
64
|
|
46
|
-
<%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name],
|
65
|
+
<%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name], # Rails 2
|
47
66
|
:scoped_by => @account %>
|
48
67
|
|
49
68
|
Add shallow option to use shallow nesting:
|
50
69
|
|
51
|
-
<%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name],
|
70
|
+
<%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name], # Rails 2
|
52
71
|
:scoped_by => @account, :shallow => true %>
|
53
72
|
|
54
73
|
Add namespace option for namespacing:
|
55
74
|
|
56
|
-
<%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name],
|
75
|
+
<%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name], # Rails 2
|
57
76
|
:namespace => :admin %>
|
58
77
|
|
59
78
|
Add use polymorphic path option for STI'ed models:
|
60
79
|
|
61
|
-
<%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name],
|
80
|
+
<%= g_already_grid @items, :id => "items-grid", :cols => [:name, :is_active], :sort => [:name], # Rails 2
|
62
81
|
:namespace => :admin, :use_polymorphic_path => true %>
|
63
82
|
|
64
83
|
|
@@ -67,13 +86,14 @@ Add use polymorphic path option for STI'ed models:
|
|
67
86
|
id:: The HTML id attribute.
|
68
87
|
cols:: (required) An array of column names to include in the table. Each position of the array can be a symbol, string, or hash with 1 entry. The hash entry is the database field name as a key and the name to use in the gird as the value. Each key and value in the hash can be a symbol or string.
|
69
88
|
skin:: The name of the skin to use for this Guilded element. Defaults to default => which is default.css.
|
70
|
-
exclude_css:: A boolean indicating if Guilded should create a stylesheet
|
89
|
+
exclude_css:: A boolean indicating if Guilded should create a stylesheet include tag for this element. Defaults to false.
|
71
90
|
empty_msg:: a message to display when the ar_col is empty or nil. Defaults to 'No matching records'.
|
72
91
|
actions:: Action links to include in the action column of grid. A boolean or Array of symbols. When boolean, if true, add show, edit and delete actions. When boolean, if false, hide actions column. When Array of symbols, add only actions present in array.
|
73
92
|
paginate:: A boolean indicating whether to output pagination controls. Defaults to true. Utilizes will_paginate plugin features.
|
74
93
|
polymorphic_type:: The type of this polymorphic record. Should be a string representing the class name.
|
75
94
|
polymorphic_as:: The as used for the polymorphic type. Can be a symbol or string.
|
76
|
-
use_polymorphic_path:: When true, uses
|
95
|
+
use_polymorphic_path:: When true, uses the polymorphic path helper to determine the AR objects path from it's type (STI), otherwise, does not. Defaults to false.
|
96
|
+
use_sti_base_index:: When true, use the STI base class' index path instead of the specific descendant AR object's.
|
77
97
|
namespace:: A string or symbol that is the namespace this collection is under.
|
78
98
|
scoped_by:: The active record object that the objects in the ar_col is scoped by.
|
79
99
|
shallow:: True if this collection is nested shallow, otherwise, false.
|
data/Rakefile
CHANGED
@@ -20,13 +20,22 @@ rescue LoadError
|
|
20
20
|
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
21
21
|
end
|
22
22
|
|
23
|
-
require 'rake/
|
24
|
-
Rake::
|
25
|
-
|
26
|
-
|
27
|
-
test.verbose = true
|
23
|
+
require 'spec/rake/spectask'
|
24
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
25
|
+
spec.libs << 'lib' << 'spec'
|
26
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
28
27
|
end
|
29
28
|
|
29
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
30
|
+
spec.libs << 'lib' << 'spec'
|
31
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
32
|
+
spec.rcov = true
|
33
|
+
end
|
34
|
+
|
35
|
+
task :spec => :check_dependencies
|
36
|
+
|
37
|
+
task :default => :spec
|
38
|
+
|
30
39
|
begin
|
31
40
|
require 'rcov/rcovtask'
|
32
41
|
Rcov::RcovTask.new do |test|
|
@@ -53,7 +62,7 @@ Rake::RDocTask.new do |rdoc|
|
|
53
62
|
end
|
54
63
|
|
55
64
|
rdoc.rdoc_dir = 'rdoc'
|
56
|
-
rdoc.title = "
|
65
|
+
rdoc.title = "tester #{version}"
|
57
66
|
rdoc.rdoc_files.include('README*')
|
58
67
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
59
|
-
end
|
68
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.8
|
data/g_already_grid.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{g_already_grid}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.8"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["C. Jason Harrelson (midas)"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-05-09}
|
13
13
|
s.description = %q{A Guilded Rails component that generates a rich grid control from an ActiveRecord.}
|
14
14
|
s.email = %q{jason@lookforwardenterprises.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -27,6 +27,16 @@ Gem::Specification.new do |s|
|
|
27
27
|
"lib/g_already_grid.rb",
|
28
28
|
"lib/g_already_grid/templates/guilded.already_grid.html.erb",
|
29
29
|
"lib/g_already_grid/view_helpers.rb",
|
30
|
+
"lib/generators/already_grid_assets/already_grid_assets_generator.rb",
|
31
|
+
"lib/generators/already_grid_assets/templates/default.css",
|
32
|
+
"lib/generators/already_grid_assets/templates/gridHeadBg.gif",
|
33
|
+
"lib/generators/already_grid_assets/templates/gridSort.gif",
|
34
|
+
"lib/generators/already_grid_assets/templates/gridSortAsc.gif",
|
35
|
+
"lib/generators/already_grid_assets/templates/gridSortDesc.gif",
|
36
|
+
"lib/generators/already_grid_assets/templates/guilded.already_grid.js",
|
37
|
+
"lib/generators/already_grid_assets/templates/guilded.already_grid.min.js",
|
38
|
+
"lib/generators/already_grid_assets/templates/jquery-already_grid-0.1.js",
|
39
|
+
"lib/generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js",
|
30
40
|
"rails_generators/already_grid_assets/already_grid_assets_generator.rb",
|
31
41
|
"rails_generators/already_grid_assets/templates/default.css",
|
32
42
|
"rails_generators/already_grid_assets/templates/gridHeadBg.gif",
|
@@ -40,13 +50,20 @@ Gem::Specification.new do |s|
|
|
40
50
|
"script/console",
|
41
51
|
"script/destroy",
|
42
52
|
"script/generate",
|
53
|
+
"spec/generators/already_grid_assets_generator_spec.rb",
|
54
|
+
"spec/spec.opts",
|
55
|
+
"spec/spec_helper.rb",
|
43
56
|
"tasks/rspec.rake"
|
44
57
|
]
|
45
58
|
s.homepage = %q{http://github.com/midas/g_already_grid}
|
46
59
|
s.rdoc_options = ["--charset=UTF-8"]
|
47
60
|
s.require_paths = ["lib"]
|
48
|
-
s.rubygems_version = %q{1.3.
|
61
|
+
s.rubygems_version = %q{1.3.6}
|
49
62
|
s.summary = %q{A Guilded Rails component that generates a rich grid control from an ActiveRecord.}
|
63
|
+
s.test_files = [
|
64
|
+
"spec/generators/already_grid_assets_generator_spec.rb",
|
65
|
+
"spec/spec_helper.rb"
|
66
|
+
]
|
50
67
|
|
51
68
|
if s.respond_to? :specification_version then
|
52
69
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
data/lib/g_already_grid.rb
CHANGED
@@ -7,7 +7,7 @@
|
|
7
7
|
<% end %>
|
8
8
|
<% unless options[:actions].empty? %><th>Actions</th><% end %>
|
9
9
|
<% options[:col_titles].each_with_index do |col, i| %>
|
10
|
-
<th><%= sort_by.include?( options[:cols][i].to_sym ) ? sortable_header( col, options[:cols][i], path_helpers[:index_rest_helper], path_helpers[:index_rest_args], options ) : col %></th>
|
10
|
+
<th><%= sort_by.include?( options[:cols][i].to_sym ) ? sortable_header( col, options[:cols][i], path_helpers[:index_rest_helper], path_helpers[:index_rest_args], controller, options ) : col %></th>
|
11
11
|
<% end %>
|
12
12
|
<th class="right"></th>
|
13
13
|
</tr>
|
@@ -21,9 +21,9 @@
|
|
21
21
|
<% end %>
|
22
22
|
<% unless options[:actions].empty? %>
|
23
23
|
<td>
|
24
|
-
<%= link_to 'show',
|
25
|
-
<%= link_to 'edit',
|
26
|
-
<%= link_to( 'del',
|
24
|
+
<%= link_to 'show', controller.send( path_helpers[:show_rest_helper], *(path_helpers[:show_rest_args] + record_array) ) if options[:actions].include?( :show ) %>
|
25
|
+
<%= link_to 'edit', controller.send( path_helpers[:edit_rest_helper], *(path_helpers[:edit_rest_args] + record_array) ) if options[:actions].include?( :edit ) %>
|
26
|
+
<%= link_to( 'del', controller.send( path_helpers[:delete_rest_helper], *(path_helpers[:edit_rest_args] + record_array) ),
|
27
27
|
:method => :delete, :confirm => options[:del_confirmation] ) if options[:actions].include?( :edit ) %>
|
28
28
|
</td>
|
29
29
|
<% end %>
|
@@ -47,12 +47,12 @@
|
|
47
47
|
<td>
|
48
48
|
<% cell_args = path_helpers[:show_rest_args] + record_array %>
|
49
49
|
<% if options[:actions].empty? && options[:clickable] == true %>
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
<%= link_to( record_val,
|
55
|
-
|
50
|
+
<% if options[:use_polymorphic_path] == true
|
51
|
+
cell_args.insert( 0, options[:namespace] ) -%>
|
52
|
+
<%= link_to record_val, controller.polymorphic_path( cell_args ) %>
|
53
|
+
<% else -%>
|
54
|
+
<%= link_to( record_val, controller.send( path_helpers[:show_rest_helper], *cell_args ) ) %>
|
55
|
+
<% end -%>
|
56
56
|
<% else %>
|
57
57
|
<%= link_to( record_val, "javascript:void(0)" ) %>
|
58
58
|
<% end %>
|
@@ -25,8 +25,9 @@ module GAlreadyGrid
|
|
25
25
|
# true. Utilizes will_paginate plugin features.
|
26
26
|
# +polymorphic_type+ The type of this polymorphic record. Should be a string representing the class name.
|
27
27
|
# +polymorphic_as+ The as used for the polymorphic type. Can be a symbol or string.
|
28
|
-
# +use_polymorphic_path+ When true, uses
|
28
|
+
# +use_polymorphic_path+ When true, uses the polymorphic path helper to determine the AR objects path from it's type (STI),
|
29
29
|
# otherwise, does not. Defaults to false.
|
30
|
+
# +use_sti_base_index+ When true, use the STI base class' index path instead of the specific descendant AR object's.
|
30
31
|
# +namespace+ A string or symbol that is the namespace this collection is under.
|
31
32
|
# +scoped_by+ The active record object that the objects in the ar_col is scoped by.
|
32
33
|
# +shallow+ True if this collection is nested shallow, otherwise, false.
|
@@ -97,13 +98,15 @@ module GAlreadyGrid
|
|
97
98
|
|
98
99
|
options[:checkboxes] = true if options[:checkboxes].nil?
|
99
100
|
|
101
|
+
controller = self if Rails.version.split('.').first.to_i > 2
|
100
102
|
total_columns = options[:cols].size
|
101
103
|
total_columns = total_columns + 1 if options[:checkboxes]
|
102
104
|
total_columns = total_columns + 1 unless options[:actions].empty?
|
103
105
|
options[:total_columns] = total_columns
|
104
106
|
|
105
107
|
vars = {
|
106
|
-
:options => options, :ar_col => ar_col, :do_paginate => do_paginate, :sort_by => sort_by, :path_helpers => path_helpers
|
108
|
+
:options => options, :ar_col => ar_col, :do_paginate => do_paginate, :sort_by => sort_by, :path_helpers => path_helpers,
|
109
|
+
:controller => controller
|
107
110
|
}
|
108
111
|
|
109
112
|
@g_already_grid_options = options
|
@@ -125,7 +128,7 @@ module GAlreadyGrid
|
|
125
128
|
# +already_grid_options+ The options hash from the already grid view helper.
|
126
129
|
# +options+ see link_to helper.
|
127
130
|
#
|
128
|
-
def sortable_header( name, method, path, scoping_args, already_grid_options, options={} )
|
131
|
+
def sortable_header( name, method, path, scoping_args, controller, already_grid_options, options={} )
|
129
132
|
is_sorted_link = ( method.to_s == params[:order].to_s )
|
130
133
|
|
131
134
|
if is_sorted_link
|
@@ -150,12 +153,12 @@ module GAlreadyGrid
|
|
150
153
|
if is_sorted_link
|
151
154
|
# Handle the currently sorted by link
|
152
155
|
path_args << sort_options
|
153
|
-
path =
|
156
|
+
path = controller.send( path, *path_args )
|
154
157
|
else
|
155
158
|
# Handle the the other currently unsorted by links (we will always sort in
|
156
159
|
# an ASC direction the first time)
|
157
160
|
path_args << unsorted_options
|
158
|
-
path =
|
161
|
+
path = controller.send( path, *path_args )
|
159
162
|
end
|
160
163
|
|
161
164
|
# Try to adapt to get collection rest methods
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
class AlreadyGridAssetsGenerator < Rails::Generators::Base
|
4
|
+
def self.source_root
|
5
|
+
File.join( File.dirname(__FILE__), 'templates' )
|
6
|
+
end
|
7
|
+
|
8
|
+
def install_already_grid_assets
|
9
|
+
copy_file "guilded.already_grid.js", "public/javascripts/guilded.already_grid.js"
|
10
|
+
copy_file "guilded.already_grid.min.js", "public/javascripts/guilded.already_grid.min.js"
|
11
|
+
copy_file "jquery-already_grid-0.1.js", "public/javascripts/jquery/jquery-already_grid-0.1.js"
|
12
|
+
copy_file "jquery-already_grid-0.1.min.js", "public/javascripts/jquery/jquery-already_grid-0.1.min.js"
|
13
|
+
copy_file "default.css", "public/stylesheets/guilded/already_grid/default.css"
|
14
|
+
copy_file "gridHeadBg.gif", "public/stylesheets/guilded/already_grid/default/gridHeadBg.gif"
|
15
|
+
copy_file "gridSort.gif", "public/stylesheets/guilded/already_grid/default/gridSort.gif"
|
16
|
+
copy_file "gridSortAsc.gif", "public/stylesheets/guilded/already_grid/default/gridSortAsc.gif"
|
17
|
+
copy_file "gridSortDesc.gif", "public/stylesheets/guilded/already_grid/default/gridSortDesc.gif"
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
.already-grid table {
|
2
|
+
width:100%;
|
3
|
+
position:relative;
|
4
|
+
top:0;
|
5
|
+
border-collapse:collapse !important;
|
6
|
+
}
|
7
|
+
.already-grid table thead {
|
8
|
+
text-align:left;
|
9
|
+
color:#636363;
|
10
|
+
background:url(/stylesheets/guilded/already_grid/default/gridHeadBg.gif) #e9e9e9 repeat-x;
|
11
|
+
font-weight:normal;
|
12
|
+
}
|
13
|
+
.already-grid table thead th {
|
14
|
+
padding:0.6em 0.75em;
|
15
|
+
border-top:1px solid #c2c2c2;
|
16
|
+
border-bottom:1px solid #c2c2c2;
|
17
|
+
border-right:1px solid #c2c2c2;
|
18
|
+
border-left-color:#c2c2c2;
|
19
|
+
white-space:nowrap;
|
20
|
+
font-size:0.7em;
|
21
|
+
}
|
22
|
+
.already-grid table tbody tr:hover a { color:#585858; }
|
23
|
+
.already-grid table tbody td {
|
24
|
+
border-bottom: 1px solid #e5e7f2;
|
25
|
+
border-right: 1px solid #e5e7f2;
|
26
|
+
font-size: 0.8em;
|
27
|
+
white-space: nowrap
|
28
|
+
}
|
29
|
+
.already-grid table tbody td a {
|
30
|
+
display: block;
|
31
|
+
padding: 0.5em 0.75em;
|
32
|
+
}
|
33
|
+
.already-grid table tfoot td {
|
34
|
+
padding: 0.75em;
|
35
|
+
text-align: center;
|
36
|
+
color: #898989;
|
37
|
+
font-size: 0.75em;
|
38
|
+
}
|
39
|
+
.already-grid table tbody .odd { background:#f0f5fa; }
|
40
|
+
.already-grid table tbody .selected { background:#029dd7; }
|
41
|
+
.already-grid table tbody .selected td a { color: white; }
|
42
|
+
|
43
|
+
.already-grid table th a {
|
44
|
+
color:#636363;
|
45
|
+
text-decoration: underline;
|
46
|
+
background: url(/stylesheets/guilded/already_grid/default/gridSort.gif) right no-repeat;
|
47
|
+
display: block;
|
48
|
+
padding-right: 10px;
|
49
|
+
}
|
50
|
+
|
51
|
+
.already-grid table th a:hover {color:black;}
|
52
|
+
|
53
|
+
.already-grid table .sort-asc {
|
54
|
+
background: url(/stylesheets/guilded/already_grid/default/gridSortAsc.gif) right no-repeat;
|
55
|
+
display: block;
|
56
|
+
}
|
57
|
+
|
58
|
+
.already-grid table .sort-desc {
|
59
|
+
background: url(/stylesheets/guilded/already_grid/default/gridSortDesc.gif) right no-repeat;
|
60
|
+
display: block;
|
61
|
+
}
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/* Guilded Already Grid 1.0.0
|
2
|
+
* Copyright (c) 2009 C. Jason Harrelson (midas)
|
3
|
+
* Guilded Flash Growler is licensed under the terms of the MIT License */
|
4
|
+
|
5
|
+
g.alreadyGridInit = function( options )
|
6
|
+
{
|
7
|
+
if( g.beforeAlreadyGridInit )
|
8
|
+
g.beforeAlreadyGridInit( options );
|
9
|
+
|
10
|
+
var grid = $j( '#' + options.id );
|
11
|
+
grid.alreadyGrid( options );
|
12
|
+
|
13
|
+
if( g.afterAlreadyGridInit )
|
14
|
+
g.afterAlreadyGridInit( options );
|
15
|
+
};
|
@@ -0,0 +1,4 @@
|
|
1
|
+
/* Guilded Already 1.0.0
|
2
|
+
* Copyright (c) 2009 C. Jason Harrelson (midas)
|
3
|
+
* Guilded Flash Growler is licensed under the terms of the MIT License */
|
4
|
+
g.alreadyGridInit=function(options){if(g.beforeAlreadyGridInit)g.beforeAlreadyGridInit(options);var grid=$j('#'+options.id);grid.alreadyGrid(options);if(g.afterAlreadyGridInit)g.afterAlreadyGridInit(options);};
|
@@ -0,0 +1,66 @@
|
|
1
|
+
(function($){
|
2
|
+
|
3
|
+
jQuery.fn.alreadyGrid = function( /* Object literal */ options )
|
4
|
+
{
|
5
|
+
opts = $j.extend( $j.fn.alreadyGrid.defaults, options );
|
6
|
+
|
7
|
+
// Set up check box events
|
8
|
+
checkAllBox = $j( '.' + opts.check_all_class );
|
9
|
+
checkboxes = $j( '.' + opts.checkbox_class );
|
10
|
+
$j( 'document' ).ready( updateSelecteds );
|
11
|
+
checkAllBox.click( checkAllClicked );
|
12
|
+
checkboxes.click( checkboxClicked );
|
13
|
+
|
14
|
+
return jQuery;
|
15
|
+
}
|
16
|
+
|
17
|
+
/* *************** public *************** */
|
18
|
+
|
19
|
+
jQuery.fn.alreadyGrid.defaults =
|
20
|
+
{
|
21
|
+
paginate: true,
|
22
|
+
checkboxes: false,
|
23
|
+
checkbox_class: 'chk',
|
24
|
+
check_all_class: 'checkAll'
|
25
|
+
};
|
26
|
+
|
27
|
+
/* *************** private *************** */
|
28
|
+
|
29
|
+
checkAllClicked = function( /* jquery Event */ e )
|
30
|
+
{
|
31
|
+
if( $j( this ).is(':checked') )
|
32
|
+
{
|
33
|
+
//$j( '.' + opts.checkbox_class ).click();
|
34
|
+
checkboxes.attr( 'checked', true );
|
35
|
+
checkboxes.parent().parent().addClass( 'selected' );
|
36
|
+
}
|
37
|
+
else
|
38
|
+
{
|
39
|
+
checkboxes.attr( 'checked', false );
|
40
|
+
checkboxes.parent().parent().removeClass( 'selected' );
|
41
|
+
}
|
42
|
+
};
|
43
|
+
|
44
|
+
checkboxClicked = function( /* jquery Event */ e )
|
45
|
+
{
|
46
|
+
if( $j( this ).is(':checked') )
|
47
|
+
$j( this ).parent().parent().addClass( 'selected' );
|
48
|
+
else
|
49
|
+
{
|
50
|
+
$j( this ).parent().parent().removeClass( 'selected' );
|
51
|
+
if( checkAllBox.is(':checked') )
|
52
|
+
{
|
53
|
+
checkAllBox.attr( 'checked', false );
|
54
|
+
}
|
55
|
+
}
|
56
|
+
};
|
57
|
+
|
58
|
+
/* Used after load to update selected based on check boxes when the
|
59
|
+
* grid loads. */
|
60
|
+
updateSelecteds = function( /* jquery Event */ e )
|
61
|
+
{
|
62
|
+
var checkboxes = $j( "." + opts.checkbox_class + "[checked]");
|
63
|
+
checkboxes.parent().parent().addClass( 'selected' );
|
64
|
+
};
|
65
|
+
|
66
|
+
})(jQuery);
|
@@ -0,0 +1,66 @@
|
|
1
|
+
(function($){
|
2
|
+
|
3
|
+
jQuery.fn.alreadyGrid = function( /* Object literal */ options )
|
4
|
+
{
|
5
|
+
opts = $j.extend( $j.fn.alreadyGrid.defaults, options );
|
6
|
+
|
7
|
+
// Set up check box events
|
8
|
+
checkAllBox = $j( '.' + opts.check_all_class );
|
9
|
+
checkboxes = $j( '.' + opts.checkbox_class );
|
10
|
+
$j( 'document' ).ready( updateSelecteds );
|
11
|
+
checkAllBox.click( checkAllClicked );
|
12
|
+
checkboxes.click( checkboxClicked );
|
13
|
+
|
14
|
+
return jQuery;
|
15
|
+
}
|
16
|
+
|
17
|
+
/* *************** public *************** */
|
18
|
+
|
19
|
+
jQuery.fn.alreadyGrid.defaults =
|
20
|
+
{
|
21
|
+
paginate: true,
|
22
|
+
checkboxes: false,
|
23
|
+
checkbox_class: 'chk',
|
24
|
+
check_all_class: 'checkAll'
|
25
|
+
};
|
26
|
+
|
27
|
+
/* *************** private *************** */
|
28
|
+
|
29
|
+
checkAllClicked = function( /* jquery Event */ e )
|
30
|
+
{
|
31
|
+
if( $j( this ).is(':checked') )
|
32
|
+
{
|
33
|
+
//$j( '.' + opts.checkbox_class ).click();
|
34
|
+
checkboxes.attr( 'checked', true );
|
35
|
+
checkboxes.parent().parent().addClass( 'selected' );
|
36
|
+
}
|
37
|
+
else
|
38
|
+
{
|
39
|
+
checkboxes.attr( 'checked', false );
|
40
|
+
checkboxes.parent().parent().removeClass( 'selected' );
|
41
|
+
}
|
42
|
+
};
|
43
|
+
|
44
|
+
checkboxClicked = function( /* jquery Event */ e )
|
45
|
+
{
|
46
|
+
if( $j( this ).is(':checked') )
|
47
|
+
$j( this ).parent().parent().addClass( 'selected' );
|
48
|
+
else
|
49
|
+
{
|
50
|
+
$j( this ).parent().parent().removeClass( 'selected' );
|
51
|
+
if( checkAllBox.is(':checked') )
|
52
|
+
{
|
53
|
+
checkAllBox.attr( 'checked', false );
|
54
|
+
}
|
55
|
+
}
|
56
|
+
};
|
57
|
+
|
58
|
+
/* Used after load to update selected based on check boxes when the
|
59
|
+
* grid loads. */
|
60
|
+
updateSelecteds = function( /* jquery Event */ e )
|
61
|
+
{
|
62
|
+
var checkboxes = $j( "." + opts.checkbox_class + "[checked]");
|
63
|
+
checkboxes.parent().parent().addClass( 'selected' );
|
64
|
+
};
|
65
|
+
|
66
|
+
})(jQuery);
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'generators/already_grid_assets/already_grid_assets_generator'
|
3
|
+
|
4
|
+
describe AlreadyGridAssetsGenerator do
|
5
|
+
before :each do
|
6
|
+
@destination = File.join 'tmp', 'test_app'
|
7
|
+
@source = AlreadyGridAssetsGenerator.source_root
|
8
|
+
AlreadyGridAssetsGenerator.start '', :destination_root => @destination
|
9
|
+
end
|
10
|
+
|
11
|
+
after :each do
|
12
|
+
FileUtils.rm_rf @destination
|
13
|
+
end
|
14
|
+
|
15
|
+
{"guilded.already_grid.js" => "public/javascripts/guilded.already_grid.js",
|
16
|
+
"guilded.already_grid.min.js" => "public/javascripts/guilded.already_grid.min.js",
|
17
|
+
"jquery-already_grid-0.1.js" => "public/javascripts/jquery/jquery-already_grid-0.1.js",
|
18
|
+
"jquery-already_grid-0.1.min.js" => "public/javascripts/jquery/jquery-already_grid-0.1.min.js",
|
19
|
+
"default.css" => "public/stylesheets/guilded/already_grid/default.css",
|
20
|
+
"gridHeadBg.gif" => "public/stylesheets/guilded/already_grid/default/gridHeadBg.gif",
|
21
|
+
"gridSort.gif" => "public/stylesheets/guilded/already_grid/default/gridSort.gif",
|
22
|
+
"gridSortAsc.gif" => "public/stylesheets/guilded/already_grid/default/gridSortAsc.gif",
|
23
|
+
"gridSortDesc.gif" => "public/stylesheets/guilded/already_grid/default/gridSortDesc.gif"}.each do |file, path|
|
24
|
+
|
25
|
+
it "should copy '#{file}' to '#{path}'" do
|
26
|
+
File.exists?( File.join( @destination, path ) ).should be_true
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should agree that the contents of '#{file}' are identical to '#{path}'" do
|
30
|
+
File.read( File.join( @source, file ) ).should eql File.read( File.join( @destination, path ) )
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/spec.opts
ADDED
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,7 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: g_already_grid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 8
|
9
|
+
version: 1.0.8
|
5
10
|
platform: ruby
|
6
11
|
authors:
|
7
12
|
- C. Jason Harrelson (midas)
|
@@ -9,49 +14,61 @@ autorequire:
|
|
9
14
|
bindir: bin
|
10
15
|
cert_chain: []
|
11
16
|
|
12
|
-
date: 2010-
|
17
|
+
date: 2010-05-09 00:00:00 -05:00
|
13
18
|
default_executable:
|
14
19
|
dependencies:
|
15
20
|
- !ruby/object:Gem::Dependency
|
16
21
|
name: rails
|
17
|
-
|
18
|
-
|
19
|
-
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
24
|
requirements:
|
21
25
|
- - ">="
|
22
26
|
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 3
|
23
30
|
version: "2.3"
|
24
|
-
|
31
|
+
type: :runtime
|
32
|
+
version_requirements: *id001
|
25
33
|
- !ruby/object:Gem::Dependency
|
26
34
|
name: guilded
|
27
|
-
|
28
|
-
|
29
|
-
version_requirements: !ruby/object:Gem::Requirement
|
35
|
+
prerelease: false
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
37
|
requirements:
|
31
38
|
- - ">="
|
32
39
|
- !ruby/object:Gem::Version
|
40
|
+
segments:
|
41
|
+
- 1
|
42
|
+
- 0
|
33
43
|
version: "1.0"
|
34
|
-
|
44
|
+
type: :runtime
|
45
|
+
version_requirements: *id002
|
35
46
|
- !ruby/object:Gem::Dependency
|
36
47
|
name: will_paginate
|
37
|
-
|
38
|
-
|
39
|
-
version_requirements: !ruby/object:Gem::Requirement
|
48
|
+
prerelease: false
|
49
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
40
50
|
requirements:
|
41
51
|
- - ">="
|
42
52
|
- !ruby/object:Gem::Version
|
53
|
+
segments:
|
54
|
+
- 0
|
43
55
|
version: "0"
|
44
|
-
|
56
|
+
type: :runtime
|
57
|
+
version_requirements: *id003
|
45
58
|
- !ruby/object:Gem::Dependency
|
46
59
|
name: shoulda
|
47
|
-
|
48
|
-
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
prerelease: false
|
61
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
50
62
|
requirements:
|
51
63
|
- - ">="
|
52
64
|
- !ruby/object:Gem::Version
|
65
|
+
segments:
|
66
|
+
- 2
|
67
|
+
- 10
|
68
|
+
- 2
|
53
69
|
version: 2.10.2
|
54
|
-
|
70
|
+
type: :development
|
71
|
+
version_requirements: *id004
|
55
72
|
description: A Guilded Rails component that generates a rich grid control from an ActiveRecord.
|
56
73
|
email: jason@lookforwardenterprises.com
|
57
74
|
executables: []
|
@@ -72,6 +89,16 @@ files:
|
|
72
89
|
- lib/g_already_grid.rb
|
73
90
|
- lib/g_already_grid/templates/guilded.already_grid.html.erb
|
74
91
|
- lib/g_already_grid/view_helpers.rb
|
92
|
+
- lib/generators/already_grid_assets/already_grid_assets_generator.rb
|
93
|
+
- lib/generators/already_grid_assets/templates/default.css
|
94
|
+
- lib/generators/already_grid_assets/templates/gridHeadBg.gif
|
95
|
+
- lib/generators/already_grid_assets/templates/gridSort.gif
|
96
|
+
- lib/generators/already_grid_assets/templates/gridSortAsc.gif
|
97
|
+
- lib/generators/already_grid_assets/templates/gridSortDesc.gif
|
98
|
+
- lib/generators/already_grid_assets/templates/guilded.already_grid.js
|
99
|
+
- lib/generators/already_grid_assets/templates/guilded.already_grid.min.js
|
100
|
+
- lib/generators/already_grid_assets/templates/jquery-already_grid-0.1.js
|
101
|
+
- lib/generators/already_grid_assets/templates/jquery-already_grid-0.1.min.js
|
75
102
|
- rails_generators/already_grid_assets/already_grid_assets_generator.rb
|
76
103
|
- rails_generators/already_grid_assets/templates/default.css
|
77
104
|
- rails_generators/already_grid_assets/templates/gridHeadBg.gif
|
@@ -85,6 +112,9 @@ files:
|
|
85
112
|
- script/console
|
86
113
|
- script/destroy
|
87
114
|
- script/generate
|
115
|
+
- spec/generators/already_grid_assets_generator_spec.rb
|
116
|
+
- spec/spec.opts
|
117
|
+
- spec/spec_helper.rb
|
88
118
|
- tasks/rspec.rake
|
89
119
|
has_rdoc: true
|
90
120
|
homepage: http://github.com/midas/g_already_grid
|
@@ -99,20 +129,23 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
129
|
requirements:
|
100
130
|
- - ">="
|
101
131
|
- !ruby/object:Gem::Version
|
132
|
+
segments:
|
133
|
+
- 0
|
102
134
|
version: "0"
|
103
|
-
version:
|
104
135
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
136
|
requirements:
|
106
137
|
- - ">="
|
107
138
|
- !ruby/object:Gem::Version
|
139
|
+
segments:
|
140
|
+
- 0
|
108
141
|
version: "0"
|
109
|
-
version:
|
110
142
|
requirements: []
|
111
143
|
|
112
144
|
rubyforge_project:
|
113
|
-
rubygems_version: 1.3.
|
145
|
+
rubygems_version: 1.3.6
|
114
146
|
signing_key:
|
115
147
|
specification_version: 3
|
116
148
|
summary: A Guilded Rails component that generates a rich grid control from an ActiveRecord.
|
117
|
-
test_files:
|
118
|
-
|
149
|
+
test_files:
|
150
|
+
- spec/generators/already_grid_assets_generator_spec.rb
|
151
|
+
- spec/spec_helper.rb
|