Recent Changes - Search:

Cookbook

PmWiki

pmwiki.org

EditOnDblClick

Summary: Enable edit on double-clicking a page
Version:
Prerequisites:
Status:
Maintainer:
Categories: Editing

Goal

When you double click on a page, go to the edit action.

Solution

Add this line to the <body> declaration of the skin template (In the .tmpl file in the pub\skins\pmwiki folder) you are using :

 ondblclick="if(window.location.href.indexOf('action=edit') < 0){window.location.href = window.location.href + '?action=edit';}"

--Pyros , Floris

practically, the body tag will now look like this :

  <body ondblclick="if(window.location.href.indexOf('action=edit') < 0){window.location.href = window.location.href + '?action=edit';}">

To avoid having people without edit permissions getting irritated by this wonderful little script it can be modified like this:

Put the following in your skin php file, or just the second line in your config file.

global $BodyAttr;
if (CondAuth($pagename, 'edit') == true) $BodyAttr = 'ondblclick="window.location.href=window.location.href + \'?action=edit\'"';

Then, change the body tag to look like this:

<body background="$SkinDirUrl/space.gif" $BodyAttr>

It will ignore the double click unless the user has edit privileges. If someone wants to rewrite this to look more like the one above, go for it, but this works fine for me. Caveman

To avoid editing again (and loose all your modifications) when double-clicking on a word you want to select, while in edition mode, I added a condition on the current action : // if ((CondAuth($pagename, 'edit') == true)&&($_GET['action']!="edit")) $BodyAttr = 'ondblclick="window.location.href=window.location.href + \'?action=edit\'"'; Kaskooy

Discussion

  • The code listed here caused my XHTML to no longer validate due to the "<" character. Rectified by encapsulating the javascript code into a function.
  • Personally, entering into edit mode upon a doubleclick feels a bit counter-intuitive, and certainly not always desirable. I do have another suggestion, however. Would it not be possible to have the doubleclick lead to some kind of "lookup" action? The reader reads a word he doesn't understand, he doubleclicks it, and bingo, there's the appropriate page of the Wikipedia or the Wictionary... Does anyone think this is possible??? (posted by Ludo - somehow, my name in the Author box on top didn't register).
    Using the opera browser will give you this. Select a word and with the right mousebutton menu you get the choices "Dictionary" and "Encyclopedia". -- jroeterd
    Konqueror, Firefox have something similar... Select the word, right click and choose "Search the web for (term)" --floris
  • I just did the same thing for "login" for AuthUser. Since I am using PmWiki as a CMS for a public site, I did not want the login link to be too obvious. So, but putting the double click on the page footer DIV, I was able to achieve a login link that's not readily apparent to the user. BenWilson January 11, 2006, at 10:52 AM

Wikiwyg.net

I came across the wikiwyg.net and has a very impressive feature for edit. Isn't it similar to the EditOnDoubleClick recipe, but a better one? Has anyone tried to integrate the wikiwyg.net to the pmwiki? Sichendra, March 06, 2006

__A VERY NICE FEATURE, YES!__ It shouldn't be hard to implement. Maybe I'll do it... KMcC

Maybe you could use SectionEdit - Split a wiki page into separately editable sections with an edit link for each section - to implement this

file://///fdeveraxp/dropbox

Edit - History - Print - Recent Changes - Search
Page last modified on August 29, 2007, at 04:53 PM