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 / facebook / public / block / block.js

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

489 lines 18.3 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 = 0);
85 /******/ })
86 /************************************************************************/
87 /******/ ([
88 /* 0 */
89 /***/ (function(module, exports, __webpack_require__) {
90
91 module.exports = __webpack_require__(1);
92
93
94 /***/ }),
95 /* 1 */
96 /***/ (function(module, __webpack_exports__, __webpack_require__) {
97
98 "use strict";
99 __webpack_require__.r(__webpack_exports__);
100 /* harmony import */ var _edit_jsx__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
101 /**
102 * WordPress dependencies
103 */
104 var addFilter = wp.hooks.addFilter;
105 /**
106 * Internal dependencies
107 */
108
109
110 /**
111 * Custom block Edit output for FacebookFanpage block.
112 *
113 * @param {JSX} edit Original block edit.
114 * @param {Object} blockProps Block data.
115 *
116 * @return {JSX} Block edit.
117 */
118
119 function editRender(edit, blockProps) {
120 if ('canvas/facebook-fanpage' === blockProps.name) {
121 return wp.element.createElement(_edit_jsx__WEBPACK_IMPORTED_MODULE_0__["default"], blockProps);
122 }
123
124 return edit;
125 }
126
127 addFilter('canvas.customBlock.editRender', 'canvas/facebook-fanpage/editRender', editRender);
128
129 /***/ }),
130 /* 2 */
131 /***/ (function(module, __webpack_exports__, __webpack_require__) {
132
133 "use strict";
134 __webpack_require__.r(__webpack_exports__);
135 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "default", function() { return FacebookFanpageBlockEdit; });
136 /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(3);
137 /* harmony import */ var classnames__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(classnames__WEBPACK_IMPORTED_MODULE_0__);
138 /* harmony import */ var throttle_debounce__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(4);
139 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); }
140
141 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
142
143 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); } }
144
145 function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
146
147 function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
148
149 function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
150
151 function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
152
153 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); }
154
155 function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
156
157 /**
158 * External dependencies
159 */
160
161
162 /**
163 * WordPress dependencies
164 */
165
166 var __ = wp.i18n.__;
167 var _wp$element = wp.element,
168 Component = _wp$element.Component,
169 Fragment = _wp$element.Fragment,
170 createRef = _wp$element.createRef;
171 var _wp$components = wp.components,
172 Placeholder = _wp$components.Placeholder,
173 Disabled = _wp$components.Disabled;
174 /**
175 * Component
176 */
177
178 var FacebookFanpageBlockEdit =
179 /*#__PURE__*/
180 function (_Component) {
181 _inherits(FacebookFanpageBlockEdit, _Component);
182
183 function FacebookFanpageBlockEdit() {
184 var _this;
185
186 _classCallCheck(this, FacebookFanpageBlockEdit);
187
188 _this = _possibleConstructorReturn(this, _getPrototypeOf(FacebookFanpageBlockEdit).apply(this, arguments));
189 _this.fbRef = createRef();
190 _this.maybeInit = Object(throttle_debounce__WEBPACK_IMPORTED_MODULE_1__["debounce"])(300, _this.maybeInit.bind(_assertThisInitialized(_this)));
191 return _this;
192 }
193
194 _createClass(FacebookFanpageBlockEdit, [{
195 key: "componentDidMount",
196 value: function componentDidMount() {
197 this.maybeInit();
198 }
199 }, {
200 key: "componentDidUpdate",
201 value: function componentDidUpdate() {
202 this.maybeInit();
203 }
204 }, {
205 key: "maybeInit",
206 value: function maybeInit() {
207 var href = this.props.attributes.href;
208
209 if (!this.fbRef || !this.fbRef.current) {
210 return;
211 }
212
213 if (!href || !window.FB || !window.FB.XFBML) {
214 return;
215 }
216
217 var $ref = this.fbRef.current;
218 var _this$props$attribute = this.props.attributes,
219 showCover = _this$props$attribute.showCover,
220 showFacepile = _this$props$attribute.showFacepile,
221 showPosts = _this$props$attribute.showPosts,
222 smallHeader = _this$props$attribute.smallHeader;
223 var hideCover = showCover ? 'false' : 'true';
224 showFacepile = showFacepile ? 'true' : 'false';
225 showPosts = showPosts ? 'true' : 'false';
226 smallHeader = smallHeader ? 'true' : 'false'; // check if already rendered
227
228 var $query = $ref.getAttribute('fb-iframe-plugin-query');
229
230 if ($query) {
231 var queryObj = false;
232
233 try {
234 // thanks https://stackoverflow.com/questions/8648892/convert-url-parameters-to-a-javascript-object
235 queryObj = JSON.parse('{"' + decodeURIComponent($query).replace(/"/g, '\\"').replace(/&/g, '","').replace(/=/g, '":"') + '"}');
236 } catch (e) {
237 queryObj = false;
238 }
239
240 if (queryObj && queryObj.href === href && queryObj.hide_cover === hideCover && queryObj.show_facepile === showFacepile && queryObj.show_posts === showPosts && queryObj.small_header === smallHeader) {
241 return;
242 }
243 } // try to re-render
244
245
246 if ($ref.attributes['fb-xfbml-state']) {
247 $ref.attributes['fb-xfbml-state'] = 're-rendering';
248 }
249
250 FB.XFBML.parse($ref.parentNode);
251 }
252 }, {
253 key: "render",
254 value: function render() {
255 var setAttributes = this.props.setAttributes;
256 var className = this.props.className;
257 var _this$props$attribute2 = this.props.attributes,
258 href = _this$props$attribute2.href,
259 showCover = _this$props$attribute2.showCover,
260 showFacepile = _this$props$attribute2.showFacepile,
261 showPosts = _this$props$attribute2.showPosts,
262 smallHeader = _this$props$attribute2.smallHeader,
263 canvasClassName = _this$props$attribute2.canvasClassName;
264 className = classnames__WEBPACK_IMPORTED_MODULE_0___default()('fb-page-wrapper', canvasClassName, className);
265 return wp.element.createElement(Fragment, null, href ? wp.element.createElement(Disabled, null, wp.element.createElement("div", {
266 className: className
267 }, wp.element.createElement("div", {
268 className: "fb-page",
269 ref: this.fbRef,
270 "data-href": href,
271 "data-hide-cover": showCover ? 'false' : 'true',
272 "data-show-facepile": showFacepile ? 'true' : 'false',
273 "data-show-posts": showPosts ? 'true' : 'false',
274 "data-small-header": smallHeader ? 'true' : 'false',
275 "data-adapt-container-width": "true"
276 }))) : wp.element.createElement(Placeholder, null, __('Please, enter Facebook Fanpage URL.')));
277 }
278 }]);
279
280 return FacebookFanpageBlockEdit;
281 }(Component);
282
283
284
285 /***/ }),
286 /* 3 */
287 /***/ (function(module, exports, __webpack_require__) {
288
289 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
290 Copyright (c) 2017 Jed Watson.
291 Licensed under the MIT License (MIT), see
292 http://jedwatson.github.io/classnames
293 */
294 /* global define */
295
296 (function () {
297 'use strict';
298
299 var hasOwn = {}.hasOwnProperty;
300
301 function classNames () {
302 var classes = [];
303
304 for (var i = 0; i < arguments.length; i++) {
305 var arg = arguments[i];
306 if (!arg) continue;
307
308 var argType = typeof arg;
309
310 if (argType === 'string' || argType === 'number') {
311 classes.push(arg);
312 } else if (Array.isArray(arg) && arg.length) {
313 var inner = classNames.apply(null, arg);
314 if (inner) {
315 classes.push(inner);
316 }
317 } else if (argType === 'object') {
318 for (var key in arg) {
319 if (hasOwn.call(arg, key) && arg[key]) {
320 classes.push(key);
321 }
322 }
323 }
324 }
325
326 return classes.join(' ');
327 }
328
329 if ( true && module.exports) {
330 classNames.default = classNames;
331 module.exports = classNames;
332 } else if (true) {
333 // register as 'classnames', consistent with npm package name
334 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
335 return classNames;
336 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
337 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
338 } else {}
339 }());
340
341
342 /***/ }),
343 /* 4 */
344 /***/ (function(module, __webpack_exports__, __webpack_require__) {
345
346 "use strict";
347 __webpack_require__.r(__webpack_exports__);
348 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "throttle", function() { return throttle; });
349 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "debounce", function() { return debounce; });
350 /* eslint-disable no-undefined,no-param-reassign,no-shadow */
351
352 /**
353 * Throttle execution of a function. Especially useful for rate limiting
354 * execution of handlers on events like resize and scroll.
355 *
356 * @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
357 * @param {Boolean} [noTrailing] Optional, defaults to false. If noTrailing is true, callback will only execute every `delay` milliseconds while the
358 * throttled-function is being called. If noTrailing is false or unspecified, callback will be executed one final time
359 * after the last throttled-function call. (After the throttled-function has not been called for `delay` milliseconds,
360 * the internal counter is reset)
361 * @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
362 * to `callback` when the throttled-function is executed.
363 * @param {Boolean} [debounceMode] If `debounceMode` is true (at begin), schedule `clear` to execute after `delay` ms. If `debounceMode` is false (at end),
364 * schedule `callback` to execute after `delay` ms.
365 *
366 * @return {Function} A new, throttled, function.
367 */
368 function throttle (delay, noTrailing, callback, debounceMode) {
369 /*
370 * After wrapper has stopped being called, this timeout ensures that
371 * `callback` is executed at the proper times in `throttle` and `end`
372 * debounce modes.
373 */
374 var timeoutID;
375 var cancelled = false; // Keep track of the last time `callback` was executed.
376
377 var lastExec = 0; // Function to clear existing timeout
378
379 function clearExistingTimeout() {
380 if (timeoutID) {
381 clearTimeout(timeoutID);
382 }
383 } // Function to cancel next exec
384
385
386 function cancel() {
387 clearExistingTimeout();
388 cancelled = true;
389 } // `noTrailing` defaults to falsy.
390
391
392 if (typeof noTrailing !== 'boolean') {
393 debounceMode = callback;
394 callback = noTrailing;
395 noTrailing = undefined;
396 }
397 /*
398 * The `wrapper` function encapsulates all of the throttling / debouncing
399 * functionality and when executed will limit the rate at which `callback`
400 * is executed.
401 */
402
403
404 function wrapper() {
405 var self = this;
406 var elapsed = Date.now() - lastExec;
407 var args = arguments;
408
409 if (cancelled) {
410 return;
411 } // Execute `callback` and update the `lastExec` timestamp.
412
413
414 function exec() {
415 lastExec = Date.now();
416 callback.apply(self, args);
417 }
418 /*
419 * If `debounceMode` is true (at begin) this is used to clear the flag
420 * to allow future `callback` executions.
421 */
422
423
424 function clear() {
425 timeoutID = undefined;
426 }
427
428 if (debounceMode && !timeoutID) {
429 /*
430 * Since `wrapper` is being called for the first time and
431 * `debounceMode` is true (at begin), execute `callback`.
432 */
433 exec();
434 }
435
436 clearExistingTimeout();
437
438 if (debounceMode === undefined && elapsed > delay) {
439 /*
440 * In throttle mode, if `delay` time has been exceeded, execute
441 * `callback`.
442 */
443 exec();
444 } else if (noTrailing !== true) {
445 /*
446 * In trailing throttle mode, since `delay` time has not been
447 * exceeded, schedule `callback` to execute `delay` ms after most
448 * recent execution.
449 *
450 * If `debounceMode` is true (at begin), schedule `clear` to execute
451 * after `delay` ms.
452 *
453 * If `debounceMode` is false (at end), schedule `callback` to
454 * execute after `delay` ms.
455 */
456 timeoutID = setTimeout(debounceMode ? clear : exec, debounceMode === undefined ? delay - elapsed : delay);
457 }
458 }
459
460 wrapper.cancel = cancel; // Return the wrapper function.
461
462 return wrapper;
463 }
464
465 /* eslint-disable no-undefined */
466 /**
467 * Debounce execution of a function. Debouncing, unlike throttling,
468 * guarantees that a function is only executed a single time, either at the
469 * very beginning of a series of calls, or at the very end.
470 *
471 * @param {Number} delay A zero-or-greater delay in milliseconds. For event callbacks, values around 100 or 250 (or even higher) are most useful.
472 * @param {Boolean} [atBegin] Optional, defaults to false. If atBegin is false or unspecified, callback will only be executed `delay` milliseconds
473 * after the last debounced-function call. If atBegin is true, callback will be executed only at the first debounced-function call.
474 * (After the throttled-function has not been called for `delay` milliseconds, the internal counter is reset).
475 * @param {Function} callback A function to be executed after delay milliseconds. The `this` context and all arguments are passed through, as-is,
476 * to `callback` when the debounced-function is executed.
477 *
478 * @return {Function} A new, debounced function.
479 */
480
481 function debounce (delay, atBegin, callback) {
482 return callback === undefined ? throttle(delay, atBegin, false) : throttle(delay, callback, atBegin !== false);
483 }
484
485
486
487
488 /***/ })
489 /******/ ]);