mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Made Field.focus in prototype friendly to effects by adding optional delay parameter [DHH]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@3366 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
89d8afa2c4
commit
d7487fffe5
3 changed files with 25 additions and 4 deletions
|
@ -1154,8 +1154,18 @@ var Field = {
|
|||
$(arguments[i]).value = '';
|
||||
},
|
||||
|
||||
focus: function(element) {
|
||||
// Pass the field id or element as the first parameter and optionally a triggering delay in micro-seconds as the second.
|
||||
// The delay is useful when the focus is part of effects that won't finish instantly since they prevent the focus from
|
||||
// taking hold. Set the delay to right after the effect finishes and the focus will work.
|
||||
focus: function() {
|
||||
element = $(arguments[0]);
|
||||
delay = arguments[1];
|
||||
|
||||
if (delay) {
|
||||
setTimeout(function() { $(element).focus(); }, delay)
|
||||
} else {
|
||||
$(element).focus();
|
||||
}
|
||||
},
|
||||
|
||||
present: function() {
|
||||
|
|
|
@ -98,5 +98,6 @@ class ReflectionTest < Test::Unit::TestCase
|
|||
assert_equal 12, Firm.reflect_on_all_associations.size
|
||||
assert_equal 11, Firm.reflect_on_all_associations(:has_many).size
|
||||
assert_equal 1, Firm.reflect_on_all_associations(:has_one).size
|
||||
assert_equal 0, Firm.reflect_on_all_associations(:belongs_to).size
|
||||
end
|
||||
end
|
||||
|
|
12
railties/html/javascripts/prototype.js
vendored
12
railties/html/javascripts/prototype.js
vendored
|
@ -1154,8 +1154,18 @@ var Field = {
|
|||
$(arguments[i]).value = '';
|
||||
},
|
||||
|
||||
focus: function(element) {
|
||||
// Pass the field id or element as the first parameter and optionally a triggering delay in micro-seconds as the second.
|
||||
// The delay is useful when the focus is part of effects that won't finish instantly since they prevent the focus from
|
||||
// taking hold. Set the delay to right after the effect finishes and the focus will work.
|
||||
focus: function() {
|
||||
element = $(arguments[0]);
|
||||
delay = arguments[1];
|
||||
|
||||
if (delay) {
|
||||
setTimeout(function() { $(element).focus(); }, delay)
|
||||
} else {
|
||||
$(element).focus();
|
||||
}
|
||||
},
|
||||
|
||||
present: function() {
|
||||
|
|
Loading…
Reference in a new issue