Copy files from jekyll-asciidoc-quickstart
[web.git] / js / vendor / placeholder.js
1 /*! http://mths.be/placeholder v2.0.8 by @mathias */
2 !function (a, b, c) {
3 function d(a) {
4 var b = {}, d = /^jQuery\d+$/;
5 return c.each(a.attributes, function (a, c) {
6 c.specified && !d.test(c.name) && (b[c.name] = c.value)
7 }), b
8 }
9
10 function e(a, b) {
11 var d = this, e = c(d);
12 if (d.value == e.attr("placeholder") && e.hasClass("placeholder"))if (e.data("placeholder-password")) {
13 if (e = e.hide().next().show().attr("id", e.removeAttr("id").data("placeholder-id")), a === !0)return e[0].value = b;
14 e.focus()
15 } else d.value = "", e.removeClass("placeholder"), d == g() && d.select()
16 }
17
18 function f() {
19 var a, b = this, f = c(b), g = this.id;
20 if ("" == b.value) {
21 if ("password" == b.type) {
22 if (!f.data("placeholder-textinput")) {
23 try {
24 a = f.clone().attr({type: "text"})
25 } catch (h) {
26 a = c("<input>").attr(c.extend(d(this), {type: "text"}))
27 }
28 a.removeAttr("name").data({
29 "placeholder-password": f,
30 "placeholder-id": g
31 }).bind("focus.placeholder", e), f.data({"placeholder-textinput": a, "placeholder-id": g}).before(a)
32 }
33 f = f.removeAttr("id").hide().prev().attr("id", g).show()
34 }
35 f.addClass("placeholder"), f[0].value = f.attr("placeholder")
36 } else f.removeClass("placeholder")
37 }
38
39 function g() {
40 try {
41 return b.activeElement
42 } catch (a) {
43 }
44 }
45
46 var h, i, j = "[object OperaMini]" == Object.prototype.toString.call(a.operamini), k = "placeholder"in b.createElement("input") && !j, l = "placeholder"in b.createElement("textarea") && !j, m = c.fn, n = c.valHooks, o = c.propHooks;
47 k && l ? (i = m.placeholder = function () {
48 return this
49 }, i.input = i.textarea = !0) : (i = m.placeholder = function () {
50 var a = this;
51 return a.filter((k ? "textarea" : ":input") + "[placeholder]").not(".placeholder").bind({
52 "focus.placeholder": e,
53 "blur.placeholder": f
54 }).data("placeholder-enabled", !0).trigger("blur.placeholder"), a
55 }, i.input = k, i.textarea = l, h = {
56 get: function (a) {
57 var b = c(a), d = b.data("placeholder-password");
58 return d ? d[0].value : b.data("placeholder-enabled") && b.hasClass("placeholder") ? "" : a.value
59 }, set: function (a, b) {
60 var d = c(a), h = d.data("placeholder-password");
61 return h ? h[0].value = b : d.data("placeholder-enabled") ? ("" == b ? (a.value = b, a != g() && f.call(a)) : d.hasClass("placeholder") ? e.call(a, !0, b) || (a.value = b) : a.value = b, d) : a.value = b
62 }
63 }, k || (n.input = h, o.value = h), l || (n.textarea = h, o.value = h), c(function () {
64 c(b).delegate("form", "submit.placeholder", function () {
65 var a = c(".placeholder", this).each(e);
66 setTimeout(function () {
67 a.each(f)
68 }, 10)
69 })
70 }), c(a).bind("beforeunload.placeholder", function () {
71 c(".placeholder").each(function () {
72 this.value = ""
73 })
74 }))
75 }(this, document, jQuery);