Skip to content

Commit

Permalink
change url input type to text if Upload is selected
Browse files Browse the repository at this point in the history
  • Loading branch information
TomeCirun authored and RossWebsterWork committed Nov 22, 2023
1 parent 52fa0a5 commit 097e77d
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ckan/public/base/javascript/modules/resource-upload-field.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
this.ckan.module('resource-upload-field', function (jQuery) {
var _nameIsDirty = !! $('input[name="name"]').val();
var urlField = $('#field-resource-url');
return {
initialize: function() {
$('input[name="name"]').on('change', function() {
_nameIsDirty = true;
});

// Change input type to text if Upload is selected
if ($('#resource-url-upload').prop('checked')) {
urlField.attr('type', 'text');
}

// revert to URL for Link option
$('#resource-link-button').on('click', function() {
urlField.attr('type', 'url');
})

$('#field-resource-upload').on('change', function() {
if (_nameIsDirty) {
return;
Expand Down

0 comments on commit 097e77d

Please sign in to comment.