created lastdocs home block and corresponfing page
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
function template_preprocess_edlp_agenda(&$vars){
|
||||
// dpm($vars);
|
||||
/*
|
||||
/*
|
||||
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
|
||||
*/
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
@@ -54,7 +54,8 @@ function edlp_ajax_page_attachments(array &$attachments) {
|
||||
|| preg_match('/^\/?productions/', $current_path)
|
||||
|| preg_match('/^\/?agenda/', $current_path)
|
||||
|| preg_match('/^\/?studio/', $current_path)
|
||||
|| preg_match('/^\/?search/', $current_path)){
|
||||
|| preg_match('/^\/?search/', $current_path)
|
||||
|| preg_match('/^\/?lastdocs/', $current_path)){
|
||||
$redirect = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,11 +23,18 @@ function edlp_corpus_theme($existing, $type, $theme, $path) {
|
||||
return array(
|
||||
'blockentrees' => array(
|
||||
// 'render element' => '',
|
||||
'file' => 'blockentrees.inc',
|
||||
'file' => 'includes/blockentrees.inc',
|
||||
'variables' => array(
|
||||
'entrees_items' => array(),
|
||||
),
|
||||
),
|
||||
'edlp_corpus_lastdocs' => array(
|
||||
// 'render element' => '',
|
||||
'file' => 'includes/edlp_corpus_lastdocs.inc',
|
||||
'variables' => array(
|
||||
'lastdocs_nodes' => NULL,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -13,3 +13,20 @@ edlp_corpus.corpusjson:
|
||||
_title: 'Corpus'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
|
||||
edlp_corpus.lastdocs:
|
||||
path: '/lastdocs'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_corpus\Controller\CorpusController::lastdocs'
|
||||
_title: 'Last Docs'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
edlp_corpus.lastdocsajax:
|
||||
path: '/lastdocs/ajax'
|
||||
defaults:
|
||||
_controller: '\Drupal\edlp_corpus\Controller\CorpusController::lastdocsjson'
|
||||
_title: 'Last docs'
|
||||
requirements:
|
||||
_permission: 'access content'
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
// use Drupal\Core\Url;
|
||||
|
||||
function template_preprocess_edlp_corpus_lastdocs(&$vars){
|
||||
// dpm($vars);
|
||||
/*
|
||||
@see https://www.drupal8.ovh/index.php/en/tutoriels/339/render-a-node-or-an-entity
|
||||
*/
|
||||
$view_builder = \Drupal::entityTypeManager()->getViewBuilder('node');
|
||||
|
||||
if(count($vars['lastdocs_nodes'])){
|
||||
$lastdocs_list = array (
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
);
|
||||
foreach($vars['lastdocs_nodes'] as $node){
|
||||
$lastdocs_list['#items'][] = $view_builder->view($node, 'lastdocs');
|
||||
}
|
||||
|
||||
$vars['lastdocs'] = array(
|
||||
"#type"=>"container",
|
||||
"#attributes"=>array(
|
||||
"class"=>['lastdocs']
|
||||
),
|
||||
"#markup"=>"<h3>".t("Last Documents")."</h3>",
|
||||
"lastdocs"=>$lastdocs_list
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -148,4 +148,99 @@ class CorpusController extends ControllerBase {
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// _ _ _
|
||||
// | | __ _ __| |_ __| |___ __ ___
|
||||
// | |__/ _` (_-< _/ _` / _ \/ _(_-<
|
||||
// |____\__,_/__/\__\__,_\___/\__/__/
|
||||
|
||||
private function query() {
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'enregistrement')
|
||||
->sort('created', 'DESC')
|
||||
->range(0,20);
|
||||
|
||||
$nids = $query->execute();
|
||||
|
||||
$this->lastdocs_nodes = entity_load_multiple('node', $nids);
|
||||
|
||||
// record an array of nids for corpus map filtering
|
||||
$this->lastdocs_nids = [];
|
||||
foreach($nids as $key => $nid){
|
||||
$this->lastdocs_nids[] = $nid;
|
||||
}
|
||||
}
|
||||
|
||||
private function toRenderable(){
|
||||
$this->query();
|
||||
// dpm($this->next_event_node);
|
||||
|
||||
return array(
|
||||
"#theme"=>'edlp_corpus_lastdocs',
|
||||
'#lastdocs_nodes' => $this->lastdocs_nodes
|
||||
);
|
||||
|
||||
}
|
||||
/**
|
||||
* Display lastdocs as a page.
|
||||
*
|
||||
* @return renderable array
|
||||
*/
|
||||
public function lastdocs() {
|
||||
return $this->toRenderable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lastdocs data as json through ajax.
|
||||
*
|
||||
* @return json
|
||||
*/
|
||||
public function lastdocsjson() {
|
||||
|
||||
$renderable = $this->toRenderable();
|
||||
// $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'=>'Last Documents',
|
||||
'documents_lies' => $this->lastdocs_nids,
|
||||
];
|
||||
|
||||
// translations links
|
||||
// use Drupal\Core\Url;
|
||||
// use Drupal\Core\Language\LanguageInterface;
|
||||
$route_name = 'edlp_corpus.lastdocs';
|
||||
$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-lastdocs-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 @@
|
||||
{{ lastdocs }}
|
||||
@@ -23,6 +23,7 @@ function edlp_home_theme($existing, $type, $theme, $path) {
|
||||
// 'last_fil_node' => NULL,
|
||||
// 'last_production_node' => NULL,
|
||||
'promoted_nodes' => array(),
|
||||
'lastdocs_items' => NULL,
|
||||
'agenda_items' => NULL,
|
||||
'entrees_items' => NULL,
|
||||
),
|
||||
|
||||
@@ -93,6 +93,34 @@ function template_preprocess_edlp_home(&$vars){
|
||||
// )
|
||||
// );
|
||||
|
||||
|
||||
// render the lasts documents of collection as list
|
||||
$lastdocs_url = Url::fromRoute('edlp_corpus.lastdocs');
|
||||
$lastdocs = array(
|
||||
'#type'=>"container",
|
||||
'title'=>array(
|
||||
'#prefix'=> '<h3>',
|
||||
'#title' => t("Last documents"),
|
||||
'#suffix' => '</h3>',
|
||||
'#type' => 'link',
|
||||
'#url' => $lastdocs_url,
|
||||
'#options'=>array(
|
||||
'attributes' => array(
|
||||
'data-drupal-link-system-path' => $lastdocs_url->getInternalPath(),
|
||||
'class' => array('ajax-link'),
|
||||
)
|
||||
)
|
||||
),
|
||||
'list'=> array(
|
||||
'#theme' => 'item_list',
|
||||
'#items' => [],
|
||||
),
|
||||
);
|
||||
foreach($vars['lastdocs_items'] as $node){
|
||||
$lastdocs['list']['#items'][] = $node_view_builder->view($node, 'search_index');
|
||||
}
|
||||
$vars['lastdocs'] = render($lastdocs);
|
||||
|
||||
// render the next events of agenda as list
|
||||
$agenda_url = Url::fromRoute('edlp_agenda.agenda');
|
||||
$agenda = array(
|
||||
|
||||
@@ -72,6 +72,17 @@ class HomeController extends ControllerBase {
|
||||
// $prod = $query->execute();
|
||||
// $contents["#last_production_node"] = entity_load('node', array_pop($prod));
|
||||
|
||||
// last documents
|
||||
$query = \Drupal::entityQuery('node')
|
||||
->condition('status', 1)
|
||||
->condition('type', 'enregistrement')
|
||||
->sort('created', 'DESC')
|
||||
->range(0,10);
|
||||
|
||||
$lastdocs = $query->execute();
|
||||
$contents["#lastdocs_items"] = entity_load_multiple('node', $lastdocs);
|
||||
// dsm($contents["#lastdocs_items"], "#lastdocs_items");
|
||||
|
||||
// agenda
|
||||
$now = new DrupalDateTime('now');
|
||||
$now->setTimezone(new \DateTimeZone(DATETIME_STORAGE_TIMEZONE));
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
{{ node.build }}
|
||||
{% endfor %}
|
||||
|
||||
{{ lastdocs }}
|
||||
|
||||
{{ agenda }}
|
||||
|
||||
{% if entrees %}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
(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();}else{if(drupalSettings.path.isFront){initHomeMobile();}
|
||||
(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');$('.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){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 checkLayout(){var $audioplayer=$("#audio-player");if($audioplayer.length){var navpos=$('#block-mainnavigation').position();if(typeof navpos!='undefined'){$audioplayer.css({'width':navpos.left+'px'});}}
|
||||
@@ -17,7 +17,7 @@ if(data.entity_type=="node"&&data.bundle=="enregistrement"&&data.view_mode=="tra
|
||||
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();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(){_$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(){$('.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();};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');}}
|
||||
@@ -28,7 +28,7 @@ history.replaceState(state,null,edlp_origin.url+edlp_origin.hash);window.localSt
|
||||
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'))
|
||||
return false;if($link.is('.audio-link')){_audioPlayer.emmit('stop-shuffle').openDocument({nid:$link.attr('nid'),audio_url:$link.attr('audio_url'),title:$link.find('.field--name-title').html()});return false;}
|
||||
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;}
|
||||
@@ -38,7 +38,7 @@ $link.addClass('ajax-loading');ajaxLoadContent(state);return false;};function on
|
||||
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')){closeAllModals();}
|
||||
if(_$body.is('.path-frontpage')&&caller!=='lastdocs'){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.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
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -35,12 +35,13 @@
|
||||
_audioPlayer = new AudioPlayer();
|
||||
_compoPlayer = new CompoPlayer();
|
||||
|
||||
|
||||
checkLayout();
|
||||
|
||||
initAjaxLinks();
|
||||
|
||||
initHistory();
|
||||
|
||||
initAudioLinksHover();
|
||||
}else{
|
||||
if(drupalSettings.path.isFront){
|
||||
initHomeMobile();
|
||||
@@ -393,6 +394,8 @@
|
||||
|
||||
initAjaxLinks();
|
||||
|
||||
initAudioLinksHover();
|
||||
|
||||
checkVisibleCorpusMapSpace();
|
||||
|
||||
// trigger other modules behaviours
|
||||
@@ -404,6 +407,7 @@
|
||||
_$body.attr('booted', 'booted');
|
||||
_$body.removeClass('ajax-loading');
|
||||
|
||||
|
||||
// url is null means that we are loading content on popState event
|
||||
// so we don't record the state again
|
||||
if(state.url){
|
||||
@@ -435,6 +439,7 @@
|
||||
};
|
||||
|
||||
function initAudioLinksHover(){
|
||||
console.log("initAudioLinksHover()");
|
||||
_$row.find('a.audio-link')
|
||||
.on('mouseover', function(event) {
|
||||
event.preventDefault();
|
||||
@@ -687,13 +692,17 @@
|
||||
// Audio links
|
||||
// launch audio player and stop here
|
||||
if($link.is('.audio-link')){
|
||||
// check if caller is lastdocs block
|
||||
caller = $link.parents('.lastdocs').length ? 'lastdocs' : null;
|
||||
// open audio player
|
||||
_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;
|
||||
}
|
||||
|
||||
@@ -957,7 +966,7 @@
|
||||
this.currentHistoricIndex = historic_index;
|
||||
}
|
||||
|
||||
if(_$body.is('.path-frontpage')){
|
||||
if(_$body.is('.path-frontpage') && caller !== 'lastdocs'){
|
||||
closeAllModals();
|
||||
}
|
||||
// TODO: update language switcher for document url
|
||||
|
||||
@@ -459,6 +459,53 @@ main[role="main"]{
|
||||
}
|
||||
}
|
||||
|
||||
div.lastdocs{
|
||||
article.node--type-enregistrement{
|
||||
h2.node-title{
|
||||
@include content_subtitles;
|
||||
margin:0.9em 0 0 0;
|
||||
// margin:0 0 0.3em 0;
|
||||
}
|
||||
.entrees{
|
||||
@include entree-micro-square;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div.lastdocs-home{
|
||||
>.wrapper{
|
||||
padding:0 1em!important;
|
||||
}
|
||||
article.node--type-enregistrement{
|
||||
h2.node-title{
|
||||
// @include content_subtitles;
|
||||
// margin:0.9em 0 0 0;
|
||||
margin:0 0 0.3em 0;
|
||||
}
|
||||
.entrees{
|
||||
@include entree-micro-square;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div.lastdocs{
|
||||
article.node--type-enregistrement{
|
||||
.entrees{
|
||||
@include entree-micro-square;
|
||||
}
|
||||
h2.node-title{
|
||||
@include content_subtitles;
|
||||
margin:0.3em 0 0 0;
|
||||
// margin:0 0 0.3em 0;
|
||||
}
|
||||
.description{
|
||||
p{
|
||||
margin:0 0 0.3em 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div.taxonomy-term.vocabulary-entrees.home_mobile{
|
||||
// &:not(:first-of-type){
|
||||
padding-bottom: 1em;
|
||||
|
||||
@@ -22,7 +22,7 @@ body.toolbar-horizontal.toolbar-themes.toolbar-no-tabs{
|
||||
|
||||
header[role="banner"]{
|
||||
// outline: 1px solid blue;
|
||||
z-index: 2;
|
||||
z-index: 5;
|
||||
position: relative;
|
||||
padding:0 1em;
|
||||
>.wrapper{
|
||||
@@ -60,7 +60,7 @@ aside.messages{
|
||||
|
||||
html:not(.is-mobile) main[role="main"]{
|
||||
// outline:1px solid green;
|
||||
z-index: 1;
|
||||
z-index: 11;
|
||||
position: absolute;
|
||||
left:0; top:0;
|
||||
box-sizing:border-box;
|
||||
@@ -97,7 +97,7 @@ body.toolbar-horizontal.toolbar-themes.toolbar-no-tabs{
|
||||
|
||||
footer[role="contentinfo"]{
|
||||
// outline: 1px solid pink;
|
||||
z-index: 2;
|
||||
z-index: 5;
|
||||
position:fixed;
|
||||
bottom:0;
|
||||
box-sizing: content-box;
|
||||
|
||||
@@ -175,6 +175,30 @@ function edlptheme_preprocess_node__enregistrement__search_index(&$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')
|
||||
));
|
||||
// dpm($vars['link_attributes']);
|
||||
}
|
||||
|
||||
function edlptheme_preprocess_node__enregistrement__compo(&$vars){
|
||||
$node = $vars['elements']['#node'];
|
||||
$options = ['absolute' => TRUE];
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<div class="col small-col-12 med-col-6 large-col-6">
|
||||
<div class="wrapper">
|
||||
<div class="lastdocs">
|
||||
{{ lastdocs }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -25,12 +25,21 @@
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
|
||||
<div class="agenda col small-col-12 med-col-4 large-col-3">
|
||||
<div class="wrapper">
|
||||
{{ agenda }}
|
||||
{% if lastdocs %}
|
||||
<div class="lastdocs-home col small-col-12 med-col-4 large-col-3">
|
||||
<div class="wrapper">
|
||||
{{ lastdocs }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if agenda %}
|
||||
<div class="agenda col small-col-12 med-col-4 large-col-3">
|
||||
<div class="wrapper">
|
||||
{{ agenda }}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if entrees %}
|
||||
<div class="entrees col small-col-12 med-col-4 large-col-3">
|
||||
|
||||
+98
@@ -0,0 +1,98 @@
|
||||
{#
|
||||
/**
|
||||
* @file
|
||||
* Theme override to display a node.
|
||||
*
|
||||
* Available variables:
|
||||
* - node: The node entity with limited access to object properties and methods.
|
||||
* Only method names starting with "get", "has", or "is" and a few common
|
||||
* methods such as "id", "label", and "bundle" are available. For example:
|
||||
* - node.getCreatedTime() will return the node creation timestamp.
|
||||
* - node.hasField('field_example') returns TRUE if the node bundle includes
|
||||
* field_example. (This does not indicate the presence of a value in this
|
||||
* field.)
|
||||
* - node.isPublished() will return whether the node is published or not.
|
||||
* Calling other methods, such as node.delete(), will result in an exception.
|
||||
* See \Drupal\node\Entity\Node for a full list of public properties and
|
||||
* methods for the node object.
|
||||
* - label: The title of the node.
|
||||
* - content: All node items. Use {{ content }} to print them all,
|
||||
* or print a subset such as {{ content.field_example }}. Use
|
||||
* {{ content|without('field_example') }} to temporarily suppress the printing
|
||||
* of a given child element.
|
||||
* - author_picture: The node author user entity, rendered using the "compact"
|
||||
* view mode.
|
||||
* - metadata: Metadata for this node.
|
||||
* - date: Themed creation date field.
|
||||
* - author_name: Themed author name field.
|
||||
* - url: Direct URL of the current node.
|
||||
* - display_submitted: Whether submission information should be displayed.
|
||||
* - attributes: HTML attributes for the containing element.
|
||||
* The attributes.class element may contain one or more of the following
|
||||
* classes:
|
||||
* - node: The current template type (also known as a "theming hook").
|
||||
* - node--type-[type]: The current node type. For example, if the node is an
|
||||
* "Article" it would result in "node--type-article". Note that the machine
|
||||
* name will often be in a short form of the human readable label.
|
||||
* - node--view-mode-[view_mode]: The View Mode of the node; for example, a
|
||||
* teaser would result in: "node--view-mode-teaser", and
|
||||
* full: "node--view-mode-full".
|
||||
* The following are controlled through the node publishing options.
|
||||
* - node--promoted: Appears on nodes promoted to the front page.
|
||||
* - node--sticky: Appears on nodes ordered above other non-sticky nodes in
|
||||
* teaser listings.
|
||||
* - node--unpublished: Appears on unpublished nodes visible only to site
|
||||
* admins.
|
||||
* - title_attributes: Same as attributes, except applied to the main title
|
||||
* tag that appears in the template.
|
||||
* - content_attributes: Same as attributes, except applied to the main
|
||||
* content tag that appears in the template.
|
||||
* - author_attributes: Same as attributes, except applied to the author of
|
||||
* the node tag that appears in the template.
|
||||
* - title_prefix: Additional output populated by modules, intended to be
|
||||
* displayed in front of the main title tag that appears in the template.
|
||||
* - title_suffix: Additional output populated by modules, intended to be
|
||||
* displayed after the main title tag that appears in the template.
|
||||
* - view_mode: View mode; for example, "teaser" or "full".
|
||||
* - teaser: Flag for the teaser state. Will be true if view_mode is 'teaser'.
|
||||
* - page: Flag for the full page state. Will be true if view_mode is 'full'.
|
||||
* - readmore: Flag for more state. Will be true if the teaser content of the
|
||||
* node cannot hold the main body content.
|
||||
* - logged_in: Flag for authenticated user status. Will be true when the
|
||||
* current user is a logged-in member.
|
||||
* - is_admin: Flag for admin user status. Will be true when the current user
|
||||
* is an administrator.
|
||||
*
|
||||
* @see template_preprocess_node()
|
||||
*
|
||||
* @todo Remove the id attribute (or make it a class), because if that gets
|
||||
* rendered twice on a page this is invalid CSS for example: two lists
|
||||
* in different view modes.
|
||||
*/
|
||||
#}
|
||||
{%
|
||||
set classes = [
|
||||
'node',
|
||||
'node--type-' ~ node.bundle|clean_class,
|
||||
node.isPromoted() ? 'node--promoted',
|
||||
node.isSticky() ? 'node--sticky',
|
||||
not node.isPublished() ? 'node--unpublished',
|
||||
view_mode ? 'node--view-mode-' ~ view_mode|clean_class,
|
||||
]
|
||||
%}
|
||||
{{ attach_library('classy/node') }}
|
||||
<article{{ attributes.addClass(classes) }}>
|
||||
<div class="entrees">
|
||||
{# THIS IS REALLY DIRTY !! #}
|
||||
{% for key, child in content.field_entrees if key|first != '#' %}
|
||||
{% set tid = child['#cache']['tags'][0]|replace({'taxonomy_term:':''}) %}
|
||||
<span class="entree" tid="{{ tid }}" title="{{ child }}"></span>
|
||||
{% endfor %}
|
||||
</div>
|
||||
<h2{{ title_attributes.addClass('node-title') }}>
|
||||
<a href="{{ url }}" rel="bookmark" {{ link_attributes }}>{{ label }}</a>
|
||||
</h2>
|
||||
<div class="description">
|
||||
{{ content.field_description }}
|
||||
</div>
|
||||
</article>
|
||||
@@ -0,0 +1,63 @@
|
||||
uuid: 0c8f0bed-07d8-4edb-97a7-22b968348fb1
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies:
|
||||
config:
|
||||
- core.entity_view_mode.node.lastdocs
|
||||
- field.field.node.enregistrement.body
|
||||
- field.field.node.enregistrement.field_collectionneurs
|
||||
- field.field.node.enregistrement.field_description
|
||||
- field.field.node.enregistrement.field_entrees
|
||||
- field.field.node.enregistrement.field_genres
|
||||
- field.field.node.enregistrement.field_langues
|
||||
- field.field.node.enregistrement.field_locuteurs
|
||||
- field.field.node.enregistrement.field_nbr_locuteurs
|
||||
- field.field.node.enregistrement.field_son
|
||||
- field.field.node.enregistrement.field_transcript_trad
|
||||
- field.field.node.enregistrement.field_transcript_vo
|
||||
- field.field.node.enregistrement.field_workflow
|
||||
- node.type.enregistrement
|
||||
module:
|
||||
- text
|
||||
- user
|
||||
id: node.enregistrement.lastdocs
|
||||
targetEntityType: node
|
||||
bundle: enregistrement
|
||||
mode: lastdocs
|
||||
content:
|
||||
content_moderation_control:
|
||||
weight: -20
|
||||
region: content
|
||||
settings: { }
|
||||
third_party_settings: { }
|
||||
field_description:
|
||||
weight: 1
|
||||
label: hidden
|
||||
settings: { }
|
||||
third_party_settings: { }
|
||||
type: text_default
|
||||
region: content
|
||||
field_entrees:
|
||||
type: entity_reference_label
|
||||
weight: 0
|
||||
region: content
|
||||
label: hidden
|
||||
settings:
|
||||
link: false
|
||||
third_party_settings: { }
|
||||
hidden:
|
||||
addtoany: true
|
||||
body: true
|
||||
chutier_actions: true
|
||||
field_collectionneurs: true
|
||||
field_genres: true
|
||||
field_langues: true
|
||||
field_locuteurs: true
|
||||
field_nbr_locuteurs: true
|
||||
field_son: true
|
||||
field_transcript_trad: true
|
||||
field_transcript_vo: true
|
||||
field_workflow: true
|
||||
langcode: true
|
||||
links: true
|
||||
relations: true
|
||||
@@ -0,0 +1,10 @@
|
||||
uuid: f842baf4-6682-4cf1-9cfa-6eff2113c348
|
||||
langcode: fr
|
||||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- node
|
||||
id: node.lastdocs
|
||||
label: 'LastDocs (documents)'
|
||||
targetEntityType: node
|
||||
cache: true
|
||||
Reference in New Issue
Block a user