Show More
@@ -26,10 +26,10 b' TTIP.main = {' | |||||
26 | offset: [15,15], |
|
26 | offset: [15,15], | |
27 | maxWidth: 600, |
|
27 | maxWidth: 600, | |
28 |
|
28 | |||
29 |
set |
|
29 | setDeferredListeners: function(){ | |
30 |
$( |
|
30 | $('body').on('mouseover', '.tooltip', yt.show_tip); | |
31 |
$( |
|
31 | $('body').on('mousemove', '.tooltip', yt.move_tip); | |
32 |
$( |
|
32 | $('body').on('mouseout', '.tooltip', yt.close_tip); | |
33 | }, |
|
33 | }, | |
34 |
|
34 | |||
35 | init: function(){ |
|
35 | init: function(){ | |
@@ -43,19 +43,13 b' TTIP.main = {' | |||||
43 | if(yt.maxWidth !== null){ |
|
43 | if(yt.maxWidth !== null){ | |
44 | $(yt.tipBox).css('max-width', yt.maxWidth+'px'); |
|
44 | $(yt.tipBox).css('max-width', yt.maxWidth+'px'); | |
45 | } |
|
45 | } | |
46 |
|
46 | yt.setDeferredListeners(); | ||
47 | var tooltips = $('.tooltip'); |
|
|||
48 | var ttLen = tooltips.length; |
|
|||
49 |
|
||||
50 | for(i=0;i<ttLen;i++){ |
|
|||
51 | yt.set_listeners(tooltips[i]); |
|
|||
52 | } |
|
|||
53 | }, |
|
47 | }, | |
54 |
|
48 | |||
55 | show_tip: function(e, el){ |
|
49 | show_tip: function(e, el){ | |
56 | e.stopPropagation(); |
|
50 | e.stopPropagation(); | |
57 | e.preventDefault(); |
|
51 | e.preventDefault(); | |
58 | var el = e.data || el; |
|
52 | var el = e.data || e.currentTarget || el; | |
59 | if(el.tagName.toLowerCase() === 'img'){ |
|
53 | if(el.tagName.toLowerCase() === 'img'){ | |
60 | yt.tipText = el.alt ? el.alt : ''; |
|
54 | yt.tipText = el.alt ? el.alt : ''; | |
61 | } else { |
|
55 | } else { | |
@@ -76,7 +70,7 b' TTIP.main = {' | |||||
76 | move_tip: function(e, el){ |
|
70 | move_tip: function(e, el){ | |
77 | e.stopPropagation(); |
|
71 | e.stopPropagation(); | |
78 | e.preventDefault(); |
|
72 | e.preventDefault(); | |
79 | var el = e.data || el; |
|
73 | var el = e.data || e.currentTarget || el; | |
80 | var movePos = [e.pageX, e.pageY]; |
|
74 | var movePos = [e.pageX, e.pageY]; | |
81 | $(yt.tipBox).css('top', (movePos[1] + yt.offset[1]) + 'px') |
|
75 | $(yt.tipBox).css('top', (movePos[1] + yt.offset[1]) + 'px') | |
82 | $(yt.tipBox).css('left', (movePos[0] + yt.offset[0]) + 'px') |
|
76 | $(yt.tipBox).css('left', (movePos[0] + yt.offset[0]) + 'px') | |
@@ -85,7 +79,7 b' TTIP.main = {' | |||||
85 | close_tip: function(e, el){ |
|
79 | close_tip: function(e, el){ | |
86 | e.stopPropagation(); |
|
80 | e.stopPropagation(); | |
87 | e.preventDefault(); |
|
81 | e.preventDefault(); | |
88 | var el = e.data || el; |
|
82 | var el = e.data || e.currentTarget || el; | |
89 | $(yt.tipBox).hide(); |
|
83 | $(yt.tipBox).hide(); | |
90 | $(el).attr('title', $(el).attr('tt_title')); |
|
84 | $(el).attr('title', $(el).attr('tt_title')); | |
91 | $('#tip-box').hide(); |
|
85 | $('#tip-box').hide(); | |
@@ -97,30 +91,13 b' TTIP.main = {' | |||||
97 | */ |
|
91 | */ | |
98 | var tooltip_activate = function(){ |
|
92 | var tooltip_activate = function(){ | |
99 | yt = TTIP.main; |
|
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 | * show changeset tooltip |
|
101 | * show changeset tooltip | |
105 | */ |
|
102 | */ | |
106 | var show_changeset_tooltip = function(){ |
|
103 | 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 | }; |
|
General Comments 0
You need to be logged in to leave comments.
Login now