Moved deletion of content user data to after dialog is closed [HFJ-1989]
parent
7807b8af68
commit
f4cee6e284
18
js/h5p.js
18
js/h5p.js
|
@ -103,7 +103,6 @@ H5P.init = function (target) {
|
||||||
var $container = H5P.jQuery('<div class="h5p-container"></div>').appendTo($element);
|
var $container = H5P.jQuery('<div class="h5p-container"></div>').appendTo($element);
|
||||||
var contentId = $element.data('content-id');
|
var contentId = $element.data('content-id');
|
||||||
var contentData = H5PIntegration.contents['cid-' + contentId];
|
var contentData = H5PIntegration.contents['cid-' + contentId];
|
||||||
var resetUserState = false;
|
|
||||||
if (contentData === undefined) {
|
if (contentData === undefined) {
|
||||||
return H5P.error('No data for content id ' + contentId + '. Perhaps the library is gone?');
|
return H5P.error('No data for content id ' + contentId + '. Perhaps the library is gone?');
|
||||||
}
|
}
|
||||||
|
@ -119,18 +118,19 @@ H5P.init = function (target) {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else if (previousState === null && H5PIntegration.saveFreq) {
|
else if (previousState === null && H5PIntegration.saveFreq) {
|
||||||
resetUserState = true;
|
|
||||||
// Content has been reset. Display dialog.
|
// Content has been reset. Display dialog.
|
||||||
delete contentData.contentUserData;
|
delete contentData.contentUserData;
|
||||||
var dialog = new H5P.Dialog('content-user-data-reset', 'Data Reset', '<p>' + H5P.t('contentChanged') + '</p><p>' + H5P.t('startingOver') + '</p><div class="h5p-dialog-ok-button" tabIndex="0" role="button">OK</div>', $container);
|
var dialog = new H5P.Dialog('content-user-data-reset', 'Data Reset', '<p>' + H5P.t('contentChanged') + '</p><p>' + H5P.t('startingOver') + '</p><div class="h5p-dialog-ok-button" tabIndex="0" role="button">OK</div>', $container);
|
||||||
H5P.jQuery(dialog).on('dialog-opened', function (event, $dialog) {
|
H5P.jQuery(dialog).on('dialog-opened', function (event, $dialog) {
|
||||||
$dialog.find('.h5p-dialog-ok-button').click(function () {
|
|
||||||
dialog.close();
|
var closeDialog = function (event) {
|
||||||
}).keypress(function (event) {
|
if (event.type === 'click' || event.which === 32) {
|
||||||
if (event.which === 32) {
|
|
||||||
dialog.close();
|
dialog.close();
|
||||||
|
H5P.deleteUserData(contentId, 'state', 0);
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
$dialog.find('.h5p-dialog-ok-button').click(closeDialog).keypress(closeDialog);
|
||||||
});
|
});
|
||||||
dialog.open();
|
dialog.open();
|
||||||
}
|
}
|
||||||
|
@ -139,10 +139,6 @@ H5P.init = function (target) {
|
||||||
// Create new instance.
|
// Create new instance.
|
||||||
var instance = H5P.newRunnable(library, contentId, $container, true, {standalone: true});
|
var instance = H5P.newRunnable(library, contentId, $container, true, {standalone: true});
|
||||||
|
|
||||||
if (resetUserState) {
|
|
||||||
H5P.deleteUserData(contentId, 'state', instance.subContentId);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we should add and display a fullscreen button for this H5P.
|
// Check if we should add and display a fullscreen button for this H5P.
|
||||||
if (contentData.fullScreen == 1 && H5P.canHasFullScreen) {
|
if (contentData.fullScreen == 1 && H5P.canHasFullScreen) {
|
||||||
H5P.jQuery('<div class="h5p-content-controls"><div role="button" tabindex="0" class="h5p-enable-fullscreen" title="' + H5P.t('fullscreen') + '"></div></div>').prependTo($container).children().click(function () {
|
H5P.jQuery('<div class="h5p-content-controls"><div role="button" tabindex="0" class="h5p-enable-fullscreen" title="' + H5P.t('fullscreen') + '"></div></div>').prependTo($container).children().click(function () {
|
||||||
|
|
Loading…
Reference in New Issue