##// END OF EJS Templates
Add image preview
rt@lightning -
r238:16e354f9 default
parent child Browse files
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 }));
@@ -1,8 +1,16 b''
1 .ui-button {
1 .ui-button {
2 display: none;
2 display: none;
3 }
3 }
4
4
5 .ui-dialog-content {
5 .ui-dialog-content {
6 padding: 0;
6 padding: 0;
7 min-height: 0;
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 } No newline at end of file
16 }
@@ -1,18 +1,19 b''
1 $( document ).ready(function() {
1 $( document ).ready(function() {
2 $("a[href='#top']").click(function() {
2 $("a[href='#top']").click(function() {
3 $("html, body").animate({ scrollTop: 0 }, "slow");
3 $("html, body").animate({ scrollTop: 0 }, "slow");
4 return false;
4 return false;
5 });
5 });
6
6
7 $(".fancy").fancybox({
7 $(".fancy").fancybox({
8 closeBtn: false,
8 closeBtn: false,
9 closeClick: true,
9 closeClick: true,
10 padding: 0,
10 padding: 0,
11 openEffect: 'none',
11 openEffect: 'none',
12 closeEffect: 'none'
12 closeEffect: 'none'
13 });
13 });
14
14
15 addImgPreview();
15 addRefLinkMap();
16 addRefLinkMap();
16 addPopups();
17 addPopups();
17 addMarkPanel();
18 addMarkPanel();
18 });
19 });
@@ -1,57 +1,58 b''
1 {% load staticfiles %}
1 {% load staticfiles %}
2 {% load i18n %}
2 {% load i18n %}
3
3
4 <!DOCTYPE html>
4 <!DOCTYPE html>
5 <html>
5 <html>
6 <head>
6 <head>
7 <link rel="stylesheet" type="text/css"
7 <link rel="stylesheet" type="text/css"
8 href="{{ STATIC_URL }}css/jquery.fancybox.css" media="all"/>
8 href="{{ STATIC_URL }}css/jquery.fancybox.css" media="all"/>
9 <link rel="stylesheet" type="text/css"
9 <link rel="stylesheet" type="text/css"
10 href="{{ STATIC_URL }}css/base.css" media="all"/>
10 href="{{ STATIC_URL }}css/base.css" media="all"/>
11 <link rel="stylesheet" type="text/css"
11 <link rel="stylesheet" type="text/css"
12 href="{{ STATIC_URL }}css/{{ theme }}/base_page.css?5" media="all"/>
12 href="{{ STATIC_URL }}css/{{ theme }}/base_page.css?5" media="all"/>
13 <link rel="alternate" type="application/rss+xml" href="rss/" title="
13 <link rel="alternate" type="application/rss+xml" href="rss/" title="
14 {% trans 'Feed' %}"/>
14 {% trans 'Feed' %}"/>
15
15
16 <link rel="icon" type="image/png"
16 <link rel="icon" type="image/png"
17 href="{{ STATIC_URL }}favicon.png">
17 href="{{ STATIC_URL }}favicon.png">
18
18
19 <meta name="viewport" content="width=device-width, initial-scale=1"/>
19 <meta name="viewport" content="width=device-width, initial-scale=1"/>
20 <meta charset="utf-8"/>
20 <meta charset="utf-8"/>
21 {% block head %}{% endblock %}
21 {% block head %}{% endblock %}
22 </head>
22 </head>
23 <body>
23 <body>
24 <script src="{{ STATIC_URL }}js/jquery-2.0.1.min.js"></script>
24 <script src="{{ STATIC_URL }}js/jquery-2.0.1.min.js"></script>
25 <script src="{{ STATIC_URL }}js/jquery-ui-1.10.3.custom.min.js"></script>
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 <script src="{{ STATIC_URL }}js/jquery.fancybox.pack.js"></script>
27 <script src="{{ STATIC_URL }}js/jquery.fancybox.pack.js"></script>
27 <script src="{% url 'django.views.i18n.javascript_catalog' %}"></script>
28 <script src="{% url 'django.views.i18n.javascript_catalog' %}"></script>
28 <script src="{{ STATIC_URL }}js/refmaps.js"></script>
29 <script src="{{ STATIC_URL }}js/refmaps.js"></script>
29 <script src="{{ STATIC_URL }}js/panel.js"></script>
30 <script src="{{ STATIC_URL }}js/panel.js"></script>
30 <script src="{{ STATIC_URL }}js/popup.js"></script>
31 <script src="{{ STATIC_URL }}js/popup.js"></script>
31 <script src="{{ STATIC_URL }}js/main.js"></script>
32 <script src="{{ STATIC_URL }}js/main.js"></script>
32
33
33 <div class="navigation_panel">
34 <div class="navigation_panel">
34 <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a>
35 <a class="link" href="{% url 'index' %}">{% trans "All threads" %}</a>
35 {% for tag in tags %}
36 {% for tag in tags %}
36 <a class="tag" href="{% url 'tag' tag_name=tag.name %}"
37 <a class="tag" href="{% url 'tag' tag_name=tag.name %}"
37 >{{ tag.name }}</a>
38 >{{ tag.name }}</a>
38 {% endfor %}
39 {% endfor %}
39 <a class="tag" href="{% url 'tags' %}" title="{% trans 'Tag management' %}"
40 <a class="tag" href="{% url 'tags' %}" title="{% trans 'Tag management' %}"
40 >[...]</a>
41 >[...]</a>
41 <a class="link" href="{% url 'settings' %}">{% trans 'Settings' %}</a>
42 <a class="link" href="{% url 'settings' %}">{% trans 'Settings' %}</a>
42 </div>
43 </div>
43
44
44 {% block content %}{% endblock %}
45 {% block content %}{% endblock %}
45
46
46 <div class="navigation_panel">
47 <div class="navigation_panel">
47 {% block metapanel %}{% endblock %}
48 {% block metapanel %}{% endblock %}
48 [<a href="{% url "login" %}">{% trans 'Login' %}</a>]
49 [<a href="{% url "login" %}">{% trans 'Login' %}</a>]
49 <a class="link" href="#top">{% trans 'Up' %}</a>
50 <a class="link" href="#top">{% trans 'Up' %}</a>
50 </div>
51 </div>
51
52
52 <div class="footer">
53 <div class="footer">
53 <!-- Put your banners here -->
54 <!-- Put your banners here -->
54 </div>
55 </div>
55
56
56 </body>
57 </body>
57 </html>
58 </html>
General Comments 0
You need to be logged in to leave comments. Login now