root / trunk / web / dojo / dojox / image / MagnifierLite.js @ 12
History | View | Annotate | Download (2.06 KB)
1 |
/*
|
---|---|
2 |
Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
|
3 |
Available via Academic Free License >= 2.1 OR the modified BSD license.
|
4 |
see: http://dojotoolkit.org/license for details
|
5 |
*/
|
6 |
|
7 |
|
8 |
if(!dojo._hasResource["dojox.image.MagnifierLite"]){ |
9 |
dojo._hasResource["dojox.image.MagnifierLite"]=true; |
10 |
dojo.provide("dojox.image.MagnifierLite");
|
11 |
dojo.experimental("dojox.image.MagnifierLite");
|
12 |
dojo.require("dijit._Widget");
|
13 |
dojo.declare("dojox.image.MagnifierLite",dijit._Widget,{glassSize:125,scale:6,postCreate:function(){ |
14 |
this.inherited(arguments); |
15 |
this._adjustScale();
|
16 |
this._createGlass();
|
17 |
this.connect(this.domNode,"onmouseenter","_showGlass"); |
18 |
this.connect(this.glassNode,"onmousemove","_placeGlass"); |
19 |
this.connect(this.img,"onmouseout","_hideGlass"); |
20 |
this.connect(window,"onresize","_adjustScale"); |
21 |
},_createGlass:function(){ |
22 |
var _1=this.glassNode=dojo.create("div",{style:{height:this.glassSize+"px",width:this.glassSize+"px"},className:"glassNode"},dojo.body()); |
23 |
this.surfaceNode=_1.appendChild(dojo.create("div")); |
24 |
this.img=dojo.place(dojo.clone(this.domNode),_1); |
25 |
dojo.style(this.img,{position:"relative",top:0,left:0,width:this._zoomSize.w+"px",height:this._zoomSize.h+"px"}); |
26 |
},_adjustScale:function(){ |
27 |
this.offset=dojo.coords(this.domNode,true); |
28 |
this._imageSize={w:this.offset.w,h:this.offset.h}; |
29 |
this._zoomSize={w:this._imageSize.w*this.scale,h:this._imageSize.h*this.scale}; |
30 |
},_showGlass:function(e){ |
31 |
this._placeGlass(e);
|
32 |
dojo.style(this.glassNode,{visibility:"visible",display:""}); |
33 |
},_hideGlass:function(e){ |
34 |
dojo.style(this.glassNode,{visibility:"hidden",display:"none"}); |
35 |
},_placeGlass:function(e){ |
36 |
this._setImage(e);
|
37 |
var _2=Math.floor(this.glassSize/2); |
38 |
dojo.style(this.glassNode,{top:Math.floor(e.pageY-_2)+"px",left:Math.floor(e.pageX-_2)+"px"}); |
39 |
},_setImage:function(e){ |
40 |
var _3=(e.pageX-this.offset.l)/this.offset.w,_4=(e.pageY-this.offset.t)/this.offset.h,x=(this._zoomSize.w*_3*-1)+(this.glassSize*_3),y=(this._zoomSize.h*_4*-1)+(this.glassSize*_4); |
41 |
dojo.style(this.img,{top:y+"px",left:x+"px"}); |
42 |
},destroy:function(_5){ |
43 |
dojo.destroy(this.glassNode);
|
44 |
this.inherited(arguments); |
45 |
}}); |
46 |
} |