r2366 - Tweaked the blur behavior when allowPartials is true.

r2366 - Tweaked the blur behavior when allowPartials is true.


Author: powella
Date: Mon Mar 23 15:42:22 2009
New Revision: 2366
Modified:
branches/dev/mask/ui/ui.mask.js
Log:
Tweaked the blur behavior when allowPartials is true.
Modified: branches/dev/mask/ui/ui.mask.js
==============================================================================
--- branches/dev/mask/ui/ui.mask.js    (original)
+++ branches/dev/mask/ui/ui.mask.js    Mon Mar 23 15:42:22 2009
@@ -25,7 +25,8 @@
        if(!this.options.mask || !this.options.mask.length) return; //no mask
pattern defined. no point in continuing.
        if(!this.options.placeholder || !this.options.placeholder.length)
this.options.placeholder = '_'; //in case the user decided to nix a
placeholder.
-        var input = this.element,
+        var widget = this,
+            input = this.element,
            opts = this.options,
            mask = opts.mask,
            defs = $.ui.mask.definitions,
@@ -176,7 +177,7 @@
                }
            }
            if (!allow && lastMatch + 1 < partialPosition) {
-                if(!opts.allowPartials){
+                if(!opts.allowPartials || !widget.value().length){
                    input.val("");
                    clearBuffer(0, len);
                }
@@ -227,7 +228,7 @@
                    setTimeout(function() { caret(checkVal(true)); }, 0);
                });
-        checkVal(); //Perform initial check for existing values
+        checkVal((input.val().length && opts.allowPartials)); //Perform initial
check for existing values
    },
@@ -261,16 +262,14 @@
        mask: '',
        placeholder: '_',
        completed: null,
-        allowPartials: false
+        allowPartials: $.ui.mask.allowPartials
    },
-    //Predefined character definitions
-    definitions: {
+    definitions: { //Predefined character definitions
        '#': "[\\d]",
        'a': "[A-Za-z]",
        '*': "[A-Za-z0-9]"
    },
-    //Helper Function for Caret positioning
-    caret: function(element, begin, end) {
+    caret: function(element, begin, end) {    //Helper Function for Caret
positioning
        var input = element[0];
        if (typeof begin == 'number') {
            end = (typeof end == 'number') ? end : begin;