ソースを参照

add support for readonly and disabled attributes/properties on the input element

Robin Herbots 13 年 前
コミット
31eca7c16a
1 ファイル変更25 行追加1 行削除
  1. 25 1
      js/jquery.inputmask.js

+ 25 - 1
js/jquery.inputmask.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2012 Robin Herbots
 * Copyright (c) 2010 - 2012 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 1.0.11
+* Version: 1.0.12
 */
 */
 
 
 (function($) {
 (function($) {
@@ -645,7 +645,31 @@
                 } else if (opts.clearMaskOnLostFocus && el._valueGet() == _buffer.join(''))
                 } else if (opts.clearMaskOnLostFocus && el._valueGet() == _buffer.join(''))
                     el._valueSet('');
                     el._valueSet('');
 
 
+				installEventRuler(el);
+
                 //private functions
                 //private functions
+                function installEventRuler(npt) {
+                 	var events = $._data(npt).events;
+
+					$.each(events, function(eventType, eventHandlers){
+                         $(npt).bind(eventType, function(event) { 
+                         							if (this.readOnly || this.disabled) {
+                         							  event.stopPropagation(); 
+                         							  event.stopImmediatePropagation(); 
+                         							  event.preventDefault();  
+                         							  return false;
+                         							}
+                         						});
+                         //!! the bound handlers are executed in the order they where bound
+                         //reorder the events
+                         var ourHandler = eventHandlers[eventHandlers.length - 1];
+                         for (i = eventHandlers.length - 1; i > 0; i--) {
+                             eventHandlers[i] = eventHandlers[i - 1];
+                         }
+                         eventHandlers[0] = ourHandler;
+                    });
+				}
+                               
                 function patchValueProperty(npt) {
                 function patchValueProperty(npt) {
                     var valueProperty;
                     var valueProperty;
                     if (Object.getOwnPropertyDescriptor)
                     if (Object.getOwnPropertyDescriptor)