low-priority.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403
  1. (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
  2. 'use strict';
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = function () {
  7. var $ = jQuery;
  8. var body = $(document.body);
  9. var settings = {};
  10. var mediaElement = function mediaElement(context) {
  11. if (typeof window._wpmejsSettings !== 'undefined') {
  12. settings = $.extend(true, {}, window._wpmejsSettings);
  13. }
  14. settings.classPrefix = 'mejs-';
  15. settings.success = settings.success || function (mejs) {
  16. var autoplay, loop;
  17. if (mejs.rendererName && -1 !== mejs.rendererName.indexOf('flash')) {
  18. autoplay = mejs.attributes.autoplay && 'false' !== mejs.attributes.autoplay;
  19. loop = mejs.attributes.loop && 'false' !== mejs.attributes.loop;
  20. if (autoplay) {
  21. mejs.addEventListener('canplay', function () {
  22. mejs.play();
  23. }, false);
  24. }
  25. if (loop) {
  26. mejs.addEventListener('ended', function () {
  27. mejs.play();
  28. }, false);
  29. }
  30. }
  31. };
  32. if ('mediaelementplayer' in $.fn) {
  33. // Only initialize new media elements.
  34. $('.wp-audio-shortcode, .wp-video-shortcode', context).not('.mejs-container').filter(function () {
  35. return !$(this).parent().hasClass('mejs-mediaelement');
  36. }).mediaelementplayer(settings);
  37. }
  38. };
  39. // infinite scrolling
  40. if (document.body.classList.contains('pagination-infinite-scrolling')) {
  41. var last_auto_load = 0;
  42. $(window).bind('resize scroll', function (e) {
  43. var button = $('.lm-btn'),
  44. now_time = e.timeStamp || new Date().getTime();
  45. if (now_time - last_auto_load > 500 && parseFloat(button.css('opacity'), 10) === 1 && $(window).scrollTop() + $(window).height() >= button.offset().top) {
  46. last_auto_load = now_time;
  47. button.click();
  48. }
  49. });
  50. }
  51. if (!document.body.classList.contains('fl-builder-active')) {
  52. document.body.addEventListener('click', function (e) {
  53. var button = e.target.closest('.load-more');
  54. if (button) {
  55. e.preventDefault();
  56. e.stopPropagation(); // customizer support
  57. var self = $(button);
  58. var list = self.prev();
  59. var link = button.querySelector('a');
  60. if (button.classList.contains('loading')) {
  61. return false;
  62. }
  63. self.addClass('loading').find('> *').animate({ opacity: 0 });
  64. $.post(VAMTAM_FRONT.ajaxurl, {
  65. action: 'vamtam-load-more',
  66. query: JSON.parse(link.dataset.query),
  67. other_vars: JSON.parse(link.dataset.otherVars)
  68. }, function (result) {
  69. var content = $(result.content);
  70. mediaElement(content);
  71. var visible = list.find('.cbp-item:not( .cbp-item-off )').length;
  72. list.cubeportfolio('append', content, function () {
  73. if (visible === list.find('.cbp-item:not( .cbp-item-off )').length) {
  74. var warning = document.createElement('p');
  75. warning.classList.add('vamtam-load-more-warning');
  76. warning.innerText = list.data('hidden-by-filters');
  77. button.after(warning);
  78. body.one('click', function () {
  79. warning.remove();
  80. });
  81. }
  82. button.outerHTML = result.button;
  83. self.removeClass('loading').find('> *').animate({ opacity: 1 });
  84. window.VAMTAM.resizeElements();
  85. });
  86. });
  87. }
  88. });
  89. }
  90. };
  91. },{}],2:[function(require,module,exports){
  92. 'use strict';
  93. Object.defineProperty(exports, "__esModule", {
  94. value: true
  95. });
  96. exports.default = function () {
  97. // button with lightbox
  98. {
  99. window.addEventListener('click', function (e) {
  100. var button = e.target.closest('[data-vamtam-lightbox]');
  101. if (button) {
  102. e.preventDefault();
  103. var contents = document.getElementById('vamtam-lightbox-template');
  104. var lightboxWrapper = document.createElement('div');
  105. lightboxWrapper.classList.add('vamtam-button-lightbox-wrapper');
  106. lightboxWrapper.innerHTML = contents.innerHTML.replace('{{ lightbox_content }}', button.dataset.vamtamLightbox);
  107. var closeLightbox = function closeLightbox(e) {
  108. e.preventDefault();
  109. requestAnimationFrame(function () {
  110. lightboxWrapper.addEventListener('transitionend', function () {
  111. lightboxWrapper.remove();
  112. document.documentElement.style.marginRight = '';
  113. document.documentElement.style.overflow = '';
  114. }, false);
  115. lightboxWrapper.style.transitionDuration = '0.2s';
  116. lightboxWrapper.style.opacity = 0;
  117. });
  118. };
  119. lightboxWrapper.querySelector('.vamtam-button-lightbox-close').addEventListener('click', closeLightbox);
  120. lightboxWrapper.addEventListener('click', closeLightbox);
  121. requestAnimationFrame(function () {
  122. document.body.appendChild(lightboxWrapper);
  123. document.documentElement.style.marginRight = window.innerWidth - document.documentElement.offsetWidth + 'px';
  124. document.documentElement.style.overflow = 'hidden';
  125. window.VAMTAM.resizeElements();
  126. lightboxWrapper.style.opacity = 1;
  127. });
  128. }
  129. });
  130. }
  131. // search
  132. var lightbox = document.getElementById('vamtam-overlay-search');
  133. var inside = lightbox.children;
  134. // initialize styles before any animations
  135. lightbox.style.display = 'none';
  136. for (var i = 0; i < inside.length; i++) {
  137. inside[i].style.animationDuration = '300ms';
  138. inside[i].style.display = 'none';
  139. }
  140. // opening animation
  141. document.body.addEventListener('click', function (e) {
  142. if (e.target.closest('.vamtam-overlay-search-trigger')) {
  143. e.preventDefault();
  144. requestAnimationFrame(function () {
  145. lightbox.classList.add('vamtam-animated', 'vamtam-fadein');
  146. lightbox.style.display = 'block';
  147. setTimeout(function () {
  148. requestAnimationFrame(function () {
  149. for (var i = 0; i < inside.length; i++) {
  150. inside[i].style.display = 'block';
  151. inside[i].classList.add('vamtam-animated', 'vamtam-zoomin');
  152. }
  153. requestAnimationFrame(function () {
  154. lightbox.querySelector('input[type=search]').focus();
  155. });
  156. });
  157. }, 200);
  158. });
  159. }
  160. });
  161. var $lightbox = jQuery(lightbox);
  162. // closing animation
  163. document.getElementById('vamtam-overlay-search-close').addEventListener('click', function (e) {
  164. e.preventDefault();
  165. requestAnimationFrame(function () {
  166. lightbox.classList.remove('vamtam-animated', 'vamtam-fadein');
  167. lightbox.classList.add('vamtam-animated', 'vamtam-fadeout');
  168. for (var i = 0; i < inside.length; i++) {
  169. inside[i].classList.remove('vamtam-animated', 'vamtam-zoomin');
  170. inside[i].classList.add('vamtam-animated', 'vamtam-zoomout');
  171. }
  172. $lightbox.one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', function () {
  173. requestAnimationFrame(function () {
  174. lightbox.style.display = 'none';
  175. lightbox.classList.remove('vamtam-animated', 'vamtam-fadeout');
  176. for (var i = 0; i < inside.length; i++) {
  177. inside[i].style.display = 'none';
  178. inside[i].classList.remove('vamtam-animated', 'vamtam-zoomout');
  179. }
  180. });
  181. });
  182. });
  183. });
  184. };
  185. },{}],3:[function(require,module,exports){
  186. 'use strict';
  187. var _portfolio = require('./portfolio');
  188. var _portfolio2 = _interopRequireDefault(_portfolio);
  189. var _ajaxNavigation = require('./ajax-navigation');
  190. var _ajaxNavigation2 = _interopRequireDefault(_ajaxNavigation);
  191. var _lightbox = require('./lightbox');
  192. var _lightbox2 = _interopRequireDefault(_lightbox);
  193. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  194. (function (v, undefined) {
  195. 'use strict';
  196. // portfolio
  197. v.portfolio = new _portfolio2.default();
  198. // infinite scrolling
  199. (0, _ajaxNavigation2.default)();
  200. // lightbox
  201. (0, _lightbox2.default)();
  202. // scroll to top button
  203. {
  204. var st_buttons = document.querySelectorAll('.vamtam-scroll-to-top');
  205. if (st_buttons.length) {
  206. vamtam_greensock_wait(function () {
  207. var side_st_button = document.getElementById('scroll-to-top');
  208. if (side_st_button) {
  209. v.addScrollHandler({
  210. init: function init() {},
  211. measure: function measure() {},
  212. mutate: function mutate(cpos) {
  213. if (cpos > 0) {
  214. side_st_button.style.opacity = 1;
  215. side_st_button.style.transform = 'scale3d( 1, 1, 1 )';
  216. } else {
  217. side_st_button.style.opacity = '';
  218. side_st_button.style.transform = '';
  219. }
  220. }
  221. });
  222. }
  223. document.addEventListener('click', function (e) {
  224. if (e.target.classList.contains('vamtam-scroll-to-top')) {
  225. e.preventDefault();
  226. vamtam_greensock_wait(function () {
  227. // iOS Safari uses a simple animation, normal browsers use scroll-behavior:smooth
  228. if (/iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream) {
  229. window.scrollTo(0, 0);
  230. } else {
  231. window.scroll({ left: 0, top: 0, behavior: 'smooth' });
  232. }
  233. });
  234. }
  235. }, true);
  236. });
  237. }
  238. }
  239. })(window.VAMTAM); /* jshint esversion: 6 */
  240. },{"./ajax-navigation":1,"./lightbox":2,"./portfolio":4}],4:[function(require,module,exports){
  241. 'use strict';
  242. Object.defineProperty(exports, "__esModule", {
  243. value: true
  244. });
  245. /* jshint esversion: 6, module: true */
  246. var $ = jQuery;
  247. var Portfolio = function Portfolio() {
  248. $(function () {
  249. this.init();
  250. }.bind(this));
  251. };
  252. Portfolio.prototype.init = function () {
  253. this.wrappers = $('.portfolios');
  254. this.wrappers.on('mouseenter', '.vamtam-project', this.mouseenter.bind(this));
  255. this.wrappers.on('mouseleave', '.vamtam-project', this.mouseleave.bind(this));
  256. this.wrappers.on('touchstart', '.vamtam-project', this.touchstart.bind(this));
  257. this.wrappers.on('touchmove', '.vamtam-project', this.touchmove.bind(this));
  258. this.wrappers.on('touchend', '.vamtam-project', this.touchend.bind(this));
  259. // close all open projects on touchstart anywhere outside a project
  260. document.body.addEventListener('touchstart', function (e) {
  261. var closest = e.target.closest('.vamtam-project');
  262. var open = document.querySelectorAll('.vamtam-project.state-open');
  263. for (var i = 0; i < open.length; i++) {
  264. if (open[i] !== closest) {
  265. this.doClose(open[i]);
  266. }
  267. }
  268. }.bind(this));
  269. };
  270. Portfolio.prototype.mouseenter = function (e) {
  271. this.doOpen(e.target.closest('.vamtam-project'));
  272. };
  273. Portfolio.prototype.mouseleave = function (e) {
  274. this.doClose(e.target.closest('.vamtam-project'));
  275. };
  276. Portfolio.prototype.touchstart = function (e) {
  277. var item = e.target.closest('.vamtam-project');
  278. if (item.classList.contains('state-closed') && !window.VAMTAM.MEDIA.layout['layout-below-max']) {
  279. item.vamtamMaybeOpen = true;
  280. }
  281. };
  282. Portfolio.prototype.touchend = function (e) {
  283. var item = e.target.closest('.vamtam-project');
  284. if (item.vamtamMaybeOpen) {
  285. item.vamtamMaybeOpen = false;
  286. this.doOpen(item);
  287. e.preventDefault();
  288. }
  289. };
  290. Portfolio.prototype.touchmove = function (e) {
  291. e.target.closest('.vamtam-project').vamtamMaybeOpen = false;
  292. };
  293. Portfolio.prototype.doOpen = function (el) {
  294. if (!el.classList.contains('state-open')) {
  295. requestAnimationFrame(function () {
  296. el.classList.add('state-open');
  297. el.classList.remove('state-closed');
  298. });
  299. }
  300. };
  301. Portfolio.prototype.doClose = function (el) {
  302. if (!el.classList.contains('state-closed')) {
  303. requestAnimationFrame(function () {
  304. el.classList.add('state-closed');
  305. el.classList.remove('state-open');
  306. });
  307. }
  308. };
  309. exports.default = Portfolio;
  310. },{}]},{},[3]);