jQuery(document).ready(function() { // CTRL+ALT+Clic pour éditer le texte a l'endroit du curseur if (typeof(click_to_edit) === 'undefined') { click_to_edit = true; $dokuWiki = jQuery('.dokuwiki'); /** * If one or more edit section buttons exist? * This makes sure this feature is enabled only on the edit page and for users with page edit rights. */ if (jQuery('.editbutton_section', $dokuWiki).length > 0) { // register double click event for all headings and section divs jQuery('[class^="sectionedit"], div[class^="level"]', $dokuWiki).on("click", function (evt) { //if (evt.detail === 3) // Triple clic if (evt.ctrlKey /*&& evt.shiftKey*/ && evt.altKey) { //console.log(evt.detail); // find string s = window.getSelection(); var range = s.getRangeAt(0); var node = s.anchorNode; while (range.toString().indexOf(' ') != 0 && range.startOffset > 0) { range.setStart(node, range.startOffset - 1); } range.setStart(node, range.startOffset + 1); do { range.setEnd(node, range.endOffset + 1); } while (range.toString().indexOf(' ') == -1 && range.toString().trim() != '' && range.endOffset < node.length); var str = range.toString().trim(); console.log("EDIT string", str); // find the closest anchor link to the element double clicked (upwards) var a = jQuery(this).prevAll('[class^="level"]:eq(0)'); console.log("EDIT anchor", a); var b = a.prevAll('.anchorjs-link:eq(0)'); console.log("EDIT anchor", b); var c = a.prevAll('*:eq(0)'); console.log("EDIT anchor", c); var d = a.prevAll('h3'); console.log("EDIT anchor", d); // find the closest edit button form to the element double clicked (downwards) and submit the form var e = jQuery(this).nextAll('.editbutton_section:eq(0)').children('form:eq(0)'); console.log("EDIT button", e); e.append(""); e.submit(); } }) } } });