slickgrid-bootstrap-rails 0.0.1.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (67) hide show
  1. data/.gitignore +34 -0
  2. data/Gemfile +4 -0
  3. data/LICENSE.txt +22 -0
  4. data/README.md +158 -0
  5. data/Rakefile +1 -0
  6. data/lib/slickgrid-bootstrap-rails/version.rb +7 -0
  7. data/lib/slickgrid-bootstrap-rails.rb +11 -0
  8. data/slickgrid-bootstrap-rails.gemspec +21 -0
  9. data/vendor/assets/images/actions.gif +0 -0
  10. data/vendor/assets/images/ajax-loader-small.gif +0 -0
  11. data/vendor/assets/images/arrow_redo.png +0 -0
  12. data/vendor/assets/images/arrow_right_peppermint.png +0 -0
  13. data/vendor/assets/images/arrow_right_spearmint.png +0 -0
  14. data/vendor/assets/images/arrow_undo.png +0 -0
  15. data/vendor/assets/images/bullet_blue.png +0 -0
  16. data/vendor/assets/images/bullet_star.png +0 -0
  17. data/vendor/assets/images/bullet_toggle_minus.png +0 -0
  18. data/vendor/assets/images/bullet_toggle_plus.png +0 -0
  19. data/vendor/assets/images/calendar.gif +0 -0
  20. data/vendor/assets/images/collapse.gif +0 -0
  21. data/vendor/assets/images/comment_yellow.gif +0 -0
  22. data/vendor/assets/images/down.gif +0 -0
  23. data/vendor/assets/images/drag-handle.png +0 -0
  24. data/vendor/assets/images/editor-helper-bg.gif +0 -0
  25. data/vendor/assets/images/expand.gif +0 -0
  26. data/vendor/assets/images/header-bg.gif +0 -0
  27. data/vendor/assets/images/header-columns-bg.gif +0 -0
  28. data/vendor/assets/images/header-columns-over-bg.gif +0 -0
  29. data/vendor/assets/images/help.png +0 -0
  30. data/vendor/assets/images/info.gif +0 -0
  31. data/vendor/assets/images/listview.gif +0 -0
  32. data/vendor/assets/images/pencil.gif +0 -0
  33. data/vendor/assets/images/row-over-bg.gif +0 -0
  34. data/vendor/assets/images/sort-asc.gif +0 -0
  35. data/vendor/assets/images/sort-asc.png +0 -0
  36. data/vendor/assets/images/sort-desc.gif +0 -0
  37. data/vendor/assets/images/sort-desc.png +0 -0
  38. data/vendor/assets/images/stripes.png +0 -0
  39. data/vendor/assets/images/tag_red.png +0 -0
  40. data/vendor/assets/images/tick.png +0 -0
  41. data/vendor/assets/images/user_identity.gif +0 -0
  42. data/vendor/assets/images/user_identity_plus.gif +0 -0
  43. data/vendor/assets/javascripts/bootstrap/slick.bootstrap.js +86 -0
  44. data/vendor/assets/javascripts/plugins/slick.autotooltips.js +48 -0
  45. data/vendor/assets/javascripts/plugins/slick.cellcopymanager.js +86 -0
  46. data/vendor/assets/javascripts/plugins/slick.cellrangedecorator.js +64 -0
  47. data/vendor/assets/javascripts/plugins/slick.cellrangeselector.js +111 -0
  48. data/vendor/assets/javascripts/plugins/slick.cellselectionmodel.js +92 -0
  49. data/vendor/assets/javascripts/plugins/slick.checkboxselectcolumn.js +153 -0
  50. data/vendor/assets/javascripts/plugins/slick.headerbuttons.js +177 -0
  51. data/vendor/assets/javascripts/plugins/slick.headermenu.js +272 -0
  52. data/vendor/assets/javascripts/plugins/slick.rowmovemanager.js +138 -0
  53. data/vendor/assets/javascripts/plugins/slick.rowselectionmodel.js +187 -0
  54. data/vendor/assets/javascripts/slick.core.js +430 -0
  55. data/vendor/assets/javascripts/slick.dataview.js +917 -0
  56. data/vendor/assets/javascripts/slick.editors.js.erb +512 -0
  57. data/vendor/assets/javascripts/slick.formatters.js.erb +55 -0
  58. data/vendor/assets/javascripts/slick.grid.js +3294 -0
  59. data/vendor/assets/javascripts/slick.groupitemmetadataprovider.js +139 -0
  60. data/vendor/assets/javascripts/slick.remotemodel.js +164 -0
  61. data/vendor/assets/javascripts/slickgrid-bootstrap-rails.js +13 -0
  62. data/vendor/assets/stylesheets/plugins/slick.headerbuttons.css +38 -0
  63. data/vendor/assets/stylesheets/plugins/slick.headermenu.css +58 -0
  64. data/vendor/assets/stylesheets/slick.grid.css.erb +157 -0
  65. data/vendor/assets/stylesheets/slickgrid-bootstrap-rails.css +4 -0
  66. data/vendor/assets/stylesheets/slickgrid-bootstrap.less +159 -0
  67. metadata +143 -0
