· 5 years ago · Jun 18, 2020, 04:32 AM
1window.brayn = window.brayn || {};
2
3/**
4 * Load script by Ajax
5 */
6jQuery.cachedScript = function( url, options ) {
7 "use strict";
8 options = jQuery.extend( options || {}, {
9 dataType: "script",
10 cache: true,
11 url: url
12 });
13 return jQuery.ajax( options );
14};
15
16// Hero image animation
17window.brayn.heroRipple = function($) {
18 "use strict";
19 var hr = {
20 init: function() {
21 var x=this;
22 x.sizes={};
23 x.onResize = x.destroyed = false;
24 x.el = x.renderer = x.stage = x.canvascontainer = x.nimage = x.iRender = x.baseTimeline = x.image = x.filter = x.after = null;
25
26 PIXI.utils.skipHello();
27 x.getWindowSize();
28 },
29 start:function( el, image, filter, after ) {
30 var x=this;
31
32 x.destroyed = false;
33 x.el = el;
34 x.image = image;
35 x.filter = filter;
36 x.after = after;
37
38 x.getWindowSize();
39
40 x.build_renderer();
41
42 if ( ! PIXI.loader.resources.hasOwnProperty( x.filter ) ) {
43 PIXI.loader.add( x.filter );
44 }
45
46 if ( ! PIXI.loader.resources.hasOwnProperty( x.image ) ) {
47 PIXI.loader.add( x.image );
48 }
49
50 PIXI.loader.load(function(loader, resources){
51 x.setup();
52 });
53 },
54 setup: function() {
55 var x=this;
56
57 // reset renderer
58 if ( ! x.renderer instanceof PIXI.CanvasRenderer ) {
59 x.renderer.reset();
60 }
61
62 x.stage = new PIXI.Container();
63 x.canvascontainer = new PIXI.Container();
64
65 var displacementSprite = new PIXI.Sprite( PIXI.loader.resources[x.filter].texture );
66 var displacementFilter = new PIXI.filters.DisplacementFilter( displacementSprite );
67
68 displacementSprite.texture.baseTexture.wrapMode = PIXI.WRAP_MODES.REPEAT;
69 displacementSprite.scale.x = 1.2;
70 displacementSprite.scale.y = 1.2;
71
72 // append the canvas to element
73 x.el.appendChild( x.renderer.view );
74 // style up the canvas
75 x.renderer.view.style.position = 'absolute';
76 x.renderer.view.style.maxWidth = '100%';
77 x.renderer.view.style.width = '100%';
78 x.renderer.view.style.height = '100%';
79 x.renderer.view.style.zIndex = '-99';
80 x.renderer.view.style.top = '0';
81 x.renderer.view.style.left = '0';
82 x.renderer.view.style.opacity = '0';
83 x.renderer.view.style.webkitPerspective = '1000';
84
85 x.stage.addChild( x.canvascontainer );
86 x.stage.addChild( displacementSprite );
87 x.stage.interactive = false;
88 x.stage.filters = [displacementFilter];
89
90 // setup the filter
91 displacementFilter.scale.alpha = 0;
92 displacementFilter.scale.x = 20;
93 displacementFilter.scale.y = 20;
94
95 x.nimage = new PIXI.Sprite( PIXI.loader.resources[x.image].texture );
96 x.sizes.tw = PIXI.loader.resources[x.image].texture.width;
97 x.sizes.th = PIXI.loader.resources[x.image].texture.height;
98
99 // set the size
100 x.resizeImage();
101
102 x.canvascontainer.alpha = 0;
103 x.canvascontainer.scale.x = 0.5;
104 x.canvascontainer.scale.y = 0.5;
105 x.canvascontainer.addChild( x.nimage );
106
107 x.iRender = new PIXI.ticker.Ticker();
108 x.iRender.autoStart = true;
109 x.iRender.add(function( delta ) {
110 if ( !x.destroyed && x.renderer ) {
111 displacementSprite.x += 10 * delta;
112 displacementSprite.y += 3;
113 x.renderer.render( x.stage );
114 }
115 });
116
117 $(window).one('braynHasFinishLoad', function () {
118 x.showit(displacementSprite, displacementFilter);
119 x.listenEvent();
120 });
121
122 },
123 showit: function(displacementSprite, displacementFilter) {
124 var x=this;
125 x.baseTimeline = new anime.timeline({
126 loop: false,
127 autoplay: true,
128 complete: function() {
129 $(x.el).find('img').css({opacity:1});
130 window.requestTimeout( function() {
131 x.canvascontainer.alpha = 0;
132 displacementSprite.texture.baseTexture.dispose();
133 x.__destroy();
134 $(x.el).find('canvas').detach();
135 },50);
136 }
137 });
138
139 x.canvascontainer.position.x = ( $(x.el).width() - (x.nimage.width/2) )/2;
140 x.canvascontainer.position.y = $(x.el).height();
141 x.renderer.view.style.opacity = '1';
142 var endScale = ( /iPad|iPhone|iPod|Android/.test(navigator.userAgent) ) ? {x:0,y:0} : {x:2,y:2};
143 x.baseTimeline.add({
144 targets: x.canvascontainer,
145 duration: 1000,
146 alpha: 1,
147 easing: 'easeInOutCirc',
148 }).add({
149 targets: x.canvascontainer.position,
150 duration: 1000,
151 y: ( $(x.el).height() - (x.nimage.height/2) )/2,
152 easing: 'easeInOutCirc',
153 }, '-=1000').add({
154 targets: x.canvascontainer.scale,
155 duration: 1500,
156 x: 1,
157 y: 1,
158 easing: 'easeInOutCirc',
159 }).add({
160 targets: x.canvascontainer.position,
161 duration: 1500,
162 y: (x.nimage.height-$(x.el).height())/-2,
163 x: (x.nimage.width-$(x.el).width())/-2,
164 easing: 'easeInOutCirc',
165 complete: function() {
166 if ( typeof x.after === 'function' ) {
167 x.after();
168 }
169 }
170 }, '-=1500').add({
171 targets: displacementSprite.scale,
172 duration: 1000,
173 x: 1,
174 y: 1,
175 easing: 'easeInOutCirc'
176 }).add({
177 targets: displacementFilter.scale,
178 duration: 2000,
179 x: endScale.x,
180 y: endScale.y,
181 delay: 1500,
182 easing: 'easeInOutCirc'
183 });
184 },
185 build_renderer: function() {
186 var x=this;
187 if ( x.renderer ) {
188 return x.renderer;
189 }
190
191 x.renderer = new PIXI.autoDetectRenderer( x.sizes.w, x.sizes.h, { transparent: true, autoResize: true });
192 return x.renderer;
193 },
194 resizeImage: function() {
195 var x=this;
196
197 if ( x.onResize ) {
198 window.clearRequestTimeout( x.onResize );
199 }
200
201 x.onResize = window.requestTimeout(function(){
202 x.nimage.width = $(x.el).find('img').width();
203 x.nimage.height = ($(x.el).find('img').width()/x.sizes.tw)*x.sizes.th;
204 if ( x.nimage.height < $(x.el).height() ) {
205 x.nimage.width = ($(x.el).height()/x.nimage.height)*x.nimage.width;
206 x.nimage.height = $(x.el).height();
207 }
208
209 x.canvascontainer.position.x = (x.nimage.width-$(x.el).width())/-2;
210 x.canvascontainer.position.y = (x.nimage.height-$(x.el).height())/-2;
211 },10);
212 },
213 resize: function() {
214 var x=this;
215 x.resizeImage();
216 x.renderer.resize( x.sizes.w, x.sizes.h );
217
218 },
219 listenEvent: function() {
220 var x=this;
221
222 $(window).on('resize',function(){
223 if ( !x.destroyed ) {
224 x.getWindowSize();
225 x.resize();
226 }
227 });
228 },
229 __destroy: function() {
230 var x=this;
231
232 x.stage.filters = null;
233 x.iRender.remove();
234 x.canvascontainer.removeChild();
235 x.stage.removeChild();
236 x.renderer.destroy();
237 x.renderer = x.stage = x.canvascontainer = x.nimage = x.iRender = x.baseTimeline = x.image = x.filter = x.after = null;
238 x.destroyed = true;
239 },
240 getWindowSize: function() {
241 var x=this,
242 wdw=window,
243 d=document,
244 e=d.documentElement,
245 g=d.getElementsByTagName('body')[0];
246
247 x.sizes.w = wdw.innerWidth||e.clientWidth||g.clientWidth;
248 x.sizes.h = wdw.innerHeight||e.clientHeight||g.clientHeight;
249 }
250 };
251 hr.init();
252 return hr;
253}(window.jQuery);
254
255// Animation images, use it only for few sections,
256// webGL is awesome, but it cost memory more
257var pSlideCanvas = function () {
258 function pSlideCanvas(parentEl, el, interaction, filterObj, sizes) {
259 "use strict";
260
261 _classCallCheck(this, pSlideCanvas);
262
263 PIXI.utils.skipHello();
264 this.build = {};
265 this.build.parentEl = parentEl;
266 this.build.el = el;
267 this.build.sizes = sizes;
268 this.build.interaction = interaction;
269 this.build.filterObj = filterObj;
270
271 if (typeof this.build.filterObj === 'undefined') {
272 this.build.filterObj = 'assets/images/clouds-s.jpg';
273 }
274
275 this.build.baseTimeline = new Array();
276 this.readAssets();
277 }
278
279 _createClass(pSlideCanvas, [{
280 key: "readAssets",
281 value: function readAssets() {
282 var that = this;
283 this.build.count = 0;
284 this.build.elemSizes = [];
285 that.build.hovered = [];
286
287 if (Array.isArray(that.build.el)) {
288 that.build.el.forEach(function (ell) {
289 that.loadAssets(ell, that.build.count);
290 that.build.elemSizes[that.build.count] = {
291 el: ell,
292 width: jQuery(ell).find('img').width(),
293 height: jQuery(ell).find('img').height()
294 };
295 that.build.hovered[that.build.count] = false;
296 ++that.build.count;
297 });
298 } else {
299 that.build.elemSizes[that.build.count] = {
300 el: that.build.el,
301 width: jQuery(that.build.el).find('img').width(),
302 height: jQuery(that.build.el).find('img').height()
303 };
304 that.build.hovered[that.build.count] = false;
305 that.loadAssets(that.build.el, that.build.count);
306 }
307
308 this.build.loader.add('objFilter', that.build.filterObj);
309 this.build.loader.load(function (loader, resources) {
310 that.buildCanvas(loader, resources);
311 loader.reset();
312 });
313 }
314 }, {
315 key: "loadAssets",
316 value: function loadAssets(ell, counter) {
317 if (typeof this.build.loader === 'undefined') {
318 this.build.loader = new PIXI.loaders.Loader();
319 }
320
321 this.build.loader.add('objSprite' + counter, jQuery(ell).find('img').attr('src'));
322 }
323 }, {
324 key: "buildCanvas",
325 value: function buildCanvas(loader, resources) {
326 var that = this;
327
328 if (typeof that.build.renderer === 'undefined') {
329 that.build.renderer = new PIXI.autoDetectRenderer(that.build.sizes.width, that.build.sizes.height, {
330 transparent: true,
331 autoResize: true
332 });
333 }
334
335 that.build.stage = new PIXI.Container();
336 that.build.displacementSprite = new PIXI.Sprite.fromImage(that.build.filterObj);
337 that.build.displacementFilter = new PIXI.filters.DisplacementFilter(that.build.displacementSprite);
338 jQuery(that.build.parentEl).append(that.build.renderer.view);
339 that.build.stage.interactive = true;
340 that.build.slidesContainer = new Array();
341 that.build.image = new Array();
342
343 for (var i = 0; i < that.build.elemSizes.length; i++) {
344 that.build.slidesContainer[i] = new PIXI.Container();
345 var texture = new PIXI.Texture.fromImage(loader.resources['objSprite' + i].url);
346 that.build.image[i] = new PIXI.Sprite(texture);
347 that.build.image[i].width = that.build.elemSizes[i].width;
348 that.build.image[i].height = that.build.elemSizes[i].height;
349 that.build.slidesContainer[i].alpha = 0;
350 that.build.slidesContainer[i].addChild(that.build.image[i]);
351 that.build.stage.addChild(that.build.slidesContainer[i]);
352 }
353
354 that.build.renderer.view.style.position = 'absolute';
355 that.build.renderer.view.style.maxWidth = '100%';
356 that.build.renderer.view.style.width = '100%';
357 that.build.renderer.view.style.height = '100%';
358 that.build.renderer.view.style.zIndex = '-1';
359 that.build.renderer.view.style.top = '50%';
360 that.build.renderer.view.style.left = '50%';
361 that.build.renderer.view.style.webkitTransform = 'translate( -50%, -50% )';
362 that.build.renderer.view.style.transform = 'translate( -50%, -50% )';
363 that.build.displacementSprite.texture.baseTexture.wrapMode = PIXI.WRAP_MODES.REPEAT;
364 that.build.displacementSprite.scale.x = 5;
365 that.build.displacementSprite.scale.y = 5;
366 that.build.stage.addChild(that.build.displacementSprite);
367 that.build.stage.filters = [that.build.displacementFilter];
368 that.build.displacementFilter.scale.alpha = 0;
369 that.build.displacementFilter.scale.x = 900;
370 that.build.displacementFilter.scale.y = 450;
371 that.build.iRender = new PIXI.ticker.Ticker();
372 that.build.iRender.autoStart = true;
373 that.build.iRender.add(function (delta) {
374 if (that.build && that.build.renderer) {
375 that.build.renderer.render(that.build.stage);
376 }
377 });
378
379 if (that.build.interaction === 'hover') {
380 that.listenEvent();
381 } else if (that.build.interaction === 'hide') {
382 that.build.displacementSprite.scale.x = 2;
383 that.build.displacementSprite.scale.y = 2;
384 that.attachNewListener();
385 } else {
386 that.build.displacementSprite.scale.x = 2;
387 that.build.displacementSprite.scale.y = 2;
388 that.show_destroy();
389 }
390 }
391 }, {
392 key: "attachNewListener",
393 value: function attachNewListener() {
394 var that = this;
395 jQuery(that.build.parentEl).on('customShowCanvas', function () {
396 that.build.baseTimeline = new anime.timeline({
397 loop: false,
398 autoplay: true,
399 complete: function complete() {
400 jQuery(that.build.parentEl).find('img').css({
401 opacity: 1
402 });
403
404 for (var i = 0; i < that.build.slidesContainer.length; i++) {
405 that.build.slidesContainer[i].alpha = 0;
406 }
407
408 that.build.displacementFilter.scale.alpha = 0;
409 that.build.displacementFilter.scale.x = 900;
410 that.build.displacementFilter.scale.y = 450;
411 that.build.displacementSprite.scale.x = 2;
412 that.build.displacementSprite.scale.y = 2;
413 }
414 });
415 that.build.baseTimeline.add({
416 targets: that.build.displacementFilter.scale,
417 duration: 1000,
418 alpha: 1,
419 x: 0,
420 y: 0,
421 easing: 'easeInOutCirc'
422 }).add({
423 targets: that.build.slidesContainer,
424 duration: 1000,
425 alpha: 1,
426 easing: 'easeInOutCirc'
427 }, '-=1000');
428 });
429 }
430 }, {
431 key: "listenEvent",
432 value: function listenEvent() {
433 var that = this;
434 jQuery(window).on('braynBeforeLoadNewCanvas', function () {
435 jQuery(window).off('resize');
436 });
437 $(that.build.slidesContainer).each(function (i) {
438 var k = i;
439 jQuery(that.build.elemSizes[k].el).on('mouseover', function () {
440 requestAnimationFrame(function () {
441 if (!that.build.hovered[k]) {
442 that.showit(k);
443 that.build.baseTimeline[k].play();
444 } else {
445 that.build.baseTimeline[k].play();
446 that.build.baseTimeline[k].reverse();
447 }
448 });
449 }).on('mouseleave', function () {
450 requestAnimationFrame(function () {
451 that.build.baseTimeline[k].play();
452 that.build.baseTimeline[k].reverse();
453 });
454 });
455 });
456 }
457 }, {
458 key: "showit",
459 value: function showit(i) {
460 var that = this;
461 that.build.baseTimeline[i] = new anime.timeline({
462 loop: false,
463 autoplay: false,
464 complete: function complete() {
465 that.build.hovered[i] = true;
466 }
467 });
468 var koko = that.build.slidesContainer[i];
469 that.build.baseTimeline[i].add({
470 targets: that.build.displacementFilter.scale,
471 duration: 1000,
472 alpha: 1,
473 x: 0,
474 y: 0,
475 easing: 'easeInOutCirc'
476 }).add({
477 targets: koko,
478 duration: 1000,
479 alpha: 1,
480 easing: 'easeInOutCirc'
481 }, '-=1000');
482 }
483 }, {
484 key: "show_destroy",
485 value: function show_destroy() {
486 var that = this;
487 that.build.baseTimeline = new anime.timeline({
488 loop: false,
489 autoplay: true,
490 complete: function complete() {
491 jQuery(that.build.parentEl).find('img').css({
492 opacity: 1
493 });
494 window.requestTimeout(function () {
495 that.build.displacementFilter.scale.alpha = 0;
496
497 for (var i = 0; i < that.build.slidesContainer.length; i++) {
498 that.build.slidesContainer[i].alpha = 0;
499 }
500
501 that.__destroy();
502 }, 50);
503 }
504 });
505 that.build.baseTimeline.add({
506 targets: that.build.displacementFilter.scale,
507 duration: 1200,
508 alpha: 1,
509 x: 0,
510 y: 0,
511 easing: 'easeInOutCirc'
512 }).add({
513 targets: that.build.slidesContainer,
514 duration: 1200,
515 alpha: 1,
516 easing: 'easeInOutCirc'
517 }, '-=1200');
518 }
519 }, {
520 key: "__destroy",
521 value: function __destroy() {
522 this.build.stage.filters = null;
523 this.build.iRender.remove();
524 this.build.stage.removeChild();
525 this.build.baseTimeline = this.build.slidesContainer = this.build.displacementSprite = this.build.displacementFilter = this.build.itexture = this.build.image = null;
526 this.build.renderer.destroy(true);
527 }
528 }]);
529
530 return pSlideCanvas;
531}();
532
533/**
534 * Custom scroll event
535 * @author wip-themes
536 * for Aiteko version 1.1.0
537 */
538(function($){
539 $.fn.aitekoScrollbar = function (options) {
540 var settings = $.extend({}, $.fn.aitekoScrollbar.defaults, options);
541
542 return this.each(function(){
543 var d=this,
544 requestScrollId = null,
545 scroller = {
546 target: d,
547 ease: settings.ease,
548 endY: 0,
549 y: 0,
550 resizeRequest: 1,
551 scrollRequest: 0,
552 };
553
554 function updateScroller() {
555 var body = document.body,
556 html = document.documentElement,
557 resized = scroller.resizeRequest > 0,
558 useSmoothScroll = true;
559
560 if ( html.className.includes('default-scroll') ) {
561 useSmoothScroll = false;
562 }
563
564 if (resized) {
565 var height = scroller.target.clientHeight;
566 body.style.height = height + "px";
567 scroller.resizeRequest = 0;
568 }
569
570 var scrollY = window.pageYOffset || html.scrollTop || body.scrollTop || 0;
571
572 scroller.endY = scrollY;
573 scroller.y += (scrollY - scroller.y) * scroller.ease;
574
575 if (Math.abs(scrollY - scroller.y) < 0.05 || resized) {
576 scroller.y = scrollY;
577 scroller.scrollRequest = 0;
578 }
579
580 if ( /iPad|iPhone|iPod|Android/.test(navigator.userAgent) || useSmoothScroll === false ) {
581
582 scroller.target.style.msTransform = 'matrix(1, 0, 0, 1, 0, 0)';
583 scroller.target.style.webkitTransform = 'matrix(1, 0, 0, 1, 0, 0)';
584 scroller.target.style.transform = 'matrix(1, 0, 0, 1, 0, 0)';
585 $(scroller.target).parent().css({'position': 'absolute'});
586
587 // incase someone need to play around with these values
588 $(window).trigger('braynScrolled', [scroller, scrollY ]);
589 } else {
590
591 $(scroller.target).parent().css({'position': ''});
592
593 scroller.target.style.willChange = 'transform';
594 scroller.target.style.msTransform = 'matrix(1, 0, 0, 1, 0, '+ -scroller.y +')';
595 scroller.target.style.webkitTransform = 'matrix(1, 0, 0, 1, 0, '+ -scroller.y +')';
596 scroller.target.style.transform = 'matrix(1, 0, 0, 1, 0, '+ -scroller.y +')';
597
598 // incase someone need to play around with these values
599 $(window).trigger('braynScrolled', [scroller, scroller.y]);
600 }
601
602 requestScrollId = scroller.scrollRequest > 0 ? requestAnimationFrame( updateScroller ) : null;
603 };
604
605 function onResize() {
606 var body = document.body;
607
608 scroller.scrollRequest++;
609 if (!requestScrollId) {
610 requestScrollId = requestAnimationFrame( updateScroller );
611 }
612 };
613
614 function onScroll() {
615 scroller.scrollRequest++;
616
617 if (!requestScrollId) {
618 requestScrollId = requestAnimationFrame( updateScroller );
619 }
620 };
621
622 function tracking() {
623 var el = scroller.target,
624 body = document.body,
625 c = document.createDocumentFragment(),
626 sizes = {};
627
628 var div = document.createElement('div');
629
630 c.appendChild(div);
631 div.className = 'aitekoresizedetect';
632 div.style.position = 'absolute';
633 div.style.width = 'auto';
634 div.style.height = 'auto';
635 div.style.top = 0;
636 div.style.left = 0;
637 div.style.bottom = 0;
638 div.style.right = 0;
639 div.style.zIndex = -1;
640 div.style.overflow = 'hidden';
641 div.style.visibility = 'hidden';
642 div.innerHTML = "<iframe id='displayframe' style='height:100%;width:0;border:0;visibility:visible;margin:0'></iframe>";
643
644 if ( $('.aitekoresizedetect').length < 1 ) {
645 el.appendChild(c);
646 }
647
648 var iframeWin = document.getElementById('displayframe').contentWindow;
649 iframeWin.addEventListener('resize', function(){
650 var h = this.document.body.scrollHeight;
651 body.style.height = h + "px";
652 });
653 };
654
655 function init() {
656 $(window).scrollTop(0);
657 updateScroller();
658 window.focus();
659 tracking();
660 window.addEventListener("resize", onResize );
661 document.addEventListener("scroll", onScroll );
662
663 $(document).ready( function() {
664 $(window).scrollTop(0);
665 $('html, body').scrollTop(0);
666 $(scroller.target).parent().scrollTop(0);
667 });
668 };
669 init();
670 });
671 };
672
673 $.fn.aitekoScrollbar.defaults = {
674 ease: 0.10
675 };
676})(window.jQuery);
677
678window.brayn.frontend = function($) {
679 "use strict";
680 var z = {
681 $win: $(window),
682 $doc: $(document),
683 init: function() {
684 var d=this;
685 d.headerSize = d.origScroll = 0;
686 d.onMenuShow = d.menuShowed = d.getter = d.getterProcess = d.onAjaxProgress = d.popStateProcess = false;
687 d.initialLoaded = true;
688 d.blurryImage = {};
689
690 d.$doc.ready(function(){
691 PIXI.utils.skipHello();
692 d.initialLoadHistory();
693 d.parallaxInit();
694 });
695
696 d.$win.on('load', function() {
697 d.getHeaderSize();
698
699 d.$doc.unbind().on('click', 'a', function(e){
700 var z=this;
701
702 if ( z.href.indexOf('#') !== -1 ) {
703 var ccid = z.hash.substring(1),
704 realURL = z.href.substr(0,z.href.indexOf('#'));
705
706 // Process haschange
707 if (ccid && ( z.pathname === window.location.pathname ) ) {
708 e.preventDefault();
709 d.hashChangeHandler(z);
710 return false;
711 }
712 }
713
714 if ( d.linkisLocal(z) ) {
715 // if other pages still in process, cancel.
716 if ( d.onAjaxProgress ) {
717 return false;
718 }
719
720 // tell our script, that we are not in firsload anymore.
721 d.initialLoaded = false;
722 // start the transition.
723 d.callthepage(e);
724 }
725 });
726
727 });
728
729 d.$win.on('hashchange', function (e) {
730 return false;
731 });
732
733 // Popstate even a.k.a next/previous browser history
734 window.addEventListener('popstate', function(e){
735 var evo = e;
736 $(window).trigger('braynBeforeLoadNewCanvas');
737 d.popStateProcess = requestAnimationFrame( function() {
738 d.popStateHandler(evo);
739 });
740 });
741
742 // only trigger on the first time page load
743 d.$win.on('braynHasDoneLoad', function() {
744 d.removeLoader();
745 });
746
747 // The event after loader is completely removed
748 d.$win.on('braynHasFinishLoad', function() {
749 if ( d.popStateProcess ) {
750 cancelAnimationFrame(d.popStateProcess);
751 d.popStateProcess = !d.popStateProcess;
752 }
753 d.shrinkHeader();
754 d.funcCaller();
755 d.prettyReveal();
756 d.menuListener();
757
758 d.origScroll = d.$win.scrollTop();
759
760 $('#scroll-viewport').aitekoScrollbar();
761
762 if ( window.location.hash ) {
763 var tgt = window.location.hash.substring(1);
764 if ( tgt ) {
765 window.requestTimeout(function(){
766 if ( /iPad|iPhone|iPod|Android/.test(navigator.userAgent) || document.documentElement.className.includes('default-scroll') ) {
767 $('html, body').animate({ scrollTop : Math.round($('#'+tgt).offset().top)-100 }, 300 );
768 } else {
769 $(window).scrollTop( Math.round($('#'+tgt).offset().top)-100 );
770 }
771
772 }, 500);
773 }
774 }
775
776 d.processContactForm();
777
778 });
779
780 // resize
781 d.$win.on('resize', function(e) {
782 d.getHeaderSize();
783 d.floatEdgeMedia();
784 });
785
786 // Scroll.
787 d.$win.on('scroll', function() {
788 //d.shrinkHeader();
789 d.watchPortfolioGridItems();
790 });
791
792 d.$win.on('braynScrolled', function(e, bs, bstop) {
793
794 if ( ( bstop < d.$win.height() ) && $('.jarallax-img').length && ( /iPad|iPhone|iPod|Android/.test(navigator.userAgent) === false ) ) {
795 $('.jarallax-img').css({
796 webkitTransform: 'translate3d(0, '+ ( bstop === 0 ? 0 : bstop*0.5 ) +'px, 0)',
797 transform: 'translate3d(0, '+ ( bstop === 0 ? 0 : bstop*0.5 ) +'px, 0)',
798 });
799
800 if ( $('#brayn-section-hero').find('canvas').length ) {
801 $('#brayn-section-hero').find('canvas').css({top: ( bstop === 0 ? 0 : bstop*0.5 ) +'px'});
802 }
803 }
804 });
805 },
806
807 /**
808 * The initial load a.k.a first time load OR after refresh
809 *
810 * @since 1.0.0
811 */
812 initialLoadHistory: function() {
813 var d=this, data={};
814
815 // save the current page data
816 data['doc_title'] = $('title').html(),
817 data['main_content'] = $('#main').html(),
818 data['body_classes'] = $('body').attr('class');
819
820 // in any case user modify the template
821 // add more scripts, etc.
822 var dynamicScripts = $('script');
823 if ( $(dynamicScripts).length ) {
824 var scriptLinks = {};
825 $(dynamicScripts).each( function(i) {
826 var _scriptcontent = ( typeof $(this).attr('src') !== 'undefined' ? $(this).attr('src') : $(this).html() ),
827 _scriptid = ( typeof $(this).attr('src') !== 'undefined' ? 'src_'+i : 'content_'+i );
828 scriptLinks[_scriptid] = _scriptcontent;
829 });
830 data['embeded_scripts'] = scriptLinks;
831 }
832
833 //save to browser history API
834 history.replaceState( data, data['doc_title'], '' );
835 },
836
837 hashChangeHandler: function(el) {
838 var ccid = el.hash.substring(1);
839 if ( ccid ) {
840 if ( /iPad|iPhone|iPod|Android/.test(navigator.userAgent) || document.documentElement.className.includes('default-scroll') ) {
841 $('html, body').animate({ scrollTop : Math.round($('#'+ccid).offset().top)-100 }, 300 );
842 } else {
843 $(window).scrollTop( Math.round($('#'+ccid).offset().top)-100 );
844 }
845 }
846 },
847
848 /**
849 * Popstate handler
850 *
851 * @since 1.0.0
852 */
853 popStateHandler: function(e) {
854 var d=this;
855
856 if ( !e.state || typeof e.state.doc_title === 'undefined' ) {
857 cancelAnimationFrame(d.popStateProcess);
858 d.popStateProcess = !d.popStateProcess;
859 return false;
860 }
861
862 if ( d.menuShowed ) {
863 // close the menu
864 $('button.hamburger__menu').trigger('click');
865 }
866 $('title').html( e.state.doc_title );
867
868 requestAnimationFrame( function() {
869 d.pageTransit();
870 });
871
872 d.$win.one('braynReadyForNewPage', function() {
873 $(window).scrollTop(0);
874 $('#site').removeAttr('style');
875 $('body').removeAttr('style').attr('class', e.state.body_classes );
876 $('#main').removeAttr('style').html(e.state.main_content);
877
878 // apply the scripts, incase any special script for different pages
879 if ( typeof e.state.embeded_scripts !== 'undefined' ) {
880 var _js = e.state.embeded_scripts, scriptDiv = $("<div id='brayn-mo-script' />");
881
882 if ( $('#brayn-mo-script').length < 1 ) {
883 $('body').append($(scriptDiv));
884 $('#brayn-mo-script').css({width:0,height:0,overflow:'hidden'});
885 } else {
886 $('#brayn-mo-script').html('');
887 }
888
889 $('style[id*="jarallax-clip"]').detach().remove();
890 $('script').each(function() {
891 var js__src = ( typeof $(this).attr('src') !== 'undefined' ? $(this).attr('src') : '' );
892 if ( js__src.indexOf('assets/js/jquery.min.js') == -1 && js__src.indexOf('assets/js/app.js') == -1 && js__src.indexOf('assets/js/plugins.js') == -1 ) {
893 $(this).detach().remove();
894 }
895 });
896
897 for( var _jsid in _js ) {
898 if (_js.hasOwnProperty(_jsid)) {
899 if ( _jsid.includes('content_') !== false ) {
900 if ( _js[_jsid].includes('aitekoRender') === false ) {
901 var jscontent = _js[_jsid];
902 jscontent = $.trim(jscontent);
903 jscontent = jscontent.replace('jQuery(document).ready', 'jQuery(window).load');
904 jscontent = jscontent.replace('$(document).ready', 'jQuery(window).load');
905
906 $('#brayn-mo-script').append( $('<script type="text/javascript">'+jscontent+'</script>') );
907 jscontent = null;
908 }
909 } else {
910 if ( $('script[src="'+_js[_jsid]+'"]').length < 1 && _js[_jsid].indexOf('assets/js/brayn-firstload.js') == -1 ) {
911 $.cachedScript( _js[_jsid] ).done( function( script, textStatus ) {});
912 }
913 }
914 }
915 _jsid = null;
916 }
917 _js = scriptDiv = null;
918 }
919
920 d.parallaxInit();
921 d.getHeaderSize();
922
923 if ( $('.portfolio-grid-lists').length ) {
924 $('.portfolio-grid-lists').find('.image-shadow').each(function(v){
925 var c=this,
926 data = {
927 el: c,
928 image: c.querySelector("img"),
929 id: v
930 };
931 d.canvasBlur(data);
932 });
933 }
934
935 window.requestTimeout(function(){
936 $('#transit_roler').find('.trload').css({opacity: 0});
937 anime({
938 targets: ['#transit_roler .trl', '#transit_roler .trr'],
939 height: ['100%','0%'],
940 duration: 500,
941 delay: function(el, i, l) { return i * 200; },
942 easing: 'easeInOutCirc',
943 complete: function() {
944 $('#transit_roler').css({height: 0, overflow: 'hidden'});
945 $(window).trigger('load');
946 $(window).trigger('braynHasFinishLoad');
947 }
948 });
949 },500);
950 });
951 },
952
953 /**
954 * The main ajax processing start from here
955 *
956 * @since 1.0.0
957 */
958 callthepage: function(e) {
959 var d=this,
960 nTarget = e.currentTarget.pathname + e.currentTarget.search;
961
962 // Don't process if the link is same as current window
963 if ( nTarget !== (window.location.pathname + window.location.search) ) {
964 e.preventDefault();
965
966 // Lock. Until all finishes
967 d.onAjaxProgress = true;
968 $(window).trigger('braynBeforeLoadNewCanvas');
969
970 // If user click on link inside the menu
971 if ( d.menuShowed ) {
972 $('body').removeAttr('style');
973 $(window).scrollTop(0);
974 }
975 d.triggerAjax( e.currentTarget.href );
976 }
977 e.preventDefault();
978 return false;
979 },
980
981 triggerAjax: function( dest_url ) {
982 var d=this, data={};
983 if ( typeof dest_url === 'undefined' ) {
984 return false;
985 }
986
987 // Remove any pointer events
988 $('body').css({
989 cursor: 'progress',
990 pointerEvents: 'none'
991 });
992
993 d.shrinkContent();
994
995 // Do the Ajax!!
996 d.$win.one( 'braynCanvasReady', function() {
997 $.ajax({
998 url : dest_url,
999 type: 'GET',
1000 error: function(httpRequest, textStatus, errorThrown) {
1001 alert( 'Something wrong! We got ' + httpRequest.status + ' - ('+ textStatus +') from server. Please try again later!' );
1002 window.location.reload(false);
1003 return false;
1004 },
1005 success: function(x) {
1006 var parser = new DOMParser(),
1007 doc = parser.parseFromString(x, "text/html"),
1008 $wholePage = $("<div>").html(x),
1009 imgs = $wholePage.find('#main').find('img');
1010
1011 data['doc_title'] = $wholePage.find('title').html();
1012 data['main_content'] = $wholePage.find('#main').html();
1013 data['body_classes'] = doc.body.getAttribute('class');
1014
1015 var dynamicScripts = $wholePage.find('script');
1016 var dynamicStyle = $wholePage.find('link[rel*="stylesheet"]');
1017
1018 if ( $(dynamicScripts).length ) {
1019 var scriptLinks = {};
1020 $(dynamicScripts).each( function(i) {
1021 var _scriptcontent = ( typeof $(this).attr('src') !== 'undefined' ? $(this).attr('src') : $(this).html() ),
1022 _scriptid = ( typeof $(this).attr('src') !== 'undefined' ? 'src_'+i : 'content_'+i );
1023 scriptLinks[_scriptid] = _scriptcontent;
1024 });
1025 data['embeded_scripts'] = scriptLinks;
1026 }
1027
1028 if ( $(dynamicStyle).length ) {
1029 $(dynamicStyle).each(function(){
1030 var hrf = $(this).attr('href');
1031 if ( $('link[href*="'+hrf+'"]').length < 1 ) {
1032 $('head').append($(this));
1033 }
1034 });
1035 }
1036
1037 $('title').html( data['doc_title'] );
1038 history.pushState(data, data['doc_title'], dest_url );
1039
1040 requestAnimationFrame( function() {
1041 d.pageTransit();
1042 });
1043
1044 d.$win.one('braynReadyForNewPage', function() {
1045 $(window).scrollTop(0);
1046 $('#site').removeAttr('style');
1047 $('body').removeAttr('style').attr('class', data.body_classes );
1048 $('#main').removeAttr('style').html(data.main_content);
1049
1050 if ( imgs.length ) {
1051 d.loadAllImages( imgs );
1052
1053 d.$win.one('braynImagesLoaded', function() {
1054 // apply the scripts, incase any special script for different pages
1055 d.injectSscripts( dynamicScripts );
1056
1057 // unlock. allow for another ajax
1058 d.onAjaxProgress = false;
1059
1060 // need this? not sure.. just tryin to free up the cache
1061 parser = doc = $wholePage = imgs = null;
1062 });
1063 } else {
1064
1065 // apply the scripts, incase any special script for different pages
1066 d.injectSscripts( dynamicScripts );
1067
1068 // unlock. allow for another ajax
1069 d.onAjaxProgress = false;
1070
1071 // need this? not sure.. just tryin to free up the cache
1072 parser = doc = $wholePage = imgs = null;
1073 }
1074 });
1075 },
1076 });
1077 });
1078 },
1079
1080 loadAllImages: function( imgs ) {
1081 var d=this, c=document.createDocumentFragment(), tracker=[];
1082
1083 for (var i = imgs.length-1; i >= 0; i--) {
1084 var im = new Image();
1085 im.onload = function () {
1086 tracker.push(im);
1087 if ( tracker.length >= imgs.length ) {
1088
1089 if ( $('.portfolio-grid-lists').length ) {
1090 $('.portfolio-grid-lists').find('.image-shadow').each(function(v){
1091 var c=this,
1092 data = {
1093 el: c,
1094 image: c.querySelector("img"),
1095 id: v
1096 };
1097 d.canvasBlur(data);
1098 });
1099 }
1100 $(window).trigger('braynImagesLoaded');
1101 }
1102 };
1103 im.onerror = function () {
1104 tracker.push(im);
1105 if ( tracker.length >= imgs.length ) {
1106 $(window).trigger('braynImagesLoaded');
1107 }
1108 };
1109 im.src = $(imgs[i]).attr('src');
1110 c.appendChild(im);
1111 }
1112 },
1113
1114 getBlurryStorage: function(){
1115 var d=this;
1116 d.blurryImage = JSON.parse(localStorage.blurryImage || null) || {};
1117 return d.blurryImage;
1118 },
1119
1120 saveBlurryStorage: function( url, data ) {
1121 var d=this;
1122 d.blurryImage[url] = data;
1123 // saveData.foo = foo;
1124 d.blurryImage.time = new Date().getTime();
1125 localStorage.blurryImage = JSON.stringify(d.blurryImage);
1126 },
1127
1128 canvasBlur: function(data) {
1129 var d=this, f=document.createDocumentFragment(), Filters = {};
1130 var mul_table = [512,512,456,512,328,456,335,512,405,328,271,456,388,335,292,512,
1131 454,405,364,328,298,271,496,456,420,388,360,335,312,292,273,512,
1132 482,454,428,405,383,364,345,328,312,298,284,271,259,496,475,456,
1133 437,420,404,388,374,360,347,335,323,312,302,292,282,273,265,512,
1134 497,482,468,454,441,428,417,405,394,383,373,364,354,345,337,328,
1135 320,312,305,298,291,284,278,271,265,259,507,496,485,475,465,456,
1136 446,437,428,420,412,404,396,388,381,374,367,360,354,347,341,335,
1137 329,323,318,312,307,302,297,292,287,282,278,273,269,265,261,512,
1138 505,497,489,482,475,468,461,454,447,441,435,428,422,417,411,405,
1139 399,394,389,383,378,373,368,364,359,354,350,345,341,337,332,328,
1140 324,320,316,312,309,305,301,298,294,291,287,284,281,278,274,271,
1141 268,265,262,259,257,507,501,496,491,485,480,475,470,465,460,456,
1142 451,446,442,437,433,428,424,420,416,412,408,404,400,396,392,388,
1143 385,381,377,374,370,367,363,360,357,354,350,347,344,341,338,335,
1144 332,329,326,323,320,318,315,312,310,307,304,302,299,297,294,292,
1145 289,287,285,282,280,278,275,273,271,269,267,265,263,261,259];
1146
1147
1148 var shg_table = [9, 11, 12, 13, 13, 14, 14, 15, 15, 15, 15, 16, 16, 16, 16, 17,
1149 17, 17, 17, 17, 17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 18, 19,
1150 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 20, 20, 20,
1151 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 21,
1152 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
1153 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
1154 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
1155 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
1156 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
1157 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
1158 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
1159 23, 23, 23, 23, 23, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
1160 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
1161 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
1162 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
1163 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24 ];
1164
1165 Filters.getPixels = function(img, el) {
1166 var c,ctx;
1167 if (img.getContext) {
1168 c = img;
1169 try {
1170 ctx = c.getContext('2d');
1171 } catch(e) {}
1172 }
1173 if (!ctx) {
1174 c = this.getCanvas($(el).width(), $(el).height());
1175 ctx = c.getContext('2d');
1176 ctx.clearRect( 0, 0, c.width, c.height );
1177 ctx.fillStyle= '#fff';
1178 ctx.globalAlpha = 0.94;
1179 ctx.fillRect(0,0,c.width, c.height);
1180
1181 ctx.drawImage(img, 30, 30, c.width-60, ((c.width-60)/c.width)*c.height);
1182 }
1183 return ctx.getImageData(0,0,c.width,c.height);
1184 };
1185
1186 Filters.getCanvas = function(w,h) {
1187 var c = document.createElement('canvas');
1188 c.width = w;
1189 c.height = h;
1190 return c;
1191 };
1192
1193 function stackBlurCanvasRGBA( c, top_x, top_y, width, height, radius ) {
1194 if ( isNaN(radius) || radius < 1 ) return;
1195 radius |= 0;
1196
1197 var canvas = c;
1198 var context = canvas.getContext("2d");
1199 var imageData;
1200
1201 try {
1202 try {
1203 imageData = context.getImageData( top_x, top_y, width, height );
1204 } catch(e) {
1205
1206 // NOTE: this part is supposedly only needed if you want to work with local files
1207 // so it might be okay to remove the whole try/catch block and just use
1208 // imageData = context.getImageData( top_x, top_y, width, height );
1209 try {
1210 netscape.security.PrivilegeManager.enablePrivilege("UniversalBrowserRead");
1211 imageData = context.getImageData( top_x, top_y, width, height );
1212 } catch(e) {
1213 alert("Cannot access local image");
1214 throw new Error("unable to access local image data: " + e);
1215 return;
1216 }
1217 }
1218 } catch(e) {
1219 alert("Cannot access image");
1220 throw new Error("unable to access image data: " + e);
1221 }
1222
1223 var pixels = imageData.data;
1224
1225 var x, y, i, p, yp, yi, yw, r_sum, g_sum, b_sum, a_sum,
1226 r_out_sum, g_out_sum, b_out_sum, a_out_sum,
1227 r_in_sum, g_in_sum, b_in_sum, a_in_sum,
1228 pr, pg, pb, pa, rbs;
1229
1230 var div = radius + radius + 1;
1231 var w4 = width << 2;
1232 var widthMinus1 = width - 1;
1233 var heightMinus1 = height - 1;
1234 var radiusPlus1 = radius + 1;
1235 var sumFactor = radiusPlus1 * ( radiusPlus1 + 1 ) / 2;
1236
1237 var stackStart = new BlurStack();
1238 var stack = stackStart;
1239 for ( i = 1; i < div; i++ )
1240 {
1241 stack = stack.next = new BlurStack();
1242 if ( i == radiusPlus1 ) var stackEnd = stack;
1243 }
1244 stack.next = stackStart;
1245 var stackIn = null;
1246 var stackOut = null;
1247
1248 yw = yi = 0;
1249
1250 var mul_sum = mul_table[radius];
1251 var shg_sum = shg_table[radius];
1252
1253 for ( y = 0; y < height; y++ )
1254 {
1255 r_in_sum = g_in_sum = b_in_sum = a_in_sum = r_sum = g_sum = b_sum = a_sum = 0;
1256
1257 r_out_sum = radiusPlus1 * ( pr = pixels[yi] );
1258 g_out_sum = radiusPlus1 * ( pg = pixels[yi+1] );
1259 b_out_sum = radiusPlus1 * ( pb = pixels[yi+2] );
1260 a_out_sum = radiusPlus1 * ( pa = pixels[yi+3] );
1261
1262 r_sum += sumFactor * pr;
1263 g_sum += sumFactor * pg;
1264 b_sum += sumFactor * pb;
1265 a_sum += sumFactor * pa;
1266
1267 stack = stackStart;
1268
1269 for( i = 0; i < radiusPlus1; i++ )
1270 {
1271 stack.r = pr;
1272 stack.g = pg;
1273 stack.b = pb;
1274 stack.a = pa;
1275 stack = stack.next;
1276 }
1277
1278 for( i = 1; i < radiusPlus1; i++ )
1279 {
1280 p = yi + (( widthMinus1 < i ? widthMinus1 : i ) << 2 );
1281 r_sum += ( stack.r = ( pr = pixels[p])) * ( rbs = radiusPlus1 - i );
1282 g_sum += ( stack.g = ( pg = pixels[p+1])) * rbs;
1283 b_sum += ( stack.b = ( pb = pixels[p+2])) * rbs;
1284 a_sum += ( stack.a = ( pa = pixels[p+3])) * rbs;
1285
1286 r_in_sum += pr;
1287 g_in_sum += pg;
1288 b_in_sum += pb;
1289 a_in_sum += pa;
1290
1291 stack = stack.next;
1292 }
1293
1294
1295 stackIn = stackStart;
1296 stackOut = stackEnd;
1297 for ( x = 0; x < width; x++ )
1298 {
1299 pixels[yi+3] = pa = (a_sum * mul_sum) >> shg_sum;
1300 if ( pa != 0 )
1301 {
1302 pa = 255 / pa;
1303 pixels[yi] = ((r_sum * mul_sum) >> shg_sum) * pa;
1304 pixels[yi+1] = ((g_sum * mul_sum) >> shg_sum) * pa;
1305 pixels[yi+2] = ((b_sum * mul_sum) >> shg_sum) * pa;
1306 } else {
1307 pixels[yi] = pixels[yi+1] = pixels[yi+2] = 0;
1308 }
1309
1310 r_sum -= r_out_sum;
1311 g_sum -= g_out_sum;
1312 b_sum -= b_out_sum;
1313 a_sum -= a_out_sum;
1314
1315 r_out_sum -= stackIn.r;
1316 g_out_sum -= stackIn.g;
1317 b_out_sum -= stackIn.b;
1318 a_out_sum -= stackIn.a;
1319
1320 p = ( yw + ( ( p = x + radius + 1 ) < widthMinus1 ? p : widthMinus1 ) ) << 2;
1321
1322 r_in_sum += ( stackIn.r = pixels[p]);
1323 g_in_sum += ( stackIn.g = pixels[p+1]);
1324 b_in_sum += ( stackIn.b = pixels[p+2]);
1325 a_in_sum += ( stackIn.a = pixels[p+3]);
1326
1327 r_sum += r_in_sum;
1328 g_sum += g_in_sum;
1329 b_sum += b_in_sum;
1330 a_sum += a_in_sum;
1331
1332 stackIn = stackIn.next;
1333
1334 r_out_sum += ( pr = stackOut.r );
1335 g_out_sum += ( pg = stackOut.g );
1336 b_out_sum += ( pb = stackOut.b );
1337 a_out_sum += ( pa = stackOut.a );
1338
1339 r_in_sum -= pr;
1340 g_in_sum -= pg;
1341 b_in_sum -= pb;
1342 a_in_sum -= pa;
1343
1344 stackOut = stackOut.next;
1345
1346 yi += 4;
1347 }
1348 yw += width;
1349 }
1350
1351
1352 for ( x = 0; x < width; x++ )
1353 {
1354 g_in_sum = b_in_sum = a_in_sum = r_in_sum = g_sum = b_sum = a_sum = r_sum = 0;
1355
1356 yi = x << 2;
1357 r_out_sum = radiusPlus1 * ( pr = pixels[yi]);
1358 g_out_sum = radiusPlus1 * ( pg = pixels[yi+1]);
1359 b_out_sum = radiusPlus1 * ( pb = pixels[yi+2]);
1360 a_out_sum = radiusPlus1 * ( pa = pixels[yi+3]);
1361
1362 r_sum += sumFactor * pr;
1363 g_sum += sumFactor * pg;
1364 b_sum += sumFactor * pb;
1365 a_sum += sumFactor * pa;
1366
1367 stack = stackStart;
1368
1369 for( i = 0; i < radiusPlus1; i++ )
1370 {
1371 stack.r = pr;
1372 stack.g = pg;
1373 stack.b = pb;
1374 stack.a = pa;
1375 stack = stack.next;
1376 }
1377
1378 yp = width;
1379
1380 for( i = 1; i <= radius; i++ )
1381 {
1382 yi = ( yp + x ) << 2;
1383
1384 r_sum += ( stack.r = ( pr = pixels[yi])) * ( rbs = radiusPlus1 - i );
1385 g_sum += ( stack.g = ( pg = pixels[yi+1])) * rbs;
1386 b_sum += ( stack.b = ( pb = pixels[yi+2])) * rbs;
1387 a_sum += ( stack.a = ( pa = pixels[yi+3])) * rbs;
1388
1389 r_in_sum += pr;
1390 g_in_sum += pg;
1391 b_in_sum += pb;
1392 a_in_sum += pa;
1393
1394 stack = stack.next;
1395
1396 if( i < heightMinus1 )
1397 {
1398 yp += width;
1399 }
1400 }
1401
1402 yi = x;
1403 stackIn = stackStart;
1404 stackOut = stackEnd;
1405 for ( y = 0; y < height; y++ )
1406 {
1407 p = yi << 2;
1408 pixels[p+3] = pa = (a_sum * mul_sum) >> shg_sum;
1409 if ( pa > 0 )
1410 {
1411 pa = 255 / pa;
1412 pixels[p] = ((r_sum * mul_sum) >> shg_sum ) * pa;
1413 pixels[p+1] = ((g_sum * mul_sum) >> shg_sum ) * pa;
1414 pixels[p+2] = ((b_sum * mul_sum) >> shg_sum ) * pa;
1415 } else {
1416 pixels[p] = pixels[p+1] = pixels[p+2] = 0;
1417 }
1418
1419 r_sum -= r_out_sum;
1420 g_sum -= g_out_sum;
1421 b_sum -= b_out_sum;
1422 a_sum -= a_out_sum;
1423
1424 r_out_sum -= stackIn.r;
1425 g_out_sum -= stackIn.g;
1426 b_out_sum -= stackIn.b;
1427 a_out_sum -= stackIn.a;
1428
1429 p = ( x + (( ( p = y + radiusPlus1) < heightMinus1 ? p : heightMinus1 ) * width )) << 2;
1430
1431 r_sum += ( r_in_sum += ( stackIn.r = pixels[p]));
1432 g_sum += ( g_in_sum += ( stackIn.g = pixels[p+1]));
1433 b_sum += ( b_in_sum += ( stackIn.b = pixels[p+2]));
1434 a_sum += ( a_in_sum += ( stackIn.a = pixels[p+3]));
1435
1436 stackIn = stackIn.next;
1437
1438 r_out_sum += ( pr = stackOut.r );
1439 g_out_sum += ( pg = stackOut.g );
1440 b_out_sum += ( pb = stackOut.b );
1441 a_out_sum += ( pa = stackOut.a );
1442
1443 r_in_sum -= pr;
1444 g_in_sum -= pg;
1445 b_in_sum -= pb;
1446 a_in_sum -= pa;
1447
1448 stackOut = stackOut.next;
1449
1450 yi += width;
1451 }
1452 }
1453
1454 for (var q = 0, n = pixels.length; q < n; q += 4) {
1455 if ( pixels[q] == 255 && pixels[q+1] == 255 && pixels[q+2] == 255 ) {
1456 pixels[q+3] = 0;
1457 }
1458 }
1459
1460 context.putImageData( imageData, top_x, top_y );
1461 }
1462
1463 function BlurStack() {
1464 this.r = 0;
1465 this.g = 0;
1466 this.b = 0;
1467 this.a = 0;
1468 this.next = null;
1469 }
1470
1471 function init( data ) {
1472 var osc = data.image.src,
1473 saved = d.getBlurryStorage();
1474
1475 if ( saved.hasOwnProperty( osc ) ) {
1476 data.image.src = saved[osc];
1477 data.image.style.opacity = 0.75;
1478 return false;
1479 }
1480
1481 var idata = Filters.getPixels(data.image, data.el);
1482 var c=document.createElement('canvas');
1483 c.width = idata.width;
1484 c.height = idata.height;
1485 c.id = 'customcvs'+data.id;
1486 f.appendChild(c);
1487 var ctx = c.getContext('2d');
1488 ctx.clearRect(0,0,idata.width,idata.height);
1489 ctx.putImageData(idata, 0, 0);
1490
1491 stackBlurCanvasRGBA(c, 0, 0, idata.width, idata.height, 72);
1492 var dataURL = c.toDataURL('image/png');
1493 // save to localStorage
1494 d.saveBlurryStorage( osc, dataURL );
1495
1496 data.image.src = dataURL;
1497 data.image.style.opacity = 0.75;
1498
1499 c = ctx = dataURL = osc = null;
1500 }
1501
1502 return init(data);
1503 },
1504
1505 /**
1506 * The animation before call the new page
1507 * @since 1.0.0
1508 */
1509 shrinkContent: function() {
1510 var d=this, $body = $('body'), $site = $("#site"), tempScrollTop = d.$win.scrollTop(), $header = $('#main-header'),
1511 shr = anime.timeline({
1512 autoplay: true,
1513 complete: function() {
1514 $(window).trigger('braynCanvasReady');
1515 $body = $site = tempScrollTop = $header = null;
1516 },
1517 });
1518
1519 if ( !d.menuShowed && $header.hasClass('shrink') ) {
1520 $header.addClass('keepshrink');
1521 }
1522
1523 $site.css({
1524 position: 'fixed',
1525 top: 0,
1526 left: 0,
1527 width: '100%',
1528 height: '100%',
1529 overflow: 'hidden',
1530 webkitBoxShadow: '0 0 100px rgba(0,0,0, .12)',
1531 boxShadow: '0 0 100px rgba(0,0,0, .12)',
1532 }).scrollTop(tempScrollTop);
1533
1534 if ( /iPad|iPhone|iPod|Android/.test(navigator.userAgent) || $('html').hasClass('default-scroll') ) {
1535 var scrollTarget = document.getElementById('scroll-viewport');
1536 document.querySelector('.viewport').style.position = 'fixed';
1537 scrollTarget.style.msTransform = 'matrix(1, 0, 0, 1, 0, '+(-tempScrollTop)+')';
1538 scrollTarget.style.webkitTransform = 'matrix(1, 0, 0, 1, 0, '+(-tempScrollTop)+')';
1539 scrollTarget.style.transform = 'matrix(1, 0, 0, 1, 0, '+(-tempScrollTop)+')';
1540 }
1541
1542 shr.add({
1543 targets: '#site',
1544 scale: 0.9,
1545 translateY: (d.$win.width()*0.05)-(d.$win.height()*0.05),
1546 duration: 500,
1547 easing: 'easeInOutCirc',
1548 });
1549 },
1550
1551 pageTransit: function() {
1552 var d=this,roler=document.getElementById('transit_roler');
1553
1554 if ( ! roler ) {
1555 var c = document.createDocumentFragment(),
1556 divroler = document.createElement('div');
1557
1558 divroler.id = 'transit_roler';
1559
1560 c.appendChild(divroler);
1561 divroler.innerHTML = '<div class="trl"></div><div class="trr"></div><div class="trload"></div>';
1562
1563 document.body.appendChild(c);
1564
1565 roler = document.getElementById('transit_roler');
1566 }
1567 $(roler).css({
1568 position: 'fixed',
1569 zIndex: 102,
1570 left: 0,
1571 right: 0,
1572 bottom: 0,
1573 top: 0,
1574 width: '100%',
1575 height: 0,
1576 overflow: ''
1577 });
1578 $(roler).find('.trl, .trr').css({
1579 position: 'fixed',
1580 zIndex: 103,
1581 width: '51%',
1582 height: 0,
1583 top: 'initial',
1584 bottom: 0,
1585 left: 0,
1586 willChange: 'height',
1587 backgroundColor: braynOptions.transitDiv_bg
1588 });
1589 $(roler).find('.trr').css({
1590 left: 'initial',
1591 right: 0
1592 });
1593
1594 $(roler).find('.trload').css({
1595 position: 'fixed',
1596 opacity: 0,
1597 zIndex: 104,
1598 width: '50px',
1599 height: '50px',
1600 top: '50%',
1601 left: '50%',
1602 marginTop: '-25px',
1603 marginLeft: '-25px',
1604 '-webkit-border-radius': '50%',
1605 borderRadius: '50%',
1606 backgroundColor: 'transparent',
1607 border: '3px solid #989898',
1608 borderBottom: '3px solid rgba(0,0,0,0)',
1609 borderLeft: '3px solid rgba(0,0,0,0)',
1610 'animation-name': 'rotateAnimation',
1611 '-webkit-animation-name': 'wk-rotateAnimation',
1612 'animation-duration': '1s',
1613 '-webkit-animation-duration': '1s',
1614 'animation-delay': '0.2s',
1615 '-webkit-animation-delay': '0.2s',
1616 'animation-iteration-count': 'infinite',
1617 '-webkit-animation-iteration-count': 'infinite'
1618 });
1619
1620 anime({
1621 targets: ['#transit_roler .trl', '#transit_roler .trr'],
1622 height: ['0%','100%'],
1623 duration: 500,
1624 easing: 'easeInOutCirc',
1625 delay: function(el, i, l) { return i * 100; },
1626 complete: function() {
1627 $('#transit_roler').find('.trload').css({opacity: 1});
1628 $('#transit_roler').find('.trl, .trr').css({
1629 top: '0',
1630 bottom: 'initial',
1631 });
1632 $('#main-header').removeClass('keepshrink').css({top: ''});
1633 $('.header--complementary').find('.button').removeClass('button-reverse');
1634
1635 if ( d.menuShowed ) {
1636 // close the menu
1637 $('button.hamburger__menu').trigger('click');
1638 // run the Ajax after 500 ms
1639 d.$win.one('braynMenuClosedForAjax', function() {
1640 $(window).trigger('braynReadyForNewPage');
1641 });
1642 } else {
1643 $(window).trigger('braynReadyForNewPage');
1644 }
1645 }
1646 });
1647 },
1648
1649 injectSscripts: function(scripts) {
1650 var d=this;
1651 if( typeof scripts !== 'undefined' ) {
1652 var scriptDiv = document.getElementById('brayn-mo-script'), c=document.createDocumentFragment();
1653
1654 if ( $('#brayn-mo-script').length < 1 ) {
1655 $('body').append($(scriptDiv));
1656 $('#brayn-mo-script').css({width:0,height:0,overflow:'hidden'});
1657 } else {
1658 $('#brayn-mo-script').html('');
1659 }
1660
1661 if ( scriptDiv ) {
1662 scriptDiv.innerHTML = "";
1663 } else {
1664 var nd = document.createElement('div');
1665 nd.id = 'brayn-mo-script';
1666 c.appendChild(nd);
1667 document.body.appendChild(c);
1668
1669 scriptDiv = document.getElementById('brayn-mo-script');
1670 scriptDiv.style.width = 0;
1671 scriptDiv.style.height = 0;
1672 scriptDiv.style.overflow = 'hidden';
1673 }
1674
1675 $('style[id*="jarallax-clip"]').detach().remove();
1676 $('script').each(function() {
1677 var js__src = ( typeof $(this).attr('src') !== 'undefined' ? $(this).attr('src') : '' );
1678 if ( js__src.indexOf('assets/js/jquery.min.js') == -1 && js__src.indexOf('assets/js/app.js') == -1 && js__src.indexOf('assets/js/plugins.js') == -1 ) {
1679 $(this).detach().remove();
1680 }
1681 });
1682
1683 $(scripts).each(function() {
1684 var x=this, _src = $(this).attr('src');
1685
1686 if ( typeof _src === 'undefined' ) {
1687 var content = $(this).html();
1688
1689 // manually fixing some custom script,
1690 // incase they call the function inside document ready.
1691 content = $.trim(content);
1692 content = content.replace('jQuery(document).ready', 'jQuery(window).load');
1693 content = content.replace('$(document).ready', 'jQuery(window).load');
1694 $(x).html(content);
1695 $(scriptDiv).append($(x));
1696
1697 } else {
1698
1699 if ( $('script[src="'+_src+'"]').length < 1 && _src.indexOf('assets/js/brayn-firstload.js') == -1 ) {
1700 $.cachedScript( _src ).done( function( script, textStatus ) {});
1701 }
1702 }
1703 });
1704
1705 d.parallaxInit();
1706 d.getHeaderSize();
1707 window.requestTimeout(function(){
1708 $('#transit_roler').find('.trload').css({opacity: 0});
1709 anime({
1710 targets: ['#transit_roler .trl', '#transit_roler .trr'],
1711 height: ['100%','0%'],
1712 duration: 500,
1713 delay: function(el, i, l) { return i * 200; },
1714 easing: 'easeInOutCirc',
1715 complete: function() {
1716 $('#transit_roler').css({height: 0, overflow: 'hidden'});
1717 $(window).trigger('load');
1718 $(window).trigger('braynHasFinishLoad');
1719 }
1720 });
1721 },500);
1722 }
1723 },
1724
1725 getHeaderSize: function() {
1726 var d=this, $header = $('#main-header'), hs=false;
1727 if ( d.getter ) {
1728 window.clearRequestTimeout( d.getter );
1729 }
1730
1731 if ( $header.hasClass('shrink') ) {
1732 hs=true;
1733 }
1734
1735 d.getterProcess = true;
1736 $header.removeClass('shrink').removeAttr('style');
1737 $header.find('.brand--nav').removeAttr('style');
1738
1739 d.getter = window.requestTimeout(function(){
1740 d.headerSize = {
1741 width: d.$win.width(),
1742 height: $header.height(),
1743 logoWidth: $('.brand').find('img').width(),
1744 }
1745 $('.ui-menu-container').css({paddingTop: d.headerSize.height+'px' });
1746 if ( $('#brayn-section-hero').length < 1 && $('header.page-header').length < 1 && $('.single-portfolio-header').length < 1 && $('#top-map').length < 1 ) {
1747 if ( ! $('#main').find('.br-section:first-child').hasClass('br-min-height__100vh') ) {
1748 $('#main').css({paddingTop: d.headerSize.height+'px'});
1749 }
1750 $('.header--complementary').find('.button').addClass('button-reverse');
1751 } else if ( $('#brayn-section-hero').length < 1 && $('header.page-header').length > 0 ) {
1752 $('header.page-header').css({paddingTop: d.headerSize.height+'px'});
1753 }
1754 d.getterProcess = false;
1755 if ( hs ) {
1756 hs=false;
1757 d.shrinkHeader();
1758 }
1759 },500);
1760 },
1761
1762 shrinkHeader: function() {
1763 var d=this, oAnimate = false, $header = $('#main-header');
1764
1765 // size is unknown, leave it for now.
1766 if ( typeof d.headerSize.height === 'undefined' || d.getterProcess || $header.hasClass('keepshrink') ) {
1767 return false;
1768 }
1769
1770 oAnimate = true;
1771 $header.find('.brand--nav').css({width: d.headerSize.logoWidth+60+54+'px'});
1772 $header.addClass('shrink');
1773 oAnimate = false;
1774 },
1775
1776 /**
1777 * Check the link,
1778 * if local means support for ajax transition page
1779 *
1780 * @version 1.0.0
1781 */
1782 linkisLocal: function(el) {
1783 var d=this;
1784 if( window.location.hostname === el.hostname || !el.hostname.length ) {
1785 // Check more for other cases
1786 if ( d.linkDeniedUseAjax(el) ) {
1787 return false;
1788 }
1789 return true;
1790 }
1791
1792 return false;
1793 },
1794
1795 /**
1796 * Check the link,
1797 * reject if link for mailto/tel, or link to image/video/text file
1798 *
1799 * @version 1.0.0
1800 */
1801 linkDeniedUseAjax: function(el) {
1802 el = el.href;
1803
1804 if ( el.indexOf('mailto:') !== -1 || el.indexOf('tel:') !== -1 ) {
1805 return true;
1806 }
1807
1808 el = el.split('?')[0];
1809 var parts = el.split('.'),
1810 extension = parts[parts.length-1],
1811 fileTypes = ['jpg','jpeg','tiff','png','gif','bmp','mp4','mp3','mov','txt','doc'];
1812
1813 // if link is point to image/video files, reject it.
1814 if( fileTypes.indexOf(extension) !== -1 ) {
1815 return true;
1816 }
1817
1818 return false;
1819 },
1820
1821 menuListener: function() {
1822 var d=this, btn = $('button.hamburger__menu'), $header = $('#main-header'), html = document.documentElement, body = document.body;
1823
1824 d.addMenuArrows();
1825 if ( $('.main-menu-widgets').is(':hidden') === false && $('.menu-widget-image').length ) {
1826 if ( $('.menu-widget-image').find('canvas').length < 1 ) {
1827 new pSlideCanvas( $('.menu-widget-image')[0], $('.menu-widget-image')[0], 'hide', 'assets/images/clouds-s.jpg', {width: $('.menu-widget-image').width(), height: $('.menu-widget-image').height()} );
1828 }
1829 }
1830
1831 btn.unbind().on( 'click', function(e) {
1832 e.preventDefault();
1833 var oSt = window.pageYOffset || html.scrollTop || body.scrollTop || 0;
1834
1835 if ( d.onMenuShow ) {
1836 return false;
1837 }
1838
1839 d.onMenuShow = true;
1840
1841 if ( btn.hasClass('is-active') ) {
1842 btn.removeClass('is-active');
1843 var menuHide = anime.timeline({
1844 autoplay: true,
1845 complete: function() {
1846 d.onMenuShow = false;
1847 $('body').css({overflow: ''});
1848 $('.main-menu-container-wrap, .menu-widget').removeAttr('style');
1849 $('.menu-widget-image').parent().removeClass('done-it');
1850 $('.menu-widget-image').find('img').removeAttr('style');
1851 d.shrinkHeader();
1852 d.menuShowed = false;
1853
1854 d.$win.on('scroll', function() {
1855 //d.shrinkHeader();
1856 d.watchPortfolioGridItems();
1857 });
1858
1859 $(window).trigger('braynMenuClosedForAjax');
1860 }
1861 });
1862
1863 $('.main-menu-container-wrap').css({
1864 top: 0,
1865 bottom: 'initial'
1866 });
1867 menuHide.add({
1868 targets: ['#brayn-menu > .menu-item', '.menu-widget'],
1869 opacity: [1,0],
1870 translateY: [0, -100],
1871 delay: function(el, i, l) { return i * 50; },
1872 easing: 'easeInOutSine',
1873 duration: ( d.onAjaxProgress ? 50 : 800 ),
1874 complete: function() {
1875 $header.removeClass('on_menu');
1876 }
1877 }).add({
1878 targets: '.main-menu-container-wrap',
1879 height: ['100%', '0%'],
1880 opacity: [1,0],
1881 easing: 'easeInOutCirc',
1882 duration: ( d.onAjaxProgress ? 50 : 600 ),
1883 offset: '-=200',
1884 });
1885 } else {
1886 btn.addClass('is-active');
1887 var menuShow = anime.timeline({
1888 autoplay: true,
1889 complete: function() {
1890 $header.addClass('on_menu');
1891 if ( $header.hasClass('shrink') ) {
1892 $header.find('.brand--nav').css({width: '50%'});
1893 window.requestTimeout(function(){
1894 $header.removeClass('shrink');
1895 $header.find('.brand--nav').css({width: ''});
1896 d.onMenuShow = false;
1897 },500);
1898 } else {
1899 d.onMenuShow = false;
1900 }
1901 d.menuShowed = true;
1902 }
1903 });
1904
1905 $('body').css({pointerEvents: 'none', overflow: 'hidden'});
1906 d.$win.off('scroll');
1907
1908 menuShow.add({
1909 targets: '.main-menu-container-wrap',
1910 height: ['0%', '100%'],
1911 opacity: [0, 1],
1912 easing: 'easeInOutCirc',
1913 duration: 600,
1914 complete: function() {
1915 var mwi = $('.menu-widget-image');
1916
1917 if ( mwi.length && typeof window.appear !== 'undefined' ) {
1918 var mwiAppear = new window.appear({
1919 elements: function elements() {
1920 return document.getElementsByClassName('menu-widget-image');
1921 },
1922 appear: function appear(el) {
1923 $(el).trigger('customShowCanvas');
1924 $(el).parent().addClass('done-it');
1925 },
1926 bounds: 0
1927 });
1928 }
1929
1930 if ( /iPad|iPhone|iPod/.test(navigator.userAgent) ) {
1931 $('.main-menu-container-wrap').find('a').on('touchstart', function(e){
1932 e.preventDefault();
1933 $(this).trigger('click');
1934 $(this).trigger('click');
1935 return true;
1936 });
1937 }
1938 }
1939 }).add({
1940 targets: ['#brayn-menu > .menu-item', '.menu-widget > h4', '.menu-widget-list > li'],
1941 opacity: [0,1],
1942 translateY: [50, 0],
1943 delay: function(el, i, l) { return i * 50; },
1944 easing: 'easeOutSine',
1945 duration: 600,
1946 offset: "-=50",
1947 complete: function() {
1948 $('body').css({ pointerEvents: '' });
1949 }
1950 });
1951 }
1952
1953 });
1954
1955 var menuScroll = window.Scrollbar,
1956 menuEl = document.querySelector('.main-menu-container'),
1957 scrollEm;
1958 scrollEm = menuScroll.init( menuEl );
1959 scrollEm.scrollTop = 0;
1960 },
1961
1962 /**
1963 * Add arrow to menu item that have child
1964 * @ver 1.0
1965 */
1966 addMenuArrows: function() {
1967 var d=this, $master=$('#brayn-menu'), $childs=$master.find('ul.sub-menu');
1968
1969 if ( $childs.length ) {
1970 $childs.each(function() {
1971 var z=$(this).parent(),arrow='<span class="arrow-yuk-down"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path d="M256 294.1L383 167c9.4-9.4 24.6-9.4 33.9 0s9.3 24.6 0 34L273 345c-9.1 9.1-23.7 9.3-33.1.7L95 201.1c-4.7-4.7-7-10.9-7-17s2.3-12.3 7-17c9.4-9.4 24.6-9.4 33.9 0l127.1 127z"/></svg></span>';
1972 $(this).hide();
1973 if ( $(z).find('>.arrow-yuk-down').length < 1 ) {
1974 $(arrow).insertAfter( $(z).find('>a') );
1975 } else {
1976 if ( $(z).find('>.arrow-yuk-down').hasClass('rtt') ) {
1977 $(z).find('>.arrow-yuk-down').removeClass('rtt');
1978 }
1979 }
1980 });
1981 }
1982
1983 $('.arrow-yuk-down').each(function() {
1984 var ayd = this;
1985 $(ayd).off().on('click', function(e) {
1986 e.preventDefault();
1987 if ( ! $(this).hasClass('rtt') ) {
1988 $(ayd).parent('li').find('>ul').slideDown(200);
1989 $(this).addClass('rtt');
1990 } else {
1991 $(ayd).parent('li').find('>ul').slideUp(200);
1992 $(this).removeClass('rtt');
1993 }
1994 });
1995 });
1996 },
1997
1998 /**
1999 * Parallax & hero helper
2000 * @ver 1.0
2001 */
2002 parallaxInit: function() {
2003 var d=this, $hero = $('.hero-bg'), $singleHeader = $('.portfolio-header-bg');
2004
2005 // Read the current hero.
2006 if ( $hero.length ) {
2007 var ef = $hero.data('effect'), c = document.createDocumentFragment();
2008
2009 // if set to video bg
2010 if ( typeof ef !== 'undefined' && ef === "video" ) {
2011 var tk = $hero.find('#br-video-bg');
2012 // cannot find the container bg, reject
2013 if ( tk.length < 1 ) {
2014 tk = null;
2015 return false;
2016 }
2017
2018 var params = {
2019 vtype: $(tk).data('video-type'),
2020 videoID: $(tk).data('video-id'),
2021 img: $(tk).data('img-fallback'),
2022 };
2023
2024 // if iPad/iPhone/iPhone/Android based browser is detected
2025 if ( /iPad|iPhone|iPod|Android/.test(navigator.userAgent) ) {
2026 var img = new Image();
2027 c.appendChild(img);
2028 img.src = params.img;
2029 img.setAttribute('data-render', 'assets/images/clouds.jpg');
2030
2031 document.querySelector(".hero-bg").appendChild(c);
2032 ef = 'parallax';
2033 $(tk).detach();
2034 tk = null;
2035 } else {
2036
2037 // process the bg based on data setting
2038 switch( params.vtype ) {
2039 case 'vimeo':
2040 var ifrm = document.createElement('iframe');
2041 ifrm.src = '//player.vimeo.com/video/'+params.videoID+'?muted=1&autoplay=1&loop=1&autopause=0&byline=0&title=0&fun=0&dnt=1';
2042 ifrm.width = '100%';
2043 ifrm.height = '100%';
2044 ifrm.setAttribute('webkitallowfullscreen', 'true');
2045 ifrm.setAttribute('mozallowfullscreen', 'true');
2046 ifrm.setAttribute('allowfullscreen', 'true');
2047 c.appendChild(ifrm);
2048 document.querySelector("#br-video-bg").appendChild(c);
2049 break;
2050 case 'youtube':
2051 default:
2052 $(tk).YTPlayer({
2053 fitToBackground: true,
2054 videoId: params.videoID,
2055 start: 5,
2056 playerVars: {
2057 modestbranding: 0,
2058 autoplay: 1,
2059 controls: 0,
2060 showinfo: 0,
2061 wmode: 'transparent',
2062 branding: 0,
2063 rel: 0,
2064 autohide: 0,
2065 origin: window.location.origin
2066 }
2067 });
2068 break;
2069 }
2070
2071 d.$win.one('braynHasFinishLoad', function() {
2072 window.requestTimeout(function(){
2073 requestAnimationFrame(function(){
2074 anime({
2075 targets: '#brayn-section-hero .wip--container > *',
2076 translateY: [50, 0],
2077 opacity: [0,1],
2078 delay: function(e, i, l) { return i * 100; },
2079 duration: 600,
2080 easing: 'easeInOutSine',
2081 complete: function() {
2082 anime({
2083 targets: '#brayn-section-hero .br-scroll-me',
2084 translateY: [50, 0],
2085 opacity: [0,1],
2086 rotate: ['-90deg', '-90deg'],
2087 duration: 600,
2088 easing: 'easeInOutSine',
2089 });
2090 }
2091 });
2092 });
2093 }, 1000);
2094 });
2095 }
2096 }
2097
2098 if ( typeof ef !== 'undefined' && ( ef === 'parallax' || ef === 'single-image' ) ) {
2099 $hero.find('img').addClass('jarallax-img');
2100
2101 window.brayn.heroRipple.start( $hero[0], $hero.find('img').attr('src'), $hero.find('img').data('render'), function() {
2102 anime({
2103 targets: '#brayn-section-hero .wip--container > *',
2104 translateY: [50, 0],
2105 opacity: [0,1],
2106 delay: function(e, i, l) { return i * 100; },
2107 duration: 600,
2108 easing: 'easeInOutSine',
2109 complete: function() {
2110 anime({
2111 targets: '#brayn-section-hero .br-scroll-me',
2112 translateY: [50, 0],
2113 opacity: [0,1],
2114 rotate: ['-90deg', '-90deg'],
2115 duration: 600,
2116 easing: 'easeInOutSine',
2117 });
2118 }
2119 });
2120 if ( ef === 'parallax' ) {
2121 $hero.braynrallax();
2122 } else {
2123 $hero.braynrallax();
2124 }
2125 });
2126 }
2127 }
2128
2129 if ( $singleHeader.length ) {
2130 $singleHeader.find('img').addClass('jarallax-img');
2131 $singleHeader.braynrallax();
2132
2133 anime({
2134 targets: '.portfolio-header-bg',
2135 opacity: [0,1],
2136 scale: [1.1, 1],
2137 duration: 1000,
2138 easing: 'easeInOutSine',
2139 delay: 800,
2140 complete: function() {
2141 $singleHeader.removeAttr('style').css({opacity: 1});
2142 }
2143 });
2144 }
2145 },
2146
2147 funcCaller: function() {
2148 var d=this, $portoCarousel = $('.portfolio-carousel-contain');
2149
2150 // portfolio carousel
2151 if ( $portoCarousel.length > 0 ) {
2152 var portfolioSwiper = new Swiper('.portfolio-carousel-contain', {
2153 slidesPerView: 1,
2154 spaceBetween: 20,
2155 grabCursor: true,
2156 navigation: {
2157 nextEl: '.portfolio-carousel-btn-next',
2158 prevEl: '.portfolio-carousel-btn-prev',
2159 },
2160 breakpointsInverse: true,
2161 breakpoints: {
2162 768: {
2163 slidesPerView: 2,
2164 spaceBetween: 30
2165 },
2166 992: {
2167 slidesPerView: 3,
2168 spaceBetween: 40
2169 }
2170 },
2171 on: {
2172 init: function() {
2173 if ( /iPad|iPhone|iPod|Android/.test(navigator.userAgent) ) {
2174 $portoCarousel.find('img').css({opacity:1});
2175 $portoCarousel.find('.portfolio-carousel-item').addClass('is-touch')
2176 } else {
2177 $portoCarousel.find('.portfolio-carousel-img').each(function(){
2178 var src = $(this).find('img').attr('src'),
2179 dl = $('<div class="dl" />'),
2180 dr = $('<div class="dr" />');
2181
2182 $(this).append(dl).append(dr);
2183 $(dl).css({backgroundImage: 'url('+src+')'});
2184 $(dr).css({backgroundImage: 'url('+src+')'});
2185
2186 src = dl = dr = null;
2187 });
2188 }
2189 },
2190 }
2191 }), $pcitem = $('.portfolio-carousel-item');
2192
2193 $pcitem.on('mouseover', function() {
2194 var k=this;
2195 $pcitem.not(k).css({opacity: .5});
2196 }).on('mouseleave', function() {
2197 $pcitem.css({opacity: ''});
2198 });
2199 }
2200
2201 // Testimonial carousel
2202 if ( $('.testimonial-carousel-contain').length ) {
2203 var testiSwiper = new Swiper ('.testimonial-carousel-contain', {
2204 slidesPerView: 1,
2205 spaceBetween: 0,
2206 grabCursor: false,
2207 navigation: {
2208 nextEl: '.testimonial-carousel-btn-next',
2209 prevEl: '.testimonial-carousel-btn-prev',
2210 },
2211 speed: 800,
2212 effect: 'fade',
2213 fadeEffect: {
2214 crossFade: true,
2215 },
2216 autoplay: {
2217 delay: 5000,
2218 disableOnInteraction: false,
2219 },
2220 on: {
2221 init: function() {
2222 var $slideTotal = $('.testimonial-carousel-contain').find('.br-testimonial').length,
2223 $markup = $('<div class="total-slide"><span class="slide-current">01</span>/<span class="slide-total">0'+$slideTotal+'</span></div>');
2224
2225 $markup.insertAfter( $('.testimonial-carousel-btn-prev') );
2226 $slideTotal = $markup = null;
2227 },
2228 slideChange: function() {
2229 var crt = "0"+(testiSwiper.activeIndex+1);
2230 $('.testimonial-carousel-contain').find('.slide-current').html(crt);
2231 crt = null;
2232 },
2233 }
2234 });
2235 }
2236
2237 // Client slide/carousel
2238 if ( $('.client-carousel-contain').length ) {
2239 var clientSwiper = new Swiper ('.client-carousel-contain', {
2240 slidesPerView: 2,
2241 spaceBetween: 20,
2242 grabCursor: true,
2243 breakpointsInverse: true,
2244 breakpoints: {
2245 768: {
2246 slidesPerView: 3,
2247 },
2248 992: {
2249 slidesPerView: 4,
2250 }
2251 },
2252 speed: 500,
2253 loop: true,
2254 autoplay: {
2255 delay: 5000,
2256 disableOnInteraction: false,
2257 },
2258 });
2259 }
2260
2261 // Portfolio gallery carousel
2262 if ( $('.br-carousel-gallery-container').length ) {
2263 $('.br-carousel-gallery-container').find('.br-carousel-item').each(function() {
2264 var _src = $(this).find('img').attr('src'),
2265 bg = $(this).find('.br-carousel-bg');
2266 bg[0].style.backgroundImage = 'url("'+_src+'")';
2267 });
2268 var interleaveOffset = 0.5,
2269 pcSlideTotal = $('.br-carousel-gallery-container').find('.br-carousel-item').length;
2270 var pCarouselSwiper = new Swiper ('.br-carousel-gallery-container', {
2271 loop: true,
2272 slidesPerView: 1,
2273 spaceBetween: 0,
2274 grabCursor: true,
2275 watchSlidesProgress: true,
2276 navigation: {
2277 nextEl: '.br-gallery-carousel-btn-next',
2278 prevEl: '.br-gallery-carousel-btn-prev',
2279 },
2280 speed: 700,
2281 autoplay: {
2282 delay: 5000,
2283 disableOnInteraction: false,
2284 },
2285 // modify the effect of Swiper transition
2286 // source : https://codepen.io/udovichenko/pen/LGeQae
2287 on: {
2288 init: function() {
2289 var $markup = $('<div class="total-slide"><span class="slide-current">01</span>/<span class="slide-total">0'+pcSlideTotal+'</span></div>');
2290
2291 $markup.insertAfter( $('.br-gallery-carousel-btn-prev') );
2292 $markup = null;
2293 },
2294 slideChange: function() {
2295 var swiper = this,
2296 crt = "0"+(swiper.realIndex+1);
2297 $('.br-carousel-gallery-container').find('.slide-current').html(crt);
2298 crt = null;
2299 },
2300 progress: function() {
2301 var swiper = this;
2302 for (var i = 0; i < swiper.slides.length; i++) {
2303 var slideProgress = swiper.slides[i].progress;
2304 var innerOffset = swiper.width * interleaveOffset;
2305 var innerTranslate = slideProgress * innerOffset;
2306 swiper.slides[i].querySelector(".br-carousel-bg").style.webkitTransform = "translate3d(" + innerTranslate + "px, 0, 0)";
2307 swiper.slides[i].querySelector(".br-carousel-bg").style.transform = "translate3d(" + innerTranslate + "px, 0, 0)";
2308 }
2309 },
2310 touchStart: function() {
2311 var swiper = this;
2312 for (var i = 0; i < swiper.slides.length; i++) {
2313 swiper.slides[i].style.transition = "";
2314 }
2315 },
2316 setTransition: function(speed) {
2317 var swiper = this;
2318 for (var i = 0; i < swiper.slides.length; i++) {
2319 swiper.slides[i].style.webkitTransition = speed + "ms";
2320 swiper.slides[i].style.transition = speed + "ms";
2321 swiper.slides[i].querySelector(".br-carousel-bg").style.webkitTransition = speed + "ms";
2322 swiper.slides[i].querySelector(".br-carousel-bg").style.transition = speed + "ms";
2323 }
2324 }
2325 }
2326 });
2327 }
2328
2329 // Portfolio grid helper
2330 if ( $('.portfolio-grid-lists').length && /iPad|iPhone|iPod|Android/.test(navigator.userAgent) === false ) {
2331 if ( typeof VanillaTilt !== "undefined" ) {
2332 VanillaTilt.init(document.querySelectorAll(".entry-image"),{
2333 max:15,
2334 speed:600,
2335 scale: 1.05,
2336 easing: 'cubic-bezier(0,0.29,0.58,1)'
2337 });
2338 }
2339
2340 var flyingPorto = new window.appear({
2341 elements: function elements() {
2342 return document.getElementsByClassName('portfolio-grid-item');
2343 },
2344 appear: function appear(el) {
2345 $(el).addClass('onAppear');
2346 },
2347 disappear: function disappear(el) {
2348 $(el).removeClass('onAppear');
2349 },
2350 reappear: function reappear(el) {
2351 $(el).addClass('onAppear');
2352 },
2353 bounds: 0
2354 });
2355
2356 }
2357
2358 // circle progress
2359 d.circleProgress();
2360
2361 // masonry init
2362 d.masonryInit();
2363
2364 // Lightbox
2365 d.magnificPopupInit();
2366
2367 d.floatEdgeMedia();
2368
2369 d.contactFormInit();
2370
2371 d.teamProfileInit();
2372 },
2373
2374 teamProfileInit: function() {
2375 var d=this;
2376
2377 $('.team-card').each(function() {
2378 if ( /iPad|iPhone|iPod|Android/.test(navigator.userAgent) === false ) {
2379 $(this).addClass('untouched');
2380 } else {
2381 $(this).removeClass('untouched');
2382 }
2383 });
2384 },
2385
2386 contactFormInit: function() {
2387 var d=this, form=$('.contact-form');
2388
2389 if ( form.length ) {
2390 form.each( function() {
2391 var f=this;
2392
2393 $(f).find('input:not([type="submit"])').each(function() {
2394 var ip=this;
2395
2396 ( $(ip).val() !== "" ) && $(ip).addClass('has_value');
2397
2398 $(ip).on('blur', function() {
2399 ( $(ip).val() !== "" ) ? $(ip).addClass('has_value') : $(ip).removeClass('has_value');
2400 });
2401 });
2402 });
2403 }
2404 },
2405
2406 floatEdgeMedia: function() {
2407 var d=this, lft=$('.container').offset().left, pl= parseFloat($('.container').css('padding-left'));
2408
2409 $('.br-float-right-edge').each(function() {
2410 var _x=this,w;
2411 $(_x).removeAttr('style');
2412 w = $(_x).width();
2413 _x.style.width = (w+lft+pl)+'px';
2414 _x.style.position = 'relative';
2415 _x.style.marginRight = ((lft+pl)*-1)+'px';
2416 });
2417
2418 $('.br-float-left-edge').each(function() {
2419 var _x=this,w;
2420 $(_x).removeAttr('style');
2421 w = $(_x).width();
2422 _x.style.width = (w+lft+pl)+'px';
2423 _x.style.position = 'relative';
2424 _x.style.marginLeft = ((lft+pl)*-1)+'px';
2425 });
2426 },
2427
2428 animatedNumber: function(el) {
2429 var d=this, fnlObj, fnl=$(el).data('final-number'), drt=(typeof $(el).data('duration') === 'undefined') ? 1500 : $(el).data('duration');
2430
2431 if ( typeof fnl === 'undefined' ) {
2432 return false;
2433 }
2434 fnlObj = {progress: 0};
2435 anime({
2436 targets: fnlObj,
2437 progress: [0, fnl],
2438 duration: Math.round(drt),
2439 easing: 'easeInSine',
2440 update: function() {
2441 $(el).html( Math.round(fnlObj.progress).toLocaleString() );
2442 }
2443 });
2444 },
2445
2446 magnificPopupInit: function() {
2447 var d=this;
2448
2449 if ( $('.br-gallery').length ) {
2450 $('.br-gallery').each(function(z) {
2451 var f=this, gal=false;
2452 if ( $(f).find('a').length ) {
2453 $(f).find('a').each( function(i, el) {
2454 var href_value = el.href;
2455 if (/\.(jpg|jpeg|png|gif)$/.test(href_value)) {
2456 gal=true;
2457 }
2458 });
2459
2460 if ( gal ) {
2461 $(f).magnificPopup({
2462 delegate: 'a',
2463 type: 'image',
2464 removalDelay: 300,
2465 mainClass: 'mfp-fade',
2466 gallery:{
2467 enabled:true
2468 }
2469 });
2470 }
2471 }
2472 });
2473 }
2474 },
2475
2476
2477 /**
2478 * Circular progress helper
2479 *
2480 * @since 1.0.0
2481 */
2482 circleProgress: function() {
2483 var d=this;
2484
2485 $('.br-circle-progress').each(function() {
2486 var _x=this, r= 0,
2487 c = document.createDocumentFragment(),
2488 data = $(_x).data('progress');
2489
2490 var svg = document.createElementNS("http://www.w3.org/2000/svg", "svg"),
2491 circ = document.createElementNS("http://www.w3.org/2000/svg", "circle"),
2492 circBG = document.createElementNS("http://www.w3.org/2000/svg", "circle"),
2493 progText = document.createElementNS("http://www.w3.org/2000/svg", "text");
2494 svg.setAttribute( 'viewBox', '0 0 250 250');
2495 svg.setAttribute( 'width', '250');
2496 svg.setAttribute( 'height', '250');
2497 c.appendChild(svg);
2498 svg.appendChild(circBG);
2499 svg.appendChild(circ);
2500 svg.appendChild(progText);
2501
2502 circ.setAttribute( 'class', 'circ-to-progress' );
2503 circ.setAttribute( 'fill', 'none' );
2504 circ.setAttribute( 'stroke', data['color'] );
2505 circ.setAttribute( 'cx', '125' );
2506 circ.setAttribute( 'cy', '125' );
2507
2508 circBG.setAttribute( 'fill', 'none' );
2509 circBG.setAttribute( 'stroke', data['background'] );
2510 circBG.setAttribute( 'cx', '125' );
2511 circBG.setAttribute( 'cy', '125' );
2512
2513 progText.setAttribute('x', '50%');
2514 progText.setAttribute('y', '50%');
2515 progText.setAttribute('dominant-baseline', 'middle');
2516 progText.setAttribute('text-anchor', 'middle');
2517
2518 progText.innerHTML = data.percent;
2519
2520 r = (250/2)-(30/2);
2521 circ.setAttribute( 'r', r );
2522 circ.setAttribute( 'stroke-width', '30');
2523 circ.setAttribute( 'opacity', '0');
2524
2525 circBG.setAttribute( 'r', r );
2526 circBG.setAttribute( 'stroke-width', '30');
2527
2528 switch( data.size ) {
2529 case 'small':
2530 svg.setAttribute( 'class', 'svg-circle small' );
2531 break;
2532 case 'big':
2533 svg.setAttribute( 'class', 'svg-circle big' );
2534 break;
2535 case 'medium':
2536 default:
2537 svg.setAttribute( 'class', 'svg-circle medium' );
2538 break;
2539 }
2540 circ.setAttribute('stroke-dashoffset',(2*Math.PI*r)*(1-(parseInt(data.percent)/100)));
2541 circ.setAttribute('stroke-dasharray', 2*Math.PI*r );
2542 circ.setAttribute('transform', 'rotate(-90, 125, 125)');
2543
2544 _x.appendChild(c);
2545 });
2546 },
2547
2548 masonryInit: function() {
2549 var d=this, masonGallery, metroGallery;
2550
2551 if ( $('.br-masonry-gallery').length ) {
2552 var grids = $('.masonry-grid')
2553 masonGallery = grids.masonry({
2554 itemSelector: '.masonry-grid-item',
2555 columnWidth: '.masonry__sizer',
2556 percentPosition: true,
2557 transitionDuration: '0.3s',
2558 gutter: 0,
2559 });
2560
2561 masonGallery.masonry().masonry('layout');
2562 }
2563
2564 if ( $('.br-metro-gallery').length ) {
2565 var mGrids = $('.metro-grid')
2566 metroGallery = mGrids.masonry({
2567 itemSelector: '.metro-grid-item',
2568 columnWidth: '.metro__sizer',
2569 percentPosition: true,
2570 transitionDuration: '0.3s',
2571 gutter: 0,
2572 });
2573
2574 metroGallery.masonry().masonry('layout');
2575 }
2576 },
2577
2578 watchPortfolioGridItems: function() {
2579 var d=this,curScroll=d.$win.scrollTop();
2580
2581 if ( $('.portfolio-grid-lists').length ) {
2582 $('.onAppear').each(function() {
2583 var _x=this, move = 0;
2584 if ( !$(_x).hasClass('onAppear') ) {
2585 return;
2586 }
2587
2588 var intercept = curScroll-d.$win.height();
2589 var followScroll = ( $(_x).find('.portfolio-grid-obj').css('transform') !== 'none' ) ? true : false;
2590
2591 if ( curScroll > d.origScroll ) {
2592 move = followScroll ? intercept/75 : (intercept/75)*-1;
2593 } else {
2594 move = followScroll ? (intercept/75)*-1 : intercept/75;
2595 }
2596 $(_x).css({
2597 'will-change' : 'transform',
2598 '-webkit-backface-visibility' : 'hidden',
2599 'perspective' : '1000px',
2600 '-webkit-transform': 'translate3d(0, '+move+'px, 0)',
2601 transform: 'translate3d(0, '+move+'px, 0)',
2602 });
2603 });
2604 }
2605 d.origScroll = curScroll;
2606 },
2607
2608 customPointerInit: function() {
2609 var d=this;
2610
2611 // If feature is disabled OR we on a touch enable device, stop it.
2612 if ( ! $('body').hasClass('custom-pointer') || ('ontouchstart' in document.documentElement) ) {
2613 return false;
2614 }
2615
2616 var cp = $('<canvas id="brayn-custom-pointer" width="50" height="50"></canvas>');
2617 $('body').append(cp);
2618 var c = document.getElementById("brayn-custom-pointer");
2619 var ctx = c.getContext("2d");
2620 ctx.beginPath();
2621 ctx.arc(25, 25, 20, 0, 2 * Math.PI, true);
2622 ctx.strokeStyle = "rgba(0,0,0, .65)";
2623 ctx.stroke();
2624 ctx.beginPath();
2625 ctx.arc(25, 25, 21, 0, 2 * Math.PI, true);
2626 ctx.strokeStyle = "rgba(255,255,255, .65)";
2627 ctx.stroke();
2628 $('#brayn-custom-pointer').css({
2629 position: 'fixed',
2630 zIndex: 99,
2631 top: '0',
2632 left: '0',
2633 pointerEvents: 'none',
2634 mixBlendMode : 'screen'
2635 });
2636
2637 d.attachPointerEvents();
2638 },
2639
2640 attachPointerEvents: function() {
2641 var d=this;
2642 document.getElementsByTagName("body")[0].addEventListener("mousemove", function(e) {
2643 var locX = e.clientX-25,
2644 locY = e.clientY-25;
2645
2646 document.getElementById("brayn-custom-pointer").style.webkitTransform = 'translate3D('+locX+'px, '+locY+'px, 0)';
2647 document.getElementById("brayn-custom-pointer").style.mozTransform = 'translate3D('+locX+'px, '+locY+'px, 0)';
2648 document.getElementById("brayn-custom-pointer").style.transform = 'translate3D('+locX+'px, '+locY+'px, 0)';
2649 });
2650 },
2651
2652 prettyReveal: function() {
2653 var d=this,
2654 fbi=$('.full-img-block'),
2655 ef=$('.has-reveal-effect'),
2656 circProg = $('.br-circle-progress');
2657
2658 if ( circProg.length && typeof window.appear !== 'undefined' ) {
2659 var circularAppear = new window.appear({
2660 elements: function elements() {
2661 return document.getElementsByClassName('svg-circle');
2662 },
2663 appear: function appear(el,i) {
2664 if ( $(el).hasClass('done-animate') ) {
2665 return;
2666 }
2667
2668 $(el).addClass( 'done-animate' );
2669 var cAnim, cDash = $(el).find('.circ-to-progress').attr('stroke-dashoffset'),
2670 cDarray = $(el).find('.circ-to-progress').attr('stroke-dasharray'),
2671 cProg = $(el).find('text').html(),
2672 cProgdata = { progress: 0 };
2673
2674 cAnim = anime.timeline({
2675 autoplay: true,
2676 });
2677 $(el).find('.circ-to-progress').attr('stroke-dashoffset', cDarray).attr('opacity', 1);
2678 $(el).find('text').html('');
2679 cAnim.add({
2680 targets: $(el).find('.circ-to-progress')[0],
2681 strokeDashoffset: [cDarray, cDash],
2682 duration: 1200,
2683 delay: 100,
2684 easing: 'easeInOutCirc'
2685 }).add({
2686 targets: cProgdata,
2687 progress: cProg,
2688 duration: 1200,
2689 delay: 100,
2690 easing: 'easeInOutSine',
2691 update: function() {
2692 $(el).find('text').html( Math.round(cProgdata.progress)+'%');
2693 }
2694 }, '-=1200');
2695 },
2696 bounds: 0
2697 });
2698 }
2699
2700 if ( $('.br-animated-number').length && typeof window.appear !== 'undefined' ) {
2701 var animNumberReveal = new window.appear({
2702 elements: function elements() {
2703 return document.getElementsByClassName('br-animated-number');
2704 },
2705 appear: function appear(el,i) {
2706 if ( $(el).hasClass('done-animate') ) {
2707 return;
2708 }
2709
2710 $(el).addClass( 'done-animate' );
2711
2712 // animated number
2713 d.animatedNumber( el );
2714
2715 },
2716 bounds: 0
2717 });
2718 }
2719
2720 if ( fbi.length && typeof window.appear !== 'undefined' ) {
2721 var fbiAppear = new window.appear({
2722 elements: function elements() {
2723 return document.getElementsByClassName('full-img-block');
2724 },
2725 appear: function appear(el) {
2726 if ( $(el).hasClass('done-animate') ) {
2727 return;
2728 }
2729
2730 $(el).addClass( 'done-animate' );
2731 new pSlideCanvas( el, el, 'appear', 'assets/images/clouds.jpg', {width: $(el).width(), height: $(el).height()} );
2732 },
2733 bounds: 0
2734 });
2735 }
2736
2737 if ( ef.length && typeof window.appear !== 'undefined' ) {
2738 var globReveal = new window.appear({
2739 elements: function elements() {
2740 return document.getElementsByClassName('has-reveal-effect');
2741 },
2742 appear: function appear(el, dly) {
2743 if ( $(el).hasClass('done-animate') ) {
2744 return;
2745 }
2746
2747 var effect = $(el).data('effect');
2748 if ( typeof effect === 'undefined' ) {
2749 // default
2750 effect = 'fadeInTop';
2751 }
2752
2753 $(el).addClass( 'done-animate' );
2754
2755 switch( effect ) {
2756 case 'revealRight':
2757 $(el).css({opacity:1});
2758 var rx = $('<span class="revealer" />');
2759 $(el).addClass('revealOnProc').append( rx );
2760 rx.css({
2761 left: 0,
2762 top: 0,
2763 width: 0,
2764 });
2765 anime({
2766 targets: $(rx)[0],
2767 width: ['0%', '100%'],
2768 duration: 300,
2769 easing: 'easeInOutCirc',
2770 complete: function() {
2771 $(rx).css({
2772 left : 'initial',
2773 right: 0,
2774 });
2775 $(el).removeClass('revealOnProc');
2776
2777 anime({
2778 targets: $(rx)[0],
2779 width: 0,
2780 duration: 300,
2781 easing: 'easeInOutCirc',
2782 delay: 200,
2783 complete: function() {
2784 $(el).removeClass('has-reveal-effect').css({opacity: '', transform: '', '-webkit-transform': ''});
2785 $(rx).remove();
2786 }
2787 });
2788 },
2789 delay: function(el) { return dly * 50; },
2790 });
2791 break;
2792 case 'revealLeft':
2793 $(el).css({opacity:1});
2794 var rx = $('<span class="revealer" />');
2795 $(el).addClass('revealOnProc').append( rx );
2796 rx.css({
2797 right: 0,
2798 top: 0,
2799 width: 0,
2800 });
2801 anime({
2802 targets: $(rx)[0],
2803 width: ['0%', '100%'],
2804 duration: 300,
2805 easing: 'easeInOutCirc',
2806 complete: function() {
2807 $(rx).css({
2808 right : 'initial',
2809 left: 0,
2810 });
2811 $(el).removeClass('revealOnProc');
2812
2813 anime({
2814 targets: $(rx)[0],
2815 width: 0,
2816 duration: 300,
2817 easing: 'easeInOutCirc',
2818 delay: 200,
2819 complete: function() {
2820 $(el).removeClass('has-reveal-effect').css({opacity: '', transform: '', '-webkit-transform': ''});
2821 $(rx).remove();
2822 }
2823 });
2824 },
2825 delay: function(el) { return dly * 50; },
2826 });
2827 break;
2828 case 'revealTop':
2829 $(el).css({opacity:1});
2830 var rx = $('<span class="revealer" />');
2831 $(el).addClass('revealOnProc').append( rx );
2832 rx.css({
2833 right: 0,
2834 left: 0,
2835 bottom: 0,
2836 height: 0,
2837 });
2838 anime({
2839 targets: $(rx)[0],
2840 height: ['0%', '100%'],
2841 duration: 300,
2842 easing: 'easeInOutCirc',
2843 complete: function() {
2844 $(rx).css({
2845 bottom : 'initial',
2846 top: 0,
2847 });
2848 $(el).removeClass('revealOnProc');
2849
2850 anime({
2851 targets: $(rx)[0],
2852 height: 0,
2853 duration: 300,
2854 easing: 'easeInOutCirc',
2855 delay: 200,
2856 complete: function() {
2857 $(el).removeClass('has-reveal-effect').css({opacity: '', transform: '', '-webkit-transform': ''});
2858 $(rx).remove();
2859 }
2860 });
2861 },
2862 delay: function(el) { return dly * 50; },
2863 });
2864 break;
2865 case 'revealBottom':
2866 $(el).css({opacity:1});
2867 var rx = $('<span class="revealer" />');
2868 $(el).addClass('revealOnProc').append( rx );
2869 rx.css({
2870 right: 0,
2871 left: 0,
2872 top: 0,
2873 height: 0,
2874 });
2875 anime({
2876 targets: $(rx)[0],
2877 height: ['0%', '100%'],
2878 duration: 300,
2879 easing: 'easeInOutCirc',
2880 complete: function() {
2881 $(rx).css({
2882 top : 'initial',
2883 bottom: 0,
2884 });
2885 $(el).removeClass('revealOnProc');
2886
2887 anime({
2888 targets: $(rx)[0],
2889 height: 0,
2890 duration: 300,
2891 easing: 'easeInOutCirc',
2892 delay: 200,
2893 complete: function() {
2894 $(el).removeClass('has-reveal-effect').css({opacity: '', transform: '', '-webkit-transform': ''});
2895 $(rx).remove();
2896 }
2897 });
2898 },
2899 delay: function(el) { return dly * 50; },
2900 });
2901 break;
2902 case 'fadeIn':
2903 anime({
2904 targets: el,
2905 opacity: [0,1],
2906 duration: 500,
2907 easing: 'easeInOutSine',
2908 complete: function() {
2909 $(el).removeClass('has-reveal-effect').css({opacity: '', transform: '', '-webkit-transform': ''});
2910 },
2911 delay: function(el) { return dly * 50; },
2912 });
2913 break;
2914 case 'fadeInLeft':
2915 anime({
2916 targets: el,
2917 opacity: [0,1],
2918 translateX: [75, 0],
2919 duration: 500,
2920 easing: 'easeInOutSine',
2921 complete: function() {
2922 $(el).removeClass('has-reveal-effect').css({opacity: '', transform: '', '-webkit-transform': ''});
2923 },
2924 delay: function(el) { return dly * 50; },
2925 });
2926 break;
2927 case 'fadeInRight':
2928 anime({
2929 targets: el,
2930 opacity: [0,1],
2931 translateX: [-75, 0],
2932 duration: 500,
2933 easing: 'easeInOutSine',
2934 complete: function() {
2935 $(el).removeClass('has-reveal-effect').css({opacity: '', transform: '', '-webkit-transform': ''});
2936 },
2937 delay: function(el) { return dly * 50; },
2938 });
2939 break;
2940 case 'zoomIn':
2941 $(el).css({opacity:1,transform: 'scale(0)','-webkit-transform': 'scale(0)'});
2942 anime({
2943 targets: el,
2944 scale: [0, 1],
2945 duration: 500,
2946 easing: 'easeInOutSine',
2947 complete: function() {
2948 $(el).removeClass('has-reveal-effect').css({opacity: '', transform: '', '-webkit-transform': ''});
2949 },
2950 delay: function(el) { return dly * 50; },
2951 });
2952 break;
2953 case 'fadeInBottom':
2954 anime({
2955 targets: el,
2956 opacity: [0,1],
2957 translateY: [-75, 0],
2958 duration: 500,
2959 easing: 'easeInOutQuad',
2960 complete: function() {
2961 $(el).removeClass('has-reveal-effect').css({opacity: '', transform: '', '-webkit-transform': ''});
2962 },
2963 delay: function(el) { return dly * 50; },
2964 });
2965 break;
2966 case 'fadeInTop':
2967 default:
2968 anime({
2969 targets: el,
2970 opacity: [0,1],
2971 translateY: [100, 0],
2972 duration: 500,
2973 easing: 'easeInOutQuad',
2974 complete: function() {
2975 $(el).removeClass('has-reveal-effect').css({opacity: '', transform: '', '-webkit-transform': ''});
2976 },
2977 delay: function(el) { return dly * 50; },
2978 });
2979 break;
2980 }
2981 },
2982 bounds: -50
2983 });
2984 }
2985 },
2986
2987 // Process contact form
2988 processContactForm: function() {
2989 var d=this, $form=$('#brayn-contact-form'), onSend = false;
2990
2991 $form.on('submit', function(e) {
2992 e.preventDefault();
2993
2994 if ( onSend ) {
2995 return false;
2996 }
2997
2998 if ( $form.find('textarea[name="message"]').val() === "" ) {
2999 $form.find('textarea[name="message"]').focus().addClass('border-danger');
3000 return false;
3001 }
3002
3003 $form.find('.border-danger').removeClass('border-danger');
3004 $form.find('button.submit').addClass('on-submit');
3005 onSend = true;
3006
3007 var from_data = $form.serialize();
3008
3009 $.ajax({
3010 url : $form.attr('action'),
3011 type : 'post',
3012 data : from_data,
3013 dataType : 'json',
3014 success: function( cb ) {
3015 $form.find('.cf-message').html('<div class="alert alert-success">'+ cb.messages +'</div>');
3016 $(window).scrollTop( $form.offset().top-100 );
3017 $form.trigger('reset');
3018 $form.find('input').blur();
3019 $form.find('button.submit').removeClass('on-submit');
3020 window.setTimeout(function() {
3021 $form.find('.cf-message').find('.alert').animate({
3022 opacity : 0
3023 }, 300, function() {
3024 $form.find('.cf-message').html('');
3025 onSend = false;
3026 });
3027 }, 3000);
3028 },
3029 error: function( cb ) {
3030 var err = JSON.parse( cb.responseText );
3031
3032 $form.find('.cf-message').html('<div class="alert alert-danger">'+ err.messages +'</div>');
3033 $(window).scrollTop( $form.offset().top-100 );
3034 $form.find('button.submit').removeClass('on-submit');
3035 window.setTimeout(function() {
3036 $form.find('.cf-message').find('.alert').animate({
3037 opacity : 0
3038 }, 300, function() {
3039 $form.find('.cf-message').html('');
3040 onSend = false
3041 });
3042 }, 3000);
3043 }
3044 });
3045
3046 });
3047 },
3048
3049 // Remove the firsttime preloader
3050 removeLoader: function() {
3051 var d=this;
3052
3053 if ( $('.portfolio-grid-lists').length ) {
3054 $('.portfolio-grid-lists').find('.image-shadow').each(function(v){
3055 var c=this,
3056 data = {
3057 el: c,
3058 image: c.querySelector("img"),
3059 id: v
3060 };
3061 d.canvasBlur(data);
3062 });
3063 }
3064 $(window).scrollTop(0);
3065
3066 requestAnimationFrame(function(){
3067 if ( $('#brayn-first-load').length ) {
3068
3069 $('#main-header').css({
3070 '-webkit-transform' : 'translateY(-300px)',
3071 'transform' : 'translateY(-300px)',
3072 });
3073 anime({
3074 targets: '#brayn-first-load',
3075 opacity: 0,
3076 duration: 800,
3077 easing: 'easeOutSine',
3078 complete: function() {
3079 $(window).trigger('braynHasFinishLoad');
3080 $('#brayn-first-load').detach();
3081 anime({
3082 targets: '#main-header',
3083 translateY: [-300, 0],
3084 duration: 600,
3085 easing: 'easeInSine',
3086 complete: function() {
3087 $('#main-header').removeAttr('style');
3088 }
3089 });
3090 },
3091 });
3092 } else {
3093 window.requestTimeout(function(){
3094 $(window).trigger('braynHasFinishLoad');
3095 },300);
3096 }
3097 });
3098 },
3099 };
3100 z.init();
3101 return z;
3102}( window.jQuery );