markdownr 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/markdown_server/version.rb +1 -1
- data/views/popup_assets.erb +87 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3ae72dd628c263c9d8657afdb7e29d5449c0515e636494322dd9e9f256167c78
|
|
4
|
+
data.tar.gz: fd1996de9f2bb8bdd5460189d2aaae3448e30874facea35a653822f6916d3ebe
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 07e413a60a5a9f8066ee9ad42f33528aa793e2f5d076eb7b5feb1d4beb214d0090d0715e7468cc962903a5a686a3d6a88a31be2c5632b4ef7721a432e6d3cbac
|
|
7
|
+
data.tar.gz: 63e6c9ba052569bccb6ca25452ddf77b8e88e94dd36f809326a3574113b54d580a2194c669040afb23c60b2fef7287155d908c2bf57511df255022c28357d51c
|
data/views/popup_assets.erb
CHANGED
|
@@ -747,5 +747,92 @@
|
|
|
747
747
|
});
|
|
748
748
|
})();
|
|
749
749
|
|
|
750
|
+
// Bible footnote and cross-reference marker popups
|
|
751
|
+
// Markers are <sup data-fn="..."> or <sup data-cr="..."> with targets at bottom
|
|
752
|
+
(function() {
|
|
753
|
+
// Build index: map each crossref marker's data-cr to its positional <li>
|
|
754
|
+
var crMarkers = document.querySelectorAll('sup.crossref-marker[data-cr]');
|
|
755
|
+
var crItems = document.querySelectorAll('.crossrefs li.crossref');
|
|
756
|
+
var crIndex = {};
|
|
757
|
+
crMarkers.forEach(function(m, i) {
|
|
758
|
+
if (i < crItems.length) crIndex[m.dataset.cr] = crItems[i];
|
|
759
|
+
});
|
|
760
|
+
|
|
761
|
+
function findMarker(el) {
|
|
762
|
+
while (el && el.tagName !== 'BODY') {
|
|
763
|
+
if (el.tagName === 'SUP' && (el.dataset.fn || el.dataset.cr)) return el;
|
|
764
|
+
el = el.parentElement;
|
|
765
|
+
}
|
|
766
|
+
return null;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
function markerContent(marker) {
|
|
770
|
+
var li;
|
|
771
|
+
if (marker.dataset.fn) {
|
|
772
|
+
li = document.getElementById(marker.dataset.fn);
|
|
773
|
+
} else if (marker.dataset.cr) {
|
|
774
|
+
li = document.getElementById(marker.dataset.cr) || crIndex[marker.dataset.cr];
|
|
775
|
+
}
|
|
776
|
+
return li ? li.innerHTML : null;
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
function markerTitle(marker) {
|
|
780
|
+
if (marker.dataset.fn) return 'Footnote ' + marker.textContent.replace(/[\[\]]/g, '');
|
|
781
|
+
return 'Cross-reference ' + marker.textContent.replace(/[()]/g, '');
|
|
782
|
+
}
|
|
783
|
+
|
|
784
|
+
function handleMarker(marker, x, y) {
|
|
785
|
+
var html = markerContent(marker);
|
|
786
|
+
if (!html) return;
|
|
787
|
+
var title = markerTitle(marker);
|
|
788
|
+
var rect = marker.getBoundingClientRect();
|
|
789
|
+
showPopup(x, y, title, html, null, rect);
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
// Click
|
|
793
|
+
document.addEventListener('click', function(e) {
|
|
794
|
+
var marker = findMarker(e.target);
|
|
795
|
+
if (!marker) return;
|
|
796
|
+
e.preventDefault();
|
|
797
|
+
e.stopPropagation();
|
|
798
|
+
handleMarker(marker, e.clientX, e.clientY);
|
|
799
|
+
});
|
|
800
|
+
|
|
801
|
+
// Touch
|
|
802
|
+
document.addEventListener('touchend', function(e) {
|
|
803
|
+
if (touchMoved) return;
|
|
804
|
+
var marker = findMarker(e.target);
|
|
805
|
+
if (!marker) return;
|
|
806
|
+
e.preventDefault();
|
|
807
|
+
e.stopPropagation();
|
|
808
|
+
var touch = e.changedTouches[0];
|
|
809
|
+
handleMarker(marker, touch.clientX, touch.clientY);
|
|
810
|
+
}, { passive: false });
|
|
811
|
+
|
|
812
|
+
// Hover
|
|
813
|
+
var hoverTimer = null;
|
|
814
|
+
document.querySelectorAll('sup.footnote-marker, sup.crossref-marker').forEach(function(marker) {
|
|
815
|
+
marker.addEventListener('mouseenter', function(e) {
|
|
816
|
+
clearTimeout(hoverTimer);
|
|
817
|
+
if (popup) return;
|
|
818
|
+
var x = e.clientX, y = e.clientY;
|
|
819
|
+
hoverTimer = setTimeout(function() {
|
|
820
|
+
if (!popup) handleMarker(marker, x, y);
|
|
821
|
+
}, 300);
|
|
822
|
+
});
|
|
823
|
+
marker.addEventListener('mouseleave', function() {
|
|
824
|
+
clearTimeout(hoverTimer);
|
|
825
|
+
if (popup) mouseLeaveTimer = setTimeout(hidePopup, 150);
|
|
826
|
+
});
|
|
827
|
+
});
|
|
828
|
+
|
|
829
|
+
// Style markers as clickable
|
|
830
|
+
var style = document.createElement('style');
|
|
831
|
+
style.textContent =
|
|
832
|
+
'.footnote-marker, .crossref-marker { cursor: pointer; }' +
|
|
833
|
+
'.footnote-marker:hover, .crossref-marker:hover { color: #8b6914; }';
|
|
834
|
+
document.head.appendChild(style);
|
|
835
|
+
})();
|
|
836
|
+
|
|
750
837
|
})();
|
|
751
838
|
</script>
|