jquery图片插件(未全完成)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>无标题文档</title>

<script type="text/javascript"  src="jquery-1.4.2.js"></script>

<script type="text/javascript">

$(function(){

var IPP=$(".preview_class").IPP(); //图片插件

});

 

$.fn.extend({

IPP:function(){

$(this).bind("mouseover",function(){

$(this).focus();

 

});

//取得焦点事件

$(this).bind("focus",function(){

var imgObj=new Image(); //图片对象

imgObj.src=$(this).attr("href");

var source_width=$(this).width();

var source_height=$(this).height();

var source_x=$(this).offset().left;

var source_y=$(this).offset().top;

 

if($("#img_plug_preview").length>0){

$("#img_plug_preview").attr("src",imgObj.src);

}else{

var img_plug_preview= document.createElement("img");

$(img_plug_preview).attr("id","img_plug_preview");

$(img_plug_preview).css("border","1px solid #99bbe8");

$(img_plug_preview).css("z-index","5000");

$(img_plug_preview).css("position","absolute");

$(img_plug_preview).attr("src",imgObj.src);

 

$(img_plug_preview).bind("click",function(){

alert($(this).attr("src"));

$("#img_plug_preview").remove();

});

$(img_plug_preview).error(function(){

//$(this).attr("src","easier_5/assets/error.png");

$("#img_plug_preview").remove();

});

$(document.body).append($(img_plug_preview));

}

//公共值 

$("#img_plug_preview").css("display","none"); //先隐藏

$("#img_plug_preview").slideDown("fast",function(){

var margin_top=source_y; //距离上边的距离

var margin_right=$(document).width()-(source_width+source_x); //距离右边的距离

var margin_bottom=$(document).height()-(source_height+source_y); //距离下边的距离

var margin_left=source_x; //距离左边的距离

var x=source_x+source_width+10;

var y=source_y+(source_height/2);

 

var borderWidth=1;

//上下左右都大于本身

if((margin_top>imgObj.width+20)||(margin_right>imgObj.height)||(margin_bottom>imgObj.width)||(margin_left>imgObj.height)){

//显示下边

//x=source_x+((source_width/2)/2)-borderWidth;

//y=source_y+source_height+10;

x=source_x+source_width+10;

y=source_y+(source_height/2/2);

}

 

//右边小于宽度;+下边也小于高度

if((margin_right<imgObj.width)&&(margin_bottom<imgObj.height)){

//显示上面

x=source_x+((source_width/2)/2)-borderWidth; 

y=source_y-imgObj.height-10;

}

//右边小于宽度;+下边大于高度

if((margin_right<imgObj.width)&&(margin_bottom>imgObj.height)){

//显示左边

x=source_x-imgObj.width-10;

y=source_y-(((source_height/2))+borderWidth*4);

}

//左边小于宽度;+上边小于高度

if((margin_left<imgObj.width)&&(margin_top<imgObj.height)){

//显示右边

x=source_x+source_width+10;

y=source_y+(source_height/2/2);

 

}

 

$("#img_plug_preview").css("left",x);

$("#img_plug_preview").css("top",y); 

}); 

});

 

$(document).click(function(){ if( $("#img_plug_preview").length>0 ){ $("#img_plug_preview").remove(); } });

 

}

});

 

 

 

</script>

 

</head>

 

<body >

<div style="height:20px;border:1px solid #99bbe8;text-align:left">

<a href="easier_5/assets/zoom-out.png1" class='preview_class'>zoom-out.png</a><br/>

<div><br/>

<div style="height:20px;border:1px solid #99bbe8;text-align:left">

<a href="easier_5/assets/zoom-out.png" class='preview_class'>zoom-out.png</a><br/>

<div><br/>

<div style="height:20px;border:1px solid #99bbe8;text-align:center">

<a href="easier_5/assets/zoom-out.png" class='preview_class'>zoom-out.png</a><br/>

<div><br/>

<div style="height:20px;border:1px solid #99bbe8;text-align:right">

<a href="easier_5/assets/zoom-out.png" class='preview_class'>zoom-out.png</a><br/>

<div><br/>

<p style="text-align:center">

<a href="easier_5/assets/pause.png" class='preview_class'>pause.png</a><br/>

<a href="easier_5/assets/player.png" class='preview_class'>player.png</a><br/>

<a href="easier_5/assets/rotate-left.png" class='preview_class'>rotate-left.png</a><br/>

<a href="easier_5/assets/rotate-right.png" class='preview_class'>rotate-right.png</a><br/>

<a href="easier_5/assets/zoom-in.png" class='preview_class'>zoom-in.png</a><br/>

<a href="easier_5/assets/zoom-out.png" class='preview_class'>zoom-out.png</a><br/>

</p>

<p>

<div style="height:20px;border:0px solid #99bbe8;text-align:right;margin-top:420px;">

<a href="easier_5/assets/zoom-out.png" class='preview_class'>zoom-out.png</a><br/>

<div

</p>

</body>

</html>


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值