PluginProbe
WPGet API – Connect to any external REST API / 1.1.0
WPGet API – Connect to any external REST API v1.1.0
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
← All changes | assets/js/wpgetapi-admin.js +12 -85 2.0.61.1.0 View file →
@@ -11,108 +11,35 @@
11 11
12 12 var $page = wpgetapi.page();
13 13
14 14 wpgetapi.functionsHelp();
15 - wpgetapi.tooltips();
16 -
15 +
17 16 $page
18 - .on( 'click', '.functions .copy-this', wpgetapi.copyThis )
19 17 .on( 'change keyup', '.field-id input', wpgetapi.functionsHelp )
20 18 .on( 'cmb2_remove_row cmb2_add_row cmb2_shift_row', wpgetapi.functionsHelp );
21 19
22 20 }
23 21
24 -
25 22 /**
26 - * Do the tooltips
23 + * Adds the endpoint into the functions help section.
27 24 */
28 - wpgetapi.tooltips = function () {
29 - $( ".wrap.wpgetapi .dashicons-editor-help" ).tooltip({
30 - items: "[data-tip]",
31 - content: function () {
32 - return $(this).data("tip");
33 - },
34 - classes: {
35 - "ui-tooltip": "wpgetapi-tooltip"
36 - },
37 - position: { my: "left+10 center", at: "right center" },
38 - close: function (event, ui) {
39 - ui.tooltip.hover(
40 - function () {
41 - $(this).stop(true).fadeTo(400, 1);
42 - },
43 - function () {
44 - $(this).fadeOut("400", function () {
45 - $(this).remove();
46 - })
47 - });
48 - }
49 - });
50 - }
51 -
52 - /**
53 - * Copy the template tag or the shortcode
54 - */
55 - wpgetapi.copyThis = function ( e ) {
56 -
57 - const $this = $( this );
58 - const textToCopy = $this.prev( '.wpgetapi-copy' ).text();
59 -
60 - navigator.clipboard.writeText(textToCopy).then(
61 - function() {
62 - /* clipboard successfully set */
63 - $this.after( '<span class="copied">Copied</span>' );
64 - setTimeout(
65 - function() {
66 - $( '.copied' ).remove();
67 - }, 3000
68 - );
69 -
70 - },
71 - function() {
72 - /* clipboard write failed */
73 - $this.append('Oops! Your browser doesn\'t support this.')
74 - }
75 - )
76 -
77 - }
78 -
79 -
80 - /**
81 - * Adds the endpoint into the functions help section,
82 - * meaning the Template tag and the shortcode.
83 - */
84 25 wpgetapi.functionsHelp = function ( e ) {
85 26
86 - // change, keyup, add_row etc
87 - if( e && e.type.length > 0 ) {
27 + // set $this depending on how we call function
28 + var $this = e ? $( this ) : $( '.field-id input' );
29 + var $group = $this.parents( '.cmb-repeatable-grouping' );
88 30
89 - var $this = $( this );
90 - var $group = $this.parents( '.cmb-repeatable-grouping' );
91 -
92 - // if we are adding a group, clear it
93 - if( e.type == 'cmb2_add_row' ) {
94 - $group = $( '.cmb-repeatable-grouping' ).last();
95 - $group.find( '.functions .endpoint_id' ).html( '' );
96 - }
97 -
98 - if( $group.length > 0 )
99 - $group.find( '.functions .endpoint_id' ).html( $this.val() );
100 -
101 - } else {
102 -
103 - $('.cmb-repeatable-grouping').each(function( index, value ) {
104 -
105 - var $group = $( this );
106 - var endpoint_value = $group.find( '.field-id input' ).val();
107 - $group.find( '.functions .endpoint_id' ).html( endpoint_value );
108 -
109 - });
110 -
31 + // if we are adding a group, clear it
32 + if( e && e.type == 'cmb2_add_row' ) {
33 + $group = $( '.cmb-repeatable-grouping' ).last();
34 + $group.find( '.functions .endpoint_id' ).html( '' );
111 35 }
36 + if( $group.length > 0 )
37 + $group.find( '.functions .endpoint_id' ).html( $this.val() );
112 38
113 39 }
114 40
41 +
115 42 /**
116 43 * Gets jQuery object containing all . Caches the result.
117 44 *
118 45 * @since 1.0.0