PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.2.0
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.2.0
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / assets / js / dist / admin / pages / widgets.js

widgets.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.2.0, at assets/js/dist/admin/pages/widgets.js

65 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 var __webpack_exports__ = {};
3 /*!***************************************************!*\
4 !*** ./assets/src/apps/js/admin/pages/widgets.js ***!
5 \***************************************************/
6 const $ = jQuery;
7 function formatCourse(repo) {
8 if (repo.loading) {
9 return repo.text;
10 }
11 const markup = "<div class='select2-result-course_title'>" + repo.id + ' - ' + repo.title.rendered + '</div>';
12 return markup;
13 }
14 function formatCourseSelection(repo) {
15 return repo.title.rendered || repo.text;
16 }
17 function autocompleteWidget() {
18 let widget = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
19 const searchs = $('.lp-widget_select_course');
20 const wpRestUrl = searchs.data('rest-url');
21 const postType = searchs.data('post_type') || 'lp_course';
22 searchs.select2({
23 ajax: {
24 method: 'GET',
25 url: wpRestUrl + 'wp/v2/' + postType,
26 dataType: 'json',
27 delay: 250,
28 data(params) {
29 return {
30 search: params.term
31 };
32 },
33 processResults(data, params) {
34 params.page = params.page || 1;
35 return {
36 results: data
37 };
38 },
39 cache: true
40 },
41 escapeMarkup(markup) {
42 return markup;
43 },
44 minimumInputLength: 2,
45 templateResult: formatCourse,
46 // omitted for brevity, see the source of this page
47 templateSelection: formatCourseSelection // omitted for brevity, see the source of this page
48 });
49 }
50
51 document.addEventListener('DOMContentLoaded', function (event) {
52 if (document.querySelector('#widgets-editor')) {
53 $(document).on('widget-added', function (event, widget) {
54 autocompleteWidget(widget);
55 });
56 } else {
57 $(document).on('learnpress/widgets/select', function () {
58 autocompleteWidget();
59 });
60 autocompleteWidget();
61 }
62 });
63 /******/ })()
64 ;
65 //# sourceMappingURL=widgets.js.map