Skip to content

Commit

Permalink
Bugfix displayOptions was not working
Browse files Browse the repository at this point in the history
  • Loading branch information
Jakeii committed May 9, 2018
1 parent edd1522 commit c4229f4
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 79 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# h5p-standalone
# h5p-standalone 1.3.3
Display H5P content with plain old HTML

## Usage
Expand All @@ -14,7 +14,8 @@ $('.h5p-container').h5p({
copyright: true,
embed: false,
download: false,
icon: true
icon: true,
export: false
}
});
```
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.3.2",
"version": "1.3.3",
"homepage": "https://github.com/tunapanda/h5p-standalone",
"authors": [
"Jake Lee Kennedy <jake@tunapanda.org>"
Expand Down
55 changes: 35 additions & 20 deletions dist/js/h5p-standalone-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -10081,27 +10081,42 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = [
});
};

$.fn.h5p = function (options) {

options.id = options.id || 1;

this.append("<div class=\"h5p-iframe-wrapper\" style=\"background-color:#DDD;\">\n <iframe id=\"h5p-iframe-" + options.id + "\" class=\"h5p-iframe\" data-content-id=\"" + options.id + "\" style=\"width: 100%; height: 100%; border: none; display: block;\" src=\"about:blank\" frameBorder=\"0\"></iframe>\n </div>");

options.frameJs = options.frameJs || 'dist/h5p-standalone-frame.min.js';
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;
$.fn.h5p = function () {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$id = _ref.id,
id = _ref$id === undefined ? 1 : _ref$id,
_ref$frameJs = _ref.frameJs,
frameJs = _ref$frameJs === undefined ? 'dist/h5p-standalone-frame.min.js' : _ref$frameJs,
_ref$frameCss = _ref.frameCss,
frameCss = _ref$frameCss === undefined ? 'dist/css/h5p.css' : _ref$frameCss,
_ref$h5pContent = _ref.h5pContent,
h5pContent = _ref$h5pContent === undefined ? 'workspace' : _ref$h5pContent,
_ref$displayOptions = _ref.displayOptions,
displayOptions = _ref$displayOptions === undefined ? {} : _ref$displayOptions;

var _displayOptions$frame = displayOptions.frame;
displayOptions.frame = _displayOptions$frame === undefined ? true : _displayOptions$frame;
var _displayOptions$copyr = displayOptions.copyright;
displayOptions.copyright = _displayOptions$copyr === undefined ? true : _displayOptions$copyr;
var _displayOptions$embed = displayOptions.embed;
displayOptions.embed = _displayOptions$embed === undefined ? true : _displayOptions$embed;
var _displayOptions$downl = displayOptions.download;
displayOptions.download = _displayOptions$downl === undefined ? true : _displayOptions$downl;
var _displayOptions$icon = displayOptions.icon;
displayOptions.icon = _displayOptions$icon === undefined ? true : _displayOptions$icon;
var _displayOptions$expor = displayOptions.export;
displayOptions.export = _displayOptions$expor === undefined ? true : _displayOptions$expor;


this.append("<div class=\"h5p-iframe-wrapper\" style=\"background-color:#DDD;\">\n <iframe id=\"h5p-iframe-" + id + "\" class=\"h5p-iframe\" data-content-id=\"" + id + "\" style=\"width: 100%; height: 100%; border: none; display: block;\" src=\"about:blank\" frameBorder=\"0\"></iframe>\n </div>");

// options.frameJs = options.frameJs || 'dist/h5p-standalone-frame.min.js';
// options.frameCss = options.frameCss || 'dist/css/h5p.css';
// options.h5pContent = options.h5pContent || 'workspace';

H5PIntegration.core = {
styles: [options.frameCss],
scripts: [options.frameJs
styles: [frameCss],
scripts: [frameJs
// 'bower_components/jquery/dist/jquery.js',
// 'lib/js/h5p-jquery.js',
// 'bower_components/h5p-php-library/js/h5p-content-type.js',
Expand All @@ -10113,7 +10128,7 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = [
]
};

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

Large diffs are not rendered by default.

7 changes: 1 addition & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "h5p-standalone",
"version": "1.3.2",
"version": "1.3.3",
"description": "Display H5P content as standalone frontend code, no server needed.",
"main": "dist/js/h5p-standalone-main.min.js",
"dependencies": {
Expand Down
51 changes: 23 additions & 28 deletions src/js/h5pintegration.es6
Original file line number Diff line number Diff line change
Expand Up @@ -172,41 +172,36 @@
});
};

$.fn.h5p = function (options) {

options.id = options.id || 1;
$.fn.h5p = function ({
id = 1,
frameJs = 'dist/h5p-standalone-frame.min.js',
frameCss = 'dist/css/h5p.css',
h5pContent = 'workspace',
displayOptions = {}
} = {}) {

({
frame: displayOptions.frame = true,
copyright: displayOptions.copyright = true,
embed: displayOptions.embed = true,
download: displayOptions.download = true,
icon: displayOptions.icon = true,
export: displayOptions.export = true
} = displayOptions);

this.append(`<div class="h5p-iframe-wrapper" style="background-color:#DDD;">
<iframe id="h5p-iframe-${options.id}" class="h5p-iframe" data-content-id="${options.id}" style="width: 100%; height: 100%; border: none; display: block;" src="about:blank" frameBorder="0"></iframe>
<iframe id="h5p-iframe-${id}" class="h5p-iframe" data-content-id="${id}" style="width: 100%; height: 100%; border: none; display: block;" src="about:blank" frameBorder="0"></iframe>
</div>`);

options.frameJs = options.frameJs || 'dist/h5p-standalone-frame.min.js';
options.frameCss = options.frameCss || 'dist/css/h5p.css';
options.h5pContent = options.h5pContent || 'workspace';

let 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;
// options.frameJs = options.frameJs || 'dist/h5p-standalone-frame.min.js';
// options.frameCss = options.frameCss || 'dist/css/h5p.css';
// options.h5pContent = options.h5pContent || 'workspace';

H5PIntegration.core = {
styles: [options.frameCss],
scripts: [
options.frameJs
// 'bower_components/jquery/dist/jquery.js',
// 'lib/js/h5p-jquery.js',
// 'bower_components/h5p-php-library/js/h5p-content-type.js',
// 'bower_components/h5p-php-library/js/h5p-event-dispatcher.js',
// 'bower_components/h5p-php-library/js/h5p-x-api-event.js',
// 'bower_components/h5p-php-library/js/h5p-x-api.js',
// 'bower_components/h5p-php-library/js/h5p.js',
// 'lib/js/h5p-overwrite.js'
]
styles: [frameCss],
scripts: [frameJs]
};

H5PIntegration.init(options.id, options.h5pContent, displayOptions);
H5PIntegration.init(id, h5pContent, displayOptions);
}
})(H5P.jQuery);
55 changes: 35 additions & 20 deletions src/js/h5pintegration.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,27 +199,42 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = [
});
};

$.fn.h5p = function (options) {

options.id = options.id || 1;

this.append("<div class=\"h5p-iframe-wrapper\" style=\"background-color:#DDD;\">\n <iframe id=\"h5p-iframe-" + options.id + "\" class=\"h5p-iframe\" data-content-id=\"" + options.id + "\" style=\"width: 100%; height: 100%; border: none; display: block;\" src=\"about:blank\" frameBorder=\"0\"></iframe>\n </div>");

options.frameJs = options.frameJs || 'dist/h5p-standalone-frame.min.js';
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;
$.fn.h5p = function () {
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref$id = _ref.id,
id = _ref$id === undefined ? 1 : _ref$id,
_ref$frameJs = _ref.frameJs,
frameJs = _ref$frameJs === undefined ? 'dist/h5p-standalone-frame.min.js' : _ref$frameJs,
_ref$frameCss = _ref.frameCss,
frameCss = _ref$frameCss === undefined ? 'dist/css/h5p.css' : _ref$frameCss,
_ref$h5pContent = _ref.h5pContent,
h5pContent = _ref$h5pContent === undefined ? 'workspace' : _ref$h5pContent,
_ref$displayOptions = _ref.displayOptions,
displayOptions = _ref$displayOptions === undefined ? {} : _ref$displayOptions;

var _displayOptions$frame = displayOptions.frame;
displayOptions.frame = _displayOptions$frame === undefined ? true : _displayOptions$frame;
var _displayOptions$copyr = displayOptions.copyright;
displayOptions.copyright = _displayOptions$copyr === undefined ? true : _displayOptions$copyr;
var _displayOptions$embed = displayOptions.embed;
displayOptions.embed = _displayOptions$embed === undefined ? true : _displayOptions$embed;
var _displayOptions$downl = displayOptions.download;
displayOptions.download = _displayOptions$downl === undefined ? true : _displayOptions$downl;
var _displayOptions$icon = displayOptions.icon;
displayOptions.icon = _displayOptions$icon === undefined ? true : _displayOptions$icon;
var _displayOptions$expor = displayOptions.export;
displayOptions.export = _displayOptions$expor === undefined ? true : _displayOptions$expor;


this.append("<div class=\"h5p-iframe-wrapper\" style=\"background-color:#DDD;\">\n <iframe id=\"h5p-iframe-" + id + "\" class=\"h5p-iframe\" data-content-id=\"" + id + "\" style=\"width: 100%; height: 100%; border: none; display: block;\" src=\"about:blank\" frameBorder=\"0\"></iframe>\n </div>");

// options.frameJs = options.frameJs || 'dist/h5p-standalone-frame.min.js';
// options.frameCss = options.frameCss || 'dist/css/h5p.css';
// options.h5pContent = options.h5pContent || 'workspace';

H5PIntegration.core = {
styles: [options.frameCss],
scripts: [options.frameJs
styles: [frameCss],
scripts: [frameJs
// 'bower_components/jquery/dist/jquery.js',
// 'lib/js/h5p-jquery.js',
// 'bower_components/h5p-php-library/js/h5p-content-type.js',
Expand All @@ -231,6 +246,6 @@ var _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = [
]
};

H5PIntegration.init(options.id, options.h5pContent, displayOptions);
H5PIntegration.init(id, h5pContent, displayOptions);
};
})(H5P.jQuery);

0 comments on commit c4229f4

Please sign in to comment.