-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy pathjquery.example.min.js
27 lines (27 loc) · 2.27 KB
/
jquery.example.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
/*
* jQuery Form Example Plugin 1.6.2
* Populate form inputs with example text that disappears on focus.
*
* e.g.
* $('input#name').example('Bob Smith');
* $('input[@title]').example(function () {
* return $(this).attr('title');
* });
* $('textarea#message').example('Type your message here', {
* className: 'example_text'
* });
*
* Copyright (c) Paul Mucur (http://mudge.name), 2007-2012.
* Dual-licensed under the BSD (BSD-LICENSE.txt) and GPL (GPL-LICENSE.txt)
* licenses.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/!function(e){"use strict";var a;a=e.fn.on?function(a,s,l){e("body").on(s,a,l)}:e.fn.delegate?function(a,s,l){e("body").delegate(a,s,l)}:e.fn.live?function(a,s,l){e(a).live(s,l)}:function(a,s,l){e(a).bind(s,l)},e.fn.example=function(s,l){var n=e.isFunction(s),m=e.extend({},l,{example:s});return this.each(function(){var s,l=e(this);s=e.metadata?e.extend({},e.fn.example.defaults,l.metadata(),m):e.extend({},e.fn.example.defaults,m),e.fn.example.boundClassNames[s.className]||(e(window).bind("unload.example",function(){e("."+s.className).val("").removeClass(s.className)}),a("form","submit.example example:resetForm",function(){e(this).find("."+s.className).val("").removeClass(s.className)}),e.fn.example.boundClassNames[s.className]=!0),l.val()===this.defaultValue||!n&&l.val()!==s.example||l.val(this.defaultValue),""!==l.val()||l.is(":focus")||l.addClass(s.className).val(n?s.example.call(this):s.example),l.bind("focus.example",function(){e(this).is("."+s.className)&&e(this).val("").removeClass(s.className)}).bind("change.example",function(){e(this).removeClass(s.className)}).bind("blur.example",function(){""===e(this).val()&&e(this).addClass(s.className).val(n?s.example.call(this):s.example)})})},e.fn.example.defaults={className:"example"},e.fn.example.boundClassNames=[]}(jQuery);