Show More
@@ -0,0 +1,76 b'' | |||
|
1 | function addImgPreview() { | |
|
2 | //keybind | |
|
3 | $(document).on('keyup.removepic', function(e) { | |
|
4 | if(e.which === 27) { | |
|
5 | $('.img-full').remove(); | |
|
6 | } | |
|
7 | }); | |
|
8 | ||
|
9 | $('.image').children('a').each(function() { | |
|
10 | $(this).on('click', function() { | |
|
11 | var el = $(this); | |
|
12 | var thumb_id = 'full'+el.parent().parent().attr('id');//костыли | |
|
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 | ||
|
21 | //new image size | |
|
22 | if (img_w > win_w) { | |
|
23 | img_h = img_h * (win_w/img_w); | |
|
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 | ||
|
33 | $(img_pv) | |
|
34 | .addClass('img-full') | |
|
35 | .attr('id', thumb_id) | |
|
36 | .attr('src', $(el).attr('href')) | |
|
37 | .appendTo($(el)) | |
|
38 | .css({ | |
|
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 | } | |
|
68 | else { | |
|
69 | $('#'+thumb_id).remove(); | |
|
70 | } | |
|
71 | ||
|
72 | //prevent default | |
|
73 | return false; | |
|
74 | }); | |
|
75 | }); | |
|
76 | } No newline at end of file |
@@ -0,0 +1,117 b'' | |||
|
1 | /*! Copyright (c) 2013 Brandon Aaron (http://brandonaaron.net) | |
|
2 | * Licensed under the MIT License (LICENSE.txt). | |
|
3 | * | |
|
4 | * Thanks to: http://adomas.org/javascript-mouse-wheel/ for some pointers. | |
|
5 | * Thanks to: Mathias Bank(http://www.mathias-bank.de) for a scope bug fix. | |
|
6 | * Thanks to: Seamus Leahy for adding deltaX and deltaY | |
|
7 | * | |
|
8 | * Version: 3.1.3 | |
|
9 | * | |
|
10 | * Requires: 1.2.2+ | |
|
11 | */ | |
|
12 | ||
|
13 | (function (factory) { | |
|
14 | if ( typeof define === 'function' && define.amd ) { | |
|
15 | // AMD. Register as an anonymous module. | |
|
16 | define(['jquery'], factory); | |
|
17 | } else if (typeof exports === 'object') { | |
|
18 | // Node/CommonJS style for Browserify | |
|
19 | module.exports = factory; | |
|
20 | } else { | |
|
21 | // Browser globals | |
|
22 | factory(jQuery); | |
|
23 | } | |
|
24 | }(function ($) { | |
|
25 | ||
|
26 | var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll']; | |
|
27 | var toBind = 'onwheel' in document || document.documentMode >= 9 ? ['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll']; | |
|
28 | var lowestDelta, lowestDeltaXY; | |
|
29 | ||
|
30 | if ( $.event.fixHooks ) { | |
|
31 | for ( var i = toFix.length; i; ) { | |
|
32 | $.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks; | |
|
33 | } | |
|
34 | } | |
|
35 | ||
|
36 | $.event.special.mousewheel = { | |
|
37 | setup: function() { | |
|
38 | if ( this.addEventListener ) { | |
|
39 | for ( var i = toBind.length; i; ) { | |
|
40 | this.addEventListener( toBind[--i], handler, false ); | |
|
41 | } | |
|
42 | } else { | |
|
43 | this.onmousewheel = handler; | |
|
44 | } | |
|
45 | }, | |
|
46 | ||
|
47 | teardown: function() { | |
|
48 | if ( this.removeEventListener ) { | |
|
49 | for ( var i = toBind.length; i; ) { | |
|
50 | this.removeEventListener( toBind[--i], handler, false ); | |
|
51 | } | |
|
52 | } else { | |
|
53 | this.onmousewheel = null; | |
|
54 | } | |
|
55 | } | |
|
56 | }; | |
|
57 | ||
|
58 | $.fn.extend({ | |
|
59 | mousewheel: function(fn) { | |
|
60 | return fn ? this.bind("mousewheel", fn) : this.trigger("mousewheel"); | |
|
61 | }, | |
|
62 | ||
|
63 | unmousewheel: function(fn) { | |
|
64 | return this.unbind("mousewheel", fn); | |
|
65 | } | |
|
66 | }); | |
|
67 | ||
|
68 | ||
|
69 | function handler(event) { | |
|
70 | var orgEvent = event || window.event, | |
|
71 | args = [].slice.call(arguments, 1), | |
|
72 | delta = 0, | |
|
73 | deltaX = 0, | |
|
74 | deltaY = 0, | |
|
75 | absDelta = 0, | |
|
76 | absDeltaXY = 0, | |
|
77 | fn; | |
|
78 | event = $.event.fix(orgEvent); | |
|
79 | event.type = "mousewheel"; | |
|
80 | ||
|
81 | // Old school scrollwheel delta | |
|
82 | if ( orgEvent.wheelDelta ) { delta = orgEvent.wheelDelta; } | |
|
83 | if ( orgEvent.detail ) { delta = orgEvent.detail * -1; } | |
|
84 | ||
|
85 | // New school wheel delta (wheel event) | |
|
86 | if ( orgEvent.deltaY ) { | |
|
87 | deltaY = orgEvent.deltaY * -1; | |
|
88 | delta = deltaY; | |
|
89 | } | |
|
90 | if ( orgEvent.deltaX ) { | |
|
91 | deltaX = orgEvent.deltaX; | |
|
92 | delta = deltaX * -1; | |
|
93 | } | |
|
94 | ||
|
95 | // Webkit | |
|
96 | if ( orgEvent.wheelDeltaY !== undefined ) { deltaY = orgEvent.wheelDeltaY; } | |
|
97 | if ( orgEvent.wheelDeltaX !== undefined ) { deltaX = orgEvent.wheelDeltaX * -1; } | |
|
98 | ||
|
99 | // Look for lowest delta to normalize the delta values | |
|
100 | absDelta = Math.abs(delta); | |
|
101 | if ( !lowestDelta || absDelta < lowestDelta ) { lowestDelta = absDelta; } | |
|
102 | absDeltaXY = Math.max(Math.abs(deltaY), Math.abs(deltaX)); | |
|
103 | if ( !lowestDeltaXY || absDeltaXY < lowestDeltaXY ) { lowestDeltaXY = absDeltaXY; } | |
|
104 | ||
|
105 | // Get a whole value for the deltas | |
|
106 | fn = delta > 0 ? 'floor' : 'ceil'; | |
|
107 | delta = Math[fn](delta / lowestDelta); | |
|
108 | deltaX = Math[fn](deltaX / lowestDeltaXY); | |
|
109 | deltaY = Math[fn](deltaY / lowestDeltaXY); | |
|
110 | ||
|
111 | // Add event and delta to the front of the arguments | |
|
112 | args.unshift(event, delta, deltaX, deltaY); | |
|
113 | ||
|
114 | return ($.event.dispatch || $.event.handle).apply(this, args); | |
|
115 | } | |
|
116 | ||
|
117 | })); |
@@ -5,4 +5,12 b'' | |||
|
5 | 5 | .ui-dialog-content { |
|
6 | 6 | padding: 0; |
|
7 | 7 | min-height: 0; |
|
8 | } | |
|
9 | ||
|
10 | .img-full { | |
|
11 | position: fixed; | |
|
12 | z-index: 9999; | |
|
13 | background-color: #CCC; | |
|
14 | border: 1px solid #000; | |
|
15 | cursor: pointer; | |
|
8 | 16 | } No newline at end of file |
@@ -12,6 +12,7 b'' | |||
|
12 | 12 | closeEffect: 'none' |
|
13 | 13 | }); |
|
14 | 14 | |
|
15 | addImgPreview(); | |
|
15 | 16 | addRefLinkMap(); |
|
16 | 17 | addPopups(); |
|
17 | 18 | addMarkPanel(); |
@@ -23,6 +23,7 b'' | |||
|
23 | 23 | <body> |
|
24 | 24 | <script src="{{ STATIC_URL }}js/jquery-2.0.1.min.js"></script> |
|
25 | 25 | <script src="{{ STATIC_URL }}js/jquery-ui-1.10.3.custom.min.js"></script> |
|
26 | <script src="{{ STATIC_URL }}js/jquery.mousewheel.js"></script> | |
|
26 | 27 | <script src="{{ STATIC_URL }}js/jquery.fancybox.pack.js"></script> |
|
27 | 28 | <script src="{% url 'django.views.i18n.javascript_catalog' %}"></script> |
|
28 | 29 | <script src="{{ STATIC_URL }}js/refmaps.js"></script> |
General Comments 0
You need to be logged in to leave comments.
Login now