editable_table_rails 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 441069eec8037c8e024e980ccf9e75ba77d49834
4
+ data.tar.gz: 66e5a6b42187bf692473d3e43985c38c799c1ffe
5
+ SHA512:
6
+ metadata.gz: b84ee59964b9c86cc4810a42bec7c86d274c9f59aab1ff5bff2f1375eeb60320dde09a892a9791114880b61d939dd52c35a1eaf3ad060cb14dd056362042b645
7
+ data.tar.gz: 26c0034f1c77d3269129ccae7a873f7a3abcba11617cca3d649ff725c712c264675e1a0329b4f5c7544b2423fdbf86548e30ac8a8955183c54e694fe5aa66eba
data/.gitignore ADDED
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in editable_table_rails.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 mcorp.io
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,52 @@
1
+ # EditableTable Rails
2
+
3
+ editable_table_rails is a simple gem to add [mindmup's editable-table][1] vendor file to Rails asset pipeline.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile
8
+
9
+ gem 'editable_table_rails'
10
+
11
+ And the execute:
12
+
13
+ $ bundle
14
+
15
+ ## Usage
16
+
17
+ Add the follow line to your application.js and application.css file:
18
+
19
+ # application.js
20
+ //= require editable_table
21
+
22
+ ## Basic Usage of editable-table
23
+
24
+ Go to [mindmup's editable-table page][0].
25
+
26
+ ## License
27
+
28
+ Copyright (c) 2014 mcorp.io
29
+
30
+ MIT License
31
+
32
+ Permission is hereby granted, free of charge, to any person obtaining
33
+ a copy of this software and associated documentation files (the
34
+ "Software"), to deal in the Software without restriction, including
35
+ without limitation the rights to use, copy, modify, merge, publish,
36
+ distribute, sublicense, and/or sell copies of the Software, and to
37
+ permit persons to whom the Software is furnished to do so, subject to
38
+ the following conditions:
39
+
40
+ The above copyright notice and this permission notice shall be
41
+ included in all copies or substantial portions of the Software.
42
+
43
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
44
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
45
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
46
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
47
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
48
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
49
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50
+
51
+ [0]: https://github.com/mindmup/editable-table
52
+ [1]: http://mindmup.github.com/editable-table/
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'editable_table_rails/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "editable_table_rails"
8
+ spec.version = EditableTableRails::VERSION
9
+ spec.authors = ["Adilson Carvalho"]
10
+ spec.email = ["lc.adilson@gmail.com"]
11
+ spec.summary = %q{Rails asset pipeline for tiny editable jQuery Bootstrap spreadsheet}
12
+ spec.description = %q{Rails asset pipeline for tiny editable jQuery Bootstrap spreadsheet}
13
+ spec.homepage = "https://github.com/mcorp/editable_table_rails"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.6"
22
+ spec.add_development_dependency "rake"
23
+ end
@@ -0,0 +1,6 @@
1
+ require "editable_table_rails/version"
2
+
3
+ module EditableTableRails
4
+ class Engine < ::Rails::Engine
5
+ end
6
+ end
@@ -0,0 +1,3 @@
1
+ module EditableTableRails
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,130 @@
1
+ /*global $, window*/
2
+ $.fn.editableTableWidget = function (options) {
3
+ 'use strict';
4
+ return $(this).each(function () {
5
+ var buildDefaultOptions = function () {
6
+ var opts = $.extend({}, $.fn.editableTableWidget.defaultOptions);
7
+ opts.editor = opts.editor.clone();
8
+ return opts;
9
+ },
10
+ activeOptions = $.extend(buildDefaultOptions(), options),
11
+ ARROW_LEFT = 37, ARROW_UP = 38, ARROW_RIGHT = 39, ARROW_DOWN = 40, ENTER = 13, ESC = 27, TAB = 9,
12
+ element = $(this),
13
+ editor = activeOptions.editor.css('position', 'absolute').hide().appendTo(element.parent()),
14
+ active,
15
+ showEditor = function (select) {
16
+ active = element.find('td:focus');
17
+ if (active.length) {
18
+ editor.val(active.text())
19
+ .removeClass('error')
20
+ .show()
21
+ .offset(active.offset())
22
+ .css(active.css(activeOptions.cloneProperties))
23
+ .width(active.width())
24
+ .height(active.height())
25
+ .focus();
26
+ if (select) {
27
+ editor.select();
28
+ }
29
+ }
30
+ },
31
+ setActiveText = function () {
32
+ var text = editor.val(),
33
+ evt = $.Event('change'),
34
+ originalContent;
35
+ if (active.text() === text || editor.hasClass('error')) {
36
+ return true;
37
+ }
38
+ originalContent = active.html();
39
+ active.text(text).trigger(evt, text);
40
+ if (evt.result === false) {
41
+ active.html(originalContent);
42
+ }
43
+ },
44
+ movement = function (element, keycode) {
45
+ if (keycode === ARROW_RIGHT) {
46
+ return element.next('td');
47
+ } else if (keycode === ARROW_LEFT) {
48
+ return element.prev('td');
49
+ } else if (keycode === ARROW_UP) {
50
+ return element.parent().prev().children().eq(element.index());
51
+ } else if (keycode === ARROW_DOWN) {
52
+ return element.parent().next().children().eq(element.index());
53
+ }
54
+ return [];
55
+ };
56
+ editor.blur(function () {
57
+ setActiveText();
58
+ editor.hide();
59
+ }).keydown(function (e) {
60
+ if (e.which === ENTER) {
61
+ setActiveText();
62
+ editor.hide();
63
+ active.focus();
64
+ e.preventDefault();
65
+ e.stopPropagation();
66
+ } else if (e.which === ESC) {
67
+ editor.val(active.text());
68
+ e.preventDefault();
69
+ e.stopPropagation();
70
+ editor.hide();
71
+ active.focus();
72
+ } else if (e.which === TAB) {
73
+ active.focus();
74
+ } else if (this.selectionEnd - this.selectionStart === this.value.length) {
75
+ var possibleMove = movement(active, e.which);
76
+ if (possibleMove.length > 0) {
77
+ possibleMove.focus();
78
+ e.preventDefault();
79
+ e.stopPropagation();
80
+ }
81
+ }
82
+ })
83
+ .on('input paste', function () {
84
+ var evt = $.Event('validate');
85
+ active.trigger(evt, editor.val());
86
+ if (evt.result === false) {
87
+ editor.addClass('error');
88
+ } else {
89
+ editor.removeClass('error');
90
+ }
91
+ });
92
+ element.on('click keypress dblclick', showEditor)
93
+ .css('cursor', 'pointer')
94
+ .keydown(function (e) {
95
+ var prevent = true,
96
+ possibleMove = movement($(e.target), e.which);
97
+ if (possibleMove.length > 0) {
98
+ possibleMove.focus();
99
+ } else if (e.which === ENTER) {
100
+ showEditor(false);
101
+ } else if (e.which === 17 || e.which === 91 || e.which === 93) {
102
+ showEditor(true);
103
+ prevent = false;
104
+ } else {
105
+ prevent = false;
106
+ }
107
+ if (prevent) {
108
+ e.stopPropagation();
109
+ e.preventDefault();
110
+ }
111
+ });
112
+
113
+ element.find('td').prop('tabindex', 1);
114
+
115
+ $(window).on('resize', function () {
116
+ if (editor.is(':visible')) {
117
+ editor.offset(active.offset())
118
+ .width(active.width())
119
+ .height(active.height());
120
+ }
121
+ });
122
+ });
123
+
124
+ };
125
+ $.fn.editableTableWidget.defaultOptions = {
126
+ cloneProperties: ['padding', 'padding-top', 'padding-bottom', 'padding-left', 'padding-right',
127
+ 'text-align', 'font', 'font-size', 'font-family', 'font-weight',
128
+ 'border', 'border-top', 'border-bottom', 'border-left', 'border-right'],
129
+ editor: $('<input>')
130
+ };
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: editable_table_rails
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Adilson Carvalho
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-08-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.6'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Rails asset pipeline for tiny editable jQuery Bootstrap spreadsheet
42
+ email:
43
+ - lc.adilson@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - Rakefile
53
+ - editable_table_rails.gemspec
54
+ - lib/editable_table_rails.rb
55
+ - lib/editable_table_rails/version.rb
56
+ - vendor/assets/javascripts/editable_table.js
57
+ homepage: https://github.com/mcorp/editable_table_rails
58
+ licenses:
59
+ - MIT
60
+ metadata: {}
61
+ post_install_message:
62
+ rdoc_options: []
63
+ require_paths:
64
+ - lib
65
+ required_ruby_version: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ required_rubygems_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 2.2.2
78
+ signing_key:
79
+ specification_version: 4
80
+ summary: Rails asset pipeline for tiny editable jQuery Bootstrap spreadsheet
81
+ test_files: []