Skip to content

Commit

Permalink
Support mods; disable submit on enter in edit summary text fields
Browse files Browse the repository at this point in the history
Addresses kynikos#206
  • Loading branch information
kynikos committed Jul 11, 2015
1 parent 2018437 commit a0d84a3
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
6 changes: 6 additions & 0 deletions auxiliary/WikiMonkey-local.user.js
Expand Up @@ -35,6 +35,7 @@
// @require file:///mnt/archive/Development/wiki-monkey/modules/Interlanguage.js
// @require file:///mnt/archive/Development/wiki-monkey/modules/Log.js
// @require file:///mnt/archive/Development/wiki-monkey/modules/Menu.js
// @require file:///mnt/archive/Development/wiki-monkey/modules/Mods.js
// @require file:///mnt/archive/Development/wiki-monkey/modules/MW.js
// @require file:///mnt/archive/Development/wiki-monkey/modules/Parser.js
// @require file:///mnt/archive/Development/wiki-monkey/modules/Tables.js
Expand Down Expand Up @@ -648,5 +649,10 @@ WM.main({
]
]
}
},
'Mods': {
'Editor': {
'disable_edit_summary_submit_on_enter': true
}
}
});
8 changes: 8 additions & 0 deletions auxiliary/release.py
Expand Up @@ -487,6 +487,12 @@
"Wikipedia": {},
}

CONFIG_MODS = {
"Editor": {
'disable_edit_summary_submit_on_enter': True,
},
}

DISABLE_EDITOR = {
"Editor": ("040SL", "060EC", "070ML", "110SR", "210ES"),
}
Expand Down Expand Up @@ -659,6 +665,7 @@
"Interlanguage",
"Log",
"Menu",
"Mods",
"MW",
"Parser",
"Tables",
Expand Down Expand Up @@ -865,6 +872,7 @@ def compose_config(wiki, browser, conf_name, disables):

conf = {
"Plugins": conf_plugins,
"Mods": CONFIG_MODS,
}
cfg = json.dumps(conf, indent=4, sort_keys=True)

Expand Down
4 changes: 4 additions & 0 deletions modules/Cfg.js
Expand Up @@ -200,6 +200,10 @@ WM.Cfg = new function () {
return config["Plugins"]["NewPages"];
};

this._getEditorMods = function() {
return config["Mods"]["Editor"];
};

var save = function() {
localStorage.setItem("WikiMonkey", JSON.stringify(config));
};
Expand Down
39 changes: 39 additions & 0 deletions modules/Mods.js
@@ -0,0 +1,39 @@
/*
* Wiki Monkey - MediaWiki bot and editor assistant that runs in the browser
* Copyright (C) 2011-2014 Dario Giovannetti <dev@dariogiovannetti.net>
*
* This file is part of Wiki Monkey.
*
* Wiki Monkey is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Wiki Monkey is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Wiki Monkey. If not, see <http://www.gnu.org/licenses/>.
*/

WM.Mods = new function () {
"use strict";

var disableEditSummarySubmitOnEnter = function () {
$('#wpSummary').keydown(function(event) {
if (event.keyCode == 13) {
event.preventDefault();
return false;
}
});
};

this.applyEditorMods = function() {
var conf = WM.Cfg._getEditorMods();
if (conf['disable_edit_summary_submit_on_enter']) {
disableEditSummarySubmitOnEnter();
}
};
};
1 change: 1 addition & 0 deletions modules/UI.js
Expand Up @@ -31,6 +31,7 @@ WM.UI = new function () {
).parentNode.nextSibling;
var conf = WM.Cfg._getEditorPlugins();
UI = (conf) ? WM.Menu._makeUI(conf) : null;
WM.Mods.applyEditorMods();
}
else if (document.getElementById('mw-diff-otitle1')) {
nextNode = document.getElementById('bodyContent'
Expand Down

0 comments on commit a0d84a3

Please sign in to comment.