Show More
@@ -6,71 +6,64 b' function addImgPreview() {' | |||||
6 | } |
|
6 | } | |
7 | }); |
|
7 | }); | |
8 |
|
8 | |||
9 |
$(' |
|
9 | $('body').on('click', '.thumb', function() { | |
10 | $(this).on('click', function() { |
|
10 | var el = $(this); | |
11 | var el = $(this); |
|
11 | var thumb_id = 'full' + el.find('img').attr('alt'); | |
12 | var thumb_id = 'full'+el.find('img').attr('alt'); |
|
|||
13 |
|
||||
14 | if(!$('#'+thumb_id).length) { |
|
|||
15 | var img_w = el.find('img').attr('data-width'); |
|
|||
16 | var img_h = el.find('img').attr('data-height'); |
|
|||
17 |
|
||||
18 | var win_w = $(window).width(); |
|
|||
19 | var win_h = $(window).height(); |
|
|||
20 |
|
12 | |||
21 | //new image size |
|
13 | if(!$('#'+thumb_id).length) { | |
22 | if (img_w > win_w) { |
|
14 | var img_w = el.find('img').attr('data-width'); | |
23 | img_h = img_h * (win_w/img_w); |
|
15 | var img_h = el.find('img').attr('data-height'); | |
24 | img_w = win_w; |
|
|||
25 | } |
|
|||
26 | if (img_h > win_h) { |
|
|||
27 | img_w = img_w * (win_h/img_h); |
|
|||
28 | img_h = win_h; |
|
|||
29 | } |
|
|||
30 |
|
||||
31 | var img_pv = new Image(); |
|
|||
32 |
|
16 | |||
33 | $(img_pv) |
|
17 | var win_w = $(window).width(); | |
34 | .addClass('img-full') |
|
18 | var win_h = $(window).height(); | |
35 | .attr('id', thumb_id) |
|
19 | //new image size | |
36 | .attr('src', $(el).attr('href')) |
|
20 | if (img_w > win_w) { | |
37 | .appendTo($(el)) |
|
21 | img_h = img_h * (win_w/img_w); | |
38 |
|
|
22 | img_w = win_w; | |
39 | 'width': img_w, |
|
|||
40 | 'height': img_h, |
|
|||
41 | 'left': (win_w - img_w) / 2, |
|
|||
42 | 'top': ((win_h - img_h) / 2) |
|
|||
43 | }) |
|
|||
44 |
|
||||
45 | //scaling preview |
|
|||
46 | .mousewheel(function(event, delta) { |
|
|||
47 | var cx = event.originalEvent.clientX, |
|
|||
48 | cy = event.originalEvent.clientY, |
|
|||
49 | i_w = parseFloat($(img_pv).width()), |
|
|||
50 | i_h = parseFloat($(img_pv).height()), |
|
|||
51 | newIW = i_w * (delta > 0 ? 1.25 : 0.8), |
|
|||
52 | newIH = i_h * (delta > 0 ? 1.25 : 0.8); |
|
|||
53 |
|
||||
54 | $(img_pv).width(newIW); |
|
|||
55 | $(img_pv).height(newIH); |
|
|||
56 |
|
||||
57 | //set position |
|
|||
58 | $(img_pv) |
|
|||
59 | .css({ |
|
|||
60 | left: parseInt(cx - (newIW/i_w) * (cx - parseInt($(img_pv).position().left, 10)), 10), |
|
|||
61 | top: parseInt(cy - (newIH/i_h) * (cy - parseInt($(img_pv).position().top, 10)), 10) |
|
|||
62 | }); |
|
|||
63 |
|
||||
64 | return false; |
|
|||
65 | } |
|
|||
66 | ).draggable() |
|
|||
67 | } |
|
23 | } | |
68 | else { |
|
24 | if (img_h > win_h) { | |
69 | $('#'+thumb_id).remove(); |
|
25 | img_w = img_w * (win_h/img_h); | |
|
26 | img_h = win_h; | |||
70 | } |
|
27 | } | |
71 |
|
28 | |||
72 | //prevent default |
|
29 | var img_pv = new Image(); | |
73 | return false; |
|
30 | $(img_pv) | |
74 | }); |
|
31 | .addClass('img-full') | |
|
32 | .attr('id', thumb_id) | |||
|
33 | .attr('src', $(el).attr('href')) | |||
|
34 | .appendTo($(el)) | |||
|
35 | .css({ | |||
|
36 | 'width': img_w, | |||
|
37 | 'height': img_h, | |||
|
38 | 'left': (win_w - img_w) / 2, | |||
|
39 | 'top': ((win_h - img_h) / 2) | |||
|
40 | }) | |||
|
41 | //scaling preview | |||
|
42 | .mousewheel(function(event, delta) { | |||
|
43 | var cx = event.originalEvent.clientX, | |||
|
44 | cy = event.originalEvent.clientY, | |||
|
45 | i_w = parseFloat($(img_pv).width()), | |||
|
46 | i_h = parseFloat($(img_pv).height()), | |||
|
47 | newIW = i_w * (delta > 0 ? 1.25 : 0.8), | |||
|
48 | newIH = i_h * (delta > 0 ? 1.25 : 0.8); | |||
|
49 | ||||
|
50 | $(img_pv).width(newIW); | |||
|
51 | $(img_pv).height(newIH); | |||
|
52 | //set position | |||
|
53 | $(img_pv) | |||
|
54 | .css({ | |||
|
55 | left: parseInt(cx - (newIW/i_w) * (cx - parseInt($(img_pv).position().left, 10)), 10), | |||
|
56 | top: parseInt(cy - (newIH/i_h) * (cy - parseInt($(img_pv).position().top, 10)), 10) | |||
|
57 | }); | |||
|
58 | ||||
|
59 | return false; | |||
|
60 | } | |||
|
61 | ).draggable() | |||
|
62 | } | |||
|
63 | else { | |||
|
64 | $('#'+thumb_id).remove(); | |||
|
65 | } | |||
|
66 | //prevent default | |||
|
67 | return false; | |||
75 | }); |
|
68 | }); | |
76 | } No newline at end of file |
|
69 | } |
@@ -49,6 +49,9 b' function tab_handler(ev)' | |||||
49 | $('#posts').replaceWith(table_dom); |
|
49 | $('#posts').replaceWith(table_dom); | |
50 | break; |
|
50 | break; | |
51 | } |
|
51 | } | |
|
52 | ||||
|
53 | //TODO: временно | |||
|
54 | addImgPreview(); | |||
52 | } |
|
55 | } | |
53 |
|
56 | |||
54 | function make_normal_dom() |
|
57 | function make_normal_dom() | |
@@ -70,8 +73,6 b' function make_table_dom()' | |||||
70 | ); |
|
73 | ); | |
71 | } |
|
74 | } | |
72 | ); |
|
75 | ); | |
73 | //TODO: временно |
|
|||
74 | addImgPreview(); |
|
|||
75 | } |
|
76 | } | |
76 |
|
77 | |||
77 | function moveCaretToEnd(el) { |
|
78 | function moveCaretToEnd(el) { |
General Comments 0
You need to be logged in to leave comments.
Login now