##// END OF EJS Templates
template: use Bootstrap tooltips and popover instead of handmade tooltips...
domruf -
r6394:1ab38cd7 default
parent child Browse files
Show More
@@ -108,7 +108,7 b' def _ignorews_url(GET, fileid=None):'
108
108
109 params['anchor'] = fileid
109 params['anchor'] = fileid
110 icon = h.literal('<i class="icon-strike"></i>')
110 icon = h.literal('<i class="icon-strike"></i>')
111 return h.link_to(icon, h.url.current(**params), title=lbl, class_='tooltip')
111 return h.link_to(icon, h.url.current(**params), title=lbl, **{'data-toggle': 'tooltip'})
112
112
113
113
114 def get_line_ctx(fid, GET):
114 def get_line_ctx(fid, GET):
@@ -168,7 +168,7 b' def _context_url(GET, fileid=None):'
168
168
169 params['anchor'] = fileid
169 params['anchor'] = fileid
170 icon = h.literal('<i class="icon-sort"></i>')
170 icon = h.literal('<i class="icon-sort"></i>')
171 return h.link_to(icon, h.url.current(**params), title=lbl, class_='tooltip')
171 return h.link_to(icon, h.url.current(**params), title=lbl, **{'data-toggle': 'tooltip'})
172
172
173
173
174 # Could perhaps be nice to have in the model but is too high level ...
174 # Could perhaps be nice to have in the model but is too high level ...
@@ -311,9 +311,9 b' def pygmentize_annotation(repo_name, fil'
311 author = escape(changeset.author)
311 author = escape(changeset.author)
312 date = changeset.date
312 date = changeset.date
313 message = escape(changeset.message)
313 message = escape(changeset.message)
314 tooltip_html = ("<div style='font-size:0.8em'><b>Author:</b>"
314 tooltip_html = ("<b>Author:</b> %s<br/>"
315 " %s<br/><b>Date:</b> %s</b><br/><b>Message:"
315 "<b>Date:</b> %s</b><br/>"
316 "</b> %s<br/></div>") % (author, date, message)
316 "<b>Message:</b> %s") % (author, date, message)
317
317
318 lnk_format = show_id(changeset)
318 lnk_format = show_id(changeset)
319 uri = link_to(
319 uri = link_to(
@@ -321,9 +321,8 b' def pygmentize_annotation(repo_name, fil'
321 url('changeset_home', repo_name=repo_name,
321 url('changeset_home', repo_name=repo_name,
322 revision=changeset.raw_id),
322 revision=changeset.raw_id),
323 style=get_color_string(changeset.raw_id),
323 style=get_color_string(changeset.raw_id),
324 class_='safe-html-title',
324 **{'data-toggle': 'popover',
325 title=tooltip_html,
325 'data-content': tooltip_html}
326 **{'data-toggle': 'tooltip'}
327 )
326 )
328
327
329 uri += '\n'
328 uri += '\n'
@@ -568,7 +567,7 b' def action_parser(user_log, feed=False, '
568 lbl = rev[:12]
567 lbl = rev[:12]
569 title_ = _('Changeset %s not found') % lbl
568 title_ = _('Changeset %s not found') % lbl
570 if parse_cs:
569 if parse_cs:
571 return link_to(lbl, url_, title=title_, class_='tooltip')
570 return link_to(lbl, url_, title=title_, **{'data-toggle': 'tooltip'})
572 return link_to(lbl, url_, class_='lazy-cs' if lazy_cs else '',
571 return link_to(lbl, url_, class_='lazy-cs' if lazy_cs else '',
573 **{'data-raw_id':rev.raw_id, 'data-repo_name':repo_name})
572 **{'data-raw_id':rev.raw_id, 'data-repo_name':repo_name})
574
573
@@ -2624,37 +2624,6 b" table.code-browser i[class^='icon-'] {"
2624 z-index: 2;
2624 z-index: 2;
2625 }
2625 }
2626
2626
2627 #tip-box {
2628 position: absolute;
2629
2630 background-color: #FFF;
2631 border: 2px solid #577632;
2632 font: 100% sans-serif;
2633 width: auto;
2634 opacity: 1;
2635 padding: 8px;
2636
2637 white-space: pre-wrap;
2638 border-radius: 8px 8px 8px 8px;
2639 box-shadow: 0 2px 2px rgba(0, 0, 0, 0.6);
2640 z-index: 100000;
2641 }
2642
2643 .hl-tip-box {
2644 z-index: 1;
2645 position: absolute;
2646 color: #666;
2647 background-color: #FFF;
2648 border: 2px solid #577632;
2649 font: 100% sans-serif;
2650 width: auto;
2651 opacity: 1;
2652 padding: 8px;
2653 white-space: pre-wrap;
2654 border-radius: 8px 8px 8px 8px;
2655 box-shadow: 0 2px 2px rgba(0, 0, 0, 0.6);
2656 }
2657
2658
2627
2659 .mentions-container {
2628 .mentions-container {
2660 width: 90% !important;
2629 width: 90% !important;
@@ -2983,7 +2952,7 b' input.btn {'
2983
2952
2984 input[disabled].btn,
2953 input[disabled].btn,
2985 .btn.disabled {
2954 .btn.disabled {
2986 color: #999;
2955 opacity: 0.5;
2987 }
2956 }
2988
2957
2989 .label,
2958 .label,
@@ -4434,3 +4403,144 b' div.codeblock div.code-header div.author'
4434 ul.user_group_member li {
4403 ul.user_group_member li {
4435 clear: both;
4404 clear: both;
4436 }
4405 }
4406
4407 .tooltip {
4408 position: absolute;
4409 z-index: 1070;
4410 display: block;
4411 font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
4412 font-size: 12px;
4413 font-style: normal;
4414 font-weight: 400;
4415 line-height: 1.42857143;
4416 text-align: left;
4417 text-align: start;
4418 text-decoration: none;
4419 text-shadow: none;
4420 text-transform: none;
4421 letter-spacing: normal;
4422 word-break: normal;
4423 word-spacing: normal;
4424 word-wrap: normal;
4425 white-space: normal;
4426 }
4427 .tooltip-arrow {
4428 position: absolute;
4429 width: 0;
4430 height: 0;
4431 border-color: transparent;
4432 border-style: solid;
4433 }
4434 .tooltip-inner {
4435 max-width: 200px;
4436 padding: 3px 8px;
4437 color: #fff;
4438 text-align: center;
4439 background-color: #000;
4440 border-radius: 4px;
4441 }
4442
4443 .tooltip.top {
4444 padding: 5px 0;
4445 margin-top: -3px;
4446 }
4447 .tooltip.top .tooltip-arrow {
4448 bottom: 0;
4449 left: 50%;
4450 margin-left: -5px;
4451 border-width: 5px 5px 0;
4452 border-top-color: #000;
4453 }
4454
4455 .tooltip.bottom {
4456 padding: 5px 0;
4457 margin-top: 3px;
4458 }
4459 .tooltip.bottom .tooltip-arrow {
4460 top: 0;
4461 left: 50%;
4462 margin-left: -5px;
4463 border-width: 0 5px 5px;
4464 border-bottom-color: #000;
4465 }
4466
4467
4468 .popover {
4469 position: absolute;
4470 top: 0;
4471 left: 0;
4472 z-index: 1060;
4473 max-width: 276px;
4474 padding: 1px;
4475 background-color: #fff;
4476 background-clip: padding-box;
4477 border: 1px solid #ccc;
4478 border: 1px solid rgba(0,0,0,.2);
4479 border-radius: 6px;
4480 box-shadow: 0 5px 10px rgba(0,0,0,.2);
4481 font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
4482 font-size: 12px;
4483 font-style: normal;
4484 font-weight: 400;
4485 line-height: 1.42857143;
4486 text-align: left;
4487 text-align: start;
4488 text-decoration: none;
4489 text-shadow: none;
4490 text-transform: none;
4491 letter-spacing: normal;
4492 word-break: normal;
4493 word-spacing: normal;
4494 word-wrap: normal;
4495 white-space: normal;
4496 }
4497
4498 .popover > .arrow {
4499 border-width: 11px;
4500 }
4501 .popover > .arrow,
4502 .popover > .arrow::after {
4503 position: absolute;
4504 display: block;
4505 width: 0;
4506 height: 0;
4507 border-color: transparent;
4508 border-style: solid;
4509 }
4510
4511 .popover-title {
4512 padding: 8px 14px;
4513 margin: 0;
4514 font-size: 14px;
4515 background-color: #f7f7f7;
4516 border-bottom: 1px solid #ebebeb;
4517 border-radius: 5px 5px 0 0;
4518 }
4519
4520 .popover-content {
4521 padding: 9px 14px;
4522 }
4523
4524 .popover.top {
4525 margin-top: -10px;
4526 }
4527 .popover.top > .arrow {
4528 bottom: -11px;
4529 left: 50%;
4530 margin-left: -11px;
4531 border-top-color: #999;
4532 border-top-color: rgba(0,0,0,.25);
4533 border-bottom-width: 0;
4534 }
4535
4536 .popover.bottom {
4537 margin-top: 10px;
4538 }
4539 .popover.bottom > .arrow {
4540 top: -11px;
4541 left: 50%;
4542 margin-left: -11px;
4543 border-top-width: 0;
4544 border-bottom-color: #999;
4545 border-bottom-color: rgba(0,0,0,.25);
4546 }
@@ -411,25 +411,6 b' var show_more_event = function(){'
411 });
411 });
412 };
412 };
413
413
414 /**
415 * activate .lazy-cs mouseover for showing changeset tooltip
416 */
417 var show_changeset_tooltip = function(){
418 $('.lazy-cs').mouseover(function(e){
419 var $target = $(e.currentTarget);
420 var rid = $target.data('raw_id');
421 var repo_name = $target.data('repo_name');
422 if(rid && !$target.hasClass('tooltip')){
423 _show_tooltip(e, _TM['loading ...']);
424 var url = pyroutes.url('changeset_info', {"repo_name": repo_name, "revision": rid});
425 ajaxGET(url, function(json){
426 $target.addClass('tooltip');
427 _show_tooltip(e, json['message']);
428 _activate_tooltip($target);
429 });
430 }
431 });
432 };
433
414
434 var _onSuccessFollow = function(target){
415 var _onSuccessFollow = function(target){
435 var $target = $(target);
416 var $target = $(target);
@@ -475,76 +456,56 b' var showRepoSize = function(target, repo'
475 };
456 };
476
457
477 /**
458 /**
478 * tooltips
459 * load tooltips dynamically based on data attributes, used for .lazy-cs changeset links
479 */
460 */
480
461 var get_changeset_tooltip = function() {
481 var tooltip_activate = function(){
462 var $target = $(this);
482 $(document).ready(_init_tooltip);
463 var tooltip = $target.data('tooltip');
483 };
464 if (!tooltip) {
484
465 var raw_id = $target.data('raw_id');
485 var _activate_tooltip = function($tt){
466 var repo_name = $target.data('repo_name');
486 $tt.mouseover(_show_tooltip);
467 var url = pyroutes.url('changeset_info', {"repo_name": repo_name, "revision": raw_id});
487 $tt.mousemove(_move_tooltip);
488 $tt.mouseout(_close_tooltip);
489 };
490
468
491 var _init_tooltip = function(){
469 $.ajax(url, {
492 var $tipBox = $('#tip-box');
470 async: false,
493 if(!$tipBox.length){
471 success: function(data) {
494 $tipBox = $('<div id="tip-box"></div>');
472 tooltip = data["message"];
495 $(document.body).append($tipBox);
473 }
474 });
475 $target.data('tooltip', tooltip);
496 }
476 }
497
477 return tooltip;
498 $tipBox.hide();
499 $tipBox.css('position', 'absolute');
500 $tipBox.css('max-width', '600px');
501
502 _activate_tooltip($('[data-toggle="tooltip"]'));
503 };
478 };
504
479
505 var _show_tooltip = function(e, tipText, safe){
480 /**
506 e.stopImmediatePropagation();
481 * activate tooltips and popups
507 var el = e.currentTarget;
482 */
508 var $el = $(el);
483 var tooltip_activate = function(){
509 if(tipText){
484 function placement(p, e){
510 // just use it
485 if(e.getBoundingClientRect().top > 2*$(window).height()/3){
511 } else if(el.tagName.toLowerCase() === 'img'){
486 return 'top';
512 tipText = el.alt ? el.alt : '';
487 }else{
513 } else {
488 return 'bottom';
514 tipText = el.title ? el.title : '';
489 }
515 safe = safe || $el.hasClass("safe-html-title");
516 }
490 }
517
491 $(document).ready(function(){
518 if(tipText !== ''){
492 $('[data-toggle="tooltip"]').tooltip({
519 // save org title
493 placement: placement
520 $el.attr('tt_title', tipText);
494 });
521 // reset title to not show org tooltips
495 $('[data-toggle="popover"]').popover({
522 $el.prop('title', '');
496 html: true,
523
497 container: 'body',
524 var $tipBox = $('#tip-box');
498 placement: placement,
525 if (safe) {
499 trigger: 'hover',
526 $tipBox.html(tipText);
500 template: '<div class="popover cs-popover" role="tooltip"><div class="arrow"></div><h3 class="popover-title"></h3><div class="popover-content"></div></div>'
527 } else {
501 });
528 $tipBox.text(tipText);
502 $('.lazy-cs').tooltip({
529 }
503 title: get_changeset_tooltip,
530 $tipBox.css('display', 'block');
504 placement: placement
531 }
505 });
506 });
532 };
507 };
533
508
534 var _move_tooltip = function(e){
535 e.stopImmediatePropagation();
536 var $tipBox = $('#tip-box');
537 $tipBox.css('top', (e.pageY + 15) + 'px');
538 $tipBox.css('left', (e.pageX + 15) + 'px');
539 };
540
541 var _close_tooltip = function(e){
542 e.stopImmediatePropagation();
543 var $tipBox = $('#tip-box');
544 $tipBox.hide();
545 var el = e.currentTarget;
546 $(el).prop('title', $(el).attr('tt_title'));
547 };
548
509
549 /**
510 /**
550 * Quick filter widget
511 * Quick filter widget
@@ -44,7 +44,6 b''
44 asynchtml(e.target.href, $user_log, function(){
44 asynchtml(e.target.href, $user_log, function(){
45 show_more_event();
45 show_more_event();
46 tooltip_activate();
46 tooltip_activate();
47 show_changeset_tooltip();
48 });
47 });
49 e.preventDefault();
48 e.preventDefault();
50 });
49 });
@@ -81,7 +81,6 b''
81 $(document).ready(function(){
81 $(document).ready(function(){
82 tooltip_activate();
82 tooltip_activate();
83 show_more_event();
83 show_more_event();
84 show_changeset_tooltip();
85 // routes registration
84 // routes registration
86 pyroutes.register('home', "${h.url('home')}", []);
85 pyroutes.register('home', "${h.url('home')}", []);
87 pyroutes.register('new_gist', "${h.url('new_gist')}", []);
86 pyroutes.register('new_gist', "${h.url('new_gist')}", []);
@@ -45,7 +45,7 b''
45 <%def name="revision(name,rev,tip,author,last_msg)">
45 <%def name="revision(name,rev,tip,author,last_msg)">
46 <div>
46 <div>
47 %if rev >= 0:
47 %if rev >= 0:
48 <a data-toggle="tooltip" title="${'%s:\n\n%s' % (h.escape(author), h.escape(last_msg))}" class="revision-link safe-html-title" href="${h.url('changeset_home',repo_name=name,revision=tip)}">${'r%s:%s' % (rev,h.short_id(tip))}</a>
48 <a data-toggle="popover" title="${author | entity}" data-content="${last_msg | entity}" class="hash" href="${h.url('changeset_home',repo_name=name,revision=tip)}">${'r%s:%s' % (rev,h.short_id(tip))}</a>
49 %else:
49 %else:
50 ${_('No changesets yet')}
50 ${_('No changesets yet')}
51 %endif
51 %endif
@@ -20,13 +20,13 b''
20 <div id="body" class="codeblock">
20 <div id="body" class="codeblock">
21 <div class="code-header">
21 <div class="code-header">
22 <div class="stats">
22 <div class="stats">
23 <div class="pull-left">
23 <div class="pull-left">
24 <div class="left img"><i class="icon-doc-inv"></i></div>
24 <div class="left img"><i class="icon-doc-inv"></i></div>
25 <div class="left item"><pre data-toggle="tooltip" title="${h.fmt_date(c.changeset.date)}">${h.link_to(h.show_id(c.changeset),h.url('changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</pre></div>
25 <div class="left item"><pre data-toggle="tooltip" title="${h.fmt_date(c.changeset.date)}">${h.link_to(h.show_id(c.changeset),h.url('changeset_home',repo_name=c.repo_name,revision=c.changeset.raw_id))}</pre></div>
26 <div class="left item"><pre>${h.format_byte_size(c.file.size,binary=True)}</pre></div>
26 <div class="left item"><pre>${h.format_byte_size(c.file.size,binary=True)}</pre></div>
27 <div class="left item last"><pre>${c.file.mimetype}</pre></div>
27 <div class="left item last"><pre>${c.file.mimetype}</pre></div>
28 </div>
28 </div>
29 <div class="pull-right buttons">
29 <div class="pull-right buttons">
30 %if c.annotate:
30 %if c.annotate:
31 ${h.link_to(_('Show Source'), h.url('files_home', repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path),class_="btn btn-default btn-xs")}
31 ${h.link_to(_('Show Source'), h.url('files_home', repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path),class_="btn btn-default btn-xs")}
32 %else:
32 %else:
@@ -39,14 +39,14 b''
39 ${h.link_to(_('Edit on Branch: %s') % c.changeset.branch, h.url('files_edit_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path, anchor='edit'),class_="btn btn-default btn-xs")}
39 ${h.link_to(_('Edit on Branch: %s') % c.changeset.branch, h.url('files_edit_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path, anchor='edit'),class_="btn btn-default btn-xs")}
40 ${h.link_to(_('Delete'), h.url('files_delete_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path, anchor='edit'),class_="btn btn-danger btn-xs")}
40 ${h.link_to(_('Delete'), h.url('files_delete_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path, anchor='edit'),class_="btn btn-danger btn-xs")}
41 %elif c.on_branch_head and c.file.is_binary:
41 %elif c.on_branch_head and c.file.is_binary:
42 ${h.link_to(_('Edit'), '#', class_="btn btn-default btn-xs disabled tooltip", title=_('Editing binary files not allowed'))}
42 ${h.link_to(_('Edit'), '#', class_="btn btn-default btn-xs disabled", title=_('Editing binary files not allowed'),**{'data-toggle':'tooltip'})}
43 ${h.link_to(_('Delete'), h.url('files_delete_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path, anchor='edit'),class_="btn btn-danger btn-xs")}
43 ${h.link_to(_('Delete'), h.url('files_delete_home',repo_name=c.repo_name,revision=c.changeset.raw_id,f_path=c.f_path, anchor='edit'),class_="btn btn-danger btn-xs")}
44 %else:
44 %else:
45 ${h.link_to(_('Edit'), '#', class_="btn btn-default btn-xs disabled tooltip", title=_('Editing files allowed only when on branch head revision'))}
45 ${h.link_to(_('Edit'), '#', class_="btn btn-default btn-xs disabled", title=_('Editing files allowed only when on branch head revision'),**{'data-toggle':'tooltip'})}
46 ${h.link_to(_('Delete'), '#', class_="btn btn-danger btn-xs disabled tooltip", title=_('Deleting files allowed only when on branch head revision'))}
46 ${h.link_to(_('Delete'), '#', class_="btn btn-danger btn-xs disabled", title=_('Deleting files allowed only when on branch head revision'),**{'data-toggle':'tooltip'})}
47 %endif
47 %endif
48 %endif
48 %endif
49 </div>
49 </div>
50 </div>
50 </div>
51 <div class="author">
51 <div class="author">
52 ${h.gravatar_div(h.email_or_none(c.changeset.author), size=16)}
52 ${h.gravatar_div(h.email_or_none(c.changeset.author), size=16)}
@@ -32,7 +32,6 b''
32 asynchtml(e.target.href, $followers, function(){
32 asynchtml(e.target.href, $followers, function(){
33 show_more_event();
33 show_more_event();
34 tooltip_activate();
34 tooltip_activate();
35 show_changeset_tooltip();
36 });
35 });
37 e.preventDefault();
36 e.preventDefault();
38 });
37 });
@@ -32,7 +32,6 b''
32 asynchtml(e.target.href, $forks, function(){
32 asynchtml(e.target.href, $forks, function(){
33 show_more_event();
33 show_more_event();
34 tooltip_activate();
34 tooltip_activate();
35 show_changeset_tooltip();
36 });
35 });
37 e.preventDefault();
36 e.preventDefault();
38 });
37 });
@@ -62,7 +62,6 b''
62 asynchtml("${h.url.current(filter=c.search_term)}", $("#journal"), function(){
62 asynchtml("${h.url.current(filter=c.search_term)}", $("#journal"), function(){
63 show_more_event();
63 show_more_event();
64 tooltip_activate();
64 tooltip_activate();
65 show_changeset_tooltip();
66 });
65 });
67 e.preventDefault();
66 e.preventDefault();
68 });
67 });
@@ -76,7 +75,6 b''
76 asynchtml(e.target.href, $journal, function(){
75 asynchtml(e.target.href, $journal, function(){
77 show_more_event();
76 show_more_event();
78 tooltip_activate();
77 tooltip_activate();
79 show_changeset_tooltip();
80 });
78 });
81 e.preventDefault();
79 e.preventDefault();
82 });
80 });
General Comments 0
You need to be logged in to leave comments. Login now