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 / src / apps / js / admin / editor / fill-in-blanks.js

fill-in-blanks.js in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.2.0, at assets/src/apps/js/admin/editor/fill-in-blanks.js

72 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function( $ ) {
2 window.FIB = {
3
4 getSelectedText: function getSelectedText() {
5 let html = '';
6 if ( typeof window.getSelection !== 'undefined' ) {
7 const sel = window.getSelection();
8 if ( sel.rangeCount ) {
9 const container = document.createElement( 'div' );
10 for ( let i = 0, len = sel.rangeCount; i < len; ++i ) {
11 container.appendChild( sel.getRangeAt( i ).cloneContents() );
12 }
13 html = container.innerHTML;
14 }
15 } else if ( typeof document.selection !== 'undefined' ) {
16 if ( document.selection.type === 'Text' ) {
17 html = document.selection.createRange().htmlText;
18 }
19 }
20 return html;
21 },
22
23 createTextNode( content ) {
24 return document.createTextNode( content );
25 },
26
27 isContainHtml: function isContainHtml( content ) {
28 const $el = $( content ),
29 sel = 'b.fib-blank';
30 return $el.is( sel ) || $el.find( sel ).length || $el.parent().is( sel );
31 },
32
33 getSelectionRange: function getSelectionRange() {
34 let t = '';
35 if ( window.getSelection ) {
36 t = window.getSelection();
37 } else if ( document.getSelection ) {
38 t = document.getSelection();
39 } else if ( document.selection ) {
40 t = document.selection.createRange().text;
41 }
42 return t;
43 },
44
45 outerHTML( $dom ) {
46 return $( '<div>' ).append( $( $dom ).clone() ).html();
47 },
48
49 doUpgrade( callback ) {
50 $.ajax( {
51 url: '',
52 data: {
53 'lp-ajax': 'fib-upgrade',
54 },
55 success( res ) {
56 console.log( res );
57 callback && callback.call( res );
58 },
59 } );
60 },
61 };
62
63 $( document ).ready( function() {
64 $( '#do-upgrade-fib' ).on( 'click', function() {
65 const $button = $( this ).prop( 'disabled', true ).addClass( 'ajaxloading' );
66 FIB.doUpgrade( function() {
67 $button.prop( 'disabled', false ).removeClass( 'ajaxloading' );
68 } );
69 } );
70 } );
71 }( jQuery ) );
72