jquery-placeholder-rails 2.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +36 -0
- data/Rakefile +1 -0
- data/jquery-placeholder-rails.gemspec +23 -0
- data/lib/jquery-placeholder-rails/engine.rb +8 -0
- data/lib/jquery-placeholder-rails/railtie.rb +8 -0
- data/lib/jquery-placeholder-rails/version.rb +7 -0
- data/lib/jquery-placeholder-rails.rb +13 -0
- data/vendor/assets/javascripts/jquery-placeholder/index.js +1 -0
- data/vendor/assets/javascripts/jquery-placeholder/jquery.placeholder.js +157 -0
- metadata +86 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8c98350a2a4e127c82b99e0d38136b3e0c9872f6
|
4
|
+
data.tar.gz: 6cadd17d9843f8c27c7620b18c923fe7108438f7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 33520bc41e3437a303349dbf994fc8e0c887e8e2d3617dec66e515c3dfe6b2e58ca8f6a1cfac4ab9c27edfb82eabeeb7bcbf3249144b7a45baf515546be4c0e3
|
7
|
+
data.tar.gz: e3e7423e70d1c422c01c3195553cd9dcb7d0488c1ec5c13fe99f79ec3b0e9788c2dd67703ab3d4ac6eac93cd1ea61ca8103f2493ee691c86b50fc12d223bdb52
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Navin Peiris
|
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,36 @@
|
|
1
|
+
# jquery-placeholder-rails
|
2
|
+
|
3
|
+
jQuery Placeholder is a utility used to enable HTML5 placeholder text in IE and non-html5 compliant browsers developed
|
4
|
+
by [Mathias Bynens](http://mathiasbynens.be) now integrated for the Rails asset pipeline.
|
5
|
+
|
6
|
+
See [jquery-placeholder](https://github.com/mathiasbynens/jquery-placeholder) for more details.
|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add this line to your application's Gemfile:
|
11
|
+
|
12
|
+
gem 'jquery-placeholder-rails'
|
13
|
+
|
14
|
+
And then execute:
|
15
|
+
|
16
|
+
$ bundle
|
17
|
+
|
18
|
+
Or install it yourself as:
|
19
|
+
|
20
|
+
$ gem install jquery-placeholder-rails
|
21
|
+
|
22
|
+
Then require `jquery-placeholder` in your `app/assets/javascripts/application.js` file:
|
23
|
+
|
24
|
+
//= require jquery-placeholder
|
25
|
+
|
26
|
+
## Usage
|
27
|
+
|
28
|
+
See [jquery-placeholder](https://github.com/mathiasbynens/jquery-placeholder).
|
29
|
+
|
30
|
+
## Contributing
|
31
|
+
|
32
|
+
1. Fork it
|
33
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
34
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
35
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
36
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
@@ -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 'jquery-placeholder-rails/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'jquery-placeholder-rails'
|
8
|
+
spec.version = JQuery::Placeholder::Rails::VERSION
|
9
|
+
spec.authors = ['Navin Peiris']
|
10
|
+
spec.email = %w(navin.peiris@gmail.com)
|
11
|
+
spec.description = %q{jQuery Placeholder for the Rails asset pipeline}
|
12
|
+
spec.summary = %q{jQuery Placeholder is a utility used to enable HTML5 placeholder text in IE and non-html5 compliant browsers developed by Mathias Bynens now integrated for the Rails asset pipeline}
|
13
|
+
spec.homepage = 'https://github.com/navinpeiris/jquery-placeholder-rails'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
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 = %w(lib)
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.3'
|
22
|
+
spec.add_development_dependency 'rake'
|
23
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require ./jquery.placeholder.js
|
@@ -0,0 +1,157 @@
|
|
1
|
+
/*! http://mths.be/placeholder v2.0.7 by @mathias */
|
2
|
+
;(function(window, document, $) {
|
3
|
+
|
4
|
+
var isInputSupported = 'placeholder' in document.createElement('input'),
|
5
|
+
isTextareaSupported = 'placeholder' in document.createElement('textarea'),
|
6
|
+
prototype = $.fn,
|
7
|
+
valHooks = $.valHooks,
|
8
|
+
hooks,
|
9
|
+
placeholder;
|
10
|
+
|
11
|
+
if (isInputSupported && isTextareaSupported) {
|
12
|
+
|
13
|
+
placeholder = prototype.placeholder = function() {
|
14
|
+
return this;
|
15
|
+
};
|
16
|
+
|
17
|
+
placeholder.input = placeholder.textarea = true;
|
18
|
+
|
19
|
+
} else {
|
20
|
+
|
21
|
+
placeholder = prototype.placeholder = function() {
|
22
|
+
var $this = this;
|
23
|
+
$this
|
24
|
+
.filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]')
|
25
|
+
.not('.placeholder')
|
26
|
+
.bind({
|
27
|
+
'focus.placeholder': clearPlaceholder,
|
28
|
+
'blur.placeholder': setPlaceholder
|
29
|
+
})
|
30
|
+
.data('placeholder-enabled', true)
|
31
|
+
.trigger('blur.placeholder');
|
32
|
+
return $this;
|
33
|
+
};
|
34
|
+
|
35
|
+
placeholder.input = isInputSupported;
|
36
|
+
placeholder.textarea = isTextareaSupported;
|
37
|
+
|
38
|
+
hooks = {
|
39
|
+
'get': function(element) {
|
40
|
+
var $element = $(element);
|
41
|
+
return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value;
|
42
|
+
},
|
43
|
+
'set': function(element, value) {
|
44
|
+
var $element = $(element);
|
45
|
+
if (!$element.data('placeholder-enabled')) {
|
46
|
+
return element.value = value;
|
47
|
+
}
|
48
|
+
if (value == '') {
|
49
|
+
element.value = value;
|
50
|
+
// Issue #56: Setting the placeholder causes problems if the element continues to have focus.
|
51
|
+
if (element != document.activeElement) {
|
52
|
+
// We can't use `triggerHandler` here because of dummy text/password inputs :(
|
53
|
+
setPlaceholder.call(element);
|
54
|
+
}
|
55
|
+
} else if ($element.hasClass('placeholder')) {
|
56
|
+
clearPlaceholder.call(element, true, value) || (element.value = value);
|
57
|
+
} else {
|
58
|
+
element.value = value;
|
59
|
+
}
|
60
|
+
// `set` can not return `undefined`; see http://jsapi.info/jquery/1.7.1/val#L2363
|
61
|
+
return $element;
|
62
|
+
}
|
63
|
+
};
|
64
|
+
|
65
|
+
isInputSupported || (valHooks.input = hooks);
|
66
|
+
isTextareaSupported || (valHooks.textarea = hooks);
|
67
|
+
|
68
|
+
$(function() {
|
69
|
+
// Look for forms
|
70
|
+
$(document).delegate('form', 'submit.placeholder', function() {
|
71
|
+
// Clear the placeholder values so they don't get submitted
|
72
|
+
var $inputs = $('.placeholder', this).each(clearPlaceholder);
|
73
|
+
setTimeout(function() {
|
74
|
+
$inputs.each(setPlaceholder);
|
75
|
+
}, 10);
|
76
|
+
});
|
77
|
+
});
|
78
|
+
|
79
|
+
// Clear placeholder values upon page reload
|
80
|
+
$(window).bind('beforeunload.placeholder', function() {
|
81
|
+
$('.placeholder').each(function() {
|
82
|
+
this.value = '';
|
83
|
+
});
|
84
|
+
});
|
85
|
+
|
86
|
+
}
|
87
|
+
|
88
|
+
function args(elem) {
|
89
|
+
// Return an object of element attributes
|
90
|
+
var newAttrs = {},
|
91
|
+
rinlinejQuery = /^jQuery\d+$/;
|
92
|
+
$.each(elem.attributes, function(i, attr) {
|
93
|
+
if (attr.specified && !rinlinejQuery.test(attr.name)) {
|
94
|
+
newAttrs[attr.name] = attr.value;
|
95
|
+
}
|
96
|
+
});
|
97
|
+
return newAttrs;
|
98
|
+
}
|
99
|
+
|
100
|
+
function clearPlaceholder(event, value) {
|
101
|
+
var input = this,
|
102
|
+
$input = $(input);
|
103
|
+
if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
|
104
|
+
if ($input.data('placeholder-password')) {
|
105
|
+
$input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
|
106
|
+
// If `clearPlaceholder` was called from `$.valHooks.input.set`
|
107
|
+
if (event === true) {
|
108
|
+
return $input[0].value = value;
|
109
|
+
}
|
110
|
+
$input.focus();
|
111
|
+
} else {
|
112
|
+
input.value = '';
|
113
|
+
$input.removeClass('placeholder');
|
114
|
+
input == document.activeElement && input.select();
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
function setPlaceholder() {
|
120
|
+
var $replacement,
|
121
|
+
input = this,
|
122
|
+
$input = $(input),
|
123
|
+
$origInput = $input,
|
124
|
+
id = this.id;
|
125
|
+
if (input.value == '') {
|
126
|
+
if (input.type == 'password') {
|
127
|
+
if (!$input.data('placeholder-textinput')) {
|
128
|
+
try {
|
129
|
+
$replacement = $input.clone().attr({ 'type': 'text' });
|
130
|
+
} catch(e) {
|
131
|
+
$replacement = $('<input>').attr($.extend(args(this), { 'type': 'text' }));
|
132
|
+
}
|
133
|
+
$replacement
|
134
|
+
.removeAttr('name')
|
135
|
+
.data({
|
136
|
+
'placeholder-password': true,
|
137
|
+
'placeholder-id': id
|
138
|
+
})
|
139
|
+
.bind('focus.placeholder', clearPlaceholder);
|
140
|
+
$input
|
141
|
+
.data({
|
142
|
+
'placeholder-textinput': $replacement,
|
143
|
+
'placeholder-id': id
|
144
|
+
})
|
145
|
+
.before($replacement);
|
146
|
+
}
|
147
|
+
$input = $input.removeAttr('id').hide().prev().attr('id', id).show();
|
148
|
+
// Note: `$input[0] != input` now!
|
149
|
+
}
|
150
|
+
$input.addClass('placeholder');
|
151
|
+
$input[0].value = $input.attr('placeholder');
|
152
|
+
} else {
|
153
|
+
$input.removeClass('placeholder');
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
}(this, document, jQuery));
|
metadata
ADDED
@@ -0,0 +1,86 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jquery-placeholder-rails
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 2.0.7
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Navin Peiris
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-07-11 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.3'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.3'
|
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: jQuery Placeholder for the Rails asset pipeline
|
42
|
+
email:
|
43
|
+
- navin.peiris@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
|
+
- jquery-placeholder-rails.gemspec
|
54
|
+
- lib/jquery-placeholder-rails.rb
|
55
|
+
- lib/jquery-placeholder-rails/engine.rb
|
56
|
+
- lib/jquery-placeholder-rails/railtie.rb
|
57
|
+
- lib/jquery-placeholder-rails/version.rb
|
58
|
+
- vendor/assets/javascripts/jquery-placeholder/index.js
|
59
|
+
- vendor/assets/javascripts/jquery-placeholder/jquery.placeholder.js
|
60
|
+
homepage: https://github.com/navinpeiris/jquery-placeholder-rails
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
metadata: {}
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options: []
|
66
|
+
require_paths:
|
67
|
+
- lib
|
68
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
requirements:
|
75
|
+
- - '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
requirements: []
|
79
|
+
rubyforge_project:
|
80
|
+
rubygems_version: 2.0.4
|
81
|
+
signing_key:
|
82
|
+
specification_version: 4
|
83
|
+
summary: jQuery Placeholder is a utility used to enable HTML5 placeholder text in
|
84
|
+
IE and non-html5 compliant browsers developed by Mathias Bynens now integrated for
|
85
|
+
the Rails asset pipeline
|
86
|
+
test_files: []
|