зеркало из https://github.com/mozilla/batucada.git
added support for input[placeholder] attr via jQuery/css for browsers that don't support it
This commit is contained in:
Родитель
c8491ab65b
Коммит
ecde901da4
|
@ -1345,5 +1345,5 @@ header {}
|
|||
line-height: 18px;
|
||||
}
|
||||
#splash #main asside #planet_drumbeat > h1 a:hover{
|
||||
opacity: 0.8;
|
||||
opacity: 0.7;
|
||||
}
|
|
@ -67,6 +67,7 @@ input:valid, textarea:valid { }
|
|||
input:invalid, textarea:invalid { border-radius: 1px; -moz-box-shadow: 0px 0px 5px red; -webkit-box-shadow: 0px 0px 5px red; box-shadow: 0px 0px 5px red; }
|
||||
.no-boxshadow input:invalid,
|
||||
.no-boxshadow textarea:invalid { background-color: #f0dddd; }
|
||||
input[type].placeholder { color: #919191; font-style: italic;}
|
||||
|
||||
::-moz-selection{ background: #FF5E99; color:#fff; text-shadow: none; }
|
||||
::selection { background:#FF5E99; color:#fff; text-shadow: none; }
|
||||
|
|
|
@ -2,15 +2,31 @@
|
|||
// remap jQuery to $
|
||||
(function($){
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// fix input[placeholder] for browsers that don't support it yet (and those that do!)
|
||||
// thanks Nico Hagenburg: http://www.hagenburger.net/BLOG/HTML5-Input-Placeholder-Fix-With-jQuery.html
|
||||
$('[placeholder]').focus(function() {
|
||||
var input = $(this);
|
||||
if (input.val() == input.attr('placeholder')) {
|
||||
input.val('');
|
||||
input.removeClass('placeholder');
|
||||
}
|
||||
}).blur(function() {
|
||||
var input = $(this);
|
||||
if (input.val() == '' || input.val() == input.attr('placeholder')) {
|
||||
input.addClass('placeholder');
|
||||
input.val(input.attr('placeholder'));
|
||||
}
|
||||
}).blur();
|
||||
// let's make sure that forms don't submit with the placeholder value
|
||||
$('[placeholder]').parents('form').submit(function() {
|
||||
$(this).find('[placeholder]').each(function() {
|
||||
var input = $(this);
|
||||
if (input.val() == input.attr('placeholder')) {
|
||||
input.val('');
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
})(window.jQuery);
|
||||
|
||||
|
|
|
@ -1,5 +1,8 @@
|
|||
<footer>
|
||||
<div class="container">
|
||||
|
||||
<form id="newsletter" action="#" method="post">
|
||||
<input type="text" placeholder="Sign up for our newsletter!" value=""/>
|
||||
<button type="submit" value="Go">Go</button>
|
||||
</form>
|
||||
</div>
|
||||
</footer>
|
Загрузка…
Ссылка в новой задаче