From 7601ad0b4c0bdaa83fc2d60966fbcde013f28198 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Thu, 26 Apr 2018 17:43:50 +0200 Subject: [PATCH] mobile dev alpha, redirecting is working, started mobile display --- .../figli/edlp_mobile/edlp_mobile.info.yml | 7 + .../figli/edlp_mobile/edlp_mobile.module | 150 ++++++++++++++++++ .../assets/dist/scripts/history.min.js | 2 - .../edlptheme/assets/dist/scripts/main.min.js | 2 +- .../assets/dist/scripts/redirect.min.js | 4 + .../edlptheme/assets/scripts/history.js | 20 --- .../custom/edlptheme/assets/scripts/main.js | 8 +- .../edlptheme/assets/scripts/redirect.js | 53 +++++++ .../custom/edlptheme/edlptheme.info.yml | 2 +- .../custom/edlptheme/edlptheme.libraries.yml | 4 +- sites/all/themes/custom/edlptheme/gulpfile.js | 2 +- .../templates/content/edlp-home.html.twig | 4 +- .../config/sync/better_messages.settings.yml | 6 +- .../sync/block.block.edlpentreesblock.yml | 3 +- ...ew_display.node.enregistrement.default.yml | 1 + sites/default/config/sync/core.extension.yml | 1 + 16 files changed, 233 insertions(+), 36 deletions(-) create mode 100644 sites/all/modules/figli/edlp_mobile/edlp_mobile.info.yml create mode 100644 sites/all/modules/figli/edlp_mobile/edlp_mobile.module delete mode 100644 sites/all/themes/custom/edlptheme/assets/dist/scripts/history.min.js create mode 100644 sites/all/themes/custom/edlptheme/assets/dist/scripts/redirect.min.js delete mode 100644 sites/all/themes/custom/edlptheme/assets/scripts/history.js create mode 100644 sites/all/themes/custom/edlptheme/assets/scripts/redirect.js diff --git a/sites/all/modules/figli/edlp_mobile/edlp_mobile.info.yml b/sites/all/modules/figli/edlp_mobile/edlp_mobile.info.yml new file mode 100644 index 000000000..773194c9e --- /dev/null +++ b/sites/all/modules/figli/edlp_mobile/edlp_mobile.info.yml @@ -0,0 +1,7 @@ +name: 'edlp_mobile' +type: module +description: 'Handle some mobile behaviours' +core: 8.x +package: 'Edlp' +dependencies: + - domain diff --git a/sites/all/modules/figli/edlp_mobile/edlp_mobile.module b/sites/all/modules/figli/edlp_mobile/edlp_mobile.module new file mode 100644 index 000000000..a1064d163 --- /dev/null +++ b/sites/all/modules/figli/edlp_mobile/edlp_mobile.module @@ -0,0 +1,150 @@ +' . t('About') . ''; + $output .= '

' . t('Handle some mobile behaviours') . '

