1/**
2 * DblClickEdit Plugin - enter edit mode with double click
3 *
4 * @license  GPL2 (http://www.gnu.org/licenses/gpl.html)
5 * @author   H�kan Sandell <sandell.hakan@gmail.com>
6 */
7
8jQuery(function () {
9
10    if (JSINFO.dblclick == 2) {
11        /**
12         *  Register double click event for all headings (h*.sectionedit)
13         *  and sections (div.level*) following a sectionedit header
14         *  Beware of div.levels before the first edit section
15         */
16        jQuery('[class*="sectionedit"], [class*="sectionedit"] ~ div[class^="level"]').dblclick(function(e){
17
18            /**
19             * Find the closest edit button form to the element double clicked (downwards) and submit the form
20             * look for div.secedit to support custom section editors like plugin:edittable and plugin:data
21             * stop event propagation to allow for full page edit
22             */
23            jQuery(this).nextAll('.secedit:eq(0)').children('form:eq(0)').submit();
24            e.stopPropagation();
25        });
26    }
27
28    /**
29     *  Find page content div and attach default page edit handler
30     *  templates supported
31     *      starter based:      div.page                a.action.edit
32     *      old default:        div.page                form.btn_edit
33     *      monobook/vector:    div#bodyContent         #ca-edit > a
34     *      sidebar:            div.page_with_sidebar   form.btn_edit
35     *      arctic:             div.right_page          a.action.edit
36     */
37    if (JSINFO.dblclick) {
38        $pageDiv = jQuery('div.page, div.page_with_sidebar, div.right_page, div#bodyContent');
39        $editLink = jQuery('a.action.edit, #ca-edit > a');
40        $editBtn = jQuery('form.btn_edit');
41
42        if ($pageDiv[0]) {
43            $pageDiv.dblclick(function() {
44                if ($editBtn[0]) {
45                    $editBtn[0].submit();
46                } else {
47                    window.location = $editLink.attr('href');
48                }
49            });
50        }
51
52    }
53});
54
55