May 27

Bind an event handler to one or more elements, allow to abort the bindation on other event. Usefull for showing tooltip when mouse moves on elements after a few time.

View: Demo

// define
(function($){
    $.fn.lazybind = function(event, fn, timeout, abort){
        var timer = null;
        $(this).bind(event, function(e){
            var ev = e;
            timer = setTimeout(function(){
                fn(ev);
            }, timeout);
        });
        if(abort == undefined){
            return;
        }
        $(this).bind(abort, function(){
            if(timer != null){
                clearTimeout(timer);
            }
        });
    };
})(jQuery);

// example
$('#my_img').lazybind(
    'mouseover',
    function(){
        alert(1);
    },
    500,
    'mouseout');

@Parameters

  • event: string, event to bind to
  • fn: function, callback
  • timeout: int, time to wait before fn being called, in millisecond
  • abort: string, on which event the binding will be cancelled.

Written by ideawu at 2011-05-27 16:40:48 | tags: ,

Dec 13

Recently, I had a experience of Google interview(Beijing, China), I went through for three rounds of the interview. Firstly a phone interview, secondly an on-site interview in Google building, thirdly also an interview in Google building but with two people.

We didn’t talk too much on the phone during first call from Google HR, a kind lady. Actually, it was because my spoken English, you know, I didn’t even speak a English word during the past threes year. But I suggest I should directly go to there office and have a face-to-face interview.

Continue reading »

Written by ideawu at 2010-12-13 23:17:17

Nov 12

Written in JavaScript+HTML+CSS, run on most web browser, such as Firefox, Internet Explorer, Chrome, Opera. Free of charge.

Play Online Now >>

Written by ideawu at 2010-11-12 14:43:48