double click to open beyt partial control
This commit is contained in:
parent
ce4ff283d5
commit
c0803000f3
@ -28,6 +28,7 @@
|
|||||||
if (Model.IsPoemPage)
|
if (Model.IsPoemPage)
|
||||||
{
|
{
|
||||||
<script>
|
<script>
|
||||||
|
var currentPoemId = @Model.GanjoorPage.Id;
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
checkWebShareSupport();
|
checkWebShareSupport();
|
||||||
if (lineNumbers) {
|
if (lineNumbers) {
|
||||||
@ -202,8 +203,8 @@ else if (Model.ReadOnlyMode)
|
|||||||
paste_remove_styles_if_webkit: true,
|
paste_remove_styles_if_webkit: true,
|
||||||
paste_strip_class_attributes: true,
|
paste_strip_class_attributes: true,
|
||||||
a11y_advanced_options: true,
|
a11y_advanced_options: true,
|
||||||
skin: (window.matchMedia("(prefers-color-scheme: dark)").matches && localStorage.getItem("scheme") != "light" ? "oxide-dark" : localStorage.getItem("scheme") == "dark" ? "oxide-dark" : "oxide"),
|
skin: (window.matchMedia("(prefers-color-scheme: dark)").matches && localStorage.getItem("scheme") != "light" ? "oxide-dark" : localStorage.getItem("scheme") == "dark" ? "oxide-dark" : ""),
|
||||||
content_css: (window.matchMedia("(prefers-color-scheme: dark)").matches && localStorage.getItem("scheme") != "light" ? "dark" : localStorage.getItem("scheme") == "dark" ? "dark" : false),
|
content_css: (window.matchMedia("(prefers-color-scheme: dark)").matches && localStorage.getItem("scheme") != "light" ? "dark" : localStorage.getItem("scheme") == "dark" ? "dark" : ""),
|
||||||
setup: function(editor) {
|
setup: function(editor) {
|
||||||
editor.on('tap', function(e, f) {
|
editor.on('tap', function(e, f) {
|
||||||
var editor_id = e.view.frameElement.id.slice(0, -4);
|
var editor_id = e.view.frameElement.id.slice(0, -4);
|
||||||
|
|||||||
@ -56,6 +56,41 @@ function bnumClick(poemId, index) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Reveals the same beyt panel as clicking the (optional) couplet-number badge,
|
||||||
|
// but triggered by clicking the verse text itself - so it works even when
|
||||||
|
// line numbering is turned off. Reuses bnumClick's own element list so the
|
||||||
|
// index always matches what bnumClick itself expects, including for poems
|
||||||
|
// mixing .m1/.m2 couplets with single-line .b2/.n/.l verse types.
|
||||||
|
function verseTextClick(event) {
|
||||||
|
// don't double-fire when the click actually landed on the number badge
|
||||||
|
// or inside an already-revealed panel - both handle their own clicks
|
||||||
|
if (event.target.closest('.bnum') || event.target.closest('.bnumdiv')) return;
|
||||||
|
|
||||||
|
var verseHalf = event.target.closest('.m1, .m2, .b2, .n, .l');
|
||||||
|
if (!verseHalf) return;
|
||||||
|
|
||||||
|
// a real drag-select, double-click word-select, or long-press selection
|
||||||
|
// leaves text selected by the time click fires - let vaabd.js own that
|
||||||
|
var sel = window.getSelection();
|
||||||
|
if (sel && sel.toString().trim() !== '') return;
|
||||||
|
|
||||||
|
// .m2 (the second hemistich) isn't itself in bnumClick's element list -
|
||||||
|
// resolve it to the sibling .m1 within the same verse container
|
||||||
|
var indexTarget = verseHalf;
|
||||||
|
if (verseHalf.classList.contains('m2')) {
|
||||||
|
var container = verseHalf.parentElement;
|
||||||
|
indexTarget = container ? container.querySelector('.m1') : null;
|
||||||
|
if (!indexTarget) return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var msr1s = getElements("m1", "b2", "n", "l");
|
||||||
|
var index = Array.prototype.indexOf.call(msr1s, indexTarget);
|
||||||
|
if (index === -1) return;
|
||||||
|
|
||||||
|
bnumClick(currentPoemId, index);
|
||||||
|
}
|
||||||
|
document.addEventListener('click', verseTextClick);
|
||||||
|
|
||||||
|
|
||||||
function coupletNumImage(bnum, color) {
|
function coupletNumImage(bnum, color) {
|
||||||
let canvas = document.createElement('canvas');
|
let canvas = document.createElement('canvas');
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user