MCPcopy Create free account
hub / github.com/KDAB/codebrowser / onMouseClick

Function onMouseClick

data/codebrowser.js:423–484  ·  view source on GitHub ↗
(e)

Source from the content-addressed store, hash-verified

421 var skipHighlightTimerId = null;
422 var onMouseLeave = function(e) { tooltip.hideAfterDelay(e); }
423 var onMouseClick = function(e) {
424 if (e.ctrlKey || e.altKey || e.button != 0) return true; // don't break ctrl+click, open in a new tab
425 if (!this.href) return true; // not clicking on a link
426 var toppos;
427 if (this.parentNode.tagName == "TD") {
428 // The node is part of the code, find out the context from there.
429 toppos = $(this).offset().top
430 } else if (tooltip.tooltip.is(":visible") && tooltip.elem) {
431 // If the tooltip is open, use the item from the tooltip
432 toppos = tooltip.elem.offset().top;
433 } else {
434 // else, from the top.
435 var contentTop = $("#content").offset().top;
436 toppos = window.scrollY + contentTop;
437 }
438 var context = undefined;
439 $('.def').each(function() {
440 var t = $(this);
441 if (t.offset().top > toppos + 1) {
442 return false;
443 }
444 context = t;
445 });
446 if (context !== undefined) {
447 if (context.hasClass("decl")) {
448 var c = context[0].title_;
449 if (c === undefined)
450 c = context.attr("title");
451 var ref = context.attr("data-ref");
452 pushHistoryLog( { url: location.origin + location.pathname + "#" + ref, name: c, ref: ref} );
453 }
454 }
455
456 var ref = $(this).attr("data-ref")
457 if (ref && ref.match(/^[^0-9].*/)) {
458 if (ref.match(/^_M\//)) { // Macro
459 var currentLine = $(this).parents("tr").find("th").text();
460 pushHistoryLog( { url: location.origin + location.pathname + "#" + currentLine, ref: ref } );
461 } else {
462 pushHistoryLog( { url: this.href, ref: ref } );
463 }
464 }
465
466 tooltip.tooltip.hide();
467 skipHighlightTimerId = setTimeout(function() { skipHighlightTimerId = null }, 600);
468
469 if (history && history.pushState) {
470 var href = this.href;
471 var hashPos = href.indexOf("#");
472 if (hashPos >= 0) {
473 var anchor = href.substr(hashPos+1);
474 var url = href.substr(0, hashPos);
475 if (url == "" || url === location.origin + location.pathname) {
476 scrollToAnchor(anchor, true)
477 e.preventDefault();
478 return false;
479 }
480 }

Callers

nothing calls this directly

Calls 2

pushHistoryLogFunction · 0.85
scrollToAnchorFunction · 0.85

Tested by

no test coverage detected