PluginProbe
Sight – Professional Image Gallery and Portfolio / 1.0.6
Sight – Professional Image Gallery and Portfolio v1.0.6
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.0.6, at render/js/sight.js

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