Browse Source

Make defaults configurable

Robin Herbots 15 years ago
parent
commit
7e5479d7dd
1 changed files with 7 additions and 6 deletions
  1. 7 6
      jquery.inputmask.js

+ 7 - 6
jquery.inputmask.js

@@ -3,16 +3,15 @@ Input Mask plugin for jquery
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 0.0.8
+Version: 0.0.9
    
 This plugin is based on the masked input plugin written by Josh Bush (digitalbush.com)
 */
 
 (function($) {
-
-    $.fn.inputmask = function(fn, options) {
+    $.inputmask = {
         //options default
-        var defaults = {
+        defaults: {
             placeholder: "_",
             mask: null,
             onComplete: null,
@@ -57,9 +56,11 @@ This plugin is based on the masked input plugin written by Josh Bush (digitalbus
             keyCode: { ALT: 18, BACKSPACE: 8, CAPS_LOCK: 20, COMMA: 188, COMMAND: 91, COMMAND_LEFT: 91, COMMAND_RIGHT: 93, CONTROL: 17, DELETE: 46, DOWN: 40, END: 35, ENTER: 13, ESCAPE: 27, HOME: 36, INSERT: 45, LEFT: 37, MENU: 93, NUMPAD_ADD: 107, NUMPAD_DECIMAL: 110, NUMPAD_DIVIDE: 111, NUMPAD_ENTER: 108,
                 NUMPAD_MULTIPLY: 106, NUMPAD_SUBTRACT: 109, PAGE_DOWN: 34, PAGE_UP: 33, PERIOD: 190, RIGHT: 39, SHIFT: 16, SPACE: 32, TAB: 9, UP: 38, WINDOWS: 91
             }
-        };
+        }
+    };
 
-        var opts = $.extend({}, defaults, options);
+    $.fn.inputmask = function(fn, options) {
+        var opts = $.extend({}, $.inputmask.defaults, options);
 
         if (typeof fn == "string") {
             if (fn == 'mask') {