PluginProbe
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more / 2.1
StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more v2.1
3.7.0 3.6.0 3.6.1 3.5.2 trunk 2.0 2.1 2.2 2.3 2.4 2.4.1 2.4.2 2.4.3 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.6.0 2.6.1 3.0.0 3.0.1 All 71 releases
stockpack / dist / js / stockpack-settings.js

stockpack-settings.js in StockPack – Stock photos and AI images from Unsplash, Adobe Stock, Freepik and more 2.1, at dist/js/stockpack-settings.js

90 lines 2.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 // debounce library
2
3 /*
4 * jQuery throttle / debounce - v1.1 - 3/7/2010
5 * http://benalman.com/projects/jquery-throttle-debounce-plugin/
6 *
7 * Copyright (c) 2010 "Cowboy" Ben Alman
8 * Dual licensed under the MIT and GPL licenses.
9 * http://benalman.com/about/license/
10 */
11 (function (b, c) {
12 var $ = b.jQuery || b.Cowboy || (b.Cowboy = {}), a;
13 $.throttle = a = function (e, f, j, i) {
14 var h, d = 0;
15 if (typeof f !== "boolean") {
16 i = j;
17 j = f;
18 f = c
19 }
20
21 function g() {
22 var o = this, m = +new Date() - d, n = arguments;
23
24 function l() {
25 d = +new Date();
26 j.apply(o, n)
27 }
28
29 function k() {
30 h = c
31 }
32
33 if (i && !h) {
34 l()
35 }
36 h && clearTimeout(h);
37 if (i === c && m > e) {
38 l()
39 } else {
40 if (f !== true) {
41 h = setTimeout(i ? k : l, i === c ? e - m : e)
42 }
43 }
44 }
45
46 if ($.guid) {
47 g.guid = j.guid = j.guid || $.guid++
48 }
49 return g
50 };
51 $.debounce = function (d, e, f) {
52 return f === c ? a(d, e, false) : a(d, f, e !== false)
53 }
54 })(this);
55
56 jQuery(document).ready(function () {
57
58 var $element = jQuery('input.validate-stockpack-key');
59
60 function append_icon() {
61 $element.after('<span class="stockpack-verification"></span>')
62 $element.before('<span class="stockpack-message">' + wp.media.view.l10n.stockpack.license + '</span>')
63 }
64
65 function validate_key() {
66 $element.parent().removeClass('valid').removeClass('invalid');
67 var val = $element.val();
68 var options = options || {};
69 options.data = _.extend(options.data || {}, {
70 action: 'validate-stockpack',
71 security:wp.media.view.settings.stockpack.nonce_validate,
72 key: val,
73 });
74 wp.media.ajax(options).done(function (response) {
75 if (response.status === 'passed') {
76 $element.parent().removeClass('invalid').addClass('valid')
77 } else {
78 $element.parent().removeClass('valid').addClass('invalid')
79 }
80 })
81 }
82
83 $element.keyup($.debounce(250, validate_key));
84
85
86 // run initially
87 append_icon();
88 validate_key();
89 })
90