From a2a6357fd5acd2d3cd647601dad08dc08341ad93 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Sun, 19 May 2013 11:19:57 +0300 Subject: [PATCH 1/2] [ticket/11556] Remove fallback JS PHPBB3-11556 --- phpBB/styles/prosilver/template/forum_fn.js | 49 +++++++-------------- 1 file changed, 15 insertions(+), 34 deletions(-) diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 23450d910b..781c2ed31f 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -364,41 +364,22 @@ function submit_default_button(event, selector, class_name) { * The non-jQuery code is a mimick of the jQuery code ;) */ function apply_onkeypress_event() { - // jQuery code in case jQuery is used - if (jquery_present) { - jQuery('form input[type=text], form input[type=password]').live('keypress', function (e) { - var default_button = jQuery(this).parents('form').find('input[type=submit].default-submit-action'); - - if (!default_button || default_button.length <= 0) { - return true; - } - - if (phpbb_check_key(e)) { - return true; - } - - if ((e.which && e.which === 13) || (e.keyCode && e.keyCode === 13)) { - default_button.click(); - return false; - } + jQuery('form input[type=text], form input[type=password]').live('keypress', function (e) { + var default_button = jQuery(this).parents('form').find('input[type=submit].default-submit-action'); + if (!default_button || default_button.length <= 0) { return true; - }); - - return; - } - - var input_tags = document.getElementsByTagName('input'); - - for (var i = 0, element = input_tags[0]; i < input_tags.length ; element = input_tags[++i]) { - if (element.type === 'text' || element.type === 'password') { - // onkeydown is possible too - element.onkeypress = function (evt) { submit_default_button((evt || window.event), this, 'default-submit-action'); }; } - } -} -/** -* Detect JQuery existance. We currently do not deliver it, but some styles do, so why not benefit from it. ;) -*/ -var jquery_present = typeof jQuery === 'function'; + if (phpbb_check_key(e)) { + return true; + } + + if ((e.which && e.which === 13) || (e.keyCode && e.keyCode === 13)) { + default_button.click(); + return false; + } + + return true; + }); +} From c29257f732ce23346e3f85d9a7ee99bff728ca84 Mon Sep 17 00:00:00 2001 From: Vjacheslav Trushkin Date: Mon, 20 May 2013 10:04:03 +0300 Subject: [PATCH 2/2] [ticket/11556] Load apply_onkeypress_event() correctly PHPBB3-11556 --- phpBB/styles/prosilver/template/forum_fn.js | 2 ++ phpBB/styles/prosilver/template/posting_editor.html | 6 ------ phpBB/styles/prosilver/template/ucp_register.html | 5 ----- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/phpBB/styles/prosilver/template/forum_fn.js b/phpBB/styles/prosilver/template/forum_fn.js index 781c2ed31f..ac8861d4a8 100644 --- a/phpBB/styles/prosilver/template/forum_fn.js +++ b/phpBB/styles/prosilver/template/forum_fn.js @@ -383,3 +383,5 @@ function apply_onkeypress_event() { return true; }); } + +jQuery(document).ready(apply_onkeypress_event); diff --git a/phpBB/styles/prosilver/template/posting_editor.html b/phpBB/styles/prosilver/template/posting_editor.html index 8156968098..83dc6111dd 100644 --- a/phpBB/styles/prosilver/template/posting_editor.html +++ b/phpBB/styles/prosilver/template/posting_editor.html @@ -1,9 +1,3 @@ - -

{ERROR}

diff --git a/phpBB/styles/prosilver/template/ucp_register.html b/phpBB/styles/prosilver/template/ucp_register.html index db95e5ba13..779c1fc2a3 100644 --- a/phpBB/styles/prosilver/template/ucp_register.html +++ b/phpBB/styles/prosilver/template/ucp_register.html @@ -10,11 +10,6 @@ document.forms['register'].change_lang.value = lang_iso; document.forms['register'].submit.click(); } - - - onload_functions.push(apply_onkeypress_event); - - // ]]>