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

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