PageSourceSearch

https://wasserfallen.news/wp-content/plugins/cubeportfolio/public/js/main.min-1.13.2.js?ver=5.1

js wasserfallen.news collected 2026-10-02 23:39:16 UTC 209,857 bytes, 6,476 lines download raw bytes

1/*!
2 * Cube Portfolio - Responsive jQuery Grid Plugin
3 *
4 * version: 3.4.1 (21 November, 2015)
5 * require: jQuery v1.7+
6 *
7 * Copyright 2013-2015, Mihai Buricea (http://scriptpie.com/cubeportfolio/live-preview/)
8 * Licensed under CodeCanyon License (http://codecanyon.net/licenses)
9 *
10 */
11
12(function($, window, document, undefined) {
13    'use strict';
14
15    function CubePortfolio(obj, options, callback) {
16        /*jshint validthis: true */
17        var t = this,
18            initialCls = 'cbp',
19            children;
20
21        if (jQuery.data(obj, 'cubeportfolio')) {
22            throw new Error('cubeportfolio is already initialized. Destroy it before initialize again!');
23        }
24
25        // attached this instance to obj
26        jQuery.data(obj, 'cubeportfolio', t);
27
28        // extend options
29        t.options = jQuery.extend({}, jQuery.fn.cubeportfolio.options, options);
30
31        // store the state of the animation used for filters
32        t.isAnimating = true;
33
34        // default filter for plugin
35        t.defaultFilter = t.options.defaultFilter;
36
37        // registered events (observator & publisher pattern)
38        t.registeredEvents = [];
39
40        // queue for this plugin
41        t.queue = [];
42
43        // has wrapper
44        t.addedWrapp = false;
45
46        // register callback function
47        if (jQuery.isFunction(callback)) {
48            t.registerEvent('initFinish', callback, true);
49        }
50
51        // js element
52        t.obj = obj;
53
54        // jquery element
55        t.$obj = jQuery(obj);
56
57        // when there are no .cbp-item
58        children = t.$obj.children();
59
60        // if caption is active
61        if (t.options.caption) {
62            if (t.options.caption !== 'expand' && !CubePortfolio.private.modernBrowser) {
63                t.options.caption = 'minimal';
64            }
65
66            // .cbp-caption-active is used only for css
67            // so it will not generate a big css from sass if a caption is set
68            initialCls += ' cbp-caption-active cbp-caption-' + t.options.caption;
69        }
70
71        t.$obj.addClass(initialCls);
72
73        if (children.length === 0 || children.first().hasClass('cbp-item')) {
74            t.wrapInner(t.obj, 'cbp-wrapper');
75            t.addedWrapp = true;
76        }
77
78        // jquery wrapper element
79        t.$ul = t.$obj.children().addClass('cbp-wrapper');
80
81        // wrap the $ul in a outside wrapper
82        t.wrapInner(t.obj, 'cbp-wrapper-outer');
83
84        t.wrapper = t.$obj.children('.cbp-wrapper-outer');
85
86        t.blocks = t.$ul.children('.cbp-item');
87        t.blocksOn = t.blocks;
88
89		// TREETHEMES 2020 fix protocols
90		t.blocksOn.each(function(){ 
91			jQuery(this).find('a[href*="http://"], a[href*="https://"]').each( function(){ jQuery(this).attr('href', jQuery(this).attr('href').replace('http://','//').replace('https://','//') ); } );
92			jQuery(this).find('img[src*="http://"], img[src*="https://"]').each( function(){ jQuery(this).attr('src', jQuery(this).attr('src').replace('http://','//').replace('https://','//') ); } ); 
93		});
94		// TREETHEMES 2020 endof fix protocols
95
96        // wrap .cbp-item-wrap div inside .cbp-item
97        t.wrapInner(t.blocks, 'cbp-item-wrapper');
98
99        // register and initialize plugins
100        t.plugins = jQuery.map(CubePortfolio.plugins, function(pluginName) {
101            return pluginName(t);
102        });
103
104        // wait to load all images and then go further
105        t.loadImages(t.$obj, t.display);
106    }
107
108
109    jQuery.extend(CubePortfolio.prototype, {
110        storeData: function(blocks, indexStart) {
111            var t = this;
112
113            indexStart = indexStart || 0; // used by loadMore
114
115            blocks.each(function(index, el) {
116                var item = jQuery(el),
117                    width = item.width(),
118                    height = item.height();
119                    
120                // TREETHEMES 2020 fix protocols
121                item.find('a[href*="http://"], a[href*="https://"]').each( function(){ jQuery(this).attr('href', jQuery(this).attr('href').replace('http://','//').replace('https://','//') ); } );
122				item.find('img[src*="http://"], img[src*="https://"]').each( function(){ jQuery(this).attr('src', jQuery(this).attr('src').replace('http://','//').replace('https://','//') ); } ); 
123				// TREETHEMES 2020 endof fix protocols
124
125                item.data('cbp', {
126                    index: indexStart + index, // used when I sort the items and I need them to revert that sorting
127                    wrapper: item.children('.cbp-item-wrapper'),
128
129                    widthInitial: width,
130                    heightInitial: height,
131
132                    width: width, // used by drag & drop wp @todo - maybe I will use widthAndGap
133                    height: height,
134
135                    widthAndGap: width + t.options.gapVertical,
136                    heightAndGap: height + t.options.gapHorizontal,
137
138                    left: null,
139                    leftNew: null,
140                    top: null,
141                    topNew: null,
142
143                    pack: false,
144                });
145            });
146        },
147
148
149        // http://bit.ly/pure-js-wrap
150        wrapInner: function(items, classAttr) {
151            var t = this,
152                item, i, div;
153
154            classAttr = classAttr || '';
155
156            if (items.length && items.length < 1) {
157                return; // there are no .cbp-item
158            } else if (items.length === undefined) {
159                items = [items];
160            }
161
162            for (i = items.length - 1; i >= 0; i--) {
163                item = items[i];
164
165                div = document.createElement('div');
166
167                div.setAttribute('class', classAttr);
168
169                while (item.childNodes.length) {
170                    div.appendChild(item.childNodes[0]);
171                }
172
173                item.appendChild(div);
174            }
175        },
176
177        removeAttrImage: function(img) {
178            img.removeAttribute('width');
179            img.removeAttribute('height');
180            img.removeAttribute('style');
181        },
182
183
184        /**
185         * Wait to load all images
186         */
187        loadImages: function(elems, callback) {
188            var t = this;
189
190            // wait a frame (Safari bug)
191            requestAnimationFrame(function() {
192                var src = elems.find('img').map(function(index, el) {
193                    // don't wait for images that have a width & height defined
194                    if (el.hasAttribute('width') && el.hasAttribute('height')) {
195                        el.style.width = el.getAttribute('width') + 'px';
196                        el.style.height = el.getAttribute('height') + 'px';
197
198                        if (el.hasAttribute('data-cbp-src')) {
199                            return null;
200                        }
201
202                        if (t.checkSrc(el.src) === null) {
203                            t.removeAttrImage(el);
204                        } else {
205                            jQuery('<img>').on('load.cbp error.cbp', function() {
206                                t.removeAttrImage(el);
207                            }).attr('src', el.src); // for ie8
208                        }
209
210                        return null;
211                    } else {
212                        return t.checkSrc(el.src);
213                    }
214                });
215
216                var srcLength = src.length;
217
218                if (srcLength === 0) {
219                    callback.call(t);
220                    return;
221                }
222
223                jQuery.each(src, function(i, el) {
224                    jQuery('<img>').on('load.cbp error.cbp', function() {
225                        srcLength--;
226
227                        if (srcLength === 0) {
228                            callback.call(t);
229                        }
230                    }).attr('src', el); // for ie8
231                });
232            });
233        },
234
235
236        checkSrc: function(src) {
237            if (src === '') {
238                return null;
239            }
240
241            var img = new Image();
242            img.src = src;
243
244            if (img.complete && img.naturalWidth !== undefined && img.naturalWidth !== 0) {
245                return null;
246            }
247
248            return src;
249        },
250
251
252        /**
253         * Show the plugin
254         */
255        display: function() {
256            var t = this;
257
258            // store main container width
259            t.width = t.$obj.outerWidth();
260
261            // store to data values of t.blocks
262            t.storeData(t.blocks);
263
264            t.triggerEvent('initStartRead');
265            t.triggerEvent('initStartWrite');
266
267            // make layout
268            t.layoutAndAdjustment();
269
270            t.triggerEvent('initEndRead');
271            t.triggerEvent('initEndWrite');
272
273            // plugin is ready to show and interact
274            t.$obj.addClass('cbp-ready');
275
276            t.runQueue('delayFrame', t.delayFrame);
277        },
278
279
280        delayFrame: function() {
281            var t = this;
282
283            requestAnimationFrame(function() {
284                t.resizeEvent();
285
286                t.triggerEvent('initFinish');
287
288                // animating is now false
289                t.isAnimating = false;
290
291                // trigger public event initComplete
292                t.$obj.trigger('initComplete.cbp');
293            });
294        },
295
296
297        /**
298         * Add resize event when browser width changes
299         */
300        resizeEvent: function() {
301            var t = this,
302                gridWidth;
303
304            CubePortfolio.private.initResizeEvent({
305                instance: t,
306                fn: function() {
307                    var tt = this;
308
309                    // used by wp fullWidth force option
310                    tt.triggerEvent('beforeResizeGrid');
311
312                    gridWidth = tt.$obj.outerWidth();
313
314                    if (tt.width !== gridWidth) {
315
316                        if (tt.options.gridAdjustment === 'alignCenter') {
317                            tt.wrapper[0].style.maxWidth = '';
318                        }
319
320                        // update the current grid width
321                        tt.width = gridWidth;
322
323                        // reposition the blocks with gridAdjustment set to true
324                        tt.layoutAndAdjustment();
325
326                        tt.triggerEvent('resizeGrid');
327                    }
328
329                    tt.triggerEvent('resizeWindow');
330                }
331            });
332        },
333
334
335        gridAdjust: function() {
336            var t = this;
337
338            // if responsive
339            if (t.options.gridAdjustment === 'responsive') {
340                t.responsiveLayout();
341            } else {
342                // reset the style attribute for all blocks so I can read a new width & height
343                // for the current grid width. This is usefull for the styles defined in css
344                // to create a custom responsive system.
345                // Note: reset height if it was set for addHeightToBlocks
346                t.blocks.removeAttr('style');
347
348                t.blocks.each(function(index, el) {
349                    var data = jQuery(el).data('cbp'),
350                        bound = el.getBoundingClientRect(),
351                        width = t.columnWidthTruncate(bound.right - bound.left),
352                        height = Math.round(bound.bottom - bound.top);
353
354                    data.height = height;
355                    data.heightAndGap = height + t.options.gapHorizontal;
356
357                    data.width = width;
358                    data.widthAndGap = width + t.options.gapVertical;
359                });
360
361                t.widthAvailable = t.width + t.options.gapVertical;
362            }
363
364            // used by slider layoutMode
365            t.triggerEvent('gridAdjust');
366        },
367
368
369        layoutAndAdjustment: function() {
370            var t = this;
371
372            t.gridAdjust();
373
374            t.layout();
375        },
376
377
378        /**
379         * Build the layout
380         */
381        layout: function() {
382            var t = this;
383
384            t.computeBlocks(t.filterConcat(t.defaultFilter));
385
386            if (t.options.layoutMode === 'slider') {
387                t.sliderLayoutReset();
388                t.sliderLayout();
389            } else {
390                t.mosaicLayoutReset();
391                t.mosaicLayout();
392            }
393
394
395            // positionate the blocks
396            t.positionateItems();
397
398            // resize main container height
399            t.resizeMainContainer();
400        },
401
402
403        computeFilter: function(expression) {
404            var t = this;
405
406            t.computeBlocks(expression);
407
408            t.mosaicLayoutReset();
409            t.mosaicLayout();
410
411            // filter call layout
412            t.filterLayout();
413        },
414
415
416        /**
417         *  Default filter layout if nothing overrides
418         */
419        filterLayout: function() {
420            var t = this;
421
422            t.blocksOff.addClass('cbp-item-off');
423
424            t.blocksOn.removeClass('cbp-item-off')
425                .each(function(index, el) {
426                    var data = jQuery(el).data('cbp');
427
428                    data.left = data.leftNew;
429                    data.top = data.topNew;
430
431                    el.style.left = data.left + 'px';
432                    el.style.top = data.top + 'px';
433                });
434
435            // resize main container height
436            t.resizeMainContainer();
437
438            t.filterFinish();
439        },
440
441
442        /**
443         *  Trigger when a filter is finished
444         */
445        filterFinish: function() {
446            var t = this;
447
448            // if blocks are sorted (the index ascending is broken) revert
449            // this state so the index is ascending again
450            if (t.blocksAreSorted) {
451                t.sortBlocks(t.blocks, 'index');
452            }
453
454            t.isAnimating = false;
455
456            t.$obj.trigger('filterComplete.cbp');
457            t.triggerEvent('filterFinish');
458        },
459
460
461        computeBlocks: function(expression) {
462            var t = this;
463
464            // blocks that are visible before applying the filter
465            t.blocksOnInitial = t.blocksOn;
466
467            // blocks visible after applying the filter
468            t.blocksOn = t.blocks.filter(expression);
469
470            // blocks off after applying the filter
471            t.blocksOff = t.blocks.not(expression);
472
473            t.triggerEvent('computeBlocksFinish', expression);
474        },
475
476
477        /**
478         * Make this plugin responsive
479         */
480        responsiveLayout: function() {
481            var t = this;
482
483            // calculate numbers of cols
484            t.cols = t[(jQuery.isArray(t.options.mediaQueries) ? 'getColumnsBreakpoints' : 'getColumnsAuto')]();
485
486            t.columnWidth = t.columnWidthTruncate((t.width + t.options.gapVertical) / t.cols);
487
488            t.widthAvailable = t.columnWidth * t.cols;
489
490            if (t.options.layoutMode === 'mosaic') {
491                t.getMosaicWidthReference();
492            }
493
494            t.blocks.each(function(index, el) {
495                var data = jQuery(el).data('cbp'),
496                    cols = 1, // grid & slider layoutMode must be 1
497                    width;
498
499                if (t.options.layoutMode === 'mosaic') {
500                    cols = t.getColsMosaic(data.widthInitial);
501                }
502
503                width = t.columnWidth * cols - t.options.gapVertical;
504
505                el.style.width = width + 'px';
506                data.width = width;
507                data.widthAndGap = width + t.options.gapVertical;
508
509                // reset height if it was set for addHeightToBlocks
510                el.style.height = '';
511            });
512
513            var imgs = [];
514
515            t.blocks.each(function(index, el) {
516                var block = jQuery(el),
517                    width = block.data('cbp').width;
518
519                jQuery.each(block.find('img').filter('[width][height]'), function(index, el) {
520                    var procent = width / parseInt(el.getAttribute('width'), 10);
521
522                    imgs.push({
523                        el: el,
524                        width: width,
525                        height: Math.floor(parseInt(el.getAttribute('height'), 10) * procent),
526                    });
527                });
528            });
529
530            jQuery.each(imgs, function(index, item) {
531                 item.el.width = item.width;
532                 item.el.height = item.height;
533                 item.el.style.width = item.width + 'px';
534                 item.el.style.height = item.height + 'px';
535            });
536
537            t.blocks.each(function(index, el) {
538                var data = jQuery(el).data('cbp'),
539                    bound = el.getBoundingClientRect(),
540                    height = Math.round(bound.bottom - bound.top);
541
542                data.height = height;
543                data.heightAndGap = height + t.options.gapHorizontal;
544            });
545        },
546
547
548        getMosaicWidthReference: function() {
549            var t = this,
550                arrWidth = [];
551
552            t.blocks.each(function(index, el) {
553                var data = jQuery(el).data('cbp');
554                arrWidth.push(data.widthInitial);
555            });
556
557            arrWidth.sort(function(a, b) {
558                return a - b;
559            });
560
561            if (arrWidth[0]) {
562                t.mosaicWidthReference = arrWidth[0];
563            } else {
564                t.mosaicWidthReference = t.columnWidth;
565            }
566        },
567
568
569        getColsMosaic: function(widthInitial) {
570            var t = this;
571
572            if (widthInitial === t.width) {
573                return t.cols;
574            }
575
576            var ratio = widthInitial / t.mosaicWidthReference;
577
578            if (ratio % 1 >= 0.79) {
579                ratio = Math.ceil(ratio);
580            } else {
581                ratio = Math.floor(ratio);
582            }
583
584            return Math.min(Math.max(ratio, 1), t.cols);
585        },
586
587
588        /**
589         * Get numbers of columns when t.options.mediaQueries is not an array
590         */
591        getColumnsAuto: function() {
592            var t = this;
593
594            if (t.blocks.length === 0) {
595                return 1;
596            }
597
598            var columnWidth = t.blocks.first().data('cbp').widthInitial + t.options.gapVertical;
599
600            return Math.max(Math.round(t.width / columnWidth), 1);
601        },
602
603
604        /**
605         * Get numbers of columns if t.options.mediaQueries is an array
606         */
607        getColumnsBreakpoints: function() {
608            var t = this,
609                gridWidth = t.width,
610                columns;
611
612            jQuery.each(t.options.mediaQueries, function(index, val) {
613                if (gridWidth >= val.width) {
614                    columns = val.cols;
615                    return false;
616                }
617            });
618
619            if (columns === undefined) {
620                columns = t.options.mediaQueries[t.options.mediaQueries.length - 1].cols;
621            }
622
623            return columns;
624        },
625
626
627        /**
628         *  Defines how the columns dimension & position (width, left) will be truncated
629         *
630         *  If you use `Math.*` there could be some issues with the items on the right side
631         *  that can have some pixels hidden(1 or 2, depends on the number of columns)
632         *  but this is a known limitation.
633         *
634         *  If you don't use the built-in captions effects (overlay at hover over an item) returning
635         *  the possibly floated values may be a solution for the pixels hidden on the right side.
636         *
637         *  The column width must be an integer because browsers have some visual issues
638         *  with transform properties for caption effects.
639         *
640         *  The initial behaviour was return Math.floor
641         *
642         */
643        columnWidthTruncate: function(value) {
644            return Math.floor(value);
645        },
646
647
648        positionateItems: function() {
649            var t = this,
650                data;
651
652            t.blocksOn.removeClass('cbp-item-off')
653                .each(function(index, el) {
654                    data = jQuery(el).data('cbp');
655
656                    data.left = data.leftNew;
657                    data.top = data.topNew;
658
659                    el.style.left = data.left + 'px';
660                    el.style.top = data.top + 'px';
661                });
662
663            t.blocksOff.addClass('cbp-item-off');
664
665            // if blocks are sorted (the index ascending is broken) revert
666            // this state so the index is ascending again
667            if (t.blocksAreSorted) {
668                t.sortBlocks(t.blocks, 'index');
669            }
670        },
671
672
673        /**
674         * Resize main container vertically
675         */
676        resizeMainContainer: function() {
677            var t = this,
678                height = Math.max(t.freeSpaces.slice(-1)[0].topStart - t.options.gapHorizontal, 0),
679                maxWidth;
680
681            // set max-width to center the grid if I need to
682            if (t.options.gridAdjustment === 'alignCenter') {
683                maxWidth = 0;
684
685                t.blocksOn.each(function(index, el) {
686                    var data = jQuery(el).data('cbp'),
687                        rightEdge = data.left + data.width;
688
689                    if (rightEdge > maxWidth) {
690                        maxWidth = rightEdge;
691                    }
692                });
693
694                t.wrapper[0].style.maxWidth = maxWidth + 'px';
695            }
696
697            // set container height for `overflow: hidden` to be applied
698            if (height === t.height) {
699                t.triggerEvent('resizeMainContainer');
700                return;
701            }
702
703            t.obj.style.height = height + 'px';
704
705            // if resizeMainContainer is called for the first time skip this event trigger
706            if (t.height !== undefined) {
707                if (CubePortfolio.private.modernBrowser) {
708                    t.$obj.one(CubePortfolio.private.transitionend, function() {
709                        t.$obj.trigger('pluginResize.cbp');
710                    });
711                } else {
712                    t.$obj.trigger('pluginResize.cbp');
713                }
714            }
715
716            t.height = height;
717
718            t.triggerEvent('resizeMainContainer');
719        },
720
721
722        filterConcat: function(filter) {
723            return filter.replace(/\|/gi, '');
724        },
725
726
727        pushQueue: function(name, deferred) {
728            var t = this;
729
730            t.queue[name] = t.queue[name] || [];
731            t.queue[name].push(deferred);
732        },
733
734
735        runQueue: function(name, fn) {
736            var t = this,
737                queue = t.queue[name] || [];
738
739            jQuery.when.apply($, queue).then(jQuery.proxy(fn, t));
740        },
741
742
743        clearQueue: function(name) {
744            var t = this;
745
746            t.queue[name] = [];
747        },
748
749
750        /**
751         *  Register event
752         */
753        registerEvent: function(name, callbackFunction, oneTime) {
754            var t = this;
755
756            if (!t.registeredEvents[name]) {
757                t.registeredEvents[name] = [];
758            }
759
760            t.registeredEvents[name].push({
761                func: callbackFunction,
762                oneTime: oneTime || false
763            });
764        },
765
766
767        /**
768         *  Trigger event
769         */
770        triggerEvent: function(name, param) {
771            var t = this,
772                i, len;
773
774            if (t.registeredEvents[name]) {
775                for (i = 0, len = t.registeredEvents[name].length; i < len; i++) {
776                    t.registeredEvents[name][i].func.call(t, param);
777
778                    if (t.registeredEvents[name][i].oneTime) {
779                        t.registeredEvents[name].splice(i, 1);
780                        // function splice change the t.registeredEvents[name] array
781                        // if event is one time you must set the i to the same value
782                        // next time and set the length lower
783                        i--;
784                        len--;
785                    }
786                }
787            }
788        },
789
790
791        addItems: function(items, callback) {
792            var t = this;
793
794            // wrap .cbp-item-wrap div inside .cbp-item
795            t.wrapInner(items, 'cbp-item-wrapper');
796
797            items.addClass('cbp-item-loading').css({
798                top: '100%',
799                left: 0
800            }).appendTo(t.$ul);
801
802            if (CubePortfolio.private.modernBrowser) {
803                items.last().one(CubePortfolio.private.animationend, function() {
804                    t.addItemsFinish(items, callback);
805                });
806            } else {
807                t.addItemsFinish(items, callback); // @todo - on ie8 & ie9 callback trigger to early
808            }
809
810            t.loadImages(items, function() {
811                t.$obj.addClass('cbp-addItems');
812
813                // push to data values of items
814                t.storeData(items, t.blocks.length);
815
816                // push the new items to t.blocks
817                jQuery.merge(t.blocks, items);
818
819                t.triggerEvent('addItemsToDOM', items);
820
821                t.layoutAndAdjustment();
822
823                // if show count was actived, call show count function again
824                if (t.elems) {
825                    CubePortfolio.public.showCounter.call(t.obj, t.elems);
826                }
827            });
828        },
829
830
831        addItemsFinish: function(items, callback) {
832            var t = this;
833
834            t.isAnimating = false;
835
836            t.$obj.removeClass('cbp-addItems');
837            items.removeClass('cbp-item-loading');
838
839            if (jQuery.isFunction(callback)) {
840                callback.call(t, items);
841            }
842        }
843    });
844
845
846    /**
847     * jQuery plugin initializer
848     */
849    jQuery.fn.cubeportfolio = function(method, options, callback) {
850        return this.each(function() {
851            if (typeof method === 'object' || !method) {
852                return CubePortfolio.public.init.call(this, method, options);
853            } else if (CubePortfolio.public[method]) {
854                return CubePortfolio.public[method].call(this, options, callback);
855            }
856
857            throw new Error('Method ' + method + ' does not exist on jquery.cubeportfolio.js');
858        });
859    };
860
861    CubePortfolio.plugins = {};
862    jQuery.fn.cubeportfolio.constructor = CubePortfolio;
863})(jQuery, window, document);
864
865(function($, window, document, undefined) {
866    'use strict';
867
868    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
869
870    jQuery.extend(CubePortfolio.prototype, {
871        mosaicLayoutReset: function() {
872            var t = this;
873
874            // flag to be set after the blocks sorting is done
875            t.blocksAreSorted = false;
876
877            // when I start layout all blocks must not be positionated
878            t.blocksOn.each(function(index, el) {
879                jQuery(el).data('cbp').pack = false;
880            });
881        },
882
883
884        mosaicLayout: function() {
885            var t = this,
886                blocksLen = t.blocksOn.length,
887                i, spaceIndexAndBlock = {},
888                leftEnd;
889
890            // array of objects where I keep the spaces available in the grid
891            t.freeSpaces = [{
892                leftStart: 0,
893                leftEnd: t.widthAvailable,
894                topStart: 0,
895                topEnd: Math.pow(2, 18) // @todo - optimize
896            }];
897            
898            //TREETHEMES [ hack para saltar as contas nos helpers que sao usados para fazer os scrolling folios. ]
899            if (blocksLen > 0 && jQuery(t.obj).closest('.des_cubeportfolio_widget_helper').length > 0){
900	            return;
901            }
902
903            for (i = 0; i < blocksLen; i++) {
904                spaceIndexAndBlock = t.getSpaceIndexAndBlock();
905
906                // if space or block are null then the sorting must be done
907                if (spaceIndexAndBlock === null) {
908                    // sort blocks
909                    t.sortBlocksToPreventGaps();
910
911                    // after the sort is done start the layout again
912                    t.mosaicLayout();
913
914                    return;
915                }
916
917                t.generateF1F2(spaceIndexAndBlock.spaceIndex, spaceIndexAndBlock.dataBlock);
918
919                t.generateG1G2G3G4(spaceIndexAndBlock.dataBlock);
920
921                t.cleanFreeSpaces();
922
923                t.addHeightToBlocks();
924            }
925
926            // sort the blocks from top to bottom to add properly displayAnimation and animationType
927            if (t.blocksAreSorted) {
928                t.sortBlocks(t.blocksOn, 'topNew');
929            }
930        },
931
932
933        /**
934         * Chose from freeSpaces the best space available
935         * Find block by verifying if it can fit in bestSpace(top-left space available)
936         * If block don't fit in the first space available & t.options.sortToPreventGaps
937         * is set to true then sort the blocks and start the layout once again
938         * Decide the free rectangle Fi from F to pack the rectangle R into.
939         */
940        getSpaceIndexAndBlock: function() {
941            var t = this,
942                spaceIndexAndBlock = null;
943
944            jQuery.each(t.freeSpaces, function(index1, space) {
945                var widthSpace = space.leftEnd - space.leftStart,
946                    heightSpace = space.topEnd - space.topStart;
947
948                t.blocksOn.each(function(index2, block) {
949                    var data = jQuery(block).data('cbp');
950
951                    if (data.pack === true) {
952                        return;
953                    }
954
955                    if (data.widthAndGap <= widthSpace && data.heightAndGap <= heightSpace) {
956                        // now the rectagle can be positioned
957                        data.pack = true;
958
959                        spaceIndexAndBlock = {
960                            spaceIndex: index1,
961                            dataBlock: data
962                        };
963
964                        data.leftNew = space.leftStart;
965                        data.topNew = space.topStart;
966
967                        // if the block is founded => return from this loop
968                        return false;
969                    }
970                });
971
972                // if first space don't have a block and sortToPreventGaps is true => return from loop
973                if (!t.blocksAreSorted && t.options.sortToPreventGaps && index1 > 0) {
974                    spaceIndexAndBlock = null;
975
976                    return false;
977                }
978
979                // if space & block is founded => return from loop
980                if (spaceIndexAndBlock !== null) {
981                    return false;
982                }
983            });
984
985            return spaceIndexAndBlock;
986        },
987
988
989        /**
990         * Use the MAXRECTS split scheme to subdivide Fi(space) into F1 and F2 and
991         * then remove that space from spaces
992         * Insert F1 & F2 in F in place of Fi
993         */
994        generateF1F2: function(spaceIndex, block) {
995            var t = this,
996                space = t.freeSpaces[spaceIndex];
997
998            var F1 = {
999                leftStart: space.leftStart + block.widthAndGap,
1000                leftEnd: space.leftEnd,
1001                topStart: space.topStart,
1002                topEnd: space.topEnd
1003            };
1004
1005            var F2 = {
1006                leftStart: space.leftStart,
1007                leftEnd: space.leftEnd,
1008                topStart: space.topStart + block.heightAndGap,
1009                topEnd: space.topEnd
1010            };
1011
1012            // remove Fi from F
1013            t.freeSpaces.splice(spaceIndex, 1);
1014
1015            if (F1.leftEnd > F1.leftStart && F1.topEnd > F1.topStart) {
1016                t.freeSpaces.splice(spaceIndex, 0, F1);
1017                spaceIndex++;
1018            }
1019
1020            if (F2.leftEnd > F2.leftStart && F2.topEnd > F2.topStart) {
1021                t.freeSpaces.splice(spaceIndex, 0, F2);
1022            }
1023        },
1024
1025
1026        /**
1027         * Generate G1, G2, G3, G4 from intersaction of t.freeSpaces with block
1028         */
1029        generateG1G2G3G4: function(block) {
1030            var t = this;
1031
1032            var spaces = [];
1033
1034            jQuery.each(t.freeSpaces, function(index, space) {
1035                var intersectSpace = t.intersectSpaces(space, block);
1036
1037                // if block & space are the same push space in spaces and return
1038                if (intersectSpace === null) {
1039                    spaces.push(space);
1040                    return;
1041                }
1042
1043                t.generateG1(space, intersectSpace, spaces);
1044                t.generateG2(space, intersectSpace, spaces);
1045                t.generateG3(space, intersectSpace, spaces);
1046                t.generateG4(space, intersectSpace, spaces);
1047            });
1048
1049            t.freeSpaces = spaces;
1050        },
1051
1052
1053        /**
1054         * Return the intersected rectagle of Fi and block
1055         * If the two spaces don't intersect or are the same return null
1056         */
1057        intersectSpaces: function(space1, block) {
1058            var t = this,
1059                space2 = {
1060                    leftStart: block.leftNew,
1061                    leftEnd: block.leftNew + block.widthAndGap,
1062                    topStart: block.topNew,
1063                    topEnd: block.topNew + block.heightAndGap,
1064                };
1065
1066            if (space1.leftStart === space2.leftStart &&
1067                space1.leftEnd === space2.leftEnd &&
1068                space1.topStart === space2.topStart &&
1069                space1.topEnd === space2.topEnd) {
1070                return null;
1071            }
1072
1073            var leftStart = Math.max(space1.leftStart, space2.leftStart),
1074                leftEnd = Math.min(space1.leftEnd, space2.leftEnd),
1075                topStart = Math.max(space1.topStart, space2.topStart),
1076                topEnd = Math.min(space1.topEnd, space2.topEnd);
1077
1078            if (leftEnd <= leftStart || topEnd <= topStart) {
1079                return null;
1080            }
1081
1082            return {
1083                leftStart: leftStart,
1084                leftEnd: leftEnd,
1085                topStart: topStart,
1086                topEnd: topEnd
1087            };
1088        },
1089
1090
1091        /**
1092         * The top subdivide space
1093         */
1094        generateG1: function(space, intersectSpace, spaces) {
1095            if (space.topStart === intersectSpace.topStart) {
1096                return;
1097            }
1098
1099            spaces.push({
1100                leftStart: space.leftStart,
1101                leftEnd: space.leftEnd,
1102                topStart: space.topStart,
1103                topEnd: intersectSpace.topStart
1104            });
1105        },
1106
1107
1108        /**
1109         * The right subdivide space
1110         */
1111        generateG2: function(space, intersectSpace, spaces) {
1112            if (space.leftEnd === intersectSpace.leftEnd) {
1113                return;
1114            }
1115
1116            spaces.push({
1117                leftStart: intersectSpace.leftEnd,
1118                leftEnd: space.leftEnd,
1119                topStart: space.topStart,
1120                topEnd: space.topEnd
1121            });
1122        },
1123
1124
1125        /**
1126         * The bottom subdivide space
1127         */
1128        generateG3: function(space, intersectSpace, spaces) {
1129            if (space.topEnd === intersectSpace.topEnd) {
1130                return;
1131            }
1132
1133            spaces.push({
1134                leftStart: space.leftStart,
1135                leftEnd: space.leftEnd,
1136                topStart: intersectSpace.topEnd,
1137                topEnd: space.topEnd
1138            });
1139        },
1140
1141
1142        /**
1143         * The left subdivide space
1144         */
1145        generateG4: function(space, intersectSpace, spaces) {
1146            if (space.leftStart === intersectSpace.leftStart) {
1147                return;
1148            }
1149
1150            spaces.push({
1151                leftStart: space.leftStart,
1152                leftEnd: intersectSpace.leftStart,
1153                topStart: space.topStart,
1154                topEnd: space.topEnd
1155            });
1156        },
1157
1158
1159        /**
1160         * For every Fi check if is another Fj so Fj contains Fi
1161         * @todo - refactor
1162         */
1163        cleanFreeSpaces: function() {
1164            var t = this;
1165
1166            // sort space from top to bottom and left to right
1167            t.freeSpaces.sort(function(space1, space2) {
1168                if (space1.topStart > space2.topStart) {
1169                    return 1;
1170                } else if (space1.topStart < space2.topStart) {
1171                    return -1;
1172                } else {
1173                    if (space1.leftStart > space2.leftStart) {
1174                        return 1;
1175                    } else if (space1.leftStart < space2.leftStart) {
1176                        return -1;
1177                    } else {
1178                        return 0;
1179                    }
1180                }
1181            });
1182
1183            t.correctSubPixelValues();
1184
1185            t.removeNonMaximalFreeSpaces();
1186        },
1187
1188
1189        /**
1190         * If topStart values for spaces are <= 1px then align those spaces
1191         */
1192        correctSubPixelValues: function() {
1193            var t = this,
1194                i, len, diff, space1, space2;
1195
1196            for (i = 0, len = t.freeSpaces.length - 1; i < len; i++) {
1197                space1 = t.freeSpaces[i];
1198                space2 = t.freeSpaces[i + 1];
1199
1200                if ((space2.topStart - space1.topStart) <= 1) {
1201                    space2.topStart = space1.topStart;
1202                }
1203            }
1204        },
1205
1206
1207        /**
1208         * Remove spaces that are not maximal
1209         * If Fi contains Fj then remove Fj from F
1210         */
1211        removeNonMaximalFreeSpaces: function() {
1212            var t = this;
1213
1214            t.uniqueFreeSpaces();
1215
1216            t.freeSpaces = jQuery.map(t.freeSpaces, function(space1, index1) {
1217                jQuery.each(t.freeSpaces, function(index2, space2) {
1218                    // don't compare the same free spaces
1219                    if (index1 === index2) {
1220                        return;
1221                    }
1222
1223                    if (space2.leftStart <= space1.leftStart &&
1224                        space2.leftEnd >= space1.leftEnd &&
1225                        space2.topStart <= space1.topStart &&
1226                        space2.topEnd >= space1.topEnd) {
1227
1228                        space1 = null;
1229                        return false;
1230                    }
1231                });
1232
1233                return space1;
1234            });
1235        },
1236
1237
1238        /**
1239         * Remove duplicates spaces from freeSpaces
1240         */
1241        uniqueFreeSpaces: function() {
1242            var t = this,
1243                result = [];
1244
1245            jQuery.each(t.freeSpaces, function(index1, space1) {
1246                jQuery.each(result, function(index2, space2) {
1247                    if (space2.leftStart === space1.leftStart &&
1248                        space2.leftEnd === space1.leftEnd &&
1249                        space2.topStart === space1.topStart &&
1250                        space2.topEnd === space1.topEnd) {
1251
1252                        space1 = null;
1253                        return false;
1254                    }
1255                });
1256
1257                if (space1 !== null) {
1258                    result.push(space1);
1259                }
1260            });
1261
1262            t.freeSpaces = result;
1263        },
1264
1265
1266        /**
1267         * If freeSpaces have only one space and that space overlap the
1268         * height of the bottom blocks with 1px cut those blocks
1269         */
1270        addHeightToBlocks: function() {
1271            var t = this;
1272
1273            if (t.freeSpaces.length > 1) {
1274                return;
1275            }
1276
1277            var topStart = typeof t.freeSpaces[0] != "undefined" ? t.freeSpaces[0].topStart : 0;
1278
1279            t.blocksOn.each(function(index, block) {
1280                var data = jQuery(block).data('cbp');
1281
1282                if (data.pack !== true) {
1283                    return;
1284                }
1285
1286                var diff = topStart - data.topNew - data.heightAndGap;
1287
1288                if (diff < 0) {
1289                    block.style.height = (data.height + diff) + 'px';
1290                }
1291            });
1292        },
1293
1294
1295        /**
1296         * Sort by the longer width first, followed by a comparison of the shorter height
1297         */
1298        sortBlocksToPreventGaps: function() {
1299            var t = this;
1300
1301            t.blocksAreSorted = true;
1302
1303            // sort based on timestamp attribute
1304            t.blocksOn.sort(function(block1, block2) {
1305                var data1 = jQuery(block1).data('cbp'),
1306                    data2 = jQuery(block2).data('cbp');
1307
1308                // order desc by width
1309                if (data1.widthAndGap < data2.widthAndGap) {
1310                    return 1;
1311                } else if (data1.widthAndGap > data2.widthAndGap) {
1312                    return -1;
1313                } else {
1314                    // order desc by height
1315                    if (data1.heightAndGap < data2.heightAndGap) {
1316                        return 1;
1317                    } else if (data1.heightAndGap > data2.heightAndGap) {
1318                        return -1;
1319                    } else {
1320                        // order asc by index
1321                        if (data1.index > data2.index) {
1322                            return 1;
1323                        } else if (data1.index < data2.index) {
1324                            return -1;
1325                        }
1326                    }
1327                }
1328            });
1329
1330            // when I start the layout again all blocks must not be positionated
1331            // reset height if it was set for addHeightToBlocks
1332            t.blocksOn.each(function(index, el) {
1333                jQuery(el).data('cbp').pack = false;
1334                el.style.height = '';
1335            });
1336        },
1337
1338
1339        /**
1340         * Generic sort block function from lower to highest values
1341         */
1342        sortBlocks: function(blocks, compare) {
1343            var t = this;
1344
1345            blocks.sort(function(block1, block2) {
1346                var data1 = jQuery(block1).data('cbp'),
1347                    data2 = jQuery(block2).data('cbp');
1348
1349                // if the items are equally order them from left to right
1350                if (data1[compare] > data2[compare]) {
1351                    return 1;
1352                } else if (data1[compare] < data2[compare]) {
1353                    return -1;
1354                } else {
1355                    if (data1.leftNew > data2.leftNew) {
1356                        return 1;
1357                    } else if (data1.leftNew < data2.leftNew) {
1358                        return -1;
1359                    } else {
1360                        return 0;
1361                    }
1362                }
1363            });
1364        }
1365    });
1366})(jQuery, window, document);
1367
1368// Plugin default options
1369jQuery.fn.cubeportfolio.options = {
1370    /**
1371     *  Define the wrapper for filters
1372     *  Values: strings that represent the elements in the document (DOM selector).
1373     */
1374    filters: '',
1375
1376    /**
1377     *  Define the wrapper for loadMore
1378     *  Values: strings that represent the elements in the document (DOM selector).
1379     */
1380    loadMore: '',
1381
1382    /**
1383     *  How the loadMore functionality should behave. Load on click on the button or
1384     *  automatically when you scroll the page
1385     *  Values: - click
1386     *          - auto
1387     */
1388    loadMoreAction: 'click',
1389
1390    /**
1391     *  Define the search input element
1392     *  Values: strings that represent the element in the document (DOM selector).
1393     */
1394    search: '',
1395
1396    /**
1397     *  Layout Mode for this instance
1398     *  Values: 'grid', 'mosaic' or 'slider'
1399     */
1400    layoutMode: 'grid',
1401
1402    /**
1403     *  Sort the items (bigger to smallest) if there are gaps in grid
1404     *  Option available only for `layoutMode: 'mosaic'`
1405     *  Values: true or false
1406     */
1407    sortToPreventGaps: false,
1408
1409    /**
1410     *  Mouse and touch drag support
1411     *  Option available only for `layoutMode: 'slider'`
1412     *  Values: true or false
1413     */
1414    drag: true,
1415
1416    /**
1417     *  Autoplay the slider
1418     *  Option available only for `layoutMode: 'slider'`
1419     *  Values: true or false
1420     */
1421    auto: false,
1422
1423    /**
1424     *  Autoplay interval timeout. Time is set in milisecconds
1425     *  1000 milliseconds equals 1 second.
1426     *  Option available only for `layoutMode: 'slider'`
1427     *  Values: only integers (ex: 1000, 2000, 5000)
1428     */
1429    autoTimeout: 5000,
1430
1431    /**
1432     *  Stops autoplay when user hover the slider
1433     *  Option available only for `layoutMode: 'slider'`
1434     *  Values: true or false
1435     */
1436    autoPauseOnHover: true,
1437
1438    /**
1439     *  Show `next` and `prev` buttons for slider
1440     *  Option available only for `layoutMode: 'slider'`
1441     *  Values: true or false
1442     */
1443    showNavigation: true,
1444
1445    /**
1446     *  Show pagination for slider
1447     *  Option available only for `layoutMode: 'slider'`
1448     *  Values: true or false
1449     */
1450    showPagination: true,
1451
1452    /**
1453     *  Enable slide to first item (last item)
1454     *  Option available only for `layoutMode: 'slider'`
1455     *  Values: true or false
1456     */
1457    rewindNav: true,
1458
1459    /**
1460     *  Scroll by page and not by item. This option affect next/prev buttons and drag support
1461     *  Option available only for `layoutMode: 'slider'`
1462     *  Values: true or false
1463     */
1464    scrollByPage: false,
1465
1466    /**
1467     *  Default filter for plugin
1468     *  Option available only for `layoutMode: 'grid'`
1469     *  Values: strings that represent the filter name(ex: *, .logo, .web-design, .design)
1470     */
1471    defaultFilter: '*',
1472
1473    /**
1474     *  Enable / disable the deeplinking feature when you click on filters
1475     *  Option available only for `layoutMode: 'grid'`
1476     *  Values: true or false
1477     */
1478    filterDeeplinking: false,
1479
1480    /**
1481     *  Defines which animation to use for items that will be shown or hidden after a filter has been activated.
1482     *  Option available only for `layoutMode: 'grid'`
1483     *  The plugin use the best browser features available (css3 transitions and transform, GPU acceleration).
1484     *  Values: - fadeOut
1485     *          - quicksand
1486     *          - bounceLeft
1487     *          - bounceTop
1488     *          - bounceBottom
1489     *          - moveLeft
1490     *          - slideLeft
1491     *          - fadeOutTop
1492     *          - sequentially
1493     *          - skew
1494     *          - slideDelay
1495     *          - rotateSides
1496     *          - flipOutDelay
1497     *          - flipOut
1498     *          - unfold
1499     *          - foldLeft
1500     *          - scaleDown
1501     *          - scaleSides
1502     *          - frontRow
1503     *          - flipBottom
1504     *          - rotateRoom
1505     */
1506    animationType: 'fadeOut',
1507
1508    /**
1509     *  Adjust the layout grid
1510     *  Values: - default (no adjustment applied)
1511     *          - alignCenter (align the grid on center of the page)
1512     *          - responsive (use a fluid algorithm to resize the grid)
1513     */
1514    gridAdjustment: 'responsive',
1515
1516    /**
1517     * Define `media queries` for columns layout.
1518     * Format: [{width: a, cols: d}, {width: b, cols: e}, {width: c, cols: f}],
1519     * where a, b, c are the grid width and d, e, f are the columns displayed.
1520     * e.g. [{width: 1100, cols: 4}, {width: 800, cols: 3}, {width: 480, cols: 2}] means
1521     * if (gridWidth >= 1100) => show 4 columns,
1522     * if (gridWidth >= 800 && gridWidth < 1100) => show 3 columns,
1523     * if (gridWidth >= 480 && gridWidth < 800) => show 2 columns,
1524     * if (gridWidth < 480) => show 2 columns
1525     * Keep in mind that a > b > c
1526     * This option is available only when `gridAdjustment: 'responsive'`
1527     * Values:  - array of objects of format: [{width: a, cols: d}, {width: b, cols: e}]
1528     *          - you can define as many objects as you want
1529     *          - if this option is `false` Cube Portfolio will adjust the items
1530     *            width automatically (default option for backward compatibility)
1531     */
1532    mediaQueries: false,
1533
1534    /**
1535     *  Horizontal gap between items
1536     *  Values: only integers (ex: 1, 5, 10)
1537     */
1538    gapHorizontal: 10,
1539
1540    /**
1541     *  Vertical gap between items
1542     *  Values: only integers (ex: 1, 5, 10)
1543     */
1544    gapVertical: 10,
1545
1546    /**
1547     *  Caption - the overlay that is shown when you put the mouse over an item
1548     *  NOTE: If you don't want to have captions set this option to an empty string ( caption: '')
1549     *  Values: - pushTop
1550     *          - pushDown
1551     *          - revealBottom
1552     *          - revealTop
1553     *          - revealLeft
1554     *          - moveRight
1555     *          - overlayBottom
1556     *          - overlayBottomPush
1557     *          - overlayBottomReveal
1558     *          - overlayBottomAlong
1559     *          - overlayRightAlong
1560     *          - minimal
1561     *          - fadeIn
1562     *          - zoom
1563     *          - opacity
1564     *          - ''
1565     */
1566    caption: 'pushTop',
1567
1568    /**
1569     *  The plugin will display his content based on the following values.
1570     *  Values: - default (the content will be displayed without any animation)
1571     *          - fadeIn (the plugin will fully preload the images before displaying the items with a fadeIn effect)
1572     *          - fadeInToTop (the plugin will fully preload the images before displaying the items with a fadeIn effect from bottom to top)
1573     *          - sequentially (the plugin will fully preload the images before displaying the items with a sequentially effect)
1574     *          - bottomToTop (the plugin will fully preload the images before displaying the items with an animation from bottom to top)
1575     */
1576    displayType: 'fadeIn',
1577
1578    /**
1579     *  Defines the speed of displaying the items (when `displayType == default` this option will have no effect)
1580     *  Values: only integers, values in ms (ex: 200, 300, 500)
1581     */
1582    displayTypeSpeed: 400,
1583
1584    /**
1585     *  This is used to define any clickable elements you wish to use to trigger lightbox popup on click.
1586     *  Values: strings that represent the elements in the document (DOM selector)
1587     */
1588    lightboxDelegate: '.cbp-lightbox',
1589
1590    /**
1591     *  Enable / disable gallery mode
1592     *  Values: true or false
1593     */
1594    lightboxGallery: true,
1595
1596    /**
1597     *  Attribute of the delegate item that contains caption for lightbox
1598     *  Values: html atributte
1599     */
1600    lightboxTitleSrc: 'data-title',
1601
1602    /**
1603     *  Markup of the lightbox counter
1604     *  Values: html markup
1605     */
1606    lightboxCounter: '<div class="cbp-popup-lightbox-counter">{{current}} of {{total}}</div>',
1607
1608    /**
1609     *  This is used to define any clickable elements you wish to use to trigger singlePage popup on click.
1610     *  Values: strings that represent the elements in the document (DOM selector)
1611     */
1612    singlePageDelegate: '.cbp-singlePage',
1613
1614    /**
1615     *  Enable / disable the deeplinking feature for singlePage popup
1616     *  Values: true or false
1617     */
1618    singlePageDeeplinking: true,
1619
1620    /**
1621     *  Enable / disable the sticky navigation for singlePage popup
1622     *  Values: true or false
1623     */
1624    singlePageStickyNavigation: true,
1625
1626    /**
1627     *  Markup of the singlePage counter
1628     *  Values: html markup
1629     */
1630    singlePageCounter: '<div class="cbp-popup-singlePage-counter">{{current}} of {{total}}</div>',
1631
1632    /**
1633     *  Defines which animation to use when singlePage appear
1634     *  Values: - left
1635     *          - fade
1636     *          - right
1637     */
1638    singlePageAnimation: 'middle',
1639
1640    /**
1641     *  Use this callback to update singlePage content.
1642     *  The callback will trigger after the singlePage popup will open.
1643     *  @param url = the href attribute of the item clicked
1644     *  @param element = the item clicked
1645     *  Values: function
1646     */
1647    singlePageCallback: function(url, element) {
1648        // to update singlePage content use the following method: this.updateSinglePage(yourContent)
1649    },
1650
1651    /**
1652     *  This is used to define any clickable elements you wish to use to trigger singlePage Inline on click.
1653     *  Values: strings that represent the elements in the document (DOM selector)
1654     */
1655    singlePageInlineDelegate: '.cbp-singlePageInline',
1656
1657    /**
1658     *  Enable / disable the deeplinking feature for singlePageInline
1659     *  Values: true or false
1660     */
1661    singlePageInlineDeeplinking: false,
1662
1663    /**
1664     *  This is used to define the position of singlePage Inline block
1665     *  Values: - above ( above current element )
1666     *          - below ( below current elemnet)
1667     *          - top ( positon top )
1668     *          - bottom ( positon bottom )
1669     */
1670    singlePageInlinePosition: 'top',
1671
1672    /**
1673     *  Push the open panel in focus and at close go back to the former stage
1674     *  Values: true or false
1675     */
1676    singlePageInlineInFocus: true,
1677
1678    /**
1679     *  Use this callback to update singlePage Inline content.
1680     *  The callback will trigger after the singlePage Inline will open.
1681     *  @param url = the href attribute of the item clicked
1682     *  @param element = the item clicked
1683     *  Values: function
1684     */
1685    singlePageInlineCallback: function(url, element) {
1686        // to update singlePage Inline content use the following method: this.updateSinglePageInline(yourContent)
1687    },
1688
1689    /**
1690     *  Used by the plugins registered to set local options for the current instance
1691     *  Values: object
1692     */
1693    plugins: {},
1694    
1695    /* TREETHEMES added */
1696	cols : 3
1697};
1698
1699(function($, window, document, undefined) {
1700    'use strict';
1701
1702    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
1703
1704    CubePortfolio.private = {
1705        // array or objects: {instance: instance, fn: fn}
1706        resizeEventArray: [],
1707
1708        initResizeEvent: function(obj) {
1709            var t = CubePortfolio.private;
1710
1711            if (t.resizeEventArray.length === 0) {
1712                t.resizeEvent();
1713            }
1714
1715            t.resizeEventArray.push(obj);
1716        },
1717
1718        destroyResizeEvent: function(instance) {
1719            var t = CubePortfolio.private;
1720
1721            var newResizeEvent = jQuery.map(t.resizeEventArray, function(val, index) {
1722                if (val.instance !== instance) {
1723                    return val;
1724                }
1725            });
1726
1727            t.resizeEventArray = newResizeEvent;
1728
1729            if (t.resizeEventArray.length === 0) {
1730                // remove off resize event
1731                jQuery(window).off('resize.cbp');
1732            }
1733        },
1734
1735        resizeEvent: function() {
1736            var t = CubePortfolio.private,
1737                timeout;
1738
1739            // resize
1740            jQuery(window).on('resize.cbp', function() {
1741                clearTimeout(timeout);
1742
1743                timeout = setTimeout(function() {
1744                    if (window.innerHeight == screen.height) {
1745                        // this is fulll screen mode. don't need to trigger a resize
1746                        return;
1747                    }
1748
1749                    jQuery.each(t.resizeEventArray, function(index, val) {
1750                        val.fn.call(val.instance);
1751                    });
1752                }, 50);
1753            });
1754        },
1755
1756        /**
1757         * Check if cubeportfolio instance exists on current element
1758         */
1759        checkInstance: function(method) {
1760            var t = jQuery.data(this, 'cubeportfolio');
1761
1762            if (!t) {
1763                throw new Error('cubeportfolio is not initialized. Initialize it before calling ' + method + ' method!');
1764            }
1765
1766            t.triggerEvent('publicMethod');
1767
1768            return t;
1769        },
1770
1771        /**
1772         * Get info about client browser
1773         */
1774        browserInfo: function() {
1775            var t = CubePortfolio.private,
1776                appVersion = navigator.appVersion,
1777                transition, animation, perspective;
1778
1779            if (appVersion.indexOf('MSIE 8.') !== -1) { // ie8
1780                t.browser = 'ie8';
1781            } else if (appVersion.indexOf('MSIE 9.') !== -1) { // ie9
1782                t.browser = 'ie9';
1783            } else if (appVersion.indexOf('MSIE 10.') !== -1) { // ie10
1784                t.browser = 'ie10';
1785            } else if (window.ActiveXObject || 'ActiveXObject' in window) { // ie11
1786                t.browser = 'ie11';
1787            } else if ((/android/gi).test(appVersion)) { // android
1788                t.browser = 'android';
1789            } else if ((/iphone|ipad|ipod/gi).test(appVersion)) { // ios
1790                t.browser = 'ios';
1791            } else if ((/chrome/gi).test(appVersion)) {
1792                t.browser = 'chrome';
1793            } else {
1794                t.browser = '';
1795            }
1796
1797            // check if perspective is available
1798            perspective = t.styleSupport('perspective');
1799
1800            // if perspective is not available => no modern browser
1801            if (typeof perspective === undefined) {
1802                return;
1803            }
1804
1805            transition = t.styleSupport('transition');
1806
1807            t.transitionend = {
1808                WebkitTransition: 'webkitTransitionEnd',
1809                transition: 'transitionend'
1810            }[transition];
1811
1812            animation = t.styleSupport('animation');
1813
1814            t.animationend = {
1815                WebkitAnimation: 'webkitAnimationEnd',
1816                animation: 'animationend'
1817            }[animation];
1818
1819            t.animationDuration = {
1820                WebkitAnimation: 'webkitAnimationDuration',
1821                animation: 'animationDuration'
1822            }[animation];
1823
1824            t.animationDelay = {
1825                WebkitAnimation: 'webkitAnimationDelay',
1826                animation: 'animationDelay'
1827            }[animation];
1828
1829            t.transform = t.styleSupport('transform');
1830
1831            if (transition && animation && t.transform) {
1832                t.modernBrowser = true;
1833            }
1834
1835        },
1836
1837
1838        /**
1839         * Feature testing for css3
1840         */
1841        styleSupport: function(prop) {
1842            var supportedProp,
1843                // capitalize first character of the prop to test vendor prefix
1844                webkitProp = 'Webkit' + prop.charAt(0).toUpperCase() + prop.slice(1),
1845                div = document.createElement('div');
1846
1847            // browser supports standard CSS property name
1848            if (prop in div.style) {
1849                supportedProp = prop;
1850            } else if (webkitProp in div.style) {
1851                supportedProp = webkitProp;
1852            }
1853
1854            // avoid memory leak in IE
1855            div = null;
1856
1857            return supportedProp;
1858        },
1859
1860    };
1861
1862    CubePortfolio.private.browserInfo();
1863
1864})(jQuery, window, document);
1865
1866(function($, window, document, undefined) {
1867    'use strict';
1868
1869    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
1870
1871    CubePortfolio.public = {
1872
1873        /*
1874         * Init the plugin
1875         */
1876        init: function(options, callback) {
1877            new CubePortfolio(this, options, callback);
1878        },
1879
1880        /*
1881         * Destroy the plugin
1882         */
1883        destroy: function(callback) {
1884            var t = CubePortfolio.private.checkInstance.call(this, 'destroy');
1885
1886            t.triggerEvent('beforeDestroy');
1887
1888            // remove data
1889            jQuery.removeData(this, 'cubeportfolio');
1890
1891            // remove data from blocks
1892            t.blocks.removeData('cbp');
1893
1894            // remove loading class and .cbp on container
1895            t.$obj.removeClass('cbp-ready').removeAttr('style');
1896
1897            // remove class from ul
1898            t.$ul.removeClass('cbp-wrapper');
1899
1900            // remove resize event
1901            CubePortfolio.private.destroyResizeEvent(t);
1902
1903            t.$obj.off('.cbp');
1904
1905            // reset blocks
1906            t.blocks.removeClass('cbp-item-off').removeAttr('style');
1907
1908            t.blocks.find('.cbp-item-wrapper').children().unwrap();
1909
1910            if (t.options.caption) {
1911                t.$obj.removeClass('cbp-caption-active cbp-caption-' + t.options.caption);
1912            }
1913
1914            t.destroySlider();
1915
1916            // remove .cbp-wrapper-outer
1917            t.$ul.unwrap();
1918
1919            // remove .cbp-wrapper
1920            if (t.addedWrapp) {
1921                t.blocks.unwrap();
1922            }
1923
1924            jQuery.each(t.plugins, function(i, item) {
1925                if (typeof item.destroy === 'function') {
1926                    item.destroy();
1927                }
1928            });
1929
1930            if (jQuery.isFunction(callback)) {
1931                callback.call(t);
1932            }
1933
1934            t.triggerEvent('afterDestroy');
1935        },
1936
1937        /*
1938         * Filter the plugin by filterName
1939         */
1940        filter: function(param, callback) {
1941            var t = CubePortfolio.private.checkInstance.call(this, 'filter'),
1942                expression;
1943
1944            if (t.isAnimating) {
1945                return;
1946            }
1947
1948            t.isAnimating = true;
1949
1950            // register callback function
1951            if (jQuery.isFunction(callback)) {
1952                t.registerEvent('filterFinish', callback, true);
1953            }
1954
1955            if (jQuery.isFunction(param)) {
1956                expression = param.call(t, t.blocks);
1957
1958                if(expression === undefined) {
1959                    throw new Error('When you call cubeportfolio API `filter` method with a param of type function you must return the blocks that will be visible.');
1960                }
1961            } else {
1962                if (t.options.filterDeeplinking) {
1963                    var url = location.href.replace(/#cbpf=(.*?)([#\?&]|$)/gi, '');
1964                    location.href = url + '#cbpf=' + encodeURIComponent(param);
1965
1966                    if (t.singlePage && t.singlePage.url) {
1967                        t.singlePage.url = location.href;
1968                    }
1969                }
1970
1971                t.defaultFilter = param;
1972                expression = t.filterConcat(t.defaultFilter);
1973            }
1974
1975            if (t.singlePageInline && t.singlePageInline.isOpen) {
1976                t.singlePageInline.close('promise', {
1977                    callback: function() {
1978                        t.computeFilter(expression);
1979                    }
1980                });
1981            } else {
1982                t.computeFilter(expression);
1983            }
1984        },
1985
1986        /*
1987         * Show counter for filters
1988         */
1989        showCounter: function(elems, callback) {
1990            var t = CubePortfolio.private.checkInstance.call(this, 'showCounter');
1991
1992            t.elems = elems;
1993
1994            jQuery.each(elems, function() {
1995                var el = jQuery(this),
1996                    filterName = el.data('filter'),
1997                    count;
1998
1999                count = t.blocks.filter(filterName).length;
2000                el.find('.cbp-filter-counter').text(count);
2001            });
2002
2003            if (jQuery.isFunction(callback)) {
2004                callback.call(t);
2005            }
2006        },
2007
2008        /*
2009         * ApendItems elements
2010         */
2011        appendItems: function(els, callback) {
2012            var t = CubePortfolio.private.checkInstance.call(this, 'appendItems'),
2013                items = jQuery(els).filter('.cbp-item');
2014
2015            if (t.isAnimating || items.length < 1) {
2016                if (jQuery.isFunction(callback)) {
2017                    callback.call(t, items);
2018                }
2019
2020                return;
2021            }
2022
2023            t.isAnimating = true;
2024
2025            if (t.singlePageInline && t.singlePageInline.isOpen) {
2026                t.singlePageInline.close('promise', {
2027                    callback: function() {
2028                        t.addItems(items, callback);
2029                    }
2030                });
2031            } else {
2032                t.addItems(items, callback);
2033            }
2034        },
2035
2036    };
2037
2038})(jQuery, window, document);
2039
2040(function($, window, document, undefined) {
2041    'use strict';
2042
2043    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
2044
2045    // @todo - gandit cum ar trebui sa fac aici ca nu prea ar merge un plugin
2046    // pt slider ca as extinde pe CubePortfolio.prototype la fiecare initializare
2047    jQuery.extend(CubePortfolio.prototype, {
2048        updateSliderPagination: function() {
2049            var t = this,
2050                pages,
2051                i;
2052
2053            if (t.options.showPagination) {
2054                // get number of pages
2055                pages = Math.ceil(t.blocksOn.length / t.cols);
2056                t.navPagination.empty();
2057
2058                for (i = pages - 1; i >= 0; i--) {
2059                    jQuery('<div/>', {
2060                        'class': 'cbp-nav-pagination-item',
2061                        'data-slider-action': 'jumpTo'
2062                    }).appendTo(t.navPagination);
2063                }
2064
2065                t.navPaginationItems = t.navPagination.children();
2066            }
2067
2068            // enable disable the nav
2069            t.enableDisableNavSlider();
2070        },
2071
2072        destroySlider: function() {
2073            var t = this;
2074
2075            if (t.options.layoutMode !== 'slider') {
2076                return;
2077            }
2078
2079            t.$obj.off('.cbp');
2080
2081            t.$obj.removeClass('cbp-mode-slider');
2082
2083            if (t.options.showNavigation) {
2084                t.nav.off('.cbp');
2085                t.nav.remove();
2086            }
2087
2088            if (t.navPagination) {
2089                t.navPagination.remove();
2090            }
2091
2092            t.$ul.removeAttr('style');
2093
2094            t.$ul.off('.cbp');
2095
2096            jQuery(document).off('.cbp'); // @todo - don't interfer with the lightbox
2097
2098            if (t.options.auto) {
2099                t.stopSliderAuto();
2100            }
2101        },
2102
2103        nextSlider: function(el) {
2104            var t = this;
2105
2106            if (t.isEndSlider()) {
2107                if (t.isRewindNav()) {
2108                    t.sliderActive = 0;
2109                } else {
2110                    return;
2111                }
2112            } else {
2113                if (t.options.scrollByPage) {
2114                    t.sliderActive = Math.min(t.sliderActive + t.cols, t.blocksOn.length - t.cols);
2115                } else {
2116                    t.sliderActive += 1;
2117                }
2118            }
2119
2120            t.goToSlider();
2121        },
2122
2123        prevSlider: function(el) {
2124            var t = this;
2125
2126            if (t.isStartSlider()) {
2127                if (t.isRewindNav()) {
2128                    t.sliderActive = t.blocksOn.length - t.cols;
2129                } else {
2130                    return;
2131                }
2132            } else {
2133                if (t.options.scrollByPage) {
2134                    t.sliderActive = Math.max(0, t.sliderActive - t.cols);
2135                } else {
2136                    t.sliderActive -= 1;
2137                }
2138            }
2139
2140            t.goToSlider();
2141        },
2142
2143        jumpToSlider: function(el) {
2144            var t = this,
2145                index = Math.min(el.index() * t.cols, t.blocksOn.length - t.cols);
2146
2147            if (index === t.sliderActive) {
2148                return;
2149            }
2150
2151            t.sliderActive = index;
2152
2153            t.goToSlider();
2154        },
2155
2156        jumpDragToSlider: function(pos) {
2157            var t = this,
2158                jumpWidth,
2159                offset,
2160                condition,
2161                index,
2162                dragLeft = (pos > 0) ? true : false;
2163
2164            if (t.options.scrollByPage) {
2165                jumpWidth = t.cols * t.columnWidth;
2166                offset = t.cols;
2167            } else {
2168                jumpWidth = t.columnWidth;
2169                offset = 1;
2170            }
2171
2172            pos = Math.abs(pos);
2173            index = Math.floor(pos / jumpWidth) * offset;
2174
2175            if (pos % jumpWidth > 20) {
2176                index += offset;
2177            }
2178
2179            if (dragLeft) { // drag to left
2180                t.sliderActive = Math.min(t.sliderActive + index, t.blocksOn.length - t.cols);
2181            } else { // drag to right
2182                t.sliderActive = Math.max(0, t.sliderActive - index);
2183            }
2184
2185            t.goToSlider();
2186        },
2187
2188        isStartSlider: function() {
2189            return this.sliderActive === 0;
2190        },
2191
2192        isEndSlider: function() {
2193            var t = this;
2194            return (t.sliderActive + t.cols) > t.blocksOn.length - 1;
2195        },
2196
2197        goToSlider: function() {
2198            var t = this;
2199
2200            // enable disable the nav
2201            t.enableDisableNavSlider();
2202
2203            t.updateSliderPosition();
2204        },
2205
2206        startSliderAuto: function() {
2207            var t = this;
2208
2209            if (t.isDrag) {
2210                t.stopSliderAuto();
2211                return;
2212            }
2213
2214            t.timeout = setTimeout(function() {
2215                // go to next slide
2216                t.nextSlider();
2217
2218                // start auto
2219                t.startSliderAuto();
2220
2221            }, t.options.autoTimeout);
2222        },
2223
2224        stopSliderAuto: function() {
2225            clearTimeout(this.timeout);
2226        },
2227
2228        enableDisableNavSlider: function() {
2229            var t = this,
2230                page,
2231                method;
2232
2233            if (!t.isRewindNav()) {
2234                method = (t.isStartSlider()) ? 'addClass' : 'removeClass';
2235                t.navPrev[method]('cbp-nav-stop');
2236
2237                method = (t.isEndSlider()) ? 'addClass' : 'removeClass';
2238                t.navNext[method]('cbp-nav-stop');
2239            }
2240
2241            if (t.options.showPagination) {
2242                if (t.options.scrollByPage) {
2243                    page = Math.ceil(t.sliderActive / t.cols);
2244                } else {
2245                    if (t.isEndSlider()) {
2246                        page = t.navPaginationItems.length - 1;
2247                    } else {
2248                        page = Math.floor(t.sliderActive / t.cols);
2249                    }
2250                }
2251
2252                // add class active on pagination's items
2253                t.navPaginationItems.removeClass('cbp-nav-pagination-active')
2254                    .eq(page)
2255                    .addClass('cbp-nav-pagination-active');
2256            }
2257
2258            if (t.customPagination) {
2259                if (t.options.scrollByPage) {
2260                    page = Math.ceil(t.sliderActive / t.cols);
2261                } else {
2262                    if (t.isEndSlider()) {
2263                        page = t.customPaginationItems.length - 1;
2264                    } else {
2265                        page = Math.floor(t.sliderActive / t.cols);
2266                    }
2267                }
2268
2269                // add class active on pagination's items
2270                t.customPaginationItems.removeClass(t.customPaginationClass)
2271                    .eq(page)
2272                    .addClass(t.customPaginationClass);
2273            }
2274        },
2275
2276        /**
2277         * If slider loop is enabled don't add classes to `next` and `prev` buttons
2278         */
2279        isRewindNav: function() {
2280            var t = this;
2281
2282            if (!t.options.showNavigation) {
2283                return true;
2284            }
2285
2286            if (t.blocksOn.length <= t.cols) {
2287                return false;
2288            }
2289
2290            if (t.options.rewindNav) {
2291                return true;
2292            }
2293
2294            return false;
2295        },
2296
2297        sliderItemsLength: function() {
2298            return this.blocksOn.length <= this.cols;
2299        },
2300
2301        /**
2302         * Arrange the items in a slider layout
2303         */
2304        sliderLayout: function() {
2305            var t = this;
2306
2307            t.blocksOn.each(function(index, el) {
2308                var data = jQuery(el).data('cbp');
2309
2310                // update the values with the new ones
2311                data.leftNew = t.columnWidth * index;
2312                data.topNew = 0;
2313
2314                t.sliderFreeSpaces.push({
2315                    topStart: data.heightAndGap
2316                });
2317            });
2318
2319            t.getFreeSpacesForSlider();
2320
2321            t.$ul.width(t.columnWidth * t.blocksOn.length - t.options.gapVertical);
2322        },
2323
2324        getFreeSpacesForSlider: function() {
2325            var t = this;
2326
2327            t.freeSpaces = t.sliderFreeSpaces.slice(t.sliderActive, t.sliderActive + t.cols);
2328
2329            t.freeSpaces.sort(function(space1, space2) {
2330                if (space1.topStart > space2.topStart) {
2331                    return 1;
2332                }
2332 else if (space1.topStart < space2.topStart) {
2333                    return -1;
2334                }
2335            });
2336        },
2337
2338        updateSliderPosition: function() {
2339            var t = this,
2340                value = -t.sliderActive * t.columnWidth;
2341
2342            if (CubePortfolio.private.modernBrowser) {
2343                t.$ul[0].style[CubePortfolio.private.transform] = 'translate3d(' + value + 'px, 0px, 0)';
2344            } else {
2345                t.$ul[0].style.left = value + 'px';
2346            }
2347
2348            t.getFreeSpacesForSlider();
2349
2350            t.resizeMainContainer();
2351        },
2352
2353        dragSlider: function() {
2354            var t = this,
2355                $document = jQuery(document),
2356                posInitial,
2357                pos,
2358                target,
2359                ulPosition,
2360                ulMaxWidth,
2361                isAnimating = false,
2362                events = {},
2363                isTouch = false,
2364                touchStartEvent,
2365                isHover = false;
2366
2367            t.isDrag = false;
2368
2369            if (('ontouchstart' in window) ||
2370                (navigator.maxTouchPoints > 0) ||
2371                (navigator.msMaxTouchPoints > 0)) {
2372
2373                events = {
2374                    start: 'touchstart.cbp',
2375                    move: 'touchmove.cbp',
2376                    end: 'touchend.cbp'
2377                };
2378
2379                isTouch = true;
2380            } else {
2381                events = {
2382                    start: 'mousedown.cbp',
2383                    move: 'mousemove.cbp',
2384                    end: 'mouseup.cbp'
2385                };
2386            }
2387
2388            function dragStart(e) {
2389                if (t.sliderItemsLength()) {
2390                    return;
2391                }
2392
2393                if (!isTouch) {
2394                    e.preventDefault();
2395                } else {
2396                    touchStartEvent = e;
2397                }
2398
2399                if (t.options.auto) {
2400                    t.stopSliderAuto();
2401                }
2402
2403                if (isAnimating) {
2404                    jQuery(target).one('click.cbp', function() {
2405                        return false;
2406                    });
2407                    return;
2408                }
2409
2410                target = jQuery(e.target);
2411                posInitial = pointerEventToXY(e).x;
2412                pos = 0;
2413                ulPosition = -t.sliderActive * t.columnWidth;
2414                ulMaxWidth = t.columnWidth * (t.blocksOn.length - t.cols);
2415
2416                $document.on(events.move, dragMove);
2417                $document.on(events.end, dragEnd);
2418
2419                t.$obj.addClass('cbp-mode-slider-dragStart');
2420            }
2421
2422            function dragEnd(e) {
2423                t.$obj.removeClass('cbp-mode-slider-dragStart');
2424
2425                // wait a frame to be sure the .cbp-mode-slider-dragStart is removed from the dom
2426                requestAnimationFrame(function () {
2427                    // put the state to animate
2428                    isAnimating = true;
2429
2430                    if (pos !== 0) {
2431                        target.one('click.cbp', function() {
2432                            return false;
2433                        });
2434
2435                        t.jumpDragToSlider(pos);
2436
2437                        t.$ul.one(CubePortfolio.private.transitionend, afterDragEnd);
2438                    } else {
2439                        afterDragEnd.call(t);
2440                    }
2441
2442                    $document.off(events.move);
2443                    $document.off(events.end);
2444                });
2445            }
2446
2447            function dragMove(e) {
2448                pos = posInitial - pointerEventToXY(e).x;
2449
2450                if (pos > 8 || pos < -8) {
2451                    e.preventDefault();
2452                }
2453
2454                t.isDrag = true;
2455
2456                var value = ulPosition - pos;
2457
2458                if (pos < 0 && pos < ulPosition) { // to right
2459                    value = (ulPosition - pos) / 5;
2460                } else if (pos > 0 && (ulPosition - pos) < -ulMaxWidth) { // to left
2461                    value = -ulMaxWidth + (ulMaxWidth + ulPosition - pos) / 5;
2462                }
2463
2464                if (CubePortfolio.private.modernBrowser) {
2465                    t.$ul[0].style[CubePortfolio.private.transform] = 'translate3d(' + value + 'px, 0px, 0)';
2466                } else {
2467                    t.$ul[0].style.left = value + 'px';
2468                }
2469            }
2470
2471            function afterDragEnd() {
2472                isAnimating = false;
2473                t.isDrag = false;
2474
2475                if (t.options.auto) {
2476                    if (t.mouseIsEntered) {
2477                        return;
2478                    }
2479
2480                    t.startSliderAuto();
2481                }
2482            }
2483
2484            function pointerEventToXY(e) {
2485                if (e.originalEvent !== undefined && e.originalEvent.touches !== undefined) {
2486                    e = e.originalEvent.touches[0];
2487                }
2488
2489                return {
2490                    x: e.pageX,
2491                    y: e.pageY
2492                };
2493            }
2494
2495            t.$ul.on(events.start, dragStart);
2496        },
2497
2498        /**
2499         * Reset the slider layout
2500         */
2501        sliderLayoutReset: function() {
2502            var t = this;
2503
2504            t.freeSpaces = [];
2505
2506            t.sliderFreeSpaces = [];
2507        },
2508    });
2509})(jQuery, window, document);
2510
2511if (typeof Object.create !== 'function') {
2512    Object.create = function(obj) {
2513        function F() {}
2514        F.prototype = obj;
2515        return new F();
2516    };
2517}
2518
2519// http://paulirish.com/2011/requestanimationframe-for-smart-animating/
2520// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating
2521
2522// requestAnimationFrame polyfill by Erik M�ller. fixes from Paul Irish and Tino Zijdel
2523
2524// MIT license
2525
2526(function() {
2527    var lastTime = 0;
2528    var vendors = ['moz', 'webkit'];
2529
2530    for (var x = 0; x < vendors.length && !window.requestAnimationFrame; x++) {
2531        window.requestAnimationFrame = window[vendors[x] + 'RequestAnimationFrame'];
2532        window.cancelAnimationFrame = window[vendors[x] + 'CancelAnimationFrame'] || window[vendors[x] + 'CancelRequestAnimationFrame'];
2533    }
2534
2535    if (!window.requestAnimationFrame) {
2536        window.requestAnimationFrame = function(callback, element) {
2537            var currTime = new Date().getTime();
2538            var timeToCall = Math.max(0, 16 - (currTime - lastTime));
2539            var id = window.setTimeout(function() {
2540                    callback(currTime + timeToCall);
2541                },
2542                timeToCall);
2543            lastTime = currTime + timeToCall;
2544            return id;
2545        };
2546    }
2547
2548    if (!window.cancelAnimationFrame) {
2549        window.cancelAnimationFrame = function(id) {
2550            clearTimeout(id);
2551        };
2552    }
2553}());
2554
2555(function($, window, document, undefined) {
2556    'use strict';
2557
2558    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
2559
2560    function Plugin(parent) {
2561        var t = this;
2562
2563        t.parent = parent;
2564
2565        parent.filterLayout = t.filterLayout;
2566
2567        parent.registerEvent('computeBlocksFinish', function(expression) {
2568            parent.blocksOn2On = parent.blocksOnInitial.filter(expression);
2569            parent.blocksOn2Off = parent.blocksOnInitial.not(expression);
2570        });
2571    }
2572
2573    // here this value point to parent grid
2574    Plugin.prototype.filterLayout = function() {
2575        var t = this;
2576
2577        t.$obj.addClass('cbp-animation-' + t.options.animationType);
2578
2579        // [1] - blocks that are only moving with translate
2580        t.blocksOn2On.addClass('cbp-item-on2on')
2581            .each(function(index, el) {
2582                var data = jQuery(el).data('cbp');
2583                el.style[CubePortfolio.private.transform] = 'translate3d(' + (data.leftNew - data.left) + 'px, ' + (data.topNew - data.top) + 'px, 0)';
2584            });
2585
2586        // [2] - blocks than intialy are on but after applying the filter are off
2587        t.blocksOn2Off.addClass('cbp-item-on2off');
2588
2589        // [3] - blocks that are off and it will be on
2590        t.blocksOff2On = t.blocksOn
2591            .filter('.cbp-item-off')
2592            .removeClass('cbp-item-off')
2593            .addClass('cbp-item-off2on')
2594            .each(function(index, el) {
2595                var data = jQuery(el).data('cbp');
2596
2597                el.style.left = data.leftNew + 'px';
2598                el.style.top = data.topNew + 'px';
2599            });
2600
2601        if (t.blocksOn2Off.length) {
2602            t.blocksOn2Off.last().data('cbp').wrapper.one(CubePortfolio.private.animationend, animationend);
2603        } else if (t.blocksOff2On.length) {
2604            t.blocksOff2On.last().data('cbp').wrapper.one(CubePortfolio.private.animationend, animationend);
2605        } else {
2606            animationend();
2607        }
2608
2609        // resize main container height
2610        t.resizeMainContainer();
2611
2612        function animationend() {
2613            t.blocks.removeClass('cbp-item-on2off cbp-item-off2on cbp-item-on2on')
2614                .each(function(index, el) {
2615                    var data = jQuery(el).data('cbp');
2616
2617                    data.left = data.leftNew;
2618                    data.top = data.topNew;
2619
2620                    el.style.left = data.left + 'px';
2621                    el.style.top = data.top + 'px';
2622
2623                    el.style[CubePortfolio.private.transform] = '';
2624                });
2625
2626            t.blocksOff.addClass('cbp-item-off');
2627
2628            t.$obj.removeClass('cbp-animation-' + t.options.animationType);
2629
2630            t.filterFinish();
2631        }
2632    };
2633
2634    Plugin.prototype.destroy = function() {
2635        var parent = this.parent;
2636        parent.$obj.removeClass('cbp-animation-' + parent.options.animationType);
2637    };
2638
2639    CubePortfolio.plugins.animationClassic = function(parent) {
2640        if (!CubePortfolio.private.modernBrowser || jQuery.inArray(parent.options.animationType, ['boxShadow', 'fadeOut', 'flipBottom', 'flipOut', 'quicksand', 'scaleSides', 'skew']) < 0) {
2641            return null;
2642        }
2643
2644        return new Plugin(parent);
2645    };
2646})(jQuery, window, document);
2647
2648(function($, window, document, undefined) {
2649    'use strict';
2650
2651    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
2652
2653    function Plugin(parent) {
2654        var t = this;
2655
2656        t.parent = parent;
2657
2658        parent.filterLayout = t.filterLayout;
2659    }
2660
2661    // here this value point to parent grid
2662    Plugin.prototype.filterLayout = function() {
2663        var t = this,
2664            ulClone = t.$ul[0].cloneNode(true);
2665
2666        ulClone.setAttribute('class', 'cbp-wrapper-helper');
2667        t.wrapper[0].insertBefore(ulClone, t.$ul[0]);
2668
2669        requestAnimationFrame(function() {
2670            t.$obj.addClass('cbp-animation-' + t.options.animationType);
2671
2672            t.blocksOff.addClass('cbp-item-off');
2673
2674            t.blocksOn.removeClass('cbp-item-off')
2675                .each(function(index, el) {
2676                    var data = jQuery(el).data('cbp');
2677
2678                    data.left = data.leftNew;
2679                    data.top = data.topNew;
2680
2681                    el.style.left = data.left + 'px';
2682                    el.style.top = data.top + 'px';
2683
2684                    if (t.options.animationType === 'sequentially') {
2685                        data.wrapper[0].style[CubePortfolio.private.animationDelay] = (index * 60) + 'ms';
2686                    }
2687                });
2688
2689            if (t.blocksOn.length) {
2690                t.blocksOn.last().data('cbp').wrapper.one(CubePortfolio.private.animationend, animationend);
2691            } else if (t.blocksOnInitial.length) {
2692                t.blocksOnInitial.last().data('cbp').wrapper.one(CubePortfolio.private.animationend, animationend);
2693            } else {
2694                animationend();
2695            }
2696
2697            // resize main container height
2698            t.resizeMainContainer();
2699        });
2700
2701        function animationend() {
2702            t.wrapper[0].removeChild(ulClone);
2703
2704            if (t.options.animationType === 'sequentially') {
2705                t.blocksOn.each(function(index, el) {
2706                    jQuery(el).data('cbp').wrapper[0].style[CubePortfolio.private.animationDelay] = '';
2707                });
2708            }
2709
2710            t.$obj.removeClass('cbp-animation-' + t.options.animationType);
2711
2712            t.filterFinish();
2713        }
2714    };
2715
2716    Plugin.prototype.destroy = function() {
2717        var parent = this.parent;
2718        parent.$obj.removeClass('cbp-animation-' + parent.options.animationType);
2719    };
2720
2721    CubePortfolio.plugins.animationClone = function(parent) {
2722        if (!CubePortfolio.private.modernBrowser || jQuery.inArray(parent.options.animationType, ['fadeOutTop', 'slideLeft', 'sequentially']) < 0) {
2723            return null;
2724        }
2725
2726        return new Plugin(parent);
2727    };
2728})(jQuery, window, document);
2729
2730(function($, window, document, undefined) {
2731    'use strict';
2732
2733    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
2734
2735    function Plugin(parent) {
2736        var t = this;
2737
2738        t.parent = parent;
2739
2740        parent.filterLayout = t.filterLayout;
2741    }
2742
2743    // here this value point to parent grid
2744    Plugin.prototype.filterLayout = function() {
2745        var t = this,
2746            ulClone = t.$ul.clone(true, true);
2747
2748        ulClone[0].setAttribute('class', 'cbp-wrapper-helper');
2749        t.wrapper[0].insertBefore(ulClone[0], t.$ul[0]);
2750
2751        // hack for safari osx because it doesn't want to work if I set animationDelay
2752        // on cbp-item-wrapper before I clone the t.$ul
2753        var items = ulClone.find('.cbp-item').not('.cbp-item-off');
2754        t.sortBlocks(items, 'top');
2755        items.children('.cbp-item-wrapper').each(function(index, el) {
2756            el.style[CubePortfolio.private.animationDelay] = (index * 50) + 'ms';
2757        });
2758
2759        requestAnimationFrame(function() {
2760            t.$obj.addClass('cbp-animation-' + t.options.animationType);
2761
2762            t.blocksOff.addClass('cbp-item-off');
2763
2764            t.blocksOn.removeClass('cbp-item-off')
2765                .each(function(index, el) {
2766                    var data = jQuery(el).data('cbp');
2767
2768                    data.left = data.leftNew;
2769                    data.top = data.topNew;
2770
2771                    el.style.left = data.left + 'px';
2772                    el.style.top = data.top + 'px';
2773
2774                    data.wrapper[0].style[CubePortfolio.private.animationDelay] = (index * 50) + 'ms';
2775                });
2776
2777            var onLength = t.blocksOn.length,
2778                offLength = items.length;
2779
2780            if (onLength === 0 && offLength === 0) {
2781                animationend();
2782            } else if (onLength < offLength) {
2783                items.last().children('.cbp-item-wrapper').one(CubePortfolio.private.animationend, animationend);
2784            } else {
2785                t.blocksOn.last().data('cbp').wrapper.one(CubePortfolio.private.animationend, animationend);
2786            }
2787
2788            // resize main container height
2789            t.resizeMainContainer();
2790        });
2791
2792        function animationend() {
2793            t.wrapper[0].removeChild(ulClone[0]);
2794
2795            t.$obj.removeClass('cbp-animation-' + t.options.animationType);
2796
2797            t.blocks.each(function(index, el) {
2798                jQuery(el).data('cbp').wrapper[0].style[CubePortfolio.private.animationDelay] = '';
2799            });
2800
2801            t.filterFinish();
2802        }
2803    };
2804
2805    Plugin.prototype.destroy = function() {
2806        var parent = this.parent;
2807        parent.$obj.removeClass('cbp-animation-' + parent.options.animationType);
2808    };
2809
2810    CubePortfolio.plugins.animationCloneDelay = function(parent) {
2811        if (!CubePortfolio.private.modernBrowser || jQuery.inArray(parent.options.animationType, ['3dflip', 'flipOutDelay', 'foldLeft', 'frontRow', 'rotateRoom', 'rotateSides', 'scaleDown', 'slideDelay', 'unfold']) < 0) {
2812            return null;
2813        }
2814
2815        return new Plugin(parent);
2816    };
2817})(jQuery, window, document);
2818
2819(function($, window, document, undefined) {
2820    'use strict';
2821
2822    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
2823
2824    function Plugin(parent) {
2825        var t = this;
2826
2827        t.parent = parent;
2828
2829        parent.filterLayout = t.filterLayout;
2830    }
2831
2832    // here this value point to parent grid
2833    Plugin.prototype.filterLayout = function() {
2834        var t = this,
2835            ulClone = t.$ul[0].cloneNode(true);
2836
2837        ulClone.setAttribute('class', 'cbp-wrapper-helper');
2838        t.wrapper[0].insertBefore(ulClone, t.$ul[0]);
2839
2840        requestAnimationFrame(function() {
2841            t.$obj.addClass('cbp-animation-' + t.options.animationType);
2842
2843            t.blocksOff.addClass('cbp-item-off');
2844
2845            t.blocksOn.removeClass('cbp-item-off')
2846                .each(function(index, el) {
2847                    var data = jQuery(el).data('cbp');
2848
2849                    data.left = data.leftNew;
2850                    data.top = data.topNew;
2851
2852                    el.style.left = data.left + 'px';
2853                    el.style.top = data.top + 'px';
2854                });
2855
2856            if (t.blocksOn.length) {
2857                t.$ul.one(CubePortfolio.private.animationend, animationend);
2858            } else if (t.blocksOnInitial.length) {
2859                jQuery(ulClone).one(CubePortfolio.private.animationend, animationend);
2860            } else {
2861                animationend();
2862            }
2863
2864            // resize main container height
2865            t.resizeMainContainer();
2866        });
2867
2868        function animationend() {
2869            t.wrapper[0].removeChild(ulClone);
2870
2871            t.$obj.removeClass('cbp-animation-' + t.options.animationType);
2872
2873            t.filterFinish();
2874        }
2875    };
2876
2877    Plugin.prototype.destroy = function() {
2878        var parent = this.parent;
2879        parent.$obj.removeClass('cbp-animation-' + parent.options.animationType);
2880    };
2881
2882    CubePortfolio.plugins.animationWrapper = function(parent) {
2883        if (!CubePortfolio.private.modernBrowser || jQuery.inArray(parent.options.animationType, ['bounceBottom', 'bounceLeft', 'bounceTop', 'moveLeft']) < 0) {
2884            return null;
2885        }
2886
2887        return new Plugin(parent);
2888    };
2889})(jQuery, window, document);
2890
2891(function($, window, document, undefined) {
2892    'use strict';
2893
2894    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
2895
2896    function Plugin(parent) {
2897        var t = this;
2898
2899        t.parent = parent;
2900
2901        parent.registerEvent('initFinish', function() {
2902            parent.$obj.on('click.cbp', '.cbp-caption-defaultWrap', function(e) {
2903                e.preventDefault();
2904
2905                if (parent.isAnimating) {
2906                    return;
2907                }
2908
2909                parent.isAnimating = true;
2910
2911                var defaultWrap = jQuery(this),
2912                    activeWrap = defaultWrap.next(),
2913                    caption = defaultWrap.parent(),
2914                    endStyle = {
2915                        position: 'relative',
2916                        height: activeWrap.outerHeight(true)
2917                    },
2918                    startStyle = {
2919                        position: 'relative',
2920                        height: 0
2921                    };
2922
2923                parent.$obj.addClass('cbp-caption-expand-active');
2924
2925                // swap endStyle & startStyle
2926                if (caption.hasClass('cbp-caption-expand-open')) {
2927                    var temp = startStyle;
2928                    startStyle = endStyle;
2929                    endStyle = temp;
2930                    caption.removeClass('cbp-caption-expand-open');
2931                }
2932
2933                activeWrap.css(endStyle);
2934
2935                parent.$obj.one('pluginResize.cbp', function() {
2936                    parent.isAnimating = false;
2937                    parent.$obj.removeClass('cbp-caption-expand-active');
2938
2939                    if (endStyle.height === 0) {
2940                        caption.removeClass('cbp-caption-expand-open');
2941                        activeWrap.attr('style', '');
2942                    }
2943                });
2944
2945                // reposition the blocks
2946                parent.layoutAndAdjustment();
2947
2948                // set activeWrap to 0 so I can start animation in the next frame
2949                activeWrap.css(startStyle);
2950
2951                // delay animation
2952                requestAnimationFrame(function() {
2953                    caption.addClass('cbp-caption-expand-open');
2954
2955                    activeWrap.css(endStyle);
2956
2957                    // used by slider layoutMode
2958                    parent.triggerEvent('gridAdjust');
2959
2960                    parent.triggerEvent('resizeGrid');
2961                });
2962            });
2963        }, true);
2964    }
2965
2966    Plugin.prototype.destroy = function() {
2967        this.parent.$obj.find('.cbp-caption-defaultWrap').off('click.cbp').parent().removeClass('cbp-caption-expand-active');
2968    };
2969
2970    CubePortfolio.plugins.captionExpand = function(parent) {
2971
2972        if (parent.options.caption !== 'expand') {
2973            return null;
2974        }
2975
2976        return new Plugin(parent);
2977    };
2978
2979})(jQuery, window, document);
2980
2981(function($, window, document, undefined) {
2982    'use strict';
2983
2984    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
2985
2986    function Plugin(parent) {
2987        var deferred = jQuery.Deferred();
2988
2989        parent.pushQueue('delayFrame', deferred);
2990
2991        parent.registerEvent('initEndWrite', function() {
2992            parent.blocksOn.each(function(index, el) {
2993                el.style[CubePortfolio.private.animationDelay] = (index * parent.options.displayTypeSpeed) + 'ms';
2994            });
2995
2996            parent.$obj.addClass('cbp-displayType-bottomToTop');
2997
2998            // get last element
2999            parent.blocksOn.last().one(CubePortfolio.private.animationend, function() {
3000                parent.$obj.removeClass('cbp-displayType-bottomToTop');
3001
3002                parent.blocksOn.each(function(index, el) {
3003                    el.style[CubePortfolio.private.animationDelay] = '';
3004                });
3005
3006                // resolve event after the animation is finished
3007                deferred.resolve();
3008            });
3009        }, true);
3010    }
3011
3012    CubePortfolio.plugins.displayBottomToTop = function(parent) {
3013        if (!CubePortfolio.private.modernBrowser || parent.options.displayType !== 'bottomToTop' || parent.blocksOn.length === 0) {
3014            return null;
3015        }
3016
3017        return new Plugin(parent);
3018    };
3019})(jQuery, window, document);
3020
3021(function($, window, document, undefined) {
3022    'use strict';
3023
3024    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
3025
3026    function Plugin(parent) {
3027        var deferred = jQuery.Deferred();
3028
3029        parent.pushQueue('delayFrame', deferred);
3030
3031        parent.registerEvent('initEndWrite', function() {
3032            parent.obj.style[CubePortfolio.private.animationDuration] = parent.options.displayTypeSpeed + 'ms';
3033
3034            parent.$obj.addClass('cbp-displayType-fadeIn');
3035
3036            parent.$obj.one(CubePortfolio.private.animationend, function() {
3037                parent.$obj.removeClass('cbp-displayType-fadeIn');
3038
3039                parent.obj.style[CubePortfolio.private.animationDuration] = '';
3040
3041                // resolve event after the animation is finished
3042                deferred.resolve();
3043            });
3044        }, true);
3045    }
3046
3047    CubePortfolio.plugins.displayFadeIn = function(parent) {
3048        if (!CubePortfolio.private.modernBrowser || (parent.options.displayType !== 'lazyLoading' && parent.options.displayType !== 'fadeIn') || parent.blocksOn.length === 0) {
3049            return null;
3050        }
3051
3052        return new Plugin(parent);
3053    };
3054})(jQuery, window, document);
3055
3056(function($, window, document, undefined) {
3057    'use strict';
3058
3059    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
3060
3061    function Plugin(parent) {
3062        var deferred = jQuery.Deferred();
3063
3064        parent.pushQueue('delayFrame', deferred);
3065
3066        parent.registerEvent('initEndWrite', function() {
3067            parent.obj.style[CubePortfolio.private.animationDuration] = parent.options.displayTypeSpeed + 'ms';
3068
3069            parent.$obj.addClass('cbp-displayType-fadeInToTop');
3070
3071            parent.$obj.one(CubePortfolio.private.animationend, function() {
3072                parent.$obj.removeClass('cbp-displayType-fadeInToTop');
3073
3074                parent.obj.style[CubePortfolio.private.animationDuration] = '';
3075
3076                // resolve event after the animation is finished
3077                deferred.resolve();
3078            });
3079        }, true);
3080    }
3081
3082    CubePortfolio.plugins.displayFadeInToTop = function(parent) {
3083        if (!CubePortfolio.private.modernBrowser || parent.options.displayType !== 'fadeInToTop' || parent.blocksOn.length === 0) {
3084            return null;
3085        }
3086
3087        return new Plugin(parent);
3088    };
3089})(jQuery, window, document);
3090
3091(function($, window, document, undefined) {
3092    'use strict';
3093
3094    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
3095
3096    function Plugin(parent) {
3097        var deferred = jQuery.Deferred();
3098
3099        parent.pushQueue('delayFrame', deferred);
3100
3101        parent.registerEvent('initEndWrite', function() {
3102            parent.blocksOn.each(function(index, el) {
3103                el.style[CubePortfolio.private.animationDelay] = (index * parent.options.displayTypeSpeed) + 'ms';
3104            });
3105
3106            parent.$obj.addClass('cbp-displayType-sequentially');
3107
3108            // get last element
3109            parent.blocksOn.last().one(CubePortfolio.private.animationend, function() {
3110                parent.$obj.removeClass('cbp-displayType-sequentially');
3111
3112                parent.blocksOn.each(function(index, el) {
3113                    el.style[CubePortfolio.private.animationDelay] = '';
3114                });
3115
3116                // resolve event after the animation is finished
3117                deferred.resolve();
3118            });
3119        }, true);
3120    }
3121
3122    CubePortfolio.plugins.displaySequentially = function(parent) {
3123        if (!CubePortfolio.private.modernBrowser || parent.options.displayType !== 'sequentially' || parent.blocksOn.length === 0) {
3124            return null;
3125        }
3126
3127        return new Plugin(parent);
3128    };
3129})(jQuery, window, document);
3130
3131(function($, window, document, undefined) {
3132    'use strict';
3133
3134    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
3135
3136    function Plugin(parent) {
3137        var t = this;
3138
3139        t.parent = parent;
3140
3141        t.filters = jQuery(parent.options.filters);
3142        t.filterData = [];
3143
3144        // set default filter if it's present in url
3145        t.filterFromUrl();
3146
3147        t.registerFilter();
3148    }
3149
3150    Plugin.prototype.registerFilter = function() {
3151        var t = this,
3152            parent = t.parent,
3153            filtersCallback,
3154            arr = parent.defaultFilter.split('|');
3155
3156        t.wrap = t.filters.find('.cbp-l-filters-dropdownWrap')
3157            .on({
3158                'mouseover.cbp': function() {
3159                    jQuery(this).addClass('cbp-l-filters-dropdownWrap-open');
3160                },
3161                'mouseleave.cbp': function() {
3162                    jQuery(this).removeClass('cbp-l-filters-dropdownWrap-open');
3163                }
3164            });
3165
3166        t.filters.each(function(index, el) {
3167            var filter = jQuery(el),
3168                filterName = '*',
3169                items = filter.find('.cbp-filter-item'),
3170                dropdown = {};
3171                
3172            //TREETHEMES
3173            filter.addClass('container');
3174
3175            if (filter.hasClass('cbp-l-filters-dropdown')) {
3176                dropdown.wrap = filter.find('.cbp-l-filters-dropdownWrap');
3177                dropdown.header = filter.find('.cbp-l-filters-dropdownHeader');
3178                dropdown.headerText = dropdown.header.text();
3179            }
3180
3181            // activate counter for filters
3182            parent.$obj.cubeportfolio('showCounter', items);
3183
3184            jQuery.each(arr, function(index, val) {
3185                if (items.filter('[data-filter="' + val + '"]').length) {
3186                    filterName = val;
3187                    arr.splice(index, 1);
3188                    return false;
3189                }
3190            });
3191
3192            jQuery.data(el, 'filterName', filterName);
3193            t.filterData.push(el);
3194
3195            t.filtersCallback(dropdown, items.filter('[data-filter="' + filterName + '"]'));
3196
3197            items.on('click.cbp', function() {
3198                var item = jQuery(this);
3199
3200                if (item.hasClass('cbp-filter-item-active') || parent.isAnimating) {
3201                    return;
3202                }
3203
3204                t.filtersCallback(dropdown, item);
3205
3206                jQuery.data(el, 'filterName', item.data('filter'));
3207
3208                var name = jQuery.map(t.filterData, function(el, index) {
3209                    var f = jQuery.data(el, 'filterName');
3210                    return (f !== "" && f !== '*') ? f : null;
3211                });
3212
3213                if (name.length < 1) {
3214                    name = ['*'];
3215                }
3216
3217                var filterJoin = name.join('|');
3218
3219                if (parent.defaultFilter !== filterJoin) {
3220                    // filter the items
3221                    parent.$obj.cubeportfolio('filter', filterJoin);
3222                }
3223            });
3224        });
3225    };
3226
3227    Plugin.prototype.filtersCallback = function(dropdown, item) {
3228        if (!jQuery.isEmptyObject(dropdown)) {
3229            dropdown.wrap.trigger('mouseleave.cbp');
3230
3231            if (dropdown.headerText) {
3232                dropdown.headerText = '';
3233            } else {
3234                dropdown.header.html(item.html());
3235            }
3236        }
3237
3238        item.addClass('cbp-filter-item-active').siblings().removeClass('cbp-filter-item-active');
3239    };
3240
3241    /**
3242     * Check if filters are present in url
3243     */
3244    Plugin.prototype.filterFromUrl = function() {
3245        var match = /#cbpf=(.*?)([#\?&]|$)/gi.exec(location.href);
3246
3247        if (match !== null) {
3248            this.parent.defaultFilter = decodeURIComponent(match[1]);
3249        }
3250    };
3251
3252    Plugin.prototype.destroy = function() {
3253        var t = this;
3254
3255        t.filters.find('.cbp-filter-item').off('.cbp');
3256        t.wrap.off('.cbp');
3257    };
3258
3259    CubePortfolio.plugins.filters = function(parent) {
3260        if (parent.options.filters === '') {
3261            return null;
3262        }
3263
3264        return new Plugin(parent);
3265    };
3266})(jQuery, window, document);
3267
3268(function($, window, document, undefined) {
3269    'use strict';
3270
3271    var options = {};
3272
3273    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
3274
3275    function Plugin(parent) {
3276        var t = this;
3277
3278        t.parent = parent;
3279
3280        t.options = jQuery.extend({}, options, t.parent.options.plugins.inlineSlider);
3281
3282        t.runInit();
3283
3284        parent.registerEvent('addItemsToDOM', function() {
3285            t.runInit();
3286        });
3287
3288    }
3289
3290    function InitSlider(slider) {
3291        var t = this;
3292
3293        if (slider.hasClass('cbp-slider-inline-ready')) {
3294            return;
3295        }
3296
3297        slider.addClass('cbp-slider-inline-ready');
3298
3299        t.items = slider.find('.cbp-slider-wrapper').children('.cbp-slider-item');
3300
3301        t.active = t.items.filter('.cbp-slider-item--active').index();
3302        t.total = t.items.length - 1;
3303
3304        t.updateLeft();
3305
3306        slider.find('.cbp-slider-next').on('click.cbp', function(e) {
3307            e.preventDefault();
3308
3309            if (t.active < t.total) {
3310                t.active++;
3311                t.updateLeft();
3312            } else if (t.active === t.total) {
3313                t.active = 0;
3314                t.updateLeft();
3315            }
3316        });
3317
3318        slider.find('.cbp-slider-prev').on('click.cbp', function(e) {
3319            e.preventDefault();
3320
3321            if (t.active > 0) {
3322                t.active--;
3323                t.updateLeft();
3324            } else if (t.active === 0) {
3325                t.active = t.total;
3326                t.updateLeft();
3327            }
3328        });
3329    };
3330
3331    InitSlider.prototype.updateLeft = function() {
3332        var t = this;
3333
3334        t.items.removeClass('cbp-slider-item--active');
3335        t.items.eq(t.active).addClass('cbp-slider-item--active');
3336
3337        t.items.each(function(index, el) {
3338            el.style.left = (index - t.active) + '00%';
3339        });
3340    };
3341
3342    Plugin.prototype.runInit = function() {
3343        var t = this;
3344
3345        t.parent.$obj.find('.cbp-slider-inline').not('.cbp-slider-inline-ready').each(function(index, el) {
3346            var slider = jQuery(el);
3347            var activeImage = slider.find('.cbp-slider-item--active').find('img')[0];
3348
3349            if (activeImage.hasAttribute('data-cbp-src')) {
3350                t.parent.$obj.on('lazyLoad.cbp', function(e, image) {
3351                    if (image.src === activeImage.src) {
3352                        new InitSlider(slider);
3353                    }
3354                });
3355            } else {
3356                new InitSlider(slider);
3357            }
3358        });
3359    };
3360
3361    Plugin.prototype.destroy = function() {
3362        var t = this;
3363
3364        t.parent.$obj.find('.cbp-slider-next').off('click.cbp');
3365        t.parent.$obj.find('.cbp-slider-prev').off('click.cbp');
3366
3367        t.parent.$obj.off('lazyLoad.cbp');
3368
3369        t.parent.$obj.find('.cbp-slider-inline').each(function(index, el) {
3370            var slider = jQuery(el);
3371
3372            slider.removeClass('cbp-slider-inline-ready');
3373
3374            var items = slider.find('.cbp-slider-item');
3375            items.removeClass('cbp-slider-item--active');
3376
3377            items.removeAttr('style');
3378
3379            items.eq(0).addClass('cbp-slider-item--active');
3380        });
3381    };
3382
3383    CubePortfolio.plugins.inlineSlider = function(parent) {
3384        return new Plugin(parent);
3385    };
3386})(jQuery, window, document);
3387
3388(function($, window, document, undefined) {
3389    'use strict';
3390
3391    var options = {
3392        loadingClass: 'cbp-lazyload',
3393        threshold: 0, // loads images 150px before they're visible
3394    };
3395
3396    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
3397
3398    function Plugin(parent) {
3399        var t = this;
3400
3401        t.window = jQuery(window);
3402
3403        t.parent = parent;
3404
3405        t.options = jQuery.extend({}, options, t.parent.options.plugins.lazyLoad);
3406
3407        parent.registerEvent('initEndWrite', function() {
3408            var timeout;
3409
3410            t.triggerImg();
3411
3412            parent.registerEvent('resizeMainContainer', function() {
3413                t.triggerImg();
3414            });
3415
3416            // scroll event. @todo - this must be done like the global resize event
3417            t.window.on('scroll.cbp', function() {
3418                clearTimeout(timeout);
3419
3420                timeout = setTimeout(function() {
3421                    t.triggerImg();
3422                }, 300);
3423            });
3424        }, true);
3425    }
3426
3427    Plugin.prototype.triggerImg = function() {
3428        var t = this;
3429
3430        var imgs = t.parent.$obj.find('img').filter('[data-cbp-src]');
3431
3432        if (imgs.length === 0) {
3433            return;
3434        }
3435
3436        t.screenHeight = t.window.height();
3437
3438        imgs.each(function(index, el) {
3439            var parentNode = jQuery(el.parentNode);
3440
3441            if (!t.isElementInScreen(el)) {
3442                parentNode.addClass(t.options.loadingClass);
3443                return;
3444            }
3445
3446            var dataSrc = el.getAttribute('data-cbp-src');
3447
3448            if (t.parent.checkSrc(dataSrc) === null) {
3449                t.removeLazy(el, dataSrc);
3450                parentNode.removeClass(t.options.loadingClass);
3451            } else {
3452                parentNode.addClass(t.options.loadingClass);
3453                jQuery('<img>').on('load.cbp error.cbp', function() {
3454                    t.removeLazy(el, dataSrc, parentNode);
3455                }).attr('src', dataSrc); // for ie8
3456            }
3457        });
3458    };
3459
3460    Plugin.prototype.removeLazy = function(el, dataSrc, parentNode) {
3461        var t = this;
3462
3463        el.src = dataSrc;
3464        el.removeAttribute('data-cbp-src');
3465        t.parent.removeAttrImage(el);
3466
3467        // trigger public event
3468        t.parent.$obj.trigger('lazyLoad.cbp', el);
3469
3470        if (parentNode) {
3471            if (CubePortfolio.private.modernBrowser) {
3472                jQuery(el).one(CubePortfolio.private.transitionend, function() {
3473                    parentNode.removeClass(t.options.loadingClass);
3474                });
3475            } else {
3476                parentNode.removeClass(t.options.loadingClass);
3477            }
3478        }
3479    };
3480
3481    Plugin.prototype.isElementInScreen = function(el) {
3482        var t = this;
3483
3484        var bound = el.getBoundingClientRect();
3485        var bottom = bound.bottom + t.options.threshold;
3486        var screenHeight = t.screenHeight + bottom - (bound.top - t.options.threshold);
3487
3488        return bottom >= 0 && bottom <= screenHeight;
3489    };
3490
3491    Plugin.prototype.destroy = function() {
3492        var t = this;
3493
3494        t.window.off('scroll.cbp');
3495    };
3496
3497    CubePortfolio.plugins.lazyLoad = function(parent) {
3498        return new Plugin(parent);
3499    };
3500})(jQuery, window, document);
3501
3502(function($, window, document, undefined) {
3503    'use strict';
3504
3505    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
3506
3507    function Plugin(parent) {
3508        var t = this;
3509
3510        t.parent = parent;
3511
3512        t.loadMore = jQuery(parent.options.loadMore).find('.cbp-l-loadMore-link');
3513
3514        // load click or auto action
3515        if (t.loadMore.length) {
3516            t[parent.options.loadMoreAction]();
3517        }
3518
3519    }
3520
3521    Plugin.prototype.click = function() {
3522        var t = this,
3523            numberOfClicks = 0;
3524
3525        t.loadMore.on('click.cbp', function(e) {
3526            var button = jQuery(this);
3527
3528            e.preventDefault();
3529
3530            if (t.parent.isAnimating || button.hasClass('cbp-l-loadMore-stop')) {
3531                return;
3532            }
3533
3534            // set loading status
3535            button.addClass('cbp-l-loadMore-loading');
3536
3537            numberOfClicks++;
3538
3539            // perform ajax request
3540            jQuery.ajax({
3541                url: t.loadMore.attr('href') + '?block=' + numberOfClicks,
3542                type: 'GET',
3543                dataType: 'HTML'
3544            }).done(function(result) {
3545                var items = result.replace(/(\r\n|\n|\r)/gm,"");
3546
3547                var startBlock = items.indexOf('cbp-loadMore-block' + numberOfClicks);
3548
3549                // stop the loadMore because the block doesn't exist
3550                if (startBlock === -1) {
3551                    button.addClass('cbp-l-loadMore-stop');
3552                    return;
3553                }
3554
3555                // set start from where I will substring
3556                var start = items.indexOf('>', startBlock) + 1;
3557
3558                var endBlock = items.indexOf('cbp-loadMore-block' + (numberOfClicks + 1));
3559                var end;
3560
3561                // if endBlock doesn't exist
3562                if (endBlock === -1) {
3563                    end = items.lastIndexOf('</');
3564                } else {
3565                    end = items.lastIndexOf('</', endBlock);
3566                }
3567
3568                t.parent.$obj.cubeportfolio('appendItems', items.substring(start, end), function() {
3569                    // remove class from button
3570                    button.removeClass('cbp-l-loadMore-loading');
3571
3572                    // check if we have more works
3573                    if (endBlock === -1) {
3574                        button.addClass('cbp-l-loadMore-stop');
3575                    }
3576                });
3577
3578            }).fail(function() {
3579                // error
3580            });
3581
3582        });
3583    };
3584
3585
3586    Plugin.prototype.auto = function() {
3587        var t = this;
3588
3589        t.parent.$obj.on('initComplete.cbp', function() {
3590            Object.create({
3591                init: function() {
3592                    var self = this;
3593
3594                    // the job inactive
3595                    self.isActive = false;
3596
3597                    self.numberOfClicks = 0;
3598
3599                    // set loading status
3600                    t.loadMore.addClass('cbp-l-loadMore-loading');
3601
3602                    // cache window selector
3603                    self.window = jQuery(window);
3604
3605                    // add events for scroll
3606                    self.addEvents();
3607
3608                    // trigger method on init
3609                    self.getNewItems();
3610                },
3611
3612                addEvents: function() {
3613                    var self = this,
3614                        timeout;
3615
3616                    t.loadMore.on('click.cbp', function(e) {
3617                        e.preventDefault();
3618                    });
3619
3620                    self.window.on('scroll.loadMoreObject', function() {
3621
3622                        clearTimeout(timeout);
3623
3624                        timeout = setTimeout(function() {
3625                            if (!t.parent.isAnimating) {
3626                                // get new items on scroll
3627                                self.getNewItems();
3628                            }
3629                        }, 80);
3630
3631                    });
3632
3633                    // when the filter is completed
3634                    t.parent.$obj.on('filterComplete.cbp', function() {
3635                        self.getNewItems();
3636                    });
3637                },
3638
3639                getNewItems: function() {
3640                    var self = this,
3641                        topLoadMore, topWindow;
3642
3643                    if (self.isActive || t.loadMore.hasClass('cbp-l-loadMore-stop')) {
3644                        return;
3645                    }
3646
3647                    // add a treshold
3648                    topLoadMore = t.loadMore.offset().top - 200;
3649                    topWindow = self.window.scrollTop() + self.window.height();
3650
3651                    if (topLoadMore > topWindow) {
3652                        return;
3653                    }
3654
3655                    // this job is now busy
3656                    self.isActive = true;
3657
3658                    // increment number of clicks
3659                    self.numberOfClicks++;
3660
3661                    // perform ajax request
3662                    jQuery.ajax({
3663                            url: t.loadMore.attr('href') + '?block=' + self.numberOfClicks,
3664                            type: 'GET',
3665                            dataType: 'HTML',
3666                            cache: true
3667                        })
3668                        .done(function(result) {
3669                            var items = result.replace(/(\r\n|\n|\r)/gm,"");
3670
3671                            var startBlock = items.indexOf('cbp-loadMore-block' + self.numberOfClicks);
3672
3673                            // stop the loadMore because the block doesn't exist
3674                            if (startBlock === -1) {
3675                                t.loadMore.addClass('cbp-l-loadMore-stop');
3676                                return;
3677                            }
3678
3679                            // set start from where I will substring
3680                            var start = items.indexOf('>', startBlock) + 1;
3681
3682                            var endBlock = items.indexOf('cbp-loadMore-block' + (self.numberOfClicks + 1));
3683                            var end;
3684
3685                            // if endBlock doesn't exist
3686                            if (endBlock === -1) {
3687                                end = items.lastIndexOf('</');
3688                            } else {
3689                                end = items.lastIndexOf('</', endBlock);
3690                            }
3691
3692                            t.parent.$obj.cubeportfolio('appendItems', items.substring(start, end), function() {
3693                                if (endBlock === -1) {
3694                                    t.loadMore.addClass('cbp-l-loadMore-stop');
3695
3696                                    // remove events
3697                                    self.window.off('scroll.loadMoreObject');
3698                                    t.parent.$obj.off('filterComplete.cbp');
3699                                } else {
3700                                    // make the job inactive
3701                                    self.isActive = false;
3702
3703                                    self.window.trigger('scroll.loadMoreObject');
3704                                }
3705                            });
3706                        })
3707                        .fail(function() {
3708                            // make the job inactive
3709                            self.isActive = false;
3710                        });
3711                }
3712            }).init();
3713        });
3714
3715    };
3716
3717
3718    Plugin.prototype.destroy = function() {
3719        var t = this;
3720
3721        t.loadMore.off('.cbp');
3722
3723        jQuery(window).off('scroll.loadMoreObject');
3724    };
3725
3726    CubePortfolio.plugins.loadMore = function(parent) {
3727        if (parent.options.loadMore === '') {
3728            return null;
3729        }
3730
3731        return new Plugin(parent);
3732    };
3733
3734})(jQuery, window, document);
3735
3736(function($, window, document, undefined) {
3737    'use strict';
3738
3739    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
3740
3741    var popup = {
3742
3743        /**
3744         * init function for popup
3745         * @param cubeportfolio = cubeportfolio instance
3746         * @param type =  'lightbox' or 'singlePage'
3747         */
3748        init: function(cubeportfolio, type) {
3749            var t = this,
3750                currentBlock;
3751
3752            // remember cubeportfolio instance
3753            t.cubeportfolio = cubeportfolio;
3754
3755            // remember if this instance is for lightbox or for singlePage
3756            t.type = type;
3757
3758            // remember if the popup is open or not
3759            t.isOpen = false;
3760
3761            t.options = t.cubeportfolio.options;
3762
3763            if (type === 'lightbox') {
3764                t.cubeportfolio.registerEvent('resizeWindow', function() {
3765                    t.resizeImage();
3766                });
3767            }
3768
3769            if (type === 'singlePageInline') {
3770                t.height = 0;
3771
3772                // create markup, css and add events for SinglePageInline
3773                t.createMarkupSinglePageInline();
3774
3775                t.cubeportfolio.registerEvent('resizeGrid', function() {
3776                    if (t.isOpen) {
3777                        // @todo must add support for this features in the future
3778                        t.close(); // workaround
3779                    }
3780                });
3781
3782                if (t.options.singlePageInlineDeeplinking) {
3783                    t.url = location.href;
3784
3785                    if (t.url.slice(-1) === '#') {
3786                        t.url = t.url.slice(0, -1);
3787                    }
3788
3789                    var links = t.url.split('#cbpi=');
3790                    var url = links.shift(); // remove first item
3791
3792                    jQuery.each(links, function(index, link) {
3793                        t.cubeportfolio.blocksOn.each(function(index1, el) {
3794                            var singlePageInline = jQuery(el).find(t.options.singlePageInlineDelegate + '[href="' + link + '"]');
3795
3796                            if (singlePageInline.length) {
3797                                currentBlock = singlePageInline;
3798                                return false;
3799                            }
3800                        });
3801
3802                        if (currentBlock) {
3803                            return false;
3804                        }
3805                    });
3806
3807                    if (currentBlock) {
3808                        t.cubeportfolio.registerEvent('initFinish', function() {
3809                            t.openSinglePageInline(t.cubeportfolio.blocksOn, currentBlock[0]);
3810                        }, true);
3811                    }
3812                }
3813
3814                return;
3815            }
3816
3817            // create markup, css and add events for lightbox and singlePage
3818            t.createMarkup();
3819
3820            if (type === 'singlePage') {
3821                t.cubeportfolio.registerEvent('resizeWindow', function() {
3822                    if (t.options.singlePageStickyNavigation) {
3823
3824                        var width = t.wrap[0].clientWidth;
3825
3826                        if (width > 0) {
3827                            t.navigationWrap.width(width);
3828
3829                            // set navigation width='window width' to center the divs
3830                            t.navigation.width(width);
3831                        }
3832
3833                    }
3834                });
3835
3836                if (t.options.singlePageDeeplinking) {
3837                    t.url = location.href;
3838
3839                    if (t.url.slice(-1) === '#') {
3840                        t.url = t.url.slice(0, -1);
3841                    }
3842
3843                    var links = t.url.split('#cbp=');
3844                    var url = links.shift(); // remove first item
3845
3846                    jQuery.each(links, function(index, link) {
3847                        t.cubeportfolio.blocksOn.each(function(index1, el) {
3848                            var singlePage = jQuery(el).find(t.options.singlePageDelegate + '[href="' + link + '"]');
3849
3850                            if (singlePage.length) {
3851                                currentBlock = singlePage;
3852                                return false;
3853                            }
3854                        });
3855
3856                        if (currentBlock) {
3857                            return false;
3858                        }
3859                    });
3860
3861                    if (currentBlock) {
3862                        t.url = url;
3863
3864                        var self = currentBlock,
3865                            gallery = self.attr('data-cbp-singlePage'),
3866                            blocks = [];
3867
3868                        if (gallery) {
3869                            blocks = self.closest(jQuery('.cbp-item')).find('[data-cbp-singlePage="' + gallery + '"]');
3870                        } else {
3871                            t.cubeportfolio.blocksOn.each(function(index, el) {
3872                                var item = jQuery(el);
3873
3874                                if (item.not('.cbp-item-off')) {
3875                                    item.find(t.options.singlePageDelegate).each(function(index2, el2) {
3876                                        if (!jQuery(el2).attr('data-cbp-singlePage')) {
3877                                            blocks.push(el2);
3878                                        }
3879                                    });
3880                                }
3881                            });
3882                        }
3883
3884                        t.openSinglePage(blocks, currentBlock[0]);
3885                    } else if (links.length) { // @todo - hack to load items from loadMore
3886                        var fakeLink = document.createElement('a');
3887                        fakeLink.setAttribute('href', links[0]);
3888                        t.openSinglePage([fakeLink], fakeLink);
3889                    }
3890                }
3891            }
3892        },
3893
3894        /**
3895         * Create markup, css and add events
3896         */
3897        createMarkup: function() {
3898            var t = this,
3899                animationCls = '';
3900
3901            if (t.type === 'singlePage') {
3902                if (t.options.singlePageAnimation !== 'left') {
3903                    animationCls = ' cbp-popup-singlePage-' + t.options.singlePageAnimation;
3904                }
3905            }
3906
3907            // wrap element
3908            t.wrap = jQuery('<div/>', {
3909                'class': 'cbp-popup-wrap cbp-popup-' + t.type + animationCls,
3910                'data-action': (t.type === 'lightbox') ? 'close' : ''
3911            }).on('click.cbp', function(e) {
3912                if (t.stopEvents) {
3913                    return;
3914                }
3915
3916                var action = jQuery(e.target).attr('data-action');
3917
3918                if (t[action]) {
3919                    t[action]();
3920                    e.preventDefault();
3921                }
3922            });
3923
3924            // content element
3925            t.content = jQuery('<div/>', {
3926                'class': 'cbp-popup-content'
3927            }).appendTo(t.wrap);
3928
3929            // append loading div
3930            jQuery('<div/>', {
3931                'class': 'cbp-popup-loadingBox'
3932            }).appendTo(t.wrap);
3933
3934            // add background only for ie8
3935            if (CubePortfolio.private.browser === 'ie8') {
3936                t.bg = jQuery('<div/>', {
3937                    'class': 'cbp-popup-ie8bg',
3938                    'data-action': (t.type === 'lightbox') ? 'close' : ''
3939                }).appendTo(t.wrap);
3940            }
3941
3942            // create navigation wrap
3943            t.navigationWrap = jQuery('<div/>', {
3944                'class': 'cbp-popup-navigation-wrap'
3945            }).appendTo(t.wrap);
3946
3947            // create navigation block
3948            t.navigation = jQuery('<div/>', {
3949                'class': 'cbp-popup-navigation'
3950            }).appendTo(t.navigationWrap);
3951
3952            // close
3953            t.closeButton = jQuery('<div/>', {
3954                'class': 'cbp-popup-close',
3955                'title': 'Close (Esc arrow key)',
3956                'data-action': 'close'
3957            }).appendTo(t.navigation);
3958
3959            // next
3960            t.nextButton = jQuery('<div/>', {
3961                'class': 'cbp-popup-next',
3962                'data-action': 'next'
3963            }).appendTo(t.navigation);
3964
3965
3966            // prev
3967            t.prevButton = jQuery('<div/>', {
3968                'class': 'cbp-popup-prev',
3969                'data-action': 'prev'
3970            }).appendTo(t.navigation);
3971
3972
3973            if (t.type === 'singlePage') {
3974                if (t.options.singlePageCounter) {
3975                    // counter for singlePage
3976                    t.counter = jQuery(t.options.singlePageCounter).appendTo(t.navigation);
3977                    t.counter.text('');
3978                }
3979
3980                t.content.on('click.cbp', t.options.singlePageDelegate, function(e) {
3981                    e.preventDefault();
3982
3983                    var i,
3984                        len = t.dataArray.length,
3985                        href = this.getAttribute('href');
3986
3987                    for (i = 0; i < len; i++) {
3988                        if (t.dataArray[i].url === href) {
3989                            break;
3990                        }
3991                    }
3992
3993                    t.singlePageJumpTo(i - t.current);
3994                });
3995
3996                // if there are some events than overrides the default scroll behaviour don't go to them
3997                t.wrap.on('mousewheel.cbp' + ' DOMMouseScroll.cbp', function(e) {
3998                    e.stopImmediatePropagation();
3999                });
4000            }
4001
4002            jQuery(document).on('keydown.cbp', function(e) {
4003                // if is not open => return
4004                if (!t.isOpen) {
4005                    return;
4006                }
4007
4008                // if all events are stopped => return
4009                if (t.stopEvents) {
4010                    return;
4011                }
4012
4013                if (e.keyCode === 37) { // prev key
4014                    t.prev();
4015                } else if (e.keyCode === 39) { // next key
4016                    t.next();
4017                } else if (e.keyCode === 27) { //esc key
4018                    t.close();
4019                }
4020            });
4021        },
4022
4023        createMarkupSinglePageInline: function() {
4024            var t = this;
4025
4026            // wrap element
4027            t.wrap = jQuery('<div/>', {
4028                'class': 'cbp-popup-singlePageInline'
4029            }).on('click.cbp', function(e) {
4030                if (t.stopEvents) {
4031                    return;
4032                }
4033
4034                var action = jQuery(e.target).attr('data-action');
4035
4036                if (action && t[action]) {
4037                    t[action]();
4038                    e.preventDefault();
4039                }
4040            });
4041
4042            // content element
4043            t.content = jQuery('<div/>', {
4044                'class': 'cbp-popup-content'
4045            }).appendTo(t.wrap);
4046
4047            // append loading div
4048            // jQuery('<div/>', {
4049            //     'class': 'cbp-popup-loadingBox'
4050            // }).appendTo(t.wrap);
4051
4052            // create navigation block
4053            t.navigation = jQuery('<div/>', {
4054                'class': 'cbp-popup-navigation'
4055            }).appendTo(t.wrap);
4056
4057            // close
4058            t.closeButton = jQuery('<div/>', {
4059                'class': 'cbp-popup-close',
4060                'title': 'Close (Esc arrow key)',
4061                'data-action': 'close'
4062            }).appendTo(t.navigation);
4063
4064        },
4065
4066        destroy: function() {
4067            var t = this,
4068                body = jQuery('body');
4069
4070            // remove off key down
4071            jQuery(document).off('keydown.cbp');
4072
4073            // external lightbox and singlePageInline
4074            body.off('click.cbp', t.options.lightboxDelegate);
4075            body.off('click.cbp', t.options.singlePageDelegate);
4076
4077            t.content.off('click.cbp', t.options.singlePageDelegate);
4078
4079            t.cubeportfolio.$obj.off('click.cbp', t.options.singlePageInlineDelegate);
4080            t.cubeportfolio.$obj.off('click.cbp', t.options.lightboxDelegate);
4081            t.cubeportfolio.$obj.off('click.cbp', t.options.singlePageDelegate);
4082
4083            t.cubeportfolio.$obj.removeClass('cbp-popup-isOpening');
4084
4085            t.cubeportfolio.$obj.find('.cbp-item').removeClass('cbp-singlePageInline-active');
4086
4087            t.wrap.remove();
4088        },
4089
4090        openLightbox: function(blocks, currentBlock) {
4091            var t = this,
4092                i = 0,
4093                currentBlockHref, tempHref = [],
4094                element;
4095
4096            if (t.isOpen) {
4097                return;
4098            }
4099
4100            // remember that the lightbox is open now
4101            t.isOpen = true;
4102
4103            // remember to stop all events after the lightbox has been shown
4104            t.stopEvents = false;
4105
4106            // array with elements
4107            t.dataArray = [];
4108
4109            // reset current
4110            t.current = null;
4111
4112            currentBlockHref = currentBlock.getAttribute('href');
4113            if (currentBlockHref === null) {
4114                throw new Error('HEI! Your clicked element doesn\'t have a href attribute.');
4115            }
4116
4117            jQuery.each(blocks, function(index, item) {
4118                var href = item.getAttribute('href'),
4119                    src = href, // default if element is image
4120                    type = 'isImage', // default if element is image
4121                    videoLink;
4122
4123                if (jQuery.inArray(href, tempHref) === -1) {
4124                    if (currentBlockHref === href) {
4125                        t.current = i;
4126                    } else if (!t.options.lightboxGallery) {
4127                        return;
4128                    }
4129
4130                    if (/youtube/i.test(href)) {
4131                        videoLink = href.substring(href.lastIndexOf('v=') + 2);
4132
4133                        if (!(/autoplay=/i.test(videoLink))) {
4134                            videoLink += '&autoplay=1';
4135                        }
4136
4137                        videoLink = videoLink.replace(/\?|&/, '?');
4138
4139                        // create new href
4140                        src = '//www.youtube.com/embed/' + videoLink;
4141
4142                        type = 'isYoutube';
4143                    } else if (/vimeo\.com/i.test(href)) {
4144                        videoLink = href.substring(href.lastIndexOf('/') + 1);
4145
4146                        if (!(/autoplay=/i.test(videoLink))) {
4147                            videoLink += '&autoplay=1';
4148                        }
4149
4150                        videoLink = videoLink.replace(/\?|&/, '?');
4151
4152                        // create new href
4153                        src = '//player.vimeo.com/video/' + videoLink;
4154
4155                        type = 'isVimeo';
4156                    } else if (/www\.ted\.com/i.test(href)) {
4157                        // create new href
4158                        src = 'http://embed.ted.com/talks/' + href.substring(href.lastIndexOf('/') + 1) + '.html';
4159
4160                        type = 'isTed';
4161                    } else if (/soundcloud\.com/i.test(href)) {
4162                        // create new href
4163                        src = href;
4164
4165                        type = 'isSoundCloud';
4166                    } else if (/(\.mp4)|(\.ogg)|(\.ogv)|(\.webm)/i.test(href)) {
4167                        if (href.indexOf('|') !== -1) {
4168                            // create new href
4169                            src = href.split('|');
4170                        } else {
4171                            // create new href
4172                            src = href.split('%7C');
4173                        }
4174
4175                        type = 'isSelfHostedVideo';
4176                    } else if (/\.mp3$/i.test(href)) {
4177                        src = href;
4178                        type = 'isSelfHostedAudio';
4179                    }
4180
4181                    t.dataArray.push({
4182                        src: src,
4183                        title: item.getAttribute(t.options.lightboxTitleSrc),
4184                        type: type
4185                    });
4186
4187                    i++;
4188                }
4189
4190                tempHref.push(href);
4191            });
4192
4193            // total numbers of elements
4194            t.counterTotal = t.dataArray.length;
4195
4196            if (t.counterTotal === 1) {
4197                t.nextButton.hide();
4198                t.prevButton.hide();
4199                t.dataActionImg = '';
4200            } else {
4201                t.nextButton.show();
4202                t.prevButton.show();
4203                t.dataActionImg = 'data-action="next"';
4204            }
4205
4206            // append to body
4207            t.wrap.appendTo(document.body);
4208
4209            t.scrollTop = jQuery(window).scrollTop();
4210
4211            t.originalStyle = jQuery('html').attr('style');
4212
4213            jQuery('html').css({
4214                overflow: 'hidden',
4215                paddingRight: window.innerWidth - jQuery(document).width()
4216            });
4217
4218            // show the wrapper (lightbox box)
4219            t.wrap.show();
4220
4221            // get the current element
4222            element = t.dataArray[t.current];
4223
4224            // call function if current element is image or video (iframe)
4225            t[element.type](element);
4226        },
4227
4228        openSinglePage: function(blocks, currentBlock) {
4229            var t = this,
4230                i = 0,
4231                currentBlockHref, tempHref = [];
4232
4233            if (t.isOpen) {
4234                return;
4235            }
4236
4237            // check singlePageInline and close it
4238            if (t.cubeportfolio.singlePageInline && t.cubeportfolio.singlePageInline.isOpen) {
4239                t.cubeportfolio.singlePageInline.close();
4240            }
4241
4242            // remember that the lightbox is open now
4243            t.isOpen = true;
4244
4245            // remember to stop all events after the popup has been showing
4246            t.stopEvents = false;
4247
4248            // array with elements
4249            t.dataArray = [];
4250
4251            // reset current
4252            t.current = null;
4253
4254            currentBlockHref = currentBlock.getAttribute('href');
4255            if (currentBlockHref === null) {
4256                throw new Error('HEI! Your clicked element doesn\'t have a href attribute.');
4257            }
4258
4259            jQuery.each(blocks, function(index, item) {
4260                var href = item.getAttribute('href');
4261
4262                if (jQuery.inArray(href, tempHref) === -1) {
4263                    if (currentBlockHref === href) {
4264                        t.current = i;
4265                    }
4266
4267                    t.dataArray.push({
4268                        url: href,
4269                        element: item
4270                    });
4271
4272                    i++;
4273                }
4274
4275                tempHref.push(href);
4276            });
4277
4278            // total numbers of elements
4279            t.counterTotal = t.dataArray.length;
4280
4281            if (t.counterTotal === 1) {
4282                t.nextButton.hide();
4283                t.prevButton.hide();
4284            } else {
4285                t.nextButton.show();
4286                t.prevButton.show();
4287            }
4288
4289            // append to body
4290            t.wrap.appendTo(document.body);
4291
4292            t.scrollTop = jQuery(window).scrollTop();
4293
4294            jQuery('html').css({
4295                overflow: 'hidden',
4296                paddingRight: window.innerWidth - jQuery(document).width()
4297            });
4298
4299            // go to top of the page (reset scroll)
4300            t.wrap.scrollTop(0);
4301
4302            // show the wrapper
4303            t.wrap.show();
4304
4305            // finish the open animation
4306            t.finishOpen = 2;
4307
4308            // if transitionend is not fulfilled
4309            t.navigationMobile = jQuery();
4310            t.wrap.one(CubePortfolio.private.transitionend, function() {
4311                var width;
4312
4313                // make the navigation sticky
4314                if (t.options.singlePageStickyNavigation) {
4315
4316                    t.wrap.addClass('cbp-popup-singlePage-sticky');
4317
4318                    width = t.wrap[0].clientWidth;
4319                    t.navigationWrap.width(width);
4320
4321                    if (CubePortfolio.private.browser === 'android' || CubePortfolio.private.browser === 'ios') {
4322                        // wrap element
4323                        t.navigationMobile = jQuery('<div/>', {
4324                            'class': 'cbp-popup-singlePage cbp-popup-singlePage-sticky',
4325                            'id': t.wrap.attr('id')
4326                        }).on('click.cbp', function(e) {
4327                            if (t.stopEvents) {
4328                                return;
4329                            }
4330
4331                            var action = jQuery(e.target).attr('data-action');
4332
4333                            if (t[action]) {
4334                                t[action]();
4335                                e.preventDefault();
4336                            }
4337                        });
4338
4339                        t.navigationMobile.appendTo(document.body).append(t.navigationWrap);
4340                    }
4341                }
4342
4343                t.finishOpen--;
4344
4345                if (t.finishOpen <= 0) {
4346                    t.updateSinglePageIsOpen.call(t);
4347                }
4348            });
4349
4350            if (CubePortfolio.private.browser === 'ie8' || CubePortfolio.private.browser === 'ie9') {
4351                // make the navigation sticky
4352                if (t.options.singlePageStickyNavigation) {
4353                    var width = t.wrap[0].clientWidth;
4354
4355                    t.navigationWrap.width(width);
4356
4357                    setTimeout(function() {
4358                        t.wrap.addClass('cbp-popup-singlePage-sticky');
4359                    }, 1000);
4360                }
4361
4362                t.finishOpen--;
4363            }
4364
4365            t.wrap.addClass('cbp-popup-loading');
4366
4367            // force reflow and then add class
4368            t.wrap.offset();
4369            t.wrap.addClass('cbp-popup-singlePage-open');
4370
4371            // change link
4372            if (t.options.singlePageDeeplinking) {
4373                // ignore old #cbp from href
4374                t.url = t.url.split('#cbp=')[0];
4375                location.href = t.url + '#cbp=' + t.dataArray[t.current].url;
4376            }
4377
4378            // run callback function
4379            if (jQuery.isFunction(t.options.singlePageCallback)) {
4380                t.options.singlePageCallback.call(t, t.dataArray[t.current].url, t.dataArray[t.current].element);
4381            }
4382        },
4383
4384        openSinglePageInline: function(blocks, currentBlock, fromOpen) {
4385            var t = this,
4386                start = 0,
4387                currentBlockHref,
4388                tempCurrent,
4389                cbpitem,
4390                parentElement;
4391                
4392                //TREETHEMES
4393            window.lastcube = t;
4394
4395            fromOpen = fromOpen || false;
4396
4397            t.fromOpen = fromOpen;
4398
4399            t.storeBlocks = blocks;
4400            t.storeCurrentBlock = currentBlock;
4401            
4402            jQuery('body').addClass('cbp-animating');
4403
4404            // check singlePageInline and close it
4405            if (t.isOpen) {
4406                tempCurrent = jQuery(currentBlock).closest('.cbp-item').index();
4407
4408                if ((t.dataArray[t.current].url !== currentBlock.getAttribute('href')) || (t.current !== tempCurrent)) {
4409                    t.cubeportfolio.singlePageInline.close('open', {
4410                        blocks: blocks,
4411                        currentBlock: currentBlock,
4412                        fromOpen: true
4413                    });
4414                } else {
4415                    t.close();
4416                }
4417
4418                return;
4419            }
4420
4421            // remember that the lightbox is open now
4422            t.isOpen = true;
4423
4424            // remember to stop all events after the popup has been showing
4425            t.stopEvents = false;
4426
4427            // array with elements
4428            t.dataArray = [];
4429
4430            // reset current
4431            t.current = null;
4432
4433            currentBlockHref = currentBlock.getAttribute('href');
4434            if (currentBlockHref === null) {
4435                throw new Error('HEI! Your clicked element doesn\'t have a href attribute.');
4436            }
4437
4438            cbpitem = jQuery(currentBlock).closest('.cbp-item')[0];
4439
4440            blocks.each(function(index, el) {
4441                if (cbpitem === el) {
4442                    t.current = index;
4443                }
4444            });
4445
4446            t.dataArray[t.current] = {
4447                url: currentBlockHref,
4448                element: currentBlock
4449            };
4450
4451            parentElement = jQuery(t.dataArray[t.current].element).parents('.cbp-item').addClass('cbp-singlePageInline-active');
4452
4453            // total numbers of elements
4454            t.counterTotal = blocks.length;
4455
4456            t.wrap.insertBefore(t.cubeportfolio.wrapper);
4457
4458            if (t.options.singlePageInlinePosition === 'top') {
4459                t.blocksToMove = blocks;
4460                t.top = 0;
4461            } else if (t.options.singlePageInlinePosition === 'bottom') {
4462                t.blocksToMove = jQuery();
4463                t.top = t.cubeportfolio.height;
4464            } else if (t.options.singlePageInlinePosition === 'above') {
4465                t.top = jQuery(blocks[t.current]).data('cbp').top;
4466                t.blocksToMove = jQuery();
4467
4468                blocks.each(function(index, el) {
4469                    var data = jQuery(el).data('cbp');
4470
4471                    if ((data.top + data.height) >= t.top) {
4472                        t.blocksToMove = t.blocksToMove.add(el);
4473                    }
4474                });
4475
4476                t.top = Math.max(t.top - t.options.gapHorizontal, 0);
4477            } else { // below
4478                var dataBlock = jQuery(blocks[t.current]).data('cbp');
4479
4480                t.top = dataBlock.top + dataBlock.height;
4481                t.blocksToMove = jQuery();
4482
4483                blocks.each(function(index, el) {
4484                    var data = jQuery(el).data('cbp');
4485
4486                    if ((data.top + data.height) > t.top) {
4487                        t.blocksToMove = t.blocksToMove.add(el);
4488                    }
4489                });
4490            }
4491
4492            t.wrap[0].style.height = t.wrap.outerHeight(true) + 'px';
4493
4494            // debouncer for inline content
4495            t.deferredInline = jQuery.Deferred();
4496
4497            if (t.options.singlePageInlineInFocus) {
4498                t.scrollTop = jQuery(window).scrollTop();
4499
4500                var goToScroll = t.cubeportfolio.$obj.offset().top + t.top - 100;
4501
4502                if (t.scrollTop !== goToScroll) {
4503                    jQuery('html,body').animate({
4504                            scrollTop: goToScroll
4505                        }, 350)
4506                        .promise()
4507                        .then(function() {
4508                            t.resizeSinglePageInline();
4509                            t.deferredInline.resolve();
4510                        });
4511                } else {
4512                    t.resizeSinglePageInline();
4513                    t.deferredInline.resolve();
4514                }
4515            } else {
4516                t.resizeSinglePageInline();
4517                t.deferredInline.resolve();
4518            }
4519
4520            t.cubeportfolio.$obj.addClass('cbp-popup-singlePageInline-open');
4521
4522            t.wrap.css({
4523                top: t.top
4524            });
4525
4526            // change link
4527            if (t.options.singlePageInlineDeeplinking) {
4528                // ignore old #cbpi from href
4529                t.url = t.url.split('#cbpi=')[0];
4530                location.href = t.url + '#cbpi=' + t.dataArray[t.current].url;
4531            }
4532
4533            // register callback function
4534            if (jQuery.isFunction(t.options.singlePageInlineCallback)) {
4535                t.options.singlePageInlineCallback.call(t, t.dataArray[t.current].url, t.dataArray[t.current].element);
4536            }
4537        },
4538
4539        resizeSinglePageInline: function() {
4540            var t = this;
4541
4542            t.height = ((t.top === 0) || (t.top === t.cubeportfolio.height)) ? t.wrap.outerHeight(true) : t.wrap.outerHeight(true) - t.options.gapHorizontal;
4543
4544            t.storeBlocks.each(function(index, el) {
4545                if (CubePortfolio.private.modernBrowser) {
4546                    el.style[CubePortfolio.private.transform] = '';
4547                } else {
4548                    el.style.marginTop = '';
4549                }
4550            });
4551
4552            t.blocksToMove.each(function(index, el) {
4553                if (CubePortfolio.private.modernBrowser) {
4554                    el.style[CubePortfolio.private.transform] = 'translate3d(0px, ' + t.height + 'px, 0)';
4555                } else {
4556                    el.style.marginTop = t.height + 'px';
4557                }
4558            });
4559
4560            t.cubeportfolio.obj.style.height = t.cubeportfolio.height + t.height + 'px';
4561        },
4562
4563        revertResizeSinglePageInline: function() {
4564            var t = this;
4565
4566            // reset deferred object
4567            t.deferredInline = jQuery.Deferred();
4568
4569            t.storeBlocks.each(function(index, el) {
4570                if (CubePortfolio.private.modernBrowser) {
4571                    el.style[CubePortfolio.private.transform] = '';
4572                } else {
4573                    el.style.marginTop = '';
4574                }
4575            });
4576
4577            t.cubeportfolio.obj.style.height = t.cubeportfolio.height + 'px';
4578        },
4579
4580        appendScriptsToWrap: function(scripts) {
4581	        
4582	        //(scripts);
4583	        
4584            var t = this,
4585                index = 0,
4586                loadScripts = function(item) {
4587	                
4588	                try{
4589		                var script = document.createElement('script'),
4590	                        src = item.src;
4591	
4592	                    script.type = 'text/javascript';
4593	
4594	                    if (script.readyState) { // ie
4595	                        script.onreadystatechange = function() {
4596	                            if (script.readyState == 'loaded' || script.readyState == 'complete') {
4597	                                script.onreadystatechange = null;
4598	                                index++;
4599	                                if (scripts[index]) {
4600	                                    loadScripts(scripts[index]);
4601	                                }
4602	                            }
4603	                        };
4604	                    } else {
4605	                        script.onload = function() {
4606	                            index++;
4607	                            if (scripts[index]) {
4608	                                loadScripts(scripts[index]);
4609	                            }
4610	                        };
4611	                    }
4612	
4613	                    if (src) {
4614	                        script.src = src;
4615	                    } else {
4616	                        script.text = item.text;
4617	                    }
4618	
4619	                    t.content[0].appendChild(script);
4620	                } catch(err){
4621		                console.log(index);
4622		                console.log(script);
4623		                console.log(err);
4624	                }
4625
4626                };
4627
4628            loadScripts(scripts[0]);
4629        },
4630
4631        updateSinglePage: function(html, scripts, isWrap) {
4632            var t = this,
4633                counterMarkup,
4634                animationFinish;
4635
4636            t.content.addClass('cbp-popup-content').removeClass('cbp-popup-content-basic');
4637
4638            if (isWrap === false) {
4639                t.content.removeClass('cbp-popup-content').addClass('cbp-popup-content-basic');
4640            }
4641
4642            // update counter navigation
4643            if (t.counter) {
4644                counterMarkup = jQuery(t.getCounterMarkup(t.options.singlePageCounter, t.current + 1, t.counterTotal));
4645                t.counter.text(counterMarkup.text());
4646            }
4647
4648            t.content.html(html);
4649
4650            if (scripts) {
4651                t.appendScriptsToWrap(scripts);
4652            }
4653
4654            // trigger public event
4655            t.cubeportfolio.$obj.trigger('updateSinglePageStart.cbp');
4656
4657            t.finishOpen--;
4658
4659            if (t.finishOpen <= 0) {
4660                t.updateSinglePageIsOpen.call(t);
4661            }
4662        },
4663
4664        updateSinglePageIsOpen: function() {
4665            var t = this,
4666                selectorSlider;
4667
4668            t.wrap.addClass('cbp-popup-ready');
4669            t.wrap.removeClass('cbp-popup-loading');
4670
4671            // instantiate slider if exists
4672            selectorSlider = t.content.find('.cbp-slider');
4673            if (selectorSlider) {
4674                selectorSlider.find('.cbp-slider-item').addClass('cbp-item');
4675                t.slider = selectorSlider.cubeportfolio({
4676                    layoutMode: 'slider',
4677                    mediaQueries: [{
4678                        width: 1,
4679                        cols: 1
4680                    }],
4681                    gapHorizontal: 0,
4682                    gapVertical: 0,
4683                    caption: '',
4684                    coverRatio: '', // wp version only
4685                });
4686            } else {
4687                t.slider = null;
4688            }
4689
4690            // scroll bug on android and ios
4691            if (CubePortfolio.private.browser === 'android' || CubePortfolio.private.browser === 'ios') {
4692                jQuery('html').css({
4693                    position: 'fixed'
4694                });
4695            }
4696
4697            // trigger public event
4698            t.cubeportfolio.$obj.trigger('updateSinglePageComplete.cbp');
4699        },
4700
4701        updateSinglePageInline: function(html, scripts) {
4702            var t = this;
4703
4704            t.content.html(html);
4705
4706            if (scripts) {
4707                t.appendScriptsToWrap(scripts);
4708            }
4709            // trigger public event
4710            t.cubeportfolio.$obj.trigger('updateSinglePageInlineStart.cbp');
4711
4712            t.singlePageInlineIsOpen.call(t);
4713        },
4714
4715        singlePageInlineIsOpen: function() {
4716            var t = this;
4717
4718            function finishLoading() {
4719                t.wrap.addClass('cbp-popup-singlePageInline-ready');
4720                t.wrap[0].style.height = '';
4721
4722                t.resizeSinglePageInline();
4723
4724                // trigger public event
4725                t.cubeportfolio.$obj.trigger('updateSinglePageInlineComplete.cbp');
4726            }
4727
4728            // wait to load all images
4729            t.cubeportfolio.loadImages(t.wrap, function() {
4730                // instantiate slider if exists
4731                var selectorSlider = t.content.find('.cbp-slider');
4732
4733                if (selectorSlider.length) {
4734                    selectorSlider.find('.cbp-slider-item').addClass('cbp-item');
4735
4736                    selectorSlider.one('initComplete.cbp', function() {
4737                        t.deferredInline.done(finishLoading);
4738                    });
4739
4740                    selectorSlider.on('pluginResize.cbp', function() {
4741                        t.deferredInline.done(finishLoading);
4742                    });
4743
4744                    t.slider = selectorSlider.cubeportfolio({
4745                        layoutMode: 'slider',
4746                        displayType: 'default',
4747                        mediaQueries: [{
4748                            width: 1,
4749                            cols: 1
4750                        }],
4751                        gapHorizontal: 0,
4752                        gapVertical: 0,
4753                        caption: '',
4754                        coverRatio: '', // wp version only
4755                    });
4756                } else {
4757                    t.slider = null;
4758                    t.deferredInline.done(finishLoading);
4759                }
4760            });
4761        },
4762
4763        isImage: function(el) {
4764            var t = this,
4765                img = new Image();
4766
4767            t.tooggleLoading(true);
4768
4769            t.cubeportfolio.loadImages(jQuery('<div><img src="' + el.src + '"></div>'), function() {
4770                t.updateImagesMarkup(el.src, el.title, t.getCounterMarkup(t.options.lightboxCounter, t.current + 1, t.counterTotal));
4771
4772                t.tooggleLoading(false);
4773            });
4774        },
4775
4776        isVimeo: function(el) {
4777            var t = this;
4778            t.updateVideoMarkup(el.src, el.title, t.getCounterMarkup(t.options.lightboxCounter, t.current + 1, t.counterTotal));
4779        },
4780
4781        isYoutube: function(el) {
4782            var t = this;
4783            t.updateVideoMarkup(el.src, el.title, t.getCounterMarkup(t.options.lightboxCounter, t.current + 1, t.counterTotal));
4784
4785        },
4786
4787        isTed: function(el) {
4788            var t = this;
4789            t.updateVideoMarkup(el.src, el.title, t.getCounterMarkup(t.options.lightboxCounter, t.current + 1, t.counterTotal));
4790        },
4791
4792        isSoundCloud: function(el) {
4793            var t = this;
4794            t.updateVideoMarkup(el.src, el.title, t.getCounterMarkup(t.options.lightboxCounter, t.current + 1, t.counterTotal));
4795        },
4796
4797        isSelfHostedVideo: function(el) {
4798            var t = this;
4799            t.updateSelfHostedVideo(el.src, el.title, t.getCounterMarkup(t.options.lightboxCounter, t.current + 1, t.counterTotal));
4800        },
4801
4802        isSelfHostedAudio: function(el) {
4803            var t = this;
4804            t.updateSelfHostedAudio(el.src, el.title, t.getCounterMarkup(t.options.lightboxCounter, t.current + 1, t.counterTotal));
4805        },
4806
4807        getCounterMarkup: function(markup, current, total) {
4808            if (!markup.length) {
4809                return '';
4810            }
4811
4812            var mapObj = {
4813                current: current,
4814                total: total
4815            };
4816
4817            return markup.replace(/\{\{current}}|\{\{total}}/gi, function(matched) {
4818                return mapObj[matched.slice(2, -2)];
4819            });
4820        },
4821
4822        updateSelfHostedVideo: function(src, title, counter) {
4823            var t = this,
4824                i;
4825
4826            t.wrap.addClass('cbp-popup-lightbox-isIframe');
4827
4828            var markup = '<div class="cbp-popup-lightbox-iframe">' +
4829                '<video controls="controls" height="auto" style="width: 100%">';
4830
4831            for (i = 0; i < src.length; i++) {
4832                if (/(\.mp4)/i.test(src[i])) {
4833                    markup += '<source src="' + src[i] + '" type="video/mp4">';
4834                } else if (/(\.ogg)|(\.ogv)/i.test(src[i])) {
4835                    markup += '<source src="' + src[i] + '" type="video/ogg">';
4836                } else if (/(\.webm)/i.test(src[i])) {
4837                    markup += '<source src="' + src[i] + '" type="video/webm">';
4838                }
4839            }
4840
4841            markup += 'Your browser does not support the video tag.' +
4842                '</video>' +
4843                '<div class="cbp-popup-lightbox-bottom">' +
4844                ((title) ? '<div class="cbp-popup-lightbox-title">' + title + '</div>' : '') +
4845                counter +
4846                '</div>' +
4847                '</div>';
4848
4849            t.content.html(markup);
4850            t.wrap.addClass('cbp-popup-ready');
4851            t.preloadNearbyImages();
4852        },
4853
4854        updateSelfHostedAudio: function(src, title, counter) {
4855            var t = this,
4856                i;
4857
4858            t.wrap.addClass('cbp-popup-lightbox-isIframe');
4859
4860            var markup = '<div class="cbp-popup-lightbox-iframe">' +
4861                '<div class="cbp-misc-video"><audio controls="controls" height="auto" style="width: 75%">' +
4862                '<source src="' + src + '" type="audio/mpeg">' +
4863                'Your browser does not support the audio tag.' +
4864                '</audio></div>' +
4865                '<div class="cbp-popup-lightbox-bottom">' +
4866                ((title) ? '<div class="cbp-popup-lightbox-title">' + title + '</div>' : '') +
4867                counter +
4868                '</div>' +
4869                '</div>';
4870
4871            t.content.html(markup);
4872            t.wrap.addClass('cbp-popup-ready');
4873            t.preloadNearbyImages();
4874        },
4875
4876        updateVideoMarkup: function(src, title, counter) {
4877            var t = this;
4878            t.wrap.addClass('cbp-popup-lightbox-isIframe');
4879
4880            var markup = '<div class="cbp-popup-lightbox-iframe">' +
4881                '<iframe src="' + src + '" frameborder="0" allowfullscreen scrolling="no"></iframe>' +
4882                '<div class="cbp-popup-lightbox-bottom">' +
4883                ((title) ? '<div class="cbp-popup-lightbox-title">' + title + '</div>' : '') +
4884                counter +
4885                '</div>' +
4886                '</div>';
4887
4888            t.content.html(markup);
4889            t.wrap.addClass('cbp-popup-ready');
4890            t.preloadNearbyImages();
4891        },
4892
4893        updateImagesMarkup: function(src, title, counter) {
4894            var t = this;
4895
4896            t.wrap.removeClass('cbp-popup-lightbox-isIframe');
4897
4898            var markup = '<div class="cbp-popup-lightbox-figure">' +
4899                '<img src="' + src + '" class="cbp-popup-lightbox-img" ' + t.dataActionImg + ' />' +
4900                '<div class="cbp-popup-lightbox-bottom">' +
4901                ((title) ? '<div class="cbp-popup-lightbox-title">' + title + '</div>' : '') +
4902                counter +
4903                '</div>' +
4904                '</div>';
4905
4906            t.content.html(markup);
4907            t.wrap.addClass('cbp-popup-ready');
4908            t.resizeImage();
4909            t.preloadNearbyImages();
4910        },
4911
4912        next: function() {
4913            var t = this;
4914            t[t.type + 'JumpTo'](1);
4915        },
4916
4917        prev: function() {
4918            var t = this;
4919            t[t.type + 'JumpTo'](-1);
4920        },
4921
4922        lightboxJumpTo: function(index) {
4923            var t = this,
4924                el;
4925
4926            t.current = t.getIndex(t.current + index);
4927
4928            // get the current element
4929            el = t.dataArray[t.current];
4930
4931            // call function if current element is image or video (iframe)
4932            t[el.type](el);
4933        },
4934
4935
4936        singlePageJumpTo: function(index) {
4937            var t = this;
4938
4939            t.current = t.getIndex(t.current + index);
4940
4941            // register singlePageCallback function
4942            if (jQuery.isFunction(t.options.singlePageCallback)) {
4943                t.resetWrap();
4944
4945                // go to top of the page (reset scroll)
4946                t.wrap.scrollTop(0);
4947
4948                t.wrap.addClass('cbp-popup-loading');
4949                t.options.singlePageCallback.call(t, t.dataArray[t.current].url, t.dataArray[t.current].element);
4950
4951                if (t.options.singlePageDeeplinking) {
4952                    location.href = t.url + '#cbp=' + t.dataArray[t.current].url;
4953                }
4954            }
4955        },
4956
4957        resetWrap: function() {
4958            var t = this;
4959
4960            if (t.type === 'singlePage' && t.options.singlePageDeeplinking) {
4961                location.href = t.url + '#';
4962            }
4963
4964            if (t.type === 'singlePageInline' && t.options.singlePageInlineDeeplinking) {
4965                location.href = t.url + '#';
4966            }
4967            
4968            
4969            jQuery('body').removeClass('cbp-animating');
4970        },
4971
4972        getIndex: function(index) {
4973            var t = this;
4974
4975            // go to interval [0, (+ or -)this.counterTotal.length - 1]
4976            index = index % t.counterTotal;
4977
4978            // if index is less then 0 then go to interval (0, this.counterTotal - 1]
4979            if (index < 0) {
4980                index = t.counterTotal + index;
4981            }
4982
4983            return index;
4984        },
4985
4986        close: function(method, data) {
4987            var t = this;
4988            
4989            jQuery('body').addClass('cbp-animating');
4990
4991            function finishClose() {
4992                // reset content
4993                t.content.html('');
4994
4995                // hide the wrap
4996                t.wrap.detach();
4997
4998                t.cubeportfolio.$obj.removeClass('cbp-popup-singlePageInline-open cbp-popup-singlePageInline-close');
4999				
5000                if (method === 'promise') {
5001                    if (jQuery.isFunction(data.callback)) {
5002                        data.callback.call(t.cubeportfolio);
5003                    }
5004                }
5005
5006                t.resetWrap();
5007            }
5008
5009            function checkFocusInline() {
5010                if (t.options.singlePageInlineInFocus && method !== 'promise') {
5011                    jQuery('html,body').animate({
5012                            scrollTop: t.scrollTop
5013                        }, 350)
5014                        .promise()
5015                        .then(function() {
5016                            finishClose();
5017                        });
5018                } else {
5019                    finishClose();
5020                }
5021            }
5022
5023            // now the popup is closed
5024            t.isOpen = false;
5025
5026            if (t.type === 'singlePageInline') {
5027                if (method === 'open') {
5028                    t.wrap.removeClass('cbp-popup-singlePageInline-ready');
5029                    jQuery(t.dataArray[t.current].element).closest('.cbp-item').removeClass('cbp-singlePageInline-active');
5030                    t.openSinglePageInline(data.blocks, data.currentBlock, data.fromOpen);
5031                } else {
5032                    t.height = 0;
5033
5034                    t.revertResizeSinglePageInline();
5035                    t.wrap.removeClass('cbp-popup-singlePageInline-ready');
5036                    t.cubeportfolio.$obj.addClass('cbp-popup-singlePageInline-close');
5037                    t.cubeportfolio.$obj.find('.cbp-item').removeClass('cbp-singlePageInline-active');
5038
5039                    if (CubePortfolio.private.modernBrowser) {
5040                        t.wrap.one(CubePortfolio.private.transitionend, function() {
5041                            checkFocusInline();
5042                        });
5043                    } else {
5044                        checkFocusInline();
5045                    }
5046                }
5047
5048            } else if (t.type === 'singlePage') {
5049                t.resetWrap();
5050
5051                t.wrap.removeClass('cbp-popup-ready');
5052
5053                // scroll bug on android and ios
5054                if (CubePortfolio.private.browser === 'android' || CubePortfolio.private.browser === 'ios') {
5055                    jQuery('html').css({
5056                        position: ''
5057                    });
5058
5059                    t.navigationWrap.appendTo(t.wrap);
5060                    t.navigationMobile.remove();
5061                }
5062
5063                jQuery(window).scrollTop(t.scrollTop);
5064
5065                // weird bug on mozilla. fixed with setTimeout
5066                setTimeout(function() {
5067                    t.stopScroll = true;
5068
5069                    t.navigationWrap.css({
5070                        top: t.wrap.scrollTop()
5071                    });
5072
5073                    t.wrap.removeClass('cbp-popup-singlePage-open cbp-popup-singlePage-sticky');
5074
5075                    if (CubePortfolio.private.browser === 'ie8' || CubePortfolio.private.browser === 'ie9') {
5076                        // reset content
5077                        t.content.html('');
5078
5079                        // hide the wrap
5080                        t.wrap.detach();
5081
5082                        jQuery('html').css({
5083                            overflow: '',
5084                            paddingRight: '',
5085                            position: ''
5086                        });
5087
5088                        t.navigationWrap.removeAttr('style');
5089                    }
5090                }, 0);
5091
5092                t.wrap.one(CubePortfolio.private.transitionend, function() {
5093                    // reset content
5094                    t.content.html('');
5095
5096                    // hide the wrap
5097                    t.wrap.detach();
5098
5099                    jQuery('html').css({
5100                        overflow: '',
5101                        paddingRight: '',
5102                        position: ''
5103                    });
5104
5105                    t.navigationWrap.removeAttr('style');
5106                });
5107            } else {
5108                if (t.originalStyle) {
5109                    jQuery('html').attr('style', t.originalStyle);
5110                } else {
5111                    jQuery('html').css({
5112                        overflow: '',
5113                        paddingRight: ''
5114                    });
5115                }
5116
5117                jQuery(window).scrollTop(t.scrollTop);
5118
5119                // reset content
5120                t.content.html('');
5121
5122                // hide the wrap
5123                t.wrap.detach();
5124            }
5125        },
5126
5127        tooggleLoading: function(state) {
5128            var t = this;
5129
5130            t.stopEvents = state;
5131            t.wrap[(state) ? 'addClass' : 'removeClass']('cbp-popup-loading');
5132        },
5133
5134        resizeImage: function() {
5135            // if lightbox is not open go out
5136            if (!this.isOpen) {
5137                return;
5138            }
5139
5140            var height = jQuery(window).height(),
5141                img = this.content.find('img'),
5142                padding = parseInt(img.css('margin-top'), 10) + parseInt(img.css('margin-bottom'), 10);
5143
5144            img.css('max-height', (height - padding) + 'px');
5145        },
5146
5147        preloadNearbyImages: function() {
5148            var arr = [],
5149                img, t = this,
5150                src;
5151
5152            arr.push(t.getIndex(t.current + 1));
5153            arr.push(t.getIndex(t.current + 2));
5154            arr.push(t.getIndex(t.current + 3));
5155            arr.push(t.getIndex(t.current - 1));
5156            arr.push(t.getIndex(t.current - 2));
5157            arr.push(t.getIndex(t.current - 3));
5158
5159            for (var i = arr.length - 1; i >= 0; i--) {
5160                if (t.dataArray[arr[i]].type === 'isImage') {
5161                    t.cubeportfolio.checkSrc(t.dataArray[arr[i]].src);
5162                }
5163            }
5164        }
5165    };
5166
5167    function Plugin(parent) {
5168        var t = this;
5169
5170        t.parent = parent;
5171
5172        // if lightboxShowCounter is false, put lightboxCounter to ''
5173        if (parent.options.lightboxShowCounter === false) {
5174            parent.options.lightboxCounter = '';
5175        }
5176
5177        // if singlePageShowCounter is false, put singlePageCounter to ''
5178        if (parent.options.singlePageShowCounter === false) {
5179            parent.options.singlePageCounter = '';
5180        }
5181
5182        // @todo - schedule this in  future
5183        parent.registerEvent('initStartRead', function() {
5184            t.run();
5185        }, true);
5186    }
5187
5188    var lightboxInit = false,
5189        singlePageInit = false;
5190
5191    Plugin.prototype.run = function() {
5192        var t = this,
5193            p = t.parent,
5194            body = jQuery(document.body);
5195
5196        // default value for lightbox
5197        p.lightbox = null;
5198
5199        // LIGHTBOX
5200        if (p.options.lightboxDelegate && !lightboxInit) {
5201            // init only one time @todo
5202            lightboxInit = true;
5203
5204            p.lightbox = Object.create(popup);
5205            p.lightbox.init(p, 'lightbox');
5206
5207            body.on('click.cbp', p.options.lightboxDelegate, function(e) {
5208                e.preventDefault();
5209
5210                var self = jQuery(this),
5211                    gallery = self.attr('data-cbp-lightbox'),
5212                    scope = t.detectScope(self),
5213                    cbp = scope.data('cubeportfolio'),
5214                    blocks = [];
5215
5216                // is inside a cbp
5217                if (cbp) {
5218                    cbp.blocksOn.each(function(index, el) {
5219                        var item = jQuery(el);
5220
5221                        if (item.not('.cbp-item-off')) {
5222                            item.find(p.options.lightboxDelegate).each(function(index2, el2) {
5223                                if (gallery) {
5224                                    if (jQuery(el2).attr('data-cbp-lightbox') === gallery) {
5225                                        blocks.push(el2);
5226                                    }
5227                                } else {
5228                                    blocks.push(el2);
5229                                }
5230                            });
5231                        }
5232                    });
5233                } else {
5234                    if (gallery) {
5235                        blocks = scope.find(p.options.lightboxDelegate + '[data-cbp-lightbox=' + gallery + ']');
5236                    } else {
5237                        blocks = scope.find(p.options.lightboxDelegate);
5238                    }
5239                }
5240
5241                p.lightbox.openLightbox(blocks, self[0]);
5242            });
5243        }
5244
5245        // default value for singlePage
5246        p.singlePage = null;
5247
5248        // SINGLEPAGE
5249        if (p.options.singlePageDelegate && !singlePageInit) {
5250            // init only one time @todo
5251            singlePageInit = true;
5252
5253            p.singlePage = Object.create(popup);
5254            p.singlePage.init(p, 'singlePage');
5255
5256            body.on('click.cbp', p.options.singlePageDelegate, function(e) {
5257                e.preventDefault();
5258
5259                var self = jQuery(this),
5260                    gallery = self.attr('data-cbp-singlePage'),
5261                    scope = t.detectScope(self),
5262                    cbp = scope.data('cubeportfolio'),
5263                    blocks = [];
5264
5265                // is inside a cbp
5266                if (cbp) {
5267                    cbp.blocksOn.each(function(index, el) {
5268                        var item = jQuery(el);
5269
5270                        if (item.not('.cbp-item-off')) {
5271                            item.find(p.options.singlePageDelegate).each(function(index2, el2) {
5272                                if (gallery) {
5273                                    if (jQuery(el2).attr('data-cbp-singlePage') === gallery) {
5274                                        blocks.push(el2);
5275                                    }
5276                                } else {
5277                                    blocks.push(el2);
5278                                }
5279                            });
5280                        }
5281                    });
5282                } else {
5283                    if (gallery) {
5284                        blocks = scope.find(p.options.singlePageDelegate + '[data-cbp-singlePage=' + gallery + ']');
5285                    } else {
5286                        blocks = scope.find(p.options.singlePageDelegate);
5287                    }
5288                }
5289
5290                p.singlePage.openSinglePage(blocks, self[0]);
5291            });
5292        }
5293
5294        // default value for singlePageInline
5295        p.singlePageInline = null;
5296
5297        // SINGLEPAGEINLINE
5298        if (p.options.singlePageDelegate) {
5299            p.singlePageInline = Object.create(popup);
5300
5301            p.singlePageInline.init(p, 'singlePageInline');
5302
5303            p.$obj.on('click.cbp', p.options.singlePageInlineDelegate, function(e) {
5304                e.preventDefault();
5305                p.singlePageInline.openSinglePageInline(p.blocksOn, this);
5306            });
5307        }
5308    };
5309
5310    Plugin.prototype.detectScope = function(item) {
5311        var singlePageInline,
5312            singlePage,
5313            cbp;
5314
5315        singlePageInline = item.closest('.cbp-popup-singlePageInline');
5316        if (singlePageInline.length) {
5317            cbp = item.closest('.cbp', singlePageInline[0]);
5318            return (cbp.length) ? cbp : singlePageInline;
5319        }
5320
5321        singlePage = item.closest('.cbp-popup-singlePage');
5322        if (singlePage.length) {
5323            cbp = item.closest('.cbp', singlePage[0]);
5324            return (cbp.length) ? cbp : singlePage;
5325        }
5326
5327        cbp = item.closest('.cbp');
5328        return (cbp.length) ? cbp : jQuery(document.body);
5329
5330    };
5331
5332    Plugin.prototype.destroy = function() {
5333        var p = this.parent;
5334
5335        jQuery(document.body).off('click.cbp');
5336
5337        // @todo - remove these from here
5338        lightboxInit = false;
5339        singlePageInit = false;
5340
5341        // destroy lightbox if enabled
5342        if (p.lightbox) {
5343            p.lightbox.destroy();
5344        }
5345
5346        // destroy singlePage if enabled
5347        if (p.singlePage) {
5348            p.singlePage.destroy();
5349        }
5350
5351        // destroy singlePage inline if enabled
5352        if (p.singlePageInline) {
5353            p.singlePageInline.destroy();
5354        }
5355    };
5356
5357    CubePortfolio.plugins.popUp = function(parent) {
5358        return new Plugin(parent);
5359    };
5360})(jQuery, window, document);
5361
5362(function($, window, document, undefined) {
5363    'use strict';
5364
5365    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
5366
5367    function Plugin(parent) {
5368        var t = this;
5369
5370        t.parent = parent;
5371
5372        t.searchInput = jQuery(parent.options.search);
5373
5374        t.searchInput.each(function(index, el) {
5375            var selector = el.getAttribute('data-search');
5376
5377            if (!selector) {
5378                selector = '*';
5379            }
5380
5381            jQuery.data(el, 'searchData', {
5382                value: el.value,
5383                el: selector
5384            });
5385        });
5386
5387        var timeout = null;
5388
5389        t.searchInput.on('keyup.cbp paste.cbp', function(e) {
5390            e.preventDefault();
5391
5392            var el = jQuery(this);
5393
5394            clearTimeout(timeout);
5395            timeout = setTimeout(function() {
5396                t.runEvent.call(t, el);
5397            }, 300);
5398        });
5399
5400        t.searchNothing = t.searchInput.siblings('.cbp-search-nothing').detach();
5401        t.searchNothingHeight = null;
5402        t.searchNothingHTML = t.searchNothing.html();
5403
5404        t.searchInput.siblings('.cbp-search-icon').on('click.cbp', function(e) {
5405            e.preventDefault();
5406
5407            t.runEvent.call(t, jQuery(this).prev().val(''));
5408        });
5409    }
5410
5411    Plugin.prototype.runEvent = function(el) {
5412        var t = this,
5413            value = el.val(),
5414            searchData = el.data('searchData'),
5415            reg = new RegExp(value, 'i');
5416
5417        if (searchData.value === value || t.parent.isAnimating) {
5418            return;
5419        }
5420
5421        searchData.value = value;
5422
5423        if (value.length > 0) {
5424            el.attr('value', value);
5425        } else {
5426            el.removeAttr('value');
5427        }
5428
5429        t.parent.$obj.cubeportfolio('filter', function(blocks) {
5430            var blocksNew = blocks.filter(function(index, block) {
5431                var text = jQuery(block).find(searchData.el).text();
5432
5433                if (text.search(reg) > -1) {
5434                    return true;
5435                }
5436            });
5437
5438            if (blocksNew.length === 0 && t.searchNothing.length) {
5439                var innerText = t.searchNothingHTML.replace('{{query}}', value);
5440                t.searchNothing.html(innerText);
5441
5442                t.searchNothing.appendTo(t.parent.$obj);
5443
5444                if (t.searchNothingHeight === null) {
5445                    t.searchNothingHeight = t.searchNothing.outerHeight(true);
5446                }
5447
5448                t.parent.registerEvent('resizeMainContainer', function() {
5449                    t.parent.height = t.parent.height + t.searchNothingHeight;
5450                    t.parent.obj.style.height = t.parent.height + 'px';
5451                }, true);
5452            } else {
5453                t.searchNothing.detach();
5454            }
5455
5456            return blocksNew;
5457        }, function() {
5458            el.trigger('keyup.cbp');
5459        });
5460    };
5461
5462    Plugin.prototype.destroy = function() {
5463        var t = this;
5464
5465        t.searchInput.off('.cbp');
5466        t.searchInput.next('.cbp-search-icon').off('.cbp');
5467
5468        t.searchInput.each(function(index, el) {
5469            jQuery.removeData(el);
5470        });
5471    };
5472
5473    CubePortfolio.plugins.search = function(parent) {
5474        if (parent.options.search === '') {
5475            return null;
5476        }
5477
5478        return new Plugin(parent);
5479    };
5480})(jQuery, window, document);
5481
5482(function($, window, document, undefined) {
5483    'use strict';
5484
5485    var options = {
5486        /**
5487         *  Pagination custom selector
5488         *  Values: strings that represent the elements in the document (DOM selector).
5489         */
5490        pagination: '',
5491        paginationClass: 'cbp-pagination-active',
5492    };
5493
5494    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
5495
5496    function Plugin(parent) {
5497        var t = this;
5498
5499        t.parent = parent;
5500
5501        t.options = jQuery.extend({}, options, t.parent.options.plugins.slider);
5502
5503        var customPagination = jQuery(t.options.pagination);
5504
5505        if (customPagination.length > 0) {
5506            t.parent.customPagination = customPagination;
5507            t.parent.customPaginationItems = customPagination.children();
5508            t.parent.customPaginationClass = t.options.paginationClass;
5509
5510            t.parent.customPaginationItems.on('click.cbp', function(e) {
5511                e.preventDefault();
5512                e.stopImmediatePropagation();
5513                e.stopPropagation();
5514
5515                if (t.parent.sliderStopEvents) {
5516                    return;
5517                }
5518
5519                t.parent.jumpToSlider(jQuery(this));
5520            });
5521        }
5522
5523        t.parent.registerEvent('gridAdjust', function() {
5524            t.sliderMarkup.call(t.parent);
5525
5526            t.parent.registerEvent('gridAdjust', function() {
5527                t.updateSlider.call(t.parent);
5528            });
5529        }, true);
5530    }
5531
5532    /**
5533     * Create mark-up for slider layout
5534     */
5535    Plugin.prototype.sliderMarkup = function() {
5536        var t = this;
5537
5538        t.sliderStopEvents = false;
5539
5540        t.sliderActive = 0;
5541
5542        t.$obj.one('initComplete.cbp', function() {
5543            t.$obj.addClass('cbp-mode-slider');
5544        });
5545
5546        t.nav = jQuery('<div/>', {
5547            'class': 'cbp-nav'
5548        });
5549
5550        t.nav.on('click.cbp', '[data-slider-action]', function(e) {
5551            e.preventDefault();
5552            e.stopImmediatePropagation();
5553            e.stopPropagation();
5554
5555            if (t.sliderStopEvents) {
5556                return;
5557            }
5558
5559            var el = jQuery(this),
5560                action = el.attr('data-slider-action');
5561
5562            if (t[action + 'Slider']) {
5563                t[action + 'Slider'](el);
5564            }
5565        });
5566
5567        if (t.options.showNavigation) {
5568            t.controls = jQuery('<div/>', {
5569                'class': 'cbp-nav-controls'
5570            });
5571
5572            t.navPrev = jQuery('<div/>', {
5573                'class': 'cbp-nav-prev',
5574                'data-slider-action': 'prev'
5575            }).appendTo(t.controls);
5576
5577            t.navNext = jQuery('<div/>', {
5578                'class': 'cbp-nav-next',
5579                'data-slider-action': 'next'
5580            }).appendTo(t.controls);
5581
5582            t.controls.appendTo(t.nav);
5583        }
5584
5585        if (t.options.showPagination) {
5586            t.navPagination = jQuery('<div/>', {
5587                'class': 'cbp-nav-pagination'
5588            }).appendTo(t.nav);
5589        }
5590
5591        if (t.controls || t.navPagination) {
5592            t.nav.appendTo(t.$obj);
5593        }
5594
5595        t.updateSliderPagination();
5596
5597        if (t.options.auto) {
5598            if (t.options.autoPauseOnHover) {
5599                t.mouseIsEntered = false;
5600                t.$obj.on('mouseenter.cbp', function(e) {
5601                    t.mouseIsEntered = true;
5602                    t.stopSliderAuto();
5603                }).on('mouseleave.cbp', function(e) {
5604                    t.mouseIsEntered = false;
5605                    t.startSliderAuto();
5606                });
5607            }
5608
5609            t.startSliderAuto();
5610        }
5611
5612        if (t.options.drag && CubePortfolio.private.modernBrowser) {
5613            t.dragSlider();
5614        }
5615    };
5616
5617    Plugin.prototype.updateSlider = function() {
5618        var t = this;
5619
5620        t.updateSliderPosition();
5621
5622        t.updateSliderPagination();
5623    };
5624
5625    Plugin.prototype.destroy = function() {
5626        var t = this;
5627
5628        if (t.parent.customPaginationItems) {
5629            t.parent.customPaginationItems.off('.cbp');
5630        }
5631    };
5632
5633    CubePortfolio.plugins.slider = function(parent) {
5634        if (parent.options.layoutMode !== 'slider') {
5635            return null;
5636        }
5637
5638        return new Plugin(parent);
5639    };
5640})(jQuery, window, document);
5641
5642(function($, window, document, undefined) {
5643    'use strict';
5644
5645    jQuery.fn.cubeportfolio.constructor.prototype.responsiveLayout = function() {
5646        var t = this;
5647
5648        // calculate numbers of cols
5649        t.cols = t[(jQuery.isArray(t.options.mediaQueries) ? 'getColumnsBreakpoints' : 'getColumnsAuto')]();
5650
5651        t.columnWidth = t.columnWidthTruncate((t.width + t.options.gapVertical) / t.cols);
5652
5653        t.widthAvailable = t.columnWidth * t.cols;
5654
5655        if (t.options.layoutMode === 'mosaic') {
5656            t.getMosaicWidthReference();
5657        }
5658
5659        if (t.options.coverRatio !== undefined) {
5660            t.blocks.each(function(index, el) {
5661                var data = jQuery(el).data('cbp'),
5662                    cols = 1, // layoutMode === grid || slider
5663                    width;
5664
5665                if (t.options.layoutMode === 'mosaic') {
5666                    cols = t.getColsMosaic(data.widthInitial);
5667                }
5668
5669                width = t.columnWidth * cols - t.options.gapVertical;
5670
5671                el.style.width = width + 'px';
5672                data.width = width;
5673                data.widthAndGap = width + t.options.gapVertical;
5674
5675                // reset height if it was set for addHeightToBlocks
5676                el.style.height = '';
5677            });
5678
5679            var imgs = [];
5680
5681            t.blocks.each(function(index, el) {
5682                var block = jQuery(el),
5683                    width = block.data('cbp').width;
5684
5685                jQuery.each(block.find('img').filter('[width][height]'), function(index, el) {
5686                    var procent = width / parseInt(el.getAttribute('width'), 10);
5687
5688                    imgs.push({
5689                        el: el,
5690                        width: width,
5691                        height: Math.floor(parseInt(el.getAttribute('height'), 10) * procent),
5692                    });
5693                });
5694            });
5695
5696            jQuery.each(imgs, function(index, item) {
5697                 item.el.width = item.width;
5698                 item.el.height = item.height;
5699                 item.el.style.width = item.width + 'px';
5700                 item.el.style.height = item.height + 'px';
5701            });
5702
5703            t.blocks.each(function(index, el) {
5704                var data = jQuery(el).data('cbp'),
5705                    bound = el.getBoundingClientRect(),
5706                    height = Math.round(bound.bottom - bound.top);
5707
5708                data.height = height;
5709                data.heightAndGap = height + t.options.gapHorizontal;
5710            });
5711        } else {
5712            var itemWidth = t.columnWidth - t.options.gapVertical;
5713
5714            t.blocks.each(function(index, el) {
5715                var data = jQuery(el).data('cbp'),
5716                    itemHeight = parseInt(data.heightInitial * (itemWidth / data.widthInitial), 10);
5717
5718                // set new css for current element
5719                el.style.width = itemWidth + 'px';
5720                el.style.height = itemHeight + 'px';
5721
5722                data.width = itemWidth;
5723                data.widthAndGap = itemWidth + t.options.gapVertical;
5724
5725                data.height = itemHeight;
5726                data.heightAndGap = itemHeight + t.options.gapHorizontal;
5727            });
5728        }
5729    };
5730})(jQuery, window, document);
5731
5732// ResetCaption
5733(function($, window, document, undefined) {
5734    'use strict';
5735
5736    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
5737
5738    jQuery.fn.cubeportfolio.options.coverRatio = undefined;
5739
5740    function Plugin(parent) {
5741        var t = this;
5742
5743        t.parent = parent;
5744
5745        parent.registerEvent('initStartWrite', function() {
5746            if (parent.options.coverRatio !== undefined) {
5747                parent.$obj.addClass('cbp-reset-caption');
5748
5749                var ratioString = parent.options.coverRatio.split(':'),
5750                    ratioX, ratioY, ratio;
5751
5752                if (ratioString.length === 2) {
5753                    parent.$obj.addClass('cbp-ratio-even');
5754
5755                    ratioX = parseInt(ratioString[0], 10);
5756                    ratioY = parseInt(ratioString[1], 10);
5757                    ratio = (ratioY / ratioX) * 100 + '%';
5758                }
5759
5760                parent.blocks.each(function(index, el) {
5761                    var item = jQuery(el),
5762                        localRatio = ratio,
5763                        attr = item.attr('data-cbp-coverRatio'),
5764                        caption = item.find('.cbp-caption');
5765
5766                    if (attr) {
5767                        if (attr !== '0:0') {
5768                            ratioString = attr.split(':');
5769
5770                            ratioX = parseInt(ratioString[0], 10);
5771                            ratioY = parseInt(ratioString[1], 10);
5772                            localRatio = (ratioY / ratioX) * 100 + '%';
5773                        } else {
5774                            localRatio = '';
5775                        }
5776                    }
5777
5778                    if (caption.length) {
5779                        caption[0].style.paddingTop = localRatio;
5780                    }
5781                });
5782            }
5783        });
5784
5785        parent.registerEvent('addItemsToDOM', function(items) {
5786            if (parent.options.coverRatio !== undefined) {
5787                var ratioString = parent.options.coverRatio.split(':'),
5788                    ratioX, ratioY, ratio;
5789
5790                if (ratioString.length === 2) {
5791                    ratioX = parseInt(ratioString[0], 10);
5792                    ratioY = parseInt(ratioString[1], 10);
5793                    ratio = (ratioY / ratioX) * 100 + '%';
5794                }
5795
5796                jQuery.each(items, function(index, el) {
5797                    var localRatio = ratio,
5798                        item = jQuery(el),
5799                        attr = item.attr('data-cbp-coverRatio'),
5800                        caption = item.find('.cbp-caption');
5801
5802                    if (attr) {
5803                        if (attr !== '0:0') {
5804                            ratioString = attr.split(':');
5805
5806                            ratioX = parseInt(ratioString[0], 10);
5807                            ratioY = parseInt(ratioString[1], 10);
5808                            localRatio = (ratioY / ratioX) * 100 + '%';
5809                        } else {
5810                            localRatio = '';
5811                        }
5812                    }
5813
5814                    if (caption.length) {
5815                        caption[0].style.paddingTop = localRatio;
5816                    }
5817                });
5818            }
5819        });
5820    }
5821
5822    Plugin.prototype.destroy = function() {
5823        this.parent.$obj.removeClass('cbp-reset-caption cbp-ratio-even');
5824
5825        this.parent.$obj.find('.cbp-caption').css('paddingTop', '');
5826    };
5827
5828    CubePortfolio.plugins.resetCaption = function(parent) {
5829        return new Plugin(parent);
5830    };
5831})(jQuery, window, document);
5832
5833// CorrectIdFrontend
5834(function($, window, document, undefined) {
5835    'use strict';
5836
5837    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
5838
5839    function Plugin(parent) {
5840        var t = this;
5841
5842        t.parent = parent;
5843
5844        t.attrId = parent.$obj.attr('id');
5845
5846        if (!t.attrId) {
5847            return;
5848        }
5849
5850        t.id = parseInt(t.attrId.replace('cbpw-grid', ''), 10);
5851
5852        parent.$obj.attr('id', '');
5853        parent.wrapper.attr('id', t.attrId);
5854
5855        parent.registerEvent('initStartWrite', function(expression) {
5856            // add id attr to singlePage block
5857            if (parent.singlePage) {
5858                parent.singlePage.wrap.attr('id', 'cbpw-singlePage' + t.id);
5859            }
5860        });
5861
5862    }
5863
5864    Plugin.prototype.destroy = function() {
5865        var t = this;
5866
5867        t.parent.$obj.attr('id', t.attrId);
5868    };
5869
5870    CubePortfolio.plugins.correctIdFrontend = function(parent) {
5871        // if is frontend run this plugin
5872        if (typeof cbpwOptions === 'undefined') {
5873            return new Plugin(parent);
5874        }
5875    };
5876})(jQuery, window, document);
5877
5878// refresh drag layout
5879(function($, window, document, undefined) {
5880    'use strict';
5881
5882    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
5883
5884    /*
5885     * refreshGragLayout
5886     */
5887    CubePortfolio.public.refreshDragLayout = function(index, newIndex) {
5888        var t = CubePortfolio.private.checkInstance.call(this, 'refreshGragLayout'),
5889            item = t.blocks.eq(index),
5890            newItem = t.blocks.eq(newIndex);
5891
5892        if (index > newIndex) {
5893            newItem.before(item);
5894        } else if (index < newIndex) {
5895            newItem.after(item);
5896        } else {
5897            return;
5898        }
5899
5900        // update blocks & index
5901        t.blocks = t.$ul.children('.cbp-item');
5902        t.blocks.each(function(index, el) {
5903            jQuery(el).data('cbp').index = index;
5904        });
5905
5906        // make layout
5907        t.layout();
5908    };
5909})(jQuery, window, document);
5910
5911// RemoveActionContainer before destroy
5912(function($, window, document, undefined) {
5913    'use strict';
5914
5915    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
5916
5917    function Plugin(parent) {
5918        var t = this;
5919
5920        t.parent = parent;
5921
5922        parent.registerEvent('publicMethod', function() {
5923            jQuery.actionCBP.remove();
5924        });
5925    }
5926
5927    Plugin.prototype.destroy = function() {
5928        var t = this;
5929    };
5930
5931    CubePortfolio.plugins.removeActionContainer = function(parent) {
5932        // if is frontend run this plugin
5933        if (typeof cbpwOptions !== 'undefined') {
5934            return new Plugin(parent);
5935        }
5936    };
5937})(jQuery, window, document);
5938
5939// LoadMore public
5940(function($, window, document, undefined) {
5941    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
5942
5943    function Plugin(parent) {
5944        var t = this;
5945
5946        t.parent = parent;
5947
5948        t.loadMore = jQuery(parent.options.loadMore).find('.cbp-l-loadMore-link');
5949
5950        // load click or auto action
5951        if (parent.options.loadMoreAction.length) {
5952            t[parent.options.loadMoreAction]();
5953        }
5954    }
5955
5956    Plugin.prototype.click = function() {
5957        var t = this,
5958            numberOfClicks = 0,
5959            displayItemsLoadMore = parseInt(t.parent.options.displayItemsLoadMore, 10);
5960
5961        t.loadMore.on('click.cbp', function(e) {
5962            var item = jQuery(this);
5963
5964            e.preventDefault();
5965
5966            if (t.parent.isAnimating || item.hasClass('cbp-l-loadMore-stop')) {
5967                return;
5968            }
5969
5970            item.addClass('cbp-l-loadMore-loading');
5971
5972            var id = t.parent.wrapper.attr('id');
5973
5974            if (!id) {
5975                id = t.parent.$obj.attr('id');
5976            }
5977            id = id.replace('cbpw-grid', '');
5978
5979            jQuery.ajax({
5980                type: 'post',
5981                dataType: 'json',
5982                url: ajaxurl,
5983                data: {
5984                    action: 'getLoadMoreItems',
5985                    offset: displayItemsLoadMore * numberOfClicks,
5986                    limit: displayItemsLoadMore,
5987                    id: id
5988                }
5989            }).done(function(data) {
5990                numberOfClicks++;
5991
5992                var items = data.items.map(function(item) {
5993                    return item.items;
5994                }).join('');
5995
5996                t.parent.$obj.cubeportfolio('appendItems', items, function() {
5997                    item.removeClass('cbp-l-loadMore-loading');
5998
5999                    if (data.itemsRemain <= 0) {
6000                        item.addClass('cbp-l-loadMore-stop');
6001                    }
6002                });
6003            });
6004        });
6005    };
6006
6007    Plugin.prototype.auto = function() {
6008        var t = this;
6009
6010        t.parent.$obj.on('initComplete.cbp', function() {
6011            t.loadMoreObj = Object.create({
6012                init: function() {
6013                    var self = this;
6014
6015                    // the job inactive
6016                    self.isActive = false;
6017
6018                    self.numberOfClicks = 0;
6019
6020                    // set loading status
6021                    t.loadMore.addClass('cbp-l-loadMore-loading');
6022
6023                    // cache window selector
6024                    self.window = jQuery(window);
6025
6026                    // add events for scroll
6027                    self.addEvents();
6028
6029                    // trigger method on init
6030                    self.getNewItems();
6031
6032                    return this;
6033                },
6034
6035                addEvents: function() {
6036                    var self = this,
6037                        timeout;
6038
6039                    t.loadMore.on('click.cbp', function(e) {
6040                        e.preventDefault();
6041                    });
6042
6043                    self.window.on('scroll.loadMoreObject', function() {
6044                        clearTimeout(timeout);
6045
6046                        timeout = setTimeout(function() {
6047                            if (!t.parent.isAnimating) {
6048                                // get new items on scroll
6049                                self.getNewItems();
6050                            }
6051                        }, 80);
6052                    });
6053
6054                    // when the filter is completed
6055                    t.parent.$obj.on('filterComplete.cbp', function() {
6056                        self.getNewItems();
6057                    });
6058                },
6059
6060                getNewItems: function() {
6061                    var self = this,
6062                        topLoadMore, topWindow;
6063
6064                    if (t.parent.isAnimating || self.isActive || t.loadMore.hasClass('cbp-l-loadMore-stop')) {
6065                        return;
6066                    }
6067
6068                    topLoadMore = (t.loadMore.length) ? t.loadMore.offset().top : 0; /* TREETHEMESadicionou se verificacao da existencia do loadmore pq estava a spamar erros no single proj */
6069                    topWindow = self.window.scrollTop() + self.window.height();
6070
6071                    if (topLoadMore > topWindow) {
6072                        return;
6073                    }
6074
6075                    // this job is now busy
6076                    self.isActive = true;
6077
6078                    var displayItemsLoadMore = parseInt(t.parent.options.displayItemsLoadMore, 10);
6079
6080                    var id = t.parent.wrapper.attr('id');
6081
6082                    if (!id) {
6083                        id = t.parent.$obj.attr('id');
6084                    }
6085                    id = id.replace('cbpw-grid', '');
6086
6087                    jQuery.ajax({
6088                            type: 'post',
6089                            dataType: 'json',
6090                            url: ajaxurl,
6091                            data: {
6092                                action: 'getLoadMoreItems',
6093                                offset: displayItemsLoadMore * self.numberOfClicks,
6094                                limit: displayItemsLoadMore,
6095                                id: id
6096                            }
6097                        })
6098                        .done(function(data) {
6099                            var items = data.items.map(function(item) {
6100                                return item.items;
6101                            }).join('');
6102
6103                            t.parent.$obj.cubeportfolio('appendItems', items, function() {
6104                                // increment number of clicks
6105                                self.numberOfClicks++;
6106
6107                                if (data.itemsRemain <= 0) {
6108                                    t.loadMore.addClass('cbp-l-loadMore-stop').removeClass('cbp-l-loadMore-loading');
6109
6110                                    // remove events
6111                                    self.window.off('scroll.loadMoreObject');
6112                                    t.parent.$obj.off('filterComplete.cbp');
6113                                } else {
6114                                    // make the job inactive
6115                                    self.isActive = false;
6116
6117                                    self.window.trigger('scroll.loadMoreObject');
6118                                }
6119                            });
6120                        })
6121                        .fail(function() {
6122                            // make the job inactive
6123                            self.isActive = false;
6124                        });
6125                }
6126            }).init();
6127        });
6128    };
6129
6130
6131    Plugin.prototype.destroy = function() {
6132        var t = this;
6133
6134        t.loadMore.off('.cbp');
6135
6136        if (t.loadMoreObj) {
6137            t.loadMoreObj.window.off('scroll.loadMoreObject');
6138        }
6139    };
6140
6141    CubePortfolio.plugins.loadMore = function(parent) {
6142        if (parent.options.loadMore === '') {
6143            return null;
6144        }
6145
6146        return new Plugin(parent);
6147    };
6148})(jQuery, window, document);
6149
6150// FullWidthForce force
6151(function($, window, document, undefined) {
6152    var CubePortfolio = jQuery.fn.cubeportfolio.constructor;
6153
6154    function Plugin(parent, forceWidthBlock) {
6155        var t = this;
6156
6157        t.parent = parent;
6158
6159        var wrap = parent.$obj.parent();
6160        var forceWidthBlock = wrap.parent();
6161
6162        if (!forceWidthBlock.hasClass('cbpw-fullWidth-force')) {
6163            return;
6164        }
6165
6166        parent.registerEvent('beforeResizeGrid', function() {
6167            forceWidthBlock.removeAttr('style');
6168
6169            forceWidthBlock.css({
6170                width: jQuery(document).width(),
6171                left: -(wrap[0].getBoundingClientRect().left)
6172            });
6173        });
6174    }
6175
6176    Plugin.prototype.destroy = function() {
6177        var t = this;
6178    };
6179
6180    CubePortfolio.plugins.fullWidthForce = function(parent) {
6181        return new Plugin(parent);
6182    };
6183})(jQuery, window, document);
6184
6185// init cubeportfolio
6186(function($, window, document, undefined) {
6187    'use strict';
6188
6189    var processResult = function(result, element) {
6190
6191            var selector,
6192                doc = jQuery(document),
6193                html = '',
6194                scripts,
6195                domStyles,
6196                styles = '',
6197                i,
6198                inlineJS = '',
6199                newScripts,
6200                script,
6201                src,
6202                href,
6203                selectorsArray,
6204                isWrap = true;
6205
6206            element = jQuery(element);
6207
6208            // if content is wrap
6209            if (element.data('cbp-iswrap') === false) {
6210                isWrap = false;
6211            }
6212
6213            // get the selector
6214            if (element.data('cbp-selector')) {
6215                selector = element.data('cbp-selector');
6216
6217                // remove scripts & css already in the popup
6218                var popupWrap = jQuery('.cbp-popup-wrap');
6219                popupWrap.find('script[type="text/javascript"]').remove();
6220                popupWrap.find('link[type="text/css"], style').not('#vc_typicons-css').remove();
6221
6222                result = result.replace('<body', '<div data-cbpelement="body"').replace('</body>', '</div>');
6223
6224                result = jQuery('<div>', {
6225                    html: result
6226                });
6227
6228                // put the scrips in the newScripts array
6229                newScripts = [];
6230                scripts = result.find('script[type="text/javascript"]').remove();
6231                var textScripts = [];
6232                doc.find('script[type="text/javascript"]').each(function(index, el) {
6233                    el = jQuery(el);
6234
6235                    if (el.html()) {
6236                        textScripts.push(el.html());
6237                    }
6238                });
6239
6240                var skipScriptWithText_one = /window\.devicePixelRatio/gim;
6241                var skipScriptWithText_two = /email-protection/;
6242
6243                for (i = 0; i < scripts.length; i++) {
6244                    src = scripts[i].src;
6245					
6246					
6247					if (!src) {
6248			            if (!skipScriptWithText_one.test(scripts[i].text) && !skipScriptWithText_two.test(scripts[i].text)) {
6249			                if (jQuery.inArray(scripts[i].text, textScripts) === -1) {
6250				                
6251				                scripts[i].text = scripts[i].text.replace('jQuery(window).load(','jQuery(document).ready(');
6252				                
6253			                    inlineJS = inlineJS + ';\n' + scripts[i].text;
6254			                }
6255			            }
6256			        } else if (doc.find('script[src="' + src + '"]').length === 0 || src.indexOf('ultimate') > -1 || src.indexOf('ult') > -1 || src.indexOf('utl') > -1 || src.indexOf('timecircle') > -1 || src.indexOf('countdown') > -1 || src.indexOf('masonry') > -1 || /* src.indexOf('google') > -1 || */ src.indexOf('modernizr') > -1 || src.indexOf('swatchbook') > -1 || src.indexOf('_box_') > -1 || src.indexOf('dualbtn') > -1 || src.indexOf('_ui') > -1 || src.indexOf('flex') > -1 || src.indexOf('team_front') > -1) {
6257			            if (src.indexOf('media-') < 0) newScripts.push(scripts[i]);
6258			        }
6259
6260                }
6261                
6262                inlineJS += ';\n jQuery(document).ready(function(){ treethemes_special_tabs(true); });';
6263                
6264                var treethemes_other_cube_instances = result.find('[id^="cbpw-grid"]');
6265                
6266                if (treethemes_other_cube_instances.length > 0){
6267	                
6268	                jQuery(treethemes_other_cube_instances).each(function(){
6269
6270		                window.treethemes_related_projects_default_opts = '{"filters":"","loadMore":"","loadMoreAction":"auto","search":"","layoutMode":"slider","sortToPreventGaps":false,"drag":true,"auto":false,"autoTimeout":5000,"autoPauseOnHover":true,"showNavigation":false,"showPagination":false,"rewindNav":true,"scrollByPage":false,"defaultFilter":"*","filterDeeplinking":false,"animationType":"flipOut","gridAdjustment":"responsive","mediaQueries":[{"width":1400,"cols":5},{"width":1170,"cols":4},{"width":1024,"cols":3},{"width":960,"cols":3},{"width":778,"cols":3},{"width":640,"cols":2},{"width":480,"cols":1}],"gapHorizontal":20,"gapVertical":20,"caption":"overlayBottomAlong","displayType":"bottomToTop","displayTypeSpeed":100,"lightboxDelegate":".cbp-lightbox","lightboxGallery":true,"lightboxTitleSrc":"data-title","lightboxCounter"
6270:"<div class=\'cbp-popup-lightbox-counter\'>{{current}} of {{total}}</div>","singlePageDelegate":".cbp-singlePage","singlePageDeeplinking":true,"singlePageStickyNavigation":true,"singlePageCounter":"<div class=\'cbp-popup-singlePage-counter\'>{{current}} of {{total}}</div>","singlePageAnimation":"middle","singlePageInlineDelegate":".cbp-singlePageInline","singlePageInlineDeeplinking":false,"singlePageInlinePosition":"below","singlePageInlineInFocus":true,"plugins":{},"coverRatio":"300:267","displayItemsLoadMore":3}';
6271		                window.treethemes_related_projects_default_opts = JSON.parse(treethemes_related_projects_default_opts);
6272		                
6273		                if (!jQuery(this).closest('#big_footer').length > 0) inlineJS += ';\n jQuery(document).ready(function(){  jQuery.fn.cubeportfolio.call( jQuery("#'+jQuery(this).attr('id')+'"), window.treethemes_related_projects_default_opts) });';
6274	                });
6275	                
6276                }
6277
6278				// add inline js in one <script> element
6279                script = document.createElement('script');
6280                script.type = 'text/javascript';
6281                script.text = (window.vc_js) ? inlineJS + '; window.vc_js();' : inlineJS;
6282                
6283                var auxScripts = [];
6284                jQuery(newScripts).each(function(e){
6285	                if ( jQuery(this).attr('src') && !jQuery('script[src="'+jQuery(this).attr('src')+'"]', document).length ){
6286		                auxScripts.push( this );
6287	                }
6288                });
6289                newScripts = auxScripts;
6290                newScripts.push(script);
6291                
6292                // get styles and link from html and add to a variable that will be prepended to html element
6293                domStyles = result.find('link[type="text/css"], style').not('.cubescroller');
6294                
6295                jQuery(result, result).find('link[type="text/css"]').not('.cubescroller').not('[rel="stylesheet"]').not('#vc_typicons-css').remove();
6296				
6297				var auxdomStyles = [];
6298				
6299				
6300				if (typeof domStyles == "object" && domStyles.length > 0){
6301					domStyles.prevObject.each(function(e){ 
6302						if( jQuery(this).attr('id') && !jQuery('#'+jQuery(this).attr('id')).length ||
6303							jQuery(this).attr('href') && !jQuery( 'link[src="'+jQuery(this).attr('href')+'"]' ) ||
6304							jQuery(this).attr('id') == 'vc_typicons-css'
6305						){
6306							auxdomStyles.push( this );
6307						}  
6308					});
6309				}
6310				
6311				domStyles = auxdomStyles;
6312				
6313                for (i = 0; i < domStyles.length; i++) {
6314                    href = domStyles[i].href;
6315
6316                    // check if current css is in dom
6317                    if (href && doc.find('link[href="' + href + '"]').not('.cubescroller').length && href.indexOf('main') > -1) {
6318                        continue;
6319                    }
6320                    styles += domStyles[i].outerHTML;
6321                }
6322
6323                if (selector === 'automatically') {
6324
6325					result = jQuery(result);
6326					html = result.find('.proj-content', result);
6327					
6328					// TREETHEMES 2020 remove elements
6329					jQuery(html).children('.navigation, .the_comments').remove(); 
6330					
6331					html = jQuery(html)[0].outerHTML
6332
6333					
6334                } else if (selector === 'manually') {
6335                    selectorsArray = ['#main', '[role="main"]', '#main-content', '#content', '#Content', '.main-content'];
6336
6337                    for (i = 0; i < selectorsArray.length; i++) {
6338                        html = result.find(selectorsArray[i]);
6339
6340                        if (html.length) {
6341                            html = html[0].outerHTML;
6342                            break;
6343                        }
6344                    }
6345
6346                } else if (selector === 'cbp-post') {
6347                    html = result.find('.cbp-popup-singlePage > article').html();
6348                } else {
6349                    html = result.find(selector)[0].outerHTML;
6350                }
6351
6352                if (html && html.length) {
6353                    result = styles + html;
6354                } else {
6355                    result = 'Error! Please correct your wordpress link added to cubeportfolio singlePage popup!';
6356                }
6357            }
6358
6359            return {
6360                result: result,
6361                scripts: newScripts,
6362                isWrap: isWrap
6363            };
6364        },
6365        singlePageCallback = function(url, element) {
6366            // to update singlePage content use the following method: this.updateSinglePage(yourContent)
6367            var self = this,
6368                inlineHtml = url.match(/html-inline-\d+$/ig),
6369                link = url;
6370
6371            if (inlineHtml && inlineHtml.length === 1) {
6372                url = ajaxurl + '?link=' + inlineHtml[0];
6373            }
6374
6375            var id = self.cubeportfolio.wrapper.attr('id');
6376            if (!id) {
6377                id = self.cubeportfolio.$obj.attr('id');
6378            }
6379            id = id.replace('cbpw-grid', '');
6380
6381            jQuery.ajax({
6382                    url: url,
6383                    type: 'POST',
6384                    dataType: 'html',
6385                    timeout: 30000,
6386                    data: {
6387                        link: link,
6388                        type: 'cbp-singlePage',
6389                        source: 'cubeportfolio',
6390                        id: id,
6391                        selector: jQuery(element).data('cbp-selector')
6392                    }
6393                }).done(function(result) {
6394                    var process = processResult(result, element);
6395                    self.updateSinglePage(process.result, process.scripts, process.isWrap);
6396                })
6397                .fail(function() {
6398                    self.updateSinglePage('AJAX Error! Please refresh the page!');
6399                });
6400        },
6401        singlePageInlineCallback = function(url, element) {
6402            // to update singlePage content use the following method: this.updateSinglePageInline(yourContent)
6403            var self = this,
6404                inlineHtml = url.match(/html-inline-\d+$/ig),
6405                link = url;
6406
6407            if (inlineHtml && inlineHtml.length === 1) {
6408                url = ajaxurl + '?link=' + inlineHtml[0];
6409            }
6410
6411            var id = self.cubeportfolio.wrapper.attr('id');
6412            if (!id) {
6413                id = self.cubeportfolio.$obj.attr('id');
6414            }
6415            id = id.replace('cbpw-grid', '');
6416
6417            jQuery.ajax({
6418                    url: url,
6419                    type: 'POST',
6420                    dataType: 'html',
6421                    timeout: 30000,
6422                    data: {
6423                        link: link,
6424                        type: 'cbp-singlePageInline',
6425                        source: 'cubeportfolio',
6426                        id: id,
6427                        selector: jQuery(element).data('cbp-selector')
6428                    }
6429                }).done(function(result) {
6430                    var process = processResult(result, element);
6431                    self.updateSinglePageInline(process.result, process.scripts);
6432                })
6433                .fail(function() {
6434                    self.updateSinglePageInline('Error! Please refresh the page!');
6435                })
6436                .always(function(){
6437	                setTimeout( function(){ jQuery('body').removeClass('cbp-animating'); if (jQuery('html.vc_mobile')) jQuery(window).trigger('scroll'); }, 1500 ); 
6438                });
6439        },
6440        initCBP = function(id, options) {
6441            if (typeof options.loadMore === 'undefined') {
6442                options.loadMore = '#cbpw-loadMore' + id;
6443            }
6444
6445            // if (typeof options.filters === 'undefined') {
6446                options.filters = '#cbpw-filters' + id;
6447            // }
6448
6449            /*********************************
6450             init cubeportfolio
6451             *********************************/
6452            options.singlePageCallback = singlePageCallback;
6453            options.singlePageInlineCallback = singlePageInlineCallback;
6454            jQuery('#cbpw-grid' + id).cubeportfolio(options);
6455        };
6456
6457    jQuery(document).ready(function() {
6458        if (typeof initCubePortfolio !== 'undefined') {
6459
6460            // init cbp instances
6461            jQuery.each(initCubePortfolio, function(index, val) {
6462                var wrap = jQuery('#cbpw-wrap' + val.id);
6463                var checkForceWidth = wrap.parent();
6464
6465                if (checkForceWidth.hasClass('cbpw-fullWidth-force')) {
6466                    checkForceWidth.css({
6467                        width: jQuery(document).width(),
6468                        left: -(wrap[0].getBoundingClientRect().left)
6469                    });
6470                }
6471
6472                initCBP(val.id, val.options);
6473            });
6474        }
6475    });
6476})(jQuery, window, document);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.