DokuWiki

It's better when it's simple

User Tools

Site Tools


tips:double-click-to-edit

Double Click to Open a Section Edit (improved)

The JavaScript snippet below adds the ability to double-click a section of an article to go straight to the edit mode for that section.

It is easy to add it. Just create a userscript.js file under your conf directory (i.e. ./conf/userscript.js) and append the following code snippet to it:

conf/userscript.js
jQuery(document).ready(function(){
 
    $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).dblclick(function(){
            // find the closest edit button form to the element double clicked (downwards) and submit the form
            jQuery(this).nextAll('.editbutton_section:eq(0)').children('form:eq(0)').submit();
        })
    }
 
});

Remember to purge the JavaScript cache, e.g. by calling

http://example.com/lib/exe/js.php?purge=true

and clean up your browser's cache as well.

Tested on:

  • Release 2022-07-31a “Igor”
  • Release 2015-08-10a “Detritus”

The functionality of the code has been commented inline. Submit any improvements and fixes you may have.

Note: Section editing is now a core feature in DokuWiki. The configuration setting maxseclevel controls the max level of displayed section edit buttons. However, there is a conflict of the above code with the Section Edit Plugin, so make sure, it is deactivated, if you want to use this code.

For queries, contact the author on http://twitter.com/daysonhi

tips/double-click-to-edit.txt · Last modified: 2023-01-26 09:38 by 212.201.117.6

Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Share Alike 4.0 International
CC Attribution-Share Alike 4.0 International Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki