Show More
@@ -1,126 +1,103 b'' | |||
|
1 | 1 | // # Copyright (C) 2010-2016 RhodeCode GmbH |
|
2 | 2 | // # |
|
3 | 3 | // # This program is free software: you can redistribute it and/or modify |
|
4 | 4 | // # it under the terms of the GNU Affero General Public License, version 3 |
|
5 | 5 | // # (only), as published by the Free Software Foundation. |
|
6 | 6 | // # |
|
7 | 7 | // # This program is distributed in the hope that it will be useful, |
|
8 | 8 | // # but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
9 | 9 | // # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
10 | 10 | // # GNU General Public License for more details. |
|
11 | 11 | // # |
|
12 | 12 | // # You should have received a copy of the GNU Affero General Public License |
|
13 | 13 | // # along with this program. If not, see <http://www.gnu.org/licenses/>. |
|
14 | 14 | // # |
|
15 | 15 | // # This program is dual-licensed. If you wish to learn more about the |
|
16 | 16 | // # RhodeCode Enterprise Edition, including its added features, Support services, |
|
17 | 17 | // # and proprietary license terms, please see https://rhodecode.com/licenses/ |
|
18 | 18 | |
|
19 | 19 | /** |
|
20 | 20 | * TOOLTIP IMPL. |
|
21 | 21 | */ |
|
22 | 22 | |
|
23 | 23 | var TTIP = {}; |
|
24 | 24 | |
|
25 | 25 | TTIP.main = { |
|
26 | 26 | offset: [15,15], |
|
27 | 27 | maxWidth: 600, |
|
28 | 28 | |
|
29 |
set |
|
|
30 |
$( |
|
|
31 |
$( |
|
|
32 |
$( |
|
|
29 | setDeferredListeners: function(){ | |
|
30 | $('body').on('mouseover', '.tooltip', yt.show_tip); | |
|
31 | $('body').on('mousemove', '.tooltip', yt.move_tip); | |
|
32 | $('body').on('mouseout', '.tooltip', yt.close_tip); | |
|
33 | 33 | }, |
|
34 | 34 | |
|
35 | 35 | init: function(){ |
|
36 | 36 | $('#tip-box').remove(); |
|
37 | 37 | yt.tipBox = document.createElement('div'); |
|
38 | 38 | document.body.appendChild(yt.tipBox); |
|
39 | 39 | yt.tipBox.id = 'tip-box'; |
|
40 | 40 | |
|
41 | 41 | $(yt.tipBox).hide(); |
|
42 | 42 | $(yt.tipBox).css('position', 'absolute'); |
|
43 | 43 | if(yt.maxWidth !== null){ |
|
44 | 44 | $(yt.tipBox).css('max-width', yt.maxWidth+'px'); |
|
45 | 45 | } |
|
46 | ||
|
47 | var tooltips = $('.tooltip'); | |
|
48 | var ttLen = tooltips.length; | |
|
49 | ||
|
50 | for(i=0;i<ttLen;i++){ | |
|
51 | yt.set_listeners(tooltips[i]); | |
|
52 | } | |
|
46 | yt.setDeferredListeners(); | |
|
53 | 47 | }, |
|
54 | 48 | |
|
55 | 49 | show_tip: function(e, el){ |
|
56 | 50 | e.stopPropagation(); |
|
57 | 51 | e.preventDefault(); |
|
58 | var el = e.data || el; | |
|
52 | var el = e.data || e.currentTarget || el; | |
|
59 | 53 | if(el.tagName.toLowerCase() === 'img'){ |
|
60 | 54 | yt.tipText = el.alt ? el.alt : ''; |
|
61 | 55 | } else { |
|
62 | 56 | yt.tipText = el.title ? el.title : ''; |
|
63 | 57 | } |
|
64 | 58 | |
|
65 | 59 | if(yt.tipText !== ''){ |
|
66 | 60 | // save org title |
|
67 | 61 | $(el).attr('tt_title', yt.tipText); |
|
68 | 62 | // reset title to not show org tooltips |
|
69 | 63 | $(el).attr('title', ''); |
|
70 | 64 | |
|
71 | 65 | yt.tipBox.innerHTML = yt.tipText; |
|
72 | 66 | $(yt.tipBox).show(); |
|
73 | 67 | } |
|
74 | 68 | }, |
|
75 | 69 | |
|
76 | 70 | move_tip: function(e, el){ |
|
77 | 71 | e.stopPropagation(); |
|
78 | 72 | e.preventDefault(); |
|
79 | var el = e.data || el; | |
|
73 | var el = e.data || e.currentTarget || el; | |
|
80 | 74 | var movePos = [e.pageX, e.pageY]; |
|
81 | 75 | $(yt.tipBox).css('top', (movePos[1] + yt.offset[1]) + 'px') |
|
82 | 76 | $(yt.tipBox).css('left', (movePos[0] + yt.offset[0]) + 'px') |
|
83 | 77 | }, |
|
84 | 78 | |
|
85 | 79 | close_tip: function(e, el){ |
|
86 | 80 | e.stopPropagation(); |
|
87 | 81 | e.preventDefault(); |
|
88 | var el = e.data || el; | |
|
82 | var el = e.data || e.currentTarget || el; | |
|
89 | 83 | $(yt.tipBox).hide(); |
|
90 | 84 | $(el).attr('title', $(el).attr('tt_title')); |
|
91 | 85 | $('#tip-box').hide(); |
|
92 | 86 | } |
|
93 | 87 | }; |
|
94 | 88 | |
|
95 | 89 | /** |
|
96 | 90 | * tooltip activate |
|
97 | 91 | */ |
|
98 | 92 | var tooltip_activate = function(){ |
|
99 | 93 | yt = TTIP.main; |
|
100 | $(document).ready(yt.init); | |
|
94 | if ($(document).data('activated-tooltips') !== '1'){ | |
|
95 | $(document).ready(yt.init); | |
|
96 | $(document).data('activated-tooltips', '1'); | |
|
97 | } | |
|
101 | 98 | }; |
|
102 | 99 | |
|
103 | 100 | /** |
|
104 | 101 | * show changeset tooltip |
|
105 | 102 | */ |
|
106 | var show_changeset_tooltip = function(){ | |
|
107 | $('.lazy-cs').mouseover(function(e) { | |
|
108 | var target = e.currentTarget; | |
|
109 | var rid = $(target).attr('raw_id'); | |
|
110 | var repo_name = $(target).attr('repo_name'); | |
|
111 | var ttid = 'tt-'+rid; | |
|
112 | var success = function(o){ | |
|
113 | $(target).addClass('tooltip') | |
|
114 | $(target).attr('title', o['message']); | |
|
115 | TTIP.main.show_tip(e, target); | |
|
116 | } | |
|
117 | if(rid && !$(target).hasClass('tooltip')){ | |
|
118 | $(target).attr('id', ttid); | |
|
119 | $(target).attr('title', _gettext('loading ...')); | |
|
120 | TTIP.main.set_listeners(target); | |
|
121 | TTIP.main.show_tip(e, target); | |
|
122 | var url = pyroutes.url('changeset_info', {"repo_name":repo_name, "revision": rid}); | |
|
123 | ajaxGET(url, success); | |
|
124 | } | |
|
125 | }); | |
|
126 | }; | |
|
103 | var show_changeset_tooltip = function(){}; |
General Comments 0
You need to be logged in to leave comments.
Login now