Redmine Submit Guard

目前為 2015-11-06 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name Redmine Submit Guard
// @description:en Avoid submit by enter.
// @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/*
// ==/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;
    });
})();