ソースを参照

production sound are now playable

Bachir Soussi Chiadmi 6 年 前
コミット
761659ddf0

+ 20 - 1
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);

+ 20 - 1
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);

+ 4 - 0
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){
+  
+}

+ 15 - 0
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
+ */
+#}
+<span{{ attributes }}>{{ link }}</span>

+ 2 - 2
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

+ 1 - 1
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