PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.1.7.3
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.1.7.3
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.1.7.3, at assets/js/dist/admin/pages/widgets.js

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