Fix code style
parent
e316eff18d
commit
82b50fc2f1
|
@ -351,7 +351,7 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
|
|||
*
|
||||
* @param {number|null} minHeight
|
||||
*/
|
||||
this.setViewPortMinimumHeight = function(minHeight) {
|
||||
this.setViewPortMinimumHeight = function (minHeight) {
|
||||
var container = document.querySelector('.h5p-container') || document.body;
|
||||
container.style.minHeight = (typeof minHeight === 'number') ? (minHeight + 'px') : minHeight;
|
||||
};
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
* @class
|
||||
* @augments H5P.EventDispatcher
|
||||
*/
|
||||
H5P.ContentType = function (isRootLibrary, library) {
|
||||
H5P.ContentType = function (isRootLibrary) {
|
||||
|
||||
function ContentType() {}
|
||||
|
||||
|
|
|
@ -127,10 +127,10 @@ H5P.ContentUpgradeProcess = (function (Version) {
|
|||
}, {metadata: metadata});
|
||||
}
|
||||
catch (err) {
|
||||
if (console && console.log) {
|
||||
console.log("Error", err.stack);
|
||||
console.log("Error", err.name);
|
||||
console.log("Error", err.message);
|
||||
if (console && console.error) {
|
||||
console.error("Error", err.stack);
|
||||
console.error("Error", err.name);
|
||||
console.error("Error", err.message);
|
||||
}
|
||||
next(err);
|
||||
}
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* global importScripts */
|
||||
var H5P = H5P || {};
|
||||
importScripts('h5p-version.js', 'h5p-content-upgrade-process.js');
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*jshint -W083 */
|
||||
/* global H5PAdminIntegration H5PUtils */
|
||||
|
||||
(function ($, Version) {
|
||||
var info, $container, librariesCache = {}, scriptsCache = {};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* global H5PUtils */
|
||||
var H5PDataView = (function ($) {
|
||||
|
||||
/**
|
||||
|
@ -198,7 +199,6 @@ var H5PDataView = (function ($) {
|
|||
* @param number col ID of column
|
||||
*/
|
||||
H5PDataView.prototype.createFacets = function (input, col) {
|
||||
var self = this;
|
||||
var facets = '';
|
||||
|
||||
if (input instanceof Array) {
|
||||
|
|
|
@ -10,7 +10,7 @@ var H5P = window.H5P = window.H5P || {};
|
|||
* @param {boolean} [extras.bubbles]
|
||||
* @param {boolean} [extras.external]
|
||||
*/
|
||||
H5P.Event = function(type, data, extras) {
|
||||
H5P.Event = function (type, data, extras) {
|
||||
this.type = type;
|
||||
this.data = data;
|
||||
var bubbles = false;
|
||||
|
@ -34,7 +34,7 @@ H5P.Event = function(type, data, extras) {
|
|||
/**
|
||||
* Prevent this event from bubbling up to parent
|
||||
*/
|
||||
this.preventBubbling = function() {
|
||||
this.preventBubbling = function () {
|
||||
bubbles = false;
|
||||
};
|
||||
|
||||
|
@ -44,7 +44,7 @@ H5P.Event = function(type, data, extras) {
|
|||
* @returns {boolean}
|
||||
* true if bubbling false otherwise
|
||||
*/
|
||||
this.getBubbles = function() {
|
||||
this.getBubbles = function () {
|
||||
return bubbles;
|
||||
};
|
||||
|
||||
|
@ -54,7 +54,7 @@ H5P.Event = function(type, data, extras) {
|
|||
* @returns {boolean}
|
||||
* true if external and not already scheduled, otherwise false
|
||||
*/
|
||||
this.scheduleForExternal = function() {
|
||||
this.scheduleForExternal = function () {
|
||||
if (external && !scheduledForExternal) {
|
||||
scheduledForExternal = true;
|
||||
return true;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
var H5PLibraryDetails= H5PLibraryDetails || {};
|
||||
/* global H5PAdminIntegration H5PUtils */
|
||||
var H5PLibraryDetails = H5PLibraryDetails || {};
|
||||
|
||||
(function ($) {
|
||||
|
||||
|
@ -68,7 +69,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
|
|||
*/
|
||||
H5PLibraryDetails.createContentTable = function () {
|
||||
// Remove it if it exists:
|
||||
if(H5PLibraryDetails.$contentTable) {
|
||||
if (H5PLibraryDetails.$contentTable) {
|
||||
H5PLibraryDetails.$contentTable.remove();
|
||||
}
|
||||
|
||||
|
@ -77,10 +78,10 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
|
|||
var i = (H5PLibraryDetails.currentPage*H5PLibraryDetails.PAGER_SIZE);
|
||||
var lastIndex = (i+H5PLibraryDetails.PAGER_SIZE);
|
||||
|
||||
if(lastIndex > H5PLibraryDetails.currentContent.length) {
|
||||
if (lastIndex > H5PLibraryDetails.currentContent.length) {
|
||||
lastIndex = H5PLibraryDetails.currentContent.length;
|
||||
}
|
||||
for(; i<lastIndex; i++) {
|
||||
for (; i<lastIndex; i++) {
|
||||
var content = H5PLibraryDetails.currentContent[i];
|
||||
H5PLibraryDetails.$contentTable.append(H5PUtils.createTableRow(['<a href="' + content.url + '">' + content.title + '</a>']));
|
||||
}
|
||||
|
@ -97,7 +98,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
|
|||
H5PLibraryDetails.$next = $('<button type="button" class="next h5p-admin">></button>');
|
||||
|
||||
H5PLibraryDetails.$previous.on('click', function () {
|
||||
if(H5PLibraryDetails.$previous.hasClass('disabled')) {
|
||||
if (H5PLibraryDetails.$previous.hasClass('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -107,7 +108,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
|
|||
});
|
||||
|
||||
H5PLibraryDetails.$next.on('click', function () {
|
||||
if(H5PLibraryDetails.$next.hasClass('disabled')) {
|
||||
if (H5PLibraryDetails.$next.hasClass('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -127,7 +128,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
|
|||
H5PLibraryDetails.$pagerInfo.hide();
|
||||
|
||||
// User has updated the pageNumber
|
||||
var pageNumerUpdated = function() {
|
||||
var pageNumerUpdated = function () {
|
||||
var newPageNum = $gotoInput.val()-1;
|
||||
var intRegex = /^\d+$/;
|
||||
|
||||
|
@ -135,7 +136,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
|
|||
H5PLibraryDetails.$pagerInfo.css({display: 'inline-block'});
|
||||
|
||||
// Check if input value is valid, and that it has actually changed
|
||||
if(!(intRegex.test(newPageNum) && newPageNum >= 0 && newPageNum < H5PLibraryDetails.getNumPages() && newPageNum != H5PLibraryDetails.currentPage)) {
|
||||
if (!(intRegex.test(newPageNum) && newPageNum >= 0 && newPageNum < H5PLibraryDetails.getNumPages() && newPageNum != H5PLibraryDetails.currentPage)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -185,7 +186,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
|
|||
H5PLibraryDetails.updatePager = function () {
|
||||
H5PLibraryDetails.$pagerInfo.css({display: 'inline-block'});
|
||||
|
||||
if(H5PLibraryDetails.getNumPages() > 0) {
|
||||
if (H5PLibraryDetails.getNumPages() > 0) {
|
||||
var message = H5PUtils.translateReplace(H5PLibraryDetails.library.translations.pageXOfY, {
|
||||
'$x': (H5PLibraryDetails.currentPage+1),
|
||||
'$y': H5PLibraryDetails.getNumPages()
|
||||
|
@ -211,7 +212,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
|
|||
var searchString = $('.h5p-content-search > input').val();
|
||||
|
||||
// If search string same as previous, just do nothing
|
||||
if(H5PLibraryDetails.currentFilter === searchString) {
|
||||
if (H5PLibraryDetails.currentFilter === searchString) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -219,7 +220,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
|
|||
// If empty search, use the complete list
|
||||
H5PLibraryDetails.currentContent = H5PLibraryDetails.library.content;
|
||||
}
|
||||
else if(H5PLibraryDetails.filterCache[searchString]) {
|
||||
else if (H5PLibraryDetails.filterCache[searchString]) {
|
||||
// If search is cached, no need to filter
|
||||
H5PLibraryDetails.currentContent = H5PLibraryDetails.filterCache[searchString];
|
||||
}
|
||||
|
@ -227,10 +228,10 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
|
|||
var listToFilter = H5PLibraryDetails.library.content;
|
||||
|
||||
// Check if we can filter the already filtered results (for performance)
|
||||
if(searchString.length > 1 && H5PLibraryDetails.currentFilter === searchString.substr(0, H5PLibraryDetails.currentFilter.length)) {
|
||||
if (searchString.length > 1 && H5PLibraryDetails.currentFilter === searchString.substr(0, H5PLibraryDetails.currentFilter.length)) {
|
||||
listToFilter = H5PLibraryDetails.currentContent;
|
||||
}
|
||||
H5PLibraryDetails.currentContent = $.grep(listToFilter, function(content) {
|
||||
H5PLibraryDetails.currentContent = $.grep(listToFilter, function (content) {
|
||||
return content.title && content.title.match(new RegExp(searchString, 'i'));
|
||||
});
|
||||
}
|
||||
|
@ -256,7 +257,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
|
|||
$('input', H5PLibraryDetails.$search).on('change keypress paste input', function () {
|
||||
// Here we start the filtering
|
||||
// We wait at least 500 ms after last input to perform search
|
||||
if(inputTimer) {
|
||||
if (inputTimer) {
|
||||
clearTimeout(inputTimer);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/*jshint multistr: true */
|
||||
/* global H5PAdminIntegration H5PUtils */
|
||||
var H5PLibraryList = H5PLibraryList || {};
|
||||
|
||||
(function ($) {
|
||||
|
@ -25,7 +25,7 @@ var H5PLibraryList = H5PLibraryList || {};
|
|||
*/
|
||||
H5PLibraryList.createLibraryList = function (libraries) {
|
||||
var t = H5PAdminIntegration.l10n;
|
||||
if(libraries.listData === undefined || libraries.listData.length === 0) {
|
||||
if (libraries.listData === undefined || libraries.listData.length === 0) {
|
||||
return $('<div>' + t.NA + '</div>');
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
iframe.style.width = '100%';
|
||||
|
||||
// Tell iframe that it needs to resize when our window resizes
|
||||
var resize = function (event) {
|
||||
var resize = function () {
|
||||
if (iframe.contentWindow) {
|
||||
// Limit resize calls to avoid flickering
|
||||
respond('resize');
|
||||
|
@ -64,7 +64,7 @@
|
|||
* @param {Object} data Payload
|
||||
* @param {Function} respond Send a response to the iframe
|
||||
*/
|
||||
actionHandlers.resize = function (iframe, data, respond) {
|
||||
actionHandlers.resize = function (iframe, data) {
|
||||
// Resize iframe so all content is visible. Use scrollHeight to make sure we get everything
|
||||
iframe.style.height = data.scrollHeight + 'px';
|
||||
};
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
/* global H5PAdminIntegration*/
|
||||
var H5PUtils = H5PUtils || {};
|
||||
|
||||
(function ($) {
|
||||
|
@ -9,7 +10,7 @@ var H5PUtils = H5PUtils || {};
|
|||
H5PUtils.createTable = function (headers) {
|
||||
var $table = $('<table class="h5p-admin-table' + (H5PAdminIntegration.extraTableClasses !== undefined ? ' ' + H5PAdminIntegration.extraTableClasses : '') + '"></table>');
|
||||
|
||||
if(headers) {
|
||||
if (headers) {
|
||||
var $thead = $('<thead></thead>');
|
||||
var $tr = $('<tr></tr>');
|
||||
|
||||
|
@ -44,7 +45,7 @@ var H5PUtils = H5PUtils || {};
|
|||
};
|
||||
}
|
||||
|
||||
$('<td/>', value).appendTo($tr);
|
||||
$('<td/>', value).appendTo($tr);
|
||||
});
|
||||
|
||||
return $tr;
|
||||
|
|
|
@ -217,7 +217,7 @@ H5P.XAPIEvent.prototype.setActor = function () {
|
|||
* @returns {number}
|
||||
* The max score, or null if not defined
|
||||
*/
|
||||
H5P.XAPIEvent.prototype.getMaxScore = function() {
|
||||
H5P.XAPIEvent.prototype.getMaxScore = function () {
|
||||
return this.getVerifiedStatementValue(['result', 'score', 'max']);
|
||||
};
|
||||
|
||||
|
@ -227,7 +227,7 @@ H5P.XAPIEvent.prototype.getMaxScore = function() {
|
|||
* @returns {number}
|
||||
* The score, or null if not defined
|
||||
*/
|
||||
H5P.XAPIEvent.prototype.getScore = function() {
|
||||
H5P.XAPIEvent.prototype.getScore = function () {
|
||||
return this.getVerifiedStatementValue(['result', 'score', 'raw']);
|
||||
};
|
||||
|
||||
|
@ -256,7 +256,7 @@ H5P.XAPIEvent.prototype.getContentXAPIId = function (instance) {
|
|||
H5P.XAPIEvent.prototype.isFromChild = function () {
|
||||
var parentId = this.getVerifiedStatementValue(['context', 'contextActivities', 'parent', 0, 'id']);
|
||||
return !parentId || parentId.indexOf('subContentId') === -1;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Figure out if a property exists in the statement and return it
|
||||
|
@ -267,7 +267,7 @@ H5P.XAPIEvent.prototype.isFromChild = function () {
|
|||
* @returns {*}
|
||||
* The value of the property if it is set, null otherwise.
|
||||
*/
|
||||
H5P.XAPIEvent.prototype.getVerifiedStatementValue = function(keys) {
|
||||
H5P.XAPIEvent.prototype.getVerifiedStatementValue = function (keys) {
|
||||
var val = this.data.statement;
|
||||
for (var i = 0; i < keys.length; i++) {
|
||||
if (val[keys[i]] === undefined) {
|
||||
|
|
|
@ -92,7 +92,7 @@ H5P.EventDispatcher.prototype.triggerXAPIScored = function (score, maxScore, ver
|
|||
this.trigger(event);
|
||||
};
|
||||
|
||||
H5P.EventDispatcher.prototype.setActivityStarted = function() {
|
||||
H5P.EventDispatcher.prototype.setActivityStarted = function () {
|
||||
if (this.activityStartTime === undefined) {
|
||||
// Don't trigger xAPI events in the editor
|
||||
if (this.contentId !== undefined &&
|
||||
|
|
31
js/h5p.js
31
js/h5p.js
|
@ -89,7 +89,7 @@ H5P.init = function (target) {
|
|||
}
|
||||
|
||||
// H5Ps added in normal DIV.
|
||||
var $containers = H5P.jQuery('.h5p-content:not(.h5p-initialized)', target).each(function () {
|
||||
H5P.jQuery('.h5p-content:not(.h5p-initialized)', target).each(function () {
|
||||
var $element = H5P.jQuery(this).addClass('h5p-initialized');
|
||||
var $container = H5P.jQuery('<div class="h5p-container"></div>').appendTo($element);
|
||||
var contentId = $element.data('content-id');
|
||||
|
@ -301,7 +301,7 @@ H5P.init = function (target) {
|
|||
});
|
||||
|
||||
// When resize has been prepared tell parent window to resize
|
||||
H5P.communicator.on('resizePrepared', function (data) {
|
||||
H5P.communicator.on('resizePrepared', function () {
|
||||
H5P.communicator.send('resize', {
|
||||
scrollHeight: document.body.scrollHeight
|
||||
});
|
||||
|
@ -494,7 +494,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body, forceSemiFull
|
|||
}
|
||||
|
||||
var $container = $element;
|
||||
var $classes, $iframe;
|
||||
var $classes, $iframe, $body;
|
||||
if (body === undefined) {
|
||||
$body = H5P.$body;
|
||||
}
|
||||
|
@ -1089,7 +1089,7 @@ H5P.findCopyrights = function (info, parameters, contentId, extras) {
|
|||
}
|
||||
}
|
||||
|
||||
function buildFromMetadata (data, name, contentId) {
|
||||
function buildFromMetadata(data, name, contentId) {
|
||||
if (data.metadata) {
|
||||
const metadataCopyrights = H5P.buildMetadataCopyrights(data.metadata, name);
|
||||
if (metadataCopyrights !== undefined) {
|
||||
|
@ -1105,12 +1105,12 @@ H5P.findCopyrights = function (info, parameters, contentId, extras) {
|
|||
}
|
||||
};
|
||||
|
||||
H5P.buildMetadataCopyrights = function (metadata, contentTypeName) {
|
||||
H5P.buildMetadataCopyrights = function (metadata) {
|
||||
if (metadata && metadata.license !== undefined && metadata.license !== 'U') {
|
||||
var dataset = {
|
||||
contentType: metadata.contentType,
|
||||
title: metadata.title,
|
||||
author: (metadata.authors && metadata.authors.length > 0) ? metadata.authors.map(function(author) {
|
||||
author: (metadata.authors && metadata.authors.length > 0) ? metadata.authors.map(function (author) {
|
||||
return (author.role) ? author.name + ' (' + author.role + ')' : author.name;
|
||||
}).join(', ') : undefined,
|
||||
source: metadata.source,
|
||||
|
@ -1118,7 +1118,7 @@ H5P.buildMetadataCopyrights = function (metadata, contentTypeName) {
|
|||
license: metadata.license,
|
||||
version: metadata.licenseVersion,
|
||||
licenseExtras: metadata.licenseExtras,
|
||||
changes: (metadata.changes && metadata.changes.length > 0) ? metadata.changes.map(function(change) {
|
||||
changes: (metadata.changes && metadata.changes.length > 0) ? metadata.changes.map(function (change) {
|
||||
return change.log + (change.author ? ', ' + change.author : '') + (change.date ? ', ' + change.date : '');
|
||||
}).join(' / ') : undefined
|
||||
};
|
||||
|
@ -1181,10 +1181,10 @@ H5P.openEmbedDialog = function ($element, embedCode, resizeCode, size) {
|
|||
updateEmbed();
|
||||
|
||||
// Select text and expand textareas
|
||||
$dialog.find('.h5p-embed-code-container').each(function(index, value) {
|
||||
H5P.jQuery(this).css('height', this.scrollHeight + 'px').focus(function() {
|
||||
H5P.jQuery(this).select();
|
||||
});
|
||||
$dialog.find('.h5p-embed-code-container').each(function () {
|
||||
H5P.jQuery(this).css('height', this.scrollHeight + 'px').focus(function () {
|
||||
H5P.jQuery(this).select();
|
||||
});
|
||||
});
|
||||
$dialog.find('.h5p-embed-code-container').eq(0).select();
|
||||
positionInner();
|
||||
|
@ -1201,7 +1201,7 @@ H5P.openEmbedDialog = function ($element, embedCode, resizeCode, size) {
|
|||
$expander.addClass('h5p-open').text(H5P.t('hideAdvanced'));
|
||||
$content.show();
|
||||
}
|
||||
$dialog.find('.h5p-embed-code-container').each(function(index, value) {
|
||||
$dialog.find('.h5p-embed-code-container').each(function () {
|
||||
H5P.jQuery(this).css('height', this.scrollHeight + 'px');
|
||||
});
|
||||
positionInner();
|
||||
|
@ -1614,7 +1614,8 @@ H5P.Coords = function (x, y, w, h) {
|
|||
this.y = x.y;
|
||||
this.w = x.w;
|
||||
this.h = x.h;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (x !== undefined) {
|
||||
this.x = x;
|
||||
}
|
||||
|
@ -1870,7 +1871,7 @@ H5P.on = function (instance, eventType, handler) {
|
|||
* @returns {string} UUID
|
||||
*/
|
||||
H5P.createUUID = function () {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function(char) {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (char) {
|
||||
var random = Math.random()*16|0, newChar = char === 'x' ? random : (random&0x3|0x8);
|
||||
return newChar.toString(16);
|
||||
});
|
||||
|
@ -2098,7 +2099,7 @@ H5P.createTitle = function (rawTitle, maxLength) {
|
|||
}
|
||||
|
||||
preloadedData[options.subContentId][dataId] = data;
|
||||
contentUserDataAjax(contentId, dataId, options.subContentId, function (error, data) {
|
||||
contentUserDataAjax(contentId, dataId, options.subContentId, function (error) {
|
||||
if (options.errorCallback && error) {
|
||||
options.errorCallback(error);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue