From acaccea977f1331f5ca0324f8c93ed45423fea36 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 3 May 2016 12:47:16 +0200 Subject: [PATCH 1/6] Allow pagination widget to handle empty pages --- js/h5p-data-view.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/js/h5p-data-view.js b/js/h5p-data-view.js index 860625f..0edfc56 100644 --- a/js/h5p-data-view.js +++ b/js/h5p-data-view.js @@ -108,11 +108,11 @@ var H5PDataView = (function ($) { else { // Update table data self.updateTable(data.rows); - - // Update pagination widget - self.updatePagination(data.num); } + // Update pagination widget + self.updatePagination(data.num); + if (self.loaded !== undefined) { self.loaded(); } @@ -255,7 +255,6 @@ var H5PDataView = (function ($) { var remove = function () { self.facets[col].$tag.remove(); delete self.facets[col]; - self.offset = 0; // Reset to page 1 self.loadData(); }; @@ -276,9 +275,6 @@ var H5PDataView = (function ($) { } }); - // Reset to page 1 - self.offset = 0; - // Load data with new filter self.loadData(); }; From cc121b2f5345db6ba7e5510a84361b128747efb8 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Thu, 12 May 2016 15:52:37 +0200 Subject: [PATCH 2/6] Bugfix: Must be able to run from CLI --- h5p.classes.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/h5p.classes.php b/h5p.classes.php index 93c4213..7f87f7c 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -2469,7 +2469,9 @@ class H5PCore { // Determine remote/visitor origin if ($type === 'network' || - ($type === 'local' && !preg_match('/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$/i', $_SERVER['REMOTE_ADDR']))) { + ($type === 'local' && + isset($_SERVER['REMOTE_ADDR']) && + !preg_match('/^localhost$|^127(?:\.[0-9]+){0,2}\.[0-9]+$|^(?:0*\:)*?:?0*1$/i', $_SERVER['REMOTE_ADDR']))) { if (isset($_SERVER['REMOTE_ADDR']) && filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE)) { // Internet $this->h5pF->setOption('site_type', 'internet'); From c2f5feaae5ae8450baa7b451801319786473cc6e Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Tue, 31 May 2016 10:51:59 +0200 Subject: [PATCH 3/6] Improved error message for req core version HFJ-1959 --- h5p.classes.php | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/h5p.classes.php b/h5p.classes.php index 93c4213..5e19639 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -1055,24 +1055,27 @@ class H5PValidator { $valid = $this->isValidRequiredH5pData($h5pData, $required, $library_name); $valid = $this->isValidOptionalH5pData($h5pData, $optional, $library_name) && $valid; - // Test library core version requirement. If no requirement is set, - // this implicitly means 1.0, which shall work on newer versions - // too. + // Check the library's required API version of Core. + // If no requirement is set this implicitly means 1.0. if (isset($h5pData['coreApi']) && !empty($h5pData['coreApi'])) { if (($h5pData['coreApi']['majorVersion'] > H5PCore::$coreApi['majorVersion']) || - (($h5pData['coreApi']['majorVersion'] == H5PCore::$coreApi['majorVersion']) && - ($h5pData['coreApi']['minorVersion'] > H5PCore::$coreApi['minorVersion']))) - { + ( ($h5pData['coreApi']['majorVersion'] == H5PCore::$coreApi['majorVersion']) && + ($h5pData['coreApi']['minorVersion'] > H5PCore::$coreApi['minorVersion']) )) { + $this->h5pF->setErrorMessage( - $this->h5pF->t('The library "%libraryName" requires H5P %requiredVersion, but only H5P %coreApi is installed.', - array( - '%libraryName' => $library_name, - '%requiredVersion' => $h5pData['coreApi']['majorVersion'] . '.' . $h5pData['coreApi']['minorVersion'], - '%coreApi' => H5PCore::$coreApi['majorVersion'] . '.' . H5PCore::$coreApi['minorVersion'] - ))); + $this->h5pF->t('The system was unable to install the %component component from the package, it requires a newer version of the H5P plugin. This site is currently running version %current, whereas the required version is %required or higher. You should consider upgrading and then try again.', + array( + '%component' => (isset($h5pData['title']) ? $h5pData['title'] : $library_name), + '%current' => H5PCore::$coreApi['majorVersion'] . '.' . H5PCore::$coreApi['minorVersion'], + '%required' => $h5pData['coreApi']['majorVersion'] . '.' . $h5pData['coreApi']['minorVersion'] + ) + ) + ); + $valid = false; } } + return $valid; } From eba774c86389f808c2d6ec54fa3179bb85b6328d Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Tue, 31 May 2016 10:19:07 +0200 Subject: [PATCH 4/6] Prevent DOM pollution when having many confirmation dialogs. Append confirmation dialog on show and detach it on hide. HFJ-1969 (cherry picked from commit 0a63d12) --- js/h5p-confirmation-dialog.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/h5p-confirmation-dialog.js b/js/h5p-confirmation-dialog.js index a8d4ac2..84c8827 100644 --- a/js/h5p-confirmation-dialog.js +++ b/js/h5p-confirmation-dialog.js @@ -141,14 +141,12 @@ H5P.ConfirmationDialog = (function (EventDispatcher) { var wrapperElement; /** - * Append confirmation dialog + * Set parent of confirmation dialog * @param {HTMLElement} wrapper * @returns {H5P.ConfirmationDialog} */ this.appendTo = function (wrapper) { - wrapper.appendChild(popupBackground); wrapperElement = wrapper; - return this; }; @@ -182,6 +180,7 @@ H5P.ConfirmationDialog = (function (EventDispatcher) { * @returns {H5P.ConfirmationDialog} */ this.show = function (offsetTop) { + wrapperElement.appendChild(popupBackground); popupBackground.classList.remove('hidden'); fitToContainer(offsetTop); setTimeout(function () { @@ -215,6 +214,7 @@ H5P.ConfirmationDialog = (function (EventDispatcher) { popup.classList.add('hidden'); setTimeout(function () { popupBackground.classList.add('hidden'); + wrapperElement.removeChild(popupBackground); }, 100); return this; From ed13203254d162036e05e83d540cfaa9347b78d1 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Mon, 23 May 2016 14:34:56 +0200 Subject: [PATCH 5/6] Use buttons instead of anchors in Confirmation Dialog. HFJ-1930 (cherry picked from commit 27bc158) --- js/h5p-confirmation-dialog.js | 71 ++++++++++++------------------ styles/h5p-confirmation-dialog.css | 10 ++--- styles/h5p-core-button.css | 25 ++++++----- 3 files changed, 47 insertions(+), 59 deletions(-) diff --git a/js/h5p-confirmation-dialog.js b/js/h5p-confirmation-dialog.js index 84c8827..c948192 100644 --- a/js/h5p-confirmation-dialog.js +++ b/js/h5p-confirmation-dialog.js @@ -24,6 +24,26 @@ H5P.ConfirmationDialog = (function (EventDispatcher) { options.cancelText = options.cancelText || H5P.t('cancelLabel'); options.confirmText = options.confirmText || H5P.t('confirmLabel'); + /** + * Handle confirming event + * @param {Event} e + */ + function dialogConfirmed(e) { + self.hide(); + self.trigger('confirmed'); + e.preventDefault(); + } + + /** + * Handle dialog canceled + * @param {Event} e + */ + function dialogCanceled(e) { + self.hide(); + self.trigger('canceled'); + e.preventDefault(); + } + // Offset of exit button var exitButtonOffset = 2 * 16; var shadowOffset = 8; @@ -69,70 +89,37 @@ H5P.ConfirmationDialog = (function (EventDispatcher) { body.appendChild(buttons); // Cancel button - var cancelButton = document.createElement('a'); + var cancelButton = document.createElement('button'); cancelButton.classList.add('h5p-core-cancel-button'); - cancelButton.href = '#'; cancelButton.textContent = options.cancelText; - cancelButton.onclick = function (e) { - self.hide(); - self.trigger('canceled'); - e.preventDefault(); - }; + cancelButton.onclick = dialogCanceled; cancelButton.onkeydown = function (e) { if (e.which === 32) { // Space - // Prevent jumping - e.preventDefault(); - } - else if (e.which === 13) { // Enter - self.hide(); - self.trigger('canceled'); - e.preventDefault(); + dialogCanceled(e); } }; buttons.appendChild(cancelButton); // Confirm button - var confirmButton = document.createElement('a'); + var confirmButton = document.createElement('button'); confirmButton.classList.add('h5p-core-button', 'h5p-confirmation-dialog-confirm-button'); - confirmButton.href = '#'; confirmButton.textContent = options.confirmText; - confirmButton.onclick = function (e) { - self.hide(); - self.trigger('confirmed'); - e.preventDefault(); - }; + confirmButton.onclick = dialogConfirmed; confirmButton.onkeydown = function (e) { if (e.which === 32) { // Space - // Prevent jumping - e.preventDefault(); - } - else if (e.which === 13) { // Enter - self.hide(); - self.trigger('confirmed'); - e.preventDefault(); + dialogConfirmed(e); } }; buttons.appendChild(confirmButton); // Exit button - var exitButton = document.createElement('a'); - exitButton.href = '#'; + var exitButton = document.createElement('button'); exitButton.classList.add('h5p-confirmation-dialog-exit'); - exitButton.onclick = function (e) { - self.hide(); - self.trigger('canceled'); - e.preventDefault(); - }; + exitButton.onclick = dialogCanceled; exitButton.onkeydown = function (e) { if (e.which === 32) { // Space - // Prevent jumping - e.preventDefault(); - } - else if (e.which === 13) { // Enter - self.hide(); - self.trigger('canceled'); - e.preventDefault(); + dialogCanceled(e); } }; popup.appendChild(exitButton); diff --git a/styles/h5p-confirmation-dialog.css b/styles/h5p-confirmation-dialog.css index 093a6ad..2923b17 100644 --- a/styles/h5p-confirmation-dialog.css +++ b/styles/h5p-confirmation-dialog.css @@ -81,9 +81,9 @@ float: right; } -a.h5p-confirmation-dialog-exit:visited, -a.h5p-confirmation-dialog-exit:link, -a.h5p-confirmation-dialog-exit { +button.h5p-confirmation-dialog-exit:visited, +button.h5p-confirmation-dialog-exit:link, +button.h5p-confirmation-dialog-exit { position: absolute; background: none; border: none; @@ -95,8 +95,8 @@ a.h5p-confirmation-dialog-exit { text-decoration: none; } -a.h5p-confirmation-dialog-exit:focus, -a.h5p-confirmation-dialog-exit:hover { +button.h5p-confirmation-dialog-exit:focus, +button.h5p-confirmation-dialog-exit:hover { color: #555; } diff --git a/styles/h5p-core-button.css b/styles/h5p-core-button.css index b05c423..04f33a3 100644 --- a/styles/h5p-core-button.css +++ b/styles/h5p-core-button.css @@ -1,6 +1,6 @@ -a.h5p-core-button:visited, -a.h5p-core-button:link, -a.h5p-core-button { +button.h5p-core-button:visited, +button.h5p-core-button:link, +button.h5p-core-button { font-size: 1em; line-height: 1.2; padding: 0.5em 1.25em; @@ -20,15 +20,15 @@ a.h5p-core-button { vertical-align: baseline; text-decoration: none; } -a.h5p-core-button:hover, -a.h5p-core-button:focus { +button.h5p-core-button:hover, +button.h5p-core-button:focus { background: #1356a3; color: #fff; text-decoration: none; -webkit-transition: initial; transition: initial; } -a.h5p-core-button:active { +button.h5p-core-button:active { position: relative; background: #104888; @@ -37,7 +37,7 @@ a.h5p-core-button:active { box-shadow: inset 0 4px 0 #0e407a; } -a.h5p-core-button:before { +button.h5p-core-button:before { font-family: 'H5P'; padding-right: 0.15em; font-size: 1.5em; @@ -45,9 +45,10 @@ a.h5p-core-button:before { line-height: 0.7; } -a.h5p-core-cancel-button:visited, -a.h5p-core-cancel-button:link, -a.h5p-core-cancel-button { +button.h5p-core-cancel-button:visited, +button.h5p-core-cancel-button:link, +button.h5p-core-cancel-button { + border: none; background: none; color: #a00; margin-right: 1em; @@ -55,8 +56,8 @@ a.h5p-core-cancel-button { text-decoration: none; } -a.h5p-core-cancel-button:hover, -a.h5p-core-cancel-button:focus { +button.h5p-core-cancel-button:hover, +button.h5p-core-cancel-button:focus { background: none; border: none; color: #e40000; From f6ce5dff74ae5ebf19e72fb0868a599e446b3205 Mon Sep 17 00:00:00 2001 From: Thomas Marstrander Date: Tue, 24 May 2016 11:18:42 +0200 Subject: [PATCH 6/6] Added pointer cursor for core cancel button. HFJ-1930 (cherry picked from commit c6b3b06) --- styles/h5p-core-button.css | 1 + 1 file changed, 1 insertion(+) diff --git a/styles/h5p-core-button.css b/styles/h5p-core-button.css index 04f33a3..3ba392e 100644 --- a/styles/h5p-core-button.css +++ b/styles/h5p-core-button.css @@ -54,6 +54,7 @@ button.h5p-core-cancel-button { margin-right: 1em; font-size: 1em; text-decoration: none; + cursor: pointer; } button.h5p-core-cancel-button:hover,