##// END OF EJS Templates
implemented yui tooltip, and added it into annotation and main page.
marcink -
r281:cd2ee462 default
parent child Browse files
Show More
@@ -9,11 +9,12 b' from pylons import url, app_globals as g'
9 from pylons.i18n.translation import _, ungettext
9 from pylons.i18n.translation import _, ungettext
10 from vcs.utils.annotate import annotate_highlight
10 from vcs.utils.annotate import annotate_highlight
11 from webhelpers.html import literal, HTML, escape
11 from webhelpers.html import literal, HTML, escape
12 from webhelpers.html.tools import *
12 from webhelpers.html.builder import make_tag
13 from webhelpers.html.builder import make_tag
13 from webhelpers.html.tags import auto_discovery_link, checkbox, css_classes, \
14 from webhelpers.html.tags import auto_discovery_link, checkbox, css_classes, \
14 end_form, file, form, hidden, image, javascript_link, link_to, link_to_if, \
15 end_form, file, form, hidden, image, javascript_link, link_to, link_to_if, \
15 link_to_unless, ol, required_legend, select, stylesheet_link, submit, text, \
16 link_to_unless, ol, required_legend, select, stylesheet_link, submit, text, \
16 password, textarea, title, ul, xml_declaration
17 password, textarea, title, ul, xml_declaration, radio
17 from webhelpers.html.tools import auto_link, button_to, highlight, js_obfuscate, \
18 from webhelpers.html.tools import auto_link, button_to, highlight, js_obfuscate, \
18 mail_to, strip_links, strip_tags, tag_re
19 mail_to, strip_links, strip_tags, tag_re
19 from webhelpers.number import format_byte_size, format_bit_size
20 from webhelpers.number import format_byte_size, format_bit_size
@@ -21,10 +22,10 b' from webhelpers.pylonslib import Flash a'
21 from webhelpers.pylonslib.secure_form import secure_form
22 from webhelpers.pylonslib.secure_form import secure_form
22 from webhelpers.text import chop_at, collapse, convert_accented_entities, \
23 from webhelpers.text import chop_at, collapse, convert_accented_entities, \
23 convert_misc_entities, lchop, plural, rchop, remove_formatting, \
24 convert_misc_entities, lchop, plural, rchop, remove_formatting, \
24 replace_whitespace, urlify, truncate
25 replace_whitespace, urlify, truncate, wrap_paragraphs
25
26
26
27
27 #Custom helper here :)
28 #Custom helpers here :)
28 class _Link(object):
29 class _Link(object):
29 '''
30 '''
30 Make a url based on label and url with help of url_for
31 Make a url based on label and url with help of url_for
@@ -38,6 +39,7 b' class _Link(object):'
38 link_fn = link_to(label, url(*url_, **urlargs))
39 link_fn = link_to(label, url(*url_, **urlargs))
39 return link_fn
40 return link_fn
40
41
42 link = _Link()
41
43
42 class _GetError(object):
44 class _GetError(object):
43
45
@@ -46,18 +48,104 b' class _GetError(object):'
46 if form_errors and form_errors.has_key(field_name):
48 if form_errors and form_errors.has_key(field_name):
47 return literal(tmpl % form_errors.get(field_name))
49 return literal(tmpl % form_errors.get(field_name))
48
50
51 get_error = _GetError()
52
53 def recursive_replace(str, replace=' '):
54 """
55 Recursive replace of given sign to just one instance
56 @param str: given string
57 @param replace:char to find and replace multiple instances
58
59 Examples::
60 >>> recursive_replace("Mighty---Mighty-Bo--sstones",'-')
61 'Mighty-Mighty-Bo-sstones'
62 """
63
64 if str.find(replace * 2) == -1:
65 return str
66 else:
67 str = str.replace(replace * 2, replace)
68 return recursive_replace(str, replace)
69
70 class _ToolTip(object):
71
72 def __call__(self, tooltip_title, trim_at=50):
73 """
74 Special function just to wrap our text into nice formatted autowrapped
75 text
76 @param tooltip_title:
77 """
78
79 return literal(wrap_paragraphs(tooltip_title, trim_at)\
80 .replace('\n', '<br/>'))
81
82 def activate(self):
83 """
84 Adds tooltip mechanism to the given Html all tooltips have to have
85 set class tooltip and set attribute tooltip_title.
86 Then a tooltip will be generated based on that
87 All with yui js tooltip
88 """
89
90 js = '''
91 YAHOO.util.Event.onDOMReady(function(){
92 function toolTipsId(){
93 var ids = [];
94 var tts = YAHOO.util.Dom.getElementsByClassName('tooltip');
95
96 for (var i = 0; i < tts.length; i++) {
97 //if element doesn not have and id autgenerate one for tooltip
98
99 if (!tts[i].id){
100 tts[i].id='tt'+i*100;
101 }
102 ids.push(tts[i].id);
103 }
104 return ids
105 };
106 var myToolTips = new YAHOO.widget.Tooltip("tooltip", {
107 context: toolTipsId(),
108 monitorresize:false,
109 xyoffset :[0,0],
110 autodismissdelay:300000,
111 hidedelay:5,
112 showdelay:20,
113 });
114
115 //Mouse subscribe optional arguments
116 myToolTips.contextMouseOverEvent.subscribe(
117 function(type, args) {
118 var context = args[0];
119 return true;
120 });
121
122 // Set the text for the tooltip just before we display it. Lazy method
123 myToolTips.contextTriggerEvent.subscribe(
124 function(type, args) {
125 var context = args[0];
126 var txt = context.getAttribute('tooltip_title');
127 this.cfg.setProperty("text", txt);
128 });
129 });
130 '''
131 return literal(js)
132
133 tooltip = _ToolTip()
134
49 class _FilesBreadCrumbs(object):
135 class _FilesBreadCrumbs(object):
50
136
51 def __call__(self, repo_name, rev, paths):
137 def __call__(self, repo_name, rev, paths):
52 url_l = [link_to(repo_name, url('files_home', repo_name=repo_name, revision=rev, f_path=''))]
138 url_l = [link_to(repo_name, url('files_home', repo_name=repo_name, revision=rev, f_path=''))]
53 paths_l = paths.split('/')
139 paths_l = paths.split(' / ')
54
140
55 for cnt, p in enumerate(paths_l, 1):
141 for cnt, p in enumerate(paths_l, 1):
56 if p != '':
142 if p != '':
57 url_l.append(link_to(p, url('files_home', repo_name=repo_name, revision=rev, f_path='/'.join(paths_l[:cnt]))))
143 url_l.append(link_to(p, url('files_home', repo_name=repo_name, revision=rev, f_path=' / '.join(paths_l[:cnt]))))
58
144
59 return literal(' / '.join(url_l))
145 return literal(' / '.join(url_l))
60
146
147 files_breadcrumbs = _FilesBreadCrumbs()
148
61 def pygmentize(filenode, **kwargs):
149 def pygmentize(filenode, **kwargs):
62 """
150 """
63 pygmentize function using pygments
151 pygmentize function using pygments
@@ -81,32 +169,28 b' def pygmentize_annotation(filenode, **kw'
81 else:
169 else:
82 color_dict[cs] = gen_color()
170 color_dict[cs] = gen_color()
83 col = color_dict[cs]
171 col = color_dict[cs]
84 return "color: rgb(%s) ! important;" % (','.join(col))
172 return "color: rgb(%s) ! important;" % (', '.join(col))
85
173
86 def url_func(changeset):
174 def url_func(changeset):
87 return '%s\n' % (link_to('r%s:%s' % (changeset.revision, changeset.raw_id),
175 tooltip_html = "<div style='font-size:0.8em'><b>Author:</b> %s<br/><b>Date:</b> %s</b><br/><b>Message:</b> %s<br/></div>"
88 url('changeset_home', repo_name='test', revision=changeset.raw_id),
176
89 title=_('author') + ':%s - %s' % (changeset.author, changeset.message,),
177 tooltip_html = tooltip_html % (changeset.author,
90 style=get_color_string(changeset.raw_id)))
178 changeset.date,
91
179 tooltip(changeset.message))
180 lnk_format = 'r%s:%s' % (changeset.revision,
181 changeset.raw_id)
182 uri = link_to(
183 lnk_format,
184 url('changeset_home', repo_name='test',
185 revision=changeset.raw_id),
186 style=get_color_string(changeset.raw_id),
187 class_='tooltip',
188 tooltip_title=tooltip_html
189 )
190
191 uri += '\n'
192 return uri
92 return literal(annotate_highlight(filenode, url_func, **kwargs))
193 return literal(annotate_highlight(filenode, url_func, **kwargs))
93
94 def recursive_replace(str, replace=' '):
95 """
96 Recursive replace of given sign to just one instance
97 @param str: given string
98 @param replace:char to find and replace multiple instances
99
100 Examples::
101 >>> recursive_replace("Mighty---Mighty-Bo--sstones",'-')
102 'Mighty-Mighty-Bo-sstones'
103 """
104
105 if str.find(replace * 2) == -1:
106 return str
107 else:
108 str = str.replace(replace * 2, replace)
109 return recursive_replace(str, replace)
110
194
111 def repo_name_slug(value):
195 def repo_name_slug(value):
112 """
196 """
@@ -117,8 +201,5 b' def repo_name_slug(value):'
117 slug = slug.replace(c, '-')
201 slug = slug.replace(c, '-')
118 slug = recursive_replace(slug, '-')
202 slug = recursive_replace(slug, '-')
119 return slug
203 return slug
120
204
121 files_breadcrumbs = _FilesBreadCrumbs()
122 link = _Link()
123 flash = _Flash()
205 flash = _Flash()
124 get_error = _GetError()
@@ -143,7 +143,8 b' from vcs.utils.lazy import LazyProperty'
143 class EmptyChangeset(BaseChangeset):
143 class EmptyChangeset(BaseChangeset):
144
144
145 revision = -1
145 revision = -1
146
146 message = ''
147
147 @LazyProperty
148 @LazyProperty
148 def raw_id(self):
149 def raw_id(self):
149 """
150 """
@@ -148,6 +148,7 b' class HgModel(object):'
148 tmp_d['contact'] = repo.contact
148 tmp_d['contact'] = repo.contact
149 tmp_d['contact_sort'] = tmp_d['contact']
149 tmp_d['contact_sort'] = tmp_d['contact']
150 tmp_d['repo_archives'] = list(repo._get_archives())
150 tmp_d['repo_archives'] = list(repo._get_archives())
151 tmp_d['last_msg'] = tip.message
151
152
152 yield tmp_d
153 yield tmp_d
153
154
@@ -156,6 +156,31 b' table tr.parity1 {'
156 .error-message{
156 .error-message{
157 color:#CC3300;
157 color:#CC3300;
158 }
158 }
159 /**** Tooltip ****/
160 .yui-overlay,
161 .yui-panel-container {
162 visibility:hidden;
163 position:absolute;
164 z-index: 2;
165 }
166
167 .yui-tt {
168 visibility:hidden;
169 position:absolute;
170 color:#666666;
171 background-color:#FFFFFF;
172 font-family:arial,helvetica,verdana,sans-serif;
173 padding:8px;
174 border:2px solid #556CB5;
175 font:100% sans-serif;
176 width:auto;
177 }
178
179 .yui-tt-shadow {
180 display: none;
181 }
182 /** end of Tooltip **/
183
159
184
160 div#main {
185 div#main {
161 padding: 5px;
186 padding: 5px;
@@ -28,6 +28,7 b''
28 </div>
28 </div>
29 <div id="main">
29 <div id="main">
30 ${next.main()}
30 ${next.main()}
31 <script>${h.tooltip.activate()}</script>
31 </div>
32 </div>
32 <div class="page-footer">
33 <div class="page-footer">
33 Hg App ${c.hg_app_version} &copy; 2010 by Marcin Kuzminski
34 Hg App ${c.hg_app_version} &copy; 2010 by Marcin Kuzminski
@@ -140,6 +141,7 b' def is_current(selected):'
140
141
141 <%def name="js()">
142 <%def name="js()">
142 <script type="text/javascript" src="/js/yui/utilities/utilities.js"></script>
143 <script type="text/javascript" src="/js/yui/utilities/utilities.js"></script>
144 <script type="text/javascript" src="/js/yui/container/container-min.js"></script>
143 </%def>
145 </%def>
144
146
145 <!-- DEFINITION OF FORM ERROR FETCHER -->
147 <!-- DEFINITION OF FORM ERROR FETCHER -->
@@ -35,10 +35,14 b' from pylons_app.lib import filters'
35 </tr>
35 </tr>
36 %for cnt,repo in enumerate(c.repos_list):
36 %for cnt,repo in enumerate(c.repos_list):
37 <tr class="parity${cnt%2}">
37 <tr class="parity${cnt%2}">
38 <td>${h.link(repo['name'],h.url('summary_home',repo_name=repo['name']))}</td>
38 <td>${h.link_to(repo['name'],
39 h.url('summary_home',repo_name=repo['name']))}</td>
39 <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
40 <td title="${repo['description']}">${h.truncate(repo['description'],60)}</td>
40 <td>${repo['last_change']|n,filters.age}</td>
41 <td>${repo['last_change']|n,filters.age}</td>
41 <td>${h.link_to('r%s:%s' % (repo['rev'],repo['tip']),h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']))}</td>
42 <td>${h.link_to('r%s:%s' % (repo['rev'],repo['tip']),
43 h.url('changeset_home',repo_name=repo['name'],revision=repo['tip']),
44 class_="tooltip",
45 tooltip_title=h.tooltip(repo['last_msg']))}</td>
42 <td title="${repo['contact']}">${repo['contact']|n,filters.person}</td>
46 <td title="${repo['contact']}">${repo['contact']|n,filters.person}</td>
43 <td>
47 <td>
44 <a title="${_('Subscribe to %s rss feed')%repo['name']}" class="rss_logo" href="${h.url('rss_feed_home',repo_name=repo['name'])}"></a>
48 <a title="${_('Subscribe to %s rss feed')%repo['name']}" class="rss_logo" href="${h.url('rss_feed_home',repo_name=repo['name'])}"></a>
General Comments 0
You need to be logged in to leave comments. Login now