Changeset 242 in t29-www for shared


Ignore:
Timestamp:
Jun 5, 2011, 10:45:52 PM (13 years ago)
Author:
sven
Message:
  • img_license-Tag-System ausgebaut
  • lightbox/fancybox-System mit img_license verheiratet: In der Fancybox wird jetzt immer ein License-Tag angezeigt (beim Bild-Hovern), ausser im aufrufenden Link steht class="no-copyright".
File:
1 edited

Legend:

Unmodified
Added
Removed
  • shared/js/tools.js

    r235 r242  
    5252 * 2010 Sven Koeppel
    5353 **/
    54 t29.img_license_settings = {
     54t29.img_license = {}; // img license namespace
     55t29.img_license.settings = {
    5556        // enable or disable system (e.g. used as API in Translation subsystem)
    5657        enabled : true,
     
    7172// configuration end
    7273
    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.
     79t29.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};
     94t29.img_license.hover_out = function(){
     95        t29.img_license.tag.hide();
     96        t29.img_license.img = null;
     97};
     98t29.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();
     107t29.img_license.apply = function($elem) {
     108        $elem.hover(t29.img_license.hover_in, t29.img_license.hover_out);
     109};
     110
     111t29.img_license.onload = function() {
    74112        $("body").append('<div id="img-license-tag"><p>'+
    75113                // 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) );
    100122};
    101123
     
    160182                $("<style type='text/css'/>").html('@import url("/shared/js/fancybox/jquery.fancybox-1.3.4.css")').appendTo("head");
    161183                $.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                        });
    163201                });
    164202        } // if lightbox elements
     
    263301$(t29.hostinfo);
    264302$(t29.window_size);
    265 $(t29.img_license);
     303$(t29.img_license.onload);
    266304$(t29.heading_links);
    267305$(t29.tr.preloader.onload);
Note: See TracChangeset for help on using the changeset viewer.
© 2008 - 2013 technikum29 • Sven Köppel • Some rights reserved
Powered by Trac
Expect where otherwise noted, content on this site is licensed under a Creative Commons 3.0 License