PageSourceSearch

https://tickets.chambermusicsociety.org/bundles/madeblocksoffice/js/tipsy/jquery.tipsy.js

js chambermusicsociety.org collected 2026-10-01 10:38:10 UTC 11,760 bytes, 254 lines download raw bytes

1/*!
2 * jQuery.tipsy
3 * Copyright (c) 2014 CreativeDream
4 * Website: http://creativedream.net/plugins/
5 * Version: 1.0 (18-11-2014)
6 * Requires: jQuery v1.7.1 or later
7 */
8(function(e) {
9    e.fn.tipsy = function(t){
10        if(typeof(t) == "string" && ["show","hide"].indexOf(t)>-1){
11            switch(t){
12                case "show":
13                    $(this).trigger('tipsy.show');
14                break;
15                case "hide":
16                    $(this).trigger('tipsy.hide');
17                break;
18            }
19            return this;
20        }
21        var n = e.extend({
22            arrowWidth: 10,
23            attr: 'data-tipsy',
24            cls: null,
25            duration: 150,
26            offset: 7,
27            position: 'top-center',
28            trigger: 'hover',
29            onShow: null,
30            onHide: null
31        }, t);
32        return this.each(function(t, r) {
33            var s = e(r),
34                b = '.tipsy',
35                o = e('<div class="tipsy"></div>'),
36                p = ["top-left","top-center","top-right","bottom-left","bottom-center","bottom-right","left","right"],
37                f = {
38                    init: function(){
39                        var d = {};
40                        switch(n.trigger){
41                            case 'hover':
42                                d = {
43                                    mouseenter: f._show,
44                                    mouseleave: f._hide
45                                }
46                            break;
47                            case 'focus':
48                                d = {
49                                    focus: f._show,
50                                    blur: f._hide
51                                }
52                            break;
53                            case 'click':
54                                d = {
55                                    click: function(e){
56                                        if(!f._clSe){
57                                            f._clSe = true;
58                                            f._show(e);
59                                        }else{
60                                            f._clSe = false;
61                                            f._hide(e);
62                                        }
63                                    },
64                                }
65                            break;
66                            case 'manual':
67                                f._unbindOptions();
68                                d = {
69                                    "tipsy.show": function(e){
70                                        f._clSe = true;
71                                        f._show(e);
72                                    },
73                                    "tipsy.hide": function(e){
74                                        f._clSe = false;
75                                        f._hide(e);
76                                    }
77                                }
78                            break;
79                        }
80                        s.on(d);
81                        o.hide();
82                    },
83                    _show: function(e){
84                        $(b).remove();
85                        f._clear();
86                        if(f.hasAttr(n.attr+'-disabled')){return false}
87                        f._createBox();
88                        if(n.trigger!='manual'){f._bindOptions()}
89                    },
90                    _hide: function(e){
91                        f._fixTitle(true);
92                        o.stop(true,true).fadeOut(n.duration, function(){
93                            n.onHide != null && typeof n.onHide == "function" ? n.onHide(o, s) : null
94                            f._clear();
95                            $(this).remove();
96                        })
97                    },
98                    _showIn: function(){
99                        o.stop(true,true).fadeIn(n.duration, function(){
100                            n.onShow != null && typeof n.onShow == "function" ? n.onShow(o, s) : null
101                        })
102                    },
103                    _bindOptions: function(){
104                        e(window).bind("contextmenu", function() {
105                            f._hide()
106                        }).bind("blur",function() {
107                            f._hide()
108                        }).bind("resize", function() {
109                            f._hide()
110                        }).bind("scroll", function() {
111                            f._hide()
112                        })
113                    },
114                    _unbindOptions: function(){
115                        e(window).unbind("contextmenu", function() {
116                            f._hide()
117                        }).unbind("blur", function() {
118                            f._hide()
119                        }).unbind("resize", function() {
120                            f._hide()
121                        }).unbind("scroll", function() {
122                            f._hide()
123                        })
124                    },
125                    _clear: function(){
126                        o.attr("class","tipsy").empty();
127                        f._lsWpI = [];
128                        f._lsWtI = [];
129                    },
130                    hasAttr: function(e){
131                        e=s.attr(e);return typeof e!==typeof undefined&&e!==false
132                    },
133                    _fixTitle: function(a){
134                        if(a){
135                            if (f.hasAttr('data-title') && !f.hasAttr('title') && f._lsWtI[0] == true) {
136                                s.attr('title', f._lsWtI[1] || '').removeAttr('data-title');
137                            }
138                        }else{
139                            if (f.hasAttr('title') || !f.hasAttr('data-title')) {
140                                f._lsWtI = [true, s.attr('title')]
141                                s.attr('data-title', s.attr('title') || '').removeAttr('title');
142                            }
143                        }
144                    },
145                    _getTitle: function(){
146                        f._fixTitle();
147                        var title = s.attr('data-title');
148                        title = '' + title;
149
150                        return title;
151                    },
152                    _position: function(a){
153                        var css = {top: 0, left: 0},
154                            position = (a ? a : (f.hasAttr(n.attr+'-position') ? s.attr(n.attr+'-position') : n.position)),
155                            arrow = position.split('-'),
156                            offset = (f.hasAttr(n.attr+'-offset') ? s.attr(n.attr+'-offset') : n.offset),
157                            style = {
158                                offsetTop:  s.offset().top,
159                                offsetLeft: s.offset().left,
160                                width: s.outerWidth(),
161                                height: s.outerHeight()
162                            },
163                            tStyle = {
164                                width: o.outerWidth(),
165                                height: o.outerHeight()
166                            },
167                            wStyle = {
168                                width: $(window).outerWidth(),
169                                height: $(window).outerHeight(),
170                                scrollTop: $(window).scrollTop(),
171                                scrollLeft: $(window).scrollLeft(),
172                            };
173
174                        if($.inArray(position, p)==-1 || $.inArray(position, f._lsWpI)!==-1){ f._hide(); return css }else{ f._lsWpI.push(position) }
175
176                        switch(arrow[0]){
177                            case 'bottom':
178                                css.top = style.offsetTop + style.height + offset;
179                                if(css.top >= wStyle.height + wStyle.scrollTop){
180                                    return f._position('top' + '-' + arrow[1])
181                                }
182                                o.addClass('arrow-top');
183                            break;
184                            case 'top':
185                                css.top = style.offsetTop - tStyle.height - offset;
186                                if(css.top - wStyle.scrollTop <= 0){
187                                    return f._position('bottom' + '-' + arrow[1])
188                                }
189                                o.addClass('arrow-bottom');
190                            break;
191                            case 'left':
192                                css.top = style.offsetTop + style.height / 2 - tStyle.height / 2;
193                                css.left =  style.offsetLeft - tStyle.width - offset;
194                                if(css.left <= 0){
195                                    return f._position('right')
196                                }
197                                o.addClass('arrow-side-right');
198                                return css;
199                            break;
200                            case 'right':
201                                css.top = style.offsetTop + style.height / 2 - tStyle.height / 2;
202                                css.left =  style.offsetLeft + style.width + offset;
203                                if(css.left + tStyle.width > wStyle.width){
204                                    return f._position('left')
205                                }
206                                o.addClass('arrow-side-left');
207                                return css;
208                            break;
209                        }
210                        switch(arrow[1]){
211                            case 'left':
212                                css.left = style.offsetLeft + style.width / 2 - tStyle.width + n.arrowWidth;
213                                if(css.left <= 0){
214                                    return f._position(arrow[0] + '-' + 'right')
215                                }
216                                o.addClass('arrow-right');
217                            break;
218                            case 'center':
219                                css.left = style.offsetLeft + style.width / 2 - tStyle.width / 2;
220                                if(css.left + tStyle.width > wStyle.width){
221                                    return f._position(arrow[0] + '-' + 'left')
222                                }
223                                if(css.left <= 0){
224                                    return f._position(arrow[0] + '-' + 'right')
225                                }
226                                o.addClass('arrow-center');
227                            break;
228                            case 'right':
229                                css.left = style.offsetLeft + style.width / 2 - n.arrowWidth;
230                                if(css.left + tStyle.width > wStyle.width){
231                                    return f._position(arrow[0] + '-' + 'left')
232                                }
233                                o.addClass('arrow-left');
234                            break;
235                        }
236
237                        return css;
238                    },
239                    _createBox: function(){
240                        o.html(f._getTitle()).appendTo('body');
241                        if((n.cls!=null && typeof(n.cls)=="string") || f.hasAttr(n.attr+'-cls')){
242                            o.addClass((f.hasAttr(n.attr+'-cls') ? s.attr(n.attr+'-cls') : n.cls));
243                        }
244                        o.css(f._position());
245                        f._showIn();
246                    },
247                    _lsWtI: [],
248                    _lsWpI: []
249                }
250            f.init();
251            return this;
252        });
253    }
254})(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.