Redmine Submit Guard

Avoid submit by enter key.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name Redmine Submit Guard
// @description:en Avoid submit by enter key.
// @version 0.1
// @namespace http://twitter.com/foldrr/
// @require   http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
// @match     http://*/redmine/projects/*/issues/new
// @match     http://*/redmine/issues/*
// @description Avoid submit by enter key.
// ==/UserScript==

(function(){
    $('input').keypress(function(ev){
        if(ev.keyCode === 10 || ev.keyCode === 13){
            if(Event.element(ev).id == 'q') return true;
            if($('#issue_subject').val().trim()     === ''){ $('#issue_subject').focus();     return false; }
            if($('#issue_description').val().trim() === ''){ $('#issue_description').focus(); return false; }
            return false;
        }
        return true;
    });
})();