Fix issues with old content

pull/20/merge
Frode Petterson 2017-06-20 10:58:13 +02:00
parent 2ac7ca6721
commit 8289ff5f8c
3 changed files with 6 additions and 5 deletions

View File

@ -89,7 +89,7 @@
self.appendTo = function ($container) {
// TODO: Translate alt attr
$card = $('<li class="h5p-memory-wrap"><div class="h5p-memory-card" role="button" tabindex="1">' +
'<div class="h5p-front"' + (styles && styles.front ? styles.front : '') + '>' + (styles.backImage ? '' : '<span></span>') + '</div>' +
'<div class="h5p-front"' + (styles && styles.front ? styles.front : '') + '>' + (styles && styles.backImage ? '' : '<span></span>') + '</div>' +
'<div class="h5p-back"' + (styles && styles.back ? styles.back : '') + '>' +
'<img src="' + path + '" alt="Memory Card" style="width:' + width + ';height:' + height + '"/>' +
'</div>' +

View File

@ -71,7 +71,7 @@ H5P.MemoryGame = (function (EventDispatcher, $) {
if (card.hasTwoImages) {
imgs.push(mate.getImage());
}
popup.show(desc, imgs, cardStyles.back, function () {
popup.show(desc, imgs, cardStyles ? cardStyles.back : undefined, function () {
if (isFinished) {
// Game done
finished();
@ -319,7 +319,7 @@ H5P.MemoryGame = (function (EventDispatcher, $) {
timer = new MemoryGame.Timer($status.find('.h5p-time-spent')[0]);
counter = new MemoryGame.Counter($status.find('.h5p-card-turns'));
popup = new MemoryGame.Popup($container, cardStyles.popup);
popup = new MemoryGame.Popup($container, cardStyles ? cardStyles.popup : undefined);
$container.click(function () {
popup.close();

View File

@ -5,6 +5,7 @@
*
* @class H5P.MemoryGame.Popup
* @param {H5P.jQuery} $container
* @param {string} [styles]
*/
MemoryGame.Popup = function ($container, styles) {
/** @alias H5P.MemoryGame.Popup# */
@ -12,7 +13,7 @@
var closed;
var $popup = $('<div class="h5p-memory-pop"><div class="h5p-memory-top"' + styles + '></div><div class="h5p-memory-desc"></div></div>').appendTo($container);
var $popup = $('<div class="h5p-memory-pop"><div class="h5p-memory-top"' + (styles ? styles : '') + '></div><div class="h5p-memory-desc"></div></div>').appendTo($container);
var $desc = $popup.find('.h5p-memory-desc');
var $top = $popup.find('.h5p-memory-top');
@ -27,7 +28,7 @@
$desc.html(desc);
$top.html('').toggleClass('h5p-memory-two-images', imgs.length > 1);
for (var i = 0; i < imgs.length; i++) {
$('<div class="h5p-memory-image"' + styles + '></div>').append(imgs[i]).appendTo($top);
$('<div class="h5p-memory-image"' + (styles ? styles : '') + '></div>').append(imgs[i]).appendTo($top);
}
$popup.show();
closed = done;