%PDF- %PDF-
Direktori : /var/www/html/shaban/laviva/wp-content/themes/levelup/assets/js/app/core/ |
Current File : //var/www/html/shaban/laviva/wp-content/themes/levelup/assets/js/app/core/app.class.js |
(function () { 'use strict'; APP.CORE.App = APP.CORE.Abstract.extend({ options:{ page : 'home' }, init: function (options) { this._super(options); this.page = null; this.can_navigate = true; this.ticker = new APP.TOOLS.Ticker(); this.browser = new APP.TOOLS.Browser({initial_triggers: ['resize']}); this.css = new APP.TOOLS.Css(); this.mouse = new APP.TOOLS.Mouse(); this.keyboard = new APP.TOOLS.Keyboard(); this.navigation = new APP.TOOLS.Navigation(); this.$.title = $('head title'); this.init_page('home'); this.init_columns(); this.init_lines(); this.init_keyboard(); this.init_hammer(); this.update_images(); this.init_down(); }, start: function () { var that = this; this.browser.start(); this.ticker.start(true); }, init_hammer: function () { if (!rdyGlobals.isMobile) { return false; } var that = this; document.ontouchmove = function (e) { e.preventDefault(); }; var hammertime = new Hammer(document.querySelector("#page")); hammertime.on('swipe', function (e) { if (!that.is_mobile_menu_open()) { var index = that.index; if (e.direction === Hammer.DIRECTION_UP) { that.go_to_line(index + 1); } else if (e.direction === Hammer.DIRECTION_DOWN) { that.go_to_line(index - 1); } else if (e.direction === Hammer.DIRECTION_RIGHT) { that.go_to_slider('next'); } else if (e.direction === Hammer.DIRECTION_LEFT) { that.go_to_slider('prev'); } } }); this.browser.on('breakpoint', function (current_breakpoint, previous_breakpoint) { hammertime.get('swipe').set({direction: Hammer.DIRECTION_ALL}); }); }, init_keyboard: function () { var that = this; this.keyboard.on('down', function (code, character) { // if (that.is_mobile_menu_open()) { // return false; // } switch (character) { case 'down' : // case 'j' : that.go_to_line(that.index + 1); break; case 'esc' : if (that.header.active) that.header.deactivate(); else if (that.page.type === 'project') that.page.$.main.find('a.close').first().trigger('click'); break; case 'up' : // case 'k' : that.go_to_line(that.index - 1); break; case 'space' : // case 'enter' : case 'right' : that.go_to_slider('next'); break; case 'left' : that.go_to_slider('prev'); break; } if (['down', 'esc', 'up', 'space', 'right', 'left'].indexOf(character) !== -1) return false; }); }, init_down: function () { var that = this; this.$.lines.find('.section-down-arrow').on('click', function () { that.go_to_next(); }); }, init_page: function (page_name) { var that = this, page = null; switch (page_name) { case 'home': page = new APP.COMPONENTS.Home(); break; } if (page) { page.on('gotoline', function (index) { that.go_to_line(index); }); page.on('gotoslider', function (direction) { that.go_to_slider(direction); }); } this.page = page; FastClick.attach(document.body); }, go_to_slider: function (direction) { var $revobj = this.page.$.illustrations_items.eq(this.index).find('.rev_slider_wrapper'); if ($revobj.length) { var id_array = $revobj.attr("id").split("_"), id = id_array[2]; if(direction == 'next') { $.globalEval('revapi'+id+'.revnext()' ); } else { // this.page.$.illustrations_items.eq(this.index).find('.rev_slider_wrapper').revprev(); $.globalEval('revapi'+id+'.revprev()' ); } } }, update_images: function ($container) { var that = this; $container = $container || $('body'); var $images_to_load = $container.find('.to-load:not(.loaded)'); $images_to_load.each(function () { var $image_to_load = $(this), $image = $('<span />'), url = $image_to_load.data('image-url'), url_m = $image_to_load.data('image-mobile-url'), image = new Image(); if (url_m && $(window).width() < 992) { url = url_m; } if ($image_to_load.data('video') == 1 && !rdyGlobals.isMobile) { var $video_tag = '<video preload="none" autoplay loop muted poster="">'; if ($image_to_load.data('video-mp4')) $video_tag += '<source src="' + $image_to_load.data('video-mp4') + '" type="video/mp4"/>'; if ($image_to_load.data('video-ogg')) $video_tag += '<source src="' + $image_to_load.data('video-ogg') + '" type="video/ogg"/>'; if ($image_to_load.data('video-webm')) $video_tag += '<source src="' + $image_to_load.data('video-webm') + '" type="video/webm"/>'; $video_tag += '</video>'; $image = $($video_tag); $image_to_load.append($image); // content editor self hosted video and blog video $image.mediaelementplayer({ // options pauseOtherPlayers: false, success: function (mediaElement, domObject) { // get media element var $thisMediaElement = (mediaElement.id) ? $("#"+mediaElement.id) : $(mediaElement); // empty poster image to avoid double images $thisMediaElement.attr('poster', ''); // show poster image after video finished mediaElement.addEventListener("ended", function(e){ $thisMediaElement.parents(".mejs-inner").find(".mejs-poster").show(); }); } }); } else { $image_to_load.append($image); image.onload = function () { window.setTimeout(function () { $image.css({ backgroundImage: 'url(' + url + ')' }); $image_to_load.addClass('loaded'); }, 30); }; image.src = url; } }); }, init_columns: function () { this.$.columns = $('.columns'); }, is_mobile_menu_open: function () { return $('.popup_menu_opened').length ? true : false; }, init_lines: function () { var that = this; this.can_scroll = true; this.$.lines = $('.line'); this.index = 0; if (window.location.hash) { var url = new Url($(this).attr('href')); if (url.hash.length) { var $project = that.$.lines.filter('[data-slug="' + url.hash + '"]'); if($project.length) { this.index = $project.index(); } } /*var $line = this.$.lines.filter('.line-' + ( window.location.hash.replace('#', '') )); if ($line.length) { this.index = $line.index(); // window.location.hash = ''; }*/ } this.$.lines.each(function () { if ($(this).hasClass('slide-click')) { $(this).on('click', function () { if ($(this).data('project-link')) { window.location = $(this).data('project-link'); } }) } }); this.go_to_line(this.index, 30); this.mouse.on('wheel', function (delta) { if (!that.is_mobile_menu_open()) { var index = that.index + ( delta < 0 ? 1 : -1 ); that.go_to_line(index); } }); }, go_to_next: function () { var index = this.index + 1; this.go_to_line(index); }, go_to_line: function (index, duration) { duration = duration || 1060; if (!this.can_scroll || index < 0 || index > this.$.lines.length - 1) { return; } if (this.$.lines.find('.section-down-arrow').length > 1) { this.$.lines.find('.section-down-arrow').velocity("fadeOut", { duration: 350 }); this.$.lines.find('.section-down-arrow').eq(index).velocity("fadeIn", { delay: 400, duration: 500 }); } var that = this, direction = that.index < index ? 'down' : 'up'; //this.navigation.update_state({line: index}); this.can_scroll = false; this.$.lines.show(); $('.columns-project .column .lines').show(); window.setTimeout(function () { that.$.lines.removeClass('before current after going-down going-up'); var i = 0; that.$.lines.each(function () { var $line = $(this), classes = null; // if(that.$.lines.eq(index).data('captionHide') != '1') { // $('.columns-project .column .lines').show(); // } if (i < index) { classes = 'before'; } else if (i > index) { classes = 'after'; } else { classes = 'current'; var bgcolor = $line.data('bgcolor'); var bgcolor_mark = $line.data('bgcolor-mark'); var bgcolor_logo_mark = $line.data('bgcolor-logo-mark'); var pgcolor_mark = $line.data('pgcolor-mark'); if (pgcolor_mark !== undefined) { $('.rdy_project .projects-list').attr('data-pgcolor', pgcolor_mark); } else { $('.rdy_project .projects-list').attr('data-pgcolor', ''); } $('#header').removeClass('mark-light').removeClass('mark-dark').removeClass('mark-logo-light').removeClass('mark-logo-dark'); $('#header-menu').removeClass('mark-light').removeClass('mark-dark'); if (bgcolor_mark == 'dark') { $('#header, #header-menu').addClass('mark-dark'); } else if (bgcolor_mark == 'light') { $('#header, #header-menu').addClass('mark-light'); } if (bgcolor_logo_mark == 'dark') { $('#header').addClass('mark-logo-dark'); } else if (bgcolor_logo_mark == 'light') { $('#header').addClass('mark-logo-light'); } $('.body-background').css('background', bgcolor); } classes += direction === 'down' ? ' going-up' : ' going-down'; $line.addClass(classes); i++; }); window.setTimeout(function () { that.$.lines.filter(':not(.current)').hide(); that.can_scroll = true; if(that.$.lines.eq(index).data('captionHide') == '1') { $('.columns-project .column .lines').hide(); } }, duration); that.page.init_update_line(index); if (that.page && that.page.active){ that.page.update_line(index, that.$.lines.length, direction); // Leave Video Section /*if (that.page.$.illustrations_items.eq(index).find('.illustration-video').length && !rdyGlobals.isMobile) { var video = that.page.$.illustrations_items.eq(index).find('.illustration-video video').get(0); if ("function" != typeof video.pause) { video.pause() } }*/ } that.index = index; }, 60); } }); })();