diff --git a/h5p.classes.php b/h5p.classes.php index 122c14d..b647efb 100644 --- a/h5p.classes.php +++ b/h5p.classes.php @@ -246,6 +246,16 @@ interface H5PFrameworkInterface { * Check if export is enabled. */ public function isExportEnabled(); + + /** + * Defines getEditorLibraries. + * + * @param $machineName Library identifier. + * @param $majorVersion Library identfier. + * @param $minorVersion Library identfier. + * @return array Editor libraries? + */ + public function getEditorLibraries($machineName, $majorVersion, $minorVersion, $complete = FALSE); } /** @@ -1121,7 +1131,7 @@ Class H5PExport { // Build h5p.json $h5pJson = array ( 'title' => $title, - 'language' => $exportData['language'] ? $exportData['language'] : 'und', + 'language' => $language ? $language : 'und', 'mainLibrary' => $exportData['mainLibrary'], 'embedTypes' => $embedTypes, ); @@ -1145,8 +1155,8 @@ Class H5PExport { } // Add preloaded and dynamic dependencies if they exist - if ($preloadedDependencies) { $h5pJson['preloadedDependencies'] = $preloadedDependencies; } - if ($dynamicDependencies) { $h5pJson['dynamicDependencies'] = $dynamicDependencies; } + if (isset($preloadedDependencies)) { $h5pJson['preloadedDependencies'] = $preloadedDependencies; } + if (isset($dynamicDependencies)) { $h5pJson['dynamicDependencies'] = $dynamicDependencies; } // Save h5p.json $results = print_r(json_encode($h5pJson), true); @@ -1198,7 +1208,7 @@ Class H5PExport { $h5pDir = $this->h5pF->getH5pPath() . DIRECTORY_SEPARATOR; $zipPath = $h5pDir . 'exports' . DIRECTORY_SEPARATOR . $contentId . '.h5p'; if (file_exists($zipPath)) { - file_delete($zipPath); + unlink($zipPath); } } diff --git a/images/h5p_logo.png b/images/h5p_logo.png new file mode 100644 index 0000000..4fb7864 Binary files /dev/null and b/images/h5p_logo.png differ diff --git a/images/h5p_logo.svg b/images/h5p_logo.svg new file mode 100644 index 0000000..7777c56 --- /dev/null +++ b/images/h5p_logo.svg @@ -0,0 +1,26 @@ + + + + + + + + + + + + + + + + + diff --git a/js/h5p.js b/js/h5p.js index 17ede95..5edcafa 100644 --- a/js/h5p.js +++ b/js/h5p.js @@ -33,7 +33,7 @@ H5P.init = function () { else if (document.documentElement.mozRequestFullScreen) { H5P.fullScreenBrowserPrefix = 'moz'; } - else if (document.documentElement.msRequestFullScreen) { + else if (document.documentElement.msRequestFullscreen) { H5P.fullScreenBrowserPrefix = 'ms'; } } @@ -65,24 +65,30 @@ H5P.init = function () { var $iframe = H5P.jQuery(iframe), contentId = $iframe.data('content-id'), mainLibrary = $iframe.data('class'); + + $iframe.ready(function () { + // This is a bit hacky but necessary until libraries runs callbacks or similar when "done" or resizing or something. + resizeIframeInterval = setInterval(function () { + var $doc = $iframe.contents(); + var contentHeight = $doc.height(); + var frameHeight = $iframe.innerHeight(); + + if (frameHeight !== contentHeight) { + H5P.resizeIframe(contentId, contentHeight); + $doc[0].documentElement.style.margin = '0 0 1px 0'; + } + else { + // Small trick to make scrollbars go away in ie. + $doc[0].documentElement.style.margin = '0 0 0 0'; + } + + }, 300); + }); iframe.contentDocument.open(); iframe.contentDocument.write('' + H5PIntegration.getHeadTags(contentId) + '
'); iframe.contentDocument.close(); }); - - // TODO: This seems very hacky... why can't we just use the resize event? What happens if we ain't done before the next interval starts? - setInterval(function () { - $h5pIframes.each(function (idx, iframe) { - var $iframe = H5P.jQuery(iframe); - var contentHeight = $iframe.contents().height(); - var frameHeight = $iframe.innerHeight(); - - if (frameHeight !== contentHeight) { - H5P.resizeIframe($iframe.data('content-id'), contentHeight); - } - }); - }, 250); } }; @@ -175,7 +181,7 @@ H5P.fullScreen = function ($el, obj, exitCallback, $body) { $body.keyup(keyup); } else { - var first, eventName = H5P.fullScreenBrowserPrefix + 'fullscreenchange'; + var first, eventName = (H5P.fullScreenBrowserPrefix === 'ms' ? 'MSFullscreenChange' : H5P.fullScreenBrowserPrefix + 'fullscreenchange'); H5P.isFullscreen = true; document.addEventListener(eventName, function () { if (first === undefined) { @@ -203,7 +209,9 @@ H5P.fullScreen = function ($el, obj, exitCallback, $body) { $el[0].requestFullScreen(); } else { - $el[0][H5P.fullScreenBrowserPrefix + 'RequestFullScreen'](H5P.fullScreenBrowserPrefix === 'webkit' ? Element.ALLOW_KEYBOARD_INPUT : undefined); + var method = (H5P.fullScreenBrowserPrefix === 'ms' ? 'msRequestFullscreen' : H5P.fullScreenBrowserPrefix + 'RequestFullScreen'); + var params = (H5P.fullScreenBrowserPrefix === 'webkit' ? Element.ALLOW_KEYBOARD_INPUT : undefined); + $el[0][method](params); } $el.add(H5P.$body).addClass('h5p-fullscreen'); diff --git a/styles/h5p.css b/styles/h5p.css index b9874d6..ca637e6 100644 --- a/styles/h5p.css +++ b/styles/h5p.css @@ -27,6 +27,8 @@ div.h5p-semi-fullscreen { top: 0; left: 0; z-index: 101; + width: 100%; + height: 100%; } .h5p-content-controls { @@ -84,7 +86,7 @@ div.h5p-semi-fullscreen { background: -ms-linear-gradient(top, rgba(4,104,206,1) 0%,rgba(100,152,254,1) 100%); /* IE10+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#0468ce', endColorstr='#6498fe',GradientType=0 ); /* IE6-9 */ } -.h5p-iframe-wrapper.h5p-fullscreen { +div.h5p-fullscreen { width: 100%; height: 100%; } @@ -167,3 +169,50 @@ body.h5p-iframe-content div.h5p-content { body.h5p-iframe-content.h5p-fullscreen div.h5p-content { height: 100%; } + +.h5p-export { + margin-top: 6px; + display: block; + position: relative; + float: left; + border-radius: 4px; + padding: 4px 58px 3px 12px; + font-weight: 900; + font-family: "Arial Black", Arial, sans-serif; + text-transform: uppercase; + color: white !important; + background-color: #ccc; + box-shadow: 0px 0px 4px #666; +} + +.h5p-export:after { + content: ""; + + display: inline; + width: 45px; + height: 27px; + + position: absolute; + right: 0; + top: 0; + + background-image: url(../images/h5p_logo.png); + background-image: url(../images/h5p_logo.svg), none; + background-repeat: no-repeat; + background-position: left center; +} + +.h5p-export:hover { + text-decoration: none; + color: white; + box-shadow: 0px 0px 6px #333; + background-color: #0092bf; + /* Firefox */ + -moz-transition: all 0.4s ease-in; + /* WebKit */ + -webkit-transition: all 0.4s ease-in; + /* Opera */ + -o-transition: all 0.4s ease-in; + /* Standard */ + transition: all 0.4s ease-in; +}