msg2.js 1.61 KB
(function($){
    $.fn.msg = function() {
    var obj = this;


    var win = function(id_win,e,title){
            $win = $('<div id='+id_win+' class="win"></div>');
                $win.css({
                    'border-radius': 5 + 'px'
                    ,'-moz-border-radius': 5 + 'px'
                    ,'-webkit-border-radius': 5 + 'px'
                });
                var cnt = '<div class="cont_win">';
                if($(e).attr('href')!="#")cnt += ' <img src="'+$(e).attr('href')+'" align="left" />';
				cnt += title;
                cnt += '</div>';
                $content = $(cnt);
                $close = $('<div class="close_win"></div>');
                $($close).bind('click',function(){
                 $($win).hide();
                });
                
                    offSetTop = $(e).offset().top - 50;
                    offSetLeft = $(e).offset().left + $(e).outerWidth() - 515;
                    $win.css({'top' : offSetTop + 'px', 'left' : offSetLeft + 'px'});
             $($win).append($close);
             $($win).append($content);
             $('body').append($win);
    }



    var find = function(){ 
     $(obj).each(function (i) {
       var href = $(this).attr('href');
       var title = $(this).attr('title');
       var id_win = 'msg_win'+i;
       $(this).bind('click',function(){
       $('.win').remove();
        win(id_win,this,title);
       return false;
       })
     })
    }
    
    var close = function(id){
    $('#tip_close').bind('click',function(){
     $('#'+id).remove();
    });
    }
    

    find();

    };
})(jQuery);
$(function(){
 $("a[rel~='msg']").msg();
})