Commit 243f0cfd authored by Gérald Niel's avatar Gérald Niel

WIP: amélioration module audio, intégration bandcamp.

parent a87fe19b
$(document).ready(function () {
getAudioUrl = function (type,iframe) {
if(type === "soundcloud"){
let secondPart = iframe.split('src="')[1]
getAudioUrl = function ( type, iframe ) {
switch ( type ) {
case "soundcloud":
return iframe.match(/src="(.*)"/)[1];
break;
case "bandcamp":
return iframe.match(/src="(.*)"/)[1];
break;
default:
return false;
return secondPart.split('"')[0]
}
}
getIframHeight = function( type, iframe ) {
switch ( type ) {
case "soundcloud":
return iframe.match(/height="(.*)"/)[1];
break;
case "bandcamp":
return iframe.match(/height: (.*)px/)[1];
break;
default:
return false;
}
}
$('.editAudioModal').modal()
$('.editAudioForm').submit(function (e) {
e.preventDefault()
......@@ -14,11 +34,12 @@ $(document).ready(function () {
let audioType = $('#editAudioForm-' + sectionId + " select[name=audioType]").val()
let audioIframe = $('#editAudioForm-' + sectionId + " input[name=audioIframe]").val()
console.log(audioIframe)
let audioUrl = getAudioUrl(audioType, audioIframe)
if(audioType === 'soundcloud') {
$('#audioContainer-' + sectionId).html('<iframe width="100%" height="450" scrolling="no" frameborder="no" allow="autoplay" src="' + audioUrl + '"></iframe>')
let audioUrl = getAudioUrl(audioType, audioIframe);
let iframeHeight = getIframHeight(audioType, audioIframe);
if( audioType === 'soundcloud' && audioUrl ) {
$('#audioContainer-' + sectionId).html('<iframe width="100%" height="' + ( iframeHeight || "450" ) +'" scrolling="no" frameborder="no" allow="autoplay" src="' + audioUrl + '"></iframe>')
}
console.log(audioIframe)
console.log(audioIframe)
$('#uglyForm input[name=uglyForm-' + sectionId + '-audioType]').val(audioType)
$('#uglyForm input[name=uglyForm-' + sectionId + '-audioUrl]').val(audioUrl)
// $('#videoTypeModuleVideo-'+sectionId).html(label)
......@@ -26,4 +47,4 @@ console.log(audioIframe)
$('.editAudioModal').modal('close')
initMainSaveBtn()
})
})
\ No newline at end of file
})
......@@ -9,7 +9,7 @@
data-delay="250" data-tooltip="Paramètres du lecteur audio" style=" right: -20px; top: -10px; z-index: 1000">
<i class="material-icons">music_video</i></a>
</check>
<div class="audio-container" id="audioContainer-{{@id}}" style="height: 188px; overflow-y: scroll">
<div class="audio-container" id="audioContainer-{{@id}}">
<check if="{{ @fields['audioType']['value'] == 'soundcloud'}}">
<iframe width="100%" height="450" scrolling="no" frameborder="no" allow="autoplay" src="{{@fields['audioUrl']['value']}}"></iframe>
</check>
......@@ -74,13 +74,14 @@
<select name="audioType">
<option value="soundcloud" selected>SoundCloud</option>
<option value="bandcamp">Bandcamp</option>
</select>
<label>Sélectionnez la source de votre lecteur audio</label>
<label for="audioType">Sélectionnez la source de votre lecteur audio</label>
</div>
<div class="input-field col s12 m8 offset-m2">
<input name="audioIframe" type="text" required class="validate grey-text text-darken-3" value="{{@fields['btnValue']['value'] }}">
<label>Collez le lien vers votre lecteur audio <b>ici</b></label>
<label for="audioIframe">Collez le lien vers votre lecteur audio <strong>ici</strong></label>
</div>
</div>
<div class="row">
......@@ -93,4 +94,4 @@
</form>
</div>
</div>
</check>
\ No newline at end of file
</check>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment