- Timestamp:
- Jun 5, 2011, 10:45:52 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
shared/js/tools.js
r235 r242 52 52 * 2010 Sven Koeppel 53 53 **/ 54 t29.img_license_settings = { 54 t29.img_license = {}; // img license namespace 55 t29.img_license.settings = { 55 56 // enable or disable system (e.g. used as API in Translation subsystem) 56 57 enabled : true, … … 71 72 // configuration end 72 73 73 t29.img_license = function() { 74 // helper elements in t29.img_license namespace: 75 // * hover_in, hover_out: functions called by apply() 76 // * img: The current image element where the license tag is shown 77 // * tag: The jquery element of the image license tag 78 // * tag_top: helper function for css top setting for tag. 79 t29.img_license.hover_in = function(){ 80 if(!t29.img_license.settings.enabled 81 || this.width < t29.img_license.settings.treshold_size[0] 82 || this.height < t29.img_license.settings.treshold_size[1]) 83 return; 84 t29.img_license.img = $(this); 85 t29.img_license.tag.css({ 86 left: $(this).offset().left, 87 // top: tag_top(); 88 width: $(this).width(), 89 display: "block" 90 }); 91 t29.img_license.tag_top(); 92 t29.img_license.tag.css("margin-top", -t29.img_license.tag.height()); // erst in zweitem schritt 93 }; 94 t29.img_license.hover_out = function(){ 95 t29.img_license.tag.hide(); 96 t29.img_license.img = null; 97 }; 98 t29.img_license.tag_top = function() { 99 if(t29.img_license.img) 100 t29.img_license.tag.css("top", Math.min( 101 t29.img_license.img.offset().top + t29.img_license.img.height(), 102 $(window).scrollTop()+$(window).height())); 103 }; 104 105 // use this function from outer, see onload for help. 106 // improvement possibility: converse to $.fn so can call $("img#my").img_license(); 107 t29.img_license.apply = function($elem) { 108 $elem.hover(t29.img_license.hover_in, t29.img_license.hover_out); 109 }; 110 111 t29.img_license.onload = function() { 74 112 $("body").append('<div id="img-license-tag"><p>'+ 75 113 // detect language by heading language (ripped from t29_gmaps...) 76 t29.img_license_settings.text[t29.language()]+'</p></div>'); 77 var tag = $("#img-license-tag"); 78 var tag_top = function() { if(t29.img_license_settings.img) 79 tag.css("top", Math.min( 80 t29.img_license_settings.img.offset().top + t29.img_license_settings.img.height(), 81 $(window).scrollTop()+$(window).height())); 82 }; 83 $("img").not(t29.img_license_settings.exclude).hover(function(){ 84 if(!t29.img_license_settings.enabled 85 || this.width < t29.img_license_settings.treshold_size[0] 86 || this.height < t29.img_license_settings.treshold_size[1]) 87 return; 88 t29.img_license_settings.img = $(this); 89 tag.css({ 90 left: $(this).offset().left, 91 // top: tag_top(); 92 width: $(this).width(), 93 display: "block" 94 }); 95 tag_top(); 96 tag.css("margin-top", -tag.height()); // erst in zweitem schritt 97 }, function(){ tag.hide(); t29.img_license_settings.img = null; }); 98 $(window).scroll(tag_top); 99 tag.hover(function(){ $(this).show(); }, function(){ $(this).hide(); }); 114 t29.img_license.settings.text[t29.language()]+'</p></div>'); 115 t29.img_license.tag = $("#img-license-tag"); 116 117 $(window).scroll(t29.img_license.tag_top); 118 t29.img_license.tag.hover(function(){ $(this).show(); }, function(){ $(this).hide(); }); 119 120 // enable on all images 121 t29.img_license.apply( $("img").not(t29.img_license.settings.exclude) ); 100 122 }; 101 123 … … 160 182 $("<style type='text/css'/>").html('@import url("/shared/js/fancybox/jquery.fancybox-1.3.4.css")').appendTo("head"); 161 183 $.getScript('/shared/js/fancybox/jquery.fancybox-1.3.4.pack.js', function(){ 162 elements.fancybox(); 184 elements.fancybox({ 185 onComplete: function() { 186 // etwas quick and dirty: 187 if(! this.orig.is(".no-copyright")) { 188 t29.img_license.apply( $("#fancybox-img") ); 189 // little hacky: 190 $("#img-license-tag").css("z-index", "10000"); // make sure much bigger than fancybox 191 // fire "hover in" because images are typically big 192 // and mouse cursor may not move on picture 193 t29.img_license.hover_in.call($("#fancybox-img")[0]); 194 } 195 }, 196 onClosed: function() { 197 // wieder de-applying 198 $("#fancybox-img").unbind('mouseenter mouseleave'); 199 } 200 }); 163 201 }); 164 202 } // if lightbox elements … … 263 301 $(t29.hostinfo); 264 302 $(t29.window_size); 265 $(t29.img_license );303 $(t29.img_license.onload); 266 304 $(t29.heading_links); 267 305 $(t29.tr.preloader.onload);
Note: See TracChangeset
for help on using the changeset viewer.