Skip to content

Commit

Permalink
add frame options for hiding download buttons etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakeii committed Mar 23, 2018
1 parent c763be7 commit 9c1f3fa
Show file tree
Hide file tree
Showing 10 changed files with 3,904 additions and 43 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ Display H5P content with plain old HTML

```javascript
$('.h5p-container').h5p({
id: 1, // OPTIONAL id change this if using multiple h5ps on the same page
frameJs: '../dist/js/h5p-standalone-frame.min.js', // OPTIONAL if you move the location of h5p-standalone-frame.min.js
frameCss: '../dist/styles/h5p.css', // OPTIONAL if you move the location of h5p.css
h5pContent: '../workspace' // Location of the unpacked H5P content
h5pContent: '../workspace' // Location of the unpacked H5P content,
displayOptions: { // OPTIONAL hide the frame or download, export etc. buttons they are visible by default
frame: true,
copyright: true,
embed: false,
download: false,
icon: true
}
});
```

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "h5p-standalone",
"version": "1.2.1",
"version": "1.3.0",
"homepage": "https://github.com/tunapanda/h5p-standalone",
"authors": [
"Jake Lee Kennedy <[email protected]>"
Expand Down
5 changes: 1 addition & 4 deletions dist/js/h5p-standalone-frame.min.js

Large diffs are not rendered by default.

32 changes: 21 additions & 11 deletions dist/js/h5p-standalone-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10648,13 +10648,14 @@ return jQuery;
H5P = window.H5P || {};
H5P.jQuery = jQuery.noConflict(true);

/*jshint esnext: true */
"use strict";

var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; })();
var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"]) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError("Invalid attempt to destructure non-iterable instance"); } }; }();

/*jshint esnext: true */
(function ($) {
'use strict';

function getJSONPromise(url) {
return new Promise(function (resolve, reject) {
H5P.jQuery.getJSON(url, resolve).fail(reject);
Expand Down Expand Up @@ -10700,13 +10701,15 @@ var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr =
};

H5PIntegration.init = function (id) {
var pathToContent = arguments.length <= 1 || arguments[1] === undefined ? 'workspace' : arguments[1];
var pathToContent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'workspace';
var displayOptions = arguments[2];


H5PIntegration.url = "" + pathToContent;

var getInfo = getJSONPromise(pathToContent + "/h5p.json");
var getContent = getJSONPromise(pathToContent + "/content/content.json");
var machinePath = undefined;
var machinePath = void 0;
var pathIncludesVersion = true;

var checklibraryPath = getInfo.then(function (h5p) {
Expand Down Expand Up @@ -10798,11 +10801,10 @@ var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr =
});

Promise.all([getInfo, getContent, getLibrary]).then(function (data) {
var _data = _slicedToArray(data, 3);

var h5p = _data[0];
var content = _data[1];
var library = _data[2];
var _data = _slicedToArray(data, 3),
h5p = _data[0],
content = _data[1],
library = _data[2];

var libraryPath = library.machineName + (h5p.pathIncludesVersion ? "-" + library.majorVersion + "." + library.minorVersion : '');
var styles = [];
Expand Down Expand Up @@ -10839,7 +10841,7 @@ var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr =
jsonContent: JSON.stringify(content),
styles: styles,
scripts: scripts,
displayOptions: {}
displayOptions: displayOptions
};

H5P.init();
Expand All @@ -10857,6 +10859,14 @@ var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr =
options.frameCss = options.frameCss || 'dist/css/h5p.css';
options.h5pContent = options.h5pContent || 'workspace';

var displayOptions = options.displayOptions || {};

displayOptions.export = displayOptions.export || true;
displayOptions.frame = displayOptions.frame || true;
displayOptions.copyright = displayOptions.copyright || true;
displayOptions.embed = displayOptions.embed || true;
displayOptions.icon = displayOptions.icon || true;

H5PIntegration.core = {
styles: [options.frameCss],
scripts: [options.frameJs
Expand All @@ -10871,7 +10881,7 @@ var _slicedToArray = (function () { function sliceIterator(arr, i) { var _arr =
]
};

H5PIntegration.init(options.id, options.h5pContent);
H5PIntegration.init(options.id, options.h5pContent, displayOptions);
};
})(H5P.jQuery);
/**
Expand Down
5 changes: 1 addition & 4 deletions dist/js/h5p-standalone-main.min.js

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ gulp.task('clean-dist', function () {

gulp.task('compile-js', ['clean-dist'], function() {
return gulp.src('src/js/h5pintegration.es6')
.pipe(babel())
.pipe(babel({
'presets': ['es2015']
}))
.pipe(gulp.dest('src/js'));
});

Expand Down
Loading

0 comments on commit 9c1f3fa

Please sign in to comment.