%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /var/www/html/shaban/laviva/wp-content/themes/levelup/assets/js/app/components/
Upload File :
Create Path :
Current File : /var/www/html/shaban/laviva/wp-content/themes/levelup/assets/js/app/components/home.class.js

(function () {
    'use strict';

    APP.COMPONENTS.Home = APP.CORE.Event_Emitter.extend({
        options: {},

        init: function (options) {
            this._super(options);

            this.browser = new APP.TOOLS.Browser();
            this.navigation = new APP.TOOLS.Navigation();
            this.type = 'home';
            this.active = true;
            this.updates_count = 0;

            this.$.main = $('.site-content.project');
            this.$.projects = this.$.main.find('.line.project');
            this.$.list = this.$.main.find('.projects-list');
            this.$.list_items = this.$.list.find('a');
            this.$.to_top = this.$.main.find('a.to-top');
            this.$.illustrations_container = this.$.main.find('.illustrations-container');
            this.$.illustrations = this.$.main.find('.illustrations');
            this.$.illustrations_items = this.$.illustrations_container.find('.illustration');

            this.wave = {};
            this.wave.timeout = null;
            this.wave.interval = null;

            this.$.illustrations_container.removeClass('hidden');

            this.init_events();
        },

        init_events: function () {
            var that = this;

            $('#main-menu li a[href*="#"]').on('click', function () {
                var url = new Url($(this).attr('href'));

                if (url.hash.length) {
                    var $project = that.$.projects.filter('[data-slug="' + url.hash + '"]');

                    if($project.length) {
                        that.trigger('gotoline', [$project.index()]);
                    }
                }
            });

            this.$.illustrations_container.on('click mouseenter mouseleave', function (e) {
                var $project = that.$.projects.filter('.current');

                if ($project.length) {
                    switch (e.type) {
                        case 'click' :
                            if($project.data('captionHide') != '1') {
                                $project.find('a').trigger('click');
                            }
                            break;
                        case 'mouseenter' :
                            $project.find('a').addClass('hover');
                            $project.find('a').removeClass('hover_out');
                            break;
                        case 'mouseleave' :
                            $project.find('a').removeClass('hover');
                            $project.find('a').addClass('hover_out');
                            break;
                    }
                }

                return false;
            });

            this.$.projects.each(function () {
                var $project = $(this);

                $(this).find('.slider_nav_prev').on('click', function (e) {
                    // that.$.illustrations_items.eq($project.index()).find('.rev_slider_wrapper').revprev();
                    var $revobj = that.$.illustrations_items.eq($project.index()).find('.rev_slider_wrapper'),
                        id_array = $revobj.attr("id").split("_"),
                        id = id_array[2];

                    $.globalEval('revapi'+id+'.revprev()' );
                    return false;
                });

                $(this).find('.slider_nav_next').on('click', function (e) {
                    // that.$.illustrations_items.eq($project.index()).find('.rev_slider_wrapper').revnext();
                    var $revobj = that.$.illustrations_items.eq($project.index()).find('.rev_slider_wrapper'),
                    id_array = $revobj.attr("id").split("_"),
                    id = id_array[2];

                    $.globalEval('revapi'+id+'.revnext()' );
                    return false;
                });
            });


            this.$.projects.each(function () {
                var $project = $(this),
                    index = $project.index();

                $project.on('mouseenter mouseleave', function (e) {
                    if (e.type === 'mouseenter') {
                        that.$.illustrations_items.eq(index).addClass('hover');
                        that.$.illustrations_items.eq(index).removeClass('hover_out');
                    }
                    else {
                        that.$.illustrations_items.eq(index).removeClass('hover');
                        that.$.illustrations_items.eq(index).addClass('hover_out');
                    }
                });
            });

            this.$.list_items.on('click', function () {
                that.trigger('gotoline', [$(this).index()]);
                return false;
            });

            if (this.$.list.data('title')) {
                this.$.list_items.on('mouseenter mouseleave', function (e) {
                    var $span = $(this).find('span');

                    switch (e.type) {
                        case 'mouseenter' :
                            $(this).addClass('hover');
                            $span.velocity("stop").velocity({opacity: 1}, {duration: 180, easing: "easeInOut"});
                            break;
                        case 'mouseleave' :

                            $span.velocity("stop").velocity({opacity: 0}, {
                                duration: 500,
                                easing: "easeInOut",
                                complete: function () {
                                    $(this).parent().removeClass('hover');
                                }
                            });
                            break;
                    }

                    return false;
                });
            }

            this.$.to_top.on('click', function () {
                that.trigger('gotoline', [0]);
                return false;
            });

            window.addEventListener('orientationchange', function () {
                var current = that.$.projects.filter('.current');

                if (!current.length)
                    return;

                var index = current.index(),
                    y = -index * 100;

                that.$.illustrations.removeClass('animated');
                window.setTimeout(function () {
                    that.$.illustrations.addClass('animated');
                }, 100);

                var match = that.browser.match_media('(max-width:900px)');

                that.$.illustrations.css({
                    transform: match ? 'translateX( ' + y + '% ) translateZ(0)' : 'translateY( ' + y + '% ) translateZ(0)'
                });

                that.$.illustrations_container.removeClass('hidden');
            }, false);

        },

        init_update_line: function (index) {
            var that = this;
            window.setTimeout(function () {
                that.$.illustrations_items.filter(function () {
                    return $(this).index() != index;
                }).removeClass('slidein')
            }, 1100);
        },

        update_line: function (index, count, direction) {
            var that = this;

            if (index < this.$.projects.length) {
                var y = -index * 100;

                if (this.updates_count === 0) {
                    this.$.illustrations.removeClass('animated');
                    window.setTimeout(function () {
                        that.$.illustrations.addClass('animated');
                    }, 100);
                }

                this.$.illustrations.css({
                    transform: 'translateY( ' + y + '% ) translateZ(0)'
                });

                this.$.illustrations_container.removeClass('hidden');
            } else {
                this.$.illustrations_container.addClass('hidden');
            }

            this.$.list_items.removeClass('active');
            this.$.list_items.eq(index).addClass('active');
            this.$.illustrations_items.removeClass('hover_out').eq(index).addClass('slidein');

            if (this.$.illustrations_items.eq(index).find('.illustration-video').length && !rdyGlobals.isMobile) {
                var video = this.$.illustrations_items.eq(index).find('.illustration-video video').get(0);
                video.pause();

                setTimeout(function () {
                    // Resume play if the element if is paused.
                    if (video.paused) {
                        video.currentTime = 0;
                        video.play();
                    }
                }, 250);
            }

            this.updates_count++;
        }

    });
})();





Zerion Mini Shell 1.0