From 4a9e6d620f0285aae659752ebe0d0c1501c13bf1 Mon Sep 17 00:00:00 2001 From: Frode Petterson Date: Fri, 22 Aug 2014 12:00:06 +0200 Subject: [PATCH] Made sure only content libraries can be upgraded. --- js/h5p-library-list.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/js/h5p-library-list.js b/js/h5p-library-list.js index a238d39..cfadf0d 100644 --- a/js/h5p-library-list.js +++ b/js/h5p-library-list.js @@ -47,14 +47,17 @@ var H5PLibraryList= H5PLibraryList || {}; ' ]); - if (library.upgradeUrl !== null && library.numContent !== 0) { + if (library.upgradeUrl === null) { + $('.h5p-admin-upgrade-library', $libraryRow).remove(); + } + else if (library.upgradeUrl === false || library.numContent === 0) { + $('.h5p-admin-upgrade-library', $libraryRow).attr('disabled', true); + } + else { $('.h5p-admin-upgrade-library', $libraryRow).attr('title', t.upgradeLibrary).click(function () { window.location.href = library.upgradeUrl; }); } - else { - $('.h5p-admin-upgrade-library', $libraryRow).attr('disabled', true); - } // Open details view when clicked $('.h5p-admin-view-library', $libraryRow).on('click', function () { @@ -64,11 +67,11 @@ var H5PLibraryList= H5PLibraryList || {}; var $deleteButton = $('.h5p-admin-delete-library', $libraryRow); if (library.numContent !== 0 || library.numContentDependencies !== 0 || library.numLibraryDependencies !== 0) { // Disabled delete if content. - $deleteButton.attr('disabled', true).attr('title', t.deleteLibrary); + $deleteButton.attr('disabled', true); } else { // Go to delete page om click. - $deleteButton.on('click', function () { + $deleteButton.attr('title', t.deleteLibrary).on('click', function () { window.location.href = library.deleteUrl; }); }