1 | /** |
---|
2 | * technikum29.de | javascript: Unobstructive copyright information |
---|
3 | * |
---|
4 | * Since there are so many people copying pictures from the website without |
---|
5 | * even knowing ot the copyright statements on the imprint, we tested some |
---|
6 | * jQuery-powered ways to inform them in an "unobstructive" way: |
---|
7 | * |
---|
8 | * - hovering a picture replaces it with the "hotlinking picture" |
---|
9 | * (see http://dev.technikum29.de/src/hotlinking), that is, an embedded |
---|
10 | * watermark / copyright tag |
---|
11 | * - hovering some more time over the picture yields a small informative |
---|
12 | * box (containing the alt-label of the picture) that informs about the |
---|
13 | * copyright message |
---|
14 | * |
---|
15 | * See Revision 169 for these features. They have been completely developed, |
---|
16 | * but removed again for a much smaller and lighter solution (just some black |
---|
17 | * box at the bottom corner of the picture). |
---|
18 | * |
---|
19 | * 2010 Sven Koeppel |
---|
20 | **/ |
---|
21 | |
---|
22 | if(!t29) window.t29 = {}; // the t29 namespace |
---|
23 | |
---|
24 | t29.img_license = {}; // img license namespace |
---|
25 | t29.img_license.settings = { |
---|
26 | // enable or disable system (e.g. used as API in Translation subsystem) |
---|
27 | enabled : true, |
---|
28 | |
---|
29 | // content for the license tags (depending on language) |
---|
30 | text : "placeholder", |
---|
31 | |
---|
32 | // min size of pictures to display the license tag |
---|
33 | treshold_size : [255,100], // [w,h] |
---|
34 | |
---|
35 | // selector to exclude images from being license tagged |
---|
36 | exclude : "img.no-copyright, .no-copyright img, .start img, .impressum img" |
---|
37 | }; |
---|
38 | |
---|
39 | // configuration end |
---|
40 | |
---|
41 | // helper elements in t29.img_license namespace: |
---|
42 | // * hover_in, hover_out: functions called by apply() |
---|
43 | // * img: The current image element where the license tag is shown |
---|
44 | // * tag: The jquery element of the image license tag |
---|
45 | // * tag_top: helper function for css top setting for tag. |
---|
46 | t29.img_license.hover_in = function(){ |
---|
47 | if(!t29.img_license.settings.enabled |
---|
48 | || this.width < t29.img_license.settings.treshold_size[0] |
---|
49 | || this.height < t29.img_license.settings.treshold_size[1]) |
---|
50 | return; |
---|
51 | t29.img_license.img = $(this); |
---|
52 | t29.img_license.tag.css({ |
---|
53 | left: $(this).offset().left, |
---|
54 | // top: tag_top(); |
---|
55 | width: $(this).width(), |
---|
56 | display: "block" |
---|
57 | }); |
---|
58 | t29.img_license.tag_top(); |
---|
59 | t29.img_license.tag.css("margin-top", -t29.img_license.tag.height()); // erst in zweitem schritt |
---|
60 | }; |
---|
61 | t29.img_license.hover_out = function(){ |
---|
62 | t29.img_license.tag.hide(); |
---|
63 | t29.img_license.img = null; |
---|
64 | }; |
---|
65 | t29.img_license.tag_top = function() { |
---|
66 | if(t29.img_license.img) |
---|
67 | t29.img_license.tag.css("top", Math.min( |
---|
68 | t29.img_license.img.offset().top + t29.img_license.img.height(), |
---|
69 | $(window).scrollTop()+$(window).height())); |
---|
70 | }; |
---|
71 | |
---|
72 | // use this function from outer, see onload for help. |
---|
73 | // improvement possibility: converse to $.fn so can call $("img#my").img_license(); |
---|
74 | t29.img_license.apply = function($elem) { |
---|
75 | $elem.hover(t29.img_license.hover_in, t29.img_license.hover_out); |
---|
76 | }; |
---|
77 | |
---|
78 | t29.img_license.onload = function() { |
---|
79 | $("body").append('<div id="img-license-tag"><p>'+t29._('js-img-license')+'</p></div>'); |
---|
80 | t29.img_license.tag = $("#img-license-tag"); |
---|
81 | |
---|
82 | $(window).scroll(t29.img_license.tag_top); |
---|
83 | t29.img_license.tag.hover(function(){ $(this).show(); }, function(){ $(this).hide(); }); |
---|
84 | |
---|
85 | // enable on all images |
---|
86 | t29.img_license.apply( $("img").not(t29.img_license.settings.exclude) ); |
---|
87 | }; |
---|
88 | |
---|
89 | $(t29.img_license.onload); |
---|