Fix code style

set-minimum-height-for-dialogs
Paal Joergensen 2018-10-23 11:25:46 +02:00
parent e316eff18d
commit 82b50fc2f1
14 changed files with 56 additions and 52 deletions

View File

@ -351,7 +351,7 @@ H5P.ConfirmationDialog = (function (EventDispatcher) {
* *
* @param {number|null} minHeight * @param {number|null} minHeight
*/ */
this.setViewPortMinimumHeight = function(minHeight) { this.setViewPortMinimumHeight = function (minHeight) {
var container = document.querySelector('.h5p-container') || document.body; var container = document.querySelector('.h5p-container') || document.body;
container.style.minHeight = (typeof minHeight === 'number') ? (minHeight + 'px') : minHeight; container.style.minHeight = (typeof minHeight === 'number') ? (minHeight + 'px') : minHeight;
}; };

View File

@ -11,7 +11,7 @@
* @class * @class
* @augments H5P.EventDispatcher * @augments H5P.EventDispatcher
*/ */
H5P.ContentType = function (isRootLibrary, library) { H5P.ContentType = function (isRootLibrary) {
function ContentType() {} function ContentType() {}

View File

@ -127,10 +127,10 @@ H5P.ContentUpgradeProcess = (function (Version) {
}, {metadata: metadata}); }, {metadata: metadata});
} }
catch (err) { catch (err) {
if (console && console.log) { if (console && console.error) {
console.log("Error", err.stack); console.error("Error", err.stack);
console.log("Error", err.name); console.error("Error", err.name);
console.log("Error", err.message); console.error("Error", err.message);
} }
next(err); next(err);
} }

View File

@ -1,3 +1,4 @@
/* global importScripts */
var H5P = H5P || {}; var H5P = H5P || {};
importScripts('h5p-version.js', 'h5p-content-upgrade-process.js'); importScripts('h5p-version.js', 'h5p-content-upgrade-process.js');

View File

