Ensure that file buttons can still be updated when you expand minimal toot form

This commit is contained in:
Jason McBrayer 2018-09-06 12:12:49 -04:00
parent 4f8bba7765
commit d9cb4b36e5
2 changed files with 45 additions and 39 deletions

View File

@ -93,3 +93,36 @@ function expandCWButtonPrepare()
});
};
}
function fileButtonUpdaters()
{
var file1 = document.getElementById("id_media_file_1");
file1.onchange = function(){
if (file1.files.length > 0)
{
document.getElementById('media_filename_1').innerHTML = file1.files[0].name;
}
};
var file2 = document.getElementById("id_media_file_2");
file2.onchange = function(){
if (file2.files.length > 0)
{
document.getElementById('media_filename_2').innerHTML = file2.files[0].name;
}
};
var file3 = document.getElementById("id_media_file_3");
file3.onchange = function(){
if (file3.files.length > 0)
{
document.getElementById('media_filename_3').innerHTML = file3.files[0].name;
}
};
var file4 = document.getElementById("id_media_file_4");
file4.onchange = function(){
if (file4.files.length > 0)
{
document.getElementById('media_filename_4').innerHTML = file4.files[0].name;
}
};
}

View File

@ -126,37 +126,10 @@
class="level-item emoji-link" title="custom emoji reference">😊</a>
</div>
</div>
</form>
{% if not preferences.theme.is_brutalist %}
{% if not preferences.theme.is_brutalist %}
<script type="application/javascript">
var file1 = document.getElementById("id_media_file_1");
file1.onchange = function(){
if (file1.files.length > 0)
{
document.getElementById('media_filename_1').innerHTML = file1.files[0].name;
}
};
var file2 = document.getElementById("id_media_file_2");
file2.onchange = function(){
if (file2.files.length > 0)
{
document.getElementById('media_filename_2').innerHTML = file2.files[0].name;
}
};
var file3 = document.getElementById("id_media_file_3");
file3.onchange = function(){
if (file3.files.length > 0)
{
document.getElementById('media_filename_3').innerHTML = file3.files[0].name;
}
};
var file4 = document.getElementById("id_media_file_4");
file4.onchange = function(){
if (file4.files.length > 0)
{
document.getElementById('media_filename_4').innerHTML = file4.files[0].name;
}
};
fileButtonUpdaters();
Intercooler.ready(fileButtonUpdaters);
</script>
{% endif %}
{% endif %}
</form>