'use strict'; /** * Config for the router */ app.run( ['$rootScope', '$state', '$stateParams','$window','$location', function ($rootScope, $state, $stateParams, $window, $location) { $rootScope.$state = $state; $rootScope.$stateParams = $stateParams; $rootScope.$on('$stateChangeSuccess', function (event) { $window.ga('send', 'pageview', $location.path()); }); } ] ) .config( [ '$stateProvider', '$urlRouterProvider','$controllerProvider','$locationProvider', function ($stateProvider, $urlRouterProvider,$controllerProvider,$locationProvider) { $locationProvider.html5Mode(true); $locationProvider.hashPrefix(''); var states = []; states.push({ name:'app', abstract: true }); states.push({ name:'app.index', url:'/?id', views: { 'boxCenter': { templateUrl:'application/index/home', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'howtoapply', url:'/how-to-apply', views: { 'boxCenter': { templateUrl:'how-to-apply/home', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'unavailable', url:'/not-available', views: { 'boxCenter': { templateUrl:'/application/index/unavailable', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'survey', url:'/survey?id', views: { 'boxCenter': { templateUrl:'survey/home', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'sitemap', url:'/site-map', views: { 'boxCenter': { templateUrl:'site-map/home', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'contacts', url:'/contacts', views: { 'boxCenter': { templateUrl:'contacts/home', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'faq', url:'/support', views: { 'boxCenter': { templateUrl:'faq/template', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ //controller:'MscLifeStyleDetailCtrl' }); }] } } } }); states.push({ name:'vacancies', abstract: true }); states.push({ name:'vacancies.detailonb', url:'/vacancies/onboard-jobs', views: { 'boxCenter': { templateUrl: function (stateParams) { return 'vacancies/onboard-jobs-page'; },resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load([ { name : 'app.jobsManageSelect', files : ['module/Application/js/selectJob.js' ] }] ); }] } } } }); states.push({ name:'vacancies.detailonb.search', url:'/search?paramS', views: { 'boxCenter.botton': { templateUrl:'vacancies/search-job-on-board', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ // controller : 'SearchSendOnBoardCtrl' }); }] } } } }); states.push({ name:'vacancies.detailofb', url:'/vacancies/office-jobs', views: { 'boxCenter': { templateUrl: function (stateParams) { return 'vacancies/office-jobs-page'; },resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load([ { name : 'app.jobsManageSelect', files : [ 'module/Application/js/selectJob.js' ] }] ); }] } } } }); states.push({ name:'vacancies.detailofb.search', url:'/search?paramS', views: { 'boxCenter.botton': { templateUrl:'vacancies/search-job-office', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ // controller : 'SearchSendOnBoardCtrl' }); }] } } } }); states.push({ name:'whymsc', abstract: true }); states.push({ name:'whymsc.detail', url:'/why-msc-cruises/{sez:[^?{}<>()]{1,30}}', views: { 'boxCenter': { templateUrl: function (stateParams) { if(stateParams.sez=='social-responsability'){ return 'why-msc/social-responsability'; } else { return 'why-msc/home'; } } } } }); states.push({ name:'whymsc.detail.sub', url:'/:sub', views: { 'boxCenter.detail': { templateUrl:'why-msc/detail', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ //controller:'MscLifeStyleDetailCtrl' }); }] } } } }); states.push({ name:'msclifestyle', abstract: true }); states.push({ name:'msclifestyle.detail', url:'/working-with-us/:sez', views: { 'boxCenter': { templateUrl: function (stateParams) { return 'lifestyle/'+stateParams.sez; },resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load([ { name : 'app.jobsManageSelect', files : [ 'module/Application/js/selectJob.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-world-mill-en.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-it_regions-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-ch-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-asia-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-europe-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-north_america-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-oceania-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-au-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-south_america-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-africa-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-at-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-be-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-cn-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-de-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-es-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-fr_regions_2016-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-nl-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-pt-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-se-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-uk-mill-en.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-data-turkey-tr-en.js', 'script/jvectormap/bower-jvectormap/japan-en.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-il-mill.js' ] }] ); }] } } } }); states.push({ name:'msclifestyle.detail.sub', url:'/:sub', views: { 'boxCenter.detail': { templateUrl:'lifestyle/detail', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ //controller:'MscLifeStyleDetailCtrl' }); }] } } } }); states.push({ name:'careerpath', abstract: true }); states.push({ name:'careerpath.detail', url:'/career-path/:sez', views: { 'boxCenter': { templateUrl: function (stateParams) { return 'careerpath/'+stateParams.sez; },resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load([ { name : 'app.jobsManageSelect', files : [ 'module/Application/js/selectJob.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-world-mill-en.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-it_regions-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-ch-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-asia-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-europe-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-north_america-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-oceania-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-au-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-south_america-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-africa-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-at-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-be-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-cn-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-de-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-es-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-fr_regions_2016-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-nl-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-pt-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-se-mill.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-uk-mill-en.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-data-turkey-tr-en.js', 'script/jvectormap/bower-jvectormap/japan-en.js', 'script/jvectormap/bower-jvectormap/jquery-jvectormap-il-mill.js' ] }] ); }] } } } }); states.push({ name:'careerpath.detail.sub', url:'/:sub', views: { 'boxCenter.detail': { templateUrl:'careerpath/detail', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ //controller:'CareerPathDetailCtrl' }); }] } } } }); states.push({ name:'careerpath.detail.sub2', url:'^/career-path/career-path/:sub', views: { 'boxCenter.detail': { templateUrl:'careerpath/detail', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ //controller:'CareerPathDetailCtrl' }); }] } } } }); states.push({ name:'privacy', abstract: true }); states.push({ name:'privacy.sub', url:'/privacy-policy/:sub', views: { 'boxCenter': { templateUrl:'privacy/home', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ //controller:'MscLifeStyleDetailCtrl' }); }] } } } }); states.push({ name:'aboutus', abstract: true }); states.push({ name:'aboutus.sub', url:'/about-us/:sub', views: { 'boxCenter': { templateUrl:'about-us/home', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ //controller:'MscLifeStyleDetailCtrl' }); }] } } } }); states.push({ name:'terms', abstract: true }); states.push({ name:'terms.sub', url:'/terms-and-conditions/:sub', views: { 'boxCenter': { templateUrl:'terms/home', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ //controller:'MscLifeStyleDetailCtrl' }); }] } } } }); /* states.push({ name:'msclifestyle.our-people', url:'/msc-lifestyle/our-people', views: { 'boxCenter': { templateUrl:'lifestyle/our-people', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'msclifestyle.equal-opportunities', url:'/msc-lifestyle/equal-opportunities', views: { 'boxCenter': { templateUrl:'lifestyle/equal-opportunities', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'msclifestyle.ashore-experience', url:'/msc-lifestyle/ashore-experience', views: { 'boxCenter': { templateUrl:'lifestyle/ashore-experience', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ controller: 'MscLifeStyleAeCtrl' }); }] } } } }); states.push({ name:'msclifestyle.ashore-experience.detail', url:'/{sez:[^?{}<>()]{1,60}}', views: { 'boxCenter.detail': { templateUrl:'lifestyle/detail', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'msclifestyle.life-onboard', url:'/msc-lifestyle/life-onboard', views: { 'boxCenter': { templateUrl:'lifestyle/life-onboard', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'msclifestyle.try-before-applying', url:'/msc-lifestyle/try-before-applying', views: { 'boxCenter': { templateUrl:'lifestyle/try-before-applying', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); */ states.push({ name:'applynow', abstract: true }); states.push({ name:'applynow.home', url:'/apply-now', views: { 'boxCenter': { templateUrl:'apply-now/home', resolve: { deps: [ '$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load([ { name : 'app.jobsManageSelect', files : ['module/Application/js/selectJob.js' ] }] ); } ] } } } }); states.push({ name:'applynow.home.job', url:'/job?paramS', views: { 'boxCenter.botton': { templateUrl:'application-job/search-job', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ controller : 'SearchCtrl' }); }] } } } }); states.push({ name:'onboardjobs', abstract: true }); states.push({ name:'explorajobs', abstract: true }); states.push({ name:'onboardjobs.detail', url:'/onboard-jobs/{dep:[^?{}<>()]{1,30}}/{name:[^?{}<>()]{1,30}}', views: { 'boxCenter': { templateUrl:'onboard-jobs/home', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'officejobs', abstract: true }); states.push({ name:'officejobs.detail', url:'/office-jobs/{dep:[^?{}<>()]{1,30}}/{name:[^?{}<>()]{1,30}}', views: { 'boxCenter': { templateUrl:'onboard-jobs/home', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'confirmtalentinterview', url:'/confirm-talent-interview/{eid:[^?{}<>()]{1,32}}', views: { 'boxCenter': { templateUrl:'confirm-talent-interview/application', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'confirmtalentcute', url:'/confirm-talent-cute/?{get:[^?{}<>()]{1,4000}}', views: { 'boxCenter': { templateUrl:'confirm-talent-cute/application', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'unscribe', url:'/unscribe', views: { 'boxCenter': { templateUrl:'unscribe/home', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); states.push({ name:'unscribeapplication', url:'/unscribe-application/{eid:[^?{}<>()]{1,32}}', views: { 'boxCenter': { templateUrl:'unscribe/application', resolve: { deps: ['$ocLazyLoad', function( $ocLazyLoad){ return $ocLazyLoad.load({ }); }] } } } }); $urlRouterProvider.otherwise('/'); angular.forEach(states, function(state) { $stateProvider.state(state); }); } ] ) .controller('menuCtrl', function($scope,$rootScope, $http, $filter,superCache) { var aDepartment = superCache.get('oDepartment'); $http .post('application/index/get-department') .success( function(data) { superCache.put( 'oDepartment', data); $rootScope.aDepartment = data; }).error(function(data) { alert(data); }); var aWhyMsc = superCache.get('oWhyMsc'); $http .get('/json/why-msc.json') .success( function(data) { superCache.put('oWhyMsc', data); $rootScope.aWhyMsc = data; }).error(function(data) { alert(data); }); var aMscLifestyle = superCache.get('oMscLifestyle'); $http .get('/json/msc-lifestyle.json') .success( function(data) { superCache.put('oMscLifestyle', data); $rootScope.aMscLifestyle = data; }).error(function(data) { alert(data); }); var aVacanciesMenu = superCache.get('oVacanciesMenu'); $http .get('/json/vacancies.json') .success( function(data) { superCache.put('oVacanciesMenu', data); $rootScope.aVacanciesMenu = data; }).error(function(data) { alert(data); }); var aMscValues = superCache.get('oMscValues'); $http .get('/json/values.json') .success( function(data) { superCache.put('oMscValues', data); $rootScope.aMscValues = data; }).error(function(data) { alert(data); }); var aMscCareerpath = superCache.get('aMscCareerpath'); $http .get('/json/career-path.json') .success( function(data) { superCache.put( 'aMscCareerpath', data); $rootScope.aMscCareerpath = data; }).error(function(data) { alert(data); }); var aMscMoreInfo = superCache.get('oMscMoreInfo'); $http .get('/json/more_info.json') .success( function(data) { superCache.put( 'oMscMoreInfo', data); $rootScope.aMscMoreInfo = data; }).error(function(data) { alert(data); }); $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams){ if(toState.name.indexOf('sub') == -1 && toState.name.indexOf('search') == -1 && toState.name.indexOf('applynow.home.job') == -1){ $(document).scrollTop(0); } }); /***** scroll anim ***********/ $(window).scroll(function(){ if($(window).width()>880){ if($(window).scrollTop() > 85 && !$('#main_menu').hasClass('fixed')){ $('#main_menu').addClass('fixed'); } else if($(window).scrollTop() < 85 && $('#main_menu').hasClass('fixed')){ $('#main_menu').removeClass('fixed'); } } }); /****** global menu ********/ var interaction_type = 0; var sub_item; function is_touch_device() { return (('ontouchstart' in window) || (navigator.MaxTouchPoints > 0) || (navigator.msMaxTouchPoints > 0)); } if(is_touch_device() || (!is_touch_device() && $(window).width() < 880) ){ interaction_type = 0; $('#menu_lower > ul li > a').unbind('click'); $('#menu_lower > ul li > a').bind('click',function(){ sub_item = $(this); submenu_toggle(); }); } else { interaction_type = 1; $('#menu_lower > ul li').bind('mouseover',function(){ $(this).addClass('hover'); }).bind('mouseout',function(){ $(this).removeClass('hover'); }); } function check_interaction(){ // chiudi menu se aperti al cambio di impostazione menu// if($('#menu_lower > ul li').hasClass('hover')){ $('#menu_lower > ul li').removeClass('hover').removeClass('active'); } // rimuovi menu se fisso (con pagina scrolata) al cambio di impostazione menu // if($(window).width() < 880 && $('#main_menu').hasClass('fixed')){ $('#main_menu').removeClass('fixed'); } else if ($(window).width()>880){ $(window).trigger('scroll'); } // cambia il tipo di controllo tra mobile con click e desktop con hover // if( (is_touch_device() || (!is_touch_device() && $(window).width() < 880) ) && interaction_type == 1){ interaction_type = 0; $('#menu_lower > ul li > a').unbind('mouseover').unbind('mouseout'); $('#menu_lower > ul li > a').bind('click',function(){ sub_item = $(this); submenu_toggle(); }); } else if(!is_touch_device() && $(window).width()>880 && interaction_type == 0){ interaction_type = 1; $('#menu_lower > ul li').unbind('click'); $('#menu_lower > ul li').bind('mouseover',function(){ $(this).addClass('hover'); }).bind('mouseout',function(){ $(this).removeClass('hover'); }); }} // funzione per apri e chiudi function submenu_toggle(){ if(!sub_item.parent('li').hasClass('hover')){ sub_item.parent('li').addClass('hover').addClass('active'); if($(window).width() > 880){ sub_item.parent('li').siblings().removeClass('active').removeClass('hover') } } else if(sub_item.parent('li').hasClass('hover')){ sub_item.parent('li').removeClass('hover').removeClass('active'); } } check_interaction(); $(window).resize(check_interaction); });