Lines 1-44
Link Here
|
1 |
var core = [ [% whole.core %] ]; |
1 |
document.addEventListener("DOMContentLoaded", function () { |
2 |
var opac = [% opac || 0 %]; |
2 |
$("#add-new-fields").click(function (e) { |
3 |
document.addEventListener('DOMContentLoaded', function() { |
|
|
4 |
$('#add-new-fields').click(function(e) { |
5 |
e.preventDefault(); |
3 |
e.preventDefault(); |
6 |
var row = '<li class="form-horizontal">' + |
4 |
var row = |
|
|
5 |
'<li class="form-horizontal">' + |
7 |
'<input type="text" class="custom-name ' + |
6 |
'<input type="text" class="custom-name ' + |
8 |
( opac ? 'form-control input-fluid custom-field-input' : '') + |
7 |
"form-control input-fluid custom-field-input" + |
9 |
'" name="custom_key" placeholder="'+__('key')+'">' + |
8 |
'" name="custom_key" placeholder="' + |
10 |
' ' + |
9 |
__("key") + |
|
|
10 |
'">' + |
11 |
" " + |
11 |
'<input type="text" id="custom-value" name="custom_value" class="' + |
12 |
'<input type="text" id="custom-value" name="custom_value" class="' + |
12 |
( opac ? 'form-control input-fluid custom-field-input' : '') +'" placeholder="'+__('value')+'"> ' + |
13 |
"form-control input-fluid custom-field-input" + |
|
|
14 |
'" placeholder="' + |
15 |
__("value") + |
16 |
'"> ' + |
13 |
'<button type="button" class="btn btn-danger btn-sm ' + |
17 |
'<button type="button" class="btn btn-danger btn-sm ' + |
14 |
'delete-new-field">' + |
18 |
'delete-new-field">' + |
15 |
'<span class="fa fa-trash-can"></span> ' + |
19 |
'<span class="fa fa-trash-can"></span> ' + |
16 |
__('Delete') + |
20 |
__("Delete") + |
17 |
'</button></li>'; |
21 |
"</button></li>"; |
18 |
$('#standard-fields').append(row); |
22 |
$("#standard-fields").append(row); |
19 |
}); |
23 |
}); |
20 |
$('#standard-fields').on('click', '.delete-new-field', |
24 |
$("#standard-fields").on("click", ".delete-new-field", function (event) { |
21 |
function(event) { |
25 |
event.preventDefault(); |
22 |
event.preventDefault(); |
26 |
$(event.target).parent().remove(); |
23 |
$(event.target).parent().remove(); |
27 |
}); |
24 |
} |
28 |
$("#type").change(function () { |
25 |
); |
29 |
$("#create_form").prepend( |
26 |
$('#type').change(function() { |
|
|
27 |
$('#create_form').prepend( |
28 |
'<input type="hidden" name="change_type" value="1" />' |
30 |
'<input type="hidden" name="change_type" value="1" />' |
29 |
); |
31 |
); |
30 |
$('#create_form').submit(); |
32 |
$("#create_form").submit(); |
31 |
}); |
33 |
}); |
32 |
$('#standard-fields').on('keyup', '.custom-name', function() { |
34 |
$("#standard-fields").on("keyup", ".custom-name", function () { |
33 |
var val = $(this).val(); |
35 |
var val = $(this).val(); |
34 |
if (core.indexOf(val.toLowerCase()) > -1) { |
36 |
if (core.indexOf(val.toLowerCase()) > -1) { |
35 |
$('#custom-warning').text(__("The name '%s' is not permitted").format(val)).show(); |
37 |
$("#custom-warning") |
36 |
$('#ill-submit').attr('disabled', true); |
38 |
.text(__("The name '%s' is not permitted").format(val)) |
37 |
$('#add-new-fields').attr('disabled', true); |
39 |
.show(); |
|
|
40 |
$("#ill-submit").attr("disabled", true); |
41 |
$("#add-new-fields").attr("disabled", true); |
38 |
} else { |
42 |
} else { |
39 |
$('#custom-warning').hide(); |
43 |
$("#custom-warning").hide(); |
40 |
$('#ill-submit').attr('disabled', false); |
44 |
$("#ill-submit").attr("disabled", false); |
41 |
$('#add-new-fields').attr('disabled', false); |
45 |
$("#add-new-fields").attr("disabled", false); |
42 |
} |
46 |
} |
43 |
}); |
47 |
}); |
44 |
}); |
48 |
}); |
45 |
- |
|
|