From 761659ddf0541417126cda75df691887e70555c5 Mon Sep 17 00:00:00 2001 From: Bachir Soussi Chiadmi Date: Tue, 24 Apr 2018 22:33:49 +0200 Subject: [PATCH] production sound are now playable --- .../edlptheme/assets/dist/scripts/main.min.js | 21 ++++++++++++++++++- .../custom/edlptheme/assets/scripts/main.js | 21 ++++++++++++++++++- .../themes/custom/edlptheme/edlptheme.theme | 4 ++++ .../templates/content/file-link.html.twig | 15 +++++++++++++ ....entity_view_display.node.page.default.yml | 4 ++-- .../sync/field.field.node.page.field_son.yml | 2 +- 6 files changed, 62 insertions(+), 5 deletions(-) create mode 100644 sites/all/themes/custom/edlptheme/templates/content/file-link.html.twig diff --git a/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js b/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js index b0034bf56..0a4975ac5 100644 --- a/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js +++ b/sites/all/themes/custom/edlptheme/assets/dist/scripts/main.min.js @@ -576,6 +576,7 @@ .add('a', '.productions-subtree') .add('a', '.productions-parent') // .add('a.index-link, a.notice-link', '#block-edlpentreesblock') + .add('a', '.field--name-field-son') .addClass('ajax-link'); _$ajaxLinks = $('.ajax-link:not(.ajax-enabled)') @@ -583,7 +584,7 @@ var $this = $(this); // avoid already ajaxified links if($this.is('.ajax-enable')) return; - if($this.attr('data-drupal-link-system-path')){ + if($this.attr('data-drupal-link-system-path') || $this.is('[type^="audio"]')){ $this.on('click', onClickAjaxLink).addClass('ajax-enable'); } }); @@ -608,6 +609,14 @@ return false; } + // other sounds playing + if($link.is('[type^="audio"]')){ + _audioPlayer + .emmit('stop-shuffle') + .openSound($link.attr('href'), $link.html()); + return false; + } + // NOT USED ( YET ? ) // if($link.is('.language-link')){ // TODO: change global site current language @@ -884,6 +893,16 @@ 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]); + } + }, // audio functions setSRC(url){ console.log('AudioPlayer setSRC : url', url); diff --git a/sites/all/themes/custom/edlptheme/assets/scripts/main.js b/sites/all/themes/custom/edlptheme/assets/scripts/main.js index b0034bf56..0a4975ac5 100644 --- a/sites/all/themes/custom/edlptheme/assets/scripts/main.js +++ b/sites/all/themes/custom/edlptheme/assets/scripts/main.js @@ -576,6 +576,7 @@ .add('a', '.productions-subtree') .add('a', '.productions-parent') // .add('a.index-link, a.notice-link', '#block-edlpentreesblock') + .add('a', '.field--name-field-son') .addClass('ajax-link'); _$ajaxLinks = $('.ajax-link:not(.ajax-enabled)') @@ -583,7 +584,7 @@ var $this = $(this); // avoid already ajaxified links if($this.is('.ajax-enable')) return; - if($this.attr('data-drupal-link-system-path')){ + if($this.attr('data-drupal-link-system-path') || $this.is('[type^="audio"]')){ $this.on('click', onClickAjaxLink).addClass('ajax-enable'); } }); @@ -608,6 +609,14 @@ return false; } + // other sounds playing + if($link.is('[type^="audio"]')){ + _audioPlayer + .emmit('stop-shuffle') + .openSound($link.attr('href'), $link.html()); + return false; + } + // NOT USED ( YET ? ) // if($link.is('.language-link')){ // TODO: change global site current language @@ -884,6 +893,16 @@ 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]); + } + }, // audio functions setSRC(url){ console.log('AudioPlayer setSRC : url', url); diff --git a/sites/all/themes/custom/edlptheme/edlptheme.theme b/sites/all/themes/custom/edlptheme/edlptheme.theme index 531ca4ee7..3b4511692 100644 --- a/sites/all/themes/custom/edlptheme/edlptheme.theme +++ b/sites/all/themes/custom/edlptheme/edlptheme.theme @@ -248,3 +248,7 @@ function edlptheme_preprocess_links__language_block(&$vars){ $vars['links'][$lang_code]['link']['#title'] = $lang_code; } } + +function edlptheme_preprocess_file_link(&$vars){ + +} diff --git a/sites/all/themes/custom/edlptheme/templates/content/file-link.html.twig b/sites/all/themes/custom/edlptheme/templates/content/file-link.html.twig new file mode 100644 index 000000000..44cbd7f68 --- /dev/null +++ b/sites/all/themes/custom/edlptheme/templates/content/file-link.html.twig @@ -0,0 +1,15 @@ +{# +/** + * @file + * Default theme implementation for a link to a file. + * + * Available variables: + * - attributes: The HTML attributes for the containing element. + * - link: A link to the file. + * + * @see template_preprocess_file_link() + * + * @ingroup themeable + */ +#} +{{ link }} diff --git a/sites/default/config/sync/core.entity_view_display.node.page.default.yml b/sites/default/config/sync/core.entity_view_display.node.page.default.yml index 74aede057..396f562cc 100644 --- a/sites/default/config/sync/core.entity_view_display.node.page.default.yml +++ b/sites/default/config/sync/core.entity_view_display.node.page.default.yml @@ -26,12 +26,12 @@ content: body: label: hidden type: text_default - weight: 3 + weight: 2 settings: { } third_party_settings: { } region: content field_son: - weight: 2 + weight: 3 label: hidden settings: use_description_as_link_text: true diff --git a/sites/default/config/sync/field.field.node.page.field_son.yml b/sites/default/config/sync/field.field.node.page.field_son.yml index 495577313..1b6d14904 100644 --- a/sites/default/config/sync/field.field.node.page.field_son.yml +++ b/sites/default/config/sync/field.field.node.page.field_son.yml @@ -21,7 +21,7 @@ settings: file_directory: page-sons file_extensions: 'mp3 ogg' max_filesize: '' - description_field: false + description_field: true handler: 'default:file' handler_settings: { } field_type: file