Skip to content

Commit

Permalink
Merge pull request #1261 from OPUS4/bug1258
Browse files Browse the repository at this point in the history
#1258 Limit ENTER handling to forms publish and metadata
  • Loading branch information
j3nsch authored Dec 4, 2024
2 parents 20059f2 + 3bfc32a commit 35a87f5
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 9 deletions.
1 change: 1 addition & 0 deletions modules/admin/controllers/DocumentController.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function init()
{
parent::init();
$this->documentsHelper = $this->_helper->getHelper('Documents');
$this->view->headScript()->prependFile($this->view->layoutPath() . '/js/form-enter.js');
}

/**
Expand Down
1 change: 1 addition & 0 deletions modules/publish/controllers/FormController.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function init()
{
$this->session = new Zend_Session_Namespace('Publish');
parent::init();
$this->view->headScript()->prependFile($this->view->layoutPath() . '/js/form-enter.js');
}

/**
Expand Down
41 changes: 41 additions & 0 deletions public/layouts/opus4/js/form-enter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* This file is part of OPUS. The software OPUS has been originally developed
* at the University of Stuttgart with funding from the German Research Net,
* the Federal Department of Higher Education and Research and the Ministry
* of Science, Research and the Arts of the State of Baden-Wuerttemberg.
*
* OPUS 4 is a complete rewrite of the original OPUS software and was developed
* by the Stuttgart University Library, the Library Service Center
* Baden-Wuerttemberg, the Cooperative Library Network Berlin-Brandenburg,
* the Saarland University and State Library, the Saxon State Library -
* Dresden State and University Library, the Bielefeld University Library and
* the University Library of Hamburg University of Technology with funding from
* the German Research Foundation and the European Regional Development Fund.
*
* LICENCE
* OPUS 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 2 of the Licence, or any later version.
* OPUS 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 OPUS; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
* @copyright Copyright (c) 2024, OPUS 4 development team
* @license http://www.gnu.org/licenses/gpl.html General Public License
*/

$(function () {

// Prevent submission of form when Enter/Return is pressed in a simple text input
$('form').on('keydown', e => {
if (e.key === 'Enter') {
if ($(e.target).is("input[type='text']")) {
e.preventDefault();
}
}
});

});
9 changes: 0 additions & 9 deletions public/layouts/opus4/js/submit.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,4 @@ $(function () {
});
});

// Prevent submission of form when Enter/Return is pressed in a simple text input
$('form').on('keydown', e => {
if (e.key === 'Enter') {
if ($(e.target).is("input[type='text']")) {
e.preventDefault();
}
}
});

});

0 comments on commit 35a87f5

Please sign in to comment.