summaryrefslogtreecommitdiff
path: root/source/bower_components/jquery-placeholder
diff options
context:
space:
mode:
authorLars Henrik Mai <lars.mai@kontinui.de>2014-09-21 12:25:47 +0200
committerLars Henrik Mai <lars.mai@kontinui.de>2014-09-21 12:25:47 +0200
commit7cc7910df63d19e7ebc67bb1156437f0559712d7 (patch)
tree66f972354559fe05b7a97efccd08fc363c91cf4d /source/bower_components/jquery-placeholder
parent450a01136a510adc4c96ff12e05e00a2ce550c8f (diff)
add foundation via bower
Diffstat (limited to 'source/bower_components/jquery-placeholder')
-rw-r--r--source/bower_components/jquery-placeholder/.bower.json17
-rw-r--r--source/bower_components/jquery-placeholder/.gitattributes1
-rw-r--r--source/bower_components/jquery-placeholder/.gitignore1
-rw-r--r--source/bower_components/jquery-placeholder/LICENSE-MIT.txt20
-rw-r--r--source/bower_components/jquery-placeholder/README.md76
-rw-r--r--source/bower_components/jquery-placeholder/bower.json5
-rw-r--r--source/bower_components/jquery-placeholder/demo.html55
-rw-r--r--source/bower_components/jquery-placeholder/jquery.placeholder.js185
-rw-r--r--source/bower_components/jquery-placeholder/tests/index.html32
-rw-r--r--source/bower_components/jquery-placeholder/tests/tests.js134
10 files changed, 526 insertions, 0 deletions
diff --git a/source/bower_components/jquery-placeholder/.bower.json b/source/bower_components/jquery-placeholder/.bower.json
new file mode 100644
index 0000000..ac1d011
--- /dev/null
+++ b/source/bower_components/jquery-placeholder/.bower.json
@@ -0,0 +1,17 @@
+{
+ "name": "jquery-placeholder",
+ "version": "2.0.8",
+ "main": [
+ "jquery.placeholder.js"
+ ],
+ "homepage": "https://github.com/mathiasbynens/jquery-placeholder",
+ "_release": "2.0.8",
+ "_resolution": {
+ "type": "version",
+ "tag": "v2.0.8",
+ "commit": "051f21ef5279f4887d9caf6af7af211d933ba670"
+ },
+ "_source": "git://github.com/mathiasbynens/jquery-placeholder.git",
+ "_target": "~2.0.7",
+ "_originalSource": "jquery-placeholder"
+} \ No newline at end of file
diff --git a/source/bower_components/jquery-placeholder/.gitattributes b/source/bower_components/jquery-placeholder/.gitattributes
new file mode 100644
index 0000000..44b4224
--- /dev/null
+++ b/source/bower_components/jquery-placeholder/.gitattributes
@@ -0,0 +1 @@
+* eol=lf \ No newline at end of file
diff --git a/source/bower_components/jquery-placeholder/.gitignore b/source/bower_components/jquery-placeholder/.gitignore
new file mode 100644
index 0000000..496ee2c
--- /dev/null
+++ b/source/bower_components/jquery-placeholder/.gitignore
@@ -0,0 +1 @@
+.DS_Store \ No newline at end of file
diff --git a/source/bower_components/jquery-placeholder/LICENSE-MIT.txt b/source/bower_components/jquery-placeholder/LICENSE-MIT.txt
new file mode 100644
index 0000000..8d4d070
--- /dev/null
+++ b/source/bower_components/jquery-placeholder/LICENSE-MIT.txt
@@ -0,0 +1,20 @@
+Copyright Mathias Bynens <http://mathiasbynens.be/>
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file
diff --git a/source/bower_components/jquery-placeholder/README.md b/source/bower_components/jquery-placeholder/README.md
new file mode 100644
index 0000000..fa7ea38
--- /dev/null
+++ b/source/bower_components/jquery-placeholder/README.md
@@ -0,0 +1,76 @@
+# HTML5 Placeholder jQuery Plugin
+
+## Demo & Examples
+
+[http://mathiasbynens.be/demo/placeholder](http://mathiasbynens.be/demo/placeholder)
+
+## Example Usage
+
+### HTML
+
+```html
+<input type="text" name="name" placeholder="e.g. John Doe">
+<input type="email" name="email" placeholder="e.g. address@example.ext">
+<input type="url" name="url" placeholder="e.g. http://mathiasbynens.be/">
+<input type="tel" name="tel" placeholder="e.g. +32 472 77 69 88">
+<input type="password" name="password" placeholder="e.g. h4x0rpr00fz">
+<input type="search" name="search" placeholder="Search this site…">
+<textarea name="message" placeholder="Your message goes here"></textarea>
+```
+
+### jQuery
+
+Use the plugin as follows:
+
+```js
+$('input, textarea').placeholder();
+```
+
+You’ll still be able to use `jQuery#val()` to get and set the input values. If the element is currently showing a placeholder, `.val()` will return an empty string instead of the placeholder text, just like it does in browsers with a native `@placeholder` implementation. Calling `.val('')` to set an element’s value to the empty string will result in the placeholder text (re)appearing.
+
+### CSS
+
+The plugin automatically adds `class="placeholder"` to the elements who are currently showing their placeholder text. You can use this to style placeholder text differently:
+
+```css
+input, textarea { color: #000; }
+.placeholder { color: #aaa; }
+```
+
+I’d suggest sticking to the `#aaa` color for placeholder text, as it’s the default in most browsers that support `@placeholder`. If you really want to, though, you can [style the placeholder text in some of the browsers that natively support it](http://stackoverflow.com/questions/2610497/change-an-inputs-html5-placeholder-color-with-css/2610741#2610741).
+
+## Installation
+
+You can install jquery-placeholder by using [Bower](http://bower.io).
+
+```bash
+bower install jquery-placeholder
+```
+
+## Notes
+
+* Requires jQuery 1.6+. For an older version of this plugin that works under jQuery 1.4.2+, see [v1.8.7](https://github.com/mathiasbynens/jquery-placeholder/tree/v1.8.7).
+* Works in all A-grade browsers, including IE6.
+* Automatically checks if the browser natively supports the HTML5 `placeholder` attribute for `input` and `textarea` elements. If this is the case, the plugin won’t do anything. If `@placeholder` is only supported for `input` elements, the plugin will leave those alone and apply to `textarea`s exclusively. (This is the case for Safari 4, Opera 11.00, and possibly other browsers.)
+* Caches the results of its two feature tests in `jQuery.fn.placeholder.input` and `jQuery.fn.placeholder.textarea`. For example, if `@placeholder` is natively supported for `input` elements, `jQuery.fn.placeholder.input` will be `true`. After loading the plugin, you can re-use these properties in your own code.
+* Makes sure it never causes duplicate IDs in your DOM, even in browsers that need an extra `input` element to fake `@placeholder` for password inputs. This means you can safely do stuff like:
+
+ ```html
+ <label for="bar">Example label</label>
+ <input type="password" placeholder="foo" id="bar">
+ ```
+
+ And the `<label>` will always point to the `<input>` element you’d expect. Also, all CSS styles based on the ID will just work™.
+
+## License
+
+This plugin is available under [the MIT license](http://mths.be/mit).
+
+## Thanks to…
+
+* [Paul Irish](http://paulirish.com/) for his inspiring snippet in [jQuery 1.4 Hawtness #1](http://jquery14.com/day-05/jquery-1-4-hawtness-1-with-paul-irish)
+* everyone from [#jquery](http://webchat.freenode.net/?channels=jquery) for the tips, ideas and patches
+* temp01 for his major contributions
+* anyone who [contributed a patch](https://github.com/mathiasbynens/jquery-placeholder/contributors) or [made a helpful suggestion](https://github.com/mathiasbynens/jquery-placeholder/issues)
+
+_– [Mathias](http://mathiasbynens.be/)_
diff --git a/source/bower_components/jquery-placeholder/bower.json b/source/bower_components/jquery-placeholder/bower.json
new file mode 100644
index 0000000..4e5a390
--- /dev/null
+++ b/source/bower_components/jquery-placeholder/bower.json
@@ -0,0 +1,5 @@
+{
+ "name": "jquery-placeholder",
+ "version": "2.0.8",
+ "main": ["jquery.placeholder.js"]
+}
diff --git a/source/bower_components/jquery-placeholder/demo.html b/source/bower_components/jquery-placeholder/demo.html
new file mode 100644
index 0000000..a25df40
--- /dev/null
+++ b/source/bower_components/jquery-placeholder/demo.html
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+<!-- If you’re looking for the online demo, it’s here: http://mathiasbynens.be/demo/placeholder -->
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>HTML5 placeholder jQuery Plugin</title>
+ <style>
+ body, input, textarea { font: 1em/1.4 Helvetica, Arial; }
+ label code { cursor: pointer; float: left; width: 150px; }
+ input { width: 14em; }
+ textarea { height: 5em; width: 20em; }
+ .placeholder { color: #aaa; }
+ .note { border: 1px solid orange; padding: 1em; background: #ffffe0; }
+ /* #p { background: lime; } */
+ </style>
+ </head>
+ <body>
+ <h1>HTML5 Placeholder jQuery Plugin</h1>
+ <p>Check out <a href="http://mths.be/placeholder">the HTML5 Placeholder jQuery Plugin project page on GitHub</a>.</p>
+ <pre><code>$(function() {<br> $('input, textarea').placeholder();<br>});</code></pre>
+ <form>
+ <p><label><code>type=search</code> <input type="search" name="search" placeholder="Search this site…"></label></p>
+ <p><label><code>type=text</code> <input type="text" name="name" placeholder="e.g. John Doe"></label></p>
+ <p><label><code>type=email</code> <input type="email" name="email" placeholder="e.g. address@example.ext"></label></p>
+ <p><label><code>type=url</code> <input type="url" name="url" placeholder="e.g. http://mathiasbynens.be/"></label></p>
+ <p><label><code>type=tel</code> <input type="tel" name="tel" placeholder="e.g. +32 472 77 69 88"></label></p>
+ <p><label for="p"><code>type=password</code> </label><input type="password" name="password" placeholder="e.g. hunter2" id="p"></p>
+ <p><label><code>textarea</code> <textarea name="message" placeholder="Your message goes here"></textarea></label></p>
+ <p><input type="submit" value="type=submit"></p>
+ </form>
+ <p>— <a href="http://mathiasbynens.be/" title="Mathias Bynens, front-end developer">Mathias</a></p>
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
+ <script src="jquery.placeholder.js"></script>
+ <script>
+ // To test the @id toggling on password inputs in browsers that don’t support changing an input’s @type dynamically (e.g. Firefox 3.6 or IE), uncomment this:
+ // $.fn.hide = function() { return this; }
+ // Then uncomment the last rule in the <style> element (in the <head>).
+ $(function() {
+ // Invoke the plugin
+ $('input, textarea').placeholder();
+ // That’s it, really.
+ // Now display a message if the browser supports placeholder natively
+ var html;
+ if ($.fn.placeholder.input && $.fn.placeholder.textarea) {
+ html = '<strong>Your current browser natively supports <code>placeholder</code> for <code>input</code> and <code>textarea</code> elements.</strong> The plugin won’t run in this case, since it’s not needed. If you want to test the plugin, use an older browser ;)';
+ } else if ($.fn.placeholder.input) {
+ html = '<strong>Your current browser natively supports <code>placeholder</code> for <code>input</code> elements, but not for <code>textarea</code> elements.</strong> The plugin will only do its thang on the <code>textarea</code>s.';
+ }
+ if (html) {
+ $('<p class="note">' + html + '</p>').insertAfter('form');
+ }
+ });
+ </script>
+ </body>
+</html>
diff --git a/source/bower_components/jquery-placeholder/jquery.placeholder.js b/source/bower_components/jquery-placeholder/jquery.placeholder.js
new file mode 100644
index 0000000..c951197
--- /dev/null
+++ b/source/bower_components/jquery-placeholder/jquery.placeholder.js
@@ -0,0 +1,185 @@
+/*! http://mths.be/placeholder v2.0.8 by @mathias */
+;(function(window, document, $) {
+
+ // Opera Mini v7 doesn’t support placeholder although its DOM seems to indicate so
+ var isOperaMini = Object.prototype.toString.call(window.operamini) == '[object OperaMini]';
+ var isInputSupported = 'placeholder' in document.createElement('input') && !isOperaMini;
+ var isTextareaSupported = 'placeholder' in document.createElement('textarea') && !isOperaMini;
+ var prototype = $.fn;
+ var valHooks = $.valHooks;
+ var propHooks = $.propHooks;
+ var hooks;
+ var placeholder;
+
+ if (isInputSupported && isTextareaSupported) {
+
+ placeholder = prototype.placeholder = function() {
+ return this;
+ };
+
+ placeholder.input = placeholder.textarea = true;
+
+ } else {
+
+ placeholder = prototype.placeholder = function() {
+ var $this = this;
+ $this
+ .filter((isInputSupported ? 'textarea' : ':input') + '[placeholder]')
+ .not('.placeholder')
+ .bind({
+ 'focus.placeholder': clearPlaceholder,
+ 'blur.placeholder': setPlaceholder
+ })
+ .data('placeholder-enabled', true)
+ .trigger('blur.placeholder');
+ return $this;
+ };
+
+ placeholder.input = isInputSupported;
+ placeholder.textarea = isTextareaSupported;
+
+ hooks = {
+ 'get': function(element) {
+ var $element = $(element);
+
+ var $passwordInput = $element.data('placeholder-password');
+ if ($passwordInput) {
+ return $passwordInput[0].value;
+ }
+
+ return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '' : element.value;
+ },
+ 'set': function(element, value) {
+ var $element = $(element);
+
+ var $passwordInput = $element.data('placeholder-password');
+ if ($passwordInput) {
+ return $passwordInput[0].value = value;
+ }
+
+ if (!$element.data('placeholder-enabled')) {
+ return element.value = value;
+ }
+ if (value == '') {
+ element.value = value;
+ // Issue #56: Setting the placeholder causes problems if the element continues to have focus.
+ if (element != safeActiveElement()) {
+ // We can't use `triggerHandler` here because of dummy text/password inputs :(
+ setPlaceholder.call(element);
+ }
+ } else if ($element.hasClass('placeholder')) {
+ clearPlaceholder.call(element, true, value) || (element.value = value);
+ } else {
+ element.value = value;
+ }
+ // `set` can not return `undefined`; see http://jsapi.info/jquery/1.7.1/val#L2363
+ return $element;
+ }
+ };
+
+ if (!isInputSupported) {
+ valHooks.input = hooks;
+ propHooks.value = hooks;
+ }
+ if (!isTextareaSupported) {
+ valHooks.textarea = hooks;
+ propHooks.value = hooks;
+ }
+
+ $(function() {
+ // Look for forms
+ $(document).delegate('form', 'submit.placeholder', function() {
+ // Clear the placeholder values so they don't get submitted
+ var $inputs = $('.placeholder', this).each(clearPlaceholder);
+ setTimeout(function() {
+ $inputs.each(setPlaceholder);
+ }, 10);
+ });
+ });
+
+ // Clear placeholder values upon page reload
+ $(window).bind('beforeunload.placeholder', function() {
+ $('.placeholder').each(function() {
+ this.value = '';
+ });
+ });
+
+ }
+
+ function args(elem) {
+ // Return an object of element attributes
+ var newAttrs = {};
+ var rinlinejQuery = /^jQuery\d+$/;
+ $.each(elem.attributes, function(i, attr) {
+ if (attr.specified && !rinlinejQuery.test(attr.name)) {
+ newAttrs[attr.name] = attr.value;
+ }
+ });
+ return newAttrs;
+ }
+
+ function clearPlaceholder(event, value) {
+ var input = this;
+ var $input = $(input);
+ if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
+ if ($input.data('placeholder-password')) {
+ $input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
+ // If `clearPlaceholder` was called from `$.valHooks.input.set`
+ if (event === true) {
+ return $input[0].value = value;
+ }
+ $input.focus();
+ } else {
+ input.value = '';
+ $input.removeClass('placeholder');
+ input == safeActiveElement() && input.select();
+ }
+ }
+ }
+
+ function setPlaceholder() {
+ var $replacement;
+ var input = this;
+ var $input = $(input);
+ var id = this.id;
+ if (input.value == '') {
+ if (input.type == 'password') {
+ if (!$input.data('placeholder-textinput')) {
+ try {
+ $replacement = $input.clone().attr({ 'type': 'text' });
+ } catch(e) {
+ $replacement = $('<input>').attr($.extend(args(this), { 'type': 'text' }));
+ }
+ $replacement
+ .removeAttr('name')
+ .data({
+ 'placeholder-password': $input,
+ 'placeholder-id': id
+ })
+ .bind('focus.placeholder', clearPlaceholder);
+ $input
+ .data({
+ 'placeholder-textinput': $replacement,
+ 'placeholder-id': id
+ })
+ .before($replacement);
+ }
+ $input = $input.removeAttr('id').hide().prev().attr('id', id).show();
+ // Note: `$input[0] != input` now!
+ }
+ $input.addClass('placeholder');
+ $input[0].value = $input.attr('placeholder');
+ } else {
+ $input.removeClass('placeholder');
+ }
+ }
+
+ function safeActiveElement() {
+ // Avoid IE9 `document.activeElement` of death
+ // https://github.com/mathiasbynens/jquery-placeholder/pull/99
+ try {
+ return document.activeElement;
+ } catch (exception) {}
+ }
+
+}(this, document, jQuery));
diff --git a/source/bower_components/jquery-placeholder/tests/index.html b/source/bower_components/jquery-placeholder/tests/index.html
new file mode 100644
index 0000000..160e3e8
--- /dev/null
+++ b/source/bower_components/jquery-placeholder/tests/index.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <meta charset="utf-8">
+ <title>jquery-placeholder test suite</title>
+ <link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-1.12.0.css">
+ <style>
+ .placeholder { color: #aaa; }
+ #input-type-password { border: 5px solid lime; }
+ </style>
+ </head>
+ <body>
+ <div id="qunit"></div>
+ <div id="fixtures">
+ <!-- I explicitly want these to be visible in the page, for easier debugging. -->
+ <form>
+ <p><label><code>type=search</code> <input id="input-type-search" type="search" name="search" placeholder="Search this site..."></label></p>
+ <p><label><code>type=text</code> <input id="input-type-text" type="text" name="name" placeholder="e.g. John Doe"></label></p>
+ <p><label><code>type=email</code> <input id="input-type-email" type="email" name="email" placeholder="e.g. address@example.ext"></label></p>
+ <p><label><code>type=url</code> <input id="input-type-url" type="url" name="url" placeholder="e.g. http://mathiasbynens.be/"></label></p>
+ <p><label><code>type=tel</code> <input id="input-type-tel" type="tel" name="tel" placeholder="e.g. +32 472 77 69 88"></label></p>
+ <p><label for="input-type-password"><code>type=password</code> </label><input id="input-type-password" type="password" name="password" placeholder="e.g. hunter2"></p>
+ <p><label><code>textarea</code> <textarea id="textarea" name="message" placeholder="Your message goes here"></textarea></label></p>
+ <p><input type="submit" value="type=submit"></p>
+ </form>
+ </div>
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
+ <script src="http://code.jquery.com/qunit/qunit-1.12.0.js"></script>
+ <script src="../jquery.placeholder.js"></script>
+ <script src="tests.js"></script>
+ </body>
+</html>
diff --git a/source/bower_components/jquery-placeholder/tests/tests.js b/source/bower_components/jquery-placeholder/tests/tests.js
new file mode 100644
index 0000000..f721564
--- /dev/null
+++ b/source/bower_components/jquery-placeholder/tests/tests.js
@@ -0,0 +1,134 @@
+(function($) {
+
+ module('jQuery#placeholder');
+
+ test('caches results of feature tests', function() {
+ strictEqual(typeof $.fn.placeholder.input, 'boolean', '$.fn.placeholder.input');
+ strictEqual(typeof $.fn.placeholder.textarea, 'boolean', '$.fn.placeholder.textarea');
+ });
+
+ if ($.fn.placeholder.input && $.fn.placeholder.textarea) {
+ return;
+ }
+
+ var testElement = function($el) {
+
+ var el = $el[0];
+ var placeholder = el.getAttribute('placeholder');
+
+ strictEqual($el.placeholder(), $el, 'should be chainable');
+
+ strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`');
+ strictEqual($el.prop('value'), '', 'propHooks works properly');
+ strictEqual($el.val(), '', 'valHooks works properly');
+ ok($el.hasClass('placeholder'), 'should have `placeholder` class');
+
+ // test on focus
+ $el.focus();
+ strictEqual(el.value, '', '`value` should be the empty string on focus');
+ strictEqual($el.prop('value'), '', 'propHooks works properly');
+ strictEqual($el.val(), '', 'valHooks works properly');
+ ok(!$el.hasClass('placeholder'), 'should not have `placeholder` class on focus');
+
+ // and unfocus (blur) again
+ $el.blur();
+
+ strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`');
+ strictEqual($el.prop('value'), '', 'propHooks works properly');
+ strictEqual($el.val(), '', 'valHooks works properly');
+ ok($el.hasClass('placeholder'), 'should have `placeholder` class');
+
+ // change the value
+ $el.val('lorem ipsum');
+ strictEqual($el.prop('value'), 'lorem ipsum', '`$el.val(string)` should change the `value` property');
+ strictEqual(el.value, 'lorem ipsum', '`$el.val(string)` should change the `value` attribute');
+ ok(!$el.hasClass('placeholder'), '`$el.val(string)` should remove `placeholder` class');
+
+ // and clear it again
+ $el.val('');
+ strictEqual($el.prop('value'), '', '`$el.val("")` should change the `value` property');
+ strictEqual(el.value, placeholder, '`$el.val("")` should change the `value` attribute');
+ ok($el.hasClass('placeholder'), '`$el.val("")` should re-enable `placeholder` class');
+
+ // make sure the placeholder property works as expected.
+ strictEqual($el.prop('placeholder'), placeholder, '$el.prop(`placeholder`) should return the placeholder value');
+ $el.prop('placeholder', 'new placeholder');
+ strictEqual($el.prop('placeholder'), 'new placeholder', '$el.prop(`placeholder`, <string>) should set the placeholder value');
+ strictEqual($el.value, 'new placeholder', '$el.prop(`placeholder`, <string>) should update the displayed placeholder value');
+ $el.prop('placeholder', placeholder);
+ };
+
+ test('emulates placeholder for <input type=text>', function() {
+ testElement( $('#input-type-text') );
+ });
+
+ test('emulates placeholder for <input type=search>', function() {
+ testElement( $('#input-type-search') );
+ });
+
+ test('emulates placeholder for <input type=email>', function() {
+ testElement( $('#input-type-email') );
+ });
+
+ test('emulates placeholder for <input type=url>', function() {
+ testElement( $('#input-type-url') );
+ });
+
+ test('emulates placeholder for <input type=tel>', function() {
+ testElement( $('#input-type-tel') );
+ });
+
+ test('emulates placeholder for <input type=tel>', function() {
+ testElement( $('#input-type-tel') );
+ });
+
+ test('emulates placeholder for <input type=password>', function() {
+ var selector = '#input-type-password';
+
+ var $el = $(selector);
+ var el = $el[0];
+
+ var placeholder = el.getAttribute('placeholder');
+
+ strictEqual($el.placeholder(), $el, 'should be chainable');
+
+ // Re-select the element, as it gets replaced by another one in some browsers
+ $el = $(selector);
+ el = $el[0];
+
+ strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`');
+ strictEqual($el.prop('value'), '', 'propHooks works properly');
+ strictEqual($el.val(), '', 'valHooks works properly');
+ ok($el.hasClass('placeholder'), 'should have `placeholder` class');
+
+ // test on focus
+ $el.focus();
+
+ // Re-select the element, as it gets replaced by another one in some browsers
+ $el = $(selector);
+ el = $el[0];
+
+ strictEqual(el.value, '', '`value` should be the empty string on focus');
+ strictEqual($el.prop('value'), '', 'propHooks works properly');
+ strictEqual($el.val(), '', 'valHooks works properly');
+ ok(!$el.hasClass('placeholder'), 'should not have `placeholder` class on focus');
+
+ // and unfocus (blur) again
+ $el.blur();
+
+ // Re-select the element, as it gets replaced by another one in some browsers
+ $el = $(selector);
+ el = $el[0];
+
+ strictEqual(el.value, placeholder, 'should set `placeholder` text as `value`');
+ strictEqual($el.prop('value'), '', 'propHooks works properly');
+ strictEqual($el.val(), '', 'valHooks works properly');
+ ok($el.hasClass('placeholder'), 'should have `placeholder` class');
+
+ });
+
+ test('emulates placeholder for <textarea></textarea>', function() {
+ testElement( $('#textarea') );
+ });
+
+}(jQuery));