Skip to content

Instantly share code, notes, and snippets.

@dkrutsko
Created November 24, 2015 17:33
Show Gist options
  • Save dkrutsko/a2d57a83417339adca3c to your computer and use it in GitHub Desktop.
Save dkrutsko/a2d57a83417339adca3c to your computer and use it in GitHub Desktop.
; (function ($, window, document, undefined)
{
"use strict";
////////////////////////////////////////////////////////////////////////////////
var PLUGIN_NAME = "passwordMeter";
////////////////////////////////////////////////////////////////////////////////
var DEFAULTS = {
showMeter : true, // Show the password meter
showMask : true, // Show/Hide the password
message : "", // Override bottom message
placeholder : "", // Input field placeholder
minLength : 0 // Type characters message
};
////////////////////////////////////////////////////////////////////////////////
function Plugin (element, options)
{
this.element = element;
// Copy the default settings into options field
this.options = $.extend ({ }, DEFAULTS, options);
////////////////////////////////////////////////////////////////////////////////
// INIT
}
Plugin.prototype = {
////////////////////////////////////////////////////////////////////////////////
getOptions: function()
{
return this.options;
},
////////////////////////////////////////////////////////////////////////////////
enableMeter: function()
{
},
////////////////////////////////////////////////////////////////////////////////
enableMasking: function()
{
},
////////////////////////////////////////////////////////////////////////////////
setMessage: function()
{
},
////////////////////////////////////////////////////////////////////////////////
setMinLength: function()
{
},
////////////////////////////////////////////////////////////////////////////////
setPlaceholder: function()
{
}
};
////////////////////////////////////////////////////////////////////////////////
$.fn[PLUGIN_NAME] = function (options)
{
if (typeof options === "string")
{
// Remove the name argument
[].shift.apply (arguments);
var plugin = this.data (PLUGIN_NAME);
// Call the desired function
return plugin[options].apply
(plugin, arguments);
}
else
{
// Create a new plugin
this.data (PLUGIN_NAME,
new Plugin (this, options));
}
};
}) (jQuery, window, document);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment