PluginProbe
Sight – Professional Image Gallery and Portfolio / 1.1.0
Sight – Professional Image Gallery and Portfolio v1.1.0
trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8
sight / render / js / sight.js

sight.js in Sight – Professional Image Gallery and Portfolio 1.1.0, at render/js/sight.js

956 lines 34.5 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 __webpack_require__(1);
92 __webpack_require__(3);
93 module.exports = __webpack_require__(4);
94
95
96 /***/ }),
97 /* 1 */
98 /***/ (function(module, __webpack_exports__, __webpack_require__) {
99
100 "use strict";
101 __webpack_require__.r(__webpack_exports__);
102 /* harmony import */ var _utility__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
103 /**
104 * Lightbox
105 */
106
107
108 (function ($) {
109 $.fn.SightLightbox = function (options) {
110 var settings = $.extend({
111 gallery: false
112 }, options);
113 var containerSelector = this;
114 var imageSelector = null;
115 $(containerSelector).each(function () {
116 if ($(this).is('img')) {
117 imageSelector = this;
118 } else {
119 imageSelector = $(this).find('img');
120 }
121
122 $(imageSelector).each(function () {
123 var link = $(this).closest('.sight-portfolio-entry').find('.sight-portfolio-overlay-link');
124
125 if (!$(link).is('a')) {
126 return;
127 }
128
129 var imagehref = $(link).attr('href');
130
131 if (!imagehref.match(/\.(gif|jpeg|jpg|png)/)) {
132 return;
133 }
134
135 $(link).addClass('sight-image-popup');
136 });
137
138 if ($(this).closest('.elementor-element').length > 0) {
139 return;
140 }
141
142 $(containerSelector).magnificPopup({
143 delegate: '.sight-image-popup',
144 type: 'image',
145 tClose: sight_lightbox_localize.text_close + '(Esc)',
146 tLoading: sight_lightbox_localize.text_loading,
147 gallery: {
148 enabled: settings.gallery,
149 tPrev: sight_lightbox_localize.text_previous,
150 tNext: sight_lightbox_localize.text_next,
151 tCounter: '<span class="mfp-counter">%curr% ' + sight_lightbox_localize.text_counter + ' %total%</span>'
152 },
153 image: {
154 titleSrc: function titleSrc(item) {
155 var entry = item.el.closest('.sight-portfolio-entry');
156
157 if ($(entry).hasClass('sight-portfolio-entry-custom')) {
158 return $(entry).find('.sight-portfolio-entry__caption').text();
159 } else if ($(entry).hasClass('sight-portfolio-entry-post')) {
160 return $(entry).find('.sight-portfolio-entry__caption').text();
161 } else {
162 return $(entry).find('.sight-portfolio-entry__heading').text();
163 }
164 }
165 }
166 });
167 });
168 };
169
170 function initSightLightbox() {
171 $('.sight-portfolio-area-lightbox').imagesLoaded(function () {
172 $('.sight-portfolio-area-lightbox').SightLightbox({
173 gallery: true
174 });
175 });
176 }
177
178 $(document).ready(function () {
179 initSightLightbox();
180 $(document.body).on('post-load image-load', function () {
181 initSightLightbox();
182 });
183 });
184 })(jQuery);
185
186 /***/ }),
187 /* 2 */
188 /***/ (function(module, __webpack_exports__, __webpack_require__) {
189
190 "use strict";
191 __webpack_require__.r(__webpack_exports__);
192 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "$", function() { return $; });
193 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "$window", function() { return $window; });
194 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "$doc", function() { return $doc; });
195 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "$body", function() { return $body; });
196 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sight", function() { return sight; });
197 // Create csco object.
198 var sight = {
199 addAction: function addAction(x, y, z) {
200 return;
201 }
202 };
203
204 if ('undefined' !== typeof wp && 'undefined' !== typeof wp.hooks) {
205 sight.addAction = wp.hooks.addAction;
206 }
207
208 if ('undefined' === typeof window.load_more_query) {
209 window.load_more_query = [];
210 }
211 /**
212 * Window size
213 */
214
215
216 var $ = jQuery;
217 var $window = $(window);
218 var $doc = $(document);
219 var $body = $('body');
220 /**
221 * In Viewport checker
222 */
223
224 $.fn.isInViewport = function () {
225 var elementTop = $(this).offset().top;
226 var elementBottom = elementTop + $(this).outerHeight();
227 var viewportTop = $(window).scrollTop();
228 var viewportBottom = viewportTop + $(window).height();
229 return elementBottom > viewportTop && elementTop < viewportBottom;
230 };
231
232
233
234 /***/ }),
235 /* 3 */
236 /***/ (function(module, __webpack_exports__, __webpack_require__) {
237
238 "use strict";
239 __webpack_require__.r(__webpack_exports__);
240 /* harmony import */ var _utility__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
241 function _typeof(obj) { "@babel/helpers - typeof"; 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); }
242
243 /**
244 * AJAX Load More.
245 *
246 * Contains functions for AJAX Load More.
247 */
248
249 /**
250 * Insert Load More
251 */
252
253 function sight_portfolio_load_more_insert(container, settings) {
254 if ('none' === settings.pagination_type) {
255 return;
256 }
257
258 if (Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).find('.sight-portfolio-area__pagination').length) {
259 return;
260 }
261
262 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).append('<div class="sight-portfolio-area__pagination"><button class="sight-portfolio-load-more">' + settings.translation.load_more + '</button></div>');
263 }
264 /**
265 * Get next posts
266 */
267
268
269 function sight_portfolio_ajax_get_posts(container, reload) {
270 var pagination = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).find('.sight-portfolio-area__pagination');
271 var loadMore = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).find('.sight-portfolio-load-more');
272 var settings = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).data('settings');
273 var page = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).data('page'); // Filter terms.
274
275 var terms = [];
276 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).find('.sight-portfolio-area-filter__list li').each(function (index, elem) {
277 if (Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).is('.sight-filter-active:not(.sight-filter-all)')) {
278 terms.push(Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).find('a').data('filter'));
279 }
280 }); // Set area loading.
281
282 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).find('.sight-portfolio-area__main').addClass('sight-portfolio-loading'); // Set ajax settings.
283
284 if (reload) {
285 page = 1;
286 }
287
288 var data = {
289 action: 'sight_portfolio_ajax_load_more',
290 terms: terms,
291 page: page,
292 posts_per_page: settings.posts_per_page,
293 query_data: settings.query_data,
294 attributes: settings.attributes,
295 options: settings.options,
296 _ajax_nonce: settings.nonce
297 }; // Set the loading state.
298
299 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).data('loading', true); // Set button text to Load More.
300
301 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(loadMore).text(settings.translation.loading); // Request Url.
302
303 var sight_pagination_url;
304
305 if ('ajax_restapi' === settings.type) {
306 sight_pagination_url = settings.rest_url;
307 } else {
308 sight_pagination_url = settings.url;
309 } // Send Request.
310
311
312 _utility__WEBPACK_IMPORTED_MODULE_0__["$"].post(sight_pagination_url, data, function (res) {
313 if (res.success) {
314 // Get the posts.
315 var data = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(res.data.content);
316 data.imagesLoaded(function () {
317 // Append new posts to list, standard and grid archives.
318 if (reload) {
319 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).find('.sight-portfolio-area__main').html(data);
320 } else {
321 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).find('.sight-portfolio-area__main').append(data);
322 } // Entry animations.
323
324
325 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).find('.sight-portfolio-entry-request').each(function () {
326 if (!Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).is('sight-portfolio-entry-animation')) {
327 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).addClass('sight-portfolio-entry-animation').animate({
328 opacity: 1,
329 top: 0
330 }, 600);
331 }
332 }); // WP Post Load trigger.
333
334 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(window).trigger('post-load'); // Reinit Facebook widgets.
335
336 if (Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])('#fb-root').length && 'object' === (typeof FB === "undefined" ? "undefined" : _typeof(FB))) {
337 FB.XFBML.parse();
338 } // Set button text to Load More.
339
340
341 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(loadMore).text(settings.translation.load_more); // Increment a page.
342
343 page = page + 1;
344 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).data('page', page); // Set the loading state.
345
346 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).data('loading', false);
347 }); // Remove Button on Posts End.
348
349 if (res.data.posts_end || !data.length) {
350 // Remove Load More button.
351 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(pagination).remove();
352 } else {
353 // Add Load More button.
354 sight_portfolio_load_more_insert(container, settings);
355 }
356
357 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).find('.sight-portfolio-area__main').removeClass('sight-portfolio-loading');
358 } else {
359 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).find('.sight-portfolio-area__main').removeClass('sight-portfolio-loading');
360 }
361 }).fail(function (xhr, textStatus, e) {// console.log(xhr.responseText);
362 });
363 }
364 /**
365 * Initialization Load More
366 */
367
368
369 function sight_portfolio_load_more_init(infinite, blockId) {
370 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])('.sight-portfolio-area').each(function () {
371 var sight_ajax_settings;
372
373 if (blockId) {
374 var itemId = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).closest("[data-block]").attr('id');
375
376 if (itemId !== blockId) {
377 return;
378 }
379 } else if (Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).data('init')) {
380 return;
381 }
382
383 var archive_data = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).data('items-area');
384
385 if (archive_data) {
386 sight_ajax_settings = JSON.parse(window.atob(archive_data));
387 }
388
389 if (sight_ajax_settings) {
390 // Set load more settings.
391 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).data('settings', sight_ajax_settings);
392 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).data('page', 2);
393 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).data('loading', false);
394 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).data('scrollHandling', {
395 allow: _utility__WEBPACK_IMPORTED_MODULE_0__["$"].parseJSON('infinite' === sight_ajax_settings.pagination_type ? true : false),
396 delay: 400
397 });
398
399 if (!infinite && ('infinite' === sight_ajax_settings.pagination_type ? true : false)) {
400 return;
401 } // Add load more button.
402
403
404 if (sight_ajax_settings.max_num_pages > 1) {
405 sight_portfolio_load_more_insert(this, sight_ajax_settings);
406 }
407 }
408
409 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).data('init', true);
410 });
411 }
412
413 sight_portfolio_load_more_init(true, false);
414 _utility__WEBPACK_IMPORTED_MODULE_0__["sight"].addAction('sight.components.serverSideRender.onChange', 'sight/portfolio/loadmore', function (props) {
415 if ('sight/portfolio' === props.block) {
416 var blockId = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])("[id=block-".concat(props.blockProps.clientId, "]")).attr('id');
417 sight_portfolio_load_more_init(false, blockId);
418 }
419 }); // On Scroll Event.
420
421 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(window).scroll(function () {
422 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])('.sight-portfolio-area .sight-portfolio-load-more').each(function () {
423 var container = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).closest('.sight-portfolio-area'); // Vars loading.
424
425 var loading = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).data('loading');
426 var scrollHandling = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).data('scrollHandling');
427
428 if ('undefined' === typeof scrollHandling) {
429 return;
430 }
431
432 if (Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).length && !loading && scrollHandling.allow) {
433 scrollHandling.allow = false;
434 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).data('scrollHandling', scrollHandling);
435 setTimeout(function () {
436 var scrollHandling = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).data('scrollHandling');
437
438 if ('undefined' === typeof scrollHandling) {
439 return;
440 }
441
442 scrollHandling.allow = true;
443 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(container).data('scrollHandling', scrollHandling);
444 }, scrollHandling.delay);
445 var offset = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).offset().top - Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(window).scrollTop();
446
447 if (4000 > offset) {
448 sight_portfolio_ajax_get_posts(container);
449 }
450 }
451 });
452 }); // On Click Event.
453
454 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])('body').on('click', '.sight-portfolio-load-more', function () {
455 var container = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).closest('.sight-portfolio-area');
456 var loading = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).data('loading');
457
458 if (!loading) {
459 sight_portfolio_ajax_get_posts(container, false);
460 }
461 }); // On Click Categories.
462
463 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])('body').on('click', '.sight-portfolio-area-filter__list a', function (e) {
464 var container = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).closest('.sight-portfolio-area'); // Remove active item.
465
466 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).parent().siblings().removeClass('sight-filter-active'); // Active item.
467
468 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).parent().addClass('sight-filter-active'); // Ajax.
469
470 sight_portfolio_ajax_get_posts(container, true);
471 e.preventDefault();
472 });
473
474 /***/ }),
475 /* 4 */
476 /***/ (function(module, __webpack_exports__, __webpack_require__) {
477
478 "use strict";
479 __webpack_require__.r(__webpack_exports__);
480 /* harmony import */ var _utility__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(2);
481 /** ----------------------------------------------------------------------------
482 * Video Background */
483
484 var sightVideoPortfolio = {};
485
486 (function () {
487 var $this;
488 var YTdeferredDone = false;
489 var initAPI = false;
490 var process = false;
491 var contex = [];
492 var players = [];
493 var attrs = []; // Create deferred object
494
495 var YTdeferred = _utility__WEBPACK_IMPORTED_MODULE_0__["$"].Deferred();
496
497 if (typeof window.onYouTubePlayerAPIReady !== 'undefined') {
498 if (typeof window.sightYTAPIReady === 'undefined') {
499 window.sightYTAPIReady = [];
500 }
501
502 window.sightYTAPIReady.push(window.onYouTubePlayerAPIReady);
503 }
504
505 window.onYouTubePlayerAPIReady = function () {
506 if (typeof window.sightYTAPIReady !== 'undefined') {
507 if (window.sightYTAPIReady.length) {
508 window.sightYTAPIReady.pop()();
509 }
510 } // Resolve when youtube callback is called
511 // passing YT as a parameter.
512
513
514 YTdeferred.resolve(window.YT);
515 }; // Whenever youtube callback was called = deferred resolved
516 // your custom function will be executed with YT as an argument.
517
518
519 YTdeferred.done(function (YT) {
520 YTdeferredDone = true;
521 }); // Embedding youtube iframe api.
522
523 function embedYoutubeAPI() {
524 if ('function' === typeof window.onYTReady) {
525 return;
526 }
527
528 var tag = document.createElement('script');
529 tag.src = 'https://www.youtube.com/iframe_api';
530 var firstScriptTag = document.getElementsByTagName('script')[0];
531 firstScriptTag.parentNode.insertBefore(tag, firstScriptTag);
532 }
533
534 _utility__WEBPACK_IMPORTED_MODULE_0__["$"].fn.contexObject = function (id, type) {
535 if ('string' === typeof id) {
536 id = "[data-id=\"".concat(id, "\"]");
537 } else {
538 id = this;
539 }
540
541 if ('wrap' === type) {
542 return Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(id).closest('.sight-portfolio-video-wrap');
543 } else if ('container' === type) {
544 return Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(id).closest('.sight-portfolio-video-container');
545 } else if ('inner' === type) {
546 return Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(id).closest('.sight-portfolio-video-wrap').find('.sight-portfolio-video-inner');
547 } else {
548 return Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(id);
549 }
550 }; // Object Video Portfolio.
551
552
553 sightVideoPortfolio = {
554 /** Initialize */
555 init: function init(e) {
556 if (Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])('body').hasClass('wp-admin')) {
557 return;
558 }
559
560 $this = sightVideoPortfolio; // Init events.
561
562 $this.events(e);
563 },
564 // Video rescale.
565 rescaleVideoBackground: function rescaleVideoBackground() {
566 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])('.sight-portfolio-video-init').each(function () {
567 var w = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).parent().width();
568 var h = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).parent().height();
569 var hideControl = 400;
570 var id = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).attr('data-id');
571
572 if (w / h > 16 / 9) {
573 if ('youtube' === Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).parent().data('video-mode')) {
574 players[id].setSize(w, w / 16 * 9 + hideControl);
575 } else {
576 players[id].width(w);
577 players[id].height(w / 16 * 9 + hideControl);
578 }
579 } else {
580 if ('youtube' === Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).parent().data('video-mode')) {
581 players[id].setSize(h / 9 * 16, h + hideControl);
582 } else {
583 players[id].width(h / 9 * 16);
584 players[id].height(h + hideControl);
585 }
586 }
587 });
588 },
589 // Init video background.
590 initVideoBackground: function initVideoBackground(mode, object) {
591 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])('.sight-portfolio-video-inner').each(function () {
592 // The mode.
593 if (!Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).parent().is("[data-video-mode=\"".concat(mode, "\"]"))) {
594 return;
595 } // The state.
596
597
598 var isInit = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).hasClass('sight-portfolio-video-init');
599 var id = null; // Generate unique ID.
600
601 if (!isInit) {
602 id = Math.random().toString(36).substr(2, 9);
603 } else {
604 id = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).attr('data-id');
605 } // Create contex.
606
607
608 contex[id] = this; // The monitor.
609
610 var isInView = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(contex[id]).isInViewport(); // The actived.
611
612 var isActive = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(contex[id]).hasClass('active'); // Get video attrs.
613
614 var youtubeID = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(contex[id]).parent().data('youtube-id');
615 var videoType = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(contex[id]).parent().data('video-type');
616 var videoStart = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(contex[id]).parent().data('video-start');
617 var videoEnd = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(contex[id]).parent().data('video-end'); // Initialization.
618
619 if (isInView && !isInit) {
620 // Add init class.
621 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(contex[id]).addClass('sight-portfolio-video-init'); // Add unique ID.
622
623 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(contex[id]).attr('data-id', id); // Check video mode.
624
625 if ('youtube' === mode) {
626 // Check video id.
627 if (typeof youtubeID === 'undefined' || !youtubeID) {
628 return;
629 } // Video attrs.
630
631
632 attrs[id] = {
633 'videoId': youtubeID,
634 'startSeconds': videoStart,
635 'endSeconds': videoEnd,
636 'suggestedQuality': 'hd720'
637 }; // Creating a player.
638
639 players[id] = new YT.Player(contex[id], {
640 playerVars: {
641 autoplay: 0,
642 autohide: 1,
643 modestbranding: 1,
644 rel: 0,
645 showinfo: 0,
646 controls: 0,
647 disablekb: 1,
648 enablejsapi: 0,
649 iv_load_policy: 3,
650 playsinline: 1,
651 loop: 1
652 },
653 events: {
654 'onReady': function onReady() {
655 players[id].cueVideoById(attrs[id]);
656 players[id].mute();
657
658 if ('always' === videoType) {
659 $this.playVideo(id);
660 }
661 },
662 'onStateChange': function onStateChange(e) {
663 if (e.data === 1) {
664 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).contexObject(id).closest('.sight-portfolio-video-wrap').addClass('sight-portfolio-video-bg-init');
665 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).contexObject(id).addClass('active');
666 } else if (e.data === 0) {
667 players[id].seekTo(attrs[id].startSeconds);
668 } else if (e.data === 5) {
669 players[id].videoReady = true;
670 }
671 }
672 }
673 });
674 } else {
675 // Creating a player.
676 players[id] = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(contex[id]); // Ready play.
677
678 players[id].on('canplay', function () {
679 players[id].videoReady = true;
680
681 if (true !== players[id].start) {
682 players[id].start = true;
683 this.currentTime = videoStart ? videoStart : 0;
684
685 if ('always' === videoType) {
686 $this.playVideo(id);
687 }
688 }
689 }); // Play.
690
691 players[id].on('play', function () {
692 players[id].parents('.sight-portfolio-video-wrap').addClass('sight-portfolio-video-bg-init');
693 players[id].addClass('active');
694 }); // Ended.
695
696 players[id].on('timeupdate', function () {
697 if (videoEnd && this.currentTime >= videoEnd) {
698 players[id].trigger('pause');
699 this.currentTime = videoStart;
700 players[id].trigger('play');
701 }
702 });
703 players[id].trigger('load');
704 }
705
706 $this.rescaleVideoBackground();
707 } // Pause and play.
708
709
710 if ('always' === videoType && isActive && isInit && !$this.getVideoUpause(id)) {
711 if (isInView) {
712 $this.playVideo(id);
713 }
714
715 if (!isInView) {
716 $this.pauseVideo(id);
717 }
718 }
719 });
720 },
721 // Construct video background.
722 constructVideoBackground: function constructVideoBackground(object) {
723 if (Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])('body').hasClass('wp-admin')) {
724 return;
725 }
726
727 if (process) {
728 return;
729 }
730
731 process = true; // Smart init API.
732
733 if (!initAPI) {
734 var elements = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])('[data-video-mode="youtube"][data-youtube-id]');
735
736 if (elements.length) {
737 embedYoutubeAPI();
738 initAPI = true;
739 }
740 }
741
742 if (!initAPI) {
743 process = false;
744 } // Play Video.
745
746
747 $this.initVideoBackground('local', object);
748
749 if (initAPI && YTdeferredDone) {
750 $this.initVideoBackground('youtube', object);
751 }
752
753 process = false;
754 },
755 // Get video type.
756 getVideoType: function getVideoType(id) {
757 return Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).contexObject(id, 'container').data('video-type');
758 },
759 // Get video mode.
760 getVideoMode: function getVideoMode(id) {
761 return Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).contexObject(id, 'container').data('video-mode');
762 },
763 // Get video state.
764 getVideoState: function getVideoState(id) {
765 return players[id].videoState;
766 },
767 // Get video ready.
768 getVideoReady: function getVideoReady(id) {
769 return players[id].videoReady ? players[id].videoReady : false;
770 },
771 // Get video upause.
772 getVideoUpause: function getVideoUpause(id) {
773 return players[id].videoUpause ? players[id].videoUpause : false;
774 },
775 // Get video volume.
776 getVideoVolume: function getVideoVolume(id) {
777 return players[id].videoVolume ? players[id].videoVolume : 'mute';
778 },
779 // Change video upause.
780 changeVideoUpause: function changeVideoUpause(id, val) {
781 players[id].videoUpause = val;
782 },
783 // Play video.
784 playVideo: function playVideo(id) {
785 if ('play' === players[id].videoState) {
786 return;
787 }
788
789 if (!players[id].videoReady) {
790 return setTimeout(function () {
791 $this.playVideo(id);
792 }, 100);
793 }
794
795 if ('youtube' === $this.getVideoMode(id)) {
796 players[id].playVideo();
797 } else {
798 players[id].trigger('play');
799 } // Change control.
800
801
802 var control = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).contexObject(id, 'wrap').find('.sight-portfolio-player-state');
803 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(control).removeClass('sight-portfolio-player-pause');
804 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(control).addClass('sight-portfolio-player-play'); // Set state.
805
806 players[id].videoState = 'play';
807 },
808 // Pause video.
809 pauseVideo: function pauseVideo(id) {
810 if ('pause' === players[id].videoState) {
811 return;
812 }
813
814 if (!players[id].videoReady) {
815 return;
816 }
817
818 if ('youtube' === $this.getVideoMode(id)) {
819 players[id].pauseVideo();
820 } else {
821 players[id].trigger('pause');
822 } // Change control.
823
824
825 var control = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).contexObject(id, 'wrap').find('.sight-portfolio-player-state');
826 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(control).removeClass('sight-portfolio-player-play');
827 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(control).addClass('sight-portfolio-player-pause'); // Set state.
828
829 players[id].videoState = 'pause';
830 },
831 // Unmute video.
832 unmuteVideo: function unmuteVideo(id) {
833 if (!players[id].videoReady) {
834 return;
835 }
836
837 if ('youtube' === $this.getVideoMode(id)) {
838 players[id].unMute();
839 } else {
840 players[id].prop('muted', false);
841 } // Change control.
842
843
844 var control = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).contexObject(id, 'wrap').find('.sight-portfolio-player-volume');
845 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(control).removeClass('sight-portfolio-player-mute');
846 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(control).addClass('sight-portfolio-player-unmute'); // Set state.
847
848 players[id].videoVolume = 'unmute';
849 },
850 // Mute video.
851 muteVideo: function muteVideo(id) {
852 if (!players[id].videoReady) {
853 return;
854 }
855
856 if ('youtube' === $this.getVideoMode(id)) {
857 players[id].mute();
858 } else {
859 players[id].prop('muted', true);
860 } // Change control.
861
862
863 var control = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).contexObject(id, 'wrap').find('.sight-portfolio-player-volume');
864 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(control).removeClass('sight-portfolio-player-unmute');
865 Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(control).addClass('sight-portfolio-player-mute'); // Set state.
866
867 players[id].videoVolume = 'muted';
868 },
869 // Toogle video state.
870 toogleVideoState: function toogleVideoState(id) {
871 if ('play' === $this.getVideoState(id)) {
872 $this.pauseVideo(id);
873 } else {
874 $this.playVideo(id);
875 }
876 },
877 // Toogle video volume.
878 toogleVideoVolume: function toogleVideoVolume(id) {
879 if ('unmute' === $this.getVideoVolume(id)) {
880 $this.muteVideo(id);
881 } else {
882 $this.unmuteVideo(id);
883 }
884 },
885
886 /** Events */
887 events: function events(e) {
888 // State Control.
889 _utility__WEBPACK_IMPORTED_MODULE_0__["$doc"].on('click', '.sight-portfolio-player-state', function () {
890 var id = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).contexObject(false, 'inner').attr('data-id');
891 $this.toogleVideoState(id);
892
893 if ('play' === $this.getVideoState(id)) {
894 $this.changeVideoUpause(id, false);
895 } else {
896 $this.changeVideoUpause(id, true);
897 }
898 }); // Stop Control.
899
900 _utility__WEBPACK_IMPORTED_MODULE_0__["$doc"].on('click', '.sight-portfolio-player-stop', function () {
901 var id = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).contexObject(false, 'inner').attr('data-id');
902
903 if ('play' === $this.getVideoState(id)) {
904 $this.changeVideoUpause(id, true);
905 }
906
907 $this.pauseVideo(id);
908 }); // Volume Control.
909
910 _utility__WEBPACK_IMPORTED_MODULE_0__["$doc"].on('click', '.sight-portfolio-player-volume', function () {
911 var id = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).contexObject(false, 'inner').attr('data-id');
912 $this.toogleVideoVolume(id);
913 }); // Mouseover.
914
915 _utility__WEBPACK_IMPORTED_MODULE_0__["$doc"].on('mouseover mousemove', '.sight-portfolio-entry__thumbnail', function () {
916 var id = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).contexObject(false, 'inner').attr('data-id');
917
918 if ('hover' === $this.getVideoType(id)) {
919 $this.playVideo(id);
920 }
921 }); // Mouseout.
922
923 _utility__WEBPACK_IMPORTED_MODULE_0__["$doc"].on('mouseout', '.sight-portfolio-entry__thumbnail', function () {
924 var id = Object(_utility__WEBPACK_IMPORTED_MODULE_0__["$"])(this).contexObject(false, 'inner').attr('data-id');
925
926 if ('hover' === $this.getVideoType(id)) {
927 $this.pauseVideo(id);
928 }
929 }); // Document scroll.
930
931 _utility__WEBPACK_IMPORTED_MODULE_0__["$window"].on('load scroll resize scrollstop', function () {
932 $this.constructVideoBackground();
933 }); // Document ready.
934
935 _utility__WEBPACK_IMPORTED_MODULE_0__["$doc"].ready(function () {
936 $this.constructVideoBackground();
937 }); // Post load.
938
939 _utility__WEBPACK_IMPORTED_MODULE_0__["$body"].on('post-load', function () {
940 $this.constructVideoBackground();
941 }); // Document resize.
942
943 _utility__WEBPACK_IMPORTED_MODULE_0__["$window"].on('resize', function () {
944 $this.rescaleVideoBackground();
945 }); // Init.
946
947 $this.constructVideoBackground();
948 }
949 };
950 })(); // Initialize.
951
952
953 sightVideoPortfolio.init();
954
955 /***/ })
956 /******/ ]);