diff --git a/js/h5p-content-upgrade.js b/js/h5p-content-upgrade.js index bbea037..c5cd02a 100644 --- a/js/h5p-content-upgrade.js +++ b/js/h5p-content-upgrade.js @@ -1,19 +1,20 @@ +/*jshint -W083 */ var H5PUpgrades = H5PUpgrades || {}; (function ($) { var info, $container, librariesCache = {}; - + // Initialize $(document).ready(function () { // Get library info info = H5PIntegration.getLibraryInfo(); - + // Get and reset container $container = $('#h5p-admin-container').html('

' + info.message + '

'); - + // Make it possible to select version var $version = $(getVersionSelect(info.versions)).appendTo($container); - + // Add "go" button $(''); H5PLibraryDetails.$next = $(''); - + H5PLibraryDetails.$previous.on('click', function () { if(H5PLibraryDetails.$previous.hasClass('disabled')) { return; } - + H5PLibraryDetails.currentPage--; H5PLibraryDetails.updatePager(); H5PLibraryDetails.createContentTable(); }); - + H5PLibraryDetails.$next.on('click', function () { if(H5PLibraryDetails.$next.hasClass('disabled')) { return; } - + H5PLibraryDetails.currentPage++; H5PLibraryDetails.updatePager(); H5PLibraryDetails.createContentTable(); }); - + // This is the Page x of y widget: H5PLibraryDetails.$pagerInfo = $(''); - + H5PLibraryDetails.$pager = $('
').append(H5PLibraryDetails.$previous, H5PLibraryDetails.$pagerInfo, H5PLibraryDetails.$next); H5PLibraryDetails.$content.append(H5PLibraryDetails.$pager); - + H5PLibraryDetails.$pagerInfo.on('click', function () { var width = H5PLibraryDetails.$pagerInfo.innerWidth(); H5PLibraryDetails.$pagerInfo.hide(); @@ -134,24 +134,24 @@ var H5PLibraryDetails= H5PLibraryDetails || {}; var pageNumerUpdated = function() { var newPageNum = $gotoInput.val()-1; var intRegex = /^\d+$/; - + $goto.remove(); 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)) { return; } - + H5PLibraryDetails.currentPage = newPageNum; H5PLibraryDetails.updatePager(); H5PLibraryDetails.createContentTable(); }; - + // We create an input box where the user may type in the page number // he wants to be displayed. // Reson for doing this is when user has ten-thousands of elements in list, - // this is the easiest way of getting to a specified page + // this is the easiest way of getting to a specified page var $gotoInput = $('', { type: 'number', min : 1, @@ -166,30 +166,30 @@ var H5PLibraryDetails= H5PLibraryDetails || {}; } } }).css({width: width}); - var $goto = $('', { + var $goto = $('', { 'class': 'h5p-pager-goto' }).css({width: width}).append($gotoInput).insertAfter(H5PLibraryDetails.$pagerInfo); - + $gotoInput.focus(); }); - + H5PLibraryDetails.updatePager(); } }; - + /** * Calculates number of pages */ H5PLibraryDetails.getNumPages = function () { return Math.ceil(H5PLibraryDetails.currentContent.length / H5PLibraryDetails.PAGER_SIZE); }; - + /** * Update the pager text, and enables/disables the next and previous buttons as needed */ H5PLibraryDetails.updatePager = function () { H5PLibraryDetails.$pagerInfo.css({display: 'inline-block'}); - + if(H5PLibraryDetails.getNumPages() > 0) { var message = H5PUtils.translateReplace(H5PLibraryDetails.library.translations.pageXOfY, { '$x': (H5PLibraryDetails.currentPage+1), @@ -200,26 +200,26 @@ var H5PLibraryDetails= H5PLibraryDetails || {}; else { H5PLibraryDetails.$pagerInfo.html(''); } - + H5PLibraryDetails.$previous.toggleClass('disabled', H5PLibraryDetails.currentPage <= 0); H5PLibraryDetails.$next.toggleClass('disabled', H5PLibraryDetails.currentContent.length < (H5PLibraryDetails.currentPage+1)*H5PLibraryDetails.PAGER_SIZE); }; - + /** * Creates the search element */ H5PLibraryDetails.createSearchElement = function () { - + H5PLibraryDetails.$search = $(''); - + var performSeach = function () { var searchString = $('.h5p-content-search > input').val(); - + // If search string same as previous, just do nothing if(H5PLibraryDetails.currentFilter === searchString) { return; } - + if (searchString.trim().length === 0) { // If empty search, use the complete list H5PLibraryDetails.currentContent = H5PLibraryDetails.library.content; @@ -230,7 +230,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {}; } else { 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)) { listToFilter = H5PLibraryDetails.currentContent; @@ -239,47 +239,47 @@ var H5PLibraryDetails= H5PLibraryDetails || {}; return content.title && content.title.match(new RegExp(searchString, 'i')); }); } - + H5PLibraryDetails.currentFilter = searchString; // Cache the current result H5PLibraryDetails.filterCache[searchString] = H5PLibraryDetails.currentContent; H5PLibraryDetails.currentPage = 0; H5PLibraryDetails.createContentTable(); - + // Display search results: if (H5PLibraryDetails.$searchResults) { H5PLibraryDetails.$searchResults.remove(); } if (searchString.trim().length > 0) { - H5PLibraryDetails.$searchResults = $('' + H5PLibraryDetails.currentContent.length + ' hits on ' + H5PLibraryDetails.currentFilter + ''); + H5PLibraryDetails.$searchResults = $('' + H5PLibraryDetails.currentContent.length + ' hits on ' + H5PLibraryDetails.currentFilter + ''); H5PLibraryDetails.$search.append(H5PLibraryDetails.$searchResults); } H5PLibraryDetails.updatePager(); }; - - var inputTimer = undefined; + + var inputTimer; $('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) { clearTimeout(inputTimer); } - + inputTimer = setTimeout( function () { performSeach(); }, 500); }); - + H5PLibraryDetails.$content.append(H5PLibraryDetails.$search); }; - + /** * Creates the page size selector */ H5PLibraryDetails.createPageSizeSelector = function () { H5PLibraryDetails.$search.append('
' + H5PLibraryDetails.library.translations.pageSizeSelectorLabel + ':102050100200
'); - - // Listen to clicks on the page size selector: + + // Listen to clicks on the page size selector: $('.h5p-admin-pager-size-selector > span', H5PLibraryDetails.$search).on('click', function () { H5PLibraryDetails.PAGER_SIZE = $(this).data('page-size'); $('.h5p-admin-pager-size-selector > span', H5PLibraryDetails.$search).removeClass('selected'); @@ -289,7 +289,7 @@ var H5PLibraryDetails= H5PLibraryDetails || {}; H5PLibraryDetails.updatePager(); }); }; - + // Initialize me: $(document).ready(function () { if (!H5PLibraryDetails.initialized) { @@ -297,5 +297,5 @@ var H5PLibraryDetails= H5PLibraryDetails || {}; H5PLibraryDetails.init(); } }); - -})(H5P.jQuery); \ No newline at end of file + +})(H5P.jQuery); diff --git a/js/h5p-library-list.js b/js/h5p-library-list.js index a1e517f..fa37d3a 100644 --- a/js/h5p-library-list.js +++ b/js/h5p-library-list.js @@ -1,3 +1,4 @@ +/*jshint multistr: true */ var H5PLibraryList= H5PLibraryList || {}; (function ($) { @@ -7,19 +8,19 @@ var H5PLibraryList= H5PLibraryList || {}; */ H5PLibraryList.init = function () { var $adminContainer = H5PIntegration.getAdminContainer(); - + var libraryList = H5PIntegration.getLibraryList(); if (libraryList.notCached) { $adminContainer.append(H5PUtils.getRebuildCache(libraryList.notCached)); } - + // Create library list $adminContainer.append(H5PLibraryList.createLibraryList(H5PIntegration.getLibraryList())); }; - + /** * Create the library list - * + * * @param {object} libraries List of libraries and headers */ H5PLibraryList.createLibraryList = function (libraries) { @@ -27,11 +28,11 @@ var H5PLibraryList= H5PLibraryList || {}; if(libraries.listData === undefined || libraries.listData.length === 0) { return $('
' + t.NA + '
'); } - + // Create table var $table = H5PUtils.createTable(libraries.listHeaders); $table.addClass('libraries'); - + // Add libraries $.each (libraries.listData, function (index, library) { var $libraryRow = H5PUtils.createTableRow([ @@ -54,7 +55,7 @@ var H5PLibraryList= H5PLibraryList || {}; \ ' ]); - + var hasContent = !(library.numContent === '' || library.numContent === 0); if (library.upgradeUrl === null) { $('.h5p-admin-upgrade-library', $libraryRow).remove(); @@ -67,12 +68,12 @@ var H5PLibraryList= H5PLibraryList || {}; window.location.href = library.upgradeUrl; }); } - + // Open details view when clicked $('.h5p-admin-view-library', $libraryRow).on('click', function () { window.location.href = library.detailsUrl; }); - + var $deleteButton = $('.h5p-admin-delete-library', $libraryRow); if (libraries.notCached !== undefined || hasContent || (library.numContentDependencies !== '' && library.numContentDependencies !== 0) || (library.numLibraryDependencies !== '' && library.numLibraryDependencies !== 0)) { // Disabled delete if content. @@ -87,11 +88,11 @@ var H5PLibraryList= H5PLibraryList || {}; $table.append($libraryRow); }); - + return $table; }; - - + + // Initialize me: $(document).ready(function () { if (!H5PLibraryList.initialized) { @@ -99,5 +100,5 @@ var H5PLibraryList= H5PLibraryList || {}; H5PLibraryList.init(); } }); - + })(H5P.jQuery); diff --git a/js/h5p-utils.js b/js/h5p-utils.js index 26ffa1d..0db73a7 100644 --- a/js/h5p-utils.js +++ b/js/h5p-utils.js @@ -3,7 +3,7 @@ var H5PUtils = H5PUtils || {}; (function ($) { /** * Generic function for creating a table including the headers - * + * * @param {array} headers List of headers */ H5PUtils.createTable = function (headers) { @@ -12,62 +12,62 @@ var H5PUtils = H5PUtils || {}; if(headers) { var $thead = $(''); var $tr = $(''); - + $.each(headers, function (index, value) { if (!(value instanceof Object)) { value = { html: value }; } - + $('', value).appendTo($tr); }); - + $table.append($thead.append($tr)); } - + return $table; }; - + /** * Generic function for creating a table row - * + * * @param {array} rows Value list. Object name is used as class name in */ H5PUtils.createTableRow = function (rows) { var $tr = $(''); - + $.each(rows, function (index, value) { if (!(value instanceof Object)) { value = { html: value }; } - + $('', value).appendTo($tr); }); - + return $tr; }; - + /** * Generic function for creating a field containing label and value - * - * @param {string} label The label displayed in front of the value + * + * @param {string} label The label displayed in front of the value * @param {string} value The value */ H5PUtils.createLabeledField = function (label, value) { var $field = $('
'); - + $field.append('
' + label + '
'); $field.append('
' + value + '
'); - + return $field; }; /** * Replaces placeholder fields in translation strings - * + * * @param {string} template The translation template string in the following format: "$name is a $sex" * @param {array} replacors An js object with key and values. Eg: {'$name': 'Frode', '$sex': 'male'} */ @@ -77,10 +77,10 @@ var H5PUtils = H5PUtils || {}; }); return template; }; - + /** * Get throbber with given text. - * + * * @param {String} text * @returns {$} */ @@ -90,7 +90,7 @@ var H5PUtils = H5PUtils || {}; text: text }); }; - + /** * Makes it possbile to rebuild all content caches from admin UI. * @param {Object} notCached @@ -107,7 +107,7 @@ var H5PUtils = H5PUtils || {}; current++; if (current === parts.length) current = 0; }, 100); - + var $counter = $container.find('.progress'); var build = function () { $.post(notCached.url, function (left) { @@ -126,8 +126,8 @@ var H5PUtils = H5PUtils || {}; }; build(); }); - + return $container; }; - -})(H5P.jQuery); \ No newline at end of file + +})(H5P.jQuery); diff --git a/js/h5p.js b/js/h5p.js index 3b5db69..c858652 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -1,3 +1,4 @@ +/*jshint multistr: true */ // TODO: Should we split up the generic parts needed by the editor(and others), and the parts needed to "run" H5Ps? var H5P = H5P || {}; @@ -11,12 +12,12 @@ H5P.$window = H5P.jQuery(window); if (document.documentElement.requestFullScreen) { H5P.fullScreenBrowserPrefix = ''; } -else if (document.documentElement.webkitRequestFullScreen - && navigator.userAgent.indexOf('Android') === -1 // Skip Android +else if (document.documentElement.webkitRequestFullScreen && + navigator.userAgent.indexOf('Android') === -1 // Skip Android ) { H5P.safariBrowser = navigator.userAgent.match(/Version\/(\d)/); H5P.safariBrowser = (H5P.safariBrowser === null ? 0 : parseInt(H5P.safariBrowser[1])); - + // Do not allow fullscreen for safari < 7. if (H5P.safariBrowser === 0 || H5P.safariBrowser > 6) { H5P.fullScreenBrowserPrefix = 'webkit'; @@ -56,14 +57,14 @@ H5P.init = function () { // Create new instance. var instance = H5P.newRunnable(library, contentId, $container, true); - + // Check if we should add and display a fullscreen button for this H5P. if (contentData.fullScreen == 1) { H5P.jQuery('
').prependTo($container).children().click(function () { H5P.fullScreen($container, instance); }); - }; - + } + var $actions = H5P.jQuery(''); if (contentData.exportUrl !== '') { // Display export button @@ -87,7 +88,7 @@ H5P.init = function () { H5P.jQuery('
  • ').appendTo($actions); } $actions.insertAfter($container); - + if (H5P.isFramed) { // Make it possible to resize the iframe when the content changes size. This way we get no scrollbars. var iframe = window.parent.document.getElementById('h5p-iframe-' + contentId); @@ -95,10 +96,10 @@ H5P.init = function () { if (window.parent.H5P.isFullscreen) { return; // Skip if full screen. } - + // Retain parent size to avoid jumping/scrolling var parentHeight = iframe.parentElement.style.height; - iframe.parentElement.style.height = iframe.parentElement.clientHeight + 'px'; + iframe.parentElement.style.height = iframe.parentElement.clientHeight + 'px'; // Reset iframe height, in case content has shrinked. iframe.style.height = '1px'; @@ -109,7 +110,7 @@ H5P.init = function () { // Free parent iframe.parentElement.style.height = parentHeight; }; - + var resizeDelay; instance.$.on('resize', function () { // Use a delay to make sure iframe is resized to the correct size. @@ -119,7 +120,7 @@ H5P.init = function () { }, 1); }); } - + // Resize everything when window is resized. $window.resize(function () { if (window.parent.H5P.isFullscreen) { @@ -130,7 +131,7 @@ H5P.init = function () { instance.$.trigger('resize'); } }); - + // Resize content. instance.$.trigger('resize'); }); @@ -159,7 +160,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body) { window.parent.H5P.fullScreen($element, instance, exitCallback, H5P.$body.get()); return; } - + var $container = $element; var $classes, $iframe; if (body === undefined) { @@ -173,23 +174,23 @@ H5P.fullScreen = function ($element, instance, exitCallback, body) { $iframe = H5P.jQuery(iframeSelector); $element = $iframe.parent(); // Put iframe wrapper in fullscreen, not container. } - + $classes = $element.add(H5P.$body).add($classes); - + /** * Prepare for resize by setting the correct styles. - * + * * @param {String} classes CSS */ var before = function (classes) { $classes.addClass(classes); - + if ($iframe !== undefined) { // Set iframe to its default size(100%). $iframe.css('height', ''); } }; - + /** * Gets called when fullscreen mode has been entered. * Resizes and sets focus on content. @@ -199,17 +200,17 @@ H5P.fullScreen = function ($element, instance, exitCallback, body) { instance.$.trigger('resize'); instance.$.trigger('focus'); }; - + /** * Gets called when fullscreen mode has been exited. * Resizes and sets focus on content. - * + * * @param {String} classes CSS */ var done = function (classes) { H5P.isFullscreen = false; $classes.removeClass(classes); - + // Do not rely on window resize events. instance.$.trigger('resize'); instance.$.trigger('focus'); @@ -222,11 +223,11 @@ H5P.fullScreen = function ($element, instance, exitCallback, body) { H5P.isFullscreen = true; if (H5P.fullScreenBrowserPrefix === undefined) { // Create semi fullscreen. - + before('h5p-semi-fullscreen'); var $disable = H5P.jQuery('
    ').appendTo($container.find('.h5p-content-controls')); var keyup, disableSemiFullscreen = function () { - $disable.remove(); + $disable.remove(); $body.unbind('keyup', keyup); done('h5p-semi-fullscreen'); }; @@ -241,7 +242,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body) { } else { // Create real fullscreen. - + before('h5p-fullscreen'); var first, eventName = (H5P.fullScreenBrowserPrefix === 'ms' ? 'MSFullscreenChange' : H5P.fullScreenBrowserPrefix + 'fullscreenchange'); document.addEventListener(eventName, function () { @@ -251,7 +252,7 @@ H5P.fullScreen = function ($element, instance, exitCallback, body) { entered(); return; } - + // We are exiting fullscreen done('h5p-fullscreen'); document.removeEventListener(eventName, arguments.callee, false); @@ -282,26 +283,26 @@ H5P.getPath = function (path, contentId) { var hasProtocol = function (path) { return path.match(/^[a-z0-9]+:\/\//i); }; - + if (hasProtocol(path)) { return path; } - + if (contentId !== undefined) { prefix = H5PIntegration.getContentPath(contentId); } - else if (window['H5PEditor'] !== undefined) { + else if (window.H5PEditor !== undefined) { prefix = H5PEditor.filesPath; } else { return; } - + if (!hasProtocol(prefix)) { prefix = window.parent.location.protocol + "//" + window.parent.location.host + prefix; } - - return prefix + '/' + path; + + return prefix + '/' + path; }; /** @@ -318,7 +319,7 @@ H5P.getContentPath = function (contentId) { /** * Get library class constructor from H5P by classname. - * Note that this class will only work for resolve "H5P.NameWithoutDot". + * Note that this class will only work for resolve "H5P.NameWithoutDot". * Also check out: H5P.newRunnable * * Used from libraries to construct instances of other libraries' objects by name. @@ -336,34 +337,36 @@ H5P.classFromName = function (name) { * * TODO: Should we check if version matches the library? * TODO: Dynamically try to load libraries currently not loaded? That will require a callback. - * + * * @param {Object} library Library/action object form params. - * @param {Number} contentId + * @param {Number} contentId * @param {jQuery} $attachTo An optional element to attach the instance to. * @param {Boolean} skipResize Optionally skip triggering of the resize event after attaching. * @return {Object} Instance. */ H5P.newRunnable = function (library, contentId, $attachTo, skipResize) { + var nameSplit, versionSplit; try { - var nameSplit = library.library.split(' ', 2); - var versionSplit = nameSplit[1].split('.', 2); + nameSplit = library.library.split(' ', 2); + versionSplit = nameSplit[1].split('.', 2); } catch (err) { return H5P.error('Invalid library string: ' + library.library); } - + if ((library.params instanceof Object) !== true || (library.params instanceof Array) === true) { H5P.error('Invalid library params for: ' + library.library); return H5P.error(library.params); } - + // Find constructor function + var constructor; try { nameSplit = nameSplit[0].split('.'); - var constructor = window; - for (var i = 0; i < nameSplit.length; i++) { + constructor = window; + for (var i = 0; i < nameSplit.length; i++) { constructor = constructor[nameSplit[i]]; - }; + } if (typeof constructor !== 'function') { throw null; } @@ -371,16 +374,16 @@ H5P.newRunnable = function (library, contentId, $attachTo, skipResize) { catch (err) { return H5P.error('Unable to find constructor for: ' + library.library); } - + var instance = new constructor(library.params, contentId); - + if (instance.$ === undefined) { instance.$ = H5P.jQuery(instance); } - + if ($attachTo !== undefined) { instance.attach($attachTo); - + if (skipResize === undefined || !skipResize) { // Resize content. instance.$.trigger('resize'); @@ -417,18 +420,18 @@ H5P.t = function (key, vars, ns) { if (H5PIntegration.i18n[ns] === undefined) { return '[Missing translation namespace "' + ns + '"]'; } - + if (H5PIntegration.i18n[ns][key] === undefined) { return '[Missing translation "' + key + '" in "' + ns + '"]'; } var translation = H5PIntegration.i18n[ns][key]; - + if (vars !== undefined) { // Replace placeholder with variables. for (var placeholder in vars) { translation = translation.replace(placeholder, vars[placeholder]); - } + } } return translation; @@ -457,7 +460,7 @@ H5P.Dialog = function (name, title, content, $element) { }) .end() .end(); - + this.open = function () { setTimeout(function () { $dialog.addClass('h5p-open'); // Fade in @@ -465,7 +468,7 @@ H5P.Dialog = function (name, title, content, $element) { H5P.jQuery(self).trigger('dialog-opened', [$dialog]); }, 1); }; - + this.close = function () { $dialog.removeClass('h5p-open'); // Fade out setTimeout(function () { @@ -489,7 +492,7 @@ H5P.openCopyrightsDialog = function ($element, instance) { if (copyrights === undefined || copyrights === '') { copyrights = H5P.t('noCopyrights'); } - + var dialog = new H5P.Dialog('copyrights', H5P.t('copyrightInformation'), copyrights, $element); dialog.open(); }; @@ -503,12 +506,12 @@ H5P.openCopyrightsDialog = function ($element, instance) { */ H5P.openEmbedDialog = function ($element, embedCode) { var dialog = new H5P.Dialog('embed', H5P.t('embed'), '', $element); - + // Selecting embed code when dialog is opened H5P.jQuery(dialog).on('dialog-opened', function (event, $dialog) { $dialog.find('.h5p-embed-code-container').select(); }); - + dialog.open(); }; @@ -519,7 +522,7 @@ H5P.ContentCopyrights = function () { var label; var media = []; var content = []; - + /** * Public. Set label. * @@ -528,7 +531,7 @@ H5P.ContentCopyrights = function () { this.setLabel = function (newLabel) { label = newLabel; }; - + /** * Public. Add sub content. * @@ -539,7 +542,7 @@ H5P.ContentCopyrights = function () { media.push(newMedia); } }; - + /** * Public. Add sub content. * @@ -550,7 +553,7 @@ H5P.ContentCopyrights = function () { content.push(newContent); } }; - + /** * Public. Print content copyright. * @@ -558,28 +561,28 @@ H5P.ContentCopyrights = function () { */ this.toString = function () { var html = ''; - + // Add media rights for (var i = 0; i < media.length; i++) { html += media[i]; } - + // Add sub content rights - for (var i = 0; i < content.length; i++) { + for (i = 0; i < content.length; i++) { html += content[i]; } - - + + if (html !== '') { // Add a label to this info if (label !== undefined) { html = '

    ' + label + '

    ' + html; } - + // Add wrapper html = '
    ' + html + '
    '; } - + return html; }; }; @@ -595,35 +598,35 @@ H5P.ContentCopyrights = function () { H5P.MediaCopyright = function (copyright, labels, order, extraFields) { var thumbnail; var list = new H5P.DefinitionList(); - + /** * Private. Get translated label for field. * * @param {String} fieldName - * @return {String} + * @return {String} */ var getLabel = function (fieldName) { if (labels === undefined || labels[fieldName] === undefined) { return H5P.t(fieldName); } - + return labels[fieldName]; }; - + /** * Private. Get humanized value for field. * * @param {String} fieldName - * @return {String} + * @return {String} */ var humanizeValue = function (fieldName, value) { if (fieldName === 'license') { return H5P.copyrightLicenses[value]; } - + return value; }; - + if (copyright !== undefined) { // Add the extra fields for (var field in extraFields) { @@ -631,12 +634,12 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) { copyright[field] = extraFields[field]; } } - + if (order === undefined) { // Set default order order = ['title', 'author', 'year', 'source', 'license']; } - + for (var i = 0; i < order.length; i++) { var fieldName = order[i]; if (copyright[fieldName] !== undefined) { @@ -644,7 +647,7 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) { } } } - + /** * Public. Set thumbnail. * @@ -653,7 +656,7 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) { this.setThumbnail = function (newThumbnail) { thumbnail = newThumbnail; }; - + /** * Public. Checks if this copyright is undisclosed. * I.e. only has the license attribute set, and it's undisclosed. @@ -669,7 +672,7 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) { } return false; }; - + /** * Public. Print media copyright. * @@ -677,20 +680,20 @@ H5P.MediaCopyright = function (copyright, labels, order, extraFields) { */ this.toString = function () { var html = ''; - + if (this.undisclosed()) { return html; // No need to print a copyright with a single undisclosed license. } - + if (thumbnail !== undefined) { html += thumbnail; } html += list; - + if (html !== '') { html = ''; } - + return html; }; }; @@ -742,16 +745,16 @@ H5P.Field = function (label, value) { * Public. Get field label. * * @returns {String} - */ + */ this.getLabel = function () { return label; }; - + /** * Public. Get field value. * * @returns {String} - */ + */ this.getValue = function () { return value; }; @@ -762,7 +765,7 @@ H5P.Field = function (label, value) { */ H5P.DefinitionList = function () { var fields = []; - + /** * Public. Add field to list. * @@ -771,7 +774,7 @@ H5P.DefinitionList = function () { this.add = function (field) { fields.push(field); }; - + /** * Public. Get Number of fields. * @@ -780,7 +783,7 @@ H5P.DefinitionList = function () { this.size = function () { return fields.length; }; - + /** * Public. Get field at given index. * @@ -790,7 +793,7 @@ H5P.DefinitionList = function () { this.get = function (index) { return fields[index]; }; - + /** * Public. Print definition list. * @@ -879,7 +882,7 @@ H5P.getLibraryPath = function (library) { /** * Recursivly clone the given object. - * TODO: Consider if this needs to be in core. Doesn't $.extend do the same? + * TODO: Consider if this needs to be in core. Doesn't $.extend do the same? * * @param {object} object Object to clone. * @param {type} recursive