Merge branch 'without-pal'

Conflicts:
	js/h5p-library-list.js
namespaces
Frode Petterson 2014-09-26 12:37:11 +02:00
commit 09bf13ee8f
3 changed files with 29 additions and 12 deletions

View File

@ -1154,7 +1154,7 @@ class H5PStorage {
if ($upgradeOnly) {
// TODO - support translation
$this->h5pF->setInfoMessage($upgradedLibsCount . ' libraries were upgraded!');
$this->h5pF->setInfoMessage($this->h5pF->t('@num libraries were upgraded!', array('@num' => $upgradedLibsCount)));
}
return $library_saved;
@ -1258,7 +1258,9 @@ Class H5PExport {
// Build h5p.json
$h5pJson = array (
'title' => $content['title'],
'language' => $content['language'],
// TODO - stop using 'und', this is not the preferred way.
// Either remove language from the json if not existing, or use "language": null
'language' => isset($content['language']) ? $content['language'] : 'und',
'mainLibrary' => $content['library']['name'],
'embedTypes' => $embedTypes,
);

View File

@ -23,9 +23,9 @@ var H5PLibraryList= H5PLibraryList || {};
* @param {object} libraries List of libraries and headers
*/
H5PLibraryList.createLibraryList = function (libraries) {
var t = H5PIntegration.i18n.H5P;
if(libraries.listData === undefined || libraries.listData.length === 0) {
return;
return $('<div>' + t.NA + '</div>');
}
// Create table
@ -33,14 +33,22 @@ var H5PLibraryList= H5PLibraryList || {};
$table.addClass('libraries');
// Add libraries
var t = H5PIntegration.i18n.H5P;
$.each (libraries.listData, function (index, library) {
var $libraryRow = H5PUtils.createTableRow([
library.title,
'<input class="h5p-admin-restricted" type="checkbox"/>',
library.numContent,
library.numContentDependencies,
library.numLibraryDependencies,
{
text: library.numContent,
class: 'h5p-admin-center'
},
{
text: library.numContentDependencies,
class: 'h5p-admin-center'
},
{
text: library.numLibraryDependencies,
class: 'h5p-admin-center'
},
'<div class="h5p-admin-buttons-wrapper">\
<button class="h5p-admin-upgrade-library"></button>\
<button class="h5p-admin-view-library" title="' + t.viewLibrary + '"></button>\
@ -50,10 +58,11 @@ var H5PLibraryList= H5PLibraryList || {};
H5PLibraryList.addRestricted($('.h5p-admin-restricted', $libraryRow), library.restrictedUrl, library.restricted);
var hasContent = !(library.numContent === '' || library.numContent === 0);
if (library.upgradeUrl === null) {
$('.h5p-admin-upgrade-library', $libraryRow).remove();
}
else if (library.upgradeUrl === false || library.numContent === 0) {
else if (library.upgradeUrl === false || !hasContent) {
$('.h5p-admin-upgrade-library', $libraryRow).attr('disabled', true);
}
else {
@ -68,7 +77,7 @@ var H5PLibraryList= H5PLibraryList || {};
});
var $deleteButton = $('.h5p-admin-delete-library', $libraryRow);
if (libraries.notCached !== undefined || library.numContent !== 0 || (library.numContentDependencies !== '' && library.numContentDependencies !== 0) || (library.numLibraryDependencies !== '' && library.numLibraryDependencies !== 0)) {
if (libraries.notCached !== undefined || hasContent || (library.numContentDependencies !== '' && library.numContentDependencies !== 0) || (library.numLibraryDependencies !== '' && library.numLibraryDependencies !== 0)) {
// Disabled delete if content.
$deleteButton.attr('disabled', true);
}

View File

@ -16,7 +16,7 @@ var H5PUtils = H5PUtils || {};
$.each(headers, function (index, value) {
if (!(value instanceof Object)) {
value = {
text: value
html: value
};
}
@ -38,7 +38,13 @@ var H5PUtils = H5PUtils || {};
var $tr = $('<tr></tr>');
$.each(rows, function (index, value) {
$tr.append('<td>' + value + '</td>');
if (!(value instanceof Object)) {
value = {
html: value
};
}
$('<td/>', value).appendTo($tr);
});
return $tr;