cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
//**************************************************************
// jQZoom allows you to realize a small magnifier window,close
// to the image or images on your web page easily.
//
// jqZoom version 2.0
// Author Doc. Ing. Renzi Marco(www.mind-projects.it)
// First Release on Dec 05 2007
// i'm searching for a job,pick me up!!!
// mail: renzi.mrc@gmail.com
//**************************************************************
 
(function($){
 
        $.fn.jqueryzoom = function(options){
 
        var settings = {
                xzoom: 200,        //zoomed width default width
                yzoom: 200,        //zoomed div default width
                offset: 10,        //zoomed div default offset
                position: "right", //zoomed div default position,offset position is to the right of the image
                preload: 1
 
            };
 
            if(options) {
                $.extend(settings, options);
            }
 
            var noalt='';
 
            $(this).hover(function(){
 
            var imageLeft = this.offsetLeft;
            var imageRight = this.offsetRight;
            var imageTop =  $(this).get(0).offsetTop;
            var imageWidth = $(this).children('img').get(0).offsetWidth;
            var imageHeight = $(this).children('img').get(0).offsetHeight;
 
 
                noalt= $(this).children("img").attr("alt");
 
            var bigimage = $(this).children("img").attr("jqimg");
                $(this).children("img").attr("alt",'');
 
            if($("div.zoomdiv").get().length == 0){
 
            $(this).after("<div class='zoomdiv'><img class='bigimg' src='"+bigimage+"'/></div>");
 
            $(this).append("<div class='jqZoomPup'>&nbsp;</div>");
 
            }
 
 
            if(settings.position == "right"){
 
            leftpos = imageLeft + imageWidth + settings.offset;
 
            }else{
 
            leftpos = imageLeft - settings.xzoom - settings.offset;
 
            }
 
            $("div.zoomdiv").css({ top: imageTop,left: leftpos });
 
            $("div.zoomdiv").width(settings.xzoom);
 
            $("div.zoomdiv").height(settings.yzoom);
 
            $("div.zoomdiv").show();
 
 
 
 
                    $(document.body).mousemove(function(e){
 
 
 
                   $("div.jqZoomPup").hide();
 
 
                    var bigwidth = $(".bigimg").get(0).offsetWidth;
 
                    var bigheight = $(".bigimg").get(0).offsetHeight;
 
                    var scaley ='x';
 
                    var scalex= 'y';
 
 
                    if(isNaN(scalex)|isNaN(scaley)){
 
                    var scalex = (bigwidth/imageWidth);
 
                    var scaley = (bigheight/imageHeight);
 
 
 
                    $("div.jqZoomPup").width((settings.xzoom)/scalex );
 
                    $("div.jqZoomPup").height((settings.yzoom)/scaley);
 
 
                     $('div.jqZoomPup').show();
 
                     $("div.jqZoomPup").css('visibility','visible');
 
 
                   }
 
 
                    mouse = new MouseEvent(e);
 
 
                    xpos = mouse.x - $("div.jqZoomPup").width()/2 - imageLeft;
 
                    ypos = mouse.y - $("div.jqZoomPup").height()/2 - imageTop ;
 
 
 
 
                    xpos = (mouse.x - $("div.jqZoomPup").width()/2 < imageLeft ) ? 0 : (mouse.x + $("div.jqZoomPup").width()/2 > imageWidth + imageLeft ) ?  (imageWidth -$("div.jqZoomPup").width() -2)  : xpos;
 
                    ypos = (mouse.y - $("div.jqZoomPup").height()/2 < imageTop ) ? 0 : (mouse.y + $("div.jqZoomPup").height()/2  > imageHeight + imageTop ) ?  (imageHeight - $("div.jqZoomPup").height() -2 ) : ypos;
 
 
 
                    $("div.jqZoomPup").css({ top: ypos,left: xpos });
 
                    $("div.jqZoomPup").show();
 
 
                    //scrolly = mouse.y - imageTop - ($("div.zoomdiv").height()*1/scaley)/2 ;
 
                    scrolly = ypos;
 
                    $("div.zoomdiv").get(0).scrollTop = scrolly * scaley;
 
                    scrollx = xpos;
 
                    //scrollx =    mouse.x - imageLeft - ($("div.zoomdiv").width()*1/scalex)/2 ;
 
                    $("div.zoomdiv").get(0).scrollLeft = (scrollx) * scalex ;
 
 
                    });
            },function(){
 
                   $(this).children("img").attr("alt",noalt);
               $(document.body).unbind("mousemove");
               $("div.jqZoomPup").remove();
               $("div.zoomdiv").remove();
 
            });
 
             count=0;
 
        if(settings.preload){
 
        $('body').append("<div style='display:none;' class='jqPreload"+count+"'>sdsdssdsd</div>");
 
        $(this).each(function(){
 
        var imagetopreload= $(this).children("img").attr("jqimg");
 
        var content = jQuery('div.jqPreload'+count+'').html();
 
        jQuery('div.jqPreload'+count+'').html(content+'<img src=\"'+imagetopreload+'\">');
 
        });
 
        }
 
        }
 
})(jQuery);
 
function MouseEvent(e) {
this.x = e.pageX
this.y = e.pageY
}