big refactoring of mobile version xhich has now a hamburger menu and a link to collection

This commit is contained in:
2018-11-21 12:51:24 +01:00
parent c92c348eee
commit e204a08202
18 changed files with 668 additions and 389 deletions
@@ -42,6 +42,13 @@ function edlp_corpus_theme($existing, $type, $theme, $path) {
'articles_nodes' => NULL,
),
),
'edlp_corpus_collection' => array(
// 'render element' => '',
'file' => 'includes/edlp_corpus_collection.inc',
'variables' => array(
'entrees_terms' => NULL,
),
),
);
}
@@ -31,7 +31,6 @@ edlp_corpus.lastdocsajax:
requirements:
_permission: 'access content'
edlp_corpus.articlesindex:
path: '/articles'
defaults:
@@ -47,3 +46,19 @@ edlp_corpus.articlesindexajax:
_title: 'Articles Index'
requirements:
_permission: 'access content'
edlp_corpus.collection:
path: '/collection'
defaults:
_controller: '\Drupal\edlp_corpus\Controller\CorpusController::collection'
_title: 'Collection'
requirements:
_permission: 'access content'
edlp_corpus.collectionajax:
path: '/collection/ajax'
defaults:
_controller: '\Drupal\edlp_corpus\Controller\CorpusController::collectionjson'
_title: 'Collection'
requirements:
_permission: 'access content'
@@ -0,0 +1,29 @@
<?php
use Drupal\Core\Url;
function template_preprocess_edlp_corpus_collection(&$vars){
$term_view_builder = \Drupal::entityTypeManager()->getViewBuilder('taxonomy_term');
if(isset($vars['entrees_terms'])){
$entrees = array(
'#type'=>"container",
// '#attributes' => array(
// 'id' => array('collection'),
// ),
'#prefix' => '<div id="collection"></div>',
'title'=>array(
'#markup'=>"<h3>".t("Collection")."</h3>",
),
'list'=> array(
'#theme' => 'item_list',
'#items' => [],
),
);
foreach($vars['entrees_terms'] as $term){
$entrees['list']['#items'][] = $term_view_builder->view($term, 'home_mobile');
}
$vars['entrees'] = render($entrees);
}
}
@@ -7,6 +7,7 @@ use Drupal\Core\Language\LanguageInterface;
use Drupal\workflow\Entity\WorkflowManager;
use Drupal\Core\Url;
use Drupal\File\Entity\File;
use Drupal\taxonomy\Entity\Term;
// use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Cache\CacheableJsonResponse;
use Drupal\Core\Cache\CacheableMetadata;
@@ -251,107 +252,199 @@ class CorpusController extends ControllerBase {
// /_/ \_\_| \__|_\__|_\___/__/ |___|_||_\__,_\___/_\_\
private function articlesQuery() {
$query = \Drupal::entityQuery('node')
->condition('status', 1)
->condition('type', 'enregistrement')
->condition('body', '', "<>")
->sort('created', 'DESC');
// ->range(0,20);
private function articlesQuery() {
$query = \Drupal::entityQuery('node')
->condition('status', 1)
->condition('type', 'enregistrement')
->condition('body', '', "<>")
->sort('created', 'DESC');
// ->range(0,20);
$nids = $query->execute();
$nodes = entity_load_multiple('node', $nids);
$nids = $query->execute();
$nodes = entity_load_multiple('node', $nids);
$current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
$current_langcode = \Drupal::languageManager()->getCurrentLanguage()->getId();
$this->articles_nodes = [];
$this->articles_nids = [];
foreach ($nodes as $node) {
// remove masqué
$sid = WorkflowManager::getCurrentStateId($node, 'field_workflow');
if($sid != 'corpus_documents_publie') continue;
$this->articles_nodes = [];
$this->articles_nids = [];
foreach ($nodes as $node) {
// remove masqué
$sid = WorkflowManager::getCurrentStateId($node, 'field_workflow');
if($sid != 'corpus_documents_publie') continue;
// TODO: check if article is translated
if ($node->getTranslation($current_langcode)->body->isEmpty()) continue;
$this->articles_nodes[] = $node;
// record an array of nids for corpus map filtering
$this->articles_nids[] = $node->get('nid')->getString();
}
// TODO: check if article is translated
if ($node->getTranslation($current_langcode)->body->isEmpty()) continue;
$this->articles_nodes[] = $node;
// record an array of nids for corpus map filtering
$this->articles_nids[] = $node->get('nid')->getString();
}
private function articlesToRenderable(){
$this->articlesQuery();
// dpm($this->next_event_node);
}
return array(
"#theme"=>'edlp_corpus_articlesindex',
'#articles_nodes' => $this->articles_nodes
);
private function articlesToRenderable(){
$this->articlesQuery();
// dpm($this->next_event_node);
}
/**
* Display lastdocs as a page.
*
* @return renderable array
*/
public function articlesindex() {
return $this->articlesToRenderable();
}
return array(
"#theme"=>'edlp_corpus_articlesindex',
'#articles_nodes' => $this->articles_nodes
);
/**
* Get lastdocs data as json through ajax.
*
* @return json
*/
public function articlesindexjson() {
}
/**
* Display lastdocs as a page.
*
* @return renderable array
*/
public function articlesindex() {
return $this->articlesToRenderable();
}
$renderable = $this->articlesToRenderable();
// $rendered = render($renderable);
// We can't render directly the entity as it throw an exception with cachable data
//http://blog.dcycle.com/blog/2018-01-24/caching-drupal-8-rest-resource/#the-dreaded-leaked-metadata-error
$rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($renderable) {
return render($renderable);
});
/**
* Get lastdocs data as json through ajax.
*
* @return json
*/
public function articlesindexjson() {
$data = [
'rendered'=> $rendered,
'title'=>'Articles',
'articles' => $this->articles_nids,
'documents_lies' => $this->articles_nids,
$renderable = $this->articlesToRenderable();
// $rendered = render($renderable);
// We can't render directly the entity as it throw an exception with cachable data
//http://blog.dcycle.com/blog/2018-01-24/caching-drupal-8-rest-resource/#the-dreaded-leaked-metadata-error
$rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($renderable) {
return render($renderable);
});
$data = [
'rendered'=> $rendered,
'title'=>'Articles',
'articles' => $this->articles_nids,
'documents_lies' => $this->articles_nids,
];
// translations links
// use Drupal\Core\Url;
// use Drupal\Core\Language\LanguageInterface;
$route_name = 'edlp_corpus.articlesindex';
$links = \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_URL, Url::fromRoute($route_name));
if (isset($links->links)) {
$translations_build = [
'#theme' => 'links__language_block',
'#links' => $links->links,
'#attributes' => ['class' => ["language-switcher-{$links->method_id}",],],
'#set_active_class' => TRUE,
];
$translations_rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($translations_build) {return render($translations_build);});
// translations links
// use Drupal\Core\Url;
// use Drupal\Core\Language\LanguageInterface;
$route_name = 'edlp_corpus.articlesindex';
$links = \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_URL, Url::fromRoute($route_name));
if (isset($links->links)) {
$translations_build = [
'#theme' => 'links__language_block',
'#links' => $links->links,
'#attributes' => ['class' => ["language-switcher-{$links->method_id}",],],
'#set_active_class' => TRUE,
];
$translations_rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($translations_build) {return render($translations_build);});
$data['translations_links'] = $translations_rendered;
}
$data['#cache'] = [
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
'tags' => ['edlp-articlesindex-cache']
];
// $response = new JsonResponse();
// $response->setData($data);
$response = new CacheableJsonResponse($data);
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
return $response;
$data['translations_links'] = $translations_rendered;
}
$data['#cache'] = [
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
'tags' => ['edlp-articlesindex-cache']
];
// $response = new JsonResponse();
// $response->setData($data);
$response = new CacheableJsonResponse($data);
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
return $response;
}
// ___ _ _ _ _
// / __|___| | |___ __| |_(_)___ _ _
// | (__/ _ \ | / -_) _| _| / _ \ ' \
// \___\___/_|_\___\__|\__|_\___/_||_|
private function collectionQuery(){
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
$query = \Drupal::entityQuery('taxonomy_term')
// ->sort('weight', 'DESC')
// ->sort('name', 'DESC')
->condition('vid', 'entrees');
$tids = $query->execute();
// $terms = entity_load_multiple('taxonomy_term', $tids);
// $terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadMultiple($terms);
$terms = Term::loadMultiple($tids);
$ordered_terms = [];
foreach ($terms as $term) {
// remove masqué
$sid = WorkflowManager::getCurrentStateId($term, 'field_workflow');
if($sid == 'generique_masque') continue;
// translate the term
$term = \Drupal::service('entity.repository')->getTranslationFromContext($term, $language);
$name = $term->getName();
$ordered_trans_terms[$name] = $term;
}
ksort($ordered_trans_terms);
$this->entrees_terms = $ordered_trans_terms;
}
private function collectionToRenderable(){
$this->collectionQuery();
return array(
"#theme"=>'edlp_corpus_collection',
'#entrees_terms' => $this->entrees_terms
);
}
public function collection(){
return $this->collectionToRenderable();
}
public function collectionjson(){
$renderable = $this->collectionToRenderable();
// $rendered = render($renderable);
// We can't render directly the entity as it throw an exception with cachable data
//http://blog.dcycle.com/blog/2018-01-24/caching-drupal-8-rest-resource/#the-dreaded-leaked-metadata-error
$rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($renderable) {
return render($renderable);
});
$data = [
'rendered'=> $rendered,
'title'=>'Collection'
];
// translations links
// use Drupal\Core\Url;
// use Drupal\Core\Language\LanguageInterface;
$route_name = 'edlp_corpus.collection';
$links = \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_URL, Url::fromRoute($route_name));
if (isset($links->links)) {
$translations_build = [
'#theme' => 'links__language_block',
'#links' => $links->links,
'#attributes' => ['class' => ["language-switcher-{$links->method_id}",],],
'#set_active_class' => TRUE,
];
$translations_rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($translations_build) {return render($translations_build);});
$data['translations_links'] = $translations_rendered;
}
$data['#cache'] = [
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
'tags' => ['edlp-articlesindex-cache']
];
// $response = new JsonResponse();
// $response->setData($data);
$response = new CacheableJsonResponse($data);
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
return $response;
}
}
@@ -0,0 +1,3 @@
{% if entrees %}
{{ entrees }}
{% endif %}
@@ -25,7 +25,8 @@ function edlp_home_theme($existing, $type, $theme, $path) {
'promoted_nodes' => array(),
'lastdocs_items' => NULL,
'agenda_items' => NULL,
'entrees_items' => NULL,
// 'entrees_items' => NULL,
'collection_link' => NULL,
),
),
);
@@ -21,3 +21,11 @@ edlp_home.home_mobile:
_title: 'Home'
requirements:
_permission: 'access content'
edlp_home.home_mobileajax:
path: '/home_m/ajax'
defaults:
_controller: '\Drupal\edlp_home\Controller\HomeController::home_mobilejson'
_title: 'Home'
requirements:
_permission: 'access content'
@@ -4,7 +4,7 @@ use Drupal\Core\Url;
function template_preprocess_edlp_home(&$vars){
$node_view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
$term_view_builder = \Drupal::entityTypeManager()->getViewBuilder('taxonomy_term');
// $term_view_builder = \Drupal::entityTypeManager()->getViewBuilder('taxonomy_term');
// dpm($vars);
// render the promoted_nodes
@@ -34,21 +34,6 @@ function template_preprocess_edlp_home(&$vars){
}
}
// render the presentation column
// $vars["presentation"] = array(
// "#type"=>"container",
// "pres"=>$node_view_builder->view($vars["presentation_node"], 'default'),
// "link"=> array(
// '#title' => t('Visiter la collection sonore.'),
// '#type' => 'link',
// '#url' => Url::fromRoute('<front>', [], array(
// 'attributes' => array(
// 'class' => ['corpus-link', 'ajax-link']
// )
// ))
// )
// );
// render the last fil column
// $vars["last_fil"] = array(
// "#type" => "container",
@@ -81,21 +66,6 @@ function template_preprocess_edlp_home(&$vars){
// // )
// );
// render the last production column
// $vars["last_production"] = array(
// '#type' => 'container',
// 'prod' => $node_view_builder->view($vars['last_production_node'], 'teaser'),
// 'link'=> array(
// '#title' => t('Voir toutes les productions.'),
// '#type' => 'link',
// '#url' => Url::fromRoute('edlp_productions.productions', [], array(
// 'attributes' => array(
// 'class' => ['productions-link', 'ajax-link']
// )
// ))
// )
// );
// render the lasts documents of collection as list
if(isset($vars['lastdocs_items'])){
@@ -156,25 +126,24 @@ function template_preprocess_edlp_home(&$vars){
$vars['agenda'] = render($agenda);
}
if(isset($vars['entrees_items'])){
$entrees = array(
if(isset($vars['collection_link'])){
$collection = array(
'#type'=>"container",
// '#attributes' => array(
// 'id' => array('collection'),
// ),
'#prefix' => '<div id="collection"></div>',
'title'=>array(
'#markup'=>"<h3>".t("Collection")."</h3>",
),
'list'=> array(
'#theme' => 'item_list',
'#items' => [],
),
'#prefix'=> '<h3>',
'#title' => t("Collection"),
'#suffix' => '</h3>',
'#type' => 'link',
'#url' => $vars['collection_link']['url'],
'#options'=>array(
'attributes' => array(
'data-drupal-link-system-path' => $vars['collection_link']['internal_path'],
'class' => array('ajax-link'),
)
)
)
);
foreach($vars['entrees_items'] as $term){
$entrees['list']['#items'][] = $term_view_builder->view($term, 'home_mobile');
}
$vars['entrees'] = render($entrees);
$vars['collection'] = render($collection);
}
}
@@ -6,7 +6,13 @@ use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\DrupalDateTime;
use Drupal\taxonomy\Entity\Term;
use Drupal\workflow\Entity\WorkflowManager;
use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Url;
use Drupal\Core\Language\LanguageInterface;
// use Symfony\Component\HttpFoundation\JsonResponse;
use Drupal\Core\Cache\CacheableJsonResponse;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\core\render\RenderContext;
class HomeController extends ControllerBase {
@@ -99,16 +105,17 @@ class HomeController extends ControllerBase {
return $contents;
}
/**
* Display agenda as a page.
* Display home mobile as a page.
*
* @return renderable array
*/
public function home_mobile() {
public function toMobileHomeRenderable() {
// $view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
$contents = array("#theme"=>'edlp_home');
$renderable = array("#theme"=>'edlp_home');
// first get static pages
$query = \Drupal::entityQuery('node')
@@ -117,7 +124,7 @@ class HomeController extends ControllerBase {
->condition('type', 'static');
$promoted_nids = $query->execute();
$contents["#promoted_nodes"] = entity_load_multiple('node', $promoted_nids);
$renderable["#promoted_nodes"] = entity_load_multiple('node', $promoted_nids);
// then get production pages
$query = \Drupal::entityQuery('node')
@@ -126,7 +133,7 @@ class HomeController extends ControllerBase {
->condition('type', 'page');
$promoted_nids = $query->execute();
$contents["#promoted_nodes"] += entity_load_multiple('node', $promoted_nids);
$renderable["#promoted_nodes"] += entity_load_multiple('node', $promoted_nids);
// last fil
// $query = \Drupal::entityQuery('node')
@@ -136,8 +143,8 @@ class HomeController extends ControllerBase {
// ->range(0,1);
//
// $fil = $query->execute();
// $contents["#last_fil_node"] = entity_load('node', array_pop($fil));
// $contents["#last_fil_node"] = array('#markup'=>'En développement.');
// $renderable["#last_fil_node"] = entity_load('node', array_pop($fil));
// $renderable["#last_fil_node"] = array('#markup'=>'En développement.');
// agenda
$now = new DrupalDateTime('now');
@@ -151,100 +158,79 @@ class HomeController extends ControllerBase {
->sort('field_date');
$events = $query->execute();
$contents['#agenda_items'] = entity_load_multiple('node', $events);
$renderable['#agenda_items'] = entity_load_multiple('node', $events);
// entrées
$language = \Drupal::languageManager()->getCurrentLanguage()->getId();
// Collection
// TODO: get the link to mobile collection page
$collection_url = Url::fromRoute('edlp_corpus.collection');
$renderable['#collection_link'] = array(
'url' => $collection_url,
'internal_path' => $collection_url->getInternalPath(),
);
$query = \Drupal::entityQuery('taxonomy_term')
// ->sort('weight', 'DESC')
// ->sort('name', 'DESC')
->condition('vid', 'entrees');
$tids = $query->execute();
// $terms = entity_load_multiple('taxonomy_term', $tids);
// $terms = \Drupal::entityManager()->getStorage('taxonomy_term')->loadMultiple($terms);
$terms = Term::loadMultiple($tids);
$ordered_terms = [];
foreach ($terms as $term) {
// remove masqué
$sid = WorkflowManager::getCurrentStateId($term, 'field_workflow');
if($sid == 'generique_masque') continue;
// translate the term
$term = \Drupal::service('entity.repository')->getTranslationFromContext($term, $language);
$name = $term->getName();
$ordered_trans_terms[$name] = $term;
return $renderable;
}
public function home_mobile() {
return $this->toMobileHomeRenderable();
}
/**
* Get home mobile data as json through ajax.
*
* @return json
*/
// NOT NEEDED ANY MORE
public function home_mobilejson() {
$renderable = $this->toMobileHomeRenderable();
// $rendered = render($renderable);
// We can't render directly the entity as it throw an exception with cachable data
//http://blog.dcycle.com/blog/2018-01-24/caching-drupal-8-rest-resource/#the-dreaded-leaked-metadata-error
$rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($renderable) {
return render($renderable);
});
$data = [
'rendered'=> $rendered,
'title'=>'Home Mobile',
];
// translations links
// use Drupal\Core\Url;
// use Drupal\Core\Language\LanguageInterface;
$route_name = 'edlp_home.home_mobile';
$links = \Drupal::languageManager()->getLanguageSwitchLinks(LanguageInterface::TYPE_URL, Url::fromRoute($route_name));
if (isset($links->links)) {
$translations_build = [
'#theme' => 'links__language_block',
'#links' => $links->links,
'#attributes' => ['class' => ["language-switcher-{$links->method_id}",],],
'#set_active_class' => TRUE,
];
$translations_rendered = \Drupal::service('renderer')->executeInRenderContext(new RenderContext(), function () use ($translations_build) {return render($translations_build);});
$data['translations_links'] = $translations_rendered;
}
ksort($ordered_trans_terms);
$data['#cache'] = [
'max-age' => \Drupal\Core\Cache\Cache::PERMANENT,
'tags' => ['edlp-home-cache'],
'contexts' => [
'languages:language_content'
]
];
// $response = new JsonResponse();
// $response->setData($data);
$response = new CacheableJsonResponse($data);
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($data));
$response->addCacheableDependency(CacheableMetadata::createFromRenderArray($renderable));
// dsm($terms);
// foreach ($ordered_trans_terms as $name => $term) {
// $tid = $term->id();
//
// $entree = array(
// 'tid'=>$tid
// );
// term link
// $url = Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term'=>$tid]);
// $url->setOptions(array(
// 'attributes' => array(
// 'class' => ['term-'.$tid, 'term-link'],
// 'tid'=>$tid,
// 'selector' => 'entree-term-link-'.$tid,
// 'data-drupal-link-system-path' => $url->getInternalPath()
// )
// ));
// $entree['term_link'] = Link::fromTextAndUrl($name, $url);
// index link
// $url = Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term'=>$tid]);
// $url->setOptions(array(
// 'attributes' => array(
// 'class' => ['index-link', 'ajax-link'],
// 'viewmode'=>'index',
// 'tid'=>$tid,
// 'selector' => 'entree-index-link-'.$tid,
// 'data-drupal-link-system-path' => $url->getInternalPath()
// )
// ));
// $entree['index_link'] = Link::fromTextAndUrl('index', $url);
// notice-link
// $url = Url::fromRoute('entity.taxonomy_term.canonical', ['taxonomy_term'=>$tid]);
// $url->setOptions(array(
// 'attributes' => array(
// 'class' => ['notice-link'],
// 'viewmode'=>'notice',
// 'tid'=>$tid,
// 'selector' => 'entree-notice-link-'.$tid,
// 'data-drupal-link-system-path' => $url->getInternalPath()
// )
// ));
// $entree['notice_link'] = Link::fromTextAndUrl('notice', $url);
// $entree['description'] = $term->get('description')->value;
//
// $entrees[] = $entree;
// }
$contents['#entrees_items'] = $ordered_trans_terms;
// = array (
// '#theme' => 'blockentrees',
// '#entrees_items' => $entrees,
// '#attached'=>array(
// 'library' => array('edlp_corpus/corpus'),
// 'drupalSettings' => array(
// 'basepath' => base_path()
// )
// )
// );
return $contents;
return $response;
}
}
@@ -16,6 +16,6 @@
{{ agenda }}
{% endif %}
{% if entrees %}
{{ entrees }}
{% if collection %}
{{ collection }}
{% endif %}
@@ -116,7 +116,7 @@ function edlp_mobile_page_attachments(array &$attachments) {
// we assume that there is only two alias by env (mobile or desktop)
foreach ($env_aliases as $env_alias_id => $env_alias) {
if($env_alias_id != $alias->id()){
// we found the desktop pattern
// we found the mobile pattern
$mobile_url = $env_alias->getPattern();
break;
}
@@ -128,6 +128,13 @@ function edlp_mobile_page_attachments(array &$attachments) {
$is_front = \Drupal::service('path.matcher')->isFrontPage();
$current_language = \Drupal::languageManager()->getCurrentLanguage()->getId();
// $config->set($domain_id . '.site_frontpage', $site_frontpage);
// $mobile_home_path = "???";
$mobile_home_path = \Drupal::config('domain_site_settings.domainconfigsettings')->get('m_encyclopediedelaparole_org.site_frontpage', FALSE);
// $desktop_home_path = "???";
$desktop_home_path = \Drupal::config('domain_site_settings.domainconfigsettings')->get('encyclopediedelaparole_org.site_frontpage', FALSE);
// $redirect = false;
$js_str = "var edlp_mobile = {\n
current_url:'".$base_root."',\n
@@ -136,7 +143,9 @@ function edlp_mobile_page_attachments(array &$attachments) {
lang_code:'".$current_language."',\n
is_mobile_domain:".($is_mobile_domain ? 'true':'false').",\n
mobile_url:'".$mobile_url."',\n
mobile_home_path:'".$mobile_home_path."',\n
desktop_url:'".$desktop_url."',\n
desktop_home_path:'".$desktop_home_path."',\n
};";
$attachments['#attached']['html_head'][] = [
@@ -1,7 +1,9 @@
(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;var _is_mobile=edlp_mobile.device_is_mobile;function init(){void 0;if(!_is_mobile){initEvents();_audioPlayer=new AudioPlayer();_compoPlayer=new CompoPlayer();checkLayout();initAjaxLinks();initHistory();initAudioLinksHover();}else{if(drupalSettings.path.isFront){initHomeMobile();}
_$body.attr('booted','booted');}};function initHomeMobile(){$('.field--name-field-notice, .index','.entrees .taxonomy-term.vocabulary-entrees').addClass('closed');$('[data-drupal-link-system-path="<front>"]','#block-mainnavigation').removeClass('is-active').attr('href','#collection');$('h2#block-mainnavigation-menu, a','#block-mainnavigation').on('click',onclickHomeMobileMenu);$('.field--name-field-notice>.field__label','.entrees .taxonomy-term.vocabulary-entrees').on('click',onClickHomeMobileNotice);$('.index>.field__label','.entrees .taxonomy-term.vocabulary-entrees').on('click',onClickHomeMobileIndex);};function onclickHomeMobileMenu(e){$('#block-mainnavigation').toggleClass('visible');};function onClickHomeMobileNotice(e){toggleEntreeOpening($(this).parent(),'notice');};function onClickHomeMobileIndex(e){toggleEntreeOpening($(this).parent(),'index');};function toggleEntreeOpening($e,part){$e.toggleClass('closed').parents('.taxonomy-term.vocabulary-entrees.home_mobile').toggleClass(part+'-opened');}
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',function(e){initAjaxLinks();initAudioLinksHover();checkVisibleCorpusMapSpace();}).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($,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;var _is_mobile=edlp_mobile.device_is_mobile;function init(){void 0;if(_is_mobile){initMobile();}
initEvents();_audioPlayer=new AudioPlayer();_compoPlayer=new CompoPlayer();initAjaxLinks();initHistory();if(!_is_mobile){checkLayout();initAudioLinksHover();}
if(_is_mobile){if(drupalSettings.path.isFront){initHomeMobile();}
_$body.attr('booted','booted');}};function initMobile(){$('h2, a','#block-mainnavigation').add('h2, a','#block-mainnavigation-2').on('click',onclickHomeMobileMenu);}
function onclickHomeMobileMenu(e){$('#block-mainnavigation-2').toggleClass('opened');};function initHomeMobile(){};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',function(e){initAjaxLinks();initAudioLinksHover();checkVisibleCorpusMapSpace();}).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();if(typeof navpos!='undefined'){$audioplayer.css({'width':navpos.left+'px'});}}
checkGridBlockHeight();checkGridBlockVisible();};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;var $rendered=$(data.rendered);$rendered.attr({'sys_path':state.sys_path,'view_mode':state.view_mode});if(data.entity_type=="node"&&data.bundle=="evenement"){if(_$row.find('.col.event').length){_$row.find('.col.event').replaceWith($rendered);}else if(_$row.find('.col.aside').length){_$row.find('.col.aside').replaceWith($rendered);}else{_$row.append($rendered);}}else{_$row.removeAttr('style').html($rendered);}
@@ -13,11 +15,12 @@ if(typeof data.menu_parents!='undefined'){for(var i=0;i<data.menu_parents.length
if(typeof data.documents_lies!='undefined'){if(_corpus_ready){_$body.trigger({type:'ajax-node-loaded-linked-documents',nids:data.documents_lies});}else{_corpus_promise.done(function(){_$body.trigger({type:'ajax-node-loaded-linked-documents',nids:data.documents_lies});});}}
if(typeof data.block!='undefined'){if(!$('#'+data.block.id,'.region-'+data.block.region).length){$('.region-'+data.block.region).append(data.block.rendered);}}
if(state.sys_path=="productions"){initGrid();}else{addCloseModalBtnToCols();}
if(state.sys_path=="collection"){initCollectionNav();}
if(data.entity_type=="node"&&data.bundle=="enregistrement"&&data.view_mode=="transcript"){initEnregistrementTranscript();}
if(state.sys_path=="search"){initSearch();}
if(typeof data.translations_links!='undefined'){void 0;var lang_code=drupalSettings.path.currentLanguage;var $links=$(data.translations_links);$links.find('li[hreflang="'+lang_code+'"]').addClass('is-active').find('a').addClass('is-active');if(state.view_mode){$links.find('a').each(function(i,e){var $a=$(this);$a.attr('href',$a.attr('href')+'#'+state.view_mode);});}
$('ul','.block.language-switcher-language-url').replaceWith($links);}
initAjaxLinks();initAudioLinksHover();checkVisibleCorpusMapSpace();_$body.trigger({'type':'new-content-ajax-loaded'});Drupal.attachBehaviors(_$row[0]);_$body.attr('booted','booted');_$body.removeClass('ajax-loading');if(state.url){history.pushState(state,null,state.url);if(typeof _paq!=='undefined'){_paq.push(['setCustomUrl',state.url]);_paq.push(['setDocumentTitle',data.title]);_ajax_timing.end=performance.now();_paq.push(['setGenerationTimeMs',_ajax_timing.end-_ajax_timing.start]);_paq.push(['trackPageView']);}}};function initAudioLinksHover(){void 0;_$row.find('a.audio-link').on('mouseover',function(event){event.preventDefault();if(_corpus_ready){_$corpus_canvas.trigger({type:'mouseover-audio-link',nid:$(this).attr('nid')});}}).on('mouseout',function(event){event.preventDefault();if(_corpus_ready){_$corpus_canvas.trigger({type:'mouseout-audio-link',nid:$(this).attr('nid')});}});};function addCloseModalBtnToCols(){$('.col',_$row).each(function(index,el){if($('span.close-col-btn',this).length)
initAjaxLinks();initAudioLinksHover();checkVisibleCorpusMapSpace();_$body.trigger({'type':'new-content-ajax-loaded'});Drupal.attachBehaviors(_$row[0]);_$body.attr('booted','booted');_$body.removeClass('ajax-loading');if(state.url){history.pushState(state,null,state.url);if(typeof _paq!=='undefined'){_paq.push(['setCustomUrl',state.url]);_paq.push(['setDocumentTitle',data.title]);_ajax_timing.end=performance.now();_paq.push(['setGenerationTimeMs',_ajax_timing.end-_ajax_timing.start]);_paq.push(['trackPageView']);}}};function initAudioLinksHover(){void 0;_$row.find('a.audio-link').on('mouseover',function(event){event.preventDefault();if(_corpus_ready){_$corpus_canvas.trigger({type:'mouseover-audio-link',nid:$(this).attr('nid')});}}).on('mouseout',function(event){event.preventDefault();if(_corpus_ready){_$corpus_canvas.trigger({type:'mouseout-audio-link',nid:$(this).attr('nid')});}});};function addCloseModalBtnToCols(){if(_is_mobile)return;$('.col',_$row).each(function(index,el){if($('span.close-col-btn',this).length)
return true;$(this).children('.wrapper').prepend($('<span>').addClass('close-col-btn').on('click',onCloseModal));});};function onCloseModal(e){var $col=$(this).parents('.col');var theme=$col.attr('theme');if(theme!=''){_$body.trigger({'type':theme+'-col-closed'});}
if(_$body.is('.entity-type-node.bundle-page')&&$(this).next().is('.node--type-page')){$col.add($col.siblings('.col')).remove();}else{$col.remove();}
checkRowEmpty();checkVisibleCorpusMapSpace();if($col.attr('view_mode')&&$col.attr('sys_path')){$('a[data-drupal-link-system-path="'+$col.attr('sys_path')+'"][viewmode="'+$col.attr('view_mode')+'"]').removeClass('is-active');}};function initHistory(){initFirstLoad();window.addEventListener('popstate',onHistoryPopState);};function initFirstLoad(){void 0;void 0;var edlp_origin=JSON.parse(window.localStorage.getItem('edlp_origin'));void 0;if(edlp_origin!=null&&edlp_origin.sys_path){var hash=edlp_origin.hash.replace('#','');var state=getSysPathState(edlp_origin.sys_path,hash);if(edlp_origin.entity_type=="taxonomy_term"&&edlp_origin.entity_bundle=="entrees"&&hash){state.selector='entree-'+hash+'-link-'+edlp_origin.entity_id;if(_corpus_ready){_$corpus_canvas.trigger({type:'open-entree',tid:edlp_origin.entity_id});}else{$('li.entree[tid="'+edlp_origin.entity_id+'"] a.term-link').addClass('is-active');}}
@@ -27,20 +30,21 @@ if(state.entree_tid){openEntree(state.entree_tid);}
history.replaceState(state,null,edlp_origin.url+edlp_origin.hash);window.localStorage.removeItem("edlp_origin");}else{history.replaceState({home:true},null,window.location.pathname+window.location.hash);initGrid();_$body.attr('booted','booted');}};function onHistoryPopState(e){void 0;if(e.state.home){backToFrontPage(true);}
else if(e.state.audio){_audioPlayer.openDocument(e.state.node,'popstate',e.state.historic_index);}
else{if(e.state.entree_tid){openEntree(e.state.entree_tid);}
if(e.state.ajax_path){e.state.url=null;ajaxLoadContent(e.state);}}};function initAjaxLinks(){$('a.site-name','#block-edlptheme-branding').add('a','#block-mainnavigation').add('a','#block-footer.menu--footer').add('a','#block-productions').add('a','article.node:not(.node--type-enregistrement) h2.node-title').add('a','.productions-subtree').add('a','.productions-parent').add('a','.field--name-field-son').addClass('ajax-link');$('a[data-drupal-link-system-path="<front>"]','#block-mainnavigation').removeClass('is-active');_$ajaxLinks=$('.ajax-link:not(.ajax-enabled)').each(function(i,e){var $this=$(this);if($this.is('.ajax-enable'))return;if($this.attr('data-drupal-link-system-path')||$this.is('[type^="audio"]')){$this.on('click',onClickAjaxLink).addClass('ajax-enable');}});};function onClickAjaxLink(e){e.preventDefault();var $link=$(this);if($link.is('.is-active')&&!$link.is('.site-name'))
if(e.state.ajax_path){e.state.url=null;ajaxLoadContent(e.state);}}};function initAjaxLinks(){$('a.site-name','#block-edlptheme-branding').add('a','#block-mainnavigation').add('a','#block-mainnavigation-2').add('a','#block-footer.menu--footer').add('a','#block-productions').add('a','article.node:not(.node--type-enregistrement) h2.node-title').add('a','.productions-subtree').add('a','.productions-parent').add('a','.field--name-field-son').addClass('ajax-link');$('a[data-drupal-link-system-path="<front>"]','#block-mainnavigation').removeClass('is-active');_$ajaxLinks=$('.ajax-link');activateAjaxLinks();};function activateAjaxLinks(){_$ajaxLinks.each(function(i,e){var $this=$(this);if($this.is('.ajax-enable'))return;if($this.attr('data-drupal-link-system-path')||$this.is('[type^="audio"]')){$this.on('click',onClickAjaxLink).addClass('ajax-enable');}});};function onClickAjaxLink(e){e.preventDefault();var $link=$(this);if($link.is('.is-active')&&!$link.is('.site-name'))
return false;if($link.is('.audio-link')){caller=$link.parents('.lastdocs').length?'lastdocs':null;_audioPlayer.emmit('stop-shuffle').openDocument({nid:$link.attr('nid'),audio_url:$link.attr('audio_url'),title:$link.find('.field--name-title').html()},caller);return false;}
if($link.is('[type^="audio"]')){_audioPlayer.emmit('stop-shuffle').openSound($link.attr('href'),$link.html());return false;}
var sys_path=$(this).attr('data-drupal-link-system-path');if(sys_path=='<front>'){if($link.is('.is-active')&&_corpus_ready){_$corpus_canvas.trigger({'type':'shuffle-collection'});}else{backToFrontPage();}
return false;}
var sys_path=$(this).attr('data-drupal-link-system-path');if(sys_path=='<front>'){if(!_is_mobile){if($link.is('.is-active')&&_corpus_ready){_$corpus_canvas.trigger({'type':'shuffle-collection'});}else{backToFrontPage();}
return false;}}
var view_mode=$link.attr('viewmode');var state=getSysPathState(sys_path,view_mode);state.url=$(this).attr('href');if(view_mode){state.url+="#"+view_mode;}
if($link.is('[selector]')){state.selector=$link.attr('selector');}
$link.addClass('ajax-loading');ajaxLoadContent(state);return false;};function onCorpusMapReady(e){_corpus_ready=true;_$corpus_canvas=$('canvas#corpus-map');_$corpus_canvas.on('corpus-cliked-on-map',function(e){backToFrontPage();}).on('corpus-cliked-on-node',function(e){_audioPlayer.emmit('stop-shuffle').openDocument(e.target_node);});_randomPlayer=new RandomPlayer(e.playlist);initAjaxLinks();_$body.attr('corpus-map','ready');}
function openEntree(tid){if(tid){closeAllModals();_$body.removeClass();if(_corpus_ready){_$corpus_canvas.trigger({type:'open-entree',tid:tid});}else{$('li.entree[tid="'+tid+'"] a.term-link').addClass('is-active');}}};function checkVisibleCorpusMapSpace(){var left_limit=0,right_limit=0;_$row.find('.col').each(function(i,e){var $col=$(this);var offset=$col.offset();void 0;switch(true){case $col.is('.float-right'):right_limit=Math.max(right_limit,Math.abs(offset.left-15-window.innerWidth));break;default:left_limit=Math.max(left_limit,offset.left+$col.width()+15);break;}});void 0;if(_corpus_ready){_$body.trigger({type:'visible-space-changed',left_limit:left_limit,right_limit:right_limit});}else{_corpus_promise.done(function(){_$body.trigger({type:'visible-space-changed',left_limit:left_limit,right_limit:right_limit});});}};function AudioPlayer(){var that=this;this.fid;this.audio=new Audio();this.audio_events=["loadedmetadata","playing","pause","timeupdate","ended","error"];this.$container=$('<div id="audio-player">');this.$btns=$('<div>').addClass('btns').appendTo(this.$container);this.$previous=$('<div>').addClass('previous').appendTo(this.$btns);this.$playpause=$('<div>').addClass('play-pause').appendTo(this.$btns);this.$next=$('<div>').addClass('next').appendTo(this.$btns);this.$timelinecont=$('<div>').addClass('time-line-container').appendTo(this.$container);this.$timeline=$('<div>').addClass('time-line').appendTo(this.$timelinecont);this.$loader=$('<div>').addClass('loader').appendTo(this.$timeline);this.$cursor=$('<div>').addClass('cursor').appendTo(this.$timeline);this.$time=$('<div>').addClass('time').appendTo(this.$container);this.$currentTime=$('<div>').addClass('current-time').html('00:00').appendTo(this.$time);this.$duration=$('<div>').addClass('duration').html('00:00').appendTo(this.$time);this.$fav=$('<div>').addClass('favoris').appendTo(this.$container);this.$cartel=$('<div>').addClass('cartel').appendTo(this.$container);this.scndCartel_visible=0;this.cartelSwitchIntervalMS=7000;this.cartelSwitchInterval=false;this.hideTimer=false;this.hideTimeMS=15000;this.currentHistoricIndex=null;this.historic=[];this.shuffle_is_active=false;this.auto_open_article=false;this.event_handlers={'audio-open-document':[],'audio-play':[],'audio-pause':[],'audio-play-next':[],'audio-ended':[],'stop-shuffle':[]};this.init();};AudioPlayer.prototype={init(){this.$container_parent=$('header[role="banner"] .region-header');this.$container.appendTo(this.$container_parent);this.timeline_w=parseInt(this.$timeline.width());this.$loader.on('click',this.seek.bind(this));var fn='';for(var i=0;i<this.audio_events.length;i++){fn=this.audio_events[i];fn='on'+fn.charAt(0).toUpperCase()+fn.slice(1);this.audio.addEventListener(this.audio_events[i],this[fn].bind(this),true);}
this.$previous.on('click',this.playPrevious.bind(this));this.$playpause.on('click',this.togglePlayPause.bind(this));this.$next.on('click',this.playNext.bind(this));},openDocument(node,caller,historic_index){void 0;if(typeof node=='undefined'||typeof node.nid=='undefined'||typeof node.audio_url=='undefined'){void 0;return false;}
if(typeof caller=='undefined'||caller!='popstate'){this.historic.push(node);this.currentHistoricIndex=this.historic.length-1;if(caller!="history_first_load"){if(typeof node.document_url=='undefined'){void 0;}else{var state={audio:true,node:{nid:node.nid,audio_url:node.audio_url,document_url:node.document_url,title:node.title||null,},historic_index:this.currentHistoricIndex,};var url=node.document_url+(caller=='random'?'#random':'');history.pushState(state,null,url);}}}else{this.currentHistoricIndex=historic_index;}
if(_$body.is('.path-frontpage')&&caller!=='lastdocs'){closeAllModals();}
if(_$body.is('.path-frontpage')&&caller!=='lastdocs'&&!_is_mobile){closeAllModals();}
this.emmit('audio-open-document',{caller:caller});if(typeof _paq!=='undefined'){if(typeof node.title!='undefined'){_paq.push(['trackEvent','Audio','play',node.title]);}}
this.launch();},launch(){this.clearTimeOutToHide();this.clearIntervalAutoCartelSwitch();this.setSRC(this.historic[this.currentHistoricIndex].audio_url);this.loadNode(this.historic[this.currentHistoricIndex].nid);try{_$corpus_canvas.trigger({'type':'audio-node-opened','nid':this.historic[this.currentHistoricIndex].nid});}catch(e){void 0;var that=this;_corpus_promise.done(function(){_$corpus_canvas.trigger({'type':'audio-node-opened','nid':that.historic[that.currentHistoricIndex].nid});});}
this.launch();},launch(){this.clearTimeOutToHide();this.clearIntervalAutoCartelSwitch();this.setSRC(this.historic[this.currentHistoricIndex].audio_url);if(!_is_mobile){this.loadNode(this.historic[this.currentHistoricIndex].nid);}
try{_$corpus_canvas.trigger({'type':'audio-node-opened','nid':this.historic[this.currentHistoricIndex].nid});}catch(e){void 0;var that=this;_corpus_promise.done(function(){_$corpus_canvas.trigger({'type':'audio-node-opened','nid':that.historic[that.currentHistoricIndex].nid});});}
this.showHidePreviousBtn();this.showHideNextBtn();this.show();},openSound(url,title){this.hide();this.clearTimeOutToHide();this.$cartel.html("");this.setSRC(url);this.show();if(typeof _paq!=='undefined'){_paq.push(['trackEvent','Audio','play',url]);}},setSRC(url){void 0;this.audio.src=url;this.play();},onLoadedmetadata(){var rem=parseInt(this.audio.duration,10),mins=Math.floor(rem/60,10),secs=rem-mins*60;this.$duration.html('<span>'+(mins<10?'0':'')+mins+':'+(secs<10?'0':'')+secs+'</span>');this.updateLoadingBar();},updateLoadingBar(){void 0;if(this.audio.buffered.length>0){this.$loader.css({'width':parseInt((100*this.audio.buffered.end(0)/this.audio.duration),10)+'%'});if(this.audio.buffered.end(0)<this.audio.duration){window.requestAnimationFrame(this.updateLoadingBar.bind(this));}else{void 0;}}else{window.requestAnimationFrame(this.updateLoadingBar.bind(this));}},onError(){void 0;},play(){this.clearTimeOutToHide();var promise=this.audio.play();if(promise!==undefined){promise.catch(function(error){void 0;}).then(function(){void 0;});}},playPrevious(){if(this.currentHistoricIndex>0){this.currentHistoricIndex-=1;this.launch();}},playNext(){if(this.currentHistoricIndex<this.historic.length-1){this.currentHistoricIndex+=1;this.launch();}else{this.emmit('audio-play-next');}},togglePlayPause(e){if(this.audio.paused){this.play();}else{this.stop();}},stop(){this.audio.pause();if(!(_$body.is('.path-node-'+this.historic[this.currentHistoricIndex].nid)&&(_$body.is('.view-mode-article')||_$body.is('.view-mode-transcript')))){this.timeOutToHide();}},seek(e){var seek=e.originalEvent.layerX/this.timeline_w*this.audio.duration
void 0;this.audio.currentTime=seek;},onPlaying(){this.$btns.addClass('is-playing');this.emmit('audio-play');},onPause(){this.$btns.removeClass('is-playing');this.emmit('audio-pause');},onTimeupdate(){this.$cursor.css({'left':(this.audio.currentTime/this.audio.duration*this.timeline_w)+"px"});var rem=parseInt(this.audio.currentTime,10),mins=Math.floor(rem/60,10),secs=rem-mins*60;this.$currentTime.html('<span>'+(mins<10?'0':'')+mins+':'+(secs<10?'0':'')+secs+'</span>');},onEnded(){void 0;this.stop();this.emmit('audio-ended');},loadNode(nid){this.$cartel.addClass('loading');var vm='player_cartel';var ajax_path=_ajax_settings.entityjson_path+'/node/'+nid+'/'+vm;var path=window.location.origin+Drupal.url(ajax_path);$.getJSON(path,{}).done(this.onNodeLoaded.bind(this)).fail(this.onNodeLoadFail.bind(this));},onNodeLoaded(data){void 0;this.$cartel.html(data.rendered).removeClass('loading');_$body.trigger({'type':'new-audio-cartel-loaded'});initAjaxLinks();this.scndCartel_visible=0;this.$cartel.removeClass('second-visible');if(this.$cartel.find('.second-cartel .col-left').children().length>1||this.$cartel.find('.second-cartel').children('.col-right').length){this.cartelSwitchInterval=setInterval(this.switchCartel.bind(this),this.cartelSwitchIntervalMS);}
Drupal.attachBehaviors(this.$cartel);this.setAutoOpenArticle();if(this.auto_open_article){this.$cartel.find('a.link-article').trigger('click');this.auto_open_article=false;}},onNodeLoadFail(jqxhr,textStatus,error){void 0;this.$cartel.removeClass('loading').html('');},setAutoOpenArticle(art){this.auto_open_article=$('a.articles-link').is('.is-active');return this;},show(){this.$container_parent.addClass('audio-player-visible');this.$container.addClass('visible');},showHidePreviousBtn(){if(this.historic.length>1&&this.currentHistoricIndex>0){this.$previous.addClass('is-active');}else{this.$previous.removeClass('is-active');}},showHideNextBtn(){if(this.currentHistoricIndex<this.historic.length-1||this.shuffle_is_active){this.$next.addClass('is-active');}else{this.$next.removeClass('is-active');}},timeOutToHide(){this.clearTimeOutToHide();this.hideTimer=setTimeout(this.hide.bind(this),this.hideTimeMS);},clearTimeOutToHide(){if(this.hideTimer){clearTimeout(this.hideTimer);this.hideTimer=false;}},switchCartel(){if(this.scndCartel_visible){this.$cartel.removeClass('second-visible');this.scndCartel_visible=0;this.clearIntervalAutoCartelSwitch();}else{this.$cartel.addClass('second-visible');this.scndCartel_visible=1;}},clearIntervalAutoCartelSwitch(){if(this.cartelSwitchInterval){clearInterval(this.cartelSwitchInterval);this.cartelSwitchInterval=false;}},hide(){this.$container_parent.removeClass('audio-player-visible');this.$container.removeClass('visible');try{_$corpus_canvas.trigger('audio-node-closed');}catch(e){void 0;}},deActivateRandom(){this.shuffle_is_active=false;this.showHideNextBtn();},on(event_name,handler){if(typeof this.event_handlers[event_name]=='undefined'){void 0;}
@@ -58,9 +62,13 @@ return this;},showHideControls(){if(this.$controls){if(this.playing&&!this.pause
if(this.$playpause){if(this.playlist.length>0){this.$playpause.addClass('is-active');}else{this.$playpause.removeClass('is-active');}}
if(this.$next){if(this.playing&&this.playlist.length>1&&this.current_index<this.playlist.length-1){this.$next.addClass('is-active');}else{this.$next.removeClass('is-active');}}
if(this.$previous){if(this.playing&&this.playlist.length>1&&this.current_index>0){this.$previous.addClass('is-active');}else{this.$previous.removeClass('is-active');}}
return this;},deactivate(){this.stop();this.active=false;},onAudioOpenDocument(args){if(args.caller!==this){this.reset();}},onAudioPlayerPlay(){if(this.playing&&this.paused){this.paused=false;this.showHideControls();}},onAudioPlayerPause(){if(this.playing&&!this.paused){this.paused=true;this.showHideControls();}},onAudioPlayerEnded(){if(this.playing){this.next();}},};function initGrid(){void 0;checkGridBlockHeight();_$row.find('.col').addClass('offfield');if(false){var $grid=$('.grid',_$row).masonry({itemSelector:'.col',columnWidth:'.col-2',containerStyle:null,resizeContainer:false,transitionDuration:0,});$grid.imagesLoaded().progress(function(){$grid.masonry('layout');});$grid.imagesLoaded(function(){$grid.masonry('layout');});$grid.on('layoutComplete',checkGridBlockVisible);}else{checkGridBlockVisible();}};function checkGridBlockHeight(){var $r_h=_$row.height();var $this;$('.grid .col',_$row).each(function(i,e){$this=$(this);if(!$this.is('[init-height]')){$this.attr('init-height',$this.outerHeight())}
return this;},deactivate(){this.stop();this.active=false;},onAudioOpenDocument(args){if(args.caller!==this){this.reset();}},onAudioPlayerPlay(){if(this.playing&&this.paused){this.paused=false;this.showHideControls();}},onAudioPlayerPause(){if(this.playing&&!this.paused){this.paused=true;this.showHideControls();}},onAudioPlayerEnded(){if(this.playing){this.next();}},};function initGrid(){void 0;if(!_is_mobile){checkGridBlockHeight();_$row.find('.col').addClass('offfield');}
if(false){var $grid=$('.grid',_$row).masonry({itemSelector:'.col',columnWidth:'.col-2',containerStyle:null,resizeContainer:false,transitionDuration:0,});$grid.imagesLoaded().progress(function(){$grid.masonry('layout');});$grid.imagesLoaded(function(){$grid.masonry('layout');});$grid.on('layoutComplete',checkGridBlockVisible);}else{if(!_is_mobile){checkGridBlockVisible();}}};function checkGridBlockHeight(){var $r_h=_$row.height();var $this;$('.grid .col',_$row).each(function(i,e){$this=$(this);if(!$this.is('[init-height]')){$this.attr('init-height',$this.outerHeight())}
$this.height(Math.min($this.attr('init-height'),_$row.height()));});};function checkGridBlockVisible(){var $r_h=_$row.height();var $this,pos;$('.grid .col',_$row).each(function(i,e){$this=$(this);pos=$this.position();if(pos.top+$this.height()<=$r_h){$this.removeClass('offfield');}else{$this.addClass('offfield');}});}
function initSearch(){$('#edit-entries--wrapper legend','#edlp-search-form').on('click',function(){$(this).parent().toggleClass('opened');});};function initEnregistrementTranscript(){void 0;var $node=_$row.find('article.node--type-enregistrement.node--view-mode-transcript');var $nav=$('<nav>').prependTo($node);$node.find('.field--name-field-transcript-vo').addClass('visible').find('.field__label').clone().appendTo($nav).addClass('is-active').attr('field_target','.field--name-field-transcript-vo');$node.find('.field--name-field-transcript-trad').find('.field__label').clone().appendTo($nav).attr('field_target','.field--name-field-transcript-trad');$nav.find('.field__label').on('click',function(){var $this=$(this).addClass('is-active');$this.siblings('.is-active').removeClass('is-active');$this.parents('article.node').find('.field.visible').removeClass('visible');$this.parents('article.node').find($this.attr('field_target')).addClass('visible');});};function backToFrontPage(pop_state){void 0;closeAllModals();$('body').removeClass().addClass('path-frontpage');$('a[data-drupal-link-system-path="<front>"]').addClass('is-active');_$corpus_canvas.trigger({'type':'close-all-entree'});_$corpus_canvas.trigger({'type':'scramble-collection'});if(typeof pop_state=="undefined"||!pop_state){void 0;history.pushState({home:true},null,drupalSettings.path.baseUrl+drupalSettings.path.currentLanguage);}}
function initCollectionNav(){void 0;$('.field--name-field-notice, .index','.taxonomy-term.vocabulary-entrees.home_mobile').addClass('closed');$('.field--name-field-notice>.field__label','.taxonomy-term.vocabulary-entrees.home_mobile').on('click',onClickCollectionNotice);$('.index>.field__label','.taxonomy-term.vocabulary-entrees.home_mobile').on('click',onClickCollectionIndex);};function onClickCollectionNotice(e){toggleEntreeOpening($(this).parent(),'notice');};function onClickCollectionIndex(e){toggleEntreeOpening($(this).parent(),'index');};function toggleEntreeOpening($e,part){$e.toggleClass('closed').parents('.taxonomy-term.vocabulary-entrees.home_mobile').toggleClass(part+'-opened');}
function initSearch(){$('#edit-entries--wrapper legend','#edlp-search-form').on('click',function(){$(this).parent().toggleClass('opened');});};function initEnregistrementTranscript(){void 0;var $node=_$row.find('article.node--type-enregistrement.node--view-mode-transcript');var $nav=$('<nav>').prependTo($node);$node.find('.field--name-field-transcript-vo').addClass('visible').find('.field__label').clone().appendTo($nav).addClass('is-active').attr('field_target','.field--name-field-transcript-vo');$node.find('.field--name-field-transcript-trad').find('.field__label').clone().appendTo($nav).attr('field_target','.field--name-field-transcript-trad');$nav.find('.field__label').on('click',function(){var $this=$(this).addClass('is-active');$this.siblings('.is-active').removeClass('is-active');$this.parents('article.node').find('.field.visible').removeClass('visible');$this.parents('article.node').find($this.attr('field_target')).addClass('visible');});};function backToFrontPage(pop_state){void 0;closeAllModals();$('body').removeClass().addClass('path-frontpage');$('a[data-drupal-link-system-path="<front>"]').addClass('is-active');if(_corpus_ready){_$corpus_canvas.trigger({'type':'close-all-entree'});_$corpus_canvas.trigger({'type':'scramble-collection'});}
if(typeof pop_state=="undefined"||!pop_state){void 0;history.pushState({home:true},null,drupalSettings.path.baseUrl+drupalSettings.path.currentLanguage);}}
function initHome(){addCloseModalBtnToCols();return;void 0;var $grid=$('.grid',_$row).masonry({itemSelector:'.col',columnWidth:'.col-2',horizontalOrder:true,containerStyle:null,});$grid.imagesLoaded().progress(function(){$grid.masonry('layout');});$grid.imagesLoaded(function(){$grid.masonry('layout');});}
function closeAllModals(){_$row.html('');_$ajaxLinks.removeClass('is-active');_$body.trigger({'type':'all-modal-closed'});};function checkRowEmpty(){void 0;if(!$('.col',_$row).length){if(!_$body.is('.entity-type-taxonomy_term.bundle-entrees')){if(!_$body.is('.entity-type-node.bundle-page')){if(_$body.is('.bundle-enregistrement.view-mode-article')&&$('a.articles-link').is('.is-active')){void 0;$('a.articles-link').removeClass('is-active').trigger('click');}else{backToFrontPage();}}else{_$corpus_canvas.trigger({'type':'scramble-collection'});$('a[data-drupal-link-system-path="productions"]','#block-mainnavigation').removeClass('is-active').trigger('click');}}else{$('.entree-content a.is-active').removeClass('is-active');}}};init();}
function closeAllModals(){_$row.html('');_$ajaxLinks.removeClass('is-active');_$body.trigger({'type':'all-modal-closed'});};function checkRowEmpty(){void 0;if(!$('.col',_$row).length){if(!_$body.is('.entity-type-taxonomy_term.bundle-entrees')){if(!_$body.is('.entity-type-node.bundle-page')){if(_$body.is('.bundle-enregistrement.view-mode-article')&&$('a.articles-link').is('.is-active')){void 0;$('a.articles-link').removeClass('is-active').trigger('click');}else{backToFrontPage();}}else{if(_corpus_ready){_$corpus_canvas.trigger({'type':'scramble-collection'});}
$('a[data-drupal-link-system-path="productions"]','#block-mainnavigation').removeClass('is-active').trigger('click');}}else{$('.entree-content a.is-active').removeClass('is-active');}}};init();}
$(document).ready(function($){if(drupalSettings.path.isFront){var edlptheme=new EdlpTheme();}else{$('body').attr('booted','booted');}});})(jQuery,Drupal,drupalSettings);
File diff suppressed because one or more lines are too long
@@ -29,23 +29,28 @@
// if(!drupalSettings.path.isFront)
// return;
if(!_is_mobile){
initEvents();
if(_is_mobile){
initMobile();
}
_audioPlayer = new AudioPlayer();
_compoPlayer = new CompoPlayer();
initEvents();
_audioPlayer = new AudioPlayer();
_compoPlayer = new CompoPlayer();
initAjaxLinks();
initHistory();
if(!_is_mobile){
checkLayout();
initAjaxLinks();
initHistory();
initAudioLinksHover();
}else{
}
if(_is_mobile){
if(drupalSettings.path.isFront){
initHomeMobile();
}
_$body.attr('booted', 'booted');
}
@@ -62,38 +67,48 @@
// | \/ |___| |__(_) |___
// | |\/| / _ \ '_ \ | / -_)
// |_| |_\___/_.__/_|_\___|
function initHomeMobile(){
$('.field--name-field-notice, .index', '.entrees .taxonomy-term.vocabulary-entrees')
.addClass('closed');
$('[data-drupal-link-system-path="<front>"]','#block-mainnavigation')
.removeClass('is-active')
.attr('href', '#collection');
$('h2#block-mainnavigation-menu, a', '#block-mainnavigation')
function initMobile(){
// $('[data-drupal-link-system-path="<front>"]','#block-mainnavigation')
// .removeClass('is-active')
// .attr('href', '#collection');
// edlp_mobile.mobile_home_path.replace(/^\//, '')
// TODO: remove collection from mobile home
// TODO: replace ajax link to only collection for mobile
$('h2, a', '#block-mainnavigation')
.add('h2, a', '#block-mainnavigation-2')
.on('click', onclickHomeMobileMenu);
// $('a', '#block-mainnavigation')
// .on('click', onclickHomeMobileMenu);
$('.field--name-field-notice>.field__label', '.entrees .taxonomy-term.vocabulary-entrees')
.on('click', onClickHomeMobileNotice);
$('.index>.field__label', '.entrees .taxonomy-term.vocabulary-entrees')
.on('click', onClickHomeMobileIndex);
};
function onclickHomeMobileMenu(e){
$('#block-mainnavigation').toggleClass('visible');
};
function onClickHomeMobileNotice(e){
// console.log('onClickHomeMobileNotice');
// var $part = $(this).parent();//parents('.taxonomy-term');
toggleEntreeOpening($(this).parent(), 'notice');
};
function onClickHomeMobileIndex(e){
// console.log('onClickHomeMobileIndex');
// var $part = $(this).parent();//parents('.taxonomy-term');
toggleEntreeOpening($(this).parent(), 'index');
};
function toggleEntreeOpening($e, part){
$e.toggleClass('closed')
.parents('.taxonomy-term.vocabulary-entrees.home_mobile').toggleClass(part+'-opened');
}
function onclickHomeMobileMenu(e){
// $('#block-mainnavigation').toggleClass('opened');
$('#block-mainnavigation-2').toggleClass('opened');
};
function initHomeMobile(){
// taxonomy-term.vocabulary-entrees.home_mobile
// $('.field--name-field-notice, .index', '.entrees .taxonomy-term.vocabulary-entrees')
// .addClass('closed');
// $('.field--name-field-notice>.field__label', '.entrees .taxonomy-term.vocabulary-entrees')
// .on('click', onClickHomeMobileNotice);
// $('.index>.field__label', '.entrees .taxonomy-term.vocabulary-entrees')
// .on('click', onClickHomeMobileIndex);
};
// function onClickHomeMobileNotice(e){
// // console.log('onClickHomeMobileNotice');
// // var $part = $(this).parent();//parents('.taxonomy-term');
// toggleEntreeOpening($(this).parent(), 'notice');
// };
// function onClickHomeMobileIndex(e){
// // console.log('onClickHomeMobileIndex');
// // var $part = $(this).parent();//parents('.taxonomy-term');
// toggleEntreeOpening($(this).parent(), 'index');
// };
// function toggleEntreeOpening($e, part){
// $e.toggleClass('closed')
// .parents('.taxonomy-term.vocabulary-entrees.home_mobile').toggleClass(part+'-opened');
// }
// ___ _
// | __|_ _____ _ _| |_ ___
@@ -379,6 +394,11 @@
addCloseModalBtnToCols();
}
if(state.sys_path == "collection"){
// only for mobile version of collection
initCollectionNav();
}
// enregistrement transcription
if(data.entity_type == "node" && data.bundle == "enregistrement" && data.view_mode == "transcript"){
// window.requestAnimationFrame(initEnregistrementTranscript);
@@ -481,6 +501,8 @@
};
function addCloseModalBtnToCols(){
if(_is_mobile) return;
$('.col', _$row).each(function(index, el) {
if($('span.close-col-btn', this).length)
@@ -682,6 +704,7 @@
$('a.site-name', '#block-edlptheme-branding')
.add('a', '#block-mainnavigation')
.add('a', '#block-mainnavigation-2')
// .add('a', '.block.language-switcher-language-url')
.add('a', '#block-footer.menu--footer')
.add('a', '#block-productions')
@@ -695,8 +718,16 @@
$('a[data-drupal-link-system-path="<front>"]', '#block-mainnavigation').removeClass('is-active');
_$ajaxLinks = $('.ajax-link:not(.ajax-enabled)')
.each(function(i,e){
_$ajaxLinks = $('.ajax-link');
activateAjaxLinks();
};
// function initAudioLinks(){
// _$ajaxLinks = $('.ajax-link.audio-link');
// activateAjaxLinks();
// };
function activateAjaxLinks(){
// $('.ajax-link:not(.ajax-enabled)')
_$ajaxLinks.each(function(i,e){
var $this = $(this);
// avoid already ajaxified links
if($this.is('.ajax-enable')) return;
@@ -753,12 +784,17 @@
// front page
// just remove contents and stop here
if(sys_path == '<front>'){
if($link.is('.is-active') && _corpus_ready){
_$corpus_canvas.trigger({'type':'shuffle-collection'});
}else{
backToFrontPage();
if(!_is_mobile){
if($link.is('.is-active') && _corpus_ready){
_$corpus_canvas.trigger({'type':'shuffle-collection'});
}else{
backToFrontPage();
}
return false;
}
return false;
// else{
// sys_path = edlp_mobile.mobile_home_path.replace(/^\//, '');
// }
}
var view_mode = $link.attr('viewmode');
@@ -993,7 +1029,7 @@
this.currentHistoricIndex = historic_index;
}
if(_$body.is('.path-frontpage') && caller !== 'lastdocs'){
if(_$body.is('.path-frontpage') && caller !== 'lastdocs' && !_is_mobile){
closeAllModals();
}
// TODO: update language switcher for document url
@@ -1024,7 +1060,9 @@
this.clearTimeOutToHide();
this.clearIntervalAutoCartelSwitch();
this.setSRC(this.historic[this.currentHistoricIndex].audio_url);
this.loadNode(this.historic[this.currentHistoricIndex].nid);
if(!_is_mobile){
this.loadNode(this.historic[this.currentHistoricIndex].nid);
}
// emmit new playing doc (e.g.: corpus map nowing that audio played from RandomPlayer)
try {
_$corpus_canvas.trigger({
@@ -1677,8 +1715,10 @@
// \___|_| |_\__,_|
function initGrid(){
console.log('theme : initGrid');
checkGridBlockHeight();
_$row.find('.col').addClass('offfield');
if(!_is_mobile){
checkGridBlockHeight();
_$row.find('.col').addClass('offfield');
}
if(false){
var $grid = $('.grid',_$row).masonry({
@@ -1711,12 +1751,16 @@
}else{
// setTimeout(checkGridBlockVisible, 100);
checkGridBlockVisible();
if(!_is_mobile){
checkGridBlockVisible();
}
}
};
function checkGridBlockHeight(){
// console.log('checkGridBlockHeight');
// if(_is_mobile) return;
var $r_h = _$row.height();
var $this;
// console.log($r_h);
@@ -1737,6 +1781,8 @@
function checkGridBlockVisible(){
// console.log('checkGridBlockVisible');
// if(_is_mobile) return;
var $r_h = _$row.height();
var $this,pos;
$('.grid .col', _$row).each(function(i,e){
@@ -1803,6 +1849,40 @@
// };
// ___ _ _ _ _
// / __|___| | |___ __| |_(_)___ _ _
// | (__/ _ \ | / -_) _| _| / _ \ ' \
// \___\___/_|_\___\__|\__|_\___/_||_|
// mobile version of collection
function initCollectionNav(){
console.log('initCollectionNav');
// taxonomy-term.vocabulary-entrees.home_mobile
$('.field--name-field-notice, .index', '.taxonomy-term.vocabulary-entrees.home_mobile')
.addClass('closed');
$('.field--name-field-notice>.field__label', '.taxonomy-term.vocabulary-entrees.home_mobile')
.on('click', onClickCollectionNotice);
$('.index>.field__label', '.taxonomy-term.vocabulary-entrees.home_mobile')
.on('click', onClickCollectionIndex);
};
function onClickCollectionNotice(e){
// console.log('onClickCollectionNotice');
// var $part = $(this).parent();//parents('.taxonomy-term');
toggleEntreeOpening($(this).parent(), 'notice');
};
function onClickCollectionIndex(e){
// console.log('onClickCollectionIndex');
// var $part = $(this).parent();//parents('.taxonomy-term');
toggleEntreeOpening($(this).parent(), 'index');
};
function toggleEntreeOpening($e, part){
$e.toggleClass('closed')
.parents('.taxonomy-term.vocabulary-entrees.home_mobile').toggleClass(part+'-opened');
}
// ___ _
// / __| ___ __ _ _ _ __| |_
// \__ \/ -_) _` | '_/ _| ' \
@@ -1852,8 +1932,10 @@
$('body').removeClass().addClass('path-frontpage');
$('a[data-drupal-link-system-path="<front>"]').addClass('is-active');
// close entrees
_$corpus_canvas.trigger({'type':'close-all-entree'});
_$corpus_canvas.trigger({'type':'scramble-collection'});
if(_corpus_ready){
_$corpus_canvas.trigger({'type':'close-all-entree'});
_$corpus_canvas.trigger({'type':'scramble-collection'});
}
if(typeof pop_state == "undefined" || !pop_state){
console.log('backToFrontPage push state');
@@ -1924,7 +2006,9 @@
// }
}else{
// if we were on production page just scramble collection in case of map was filtered
_$corpus_canvas.trigger({'type':'scramble-collection'});
if(_corpus_ready){
_$corpus_canvas.trigger({'type':'scramble-collection'});
}
// reload production home
$('a[data-drupal-link-system-path="productions"]', '#block-mainnavigation')
.removeClass('is-active').trigger('click');
@@ -103,7 +103,7 @@ header[role="banner"]{
}
}
#block-mainnavigation{
#block-mainnavigation, #block-mainnavigation-2{
float:right;
margin-top: 25px;
z-index: 21;
@@ -161,12 +161,14 @@ header[role="banner"]{
width:50px; //height:25px;
overflow: visible;
$square-size:15px;
>h2#block-mainnavigation-menu.visually-hidden{
>h2#block-mainnavigation-menu.visually-hidden,
>h2{
// outline: 1px solid green;
right:0;
clip: auto;
margin:0;
text-indent: 100px;
overflow: hidden;
cursor: pointer;
width:$square-size*2; height:$square-size*2;
background-size:$square-size $square-size;
@@ -206,7 +208,7 @@ header[role="banner"]{
}
&.visible ul.menu{
&.opened ul.menu{
left:-130px;
}
}
@@ -579,11 +581,15 @@ main[role="main"]{
}
}
html.is-mobile & .entrees{
#collection{
margin-top: -80px;
margin-bottom: 80px;
.collection{
h3{
@include content_titles;
text-align: center;
padding-top: 0.5em;
}
}
html.is-mobile & .col[sys_path="collection"]{
h3{
@include content_titles;
text-align: center;
+133 -79
View File
@@ -128,98 +128,128 @@ function edlptheme_preprocess_edlp_productions(&$vars){
}
function edlptheme_preprocess_node__enregistrement__index(&$vars){
$node = $vars['elements']['#node'];
$options = ['absolute' => TRUE];
$url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
$system_path = $url->getInternalPath();
// get the audio file url
$field_son_values = $node->get('field_son')->getValue();
$son_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
$son_file = \Drupal\file\Entity\File::load($son_fid);
$son_url = null;
if($son_file){
$son_uri = $son_file->getFileUri();
$son_url = file_create_url($son_uri);
}
// $node = $vars['elements']['#node'];
// $options = ['absolute' => TRUE];
// $url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
// $system_path = $url->getInternalPath();
// // get the audio file url
// $field_son_values = $node->get('field_son')->getValue();
// $son_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
// $son_file = \Drupal\file\Entity\File::load($son_fid);
// $son_url = null;
// if($son_file){
// $son_uri = $son_file->getFileUri();
// $son_url = file_create_url($son_uri);
// }
//
// $vars['link_attributes'] = new Attribute(array(
// 'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
// 'audio_url' => $son_url,
// 'nid' => $node->id(),
// 'class' => array('audio-link', 'ajax-link')
// ));
edlptheme_prepare_audio_link($vars);
// dpm($vars['link_attributes']);
}
$vars['link_attributes'] = new Attribute(array(
'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
'audio_url' => $son_url,
'nid' => $node->id(),
'class' => array('audio-link', 'ajax-link')
));
// forhome mobile index
function edlptheme_preprocess_node__enregistrement__index_home(&$vars){
// $node = $vars['elements']['#node'];
// $options = ['absolute' => TRUE];
// $url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
// $system_path = $url->getInternalPath();
// // get the audio file url
// $field_son_values = $node->get('field_son')->getValue();
// $son_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
// $son_file = \Drupal\file\Entity\File::load($son_fid);
// $son_url = null;
// if($son_file){
// $son_uri = $son_file->getFileUri();
// $son_url = file_create_url($son_uri);
// }
//
// $vars['link_attributes'] = new Attribute(array(
// 'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
// 'audio_url' => $son_url,
// 'nid' => $node->id(),
// 'class' => array('audio-link', 'ajax-link')
// ));
edlptheme_prepare_audio_link($vars);
// dpm($vars['link_attributes']);
}
function edlptheme_preprocess_node__enregistrement__search_index(&$vars){
$node = $vars['elements']['#node'];
$options = ['absolute' => TRUE];
$url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
$system_path = $url->getInternalPath();
// get the audio file url
$field_son_values = $node->get('field_son')->getValue();
$son_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
$son_file = \Drupal\file\Entity\File::load($son_fid);
$son_url = null;
if($son_file){
$son_uri = $son_file->getFileUri();
$son_url = file_create_url($son_uri);
}
$vars['link_attributes'] = new Attribute(array(
'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
'audio_url' => $son_url,
'nid' => $node->id(),
'class' => array('audio-link', 'ajax-link')
));
// $node = $vars['elements']['#node'];
// $options = ['absolute' => TRUE];
// $url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
// $system_path = $url->getInternalPath();
// // get the audio file url
// $field_son_values = $node->get('field_son')->getValue();
// $son_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
// $son_file = \Drupal\file\Entity\File::load($son_fid);
// $son_url = null;
// if($son_file){
// $son_uri = $son_file->getFileUri();
// $son_url = file_create_url($son_uri);
// }
//
// $vars['link_attributes'] = new Attribute(array(
// 'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
// 'audio_url' => $son_url,
// 'nid' => $node->id(),
// 'class' => array('audio-link', 'ajax-link')
// ));
edlptheme_prepare_audio_link($vars);
// dpm($vars['link_attributes']);
}
function edlptheme_preprocess_node__enregistrement__lastdocs(&$vars){
$node = $vars['elements']['#node'];
$options = ['absolute' => TRUE];
$url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
$system_path = $url->getInternalPath();
// get the audio file url
$field_son_values = $node->get('field_son')->getValue();
$son_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
$son_file = \Drupal\file\Entity\File::load($son_fid);
$son_url = null;
if($son_file){
$son_uri = $son_file->getFileUri();
$son_url = file_create_url($son_uri);
}
$vars['link_attributes'] = new Attribute(array(
'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
'audio_url' => $son_url,
'nid' => $node->id(),
'class' => array('audio-link', 'ajax-link')
));
// $node = $vars['elements']['#node'];
// $options = ['absolute' => TRUE];
// $url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
// $system_path = $url->getInternalPath();
// // get the audio file url
// $field_son_values = $node->get('field_son')->getValue();
// $son_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
// $son_file = \Drupal\file\Entity\File::load($son_fid);
// $son_url = null;
// if($son_file){
// $son_uri = $son_file->getFileUri();
// $son_url = file_create_url($son_uri);
// }
//
// $vars['link_attributes'] = new Attribute(array(
// 'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
// 'audio_url' => $son_url,
// 'nid' => $node->id(),
// 'class' => array('audio-link', 'ajax-link')
// ));
edlptheme_prepare_audio_link($vars);
// dpm($vars['link_attributes']);
}
function edlptheme_preprocess_node__enregistrement__compo(&$vars){
$node = $vars['elements']['#node'];
$options = ['absolute' => TRUE];
$url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
$system_path = $url->getInternalPath();
// get the audio file url
$field_son_values = $node->get('field_son')->getValue();
$son_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
$son_file = \Drupal\file\Entity\File::load($son_fid);
$son_url = null;
if($son_file){
$son_uri = $son_file->getFileUri();
$son_url = file_create_url($son_uri);
}
$vars['link_attributes'] = new Attribute(array(
'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
'audio_url' => $son_url,
'nid' => $node->id(),
'class' => array('audio-link', 'ajax-link')
));
// $node = $vars['elements']['#node'];
// $options = ['absolute' => TRUE];
// $url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
// $system_path = $url->getInternalPath();
// // get the audio file url
// $field_son_values = $node->get('field_son')->getValue();
// $son_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
// $son_file = \Drupal\file\Entity\File::load($son_fid);
// $son_url = null;
// if($son_file){
// $son_uri = $son_file->getFileUri();
// $son_url = file_create_url($son_uri);
// }
//
// $vars['link_attributes'] = new Attribute(array(
// 'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
// 'audio_url' => $son_url,
// 'nid' => $node->id(),
// 'class' => array('audio-link', 'ajax-link')
// ));
edlptheme_prepare_audio_link($vars);
// dpm($vars);
$title = $vars['label'][0]['#context']['value'];
@@ -227,6 +257,30 @@ function edlptheme_preprocess_node__enregistrement__compo(&$vars){
// dpm($vars['link_attributes']);
}
function edlptheme_prepare_audio_link(&$vars){
$node = $vars['elements']['#node'];
$options = ['absolute' => TRUE];
$url = Url::fromRoute('entity.node.canonical', ['node' => $node->id()], $options);
$system_path = $url->getInternalPath();
// get the audio file url
$field_son_values = $node->get('field_son')->getValue();
$son_fid = count($field_son_values) ? $field_son_values[0]['target_id'] : "";
$son_file = \Drupal\file\Entity\File::load($son_fid);
$son_url = null;
if($son_file){
$son_uri = $son_file->getFileUri();
$son_url = file_create_url($son_uri);
}
$vars['link_attributes'] = new Attribute(array(
'data-drupal-link-system-path' => $system_path=='' ? '<front>' : $system_path,
'audio_url' => $son_url,
'nid' => $node->id(),
'class' => array('audio-link', 'ajax-link')
));
}
function edlptheme_preprocess_node__enregistrement__player_cartel(&$vars){
// dpm($vars);
$node = $vars['node'];
@@ -0,0 +1,7 @@
{% if entrees %}
<div class="col small-col-12 med-col-6 large-col-6">
<div class="wrapper">
{{ entrees }}
</div>
</div>
{% endif %}
@@ -43,10 +43,10 @@
</div>
{% endif %}
{% if entrees %}
<div class="entrees col small-col-12 med-col-4 large-col-3">
{% if collection %}
<div class="collection col small-col-12 med-col-4 large-col-3">
<div class="wrapper">
{{ entrees }}
{{ collection }}
</div>
</div>
{% endif %}