PageSourceSearch

https://ponferrada.org/javaScript/jquery.tipsy.js

js ponferrada.org collected 2026-09-24 20:03:22 UTC 4,805 bytes, 109 lines download raw bytes

1/*jquery tipsy con una modificacion par apoder añadir una clase especifica (se utiliza el pageflip), por defecto esta la que se utilizaba antes (tipsy)*/
2/*IMPORTANTE: EN LOS PROYECTOS DE BLOGS SOBREESCRIBIR EL FICHERO QUE HAYA CON ESTE*/
3/*ESTE FICHERO ES EL QUE TIENE QUE PREVALECER*/
4(function($) {
5    $.fn.tipsy = function(options) {
6
7        options = $.extend({}, $.fn.tipsy.defaults, options);
8        
9        return this.each(function() {
10            
11            var opts = $.fn.tipsy.elementOptions(this, options);
12
13			//necesario para el explorer, porque sino sale dos veces
14			if ($(this).attr('title') || typeof($(this).attr('original-title')) != 'string') {
15               $(this).attr('original-title', $(this).attr('title') || '').removeAttr('title');
16            }
17            
18            $(this).hover(function() {
19
20                $.data(this, 'cancel.tipsy', true);
21
22                var tip = $.data(this, 'active.tipsy');
23                if (!tip) {
24                    tip = $('<div class="'+opts.cssClass+'"><div class="tipsy-inner"/></div>');
25                    tip.css({position: 'absolute', zIndex: 310000});
26                    $.data(this, 'active.tipsy', tip);
27                }
28
29                if ($(this).attr('title') || typeof($(this).attr('original-title')) != 'string') {
30                    $(this).attr('original-title', $(this).attr('title') || '').removeAttr('title');
31                }
32
33                var title;
34                if (typeof opts.title == 'string') {
35                    title = $(this).attr(opts.title == 'title' ? 'original-title' : opts.title);
36                } else if (typeof opts.title == 'function') {
37                    title = opts.title.call(this);
38                }
39
40                tip.find('.tipsy-inner')[opts.html ? 'html' : 'text'](title || opts.fallback);
41
42                var pos = $.extend({}, $(this).offset(), {width: this.offsetWidth, height: this.offsetHeight});
43                tip.get(0).className = opts.cssClass; // reset classname in case of dynamic gravity
44                tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body);
45                var actualWidth = tip[0].offsetWidth, actualHeight = tip[0].offsetHeight;
46                var gravity = (typeof opts.gravity == 'function') ? opts.gravity.call(this) : opts.gravity;
47
48                switch (gravity.charAt(0)) {
49                    case 'n':
50                        tip.css({top: pos.top + pos.height, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-north');
51                        break;
52                    case 's':
53                        tip.css({top: pos.top - actualHeight, left: pos.left + pos.width / 2 - actualWidth / 2}).addClass('tipsy-south');
54                        break;
55                    case 'e':
56                        tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth}).addClass('tipsy-east');
57                        break;
58                    case 'w':
59                        tip.css({top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width}).addClass('tipsy-west');
60                        break;
61                }
62
63                if (opts.fade) {
64                    tip.css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: 0.8}, 200);
65                } else {
66                    tip.css({visibility: 'visible'});
67                }
68
69            }, function() {
70                $.data(this, 'cancel.tipsy', false);
71                var self = this;
72                setTimeout(function() {
73                    if ($.data(this, 'cancel.tipsy')) return;
74                    var tip = $.data(self, 'active.tipsy');
75                    if (tip) tip.remove();
76                }, 100);
77
78            });
79            
80        });
81        
82    };
83    
84    // Overwrite this method to provide options on a per-element basis.
85    // For example, you could store the gravity in a 'tipsy-gravity' attribute:
86    // return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' });
87    // (remember - do not modify 'options' in place!)
88    $.fn.tipsy.elementOptions = function(ele, options) {
89        return $.metadata ? $.extend({}, options, $(ele).metadata()) : options;
90    };
91    
92    $.fn.tipsy.defaults = {
93        fade: false,
94        fallback: '',
95        gravity: 'n',
96        html: false,
97        title: 'title',
98        cssClass: 'tipsy'
99    };
100    
101    $.fn.tipsy.autoNS = function() {
102        return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n';
103    };
104    
105    $.fn.tipsy.autoWE = function() {
106        return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w';
107    };
108    
109})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.