PluginProbe
Powerkit – Supercharge your WordPress Site / 2.4.4
Powerkit – Supercharge your WordPress Site v2.4.4
3.1.1 3.1.0 3.0.9 3.0.8 trunk 2.2.6 2.2.7 2.2.8 2.2.9 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 All 87 releases
powerkit / modules / pinterest / public / block / block.js

block.js in Powerkit – Supercharge your WordPress Site 2.4.4, at modules/pinterest/public/block/block.js

464 lines 16.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (function(modules) { // webpackBootstrap
2 /******/ // The module cache
3 /******/ var installedModules = {};
4 /******/
5 /******/ // The require function
6 /******/ function __webpack_require__(moduleId) {
7 /******/
8 /******/ // Check if module is in cache
9 /******/ if(installedModules[moduleId]) {
10 /******/ return installedModules[moduleId].exports;
11 /******/ }
12 /******/ // Create a new module (and put it into the cache)
13 /******/ var module = installedModules[moduleId] = {
14 /******/ i: moduleId,
15 /******/ l: false,
16 /******/ exports: {}
17 /******/ };
18 /******/
19 /******/ // Execute the module function
20 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21 /******/
22 /******/ // Flag the module as loaded
23 /******/ module.l = true;
24 /******/
25 /******/ // Return the exports of the module
26 /******/ return module.exports;
27 /******/ }
28 /******/
29 /******/
30 /******/ // expose the modules object (__webpack_modules__)
31 /******/ __webpack_require__.m = modules;
32 /******/
33 /******/ // expose the module cache
34 /******/ __webpack_require__.c = installedModules;
35 /******/
36 /******/ // define getter function for harmony exports
37 /******/ __webpack_require__.d = function(exports, name, getter) {
38 /******/ if(!__webpack_require__.o(exports, name)) {
39 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
40 /******/ }
41 /******/ };
42 /******/
43 /******/ // define __esModule on exports
44 /******/ __webpack_require__.r = function(exports) {
45 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47 /******/ }
48 /******/ Object.defineProperty(exports, '__esModule', { value: true });
49 /******/ };
50 /******/
51 /******/ // create a fake namespace object
52 /******/ // mode & 1: value is a module id, require it
53 /******/ // mode & 2: merge all properties of value into the ns
54 /******/ // mode & 4: return value when already ns object
55 /******/ // mode & 8|1: behave like require
56 /******/ __webpack_require__.t = function(value, mode) {
57 /******/ if(mode & 1) value = __webpack_require__(value);
58 /******/ if(mode & 8) return value;
59 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60 /******/ var ns = Object.create(null);
61 /******/ __webpack_require__.r(ns);
62 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64 /******/ return ns;
65 /******/ };
66 /******/
67 /******/ // getDefaultExport function for compatibility with non-harmony modules
68 /******/ __webpack_require__.n = function(module) {
69 /******/ var getter = module && module.__esModule ?
70 /******/ function getDefault() { return module['default']; } :
71 /******/ function getModuleExports() { return module; };
72 /******/ __webpack_require__.d(getter, 'a', getter);
73 /******/ return getter;
74 /******/ };
75 /******/
76 /******/ // Object.prototype.hasOwnProperty.call
77 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78 /******/
79 /******/ // __webpack_public_path__
80 /******/ __webpack_require__.p = "";
81 /******/
82 /******/
83 /******/ // Load entry module and return exports
84 /******/ return __webpack_require__(__webpack_require__.s = 5);
85 /******/ })
86 /************************************************************************/
87 /******/ ([
88 /* 0 */,
89 /* 1 */,
90 /* 2 */,
91 /* 3 */
92 /***/ (function(module, exports, __webpack_require__) {
93
94 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
95 Copyright (c) 2017 Jed Watson.
96 Licensed under the MIT License (MIT), see
97 http://jedwatson.github.io/classnames
98 */
99 /* global define */
100
101 (function () {
102 'use strict';
103
104 var hasOwn = {}.hasOwnProperty;
105
106 function classNames () {
107 var classes = [];
108
109 for (var i = 0; i < arguments.length; i++) {
110 var arg = arguments[i];
111 if (!arg) continue;
112
113 var argType = typeof arg;
114
115 if (argType === 'string' || argType === 'number') {
116 classes.push(arg);
117 } else if (Array.isArray(arg) && arg.length) {
118 var inner = classNames.apply(null, arg);
119 if (inner) {
120 classes.push(inner);
121 }
122 } else if (argType === 'object') {
123 for (var key in arg) {
124 if (hasOwn.call(arg, key) && arg[key]) {
125 classes.push(key);
126 }
127 }
128 }
129 }
130
131 return classes.join(' ');
132 }
133
134 if ( true && module.exports) {
135 classNames.default = classNames;
136 module.exports = classNames;
137 } else if (true) {
138 // register as 'classnames', consistent with npm package name
139 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
140 return classNames;
141 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
142 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
143 } else {}
144 }());
145
146
147 /***/ }),
148 /* 4 */
149 /***/ (function(module, __webpack_exports__, __webpack_require__) {
150
151 "use strict";
152 __webpack_require__.r(__webpack_exports__);
153 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "throttle", function() { return throttle; });
154 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "debounce", function() { return debounce; });
155 /* eslint-disable no-undefined,no-param-reassign,no-shadow */
156
157 /**
158 * Throttle execution of a function. Especially useful for rate limiting
159 * execution of handlers on events like resize and scroll.
160 *
161 * @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
162 * @param {Boolean} [noTrailing] Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds while the
163 * throttled-function is being called. If noTrailing is false or unspecified, callback will be executed one final time
164 * after the last throttled-function call. (After the throttled-function has not been called for `delay` milliseconds,
165 * the internal counter is reset)
166 * @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
167 * to `callback` when the throttled-function is executed.
168 * @param {Boolean} [debounceMode] If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is false (at end),
169 * schedule `callback` to execute after `delay` ms.
170 *
171 * @return {Function} A new, throttled, function.
172 */
173 function throttle (delay, noTrailing, callback, debounceMode) {
174 /*
175 * After wrapper has stopped being called, this timeout ensures that
176 * `callback` is executed at the proper times in `throttle` and `end`
177 * debounce modes.
178 */
179 var timeoutID;
180 var cancelled = false; // Keep track of the last time `callback` was executed.
181
182 var lastExec = 0; // Function to clear existing timeout
183
184 function clearExistingTimeout() {
185 if (timeoutID) {
186 clearTimeout(timeoutID);
187 }
188 } // Function to cancel next exec
189
190
191 function cancel() {
192 clearExistingTimeout();
193 cancelled = true;
194 } // `noTrailing` defaults to falsy.
195
196
197 if (typeof noTrailing !== 'boolean') {
198 debounceMode = callback;
199 callback = noTrailing;
200 noTrailing = undefined;
201 }
202 /*
203 * The `wrapper` function encapsulates all of the throttling / debouncing
204 * functionality and when executed will limit the rate at which `callback`
205 * is executed.
206 */
207
208
209 function wrapper() {
210 var self = this;
211 var elapsed = Date.now() - lastExec;
212 var args = arguments;
213
214 if (cancelled) {
215 return;
216 } // Execute `callback` and update the `lastExec` timestamp.
217
218
219 function exec() {
220 lastExec = Date.now();
221 callback.apply(self, args);
222 }
223 /*
224 * If `debounceMode` is true (at begin) this is used to clear the flag
225 * to allow future `callback` executions.
226 */
227
228
229 function clear() {
230 timeoutID = undefined;
231 }
232
233 if (debounceMode && !timeoutID) {
234 /*
235 * Since `wrapper` is being called for the first time and
236 * `debounceMode` is true (at begin), execute `callback`.
237 */
238 exec();
239 }
240
241 clearExistingTimeout();
242
243 if (debounceMode === undefined && elapsed > delay) {
244 /*
245 * In throttle mode, if `delay` time has been exceeded, execute
246 * `callback`.
247 */
248 exec();
249 } else if (noTrailing !== true) {
250 /*
251 * In trailing throttle mode, since `delay` time has not been
252 * exceeded, schedule `callback` to execute `delay` ms after most
253 * recent execution.
254 *
255 * If `debounceMode` is true (at begin), schedule `clear` to execute
256 * after `delay` ms.
257 *
258 * If `debounceMode` is false (at end), schedule `callback` to
259 * execute after `delay` ms.
260 */
261 timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);
262 }
263 }
264
265 wrapper.cancel = cancel; // Return the wrapper function.
266
267 return wrapper;
268 }
269
270 /* eslint-disable no-undefined */
271 /**
272 * Debounce execution of a function. Debouncing, unlike throttling,
273 * guarantees that a function is only executed a single time, either at the
274 * very beginning of a series of calls, or at the very end.
275 *
276 * @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
277 * @param {Boolean} [atBegin] Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds
278 * after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.
279 * (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).
280 * @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
281 * to `callback` when the debounced-function is executed.
282 *
283 * @return {Function} A new, debounced function.
284 */
285
286 function debounce (delay, atBegin, callback) {
287 return callback === undefined ? throttle(delay, atBegin, false) : throttle(delay, callback, atBegin !== false);
288 }
289
290
291
292
293 /***/ }),
294 /* 5 */
295 /***/ (function(module, exports, __webpack_require__) {
296
297 module.exports = __webpack_require__(6);
298
299
300 /***/ }),
301 /* 6 */
302 /***/ (function(module, __webpack_exports__, __webpack_require__) {
303
304 "use strict";
305 __webpack_require__.r(__webpack_exports__);
306 /* harmony import */ var _edit_jsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(7);
307 /**
308 * WordPress dependencies
309 */
310 var addFilter = wp.hooks.addFilter;
311 /**
312 * Internal dependencies
313 */
314
315
316 /**
317 * Custom block Edit output for PinterestBoard block.
318 *
319 * @param {JSX} edit Original block edit.
320 * @param {Object} blockProps Block data.
321 *
322 * @return {JSX} Block edit.
323 */
324
325 function editRender(edit, blockProps) {
326 if ('canvas/pinterest-board' === blockProps.name) {
327 return wp.element.createElement(_edit_jsx__WEBPACK_IMPORTED_MODULE_0__["default"], blockProps);
328 }
329
330 return edit;
331 }
332
333 addFilter('canvas.customBlock.editRender', 'canvas/pinterest-board/editRender', editRender);
334
335 /***/ }),
336 /* 7 */
337 /***/ (function(module, __webpack_exports__, __webpack_require__) {
338
339 "use strict";
340 __webpack_require__.r(__webpack_exports__);
341 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return PinterestBoardBlockEdit; });
342 /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
343 /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_0__);
344 /* harmony import */ var throttle_debounce__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
345 function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
346
347 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
348
349 function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
350
351 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
352
353 function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
354
355 function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
356
357 function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
358
359 function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
360
361 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
362
363 /**
364 * External dependencies
365 */
366
367
368 /**
369 * WordPress dependencies
370 */
371
372 var __ = wp.i18n.__;
373 var _wp$element = wp.element,
374 Component = _wp$element.Component,
375 Fragment = _wp$element.Fragment;
376 var _wp$components = wp.components,
377 Placeholder = _wp$components.Placeholder,
378 Disabled = _wp$components.Disabled;
379 /**
380 * Component
381 */
382
383 var PinterestBoardBlockEdit =
384 /*#__PURE__*/
385 function (_Component) {
386 _inherits(PinterestBoardBlockEdit, _Component);
387
388 function PinterestBoardBlockEdit() {
389 var _this;
390
391 _classCallCheck(this, PinterestBoardBlockEdit);
392
393 _this = _possibleConstructorReturn(this, _getPrototypeOf(PinterestBoardBlockEdit).apply(this, arguments));
394 _this.state = {
395 pinApi: false
396 };
397 _this.maybeFindGlobalPinObj = _this.maybeFindGlobalPinObj.bind(_assertThisInitialized(_this));
398 _this.maybeInit = Object(throttle_debounce__WEBPACK_IMPORTED_MODULE_1__["debounce"])(300, _this.maybeInit.bind(_assertThisInitialized(_this)));
399 return _this;
400 }
401
402 _createClass(PinterestBoardBlockEdit, [{
403 key: "componentDidMount",
404 value: function componentDidMount() {
405 this.maybeInit();
406 }
407 }, {
408 key: "componentDidUpdate",
409 value: function componentDidUpdate() {
410 this.maybeInit();
411 }
412 /**
413 * Try to find global Pinterest object.
414 */
415
416 }, {
417 key: "maybeFindGlobalPinObj",
418 value: function maybeFindGlobalPinObj() {
419 var _this2 = this;
420
421 Object.keys(window).forEach(function (k) {
422 if (/^PIN_\d+$/.test(k) && window[k].f && window[k].f.build) {
423 _this2.setState({
424 pinApi: k
425 });
426 }
427 });
428 }
429 }, {
430 key: "maybeInit",
431 value: function maybeInit() {
432 if (!this.state.pinApi) {
433 this.maybeFindGlobalPinObj();
434 return;
435 }
436
437 window[this.state.pinApi].f.build();
438 }
439 }, {
440 key: "render",
441 value: function render() {
442 var className = this.props.className;
443 var _this$props$attribute = this.props.attributes,
444 href = _this$props$attribute.href,
445 canvasClassName = _this$props$attribute.canvasClassName;
446 className = classnames__WEBPACK_IMPORTED_MODULE_0___default()('pinterest-board-wrapper pk-block-pinterest-board', canvasClassName, className);
447 return wp.element.createElement(Fragment, null, href ? wp.element.createElement(Disabled, null, wp.element.createElement("div", {
448 className: className,
449 key: "pin-board-".concat(href)
450 }, wp.element.createElement("a", {
451 "data-pin-do": "embedBoard",
452 "data-pin-board-width": "100%",
453 href: href
454 }))) : wp.element.createElement(Placeholder, null, __('Please, enter Pinterest Board URL.')));
455 }
456 }]);
457
458 return PinterestBoardBlockEdit;
459 }(Component);
460
461
462
463 /***/ })
464 /******/ ]);