PageSourceSearch

https://bikeformike.org/wp-content/themes/flatsum_wp/assets/js/placeholder.js?ver=1791152573

js bikeformike.org collected 2026-10-04 22:23:57 UTC 4,516 bytes, 157 lines download raw bytes

vendor: 4,516 bytes, lines 1-157
1/*! http://mths.be/placeholder v2.0.7 by @mathias */
2;(function(window, document, $) {
3
4	var isInputSupported = 'placeholder' in document.createElement('input'),
5	    isTextareaSupported = 'placeholder' in document.createElement('textarea'),
6	    prototype = $.fn,
7	    valHooks = $.valHooks,
8	    hooks,
9	    placeholder;
10
11	if (isInputSupported && isTextareaSupported) {
12
13		placeholder = prototype.placeholder = function() {
14			return this;
15		};
16
17		placeholder.input = placeholder.textarea = true;
18
19	} else {
20
21		placeholder = prototype.placeholder = function() {
22			var $this = this;
23			$this
24				.filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]')
25				.not('.placeholder')
26				.bind({
27					'focus.placeholder': clearPlaceholder,
28					'blur.placeholder': setPlaceholder
29				})
30				.data('placeholder-enabled', true)
31				.trigger('blur.placeholder');
32			return $this;
33		};
34
35		placeholder.input = isInputSupported;
36		placeholder.textarea = isTextareaSupported;
37
38		hooks = {
39			'get': function(element) {
40				var $element = $(element);
41				return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value;
42			},
43			'set': function(element, value) {
44				var $element = $(element);
45				if (!$element.data('placeholder-enabled')) {
46					return element.value = value;
47				}
48				if (value == '') {
49					element.value = value;
50					// Issue #56: Setting the placeholder causes problems if the element continues to have focus.
51					if (element != document.activeElement) {
52						// We can't use `triggerHandler` here because of dummy text/password inputs :(
53						setPlaceholder.call(element);
54					}
55				} else if ($element.hasClass('placeholder')) {
56					clearPlaceholder.call(element, true, value) || (element.value = value);
57				} else {
58					element.value = value;
59				}
60				// `set` can not return `undefined`; see http://jsapi.info/jquery/1.7.1/val#L2363
61				return $element;
62			}
63		};
64
65		isInputSupported || (valHooks.input = hooks);
66		isTextareaSupported || (valHooks.textarea = hooks);
67
68		$(function() {
69			// Look for forms
70			$(document).delegate('form', 'submit.placeholder', function() {
71				// Clear the placeholder values so they don't get submitted
72				var $inputs = $('.placeholder', this).each(clearPlaceholder);
73				setTimeout(function() {
74					$inputs.each(setPlaceholder);
75				}, 10);
76			});
77		});
78
79		// Clear placeholder values upon page reload
80		$(window).bind('beforeunload.placeholder', function() {
81			$('.placeholder').each(function() {
82				this.value = '';
83			});
84		});
85
86	}
87
88	function args(elem) {
89		// Return an object of element attributes
90		var newAttrs = {},
91		    rinlinejQuery = /^jQuery\d+$/;
92		$.each(elem.attributes, function(i, attr) {
93			if (attr.specified && !rinlinejQuery.test(attr.name)) {
94				newAttrs[attr.name] = attr.value;
95			}
96		});
97		return newAttrs;
98	}
99
100	function clearPlaceholder(event, value) {
101		var input = this,
102		    $input = $(input);
103		if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
104			if ($input.data('placeholder-password')) {
105				$input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
106				// If `clearPlaceholder` was called from `$.valHooks.input.set`
107				if (event === true) {
108					return $input[0].value = value;
109				}
110				$input.focus();
111			} else {
112				input.value = '';
113				$input.removeClass('placeholder');
114				input == document.activeElement && input.select();
115			}
116		}
117	}
118
119	function setPlaceholder() {
120		var $replacement,
121		    input = this,
122		    $input = $(input),
123		    $origInput = $input,
124		    id = this.id;
125		if (input.value == '') {
126			if (input.type == 'password') {
127				if (!$input.data('placeholder-textinput')) {
128					try {
129						$replacement = $input.clone().attr({ 'type': 'text' });
130					} catch(e) {
131						$replacement = $('<input>').attr($.extend(args(this), { 'type': 'text' }));
132					}
133					$replacement
134						.removeAttr('name')
135						.data({
136							'placeholder-password': true,
137							'placeholder-id': id
138						})
139						.bind('focus.placeholder', clearPlaceholder);
140					$input
141						.data({
142							'placeholder-textinput': $replacement,
143							'placeholder-id': id
144						})
145						.before($replacement);
146				}
147				$input = $input.removeAttr('id').hide().prev().attr('id', id).show();
148				// Note: `$input[0] != input` now!
149			}
150			$input.addClass('placeholder');
151			$input[0].value = $input.attr('placeholder');
152		} else {
153			$input.removeClass('placeholder');
154		}
155	}
156
157}(this, document, jQuery));

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.