rails_jq_grid 0.0.3.pre1 → 0.0.3.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +21 -1
- data/Rakefile +25 -5
- data/VERSION +1 -1
- data/app/helpers/rails_jq_grid/jq_grid_css_helper.rb +10 -4
- data/app/helpers/rails_jq_grid/jq_grid_helper.rb +4 -1
- data/app/helpers/rails_jq_grid/jq_grid_js_helper.rb +15 -4
- data/app/models/rails_jq_grid/jq_grid.rb +2 -2
- data/app/models/rails_jq_grid/jq_grid_nav_grid.rb +66 -2
- data/public/javascripts/rails-jqgrid/multiselect/MIT-LICENSE.txt +20 -0
- data/public/javascripts/rails-jqgrid/multiselect/ui.multiselect.js +319 -0
- data/public/stylesheets/rails-jqgrid/multiselect/MIT-LICENSE.txt +20 -0
- data/public/stylesheets/rails-jqgrid/multiselect/ui.multiselect.css +30 -0
- data/rails_jq_grid.gemspec +6 -2
- metadata +8 -4
data/README.rdoc
CHANGED
@@ -65,7 +65,7 @@ RAILS_ROOT\public\stylesheets\rails-jqgrid\themes
|
|
65
65
|
a.gridview true
|
66
66
|
a.multiselect false
|
67
67
|
|
68
|
-
a.on_select_row
|
68
|
+
a.on_select_row << "function(){alert('test');}"
|
69
69
|
|
70
70
|
a.nav_grid do |n|
|
71
71
|
# Defaults
|
@@ -93,6 +93,26 @@ RAILS_ROOT\public\stylesheets\rails-jqgrid\themes
|
|
93
93
|
n.prm_view do |p|
|
94
94
|
end
|
95
95
|
|
96
|
+
#Custom buttons
|
97
|
+
n.custom_button do |b|
|
98
|
+
b.caption "Columns"
|
99
|
+
b.title "Reorder Columns"
|
100
|
+
b.on_click_button << "function (){ jQuery('##{a.dom_id}').jqGrid('columnChooser'); } "
|
101
|
+
end
|
102
|
+
|
103
|
+
#Toolbar searching
|
104
|
+
n.filter_toolbar(true) do |filter_toolbar,b_t, b_c|
|
105
|
+
filter_toolbar.before_search << "function (){ alert('Before Search');}"
|
106
|
+
|
107
|
+
b_t.caption "Toggle"
|
108
|
+
b_t.title "Toggle Search Toolbar"
|
109
|
+
b_t.buttonicon 'ui-icon-pin-s'
|
110
|
+
|
111
|
+
b_c.caption "Clear"
|
112
|
+
b_c.title "Clear Search"
|
113
|
+
b_c.buttonicon 'ui-icon-refresh'
|
114
|
+
end
|
115
|
+
|
96
116
|
end
|
97
117
|
|
98
118
|
|
data/Rakefile
CHANGED
@@ -13,6 +13,8 @@ require "rake"
|
|
13
13
|
require 'rake/testtask'
|
14
14
|
require 'rake/rdoctask'
|
15
15
|
|
16
|
+
SOURCE_PATHS=['lib/**/*.rb', 'app/**/*.rb' ]
|
17
|
+
|
16
18
|
begin
|
17
19
|
require "jeweler"
|
18
20
|
Jeweler::Tasks.new do |gem|
|
@@ -22,7 +24,7 @@ begin
|
|
22
24
|
gem.email = "dieter.spaeth@gmx.de"
|
23
25
|
gem.authors = ["Dieter Spaeth"]
|
24
26
|
gem.homepage = "http://github.com/consu/rails-jqgrid"
|
25
|
-
gem.add_development_dependency "rspec", ">= 1.2.9"
|
27
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
26
28
|
gem.files = Dir["*", "{lib}/**/*", "{public}/**/*", "{spec}/**/*", "{app}/**/*"]
|
27
29
|
end
|
28
30
|
|
@@ -48,11 +50,29 @@ task :spec => :check_dependencies
|
|
48
50
|
task :default => :spec
|
49
51
|
|
50
52
|
require 'rake/rdoctask'
|
53
|
+
|
54
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
55
|
+
title = "RailsJgGrid #{version}"
|
51
56
|
Rake::RDocTask.new do |rdoc|
|
52
|
-
|
57
|
+
|
53
58
|
|
54
59
|
rdoc.rdoc_dir = 'rdoc'
|
55
|
-
rdoc.title =
|
56
|
-
rdoc.rdoc_files.include('README*')
|
57
|
-
|
60
|
+
rdoc.title = title
|
61
|
+
rdoc.rdoc_files.include('README*', *SOURCE_PATHS)
|
62
|
+
end
|
63
|
+
|
64
|
+
begin
|
65
|
+
|
66
|
+
require 'yard'
|
67
|
+
YARD::Rake::YardocTask.new do |t|
|
68
|
+
t.files = [SOURCE_PATHS] # optional
|
69
|
+
t.options = ['--title', title, '--files', 'GPL-LICENSE,COPYRIGHT.txt'] # optional
|
70
|
+
end
|
71
|
+
|
72
|
+
rescue LoadError
|
73
|
+
desc 'Generate YARD Documentation (not available)'
|
74
|
+
task :doc do
|
75
|
+
puts 'YARD is not available. Install it using `gem install yard`.'
|
76
|
+
end
|
58
77
|
end
|
78
|
+
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.3.
|
1
|
+
0.0.3.pre2
|
@@ -10,16 +10,18 @@
|
|
10
10
|
module RailsJqGrid
|
11
11
|
module JqGridCssHelper
|
12
12
|
STYLESHEETS_BASE = "/stylesheets/rails-jqgrid"
|
13
|
-
JQUERY_UI_THEMES_BASE = STYLESHEETS_BASE + "/themes"
|
14
|
-
JQUERY_UI_VERSION = "1.8.4"
|
13
|
+
JQUERY_UI_THEMES_BASE = STYLESHEETS_BASE + "/themes"
|
15
14
|
|
16
15
|
# Includes the following stylesheets:
|
17
16
|
# * ui.jqgrid.css
|
18
17
|
# * /stylesheets/rails-jqgrid/themes/[theme_name]/jquery-ui-...custom.css
|
19
18
|
# options:: :theme name of the theme folder, default start
|
20
19
|
def jqgrid_stylesheets_tags(options={})
|
21
|
-
[
|
22
|
-
|
20
|
+
["<!-- JQGRID CSS INCLUDES START-->",
|
21
|
+
jqgrid_ui_stylesheet_tag(options),
|
22
|
+
jquery_ui_stylesheet_tag(options),
|
23
|
+
jqgrid_ui_multi_select_stylesheet_tag(options),
|
24
|
+
"<!-- JQGRID CSS INCLUDES ENDS-->"
|
23
25
|
].join("\n").html_safe
|
24
26
|
end
|
25
27
|
|
@@ -32,6 +34,10 @@ module RailsJqGrid
|
|
32
34
|
(stylesheet_link_tag JQUERY_UI_THEMES_BASE + "/#{jquery_theme(options)}" +"/jquery-ui-#{JQUERY_UI_VERSION}.custom.css").html_safe
|
33
35
|
end
|
34
36
|
|
37
|
+
def jqgrid_ui_multi_select_stylesheet_tag(options={})
|
38
|
+
(stylesheet_link_tag STYLESHEETS_BASE + "/multiselect/ui.multiselect.css").html_safe
|
39
|
+
end
|
40
|
+
|
35
41
|
def jquery_theme(options={})
|
36
42
|
options[:theme] || "start"
|
37
43
|
end
|
@@ -10,8 +10,7 @@
|
|
10
10
|
|
11
11
|
module RailsJqGrid
|
12
12
|
module JqGridJsHelper
|
13
|
-
JS_BASE = "/javascripts/rails-jqgrid"
|
14
|
-
JQUERY_VERSION = "1.4.2"
|
13
|
+
JS_BASE = "/javascripts/rails-jqgrid"
|
15
14
|
|
16
15
|
# Includes the following javascript libraries:
|
17
16
|
# * jquery-...min.js
|
@@ -19,9 +18,13 @@ module RailsJqGrid
|
|
19
18
|
# * grid.locale-...js
|
20
19
|
# options:: :local local to use, default :en
|
21
20
|
def jqgrid_js_tags(options={})
|
22
|
-
[
|
21
|
+
["<!-- JQGRID JS INCLUDES START-->",
|
22
|
+
jquery_js_tag,
|
23
|
+
jquery_ui_js_tag,
|
23
24
|
jqgrid_i18n_js_tag(options),
|
24
|
-
|
25
|
+
jquery_ui_multiselect_js_tag,
|
26
|
+
jqgrid_js_tag,
|
27
|
+
"<!-- JQGRID JS INCLUDES END -->"
|
25
28
|
].join("\n").html_safe
|
26
29
|
end
|
27
30
|
|
@@ -34,6 +37,14 @@ module RailsJqGrid
|
|
34
37
|
(javascript_include_tag JS_BASE + "/jquery.jqGrid.min.js").html_safe
|
35
38
|
end
|
36
39
|
|
40
|
+
def jquery_ui_js_tag
|
41
|
+
(javascript_include_tag JS_BASE + "/jquery-ui-#{JQUERY_UI_VERSION}.custom.min.js").html_safe
|
42
|
+
end
|
43
|
+
|
44
|
+
def jquery_ui_multiselect_js_tag
|
45
|
+
(javascript_include_tag JS_BASE + "/multiselect/ui.multiselect.js").html_safe
|
46
|
+
end
|
47
|
+
|
37
48
|
def jqgrid_i18n_js_tag(options={})
|
38
49
|
options[:local] ||= I18n.locale rescue :en
|
39
50
|
(javascript_include_tag JS_BASE + "/i18n/grid.locale-#{options[:local]}.js").html_safe
|
@@ -100,7 +100,7 @@ module RailsJqGrid
|
|
100
100
|
end
|
101
101
|
|
102
102
|
def pager_id
|
103
|
-
"#{dom_id}
|
103
|
+
"#{dom_id}_pager"
|
104
104
|
end
|
105
105
|
|
106
106
|
def columns(*fields,&block)
|
@@ -186,7 +186,7 @@ module RailsJqGrid
|
|
186
186
|
self.nav_grid_data.restfull = is_restful?
|
187
187
|
|
188
188
|
nav_grid_data.to_js
|
189
|
-
end
|
189
|
+
end
|
190
190
|
|
191
191
|
def is_restful?
|
192
192
|
self.options[:restful]
|
@@ -8,6 +8,8 @@
|
|
8
8
|
# Copyright:: Copyright (c) 2010 Dieter Spaeth
|
9
9
|
|
10
10
|
module RailsJqGrid
|
11
|
+
# Handles the creation of JQGrid navigator
|
12
|
+
# @see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:navigator
|
11
13
|
class JqGridNavGrid
|
12
14
|
include JqGridMethodMissing
|
13
15
|
|
@@ -25,7 +27,7 @@ module RailsJqGrid
|
|
25
27
|
|
26
28
|
attr_accessor :dom_id, :pager_id, :restfull,
|
27
29
|
:prm_edit_data, :prm_add_data, :prm_del_data, :prm_search_data,
|
28
|
-
:prm_view_data
|
30
|
+
:prm_view_data, :filter_toolbar_data, :custom_buttons
|
29
31
|
|
30
32
|
|
31
33
|
|
@@ -39,32 +41,79 @@ module RailsJqGrid
|
|
39
41
|
self.prm_search_data = JqGridNavGridParameter.new(DEFAULT_PRM_OPTIONS)
|
40
42
|
self.prm_view_data = JqGridNavGridParameter.new(DEFAULT_PRM_OPTIONS)
|
41
43
|
|
44
|
+
self.custom_buttons = []
|
45
|
+
self.filter_toolbar_data = nil
|
46
|
+
|
42
47
|
self.init_jq_grid_js_options DEFAULT_OPTIONS
|
43
48
|
|
44
49
|
option_block.call(self) if block_given?
|
45
50
|
end
|
46
51
|
|
52
|
+
# @param [Block] options for edit action
|
53
|
+
# @see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing%29?
|
47
54
|
def prm_edit(&block)
|
48
55
|
prm_edit_data.set_jqgrid_options(&block)
|
49
56
|
end
|
50
57
|
|
58
|
+
# @param [Block] options for add action
|
59
|
+
# @see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing%29?
|
51
60
|
def prm_add(&block)
|
52
61
|
prm_add_data.set_jqgrid_options(&block)
|
53
62
|
end
|
54
63
|
|
64
|
+
# @param [Block] options for delete action
|
65
|
+
# @see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing%29?
|
55
66
|
def prm_del(&block)
|
56
67
|
prm_del_data.set_jqgrid_options(&block)
|
57
68
|
end
|
58
69
|
|
70
|
+
# @param [Block] options for search action
|
71
|
+
# @see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing%29?
|
59
72
|
def prm_search(&block)
|
60
73
|
prm_search_data.set_jqgrid_options(&block)
|
61
74
|
end
|
62
75
|
|
76
|
+
# @see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:form_editing%29?
|
63
77
|
def prm_view(&block)
|
64
78
|
prm_view_data.set_jqgrid_options(&block)
|
65
79
|
end
|
66
80
|
|
81
|
+
# Creates a custom button for the navigator
|
82
|
+
#
|
83
|
+
# @yield [custom_button] creates a custom button with given options
|
84
|
+
# @see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:custom_buttons
|
85
|
+
def custom_button(&block)
|
86
|
+
self.custom_buttons << JqGridNavGridParameter.new(&block)
|
87
|
+
end
|
88
|
+
|
89
|
+
# Creates a custom button for the navigator
|
90
|
+
#
|
91
|
+
# @yield [filter_toolbar, toggle_button, clear_button] creates the toggle- and clear-button
|
92
|
+
# @params [true, false] create_clear_button determines if the clear button should
|
93
|
+
# be created as well. Default true.
|
94
|
+
# @see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:toolbar_searching&s[]=toggletoolbar
|
95
|
+
def filter_toolbar(create_clear_button=true, &block)
|
96
|
+
self.filter_toolbar_data = JqGridNavGridParameter.new()
|
97
|
+
toggle_button = JqGridNavGridParameter.new()
|
98
|
+
clear_button = JqGridNavGridParameter.new()
|
99
|
+
|
100
|
+
block.call(self.filter_toolbar_data, toggle_button, clear_button)
|
101
|
+
|
102
|
+
toggle_button.on_click_button << "function (){ var sgrid = jQuery('##{dom_id}')[0];
|
103
|
+
sgrid.toggleToolbar(); } "
|
104
|
+
|
105
|
+
clear_button.on_click_button << "function (){ var sgrid = jQuery('##{dom_id}')[0];
|
106
|
+
sgrid.clearToolbar(); } "
|
107
|
+
|
108
|
+
|
109
|
+
self.custom_buttons << toggle_button
|
110
|
+
self.custom_buttons << clear_button if create_clear_button
|
67
111
|
|
112
|
+
end
|
113
|
+
|
114
|
+
# Creates the js for a navigator
|
115
|
+
# @see http://www.trirand.com/jqgridwiki/doku.php?id=wiki:navigator
|
116
|
+
# @return [String] Contains the javascript for the navigator
|
68
117
|
def to_js
|
69
118
|
params=[nav_grid_parameters]
|
70
119
|
|
@@ -78,9 +127,24 @@ module RailsJqGrid
|
|
78
127
|
prm_search_data.to_js,
|
79
128
|
prm_view_data.to_js]).flatten!
|
80
129
|
|
81
|
-
|
130
|
+
js_parts = []
|
131
|
+
js_parts << <<-EO_JS
|
82
132
|
jQuery("##{dom_id}").jqGrid('navGrid','##{pager_id}',#{params.join(",\n")} );
|
83
133
|
EO_JS
|
134
|
+
|
135
|
+
self.custom_buttons.each do |custom_button|
|
136
|
+
js_parts << <<-EO_JS
|
137
|
+
jQuery("##{dom_id}").jqGrid('navButtonAdd','##{pager_id}',#{custom_button.to_js} );
|
138
|
+
EO_JS
|
139
|
+
end
|
140
|
+
|
141
|
+
if self.filter_toolbar_data
|
142
|
+
js_parts << <<-EO_JS
|
143
|
+
jQuery("##{dom_id}").jqGrid('filterToolbar',#{self.filter_toolbar_data.to_js});
|
144
|
+
EO_JS
|
145
|
+
end
|
146
|
+
|
147
|
+
js_parts.join("\n")
|
84
148
|
end
|
85
149
|
|
86
150
|
def nav_grid_parameters
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Michael Aufreiter, http://www.quasipartikel.at
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,319 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery UI Multiselect
|
3
|
+
*
|
4
|
+
* Authors:
|
5
|
+
* Michael Aufreiter (quasipartikel.at)
|
6
|
+
* Yanick Rochon (yanick.rochon[at]gmail[dot]com)
|
7
|
+
*
|
8
|
+
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
9
|
+
* and GPL (GPL-LICENSE.txt) licenses.
|
10
|
+
*
|
11
|
+
* http://www.quasipartikel.at/multiselect/
|
12
|
+
*
|
13
|
+
*
|
14
|
+
* Depends:
|
15
|
+
* ui.core.js
|
16
|
+
* ui.sortable.js
|
17
|
+
*
|
18
|
+
* Optional:
|
19
|
+
* localization (http://plugins.jquery.com/project/localisation)
|
20
|
+
* scrollTo (http://plugins.jquery.com/project/ScrollTo)
|
21
|
+
*
|
22
|
+
* Todo:
|
23
|
+
* Make batch actions faster
|
24
|
+
* Implement dynamic insertion through remote calls
|
25
|
+
*/
|
26
|
+
|
27
|
+
|
28
|
+
(function($) {
|
29
|
+
|
30
|
+
$.widget("ui.multiselect", {
|
31
|
+
options: {
|
32
|
+
sortable: true,
|
33
|
+
searchable: true,
|
34
|
+
animated: 'fast',
|
35
|
+
show: 'slideDown',
|
36
|
+
hide: 'slideUp',
|
37
|
+
dividerLocation: 0.6,
|
38
|
+
nodeComparator: function(node1,node2) {
|
39
|
+
var text1 = node1.text(),
|
40
|
+
text2 = node2.text();
|
41
|
+
return text1 == text2 ? 0 : (text1 < text2 ? -1 : 1);
|
42
|
+
}
|
43
|
+
},
|
44
|
+
_create: function() {
|
45
|
+
this.element.hide();
|
46
|
+
this.id = this.element.attr("id");
|
47
|
+
this.container = $('<div class="ui-multiselect ui-helper-clearfix ui-widget"></div>').insertAfter(this.element);
|
48
|
+
this.count = 0; // number of currently selected options
|
49
|
+
this.selectedContainer = $('<div class="selected"></div>').appendTo(this.container);
|
50
|
+
this.availableContainer = $('<div class="available"></div>').appendTo(this.container);
|
51
|
+
this.selectedActions = $('<div class="actions ui-widget-header ui-helper-clearfix"><span class="count">0 '+$.ui.multiselect.locale.itemsCount+'</span><a href="#" class="remove-all">'+$.ui.multiselect.locale.removeAll+'</a></div>').appendTo(this.selectedContainer);
|
52
|
+
this.availableActions = $('<div class="actions ui-widget-header ui-helper-clearfix"><input type="text" class="search empty ui-widget-content ui-corner-all"/><a href="#" class="add-all">'+$.ui.multiselect.locale.addAll+'</a></div>').appendTo(this.availableContainer);
|
53
|
+
this.selectedList = $('<ul class="selected connected-list"><li class="ui-helper-hidden-accessible"></li></ul>').bind('selectstart', function(){return false;}).appendTo(this.selectedContainer);
|
54
|
+
this.availableList = $('<ul class="available connected-list"><li class="ui-helper-hidden-accessible"></li></ul>').bind('selectstart', function(){return false;}).appendTo(this.availableContainer);
|
55
|
+
|
56
|
+
var that = this;
|
57
|
+
|
58
|
+
// set dimensions
|
59
|
+
this.container.width(this.element.width()+1);
|
60
|
+
this.selectedContainer.width(Math.floor(this.element.width()*this.options.dividerLocation));
|
61
|
+
this.availableContainer.width(Math.floor(this.element.width()*(1-this.options.dividerLocation)));
|
62
|
+
|
63
|
+
// fix list height to match <option> depending on their individual header's heights
|
64
|
+
this.selectedList.height(Math.max(this.element.height()-this.selectedActions.height(),1));
|
65
|
+
this.availableList.height(Math.max(this.element.height()-this.availableActions.height(),1));
|
66
|
+
|
67
|
+
if ( !this.options.animated ) {
|
68
|
+
this.options.show = 'show';
|
69
|
+
this.options.hide = 'hide';
|
70
|
+
}
|
71
|
+
|
72
|
+
// init lists
|
73
|
+
this._populateLists(this.element.find('option'));
|
74
|
+
|
75
|
+
// make selection sortable
|
76
|
+
if (this.options.sortable) {
|
77
|
+
this.selectedList.sortable({
|
78
|
+
placeholder: 'ui-state-highlight',
|
79
|
+
axis: 'y',
|
80
|
+
update: function(event, ui) {
|
81
|
+
// apply the new sort order to the original selectbox
|
82
|
+
that.selectedList.find('li').each(function() {
|
83
|
+
if ($(this).data('optionLink'))
|
84
|
+
$(this).data('optionLink').remove().appendTo(that.element);
|
85
|
+
});
|
86
|
+
},
|
87
|
+
receive: function(event, ui) {
|
88
|
+
ui.item.data('optionLink').attr('selected', true);
|
89
|
+
// increment count
|
90
|
+
that.count += 1;
|
91
|
+
that._updateCount();
|
92
|
+
// workaround, because there's no way to reference
|
93
|
+
// the new element, see http://dev.jqueryui.com/ticket/4303
|
94
|
+
that.selectedList.children('.ui-draggable').each(function() {
|
95
|
+
$(this).removeClass('ui-draggable');
|
96
|
+
$(this).data('optionLink', ui.item.data('optionLink'));
|
97
|
+
$(this).data('idx', ui.item.data('idx'));
|
98
|
+
that._applyItemState($(this), true);
|
99
|
+
});
|
100
|
+
|
101
|
+
// workaround according to http://dev.jqueryui.com/ticket/4088
|
102
|
+
setTimeout(function() { ui.item.remove(); }, 1);
|
103
|
+
}
|
104
|
+
});
|
105
|
+
}
|
106
|
+
|
107
|
+
// set up livesearch
|
108
|
+
if (this.options.searchable) {
|
109
|
+
this._registerSearchEvents(this.availableContainer.find('input.search'));
|
110
|
+
} else {
|
111
|
+
$('.search').hide();
|
112
|
+
}
|
113
|
+
|
114
|
+
// batch actions
|
115
|
+
this.container.find(".remove-all").click(function() {
|
116
|
+
that._populateLists(that.element.find('option').removeAttr('selected'));
|
117
|
+
return false;
|
118
|
+
});
|
119
|
+
|
120
|
+
this.container.find(".add-all").click(function() {
|
121
|
+
that._populateLists(that.element.find('option').attr('selected', 'selected'));
|
122
|
+
return false;
|
123
|
+
});
|
124
|
+
},
|
125
|
+
destroy: function() {
|
126
|
+
this.element.show();
|
127
|
+
this.container.remove();
|
128
|
+
|
129
|
+
$.Widget.prototype.destroy.apply(this, arguments);
|
130
|
+
},
|
131
|
+
_populateLists: function(options) {
|
132
|
+
this.selectedList.children('.ui-element').remove();
|
133
|
+
this.availableList.children('.ui-element').remove();
|
134
|
+
this.count = 0;
|
135
|
+
|
136
|
+
var that = this;
|
137
|
+
var items = $(options.map(function(i) {
|
138
|
+
var item = that._getOptionNode(this).appendTo(this.selected ? that.selectedList : that.availableList).show();
|
139
|
+
|
140
|
+
if (this.selected) that.count += 1;
|
141
|
+
that._applyItemState(item, this.selected);
|
142
|
+
item.data('idx', i);
|
143
|
+
return item[0];
|
144
|
+
}));
|
145
|
+
|
146
|
+
// update count
|
147
|
+
this._updateCount();
|
148
|
+
},
|
149
|
+
_updateCount: function() {
|
150
|
+
this.selectedContainer.find('span.count').text(this.count+" "+$.ui.multiselect.locale.itemsCount);
|
151
|
+
},
|
152
|
+
_getOptionNode: function(option) {
|
153
|
+
option = $(option);
|
154
|
+
var node = $('<li class="ui-state-default ui-element" title="'+option.text()+'"><span class="ui-icon"/>'+option.text()+'<a href="#" class="action"><span class="ui-corner-all ui-icon"/></a></li>').hide();
|
155
|
+
node.data('optionLink', option);
|
156
|
+
return node;
|
157
|
+
},
|
158
|
+
// clones an item with associated data
|
159
|
+
// didn't find a smarter away around this
|
160
|
+
_cloneWithData: function(clonee) {
|
161
|
+
var clone = clonee.clone();
|
162
|
+
clone.data('optionLink', clonee.data('optionLink'));
|
163
|
+
clone.data('idx', clonee.data('idx'));
|
164
|
+
return clone;
|
165
|
+
},
|
166
|
+
_setSelected: function(item, selected) {
|
167
|
+
item.data('optionLink').attr('selected', selected);
|
168
|
+
|
169
|
+
if (selected) {
|
170
|
+
var selectedItem = this._cloneWithData(item);
|
171
|
+
item[this.options.hide](this.options.animated, function() { $(this).remove(); });
|
172
|
+
selectedItem.appendTo(this.selectedList).hide()[this.options.show](this.options.animated);
|
173
|
+
|
174
|
+
this._applyItemState(selectedItem, true);
|
175
|
+
return selectedItem;
|
176
|
+
} else {
|
177
|
+
|
178
|
+
// look for successor based on initial option index
|
179
|
+
var items = this.availableList.find('li'), comparator = this.options.nodeComparator;
|
180
|
+
var succ = null, i = item.data('idx'), direction = comparator(item, $(items[i]));
|
181
|
+
|
182
|
+
// TODO: test needed for dynamic list populating
|
183
|
+
if ( direction ) {
|
184
|
+
while (i>=0 && i<items.length) {
|
185
|
+
direction > 0 ? i++ : i--;
|
186
|
+
if ( direction != comparator(item, $(items[i])) ) {
|
187
|
+
// going up, go back one item down, otherwise leave as is
|
188
|
+
succ = items[direction > 0 ? i : i+1];
|
189
|
+
break;
|
190
|
+
}
|
191
|
+
}
|
192
|
+
} else {
|
193
|
+
succ = items[i];
|
194
|
+
}
|
195
|
+
|
196
|
+
var availableItem = this._cloneWithData(item);
|
197
|
+
succ ? availableItem.insertBefore($(succ)) : availableItem.appendTo(this.availableList);
|
198
|
+
item[this.options.hide](this.options.animated, function() { $(this).remove(); });
|
199
|
+
availableItem.hide()[this.options.show](this.options.animated);
|
200
|
+
|
201
|
+
this._applyItemState(availableItem, false);
|
202
|
+
return availableItem;
|
203
|
+
}
|
204
|
+
},
|
205
|
+
_applyItemState: function(item, selected) {
|
206
|
+
if (selected) {
|
207
|
+
if (this.options.sortable)
|
208
|
+
item.children('span').addClass('ui-icon-arrowthick-2-n-s').removeClass('ui-helper-hidden').addClass('ui-icon');
|
209
|
+
else
|
210
|
+
item.children('span').removeClass('ui-icon-arrowthick-2-n-s').addClass('ui-helper-hidden').removeClass('ui-icon');
|
211
|
+
item.find('a.action span').addClass('ui-icon-minus').removeClass('ui-icon-plus');
|
212
|
+
this._registerRemoveEvents(item.find('a.action'));
|
213
|
+
|
214
|
+
} else {
|
215
|
+
item.children('span').removeClass('ui-icon-arrowthick-2-n-s').addClass('ui-helper-hidden').removeClass('ui-icon');
|
216
|
+
item.find('a.action span').addClass('ui-icon-plus').removeClass('ui-icon-minus');
|
217
|
+
this._registerAddEvents(item.find('a.action'));
|
218
|
+
}
|
219
|
+
|
220
|
+
this._registerHoverEvents(item);
|
221
|
+
},
|
222
|
+
// taken from John Resig's liveUpdate script
|
223
|
+
_filter: function(list) {
|
224
|
+
var input = $(this);
|
225
|
+
var rows = list.children('li'),
|
226
|
+
cache = rows.map(function(){
|
227
|
+
|
228
|
+
return $(this).text().toLowerCase();
|
229
|
+
});
|
230
|
+
|
231
|
+
var term = $.trim(input.val().toLowerCase()), scores = [];
|
232
|
+
|
233
|
+
if (!term) {
|
234
|
+
rows.show();
|
235
|
+
} else {
|
236
|
+
rows.hide();
|
237
|
+
|
238
|
+
cache.each(function(i) {
|
239
|
+
if (this.indexOf(term)>-1) { scores.push(i); }
|
240
|
+
});
|
241
|
+
|
242
|
+
$.each(scores, function() {
|
243
|
+
$(rows[this]).show();
|
244
|
+
});
|
245
|
+
}
|
246
|
+
},
|
247
|
+
_registerHoverEvents: function(elements) {
|
248
|
+
elements.removeClass('ui-state-hover');
|
249
|
+
elements.mouseover(function() {
|
250
|
+
$(this).addClass('ui-state-hover');
|
251
|
+
});
|
252
|
+
elements.mouseout(function() {
|
253
|
+
$(this).removeClass('ui-state-hover');
|
254
|
+
});
|
255
|
+
},
|
256
|
+
_registerAddEvents: function(elements) {
|
257
|
+
var that = this;
|
258
|
+
elements.click(function() {
|
259
|
+
var item = that._setSelected($(this).parent(), true);
|
260
|
+
that.count += 1;
|
261
|
+
that._updateCount();
|
262
|
+
return false;
|
263
|
+
});
|
264
|
+
|
265
|
+
// make draggable
|
266
|
+
if (this.options.sortable) {
|
267
|
+
elements.each(function() {
|
268
|
+
$(this).parent().draggable({
|
269
|
+
connectToSortable: that.selectedList,
|
270
|
+
helper: function() {
|
271
|
+
var selectedItem = that._cloneWithData($(this)).width($(this).width() - 50);
|
272
|
+
selectedItem.width($(this).width());
|
273
|
+
return selectedItem;
|
274
|
+
},
|
275
|
+
appendTo: that.container,
|
276
|
+
containment: that.container,
|
277
|
+
revert: 'invalid'
|
278
|
+
});
|
279
|
+
});
|
280
|
+
}
|
281
|
+
},
|
282
|
+
_registerRemoveEvents: function(elements) {
|
283
|
+
var that = this;
|
284
|
+
elements.click(function() {
|
285
|
+
that._setSelected($(this).parent(), false);
|
286
|
+
that.count -= 1;
|
287
|
+
that._updateCount();
|
288
|
+
return false;
|
289
|
+
});
|
290
|
+
},
|
291
|
+
_registerSearchEvents: function(input) {
|
292
|
+
var that = this;
|
293
|
+
|
294
|
+
input.focus(function() {
|
295
|
+
$(this).addClass('ui-state-active');
|
296
|
+
})
|
297
|
+
.blur(function() {
|
298
|
+
$(this).removeClass('ui-state-active');
|
299
|
+
})
|
300
|
+
.keypress(function(e) {
|
301
|
+
if (e.keyCode == 13)
|
302
|
+
return false;
|
303
|
+
})
|
304
|
+
.keyup(function() {
|
305
|
+
that._filter.apply(this, [that.availableList]);
|
306
|
+
});
|
307
|
+
}
|
308
|
+
});
|
309
|
+
|
310
|
+
$.extend($.ui.multiselect, {
|
311
|
+
locale: {
|
312
|
+
addAll:'Add all',
|
313
|
+
removeAll:'Remove all',
|
314
|
+
itemsCount:'items selected'
|
315
|
+
}
|
316
|
+
});
|
317
|
+
|
318
|
+
|
319
|
+
})(jQuery);
|
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Michael Aufreiter, http://www.quasipartikel.at
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/* Multiselect
|
2
|
+
----------------------------------*/
|
3
|
+
|
4
|
+
.ui-multiselect { border: solid 1px; font-size: 0.8em; }
|
5
|
+
.ui-multiselect ul { -moz-user-select: none; }
|
6
|
+
.ui-multiselect li { margin: 0; padding: 0; cursor: default; line-height: 20px; height: 20px; font-size: 11px; list-style: none; }
|
7
|
+
.ui-multiselect li a { color: #999; text-decoration: none; padding: 0; display: block; float: left; cursor: pointer;}
|
8
|
+
.ui-multiselect li.ui-draggable-dragging { padding-left: 10px; }
|
9
|
+
|
10
|
+
.ui-multiselect div.selected { position: relative; padding: 0; margin: 0; border: 0; float:left; }
|
11
|
+
.ui-multiselect ul.selected { position: relative; padding: 0; overflow: auto; overflow-x: hidden; background: #fff; margin: 0; list-style: none; border: 0; position: relative; width: 100%; }
|
12
|
+
.ui-multiselect ul.selected li { }
|
13
|
+
|
14
|
+
.ui-multiselect div.available { position: relative; padding: 0; margin: 0; border: 0; float:left; border-left: 1px solid; }
|
15
|
+
.ui-multiselect ul.available { position: relative; padding: 0; overflow: auto; overflow-x: hidden; background: #fff; margin: 0; list-style: none; border: 0; width: 100%; }
|
16
|
+
.ui-multiselect ul.available li { padding-left: 10px; }
|
17
|
+
|
18
|
+
.ui-multiselect .ui-state-default { border: none; margin-bottom: 1px; position: relative; padding-left: 20px;}
|
19
|
+
.ui-multiselect .ui-state-hover { border: none; }
|
20
|
+
.ui-multiselect .ui-widget-header {border: none; font-size: 11px; margin-bottom: 1px;}
|
21
|
+
|
22
|
+
.ui-multiselect .add-all { float: right; padding: 7px;}
|
23
|
+
.ui-multiselect .remove-all { float: right; padding: 7px;}
|
24
|
+
.ui-multiselect .search { float: left; padding: 4px;}
|
25
|
+
.ui-multiselect .count { float: left; padding: 7px;}
|
26
|
+
|
27
|
+
.ui-multiselect li span.ui-icon-arrowthick-2-n-s { position: absolute; left: 2px; }
|
28
|
+
.ui-multiselect li a.action { position: absolute; right: 2px; top: 2px; }
|
29
|
+
|
30
|
+
.ui-multiselect input.search { height: 14px; padding: 1px; opacity: 0.5; margin: 4px; width: 100px; }
|
data/rails_jq_grid.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rails_jq_grid}
|
8
|
-
s.version = "0.0.3.
|
8
|
+
s.version = "0.0.3.pre2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Dieter Spaeth"]
|
12
|
-
s.date = %q{2010-10-
|
12
|
+
s.date = %q{2010-10-16}
|
13
13
|
s.description = %q{This gems is a Rails 3 Enginge that helps you to create jqGrid. It's bundled with jqGrid and some themes.}
|
14
14
|
s.email = %q{dieter.spaeth@gmx.de}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -68,6 +68,8 @@ Gem::Specification.new do |s|
|
|
68
68
|
"public/javascripts/rails-jqgrid/jquery-1.4.2.min.js",
|
69
69
|
"public/javascripts/rails-jqgrid/jquery-ui-1.8.4.custom.min.js",
|
70
70
|
"public/javascripts/rails-jqgrid/jquery.jqGrid.min.js",
|
71
|
+
"public/javascripts/rails-jqgrid/multiselect/MIT-LICENSE.txt",
|
72
|
+
"public/javascripts/rails-jqgrid/multiselect/ui.multiselect.js",
|
71
73
|
"public/javascripts/rails-jqgrid/src/JsonXml.js",
|
72
74
|
"public/javascripts/rails-jqgrid/src/css/ellipsis-xbl.xml",
|
73
75
|
"public/javascripts/rails-jqgrid/src/css/jquery.searchFilter.css",
|
@@ -122,6 +124,8 @@ Gem::Specification.new do |s|
|
|
122
124
|
"public/javascripts/rails-jqgrid/src/jquery.searchFilter.js",
|
123
125
|
"public/javascripts/rails-jqgrid/src/ui.multiselect.js",
|
124
126
|
"public/stylesheets/rails-jqgrid/ellipsis-xbl.xml",
|
127
|
+
"public/stylesheets/rails-jqgrid/multiselect/MIT-LICENSE.txt",
|
128
|
+
"public/stylesheets/rails-jqgrid/multiselect/ui.multiselect.css",
|
125
129
|
"public/stylesheets/rails-jqgrid/themes/AUTHORS.txt",
|
126
130
|
"public/stylesheets/rails-jqgrid/themes/GPL-LICENSE.txt",
|
127
131
|
"public/stylesheets/rails-jqgrid/themes/MIT-LICENSE.txt",
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rails_jq_grid
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 270495469
|
5
5
|
prerelease: true
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
9
|
- 3
|
10
|
-
-
|
11
|
-
version: 0.0.3.
|
10
|
+
- pre2
|
11
|
+
version: 0.0.3.pre2
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- Dieter Spaeth
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2010-10-
|
19
|
+
date: 2010-10-16 00:00:00 +02:00
|
20
20
|
default_executable:
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -96,6 +96,8 @@ files:
|
|
96
96
|
- public/javascripts/rails-jqgrid/jquery-1.4.2.min.js
|
97
97
|
- public/javascripts/rails-jqgrid/jquery-ui-1.8.4.custom.min.js
|
98
98
|
- public/javascripts/rails-jqgrid/jquery.jqGrid.min.js
|
99
|
+
- public/javascripts/rails-jqgrid/multiselect/MIT-LICENSE.txt
|
100
|
+
- public/javascripts/rails-jqgrid/multiselect/ui.multiselect.js
|
99
101
|
- public/javascripts/rails-jqgrid/src/JsonXml.js
|
100
102
|
- public/javascripts/rails-jqgrid/src/css/ellipsis-xbl.xml
|
101
103
|
- public/javascripts/rails-jqgrid/src/css/jquery.searchFilter.css
|
@@ -150,6 +152,8 @@ files:
|
|
150
152
|
- public/javascripts/rails-jqgrid/src/jquery.searchFilter.js
|
151
153
|
- public/javascripts/rails-jqgrid/src/ui.multiselect.js
|
152
154
|
- public/stylesheets/rails-jqgrid/ellipsis-xbl.xml
|
155
|
+
- public/stylesheets/rails-jqgrid/multiselect/MIT-LICENSE.txt
|
156
|
+
- public/stylesheets/rails-jqgrid/multiselect/ui.multiselect.css
|
153
157
|
- public/stylesheets/rails-jqgrid/themes/AUTHORS.txt
|
154
158
|
- public/stylesheets/rails-jqgrid/themes/GPL-LICENSE.txt
|
155
159
|
- public/stylesheets/rails-jqgrid/themes/MIT-LICENSE.txt
|