|
1 | 1 | $(document).ready(function() { |
2 | 2 |
|
3 | | - // modify thumbnail links in wiki content -> add filename from ./img/@alt to url to support fancybox preview |
4 | | - $("div.wiki a.thumbnail").attr('href', function(i, v){ |
5 | | - return v.replace(/\/attachments\/(\d+)/g,'/attachments/download/$1') + '/' + $(this).children('img').attr('alt').replace(/(.*\.(png|jp(e)?g|gif))(\s\(.*\))?/g,'$1'); |
6 | | - }); |
| 3 | + // modify thumbnail links in wiki content -> add filename from ./img/@alt to url to support fancybox preview |
| 4 | + $("div.wiki a.thumbnail").attr('href', function(i, v){ |
| 5 | + return v.replace(/\/attachments\/(\d+)/g,'/attachments/download/$1') + '/' + $(this).children('img').attr('alt').replace(/(.*\.(png|jpe?g|gif))(\s\(.*\))?/gi,'$1'); |
| 6 | + }); |
7 | 7 |
|
8 | | - // modify thumbnails and magnifier links in journal details -> add filename to url to support fancybox preview |
9 | | - $("div.journal div.thumbnails a, div.journal ul.details li a.icon-magnifier").attr('href', function(i, v){ |
| 8 | + // modify thumbnails and magnifier links in journal details -> add filename to url to support fancybox preview |
| 9 | + $("div.journal div.thumbnails a, div.journal ul.details li a:not([title])").attr('href', function(i, v){ |
| 10 | + if($(this).attr('href').match(/(png|jp?eg|gif|pdf)$/i)) { |
10 | 11 | return v.replace(/\/attachments\/(\d+)/g,'/attachments/download/$1'); |
11 | | - }); |
| 12 | + } else { |
| 13 | + return v; |
| 14 | + } |
| 15 | + }); |
12 | 16 |
|
13 | | - // add rel attribute to detail links of the same journal entry |
14 | | - $("div.journal ul.details li a.icon-magnifier").attr('rel', function(i, v){ |
15 | | - return 'image-details-' + $(this).closest('div.journal').attr('id'); |
16 | | - }); |
| 17 | + // add a magnifier icon before download icon for images and pdf |
| 18 | + $("div.journal ul.details li a.icon-download").each(function(i, obj) { |
| 19 | + if($(this).attr('href').match(/\.(png|jp?eg|gif|pdf)$/i)) { |
| 20 | + var icon = $(this).clone().attr('class', function(i, v){ |
| 21 | + return v.replace(/-download/g,'-magnifier'); |
| 22 | + }); |
| 23 | + icon.insertBefore($(this)); |
| 24 | + } |
| 25 | + }); |
17 | 26 |
|
18 | | - // add rel attribute to thumbnails of the same journal entry |
19 | | - $("div.journal div.thumbnails a").attr('rel', function(i, v){ |
20 | | - return 'thumbnails-' + $(this).closest('div.journal').attr('id'); |
21 | | - }); |
| 27 | + // add rel attribute to thumbnails of the same journal entry |
| 28 | + $("div.journal div.thumbnails a").attr('rel', function(i, v){ |
| 29 | + return 'thumbnails-' + $(this).closest('div.journal').attr('id'); |
| 30 | + }); |
22 | 31 |
|
23 | | - $("div.attachments a.lightbox," + |
24 | | - "div.attachments a.lightbox_preview," + |
25 | | - "div.journal ul.details a[href$='.png']," + |
26 | | - "div.journal ul.details a[href$='.PNG']," + |
27 | | - "div.journal ul.details a[href$='.jpg']," + |
28 | | - "div.journal ul.details a[href$='.JPG']," + |
29 | | - "div.journal ul.details a[href$='.jpeg']," + |
30 | | - "div.journal ul.details a[href$='.JPEG']," + |
31 | | - "div.journal ul.details a[href$='.gif']," + |
32 | | - "div.journal ul.details a[href$='.GIF']," + |
33 | | - "div.journal div.thumbnails a," + |
34 | | - "div.wiki a.thumbnail," + |
35 | | - "div.attachments a.swf," + |
36 | | - ".avatar a").fancybox({ |
37 | | - prevEffect : 'none', |
38 | | - nextEffect : 'none', |
39 | | - openSpeed : 300, |
40 | | - closeSpeed : 150 |
41 | | - }); |
| 32 | + $("div.attachments a.lightbox," + |
| 33 | + "div.attachments a.lightbox_preview," + |
| 34 | + "div.journal ul.details a[href$='.png']:not(.icon-download)," + |
| 35 | + "div.journal ul.details a[href$='.PNG']:not(.icon-download)," + |
| 36 | + "div.journal ul.details a[href$='.jpg']:not(.icon-download)," + |
| 37 | + "div.journal ul.details a[href$='.JPG']:not(.icon-download)," + |
| 38 | + "div.journal ul.details a[href$='.jpeg']:not(.icon-download)," + |
| 39 | + "div.journal ul.details a[href$='.JPEG']:not(.icon-download)," + |
| 40 | + "div.journal ul.details a[href$='.gif']:not(.icon-download)," + |
| 41 | + "div.journal ul.details a[href$='.GIF']:not(.icon-download)," + |
| 42 | + "div.journal div.thumbnails a," + |
| 43 | + "div.wiki a.thumbnail," + |
| 44 | + "div.attachments a.swf," + |
| 45 | + ".avatar a").fancybox({ |
| 46 | + prevEffect : 'none', |
| 47 | + nextEffect : 'none', |
| 48 | + openSpeed : 300, |
| 49 | + closeSpeed : 150 |
| 50 | + }); |
42 | 51 |
|
43 | | - $("div.attachments a.pdf," + |
44 | | - "div.journal ul.details a[href$='.pdf']," + |
45 | | - "div.journal ul.details a[href$='.PDF']," + |
46 | | - "div.journal div.thumbnails a[href$='.pdf']," + |
47 | | - "div.journal div.thumbnails a[href$='.PDF']").fancybox({ |
| 52 | + $("div.attachments a.pdf," + |
| 53 | + "div.journal ul.details a[href$='.pdf']:not(.icon-download)," + |
| 54 | + "div.journal ul.details a[href$='.PDF']:not(.icon-download)," + |
| 55 | + "div.journal div.thumbnails a[href$='.pdf']," + |
| 56 | + "div.journal div.thumbnails a[href$='.PDF']").fancybox({ |
48 | 57 | type : 'iframe', |
49 | | - prevEffect : 'none', |
50 | | - nextEffect : 'none', |
51 | | - openSpeed : 300, |
52 | | - closeSpeed : 150, |
53 | | - width : '90%', |
54 | | - height : '90%', |
55 | | - autoSize : true, |
56 | | - iframe : { |
57 | | - preload: false |
58 | | - } |
59 | | - }); |
| 58 | + prevEffect : 'none', |
| 59 | + nextEffect : 'none', |
| 60 | + openSpeed : 300, |
| 61 | + closeSpeed : 150, |
| 62 | + width : '90%', |
| 63 | + height : '90%', |
| 64 | + autoSize : true, |
| 65 | + iframe : { |
| 66 | + preload: false |
| 67 | + } |
| 68 | + }); |
60 | 69 | }); |
0 commit comments