PageSourceSearch

https://dtpa.dn.ua/index_dtpa.dn.ua_files/tooltip.js

js dtpa.dn.ua collected 2026-10-04 20:11:26 UTC 7,619 bytes, 157 lines download raw bytes

1
2
3
4
5
6
7
8/*
9originally written by paul sowden <[email protected]> | /web/20131212133316/http://idontsmoke.co.uk
10modified and localized by alexander shurkayev <[email protected]> | /web/20131212133316/http://htmlcoder.visions.ru
11*/
12
13var tooltip = {
14
15    /* ������ �������� */
16    options: {
17        attr_name: "tooltip", // ������������ ������������ tooltip'��� ��������
18        blank_text: "(��������� � ����� ����)", // ����� ��� ������ � target="_blank"
19        newline_entity: "  ", // ������� ������ ������ (""), ���� �� ������ ������������ � tooltip'�� ���������������; ����� ������, �� ������� ��� ������ ��� �������, ������� ����� ���������� �� ������� ������
20        max_width: 0, // ������������ ������ tooltip'� � ��������; �������� ��� ��������, ���� ������ ������ ���� ��������������
21        delay: 0, // �������� ��� ������ tooltip'� � �������������
22        skip_tags: ["link", "style"] // ����, � ������� �� ������������ �������� alt � title
23    },
24    /* ����� �������� */
25
26    t: document.createElement("DIV"),
27    c: null,
28    g: false,
29    canvas: null,
30
31    m: function(e){
32        if (tooltip.g){
33            var x = window.event ? event.clientX + (tooltip.canvas.scrollLeft || document.body.scrollLeft) : e.pageX;
34            var y = window.event ? event.clientY + (tooltip.canvas.scrollTop || document.body.scrollTop) : e.pageY;
35            tooltip.a(x, y);
36        }
37    },
38
39    d: function(){
40        tooltip.canvas = document.getElementsByTagName(document.compatMode && document.compatMode == "CSS1Compat" ? "HTML" : "BODY")[0];
41        tooltip.t.setAttribute("id", "tooltip");
42        document.body.appendChild(tooltip.t);
43        if (tooltip.options.max_width) tooltip.t.style.maxWidth = tooltip.options.max_width + "px"; // all but ie
44        var a = document.all && !window.opera ? document.all : document.getElementsByTagName("*"); // in opera 9 document.all produces type mismatch error
45        var l = a.length;
46        for (var i = 0; i < l; i++){
47
48            if (!a[i] || tooltip.options.skip_tags.in_array(a[i].tagName.toLowerCase())) continue;
49
50            var tooltip_title = a[i].getAttribute("title"); // returns form object if IE & name="title"; then IE crashes; so...
51            if (tooltip_title && typeof tooltip_title != "string") tooltip_title = "";
52
53            var tooltip_alt = a[i].getAttribute("alt");
54            var tooltip_blank = a[i].getAttribute("target") && a[i].getAttribute("target") == "_blank" && tooltip.options.blank_text;
55            if (tooltip_title || tooltip_blank){
56                a[i].setAttribute(tooltip.options.attr_name, tooltip_blank ? (tooltip_title ? tooltip_title + " " + tooltip.options.blank_text : tooltip.options.blank_text) : tooltip_title);
57                if (a[i].getAttribute(tooltip.options.attr_name)){
58                    a[i].removeAttribute("title");
59                    if (tooltip_alt && a[i].complete) a[i].removeAttribute("alt");
60                    tooltip.l(a[i], "mouseover", tooltip.s);
61                    tooltip.l(a[i], "mouseout", tooltip.h);
62                }
63            }else if (tooltip_alt && a[i].complete){
64                a[i].setAttribute(tooltip.options.attr_name, tooltip_alt);
65                if (a[i].getAttribute(tooltip.options.attr_name)){
66                    a[i].removeAttribute("alt");
67                    tooltip.l(a[i], "mouseover", tooltip.s);
68                    tooltip.l(a[i], "mouseout", tooltip.h);
69                }
70            }
71            if (!a[i].getAttribute(tooltip.options.attr_name) && tooltip_blank){
72                //
73            }
74        }
75        document.onmousemove = tooltip.m;
76        window.onscroll = tooltip.h;
77        tooltip.a(-99, -99);
78    },
79    
80    _: function(s){
81        s = s.replace(/\&/g,"&amp;");
82        s = s.replace(/\</g,"&lt;");
83        s = s.replace(/\>/g,"&gt;");
84        return s;
85    },
86
87    s: function(e){
88        if (typeof tooltip == "undefined") return;
89        var d = window.event ? window.event.srcElement : e.target;
90        if (!d.getAttribute(tooltip.options.attr_name)) return;
91        var s = d.getAttribute(tooltip.options.attr_name);
92        if (tooltip.options.newline_entity){
93            var s = tooltip._(s);
94            s = s.replace(eval("/" + tooltip._(tooltip.options.newline_entity) + "/g"), "<br />");
95            tooltip.t.innerHTML = s;
96        }else{
97            if (tooltip.t.firstChild) tooltip.t.removeChild(tooltip.t.firstChild);
98            tooltip.t.appendChild(document.createTextNode(s));
99        }
100        tooltip.c = setTimeout(function(){
101            tooltip.t.style.visibility = 'visible';
102        }, tooltip.options.delay);
103        tooltip.g = true;
104    },
105
106    h: function(e){
107        if (typeof tooltip == "undefined") return;
108        tooltip.t.style.visibility = "hidden";
109        if (!tooltip.options.newline_entity && tooltip.t.firstChild) tooltip.t.removeChild(tooltip.t.firstChild);
110        clearTimeout(tooltip.c);
111        tooltip.g = false;
112        tooltip.a(-99, -99);
113    },
114
115    l: function(o, e, a){
116        if (o.addEventListener) o.addEventListener(e, a, false); // was true--Opera 7b workaround!
117        else if (o.attachEvent) o.attachEvent("on" + e, a);
118            else return null;
119    },
120
121    a: function(x, y){
122        var w_width = tooltip.canvas.clientWidth ? tooltip.canvas.clientWidth + (tooltip.canvas.scrollLeft || document.body.scrollLeft) : window.innerWidth + window.pageXOffset;
123        var w_height = window.innerHeight ? window.innerHeight + window.pageYOffset : tooltip.canvas.clientHeight + (tooltip.canvas.scrollTop || document.body.scrollTop); // should be vice verca since Opera 7 is crazy!
124
125        if (document.all && document.all.item && !window.opera) tooltip.t.style.width = tooltip.options.max_width && tooltip.t.offsetWidth > tooltip.options.max_width ? tooltip.options.max_width + "px" : "auto";
126        
127        var t_width = tooltip.t.offsetWidth;
128        var t_height = tooltip.t.offsetHeight;
129
130        tooltip.t.style.left = x + 12 + "px";
131        tooltip.t.style.top = y + 12 + "px";
132        
133        if (x + t_width > w_width) tooltip.t.style.left = w_width - t_width + "px";
134        if (y + t_height > w_height) tooltip.t.style.top = w_height - t_height + "px";
135    }
136}
137
138Array.prototype.in_array = function(value){
139    var l = this.length;
140    for (var i = 0; i < l; i++)
141        if (this[i] === value) return true;
142    return false;
143};
144
145var root = window.addEventListener || window.attachEvent ? window : document.addEventListener ? document : null;
146if (root){
147    if (root.addEventListener) root.addEventListener("load", tooltip.d, false);
148    else if (root.attachEvent) root.attachEvent("onload", tooltip.d);
149}<!--Array
150(
151    [label01] =>    0.00000
152    [label02] =>    0.00104
153    [label03] =>    0.00145
154    [label04] =>    0.00145
155    [label05] =>    0.00146
156)
157--><!--b--><!--a-->

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.