form-focus-rails 0.8 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/README.md +11 -0
- data/form-focus-rails.gemspec +21 -0
- data/lib/form-focus-rails.rb +12 -0
- data/lib/form-focus-rails/version.rb +7 -0
- data/vendor/assets/javascripts/form-focus-rails.js +11 -0
- metadata +8 -2
data/.gitignore
ADDED
data/README.md
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Form focus for Rails
|
2
|
+
|
3
|
+
Focus the first field in a form in a Rails application.
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
```javascript
|
8
|
+
//= require form-focus-rails
|
9
|
+
```
|
10
|
+
|
11
|
+
If you want the autofocus to work on a specific part of your page (say you want to exclude any inputs you have in your navigation bar), wrap this part of the page in a <tt>form-focus</tt> CSS class.
|
@@ -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 'form-focus-rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "form-focus-rails"
|
8
|
+
gem.version = Form::Focus::Rails::VERSION
|
9
|
+
gem.authors = ["Tomislav Car"]
|
10
|
+
gem.email = ["tomislav@infinum.hr"]
|
11
|
+
gem.description = %q{Focus the first available field on a page}
|
12
|
+
gem.summary = %q{Quick and simple Rails gem for adding autofocusing to the first field of a form in a Rails application}
|
13
|
+
gem.homepage = "https://github.com/infinum"
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
|
20
|
+
gem.add_dependency "railties", ">= 3.1"
|
21
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
jQuery(function($) {
|
2
|
+
var $parentElement = $('.form-focus')
|
3
|
+
if($parentElement.length == 0)
|
4
|
+
$parentElement = $('body')
|
5
|
+
|
6
|
+
var $input = $parentElement.find("input:text:visible, select:visible, textarea:visible, input[type=email]:visible")
|
7
|
+
|
8
|
+
if($input.length > 0){
|
9
|
+
$($input[0]).focus()
|
10
|
+
}
|
11
|
+
});
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: form-focus-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.8.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -33,7 +33,13 @@ email:
|
|
33
33
|
executables: []
|
34
34
|
extensions: []
|
35
35
|
extra_rdoc_files: []
|
36
|
-
files:
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- README.md
|
39
|
+
- form-focus-rails.gemspec
|
40
|
+
- lib/form-focus-rails.rb
|
41
|
+
- lib/form-focus-rails/version.rb
|
42
|
+
- vendor/assets/javascripts/form-focus-rails.js
|
37
43
|
homepage: https://github.com/infinum
|
38
44
|
licenses: []
|
39
45
|
post_install_message:
|