/** * Main loginPage application */ define([ 'jquery', 'app/init', 'app/util', 'app/render', 'blueImpGallery', 'bootbox', 'lazyload', 'app/ui/header', 'app/ui/logo', 'app/ui/demo_map', 'dialog/account_settings', 'dialog/notification', 'dialog/manual', 'dialog/changelog', 'dialog/credit' ], ($, Init, Util, Render, Gallery, bootbox) => { 'use strict'; let config = { splashOverlayClass: 'pf-splash', // class for "splash" overlay // header headerId: 'pf-landing-top', // id for header headerContainerId: 'pf-header-container', // id for header container logoContainerId: 'pf-logo-container', // id for main header logo container headHeaderMapId: 'pf-header-map', // id for header image (svg animation) // map bg headMapBgId: 'pf-header-map-bg', // id for header background container mapNeocomId: 'pf-map-neocom', // id for map "neocom" image mapBrowserId: 'pf-map-browser', // id for "browser" image mapBgImageId: 'pf-map-bg-image', // id for "background" map image // navigation navigationElementId: 'pf-navbar', // id for navbar element navigationLinkManualClass: 'pf-navbar-manual', // class for "manual" trigger link navigationLinkLicenseClass: 'pf-navbar-license', // class for "license" trigger link navigationVersionLinkClass: 'pf-navbar-version-info', // class for "version information" // cookie hint cookieHintId: 'pf-cookie-hint', // id for "cookie hint" element // login ssoButtonClass: 'pf-sso-login-button', // class for SSO login button // character select characterSelectionClass: 'pf-character-selection', // class for character panel wrapper characterRowAnimateClass: 'pf-character-row-animate', // class for character panel row during animation characterImageWrapperClass: 'pf-character-image-wrapper', // class for image wrapper (animated) characterImageInfoClass: 'pf-character-info', // class for character info layer (visible on hover) dynamicMessageContainerClass: 'pf-dynamic-message-container', // class for "dynamic" (JS) message container // gallery galleryId: 'pf-gallery', // id for gallery container galleryThumbImageClass: 'pf-landing-image-preview', // class for gallery thumb images galleryThumbContainerId: 'pf-landing-gallery-thumb-container', // id for gallery thumb images galleryCarouselId: 'pf-landing-gallery-carousel', // id for "carousel" element // notification panel notificationPanelId: 'pf-notification-panel', // id for "notification panel" (e.g. last update information) // sticky panel stickyPanelClass: 'pf-landing-sticky-panel', // class for sticky panels stickyPanelServerId: 'pf-landing-server-panel', // id for EVE Online server status panel stickyPanelAdminId: 'pf-landing-admin-panel', // id for admin login panel // animation animateElementClass: 'pf-animate-on-visible', // class for elements that will be animated to show defaultAcceptCookieExpire: 365 // default expire for "accept coolies" cookie }; /** * set link observer for "version info" dialog */ let setVersionLinkObserver = () => { $('.' + config.navigationVersionLinkClass).off('click').on('click', function(e){ $.fn.changelogsDialog(); }); }; /** * move panel out of "cookie" accept hint * @param direction */ let moveAdminPanel = (direction) => { let adminPanel = $('#' + config.stickyPanelAdminId); adminPanel.css({bottom: ((direction === 'up') ? '+' : '-') + '=35px'}); }; let setAcceptCookie = () => { Util.setCookie('cookie', 1, config.defaultAcceptCookieExpire, 'd'); }; /** * set page observer */ let setPageObserver = () => { let ssoButtonElement = $('.' + config.ssoButtonClass); let cookieHintElement = $('#' + config.cookieHintId); $(document).on('click', '.' + config.characterSelectionClass + ' a', function(){ $('.' + config.splashOverlayClass).showSplashOverlay(); }); $(document).on('click', '.' + config.ssoButtonClass , function(){ if(Util.getCookie('cookie') === '1'){ // ... cookies accepted no "confirm" shown $('.' + config.splashOverlayClass).showSplashOverlay(); } }); // cookie hint -------------------------------------------------------- cookieHintElement.find('.btn-success').on('click', function(){ setAcceptCookie(); // confirmation no longer needed on SSO login button ssoButtonElement.confirmation('destroy'); }); cookieHintElement.on('show.bs.collapse', function(){ // move admin panel upwards (prevents overlapping with cookie notice) moveAdminPanel('up'); }); cookieHintElement.on('hidden.bs.collapse', function(){ moveAdminPanel('down'); }); if(Util.getCookie('cookie') !== '1'){ // hint not excepted cookieHintElement.collapse('show'); // show Cookie accept hint on SSO login button let confirmationSettings = { container: 'body', placement: 'bottom', btnOkClass: 'btn btn-sm btn-default', btnOkLabel: 'dismiss', btnOkIcon: 'fas fa-fw fa-sign-in-alt', title: 'Accept cookies', btnCancelClass: 'btn btn-sm btn-success', btnCancelLabel: 'accept', btnCancelIcon: 'fas fa-fw fa-check', onCancel: function(e, target){ // "Accept cookies" setAcceptCookie(); // set "default" href let href = $(target).data('bs.confirmation').getHref(); $(e.target).attr('href', href); }, onConfirm : function(e, target){ // "NO cookies" => trigger "default" href link action }, href: function(target){ return $(target).attr('href'); } }; ssoButtonElement.confirmation(confirmationSettings); } // manual ------------------------------------------------------------- $('.' + config.navigationLinkManualClass).on('click', function(e){ e.preventDefault(); $.fn.showMapManual(); }); // license ------------------------------------------------------------ $('.' + config.navigationLinkLicenseClass).on('click', function(e){ e.preventDefault(); $.fn.showCreditsDialog(false, true); }); // releases ----------------------------------------------------------- setVersionLinkObserver(); // tooltips ----------------------------------------------------------- let mapTooltipOptions = { toggle: 'tooltip', delay: 150 }; let tooltipElements = $('[title]').not('.slide img'); tooltipElements.tooltip(mapTooltipOptions); // initial show some tooltips tooltipElements.filter('[data-show="1"]').tooltip('show'); }; /** * init image carousel */ let initCarousel = () => { // check if carousel exists if($('#' + config.galleryCarouselId).length === 0){ return; } // extent "blueimp" gallery for a textFactory method to show HTML templates Gallery.prototype.textFactory = function(obj, callback){ let newSlideContent = $('
') .addClass('text-content') .attr('imgTitle', obj.title); let moduleConfig = { name: obj.href, // template name position: newSlideContent, functions: { after: function(){ // element inserted -> load complete callback({ type: 'complete', target: newSlideContent[0] }); } } }; // render HTML file (template) let moduleData = { id: config.headHeaderMapId, bgId: config.headMapBgId, neocomId: config.mapNeocomId, browserId: config.mapBrowserId, mapBgImageId: config.mapBgImageId }; Render.showModule(moduleConfig, moduleData); return newSlideContent[0]; }; // initialize carousel ------------------------------------------------ let carousel = new Gallery([ { imgTitle: 'Browser', href: 'ui/map', type: 'text/html' }, { href: 'public/img/landing/responsive.jpg', imgTitle: 'Responsive layout', type: 'image/jpg', thumbnail: '' }, { href: 'public/img/landing/pathfinder_1.jpg', imgTitle: 'Map view', type: 'image/jpg', thumbnail: '' }, { href: 'public/img/landing/pathfinder_3.jpg', imgTitle: 'Map information', type: 'image/jpg', thumbnail: '' }, { href: 'public/img/landing/pathfinder_2.jpg', imgTitle: 'System information', type: 'image/jpg', thumbnail: '' } ], { container: '#' + config.galleryCarouselId, carousel: true, startSlideshow: false, titleProperty: 'imgTitle', transitionSpeed: 600, slideshowInterval: 5000, preloadRange: 1, onopened: function(){ // Callback function executed when the Gallery has been initialized // and the initialization transition has been completed. // -> show "demo" map // set title for first slide $(this.options.container).find(this.options.titleElement).text('Browser view'); $('#' + config.headHeaderMapId).drawDemoMap(function(){ // zoom map SVGs $('#' + config.headHeaderMapId + ' svg').velocity({ scaleX: 0.66, scaleY: 0.66 }, { duration: 360 }); // position map container $('#' + config.headHeaderMapId).velocity({ marginTop: '130px', marginLeft: '-50px' }, { duration: 360, complete: function(){ // show browser $('#' + config.mapBrowserId).velocity('transition.slideUpBigIn', { duration: 360, complete: function(){ // show neocom $('#' + config.mapNeocomId).velocity('transition.slideLeftIn', { duration: 180 }); // show background $('#' + config.mapBgImageId).velocity('transition.shrinkIn', { duration: 360 }); // when map is shown -> start carousel looping carousel.play(); } }); } }); }); } }); }; /** * get all thumbnail elements * @returns {*|jQuery|HTMLElement} */ let getThumbnailElements = () => { return $('a[data-gallery="#' + config.galleryId + '"]').not('.disabled'); }; /** * init gallery for thumbnail elements * @param newElements */ let initGallery = (newElements) => { if( newElements.length > 0){ // We have to add ALL thumbnail elements to the gallery! // -> even those which are invisible (not lazyLoaded) now! // -> This is required for "swipe" through all images let allThumbLinks = getThumbnailElements(); requirejs(['blueImpGalleryBootstrap'], () => { $(newElements).each(function(){ let borderless = false; let galleryElement = $('#' + config.galleryId); galleryElement.data('useBootstrapModal', !borderless); galleryElement.toggleClass('blueimp-gallery-controls', borderless); $(this).on('click', function(e){ e.preventDefault(); e = e || window.event; let target = e.target || e.srcElement; let link = target.src ? target.parentNode : target; let options = { index: link, event: e, container: '#' + config.galleryId, titleProperty: 'description' }; new Gallery(allThumbLinks, options); }); }); }); } }; /** * init "YouTube" video preview */ let initYoutube = () => { $('.youtube').each(function(){ // Based on the YouTube ID, we can easily find the thumbnail image $(this).css('background-image', 'url(//i.ytimg.com/vi/' + this.id + '/sddefault.jpg)'); // Overlay the Play icon to make it look like a video player $(this).append($('
', {'class': 'play'})); $(document).delegate('#' + this.id, 'click', function(){ // Create an iFrame with autoplay set to true let iFrameUrl = '//www.youtube.com/embed/' + this.id + '?autoplay=1&autohide=1'; if( $(this).data('params') ){ iFrameUrl += '&'+$(this).data('params'); } // The height and width of the iFrame should be the same as parent let iFrame = $('