@ -1,4 +1,4 @@
/*jshint -W083 */ /* global H5PAdminIntegration H5PUtils */
(function ($, Version) { (function ($, Version) {
var info, $container, librariesCache = {}, scriptsCache = {}; var info, $container, librariesCache = {}, scriptsCache = {};

View File

@ -1,3 +1,4 @@
/* global H5PUtils */
var H5PDataView = (function ($) { var H5PDataView = (function ($) {
/** /**
@ -198,7 +199,6 @@ var H5PDataView = (function ($) {
* @param number col ID of column * @param number col ID of column
*/ */
H5PDataView.prototype.createFacets = function (input, col) { H5PDataView.prototype.createFacets = function (input, col) {
var self = this;
var facets = ''; var facets = '';
if (input instanceof Array) { if (input instanceof Array) {

View File

@ -10,7 +10,7 @@ var H5P = window.H5P = window.H5P || {};
* @param {boolean} [extras.bubbles] * @param {boolean} [extras.bubbles]
* @param {boolean} [extras.external] * @param {boolean} [extras.external]
*/ */
H5P.Event = function(type, data, extras) { H5P.Event = function (type, data, extras) {
this.type = type; this.type = type;
this.data = data; this.data = data;
var bubbles = false; var bubbles = false;
@ -34,7 +34,7 @@ H5P.Event = function(type, data, extras) {
/** /**
* Prevent this event from bubbling up to parent * Prevent this event from bubbling up to parent
*/ */
this.preventBubbling = function() { this.preventBubbling = function () {
bubbles = false; bubbles = false;
}; };
@ -44,7 +44,7 @@ H5P.Event = function(type, data, extras) {
* @returns {boolean} * @returns {boolean}
* true if bubbling false otherwise * true if bubbling false otherwise
*/ */
this.getBubbles = function() { this.getBubbles = function () {
return bubbles; return bubbles;
}; };
@ -54,7 +54,7 @@ H5P.Event = function(type, data, extras) {
* @returns {boolean} * @returns {boolean}
* true if external and not already scheduled, otherwise false * true if external and not already scheduled, otherwise false
*/ */
this.scheduleForExternal = function() { this.scheduleForExternal = function () {
if (external && !scheduledForExternal) { if (external && !scheduledForExternal) {
scheduledForExternal = true; scheduledForExternal = true;
return true; return true;

View File

@ -1,4 +1,5 @@
var H5PLibraryDetails= H5PLibraryDetails || {}; /* global H5PAdminIntegration H5PUtils */
var H5PLibraryDetails = H5PLibraryDetails || {};
(function ($) { (function ($) {
@ -68,7 +69,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
*/ */
H5PLibraryDetails.createContentTable = function () { H5PLibraryDetails.createContentTable = function () {
// Remove it if it exists: // Remove it if it exists:
if(H5PLibraryDetails.$contentTable) { if (H5PLibraryDetails.$contentTable) {
H5PLibraryDetails.$contentTable.remove(); H5PLibraryDetails.$contentTable.remove();
} }
@ -77,10 +78,10 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
var i = (H5PLibraryDetails.currentPage*H5PLibraryDetails.PAGER_SIZE); var i = (H5PLibraryDetails.currentPage*H5PLibraryDetails.PAGER_SIZE);
var lastIndex = (i+H5PLibraryDetails.PAGER_SIZE); var lastIndex = (i+H5PLibraryDetails.PAGER_SIZE);
if(lastIndex > H5PLibraryDetails.currentContent.length) { if (lastIndex > H5PLibraryDetails.currentContent.length) {
lastIndex = H5PLibraryDetails.currentContent.length; lastIndex = H5PLibraryDetails.currentContent.length;
} }
for(; i<lastIndex; i++) { for (; i<lastIndex; i++) {
var content = H5PLibraryDetails.currentContent[i]; var content = H5PLibraryDetails.currentContent[i];
H5PLibraryDetails.$contentTable.append(H5PUtils.createTableRow(['<a href="' + content.url + '">' + content.title + '</a>'])); 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.$next = $('<button type="button" class="next h5p-admin">></button>');
H5PLibraryDetails.$previous.on('click', function () { H5PLibraryDetails.$previous.on('click', function () {
if(H5PLibraryDetails.$previous.hasClass('disabled')) { if (H5PLibraryDetails.$previous.hasClass('disabled')) {
return; return;
} }
@ -107,7 +108,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
}); });
H5PLibraryDetails.$next.on('click', function () { H5PLibraryDetails.$next.on('click', function () {
if(H5PLibraryDetails.$next.hasClass('disabled')) { if (H5PLibraryDetails.$next.hasClass('disabled')) {
return; return;
} }
@ -127,7 +128,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
H5PLibraryDetails.$pagerInfo.hide(); H5PLibraryDetails.$pagerInfo.hide();
// User has updated the pageNumber // User has updated the pageNumber
var pageNumerUpdated = function() { var pageNumerUpdated = function () {
var newPageNum = $gotoInput.val()-1; var newPageNum = $gotoInput.val()-1;
var intRegex = /^\d+$/; var intRegex = /^\d+$/;
@ -135,7 +136,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
H5PLibraryDetails.$pagerInfo.css({display: 'inline-block'}); H5PLibraryDetails.$pagerInfo.css({display: 'inline-block'});
// Check if input value is valid, and that it has actually changed // 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; return;
} }
@ -185,7 +186,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
H5PLibraryDetails.updatePager = function () { H5PLibraryDetails.updatePager = function () {
H5PLibraryDetails.$pagerInfo.css({display: 'inline-block'}); H5PLibraryDetails.$pagerInfo.css({display: 'inline-block'});
if(H5PLibraryDetails.getNumPages() > 0) { if (H5PLibraryDetails.getNumPages() > 0) {
var message = H5PUtils.translateReplace(H5PLibraryDetails.library.translations.pageXOfY, { var message = H5PUtils.translateReplace(H5PLibraryDetails.library.translations.pageXOfY, {
'$x': (H5PLibraryDetails.currentPage+1), '$x': (H5PLibraryDetails.currentPage+1),
'$y': H5PLibraryDetails.getNumPages() '$y': H5PLibraryDetails.getNumPages()
@ -211,7 +212,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
var searchString = $('.h5p-content-search > input').val(); var searchString = $('.h5p-content-search > input').val();
// If search string same as previous, just do nothing // If search string same as previous, just do nothing
if(H5PLibraryDetails.currentFilter === searchString) { if (H5PLibraryDetails.currentFilter === searchString) {
return; return;
} }
@ -219,7 +220,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
// If empty search, use the complete list // If empty search, use the complete list
H5PLibraryDetails.currentContent = H5PLibraryDetails.library.content; H5PLibraryDetails.currentContent = H5PLibraryDetails.library.content;
} }
else if(H5PLibraryDetails.filterCache[searchString]) { else if (H5PLibraryDetails.filterCache[searchString]) {
// If search is cached, no need to filter // If search is cached, no need to filter
H5PLibraryDetails.currentContent = H5PLibraryDetails.filterCache[searchString]; H5PLibraryDetails.currentContent = H5PLibraryDetails.filterCache[searchString];
} }
@ -227,10 +228,10 @@ var H5PLibraryDetails= H5PLibraryDetails || {};
var listToFilter = H5PLibraryDetails.library.content; var listToFilter = H5PLibraryDetails.library.content;
// Check if we can filter the already filtered results (for performance) // 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; 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')); 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 () { $('input', H5PLibraryDetails.$search).on('change keypress paste input', function () {
// Here we start the filtering // Here we start the filtering
// We wait at least 500 ms after last input to perform search // We wait at least 500 ms after last input to perform search
if(inputTimer) { if (inputTimer) {
clearTimeout(inputTimer); clearTimeout(inputTimer);
} }

View File

@ -1,4 +1,4 @@
/*jshint multistr: true */ /* global H5PAdminIntegration H5PUtils */
var H5PLibraryList = H5PLibraryList || {}; var H5PLibraryList = H5PLibraryList || {};
(function ($) { (function ($) {
@ -25,7 +25,7 @@ var H5PLibraryList = H5PLibraryList || {};
*/ */
H5PLibraryList.createLibraryList = function (libraries) { H5PLibraryList.createLibraryList = function (libraries) {
var t = H5PAdminIntegration.l10n; 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>'); return $('<div>' + t.NA + '</div>');
} }

View File

@ -21,7 +21,7 @@
iframe.style.width = '100%'; iframe.style.width = '100%';
// Tell iframe that it needs to resize when our window resizes // Tell iframe that it needs to resize when our window resizes
var resize = function (event) { var resize = function () {
if (iframe.contentWindow) { if (iframe.contentWindow) {
// Limit resize calls to avoid flickering // Limit resize calls to avoid flickering
respond('resize'); respond('resize');
@ -64,7 +64,7 @@
* @param {Object} data Payload * @param {Object} data Payload
* @param {Function} respond Send a response to the iframe * @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 // Resize iframe so all content is visible. Use scrollHeight to make sure we get everything
iframe.style.height = data.scrollHeight + 'px'; iframe.style.height = data.scrollHeight + 'px';
}; };

View File

@ -1,3 +1,4 @@
/* global H5PAdminIntegration*/
var H5PUtils = H5PUtils || {}; var H5PUtils = H5PUtils || {};
(function ($) { (function ($) {
@ -9,7 +10,7 @@ var H5PUtils = H5PUtils || {};
H5PUtils.createTable = function (headers) { H5PUtils.createTable = function (headers) {
var $table = $('<table class="h5p-admin-table' + (H5PAdminIntegration.extraTableClasses !== undefined ? ' ' + H5PAdminIntegration.extraTableClasses : '') + '"></table>'); var $table = $('<table class="h5p-admin-table' + (H5PAdminIntegration.extraTableClasses !== undefined ? ' ' + H5PAdminIntegration.extraTableClasses : '') + '"></table>');
if(headers) { if (headers) {
var $thead = $('<thead></thead>'); var $thead = $('<thead></thead>');
var $tr = $('<tr></tr>'); var $tr = $('<tr></tr>');
@ -44,7 +45,7 @@ var H5PUtils = H5PUtils || {};
}; };
} }
$('<td/>', value).appendTo($tr); $('<td/>', value).appendTo($tr);
}); });
return $tr; return $tr;

View File

@ -217,7 +217,7 @@ H5P.XAPIEvent.prototype.setActor = function () {
* @returns {number} * @returns {number}
* The max score, or null if not defined * The max score, or null if not defined
*/ */
H5P.XAPIEvent.prototype.getMaxScore = function() { H5P.XAPIEvent.prototype.getMaxScore = function () {
return this.getVerifiedStatementValue(['result', 'score', 'max']); return this.getVerifiedStatementValue(['result', 'score', 'max']);
}; };
@ -227,7 +227,7 @@ H5P.XAPIEvent.prototype.getMaxScore = function() {
* @returns {number} * @returns {number}
* The score, or null if not defined * The score, or null if not defined
*/ */
H5P.XAPIEvent.prototype.getScore = function() { H5P.XAPIEvent.prototype.getScore = function () {
return this.getVerifiedStatementValue(['result', 'score', 'raw']); return this.getVerifiedStatementValue(['result', 'score', 'raw']);
}; };
@ -256,7 +256,7 @@ H5P.XAPIEvent.prototype.getContentXAPIId = function (instance) {
H5P.XAPIEvent.prototype.isFromChild = function () { H5P.XAPIEvent.prototype.isFromChild = function () {
var parentId = this.getVerifiedStatementValue(['context', 'contextActivities', 'parent', 0, 'id']); var parentId = this.getVerifiedStatementValue(['context', 'contextActivities', 'parent', 0, 'id']);
return !parentId || parentId.indexOf('subContentId') === -1; return !parentId || parentId.indexOf('subContentId') === -1;
} };
/** /**
* Figure out if a property exists in the statement and return it * Figure out if a property exists in the statement and return it
@ -267,7 +267,7 @@ H5P.XAPIEvent.prototype.isFromChild = function () {
* @returns {*} * @returns {*}
* The value of the property if it is set, null otherwise. * 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; var val = this.data.statement;
for (var i = 0; i < keys.length; i++) { for (var i = 0; i < keys.length; i++) {
if (val[keys[i]] === undefined) { if (val[keys[i]] === undefined) {

View File

@ -92,7 +92,7 @@ H5P.EventDispatcher.prototype.triggerXAPIScored = function (score, maxScore, ver
this.trigger(event); this.trigger(event);
}; };
H5P.EventDispatcher.prototype.setActivityStarted = function() { H5P.EventDispatcher.prototype.setActivityStarted = function () {
if (this.activityStartTime === undefined) { if (this.activityStartTime === undefined) {
// Don't trigger xAPI events in the editor // Don't trigger xAPI events in the editor
if (this.contentId !== undefined && if (this.contentId !== undefined &&

View File

@ -89,7 +89,7 @@ H5P.init = function (target) {
} }
// H5Ps added in normal DIV. // 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 $element = H5P.jQuery(this).addClass('h5p-initialized');
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');
@ -301,7 +301,7 @@ H5P.init = function (target) {
}); });
// When resize has been prepared tell parent window to resize // 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', { H5P.communicator.send('resize', {
scrollHeight: document.body.scrollHeight scrollHeight: document.body.scrollHeight
}); });
@ -494,7 +494,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body, forceSemiFull
} }
var $container = $element; var $container = $element;
var $classes, $iframe; var $classes, $iframe, $body;
if (body === undefined) { if (body === undefined) {
$body = H5P.$body; $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) { if (data.metadata) {
const metadataCopyrights = H5P.buildMetadataCopyrights(data.metadata, name); const metadataCopyrights = H5P.buildMetadataCopyrights(data.metadata, name);
if (metadataCopyrights !== undefined) { 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') { if (metadata && metadata.license !== undefined && metadata.license !== 'U') {
var dataset = { var dataset = {
contentType: metadata.contentType, contentType: metadata.contentType,
title: metadata.title, 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; return (author.role) ? author.name + ' (' + author.role + ')' : author.name;
}).join(', ') : undefined, }).join(', ') : undefined,
source: metadata.source, source: metadata.source,
@ -1118,7 +1118,7 @@ H5P.buildMetadataCopyrights = function (metadata, contentTypeName) {
license: metadata.license, license: metadata.license,
version: metadata.licenseVersion, version: metadata.licenseVersion,
licenseExtras: metadata.licenseExtras, 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 : ''); return change.log + (change.author ? ', ' + change.author : '') + (change.date ? ', ' + change.date : '');
}).join(' / ') : undefined }).join(' / ') : undefined
}; };
@ -1181,10 +1181,10 @@ H5P.openEmbedDialog = function ($element, embedCode, resizeCode, size) {
updateEmbed(); updateEmbed();
// Select text and expand textareas // Select text and expand textareas
$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').focus(function() { H5P.jQuery(this).css('height', this.scrollHeight + 'px').focus(function () {
H5P.jQuery(this).select(); H5P.jQuery(this).select();
}); });
}); });
$dialog.find('.h5p-embed-code-container').eq(0).select(); $dialog.find('.h5p-embed-code-container').eq(0).select();
positionInner(); positionInner();
@ -1201,7 +1201,7 @@ H5P.openEmbedDialog = function ($element, embedCode, resizeCode, size) {
$expander.addClass('h5p-open').text(H5P.t('hideAdvanced')); $expander.addClass('h5p-open').text(H5P.t('hideAdvanced'));
$content.show(); $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'); H5P.jQuery(this).css('height', this.scrollHeight + 'px');
}); });
positionInner(); positionInner();
@ -1614,7 +1614,8 @@ H5P.Coords = function (x, y, w, h) {
this.y = x.y; this.y = x.y;
this.w = x.w; this.w = x.w;
this.h = x.h; this.h = x.h;
} else { }
else {
if (x !== undefined) { if (x !== undefined) {
this.x = x; this.x = x;
} }
@ -1870,7 +1871,7 @@ H5P.on = function (instance, eventType, handler) {
* @returns {string} UUID * @returns {string} UUID
*/ */
H5P.createUUID = function () { 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); var random = Math.random()*16|0, newChar = char === 'x' ? random : (random&0x3|0x8);
return newChar.toString(16); return newChar.toString(16);
}); });
@ -2098,7 +2099,7 @@ H5P.createTitle = function (rawTitle, maxLength) {
} }
preloadedData[options.subContentId][dataId] = data; preloadedData[options.subContentId][dataId] = data;
contentUserDataAjax(contentId, dataId, options.subContentId, function (error, data) { contentUserDataAjax(contentId, dataId, options.subContentId, function (error) {
if (options.errorCallback && error) { if (options.errorCallback && error) {
options.errorCallback(error); options.errorCallback(error);
} }