(function (factory, global) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(['jquery'], factory); } else { // Browser globals. factory(global.jQuery); } }(function ($, undef) { var dataKey = 'plugin_hideShowPassword' , shorthandArgs = ['show', 'innerToggle'] , SPACE = 32 , ENTER = 13; var canSetInputAttribute = (function(){ var body = document.body , input = document.createElement('input') , result = true; if (! body) { body = document.createElement('body'); } input = body.appendChild(input); try { input.setAttribute('type', 'text'); } catch (e) { result = false; } body.removeChild(input); return result; }()); var defaults = { // Visibility of the password text. Can be true, false, 'toggle' // or 'infer'. If 'toggle', it will be the opposite of whatever // it currently is. If 'infer', it will be based on the input // type (false if 'password', otherwise true). show: 'infer', // Set to true to create an inner toggle for this input. Can // also be sent to an event name to delay visibility of toggle // until that event is triggered on the input element. innerToggle: false, // If false, the plugin will be disabled entirely. Set to // the outcome of a test to insure input attributes can be // set after input has been inserted into the DOM. enable: canSetInputAttribute, // Class to add to input element when the plugin is enabled. className: 'hideShowPassword-field', // Event to trigger when the plugin is initialized and enabled. initEvent: 'hideShowPasswordInit', // Event to trigger whenever the visibility changes. changeEvent: 'passwordVisibilityChange', // Properties to add to the input element. props: { autocapitalize: 'off', autocomplete: 'off', autocorrect: 'off', spellcheck: 'false' }, // Options specific to the inner toggle. toggle: { // The element to create. element: '