'; + return $output; + + default: + } +} + + +/** +* hook_entity_extra_field_info() +*/ +// function edlp_mobile_entity_extra_field_info(){ +// $extra = []; +// $extra['domain']['relations'] = [ +// 'label' => t('Relations'), +// 'description' => 'Display enregistrement relations with other content types', +// 'weight' => 99, +// ]; +// return $extra; +// } + +// should be the right way +// function edlp_mobile_entity_field_storage_info(\Drupal\Core\Entity\EntityTypeInterface $entity_type) { +// if ($entity_type->id() == 'domain') { +// $definitions['device'] = \Drupal\Core\Field\BaseFieldDefinition::create('string') +// ->setName('Device') +// ->setLabel(t('Define a target device for this domain (mobile|desktop)')) +// ->setTargetEntityTypeId($entity_type->id()); +// return $definitions; +// } +// } + +/** + * Implements hook_page_attachments(). + * @param array $attachments + */ +function edlp_mobile_page_attachments(array &$attachments) { + $is_mobile_domain = false; + + global $base_root; + //dpm($base_root, '$base_root'); + + $current_domain = preg_replace('/http:\/\/|https:\/\//i', '', $base_root); + //dpm($current_domain, '$current_domain'); + + $domain_storage = \Drupal::entityTypeManager()->getStorage('domain'); + $domains = $domain_storage->loadMultiple(); + //dpm($domains); + $domain_alias_storage = \Drupal::entityTypeManager()->getStorage('domain_alias'); + //dpm($domain_alias_storage); + + foreach ($domains as $domain_id => $domain) { + if($domain->isActive()){ + //dpm($domain); + + $alias_ids = $domain_alias_storage->getQuery()->condition('domain_id', $domain_id)->execute(); + //dpm($alias_ids, 'alias_ids'); + + $aliases = $domain_alias_storage->loadMultiple($alias_ids); + // dpm($aliases, 'aliases'); + + foreach ($aliases as $alias_id => $alias) { + if($alias->getPattern() == $current_domain){ + // we found the current domain and current alias + dpm($domain, 'domain'); + dpm($alias, 'alias'); + $env = $alias->getEnvironment(); + $env_aliases = $domain_alias_storage->loadByEnvironment($env); + dpm($env_aliases, '$env_aliases'); + // find out mibile alias and desktop alias + // this is dirty + // TODO: set target device as domain setting + if ($domain->id() == 'm_encyclopediedelaparole_org'){ + // current domain/alias is mobile + $is_mobile_domain = true; + $mobile_url = $alias->getPattern(); + // find desktop pattern + foreach ($env_aliases as $env_alias_id => $env_alias) { + if($env_alias_id != $alias_id){ + // we found the desktop pattern + $desktop_url = $env_alias->getPattern(); + } + } + }else{ + // current domain/alias is mobile + $is_mobile_domain = false; + $desktop_url = $alias->getPattern(); + // find desktop pattern + foreach ($env_aliases as $env_alias_id => $env_alias) { + if($env_alias_id != $alias_id){ + // we found the desktop pattern + $mobile_url = $env_alias->getPattern(); + } + } + } + break; + } + } + break; + } + } + + // $mobile = + $current_path = \Drupal::service('path.current')->getPath(); + $is_front = \Drupal::service('path.matcher')->isFrontPage(); + $current_language = \Drupal::languageManager()->getCurrentLanguage()->getId(); + + // $redirect = false; + $js_str = "var edlp_mobile = {\n + current_url:'".$base_root."',\n + current_path:'".$current_path."',\n + is_front:".($is_front ? 'true':'false').",\n + lang_code:'".$current_language."',\n + is_mobile_domain:".($is_mobile_domain ? 'true':'false').",\n + mobile_url:'".$mobile_url."',\n + desktop_url:'".$desktop_url."',\n + };"; + + $attachments['#attached']['html_head'][] = [ + [ + '#type' => 'html_tag', + '#tag' => 'script', + '#value' => $js_str, + '#weight' => -1000, + '#group' => 'edlp' + ], + // A key, to make it possible to recognize this HTML element when altering. + 'edlp_mobile', + ]; +} diff --git a/sites/all/themes/custom/edlptheme/assets/dist/scripts/history.min.js b/sites/all/themes/custom/edlptheme/assets/dist/scripts/history.min.js deleted file mode 100644 index 89e356891..000000000 --- a/sites/all/themes/custom/edlptheme/assets/dist/scripts/history.min.js +++ /dev/null @@ -1,2 +0,0 @@ - -void 0;if(edlp.redirect){void 0;void 0;edlp.sys_path=edlp.sys_path.replace(/^\//,'');edlp.url=window.location.pathname;edlp.hash=window.location.hash;window.localStorage.setItem('edlp_origin',JSON.stringify(edlp));window.location.replace(window.location.origin+'/'+edlp.lang_code);}else{void 0;} \ No newline at end of file diff --git a/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js b/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js index 785c5af9b..4bb2edb12 100644 --- a/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js +++ b/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js @@ -1,7 +1,7 @@ (function($,Drupal,drupalSettings){EdlpTheme=function(){var _ajax_settings=drupalSettings.edlp_ajax;var _$body=$('body');var _corpus_ready=false;var _$corpus_canvas;var _$row=$('main[role="main"]>.layout-content>.row');var _$ajaxLinks;var _audioPlayer;var _randomPlayer;var _compoPlayer;var _ajax_timing={start:0,end:0};var _corpus_promise;function init(){void 0;if(!drupalSettings.path.isFront) return;initEvents();_audioPlayer=new AudioPlayer();_compoPlayer=new CompoPlayer();checkLayout();initAjaxLinks();initHistory();};function initEvents(){var $corpus_df=$.Deferred();_corpus_promise=$corpus_df.promise();_$body.on('corpus-map-ready',function(e){onCorpusMapReady(e);$corpus_df.resolve();}).on('on-studio-chutier-updated',initAjaxLinks).on('studio-initialized',function(e){_compoPlayer.newCompo();}).on('studio-not-active',function(e){_compoPlayer.deactivate();}).on('on-studio-compo-updated',function(e){initAjaxLinks();_compoPlayer.refresh();}).on('on-studio-compo-opened',function(e){initAjaxLinks();_compoPlayer.newCompo();}).on('search-results-loaded',initAjaxLinks).on('open_entree',function(e){void 0;closeAllModals();checkLayout();_$body.removeClass();if(typeof e.url!='undefined'){var state=getSysPathState(e.sys_path);history.pushState(state,null,e.url);if(typeof _paq!=='undefined'){_paq.push(['setCustomUrl',e.url]);_paq.push(['setDocumentTitle',e.title]);_paq.push(['trackPageView']);}}}).on('close_entree',function(e){backToFrontPage();checkLayout();});window.addEventListener('resize',checkLayout,false);} -function checkLayout(){var $audioplayer=$("#audio-player");if($audioplayer.length){var navpos=$('#block-mainnavigation').position();void 0;$audioplayer.css({'width':navpos.left+'px'});}};function initScrollbars(){};function getSysPathState(sys_path,view_mode){var state={'sys_path':sys_path,'ajax_path':sys_path};var node_match=state.ajax_path.match(/^\/?(node\/(\d+))$/i);void 0;var term_match=state.ajax_path.match(/^\/?(taxonomy\/term\/(\d+))$/i);void 0;if(node_match){state.ajax_path=_ajax_settings.entityjson_path+'/'+node_match[1];state.node_nid=node_match[2];if(view_mode){state.ajax_path+='/'+view_mode;state.view_mode=view_mode;}}else if(term_match){state.ajax_path=_ajax_settings.entityjson_path+'/'+term_match[1];state.ajax_path=state.ajax_path.replace(/taxonomy\/term/,'taxonomy_term');state.entree_tid=term_match[2];if(view_mode){state.ajax_path+='/'+view_mode;state.view_mode=view_mode;}else{state.ajax_path=null;}}else{state.ajax_path+='/ajax'} +function checkLayout(){var $audioplayer=$("#audio-player");if($audioplayer.length){var navpos=$('#block-mainnavigation').position();void 0;if(typeof navpos!='undefined'){$audioplayer.css({'width':navpos.left+'px'});}}};function initScrollbars(){};function getSysPathState(sys_path,view_mode){var state={'sys_path':sys_path,'ajax_path':sys_path};var node_match=state.ajax_path.match(/^\/?(node\/(\d+))$/i);void 0;var term_match=state.ajax_path.match(/^\/?(taxonomy\/term\/(\d+))$/i);void 0;if(node_match){state.ajax_path=_ajax_settings.entityjson_path+'/'+node_match[1];state.node_nid=node_match[2];if(view_mode){state.ajax_path+='/'+view_mode;state.view_mode=view_mode;}}else if(term_match){state.ajax_path=_ajax_settings.entityjson_path+'/'+term_match[1];state.ajax_path=state.ajax_path.replace(/taxonomy\/term/,'taxonomy_term');state.entree_tid=term_match[2];if(view_mode){state.ajax_path+='/'+view_mode;state.view_mode=view_mode;}else{state.ajax_path=null;}}else{state.ajax_path+='/ajax'} return state;};function ajaxLoadContent(state){void 0;_$body.addClass('ajax-loading');_ajax_timing.start=performance.now();var path=window.location.origin+Drupal.url(state.ajax_path);$.getJSON(path,{}).done(function(data){onAjaxLoaded(data,state);}).fail(function(jqxhr,textStatus,error){onAjaxLoadError(jqxhr,textStatus,error,state.sys_path);});};function onAjaxLoadError(jqxhr,textStatus,error,sys_path){void 0;$('.ajax-loading').removeClass('ajax-loading');_$body.removeClass('ajax-loading');};function onAjaxLoaded(data,state){void 0;if(data.entity_type=="node"&&data.bundle=="evenement"){if(_$row.find('.col.event').length){_$row.find('.col.event').replaceWith(data.rendered);}else if(_$row.find('.col.aside').length){_$row.find('.col.aside').replaceWith(data.rendered);}else{_$row.append(data.rendered);}}else{_$row.removeAttr('style').html(data.rendered);} var body_classes=['path-'+state.sys_path.replace(/\//g,'-'),'entity-type-'+data.entity_type,'bundle-'+data.bundle,'view-mode-'+data.view_mode];_$body.removeClass().addClass(body_classes.join(' '));if(state.node_nid) _$body.addClass('path-edlp-node');$('.ajax-loading').removeClass('ajax-loading');$('.ajax-link.is-active').removeClass('is-active');$('.is-active-trail').removeClass('is-active-trail');if(typeof state.selector!='undefined'){void 0;$('a[selector="'+state.selector+'"]').addClass('is-active');initAudioLinksInContent();}else{if(typeof state.view_mode!='undefined'){$('a[viewmode="'+state.view_mode+'"][data-drupal-link-system-path="'+state.sys_path+'"]').addClass('is-active');}else{$('a[data-drupal-link-system-path="'+state.sys_path+'"]').addClass('is-active');} diff --git a/sites/all/themes/custom/edlptheme/assets/dist/scripts/redirect.min.js b/sites/all/themes/custom/edlptheme/assets/dist/scripts/redirect.min.js new file mode 100644 index 000000000..75ff52db5 --- /dev/null +++ b/sites/all/themes/custom/edlptheme/assets/dist/scripts/redirect.min.js @@ -0,0 +1,4 @@ + +void 0;function checkMobile(){var user_agent=navigator.userAgent||navigator.vendor||window.opera;return/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge|maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm(os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(user_agent)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(user_agent.substr(0,4));} +if(typeof edlp_mobile!="undefined"){void 0;void 0;var device_redirect=false;var device_is_mobile=checkMobile();void 0;void 0;switch(true){case(device_is_mobile&&!edlp_mobile.is_mobile_domain):void 0;device_redirect=true;window.location.replace(window.location.protocol+'//'+edlp_mobile.mobile_url);break;case(edlp_mobile.is_mobile_domain&&!device_is_mobile):void 0;device_redirect=true;window.location.replace(window.location.protocol+'//'+edlp_mobile.desktop_url);break;default:void 0;break;}} +if(edlp.redirect&&!device_redirect){void 0;void 0;edlp.sys_path=edlp.sys_path.replace(/^\//,'');edlp.url=window.location.pathname;edlp.hash=window.location.hash;window.localStorage.setItem('edlp_origin',JSON.stringify(edlp));window.location.replace(window.location.origin+'/'+edlp.lang_code);}else{void 0;} \ No newline at end of file diff --git a/sites/all/themes/custom/edlptheme/assets/scripts/history.js b/sites/all/themes/custom/edlptheme/assets/scripts/history.js deleted file mode 100644 index 6ed8192af..000000000 --- a/sites/all/themes/custom/edlptheme/assets/scripts/history.js +++ /dev/null @@ -1,20 +0,0 @@ -console.log('EDLP THEME HISTORY.js'); -// var edlp is provided by edlp_ajax.module file -if(edlp.redirect){ - console.log('history redirect', edlp); - console.log('window.location', window.location); - // window.localStorage.setItem('edlp_origin_path', edlp.sys_path.replace(/^\//, '')); - edlp.sys_path = edlp.sys_path.replace(/^\//, ''); - - // window.localStorage.setItem('edlp_origin_url', window.location.pathname); - edlp.url = window.location.pathname; - - // window.localStorage.setItem('edlp_origin_hash', window.location.hash); - edlp.hash = window.location.hash; - - window.localStorage.setItem('edlp_origin', JSON.stringify(edlp)); - // redirect to home - window.location.replace(window.location.origin+'/'+edlp.lang_code); -}else{ - console.log('history do not redirect'); -} diff --git a/sites/all/themes/custom/edlptheme/assets/scripts/main.js b/sites/all/themes/custom/edlptheme/assets/scripts/main.js index 403304d8a..863a38c85 100644 --- a/sites/all/themes/custom/edlptheme/assets/scripts/main.js +++ b/sites/all/themes/custom/edlptheme/assets/scripts/main.js @@ -121,9 +121,11 @@ if($audioplayer.length){ var navpos = $('#block-mainnavigation').position(); console.log('navpos', navpos); - $audioplayer.css({ - 'width':navpos.left+'px' - }); + if(typeof navpos != 'undefined'){ + $audioplayer.css({ + 'width':navpos.left+'px' + }); + } } // entrees diff --git a/sites/all/themes/custom/edlptheme/assets/scripts/redirect.js b/sites/all/themes/custom/edlptheme/assets/scripts/redirect.js new file mode 100644 index 000000000..4110561dc --- /dev/null +++ b/sites/all/themes/custom/edlptheme/assets/scripts/redirect.js @@ -0,0 +1,53 @@ +console.log('EDLP THEME redirect.js'); + +function checkMobile(){ + var user_agent = navigator.userAgent||navigator.vendor||window.opera; + return /(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino/i.test(user_agent) || /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(user_agent.substr(0,4)); +} + +// var edlp_mobile is provided by edlp_mobile.module file +if(typeof edlp_mobile != "undefined"){ + console.log(edlp_mobile); + console.log('window.location', window.location); + var device_redirect = false; + var device_is_mobile = checkMobile(); + console.log('is_mobile_domain', edlp_mobile.is_mobile_domain); + console.log('device_is_mobile', device_is_mobile); + switch(true){ + case (device_is_mobile && !edlp_mobile.is_mobile_domain): + console.log('redirect to mobile domain', window.location.protocol +'//'+ edlp_mobile.mobile_url); + device_redirect = true; + // TODO: redirect to mobile domain + window.location.replace(window.location.protocol +'//'+ edlp_mobile.mobile_url); + break; + case (edlp_mobile.is_mobile_domain && !device_is_mobile): + console.log('redirect to desktop domain', window.location.protocol +'//'+ edlp_mobile.desktop_url); + device_redirect = true; + // TODO: redirect to desktop domain + window.location.replace(window.location.protocol +'//'+ edlp_mobile.desktop_url); + break; + default: + console.log('do not redirect'); + break; + } +} + +// var edlp is provided by edlp_ajax.module file +if(edlp.redirect && !device_redirect){ + console.log('redirect', edlp); + console.log('window.location', window.location); + // window.localStorage.setItem('edlp_origin_path', edlp.sys_path.replace(/^\//, '')); + edlp.sys_path = edlp.sys_path.replace(/^\//, ''); + + // window.localStorage.setItem('edlp_origin_url', window.location.pathname); + edlp.url = window.location.pathname; + + // window.localStorage.setItem('edlp_origin_hash', window.location.hash); + edlp.hash = window.location.hash; + + window.localStorage.setItem('edlp_origin', JSON.stringify(edlp)); + // redirect to home + window.location.replace(window.location.origin+'/'+edlp.lang_code); +}else{ + console.log('history do not redirect'); +} diff --git a/sites/all/themes/custom/edlptheme/edlptheme.info.yml b/sites/all/themes/custom/edlptheme/edlptheme.info.yml index 5013a92eb..53d255d70 100644 --- a/sites/all/themes/custom/edlptheme/edlptheme.info.yml +++ b/sites/all/themes/custom/edlptheme/edlptheme.info.yml @@ -5,7 +5,7 @@ base theme: classy core: 8.x libraries: - core/normalize - - edlptheme/history-js + - edlptheme/redirect-js - edlptheme/global-css - edlptheme/global-js diff --git a/sites/all/themes/custom/edlptheme/edlptheme.libraries.yml b/sites/all/themes/custom/edlptheme/edlptheme.libraries.yml index 4748329e0..faf5b02fa 100644 --- a/sites/all/themes/custom/edlptheme/edlptheme.libraries.yml +++ b/sites/all/themes/custom/edlptheme/edlptheme.libraries.yml @@ -4,11 +4,11 @@ global-css: theme: assets/dist/styles/app.min.css: {} -history-js: +redirect-js: version: VERSION header: true js: - assets/dist/scripts/history.min.js: { weight:-998, preprocess: false, minified: true } + assets/dist/scripts/redirect.min.js: { weight:-998, preprocess: false, minified: true } global-js: version: VERSION diff --git a/sites/all/themes/custom/edlptheme/gulpfile.js b/sites/all/themes/custom/edlptheme/gulpfile.js index bec20e993..c048bc226 100644 --- a/sites/all/themes/custom/edlptheme/gulpfile.js +++ b/sites/all/themes/custom/edlptheme/gulpfile.js @@ -29,7 +29,7 @@ function handleError(err) { } gulp.task('scripts', function () { - gulp.src(['./assets/scripts/main.js', './assets/scripts/history.js']) // './assets/scripts/shared_variables.js', + gulp.src(['./assets/scripts/main.js', './assets/scripts/redirect.js']) // './assets/scripts/shared_variables.js', // .pipe(concat('main.js')) .pipe(gulpif(prod, stripDebug())) .pipe(gulpif(prod, jsmin())) diff --git a/sites/all/themes/custom/edlptheme/templates/content/edlp-home.html.twig b/sites/all/themes/custom/edlptheme/templates/content/edlp-home.html.twig index 9678c0dad..dc7302f6c 100644 --- a/sites/all/themes/custom/edlptheme/templates/content/edlp-home.html.twig +++ b/sites/all/themes/custom/edlptheme/templates/content/edlp-home.html.twig @@ -18,7 +18,7 @@
{% for node in nodes %} -
+
{{ node.build }}
@@ -26,7 +26,7 @@ {% endfor %} -
+
{{ agenda }}
diff --git a/sites/default/config/sync/better_messages.settings.yml b/sites/default/config/sync/better_messages.settings.yml index 6a551d268..c46bdf191 100644 --- a/sites/default/config/sync/better_messages.settings.yml +++ b/sites/default/config/sync/better_messages.settings.yml @@ -2,7 +2,7 @@ position: tr vertical: 70 horizontal: 10 fixed: 1 -width: 400px +width: 600px autoclose: 7 opendelay: 0.3 disable_autoclose: 1 @@ -15,8 +15,8 @@ popout: effect: fadeIn duration: fast jquery_ui: - draggable: 0 - resizable: 0 + draggable: 1 + resizable: 1 visibility: message_type: id: message_type diff --git a/sites/default/config/sync/block.block.edlpentreesblock.yml b/sites/default/config/sync/block.block.edlpentreesblock.yml index 9f530df40..d026d8ceb 100644 --- a/sites/default/config/sync/block.block.edlpentreesblock.yml +++ b/sites/default/config/sync/block.block.edlpentreesblock.yml @@ -25,7 +25,8 @@ visibility: domains: encyclopediedelaparole_org: encyclopediedelaparole_org negate: false - context_mapping: { } + context_mapping: + 'entity:domain': '@domain.current_domain_context:entity:domain' request_path: id: request_path pages: '' diff --git a/sites/default/config/sync/core.entity_view_display.node.enregistrement.default.yml b/sites/default/config/sync/core.entity_view_display.node.enregistrement.default.yml index 7e4ba7d18..9da35465f 100644 --- a/sites/default/config/sync/core.entity_view_display.node.enregistrement.default.yml +++ b/sites/default/config/sync/core.entity_view_display.node.enregistrement.default.yml @@ -45,6 +45,7 @@ content: link: false third_party_settings: { } hidden: + addtoany: true body: true chutier_actions: true field_collectionneurs: true diff --git a/sites/default/config/sync/core.extension.yml b/sites/default/config/sync/core.extension.yml index b20c93e64..ea7f1daaa 100644 --- a/sites/default/config/sync/core.extension.yml +++ b/sites/default/config/sync/core.extension.yml @@ -39,6 +39,7 @@ module: edlp_fils: 0 edlp_home: 0 edlp_migrate: 0 + edlp_mobile: 0 edlp_productions: 0 edlp_search: 0 edlp_studio: 0