data/.gitignore ADDED
@@ -0,0 +1,34 @@
1
+ .idea/
2
+ *.gem
3
+ *.rbc
4
+ .bundle
5
+ .config
6
+ .yardoc
7
+ Gemfile.lock
8
+ InstalledFiles
9
+ _yardoc
10
+ coverage
11
+ doc/
12
+ lib/bundler/man
13
+ pkg
14
+ rdoc
15
+ spec/reports
16
+ test/tmp
17
+ test/version_tmp
18
+ tmp
19
+ .DS_Store
20
+ *.sassc
21
+ .sass-cache
22
+ capybara-*.html
23
+ .rspec
24
+ /.bundle
25
+ /vendor/bundle
26
+ /log/*
27
+ /tmp/*
28
+ /db/*.sqlite3
29
+ /public/system/*
30
+ /coverage/
31
+ /spec/tmp/*
32
+ **.orig
33
+ rerun.txt
34
+ pickle-email-*.html
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in slickgrid-bootstrap-rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Aki Atoji
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,158 @@
1
+ # slickgrid-bootstrap-rails
2
+
3
+ SlickGrid rails integration with Bootstrap support.
4
+
5
+ Integrates mleibman/SlickGrid into your rails app.
6
+ SlickGrid is a superb editable grid, but integration into Rails was
7
+ a bit messy and jQuery UI themes didn't always look too great. With this gem,
8
+ you can
9
+
10
+ * Fixes hardcoded pathing in SlickGrid that breaks Rails asset pipeline
11
+ * Eases jquery.drag.drag/drop integration (with akiatoji/jquery-dragdrop-rails)
12
+ * Requires less based integration with Bootstrap (with seyhunak/twitter-bootstrap-rails)
13
+ * Bootstrap styling with minimal markup changes (credits to reeblazs/SlickGrid-touch)
14
+
15
+ ## Installation
16
+
17
+ Add this line to your application's Gemfile:
18
+
19
+ ```
20
+ gem 'slickgrid-bootstrap-rails'
21
+ ```
22
+
23
+ Then execute:
24
+
25
+ ```
26
+ $ bundle
27
+ ```
28
+
29
+
30
+ ## Usage
31
+
32
+ Pre-requisite
33
+ -------------
34
+
35
+ SlickGrid uses jQuery UI so you need it in your assets.
36
+ slickgrid-bootstrap-rails doesn't have any direct support to pull-in jQuery UI.
37
+ This is so that you can add themed jQuery UI assets yourself.
38
+
39
+ Alternatively, you can use joliss/jquery-ui-rails.
40
+
41
+
42
+ In your bootstrap enabled Rails app:
43
+ ====================================
44
+
45
+ application.js
46
+ --------------
47
+ Bring in SlickGrid
48
+ ```
49
+ //= require slickgrid-bootstrap-rails
50
+ ```
51
+
52
+ application.css
53
+ ---------------
54
+ Bring in SlickGrid styles
55
+
56
+ ```
57
+ /*= slickgrid-bootstrap-rails
58
+ ```
59
+
60
+ bootstrap_and_overrides.css.less
61
+ --------------------------------
62
+ Enable Bootstrap styling for SlickGrid.
63
+
64
+ ```
65
+ @import "slickgrid-bootstrap";
66
+ ```
67
+
68
+
69
+
70
+
71
+ In your HTML
72
+ -----------------
73
+
74
+ ```HTML
75
+ <div id="myGrid" class="bootstrap-slickgrid" style="height: 400px"></div>
76
+ ```
77
+
78
+ The class bootstrap-slickgrid applies Bootstrap styling.
79
+ You can leave it off if you just want jQuery UI theme.
80
+
81
+
82
+ Sample CoffeeScript that populates above grid:
83
+
84
+ ```coffeescript
85
+ formatter = (row, cell, value, columnDef, dataContext) ->
86
+ value
87
+ grid = undefined
88
+ data = []
89
+ columns = [
90
+ id: "title"
91
+ name: "Title"
92
+ field: "title"
93
+ minWidth: 30
94
+ formatter: formatter
95
+ ,
96
+ id: "duration"
97
+ name: "Duration"
98
+ field: "duration"
99
+ minWidth: 30
100
+ ,
101
+ id: "%"
102
+ name: "% Complete"
103
+ field: "percentComplete"
104
+ width: 100
105
+ resizable: false
106
+ formatter: Slick.Formatters.PercentCompleteBar
107
+ ,
108
+ id: "start"
109
+ name: "Start"
110
+ field: "start"
111
+ minWidth: 60
112
+ ,
113
+ id: "finish"
114
+ name: "Finish"
115
+ field: "finish"
116
+ minWidth: 60
117
+ ,
118
+ id: "effort-driven"
119
+ name: "Effort Driven"
120
+ sortable: false
121
+ width: 120
122
+ minWidth: 60
123
+ maxWidth: 120
124
+ cssClass: "cell-effort-driven"
125
+ field: "effortDriven"
126
+ formatter: Slick.Formatters.Checkmark
127
+ ]
128
+ options =
129
+ enableCellNavigation: true
130
+ enableColumnReorder: false
131
+ forceFitColumns: true
132
+ rowHeight: 35
133
+
134
+ $ ->
135
+ i = 0
136
+ while i < 5
137
+ d = (data[i] = {})
138
+ d["title"] = "<a href='#' tabindex='0'>Task</a> " + i
139
+ d["duration"] = "5 days"
140
+ d["percentComplete"] = Math.min(100, Math.round(Math.random() * 110))
141
+ d["start"] = "01/01/2009"
142
+ d["finish"] = "01/05/2009"
143
+ d["effortDriven"] = (i % 5 is 0)
144
+ i++
145
+ grid = new Slick.Grid("#myGrid", data, columns, options)
146
+ ```
147
+
148
+ ## Contributing
149
+
150
+ 1. Fork it
151
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
152
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
153
+ 4. Push to the branch (`git push origin my-new-feature`)
154
+ 5. Create new Pull Request
155
+
156
+ ## Credits
157
+
158
+ Bootstrap integration is from reeblazs/SlickGrid-touch
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,7 @@
1
+ module Slickgrid
2
+ module Bootstrap
3
+ module Rails
4
+ VERSION = "0.0.1.10"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ require "slickgrid-bootstrap-rails/version"
2
+
3
+ module Slickgrid
4
+ module Bootstrap
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'slickgrid-bootstrap-rails/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "slickgrid-bootstrap-rails"
8
+ gem.version = Slickgrid::Bootstrap::Rails::VERSION
9
+ gem.authors = ["Aki Atoji"]
10
+ gem.email = ["akiatoji@gmail.com"]
11
+ gem.description = %q{Rails 3.x integration of SlickGrid with Bootstrap}
12
+ gem.summary = %q{Rails 3.x integration of SlickGrid with Bootstrap}
13
+ gem.homepage = "http://github.com/akiatoji/slickgrid-bootstrap-rails"
14
+
15
+ gem.add_dependency "railties", "~> 3.0"
16
+ gem.add_dependency "jquery-dragdrop-rails"
17
+ gem.files = `git ls-files`.split($/)
18
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
+ gem.require_paths = ["lib"]
21
+ 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
@@ -0,0 +1,86 @@
1
+
2
+ (function ($) {
3
+
4
+ "use strict"; // jshint ;_;
5
+
6
+ /*global Slick: true*/
7
+
8
+ /* SlickGrid PUBLIC CLASS DEFINITION
9
+ * ================================= */
10
+
11
+ var SlickGrid = function ( element, options ) {
12
+ element = $(element);
13
+ var cookedOptions = $.extend(true, {},
14
+ $.fn.slickgrid.defaults, options);
15
+ this.init('slickgrid', element, cookedOptions);
16
+ };
17
+
18
+ SlickGrid.prototype = {
19
+
20
+ constructor: SlickGrid,
21
+
22
+ init: function (type, element, options) {
23
+ var self = this;
24
+ this.element = $(element);
25
+ this.wrapperOptions = options;
26
+ this.postInit();
27
+ },
28
+
29
+ postInit: function () {
30
+ // Call the provided hook to post-process.
31
+ (this.wrapperOptions.handleCreate || this.handleCreate).apply(this);
32
+ },
33
+
34
+ handleCreate: function () {
35
+ // Create a simple grid configuration.
36
+ //
37
+ // This handler will run after the options
38
+ // have been preprocessed. It can be overridden by passing
39
+ // the handleCreate option at creation time.
40
+ //
41
+ // Variables you can access from this handler:
42
+ //
43
+ // this: will equal to the SlickGrid object instance
44
+ // this.element: the element to bind the grid to
45
+ // this.wrapperOptions: options passed to this object at creation
46
+ //
47
+ // this.wrapperOptions.slickGridOptions: options for Slick.Grid
48
+ //
49
+ var o = this.wrapperOptions;
50
+ var grid = new Slick.Grid(this.element, o.data,
51
+ o.columns, o.slickGridOptions);
52
+ }
53
+
54
+ };
55
+
56
+ /* SlickGrid PLUGIN DEFINITION */
57
+
58
+ $.fn.slickgrid = function (option) {
59
+ return this.each(function () {
60
+ var $this = $(this),
61
+ data = $this.data('slickgrid'),
62
+ options = typeof option == 'object' && option;
63
+ if (!data) {
64
+ $this.data('slickgrid', (data = new SlickGrid(this, options)));
65
+ }
66
+ if (typeof option == 'string') {
67
+ data[option]();
68
+ }
69
+ });
70
+ };
71
+
72
+ $.fn.slickgrid.Constructor = SlickGrid;
73
+
74
+ $.fn.slickgrid.defaults = {
75
+ slickGridOptions: {},
76
+ columns: [], // Column meta data in SlickGrid's format.
77
+ handleCreate: null // This handler is called after the grid is created,
78
+ // and it can be used to customize the grid.
79
+ // Variables you can access from this handler:
80
+ //
81
+ // this: will equal to the SlickGrid object instance
82
+ // this.element: the element to bind the grid to
83
+ // this.wrapperOptions: options passed to this object at creation
84
+ };
85
+
86
+ })(window.jQuery);
@@ -0,0 +1,48 @@
1
+ (function ($) {
2
+ // register namespace
3
+ $.extend(true, window, {
4
+ "Slick": {
5
+ "AutoTooltips": AutoTooltips
6
+ }
7
+ });
8
+
9
+
10
+ function AutoTooltips(options) {
11
+ var _grid;
12
+ var _self = this;
13
+ var _defaults = {
14
+ maxToolTipLength: null
15
+ };
16
+
17
+ function init(grid) {
18
+ options = $.extend(true, {}, _defaults, options);
19
+ _grid = grid;
20
+ _grid.onMouseEnter.subscribe(handleMouseEnter);
21
+ }
22
+
23
+ function destroy() {
24
+ _grid.onMouseEnter.unsubscribe(handleMouseEnter);
25
+ }
26
+
27
+ function handleMouseEnter(e, args) {
28
+ var cell = _grid.getCellFromEvent(e);
29
+ if (cell) {
30
+ var node = _grid.getCellNode(cell.row, cell.cell);
31
+ if ($(node).innerWidth() < node.scrollWidth) {
32
+ var text = $.trim($(node).text());
33
+ if (options.maxToolTipLength && text.length > options.maxToolTipLength) {
34
+ text = text.substr(0, options.maxToolTipLength - 3) + "...";
35
+ }
36
+ $(node).attr("title", text);
37
+ } else {
38
+ $(node).attr("title", "");
39
+ }
40
+ }
41
+ }
42
+
43
+ $.extend(this, {
44
+ "init": init,
45
+ "destroy": destroy
46
+ });
47
+ }
48
+ })(jQuery);
@@ -0,0 +1,86 @@
1
+ (function ($) {
2
+ // register namespace
3
+ $.extend(true, window, {
4
+ "Slick": {
5
+ "CellCopyManager": CellCopyManager
6
+ }
7
+ });
8
+
9
+
10
+ function CellCopyManager() {
11
+ var _grid;
12
+ var _self = this;
13
+ var _copiedRanges;
14
+
15
+ function init(grid) {
16
+ _grid = grid;
17
+ _grid.onKeyDown.subscribe(handleKeyDown);
18
+ }
19
+
20
+ function destroy() {
21
+ _grid.onKeyDown.unsubscribe(handleKeyDown);
22
+ }
23
+
24
+ function handleKeyDown(e, args) {
25
+ var ranges;
26
+ if (!_grid.getEditorLock().isActive()) {
27
+ if (e.which == $.ui.keyCode.ESCAPE) {
28
+ if (_copiedRanges) {
29
+ e.preventDefault();
30
+ clearCopySelection();
31
+ _self.onCopyCancelled.notify({ranges: _copiedRanges});
32
+ _copiedRanges = null;
33
+ }
34
+ }
35
+
36
+ if (e.which == 67 && (e.ctrlKey || e.metaKey)) {
37
+ ranges = _grid.getSelectionModel().getSelectedRanges();
38
+ if (ranges.length != 0) {
39
+ e.preventDefault();
40
+ _copiedRanges = ranges;
41
+ markCopySelection(ranges);
42
+ _self.onCopyCells.notify({ranges: ranges});
43
+ }
44
+ }
45
+
46
+ if (e.which == 86 && (e.ctrlKey || e.metaKey)) {
47
+ if (_copiedRanges) {
48
+ e.preventDefault();
49
+ clearCopySelection();
50
+ ranges = _grid.getSelectionModel().getSelectedRanges();
51
+ _self.onPasteCells.notify({from: _copiedRanges, to: ranges});
52
+ _copiedRanges = null;
53
+ }
54
+ }
55
+ }
56
+ }
57
+
58
+ function markCopySelection(ranges) {
59
+ var columns = _grid.getColumns();
60
+ var hash = {};
61
+ for (var i = 0; i < ranges.length; i++) {
62
+ for (var j = ranges[i].fromRow; j <= ranges[i].toRow; j++) {
63
+ hash[j] = {};
64
+ for (var k = ranges[i].fromCell; k <= ranges[i].toCell; k++) {
65
+ hash[j][columns[k].id] = "copied";
66
+ }
67
+ }
68
+ }
69
+ _grid.setCellCssStyles("copy-manager", hash);
70
+ }
71
+
72
+ function clearCopySelection() {
73
+ _grid.removeCellCssStyles("copy-manager");
74
+ }
75
+
76
+ $.extend(this, {
77
+ "init": init,
78
+ "destroy": destroy,
79
+ "clearCopySelection": clearCopySelection,
80
+
81
+ "onCopyCells": new Slick.Event(),
82
+ "onCopyCancelled": new Slick.Event(),
83
+ "onPasteCells": new Slick.Event()
84
+ });
85
+ }
86
+ })(jQuery);
@@ -0,0 +1,64 @@
1
+ (function ($) {
2
+ // register namespace
3
+ $.extend(true, window, {
4
+ "Slick": {
5
+ "CellRangeDecorator": CellRangeDecorator
6
+ }
7
+ });
8
+
9
+ /***
10
+ * Displays an overlay on top of a given cell range.
11
+ *
12
+ * TODO:
13
+ * Currently, it blocks mouse events to DOM nodes behind it.
14
+ * Use FF and WebKit-specific "pointer-events" CSS style, or some kind of event forwarding.
15
+ * Could also construct the borders separately using 4 individual DIVs.
16
+ *
17
+ * @param {Grid} grid
18
+ * @param {Object} options
19
+ */
20
+ function CellRangeDecorator(grid, options) {
21
+ var _elem;
22
+ var _defaults = {
23
+ selectionCss: {
24
+ "zIndex": "9999",
25
+ "border": "2px dashed red"
26
+ }
27
+ };
28
+
29
+ options = $.extend(true, {}, _defaults, options);
30
+
31
+
32
+ function show(range) {
33
+ if (!_elem) {
34
+ _elem = $("<div></div>", {css: options.selectionCss})
35
+ .css("position", "absolute")
36
+ .appendTo(grid.getCanvasNode());
37
+ }
38
+
39
+ var from = grid.getCellNodeBox(range.fromRow, range.fromCell);
40
+ var to = grid.getCellNodeBox(range.toRow, range.toCell);
41
+
42
+ _elem.css({
43
+ top: from.top - 1,
44
+ left: from.left - 1,
45
+ height: to.bottom - from.top - 2,
46
+ width: to.right - from.left - 2
47
+ });
48
+
49
+ return _elem;
50
+ }
51
+
52
+ function hide() {
53
+ if (_elem) {
54
+ _elem.remove();
55
+ _elem = null;
56
+ }
57
+ }
58
+
59
+ $.extend(this, {
60
+ "show": show,
61
+ "hide": hide
62
+ });
63
+ }
64
+ })(jQuery);