js:clicktoedit

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Prochaine révision
Révision précédente
js:clicktoedit [2020/02/04 14:48] – créée avillepreuxjs:clicktoedit [2023/01/15 18:19] (Version actuelle) avillepreux
Ligne 4: Ligne 4:
 jQuery(document).ready(function() jQuery(document).ready(function()
 {     {    
-//  ALT+Clic pour éditer le texte a l'endroit du curseur +   //  CTRL+ALT+Clic pour éditer le texte a l'endroit du curseur
- +
-    var key_modifier_pressed = false; +
-    jQuery(document).keydown( function(event) { if (event.which == "18") key_modifier_pressed = true;  }); // 18 = ALT +
-    jQuery(document).keyup(   function(event) { if (event.which == "18") key_modifier_pressed = false; });+
  
     if (typeof(click_to_edit) === 'undefined')     if (typeof(click_to_edit) === 'undefined')
Ligne 26: Ligne 22:
             jQuery('[class^="sectionedit"], div[class^="level"]', $dokuWiki).on("click", function (evt)              jQuery('[class^="sectionedit"], div[class^="level"]', $dokuWiki).on("click", function (evt) 
             {             {
-            //  if (evt.detail === 3) // Triple clic +              //if (evt.detail === 3) // Triple clic 
-                if (key_modifier_pressed)+                if (evt.ctrlKey /*&& evt.shiftKey*/ && evt.altKey)
                 {                 {
-                console.log(evt.detail);+                    //console.log(evt.detail);
                                  
-                    // find the closest edit button form to the element double clicked (downwards) and submit the form+                    // find string
                                          
                     s = window.getSelection();                     s = window.getSelection();
Ligne 52: Ligne 48:
                     var str = range.toString().trim();                     var str = range.toString().trim();
                                          
-                    console.log(str);            +                    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)');                     var e = jQuery(this).nextAll('.editbutton_section:eq(0)').children('form:eq(0)');
 +                    console.log("EDIT button", e);
 +                            
                     e.append("<input type='hidden' name='str' value='"+str+"' />");                     e.append("<input type='hidden' name='str' value='"+str+"' />");
                     e.submit();                     e.submit();
  • js/clicktoedit.1580824103.txt.gz
  • Dernière modification : 2020/02/04 14:48
  • de avillepreux