Changeset 4222 for trunk/plugins/validate/test/events.html
- Timestamp:
- 12/18/07 23:50:20 (1 year ago)
- Files:
-
- 1 modified
-
trunk/plugins/validate/test/events.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/plugins/validate/test/events.html
r4183 r4222 11 11 <script type="text/javascript"> 12 12 $().ready(function() { 13 var current; 14 function focus(event) { 15 if (current != null) 16 return; 17 var form = $(this); 13 jQuery.event.special.focusin = { 14 setup: function() { 15 if ($.browser.msie) 16 return false; 17 this.addEventListener("focus", jQuery.event.special.focusin.handler, true); 18 }, 19 teardown: function() { 20 if ($.browser.msie) 21 return false; 22 this.removeEventListener("focus", jQuery.event.special.focusin.handler, true); 23 }, 24 handler: function(event) { 25 var args = Array.prototype.slice.call( arguments, 1 ); 26 args.unshift(jQuery.extend({}, event, { type: "focusin" })); 27 var val = jQuery.event.handle.apply(this, args); 28 return val; 29 } 30 } 31 32 function handler(event) { 18 33 var target = $(event.target); 19 if (target.is("label") && event.type != "mousedown") {20 target = $("#" + target.attr("for"));21 }22 34 if (target.is(":text, textarea")) { 23 current = target; 24 target.addClass("focus").one("blur", function() { 35 $(event.target).addClass("focus").one("blur", function() { 25 36 $(this).removeClass("focus"); 26 current = null;27 37 }); 28 38 } 29 39 } 30 $("#commentForm"). keyup(focus).mousedown(focus).click(focus).submit(function() {31 return false;32 });33 40 $("#commentForm").bind("focusin", handler); 41 $("#remove").click(function() { 42 $("#commentForm").unbind("focusin"); 43 }) 34 44 }); 35 45 </script> … … 68 78 </form> 69 79 80 <button id="remove">Remove focus handler</button> 81 70 82 </body> 71 83 </html>
