-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
better approach to fixing jquery issue
- Loading branch information
1 parent
64055cb
commit 4e1d933
Showing
5 changed files
with
39 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 11 additions & 15 deletions
26
sourcecode/apis/contentauthor/resources/assets/entrypoints/h5p-core-bundle.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,11 @@ | ||
import jQuery from 'jquery'; | ||
|
||
window.H5P = window.H5P || {}; | ||
window.H5P.jQuery = jQuery; | ||
|
||
// do not replace these with imports | ||
require('../../../vendor/h5p/h5p-core/js/h5p.js'); | ||
require('../../../vendor/h5p/h5p-core/js/h5p-event-dispatcher.js'); | ||
require('../../../vendor/h5p/h5p-core/js/h5p-x-api-event.js'); | ||
require('../../../vendor/h5p/h5p-core/js/h5p-x-api.js'); | ||
require('../../../public/js/h5p/core-override/h5p-content-type.js'); //TODO Replaced to support patch-version in library folder name. Used by libraries to loads assets that is not js or css | ||
require('../../../vendor/h5p/h5p-core/js/h5p-confirmation-dialog.js'); | ||
require('../../../vendor/h5p/h5p-core/js/h5p-action-bar.js'); | ||
require('../../../public/js/h5p/core-override/request-queue.js'); //TODO Change to vanilla H5P when they fix https://github.com/h5p/h5p-php-library/pull/66 | ||
require('../../../vendor/h5p/h5p-core/js/h5p-tooltip.js'); | ||
import '../js/core-override/h5p-jquery.js'; | ||
import '../../../vendor/h5p/h5p-core/js/h5p.js'; | ||
import '../../../vendor/h5p/h5p-core/js/h5p.js'; | ||
import '../../../vendor/h5p/h5p-core/js/h5p-event-dispatcher.js'; | ||
import '../../../vendor/h5p/h5p-core/js/h5p-x-api-event.js'; | ||
import '../../../vendor/h5p/h5p-core/js/h5p-x-api.js'; | ||
import '../js/core-override/h5p-content-type.js'; //TODO Replaced to support patch-version in library folder name. Used by libraries to loads assets that is not js or css | ||
import '../../../vendor/h5p/h5p-core/js/h5p-confirmation-dialog.js'; | ||
import '../../../vendor/h5p/h5p-core/js/h5p-action-bar.js'; | ||
import '../js/core-override/request-queue.js'; //TODO Change to vanilla H5P when they fix https://github.com/h5p/h5p-php-library/pull/66 | ||
import '../../../vendor/h5p/h5p-core/js/h5p-tooltip.js'; |
2 changes: 2 additions & 0 deletions
2
.../js/h5p/core-override/h5p-content-type.js → ...sets/js/core-override/h5p-content-type.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
sourcecode/apis/contentauthor/resources/assets/js/core-override/h5p-jquery.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import jQuery from "jquery"; | ||
|
||
const H5P = window.H5P = window.H5P || {}; | ||
H5P.jQuery = jQuery; | ||
|
||
const originalLoad = jQuery.fn.load; | ||
|
||
// Copied from h5p-php-library | ||
H5P.jQuery.fn.load = function (url, params, callback) { | ||
/** | ||
* NOTE: | ||
* This is needed in order to support old libraries that uses the .load() function | ||
* for elements in the deprecated jQuery way (elem.load(fn)), the correct way to do this | ||
* now is elem.on('load', fn) | ||
*/ | ||
if (typeof url === "function") { | ||
console.warn('You are using a deprecated H5P library. Please upgrade!'); | ||
let args = Array.prototype.slice.call(arguments); | ||
args.unshift('load'); | ||
return window.H5P.jQuery.fn.on.apply(this, args); | ||
} | ||
|
||
return originalLoad.apply(this, arguments); | ||
} |
2 changes: 2 additions & 0 deletions
2
...lic/js/h5p/core-override/request-queue.js → .../assets/js/core-override/request-queue.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
const H5P = window.H5P = window.H5P || {}; | ||
|
||
/** | ||
* Queue requests and handle them at your convenience | ||
* | ||
|