MCPcopy Index your code
hub / github.com/zxlie/FeHelper / _addEvents

Function _addEvents

apps/json-format/format-lib.js:1388–1547  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1386
1387 // 附加操作
1388 let _addEvents = function () {
1389
1390 // 折叠、展开
1391 $('#jfContent span.expand').bind('click', function (ev) {
1392 ev.preventDefault();
1393 ev.stopPropagation();
1394
1395 let parentEl = $(this).parent();
1396 parentEl.toggleClass('collapsed');
1397
1398 if (parentEl.hasClass('collapsed')) {
1399 collapse(parentEl);
1400 }
1401 });
1402
1403 // 点击选中:高亮
1404 $('#jfContent .item').bind('click', function (e) {
1405
1406 let el = $(this);
1407
1408 if (el.hasClass('x-selected')) {
1409 _toogleStatusBar(el, false);
1410 _addOptForItem(el, false);
1411 el.removeClass('x-selected');
1412 _emitSelectionChange($());
1413 e.stopPropagation();
1414 return true;
1415 }
1416
1417 _selectJsonElement(el, {scroll: false});
1418
1419 if (!$(e.target).is('.item .expand')) {
1420 e.stopPropagation();
1421 } else {
1422 $(e.target).parent().trigger('click');
1423 }
1424
1425 // 触发钩子
1426 if (typeof window._OnJsonItemClickByFH === 'function') {
1427 window._OnJsonItemClickByFH(getJsonText(el));
1428 }
1429 });
1430
1431 // 行悬停效果:只高亮当前直接悬停的item,避免嵌套冒泡
1432 let currentHoverElement = null;
1433
1434 $('#jfContent .item').bind('mouseenter', function (e) {
1435 // 只处理视觉效果,不触发任何其他逻辑
1436
1437 // 清除之前的悬停样式
1438 if (currentHoverElement) {
1439 currentHoverElement.removeClass('fh-hover');
1440 }
1441
1442 // 添加当前悬停样式
1443 let el = $(this);
1444 el.addClass('fh-hover');
1445 currentHoverElement = el;

Callers 2

formatFunction · 0.85
formatSyncFunction · 0.85

Calls 12

collapseFunction · 0.85
_toogleStatusBarFunction · 0.85
_addOptForItemFunction · 0.85
_emitSelectionChangeFunction · 0.85
_selectJsonElementFunction · 0.85
getJsonTextFunction · 0.85
getImgCacheFunction · 0.85
getOrCreateImgPreviewFunction · 0.85
setImgCacheFunction · 0.85
showMethod · 0.80
hideMethod · 0.80
$Function · 0.50

Tested by

no test coverage detected