|
|
|
@ -613,39 +613,10 @@ jQuery.last = function(arr) {
|
|
|
|
|
return arr && arr.length ? arr[arr.length-1] : undefined;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// jQuery plugin to emulate HTML5 placeholder attributes on input elements
|
|
|
|
|
// jQuery plugin to set HTML5 placeholder and title attributes on input elements
|
|
|
|
|
jQuery.fn.placeholder = function(text) {
|
|
|
|
|
return this.each(function() {
|
|
|
|
|
var active = false, elem = $(this);
|
|
|
|
|
this.title = text;
|
|
|
|
|
|
|
|
|
|
// Try HTML5 placeholder attribute first
|
|
|
|
|
if ('placeholder' in this) {
|
|
|
|
|
elem.attr('placeholder', text);
|
|
|
|
|
}
|
|
|
|
|
// Fallback to Javascript emulation of placeholder
|
|
|
|
|
else {
|
|
|
|
|
this._placeholder = text;
|
|
|
|
|
elem.blur(function(e) {
|
|
|
|
|
if ($.trim(elem.val()) == "")
|
|
|
|
|
elem.val(text);
|
|
|
|
|
elem.triggerHandler('change');
|
|
|
|
|
})
|
|
|
|
|
.focus(function(e) {
|
|
|
|
|
if ($.trim(elem.val()) == text)
|
|
|
|
|
elem.val("");
|
|
|
|
|
elem.triggerHandler('change');
|
|
|
|
|
})
|
|
|
|
|
.change(function(e) {
|
|
|
|
|
var active = elem.val() == text;
|
|
|
|
|
elem[(active ? 'addClass' : 'removeClass')]('placeholder').attr('spellcheck', active);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Do not blur currently focused element (catch exception: #1489008)
|
|
|
|
|
try { active = this == document.activeElement; } catch(e) {}
|
|
|
|
|
if (!active)
|
|
|
|
|
elem.blur();
|
|
|
|
|
}
|
|
|
|
|
$(this).prop({title: text, placeholder: text});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|