Bug Tracker

Changeset 4242

Show
Ignore:
Timestamp:
12/19/07 21:46:56 (1 year ago)
Author:
joern.zaefferer
Message:

perfected focusin event, thanks to Aaron and Brandon

Location:
trunk/plugins/validate
Files:
1 added
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/plugins/validate/lib/jquery.js

    r4222 r4242  
    11(function(){ 
    22/* 
    3  * jQuery 1.2.2-pre - New Wave Javascript 
     3 * jQuery 1.2.2pre - New Wave Javascript 
    44 * 
    55 * Copyright (c) 2007 John Resig (jquery.com) 
     
    77 * and GPL (GPL-LICENSE.txt) licenses. 
    88 * 
    9  * $Date: 2007-12-18 18:19:33 +0100 (Di, 18 Dez 2007) $ 
    10  * $Rev: 4220 $ 
     9 * $Date: 2007-12-19 19:23:46 +0100 (Mi, 19 Dez 2007) $ 
     10 * $Rev: 4236 $ 
    1111 */ 
    1212 
     
    800800                jQuery.swap( elem, props, getWH ); 
    801801             
    802             return val; 
     802            return Math.max(0, val); 
    803803        } 
    804804         
     
    14891489                    r = []; 
    14901490 
    1491                     nodeName = m[2].toUpperCase(), merge = {}; 
     1491                    var merge = {}; 
     1492                    nodeName = m[2].toUpperCase(); 
    14921493                    m = m[1]; 
    14931494 
     
    18931894        if ( events ) { 
    18941895            // Unbind all events for the element 
    1895             if ( !types ) 
     1896            if ( types == undefined ) 
    18961897                for ( var type in events ) 
    18971898                    this.remove( elem, type ); 
     
    20542055 
    20552056    fix: function(event) { 
     2057        // Short-circuit if the event has already been fixed by jQuery.event.fix 
     2058        if ( event[ expando ] ) 
     2059            return event; 
     2060             
    20562061        // store a copy of the original event object  
    20572062        // and clone to set read-only properties 
    20582063        var originalEvent = event; 
    20592064        event = jQuery.extend({}, originalEvent); 
     2065         
     2066        // Mark the event as fixed by jQuery.event.fix 
     2067        event[ expando ] = true; 
    20602068         
    20612069        // add preventDefault and stopPropagation since  
     
    32813289         
    32823290            // Get parent scroll offsets 
    3283             while ( parent.tagName && !/^body|html$/i.test(parent.tagName) ) { 
     3291            while ( parent && parent.tagName && !/^body|html$/i.test(parent.tagName) ) { 
    32843292                // Remove parent scroll UNLESS that parent is inline or a table to work around Opera inline/table scrollLeft/Top bug 
    32853293                if ( !/^inline|table.*$/i.test(jQuery.css(parent, "display")) ) 
     
    33123320 
    33133321    function border(elem) { 
    3314         add( jQuery.css(elem, "borderLeftWidth"), jQuery.css(elem, "borderTopWidth") ); 
     3322        add( jQuery.curCSS(elem, "borderLeftWidth", true), jQuery.curCSS(elem, "borderTopWidth", true) ); 
    33153323    } 
    33163324 
  • trunk/plugins/validate/test/events.html

    r4224 r4242  
    77<link rel="stylesheet" type="text/css" media="screen" href="css/screen.css" /> 
    88<script src="../lib/jquery.js" type="text/javascript"></script> 
     9<script src="jquery.delegate.js" type="text/javascript"></script> 
    910<script src="firebug/firebug.js" type="text/javascript"></script> 
    1011 
    1112<script type="text/javascript"> 
    1213$().ready(function() { 
    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             return jQuery.event.handle.apply(this, args); 
    28         } 
    29     } 
    30      
    31     function handler(event) { 
    32         var target = $(event.target); 
    33         if (target.is(":text, textarea")) { 
    34             target.addClass("focus").one("blur", function() { 
    35                 $(this).removeClass("focus"); 
    36             }); 
    37         } 
    38     } 
    39     $("#commentForm").bind("focusin", handler); 
     14    $("#commentForm").delegate("focusin", ":text, textarea", function() { 
     15        this.addClass("focus").one("blur", function() { 
     16            $(this).removeClass("focus"); 
     17        }); 
     18    }); 
    4019    $("#remove").click(function() { 
    4120        $("#commentForm").unbind("focusin");