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