slickgrid-rails 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +75 -0
- data/LICENSE +22 -0
- data/README.md +29 -0
- data/Rakefile +2 -0
- data/fetch.sh +8 -0
- data/lib/slickgrid-rails.rb +1 -0
- data/lib/slickgrid/rails.rb +5 -0
- data/lib/slickgrid/rails/engine.rb +7 -0
- data/lib/slickgrid/rails/version.rb +6 -0
- data/lib/slickgrid/table.rb +72 -0
- data/slickgrid-rails.gemspec +22 -0
- data/vendor/assets/images/slick/actions.gif +0 -0
- data/vendor/assets/images/slick/ajax-loader-small.gif +0 -0
- data/vendor/assets/images/slick/arrow_redo.png +0 -0
- data/vendor/assets/images/slick/arrow_right_peppermint.png +0 -0
- data/vendor/assets/images/slick/arrow_right_spearmint.png +0 -0
- data/vendor/assets/images/slick/arrow_undo.png +0 -0
- data/vendor/assets/images/slick/bullet_blue.png +0 -0
- data/vendor/assets/images/slick/bullet_star.png +0 -0
- data/vendor/assets/images/slick/bullet_toggle_minus.png +0 -0
- data/vendor/assets/images/slick/bullet_toggle_plus.png +0 -0
- data/vendor/assets/images/slick/calendar.gif +0 -0
- data/vendor/assets/images/slick/collapse.gif +0 -0
- data/vendor/assets/images/slick/comment_yellow.gif +0 -0
- data/vendor/assets/images/slick/down.gif +0 -0
- data/vendor/assets/images/slick/drag-handle.png +0 -0
- data/vendor/assets/images/slick/editor-helper-bg.gif +0 -0
- data/vendor/assets/images/slick/expand.gif +0 -0
- data/vendor/assets/images/slick/header-bg.gif +0 -0
- data/vendor/assets/images/slick/header-columns-bg.gif +0 -0
- data/vendor/assets/images/slick/header-columns-over-bg.gif +0 -0
- data/vendor/assets/images/slick/help.png +0 -0
- data/vendor/assets/images/slick/info.gif +0 -0
- data/vendor/assets/images/slick/listview.gif +0 -0
- data/vendor/assets/images/slick/pencil.gif +0 -0
- data/vendor/assets/images/slick/row-over-bg.gif +0 -0
- data/vendor/assets/images/slick/sort-asc.gif +0 -0
- data/vendor/assets/images/slick/sort-asc.png +0 -0
- data/vendor/assets/images/slick/sort-desc.gif +0 -0
- data/vendor/assets/images/slick/sort-desc.png +0 -0
- data/vendor/assets/images/slick/stripes.png +0 -0
- data/vendor/assets/images/slick/tag_red.png +0 -0
- data/vendor/assets/images/slick/tick.png +0 -0
- data/vendor/assets/images/slick/user_identity.gif +0 -0
- data/vendor/assets/images/slick/user_identity_plus.gif +0 -0
- data/vendor/assets/javascripts/slick.js +4 -0
- data/vendor/assets/javascripts/slick/controls/columnpicker.js +106 -0
- data/vendor/assets/javascripts/slick/controls/pager.js +151 -0
- data/vendor/assets/javascripts/slick/core.js +424 -0
- data/vendor/assets/javascripts/slick/dataview.js +908 -0
- data/vendor/assets/javascripts/slick/editors.js +512 -0
- data/vendor/assets/javascripts/slick/formatters.js +55 -0
- data/vendor/assets/javascripts/slick/grid.js +2783 -0
- data/vendor/assets/javascripts/slick/groupitemmetadataprovider.js +139 -0
- data/vendor/assets/javascripts/slick/plugins/autotooltips.js +48 -0
- data/vendor/assets/javascripts/slick/plugins/cellcopymanager.js +86 -0
- data/vendor/assets/javascripts/slick/plugins/cellrangedecorator.js +64 -0
- data/vendor/assets/javascripts/slick/plugins/cellrangeselector.js +112 -0
- data/vendor/assets/javascripts/slick/plugins/cellselectionmodel.js +92 -0
- data/vendor/assets/javascripts/slick/plugins/checkboxselectcolumn.js +154 -0
- data/vendor/assets/javascripts/slick/plugins/rowmovemanager.js +132 -0
- data/vendor/assets/javascripts/slick/plugins/rowselectionmodel.js +187 -0
- data/vendor/assets/javascripts/slick/remotemodel.js +164 -0
- data/vendor/assets/stylesheets/slick/controls/columnpicker.css +30 -0
- data/vendor/assets/stylesheets/slick/controls/pager.css.scss +41 -0
- data/vendor/assets/stylesheets/slick/default-theme.css.scss +104 -0
- data/vendor/assets/stylesheets/slick/grid.css.scss +158 -0
- metadata +158 -0
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm use --create ruby-1.9.3-p0@slickgrid-rails
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
slickgrid-rails (0.1.0)
|
5
|
+
jquery-plugins-rails
|
6
|
+
jquery-rails
|
7
|
+
railties (~> 3.0)
|
8
|
+
sass-rails
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
actionpack (3.2.1)
|
14
|
+
activemodel (= 3.2.1)
|
15
|
+
activesupport (= 3.2.1)
|
16
|
+
builder (~> 3.0.0)
|
17
|
+
erubis (~> 2.7.0)
|
18
|
+
journey (~> 1.0.1)
|
19
|
+
rack (~> 1.4.0)
|
20
|
+
rack-cache (~> 1.1)
|
21
|
+
rack-test (~> 0.6.1)
|
22
|
+
sprockets (~> 2.1.2)
|
23
|
+
activemodel (3.2.1)
|
24
|
+
activesupport (= 3.2.1)
|
25
|
+
builder (~> 3.0.0)
|
26
|
+
activesupport (3.2.1)
|
27
|
+
i18n (~> 0.6)
|
28
|
+
multi_json (~> 1.0)
|
29
|
+
builder (3.0.0)
|
30
|
+
erubis (2.7.0)
|
31
|
+
hike (1.2.1)
|
32
|
+
i18n (0.6.0)
|
33
|
+
journey (1.0.1)
|
34
|
+
jquery-plugins-rails (0.1.0)
|
35
|
+
jquery-rails
|
36
|
+
railties (~> 3.0)
|
37
|
+
jquery-rails (2.0.0)
|
38
|
+
railties (>= 3.2.0.beta, < 5.0)
|
39
|
+
thor (~> 0.14)
|
40
|
+
json (1.6.5)
|
41
|
+
multi_json (1.0.4)
|
42
|
+
rack (1.4.1)
|
43
|
+
rack-cache (1.1)
|
44
|
+
rack (>= 0.4)
|
45
|
+
rack-ssl (1.3.2)
|
46
|
+
rack
|
47
|
+
rack-test (0.6.1)
|
48
|
+
rack (>= 1.0)
|
49
|
+
railties (3.2.1)
|
50
|
+
actionpack (= 3.2.1)
|
51
|
+
activesupport (= 3.2.1)
|
52
|
+
rack-ssl (~> 1.3.2)
|
53
|
+
rake (>= 0.8.7)
|
54
|
+
rdoc (~> 3.4)
|
55
|
+
thor (~> 0.14.6)
|
56
|
+
rake (0.9.2.2)
|
57
|
+
rdoc (3.12)
|
58
|
+
json (~> 1.4)
|
59
|
+
sass (3.1.15)
|
60
|
+
sass-rails (3.2.4)
|
61
|
+
railties (~> 3.2.0)
|
62
|
+
sass (>= 3.1.10)
|
63
|
+
tilt (~> 1.3)
|
64
|
+
sprockets (2.1.2)
|
65
|
+
hike (~> 1.2)
|
66
|
+
rack (~> 1.0)
|
67
|
+
tilt (~> 1.1, != 1.3.0)
|
68
|
+
thor (0.14.6)
|
69
|
+
tilt (1.3.3)
|
70
|
+
|
71
|
+
PLATFORMS
|
72
|
+
ruby
|
73
|
+
|
74
|
+
DEPENDENCIES
|
75
|
+
slickgrid-rails!
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 madvertise Mobile Advertising GmbH
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# SlickGrid::Rails
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'slickgrid-rails'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install slickgrid-rails
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/fetch.sh
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "slickgrid/rails"
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module SlickGrid
|
2
|
+
class Table
|
3
|
+
|
4
|
+
class << self
|
5
|
+
attr_reader :columns
|
6
|
+
|
7
|
+
def register_column(name, options={})
|
8
|
+
@columns ||= {}
|
9
|
+
@columns[name] = options
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_accessor :rows
|
14
|
+
|
15
|
+
def initialize(collection, i18n_scope="")
|
16
|
+
@collection = collection
|
17
|
+
@i18n_scope = i18n_scope
|
18
|
+
@hidden_columns = [:id]
|
19
|
+
end
|
20
|
+
|
21
|
+
def columns
|
22
|
+
self.class.columns
|
23
|
+
end
|
24
|
+
|
25
|
+
def hide_column(name)
|
26
|
+
@hidden_columns |= [name.to_sym]
|
27
|
+
end
|
28
|
+
|
29
|
+
def active_columns
|
30
|
+
columns.keys - @hidden_columns
|
31
|
+
end
|
32
|
+
|
33
|
+
def as_json
|
34
|
+
{
|
35
|
+
columns: generate_columns,
|
36
|
+
rows: generate_rows,
|
37
|
+
}
|
38
|
+
end
|
39
|
+
|
40
|
+
protected
|
41
|
+
|
42
|
+
def generate_columns
|
43
|
+
active_columns.map do |column|
|
44
|
+
options = columns[column][:options] || {}
|
45
|
+
{ :id => column, :field => column, :name => column }.merge(options)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def generate_rows
|
50
|
+
@collection.map do |obj|
|
51
|
+
generate_row(obj)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def generate_row(obj)
|
56
|
+
Hash[columns.map do |name, options|
|
57
|
+
[name, generate_cell(obj, name, options)]
|
58
|
+
end]
|
59
|
+
end
|
60
|
+
|
61
|
+
def generate_cell(obj, name, options)
|
62
|
+
generator = options[:generator]
|
63
|
+
|
64
|
+
if generator and generator.respond_to?(:call)
|
65
|
+
generator.call(obj)
|
66
|
+
else
|
67
|
+
obj.send(name)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/slickgrid/rails/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "slickgrid-rails"
|
6
|
+
gem.version = SlickGrid::Rails::VERSION
|
7
|
+
gem.authors = ["Benedikt Böhm"]
|
8
|
+
gem.email = ["bb@xnull.de"]
|
9
|
+
gem.description = %q{SlickGrid Integration for Rails 3.x}
|
10
|
+
gem.summary = %q{SlickGrid Integration for Rails 3.x}
|
11
|
+
gem.homepage = "https://github.com/madvertise/slickgrid-rails"
|
12
|
+
|
13
|
+
gem.add_dependency "railties", "~> 3.0"
|
14
|
+
gem.add_dependency "jquery-rails"
|
15
|
+
gem.add_dependency "jquery-plugins-rails"
|
16
|
+
gem.add_dependency "sass-rails"
|
17
|
+
|
18
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
gem.files = `git ls-files`.split("\n")
|
20
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
21
|
+
gem.require_paths = ["lib"]
|
22
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,106 @@
|
|
1
|
+
(function ($) {
|
2
|
+
function SlickColumnPicker(columns, grid, options) {
|
3
|
+
var $menu;
|
4
|
+
|
5
|
+
var defaults = {
|
6
|
+
fadeSpeed:250
|
7
|
+
};
|
8
|
+
|
9
|
+
function init() {
|
10
|
+
grid.onHeaderContextMenu.subscribe(handleHeaderContextMenu);
|
11
|
+
options = $.extend({}, defaults, options);
|
12
|
+
|
13
|
+
$menu = $("<span class='slick-columnpicker' style='display:none;position:absolute;z-index:20;' />").appendTo(document.body);
|
14
|
+
|
15
|
+
$menu.bind("mouseleave", function (e) {
|
16
|
+
$(this).fadeOut(options.fadeSpeed)
|
17
|
+
});
|
18
|
+
$menu.bind("click", updateColumn);
|
19
|
+
|
20
|
+
}
|
21
|
+
|
22
|
+
function handleHeaderContextMenu(e, args) {
|
23
|
+
e.preventDefault();
|
24
|
+
$menu.empty();
|
25
|
+
|
26
|
+
var $li, $input;
|
27
|
+
for (var i = 0; i < columns.length; i++) {
|
28
|
+
$li = $("<li />").appendTo($menu);
|
29
|
+
|
30
|
+
$input = $("<input type='checkbox' />")
|
31
|
+
.attr("id", "columnpicker_" + i)
|
32
|
+
.data("id", columns[i].id)
|
33
|
+
.appendTo($li);
|
34
|
+
|
35
|
+
if (grid.getColumnIndex(columns[i].id) != null) {
|
36
|
+
$input.attr("checked", "checked");
|
37
|
+
}
|
38
|
+
|
39
|
+
$("<label for='columnpicker_" + i + "' />")
|
40
|
+
.text(columns[i].name)
|
41
|
+
.appendTo($li);
|
42
|
+
}
|
43
|
+
|
44
|
+
$("<hr/>").appendTo($menu);
|
45
|
+
$li = $("<li />").appendTo($menu);
|
46
|
+
$input = $("<input type='checkbox' id='autoresize' />").appendTo($li);
|
47
|
+
$("<label for='autoresize'>Force Fit Columns</label>").appendTo($li);
|
48
|
+
if (grid.getOptions().forceFitColumns) {
|
49
|
+
$input.attr("checked", "checked");
|
50
|
+
}
|
51
|
+
|
52
|
+
$li = $("<li />").appendTo($menu);
|
53
|
+
$input = $("<input type='checkbox' id='syncresize' />").appendTo($li);
|
54
|
+
$("<label for='syncresize'>Synchronous Resizing</label>").appendTo($li);
|
55
|
+
if (grid.getOptions().syncColumnCellResize) {
|
56
|
+
$input.attr("checked", "checked");
|
57
|
+
}
|
58
|
+
|
59
|
+
$menu
|
60
|
+
.css("top", e.pageY - 10)
|
61
|
+
.css("left", e.pageX - 10)
|
62
|
+
.fadeIn(options.fadeSpeed);
|
63
|
+
}
|
64
|
+
|
65
|
+
function updateColumn(e) {
|
66
|
+
if (e.target.id == 'autoresize') {
|
67
|
+
if (e.target.checked) {
|
68
|
+
grid.setOptions({forceFitColumns:true});
|
69
|
+
grid.autosizeColumns();
|
70
|
+
} else {
|
71
|
+
grid.setOptions({forceFitColumns:false});
|
72
|
+
}
|
73
|
+
return;
|
74
|
+
}
|
75
|
+
|
76
|
+
if (e.target.id == 'syncresize') {
|
77
|
+
if (e.target.checked) {
|
78
|
+
grid.setOptions({syncColumnCellResize:true});
|
79
|
+
} else {
|
80
|
+
grid.setOptions({syncColumnCellResize:false});
|
81
|
+
}
|
82
|
+
return;
|
83
|
+
}
|
84
|
+
|
85
|
+
if ($(e.target).is(":checkbox")) {
|
86
|
+
if ($menu.find(":checkbox:checked").length == 0) {
|
87
|
+
$(e.target).attr("checked", "checked");
|
88
|
+
return;
|
89
|
+
}
|
90
|
+
|
91
|
+
var visibleColumns = [];
|
92
|
+
$menu.find(":checkbox[id^=columnpicker]").each(function (i, e) {
|
93
|
+
if ($(this).is(":checked")) {
|
94
|
+
visibleColumns.push(columns[i]);
|
95
|
+
}
|
96
|
+
});
|
97
|
+
grid.setColumns(visibleColumns);
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
init();
|
102
|
+
}
|
103
|
+
|
104
|
+
// Slick.Controls.ColumnPicker
|
105
|
+
$.extend(true, window, { Slick:{ Controls:{ ColumnPicker:SlickColumnPicker }}});
|
106
|
+
})(jQuery);
|