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

119 lines 3.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /*!***************************************************!*\
3 !*** ./assets/src/apps/js/admin/pages/widgets.js ***!
4 \***************************************************/
5 const $ = jQuery;
6 function formatCourse(repo) {
7 if (repo.loading) {
8 return repo.text;
9 }
10 const markup = "<div class='select2-result-course_title'>" + repo.id + ' - ' + repo.title.rendered + '</div>';
11 return markup;
12 }
13 function formatCourseSelection(repo) {
14 return repo.title.rendered || repo.text;
15 }
16
17 /*function autocompleteWidget( widget = null ) {
18 const searchs = $( '.lp-widget_select_course' );
19 const wpRestUrl = searchs.data( 'rest-url' );
20 const postType = searchs.data( 'post_type' ) || 'lp_course';
21
22 if ( postType === 'lp_course' ) {
23 const dataStruct = {
24 urlApi: Api.admin.apiSearchCourses,
25 dataType: 'courses',
26 keyGetValue: {
27 value: 'ID',
28 text: '{{post_title}} (#{{ID}})',
29 key_render: {
30 post_title: 'post_title',
31 ID: 'ID',
32 },
33 },
34 };
35 const dataStructJson = JSON.stringify( dataStruct );
36 const widgetListEl = document.querySelector( '#widget-list' );
37 let nonTomSelectWidgetEls = '';
38 if ( widgetListEl ) {
39 const tomSelectWidgetEls = Array.prototype.slice.call( widgetListEl.querySelectorAll( '.lp-widget_select_course' ) );
40 nonTomSelectWidgetEls = Array.prototype.slice.call( searchs ).filter( ( el ) => ! tomSelectWidgetEls.includes( el ) );
41 }
42
43 nonTomSelectWidgetEls.forEach( ( nonTomSelectWidgetEl ) => {
44 $( nonTomSelectWidgetEl ).attr( 'data-struct', dataStructJson );
45 initTomSelect( nonTomSelectWidgetEl );
46 } );
47 } else {
48 searchs.select2( {
49 ajax: {
50 method: 'GET',
51 url: wpRestUrl + 'wp/v2/' + postType,
52 dataType: 'json',
53 delay: 250,
54 data( params ) {
55 return {
56 search: params.term,
57 };
58 },
59 processResults( data, params ) {
60 params.page = params.page || 1;
61
62 return {
63 results: data,
64 };
65 },
66 cache: true,
67 },
68 escapeMarkup( markup ) {
69 return markup;
70 },
71 minimumInputLength: 2,
72 templateResult: formatCourse, // omitted for brevity, see the source of this page
73 templateSelection: formatCourseSelection, // omitted for brevity, see the source of this page
74 } );
75 }
76 }*/
77
78 document.addEventListener('DOMContentLoaded', function (event) {
79 if (document.querySelector('#widgets-editor')) {
80 $(document).on('widget-added', function (event, widget) {
81 //autocompleteWidget( widget );
82 });
83 } else {
84 $(document).on('learnpress/widgets/select', function () {
85 //autocompleteWidget();
86 sortItem();
87 });
88
89 //autocompleteWidget();
90 }
91 });
92
93 //Sortable checkbox
94 document.addEventListener('DOMContentLoaded', function (event) {
95 sortItem();
96 });
97 $(document).on('widget-added widget-updated', function (event) {
98 sortItem();
99 });
100 function sortItem() {
101 $('.widget-content .sortable').sortable({
102 handle: '.drag',
103 start(event, ui) {},
104 update(event, ui) {
105 const value = [];
106 $(this).children().map(function () {
107 value.push($(this).find('input').val());
108 });
109 value.join(',');
110 const fieldSort = $(this).closest('.widget-content').find('input.fields-sort');
111 fieldSort.val(value);
112 fieldSort.trigger('change');
113 },
114 stop(event, ui) {}
115 });
116 }
117 /******/ })()
118 ;
119 //# sourceMappingURL=widgets.js.map