murph-skeleton/assets/js/admin/modules/form.js

32 lines
632 B
JavaScript
Raw Normal View History

2021-06-15 14:16:07 +02:00
const $ = require('jquery')
2021-03-24 12:27:07 +01:00
2021-06-15 14:16:07 +02:00
module.exports = function () {
$('body').on('change', '.custom-file-input', function (event) {
const inputFile = event.currentTarget
2021-03-24 12:27:07 +01:00
2021-06-15 14:16:07 +02:00
$(inputFile).parent()
.find('.custom-file-label')
.html(inputFile.files[0].name)
})
2021-06-15 14:16:07 +02:00
$('.nav a').each(function () {
const link = $(this)
const href = link.attr('href')
2021-06-15 14:16:07 +02:00
if (href.substr(0, 1) !== '#') {
return
}
2021-06-15 14:16:07 +02:00
const tab = $('.tab-pane ' + href)
2021-06-15 14:16:07 +02:00
if (!tab.length) {
return
}
2021-06-15 14:16:07 +02:00
if (tab.find('.form-error-message').length) {
link.addClass('border border-danger')
link.click()
}
})
}