PluginProbe
WPGet API – Connect to any external REST API / 1.8.13
WPGet API – Connect to any external REST API v1.8.13
1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.1.0 2.1.1 2.1.3 2.1.4 2.1.5 2.2.0 2.2.1 2.2.10 2.2.2 2.2.3 All 97 releases
wpgetapi / assets / js / wpgetapi-admin.js

wpgetapi-admin.js in WPGet API – Connect to any external REST API 1.8.13, at assets/js/wpgetapi-admin.js

73 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 window.WpGetApi = window.WpGetApi || {};
2
3 (function (window, document, $, wpgetapi, undefined) {
4
5 'use strict';
6
7 /**
8 * Start the JS.
9 */
10 wpgetapi.onReady = function () {
11
12 var $page = wpgetapi.page();
13
14 wpgetapi.functionsHelp();
15
16 $page
17 .on( 'change keyup', '.field-id input', wpgetapi.functionsHelp )
18 .on( 'cmb2_remove_row cmb2_add_row cmb2_shift_row', wpgetapi.functionsHelp );
19
20 }
21
22 /**
23 * Adds the endpoint into the functions help section.
24 */
25 wpgetapi.functionsHelp = function ( e ) {
26
27 // change, keyup, add_row etc
28 if( e && e.type.length > 0 ) {
29
30 var $this = $( this );
31 var $group = $this.parents( '.cmb-repeatable-grouping' );
32
33 // if we are adding a group, clear it
34 if( e.type == 'cmb2_add_row' ) {
35 $group = $( '.cmb-repeatable-grouping' ).last();
36 $group.find( '.functions .endpoint_id' ).html( '' );
37 }
38
39 if( $group.length > 0 )
40 $group.find( '.functions .endpoint_id' ).html( $this.val() );
41
42 } else {
43
44 $('.cmb-repeatable-grouping').each(function( index, value ) {
45
46 var $group = $( this );
47 var endpoint_value = $group.find( '.field-id input' ).val();
48 $group.find( '.functions .endpoint_id' ).html( endpoint_value );
49
50 });
51
52 }
53
54 }
55
56 /**
57 * Gets jQuery object containing all . Caches the result.
58 *
59 * @since 1.0.0
60 *
61 * @return {Object} jQuery object containing all.
62 */
63 wpgetapi.page = function() {
64 if ( wpgetapi.$page ) {
65 return wpgetapi.$page;
66 }
67 wpgetapi.$page = $('.wpgetapi');
68 return wpgetapi.$page;
69 };
70
71 $( wpgetapi.onReady );
72
73 }(window, document, jQuery, window.WpGetApi));