PageSourceSearch

https://www.taedp.org.tw/sites/all/modules/civicrm/packages/jquery/plugins/jquery.toolTip.js

js taedp.org.tw collected 2026-10-02 11:36:30 UTC 7,857 bytes, 200 lines download raw bytes

1 /*
2 * TipTip
3 * Copyright 2010 Drew Wilson
4 * www.drewwilson.com
5 * code.drewwilson.com/entry/tiptip-jquery-plugin
6 *
7 * Version 1.3   -   Updated: Mar. 23, 2010
8 *
9 * This Plug-In will create a custom tooltip to replace the default
10 * browser tooltip. It is extremely lightweight and very smart in
11 * that it detects the edges of the browser window and will make sure
12 * the tooltip stays within the current window size. As a result the
13 * tooltip will adjust itself to be displayed above, below, to the left 
14 * or to the right depending on what is necessary to stay within the
15 * browser window. It is completely customizable as well via CSS.
16 *
17 * This TipTip jQuery plug-in is dual licensed under the MIT and GPL licenses:
18 *   http://www.opensource.org/licenses/mit-license.php
19 *   http://www.gnu.org/licenses/gpl.html
20 */
21
22;(function($){
23  $.fn.toolTip = function(options) {
24    var defaults = { 
25      activation: "hover",
26      keepAlive: false,
27      maxWidth: "500px",
28      edgeOffset: 3,
29      defaultPosition: "bottom",
30      delay: 400,
31      fadeIn: 200,
32      fadeOut: 200,
33      attribute: "title",
34      skipVerticalComparison: false,
35      content: false, // HTML or String to fill TipTIp with
36        enter: function(){},
37        exit: function(){}
38      };
39    var opts = $.extend(defaults, options);
40    
41    // Setup tip tip elements and render them to the DOM
42    if($("#tiptip_holder").length <= 0){
43      var tiptip_holder = $('<div id="tiptip_holder" style="max-width:'+ opts.maxWidth +';"></div>');
44      var tiptip_content = $('<div id="tiptip_content"></div>');
45      var tiptip_arrow = $('<div id="tiptip_arrow"></div>');
46      $("body").append(tiptip_holder.html(tiptip_content).prepend(tiptip_arrow.html('<div id="tiptip_arrow_inner"></div>')));
47    } else {
48      var tiptip_holder = $("#tiptip_holder");
49      var tiptip_content = $("#tiptip_content");
50      var tiptip_arrow = $("#tiptip_arrow");
51    }
52    
53    return this.each(function(){
54      var org_elem = $(this);
55      if(opts.content){
56        var org_title = opts.content;
57      } else {
58        var org_title = $(this).find('.crm-help').html();
59        if(!org_title){
60          org_title = org_elem.attr(opts.attribute);
61        }
62      }
63      if(org_title != ""){
64        if(!opts.content){
65          org_elem.removeAttr(opts.attribute); //remove original Attribute
66        }
67        var timeout = false;
68        
69        if(opts.activation == "hover"){
70          org_elem.hover(function(){
71            active_tiptip();
72          }, function(){
73            if(!opts.keepAlive){
74              deactive_tiptip();
75            }
76          });
77          if(opts.keepAlive){
78            tiptip_holder.hover(function(){}, function(){
79              deactive_tiptip();
80            });
81          }
82        } else if(opts.activation == "focus"){
83          org_elem.focus(function(){
84            active_tiptip();
85          }).blur(function(){
86            deactive_tiptip();
87          });
88        } else if(opts.activation == "click"){
89          org_elem.click(function(){
90            active_tiptip();
91            return false;
92          }).hover(function(){},function(){
93            if(!opts.keepAlive){
94              deactive_tiptip();
95            }
96          });
97          if(opts.keepAlive){
98            tiptip_holder.hover(function(){}, function(){
99              deactive_tiptip();
100            });
101          }
102        }
103      
104        function active_tiptip(){
105          opts.enter.call(this);
106          tiptip_content.html(org_title);
107          tiptip_holder.hide().removeAttr("class").css("margin","0");
108          tiptip_arrow.removeAttr("style");
109          
110          var top = parseInt(org_elem.offset()['top']);
111          var left = parseInt(org_elem.offset()['left']);
112          var org_width = parseInt(org_elem.outerWidth());
113          var org_height = parseInt(org_elem.outerHeight());
114          var tip_w = tiptip_holder.outerWidth();
115          var tip_h = tiptip_holder.outerHeight();
116          var w_compare = Math.round((org_width - tip_w) / 2);
117          var h_compare = Math.round((org_height - tip_h) / 2);
118          var marg_left = Math.round(left + w_compare);
119          var marg_top = Math.round(top + org_height + opts.edgeOffset);
120          var t_class = "";
121          var arrow_top = "";
122          var arrow_left = Math.round(tip_w - 12) / 2;
123
124                    if(opts.defaultPosition == "bottom"){
125                      t_class = "_bottom";
126                    } else if(opts.defaultPosition == "top"){ 
127                      t_class = "_top";
128                    } else if(opts.defaultPosition == "left"){
129                      t_class = "_left";
130                    } else if(opts.defaultPosition == "right"){
131                      t_class = "_right";
132                    }
133          
134          var right_compare = (w_compare + left) < parseInt($(window).scrollLeft());
135          var left_compare = (tip_w + left) > parseInt($(window).width());
136          
137          if((right_compare && w_compare < 0) || (t_class == "_right" && !left_compare) || (t_class == "_left" && left < (tip_w + opts.edgeOffset + 5))){
138            t_class = "_right";
139            arrow_top = Math.round(tip_h - 13) / 2;
140            arrow_left = -12;
141            marg_left = Math.round(left + org_width + opts.edgeOffset);
142            marg_top = Math.round(top + h_compare);
143          } else if((left_compare && w_compare < 0) || (t_class == "_left" && !right_compare)){
144            t_class = "_left";
145            arrow_top = Math.round(tip_h - 13) / 2;
146            arrow_left =  Math.round(tip_w);
147            marg_left = Math.round(left - (tip_w + opts.edgeOffset + 5));
148            marg_top = Math.round(top + h_compare);
149          }
150
151          var top_compare = false;
152          var bottom_compare = false;
153
154          if (!opts.skipVerticalComparison) {
155            top_compare = (top + org_height + opts.edgeOffset + tip_h + 8) > parseInt($(window).height() + $(window).scrollTop());
156            bottom_compare = ((top + org_height) - (opts.edgeOffset + tip_h + 8)) < 0;
157          }
158
159          if(top_compare || (t_class == "_bottom" && top_compare) || (t_class == "_top" && !bottom_compare)){
160            if(t_class == "_top" || t_class == "_bottom"){
161              t_class = "_top";
162            } else {
163              t_class = t_class+"_top";
164            }
165            arrow_top = tip_h;
166            marg_top = Math.round(top - (tip_h + 5 + opts.edgeOffset));
167          } else if(bottom_compare | (t_class == "_top" && bottom_compare) || (t_class == "_bottom" && !top_compare)){
168            if(t_class == "_top" || t_class == "_bottom"){
169              t_class = "_bottom";
170            } else {
171              t_class = t_class+"_bottom";
172            }
173            arrow_top = -12;            
174            marg_top = Math.round(top + org_height + opts.edgeOffset);
175          }
176        
177          if(t_class == "_right_top" || t_class == "_left_top"){
178            marg_top = marg_top + 5;
179          } else if(t_class == "_right_bottom" || t_class == "_left_bottom"){   
180            marg_top = marg_top - 5;
181          }
182          if(t_class == "_left_top" || t_class == "_left_bottom"){  
183            marg_left = marg_left + 5;
184          }
185          tiptip_arrow.css({"margin-left": arrow_left+"px", "margin-top": arrow_top+"px"});
186          tiptip_holder.css({"margin-left": marg_left+"px", "margin-top": marg_top+"px"}).attr("class","tip"+t_class);
187          
188          if (timeout){ clearTimeout(timeout); }
189          timeout = setTimeout(function(){ tiptip_holder.stop(true,true).fadeIn(opts.fadeIn); }, opts.delay); 
190        }
191        
192        function deactive_tiptip(){
193          opts.exit.call(this);
194          if (timeout){ clearTimeout(timeout); }
195          tiptip_holder.fadeOut(opts.fadeOut);
196        }
197      }       
198    });
199  }
200})(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.