PluginProbe
Sight – Professional Image Gallery and Portfolio / 1.1.0
Sight – Professional Image Gallery and Portfolio v1.1.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8
sight / elementor / assets / custom-post.js

custom-post.js in Sight – Professional Image Gallery and Portfolio 1.1.0, at elementor/assets/custom-post.js

70 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ( function( $ ) {
2
3 $( document ).ready( function() {
4
5 var customPostView = elementor.modules.controls.BaseData.extend( {
6 onReady: function() {
7
8 var self = this;
9
10 $( self.el ).find( 'select' ).select2( {
11 ajax: {
12 url: cpConfig.ajaxurl,
13 dataType: 'json',
14 delay: 250,
15 data: function( params ) {
16 var query = {
17 posts_per_page: 10,
18 q: params.term,
19 paged: params.page || 1,
20 action: 'handler_custom_posts'
21 };
22
23 return query;
24 },
25 processResults: function (data, params) {
26 params.page = params.page || 1;
27
28 return {
29 results: data.results,
30 pagination: {
31 more: data.more
32 }
33 };
34 },
35 cache: true
36 },
37 allowClear: true,
38 minimumInputLength: 3,
39 placeholder : 'Select post',
40 templateSelection: function(state){
41 var $state = state;
42
43 if ( !isNaN( state.text.trim() ) ) {
44 $state = $.ajax({
45 global: false,
46 type: "POST",
47 url: cpConfig.ajaxurl,
48 dataType: 'json',
49 delay: 250,
50 data: {
51 post_id: state.text.trim(),
52 action: 'handler_post_title'
53 },
54 async:false
55 } ).responseText;
56 } else {
57 $state = state.text;
58 }
59
60 return $state;
61 },
62 } );
63
64 },
65 } );
66
67 elementor.addControlView( 'custom_post', customPostView );
68 } );
69 } )( jQuery );
70