Skip to content

Commit efcf3c4

Browse files
committed
Modified Upload Field
It'll show filenames in upload field when uploaded.
1 parent e75792e commit efcf3c4

File tree

9 files changed

+41
-29
lines changed

9 files changed

+41
-29
lines changed

language/en-GB/en-GB.mod_jdsimplecontactform.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ MOD_JDSCF_TYPE_CALENDAR_LBL="Calendar"
8383
MOD_JDSCF_TYPE_LIST_LBL="List"
8484

8585
MOD_JDSCF_OPTIONS_LBL="Options"
86-
MOD_JDSCF_OPTIONS_DESC="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ac ligula ipsum."
86+
MOD_JDSCF_OPTIONS_DESC="Enter return seperated values."
8787

8888
MOD_JDSCF_CSS_LBL="Load CSS"
89-
MOD_JDSCF_CSS_DESC="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin ac ligula ipsum."
89+
MOD_JDSCF_CSS_DESC=""
9090

9191

9292
MOD_JDSCF_REQUIRED_ERROR="%s is required."

layouts/fields/checkbox.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,14 @@
1010
extract($displayData);
1111
$options = ModJDSimpleContactFormHelper::getOptions($field->options);
1212
$attrs = [];
13+
1314
if ($field->required) {
14-
$attrs[] = 'required';
15-
if (!empty(trim($field->custom_error))) {
16-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
17-
} else {
18-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
19-
}
15+
$attrs[] = 'required';
16+
if (!empty(trim($field->custom_error))) {
17+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
18+
} else {
19+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
20+
}
2021
}
2122
?>
2223
<div class="form-check form-check-inline">

layouts/fields/checkboxes.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
if ($field->required) {
1414
$attrs[] = 'required';
1515
if (!empty(trim($field->custom_error))) {
16-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
16+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
1717
} else {
18-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
18+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
1919
}
2020
}
2121
$optionslayout = isset($field->optionslayout) ? $field->optionslayout : 'vertical';

layouts/fields/file.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@
1212
if ($field->required) {
1313
$attrs[] = 'required';
1414
if (!empty(trim($field->custom_error))) {
15-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
15+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
1616
} else {
17-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
17+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
1818
}
19-
}
19+
}
2020
$attrs[] = 'id="' . $field->name . '-file-input"';
2121
//fetching allowed types
2222
$params = JComponentHelper::getParams('com_media');
@@ -31,7 +31,7 @@
3131
?>
3232
<div class="custom-file">
3333
<input id="<?php echo $field->name; ?>-<?php echo $module->id; ?>" accept="<?php foreach ($allowable as $type) { echo ".".$type.","; } ?>" type="file" name="jdscf[<?php echo $field->name; ?>]" class="custom-file-input" <?php echo implode(' ', $attrs); ?>>
34-
<label class="custom-file-label" for="<?php echo $field->name; ?>-file-input"><?php echo JText::_('MOD_JDSCF_FILE_BTN_LBL'); ?></label>
34+
<label class="custom-file-label" for="<?php echo $field->name; ?>-<?php echo $module->id; ?>"><?php echo JText::_('MOD_JDSCF_FILE_BTN_LBL'); ?></label>
3535
</div>
3636

3737
<div class="filesize-err filesize-error-<?php echo $field->name; ?>-<?php echo $module->id; ?> alert alert-danger alert-dismissable">
@@ -55,5 +55,16 @@
5555
$js .= '}';
5656
$js .= '};';
5757

58+
59+
// $js .= "jQuery('#" . $field->name . '-' .$module->id . "').on('change', function() {";
60+
// $js .= "var fileName = jQuery(this).val().split('\\').pop();";
61+
// $js .= "jQuery(this).siblings('.custom-file-label').addClass('selected').html(fileName);";
62+
// $js .= "});";
63+
64+
$js .= 'jQuery("#' . $field->name . '-' .$module->id . '").on("change", function() {';
65+
$js .= 'var fileName = jQuery(this).val().split("\\\").pop();';
66+
$js .= 'jQuery(this).siblings(".custom-file-label").addClass("selected").html(fileName);';
67+
$js .= '});';
68+
5869
ModJDSimpleContactFormHelper::addJS($js, $module->id);
5970
?>

layouts/fields/list.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,15 @@
1010
extract($displayData);
1111
$options = ModJDSimpleContactFormHelper::getOptions($field->options);
1212
$attrs = [];
13+
14+
1315
if ($field->required) {
14-
$attrs[] = 'required';
15-
if (!empty(trim($field->custom_error))) {
16+
$attrs[] = 'required';
17+
if (!empty(trim($field->custom_error))) {
1618
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
17-
} else {
19+
} else {
1820
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
19-
}
21+
}
2022
}
2123
?>
2224
<select name="jdscf[<?php echo $field->name; ?>]" class="form-control" <?php echo implode(' ', $attrs); ?>>

layouts/fields/radio.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@
1313
if ($field->required) {
1414
$attrs[] = 'required';
1515
if (!empty(trim($field->custom_error))) {
16-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
16+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
1717
} else {
18-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
18+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
1919
}
2020
}
2121
$optionslayout = isset($field->optionslayout) ? $field->optionslayout : 'vertical';

layouts/fields/text.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@
4848
if ($field->required) {
4949
$attrs[] = 'required';
5050
if (!empty(trim($field->custom_error))) {
51-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
51+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
5252
} else {
53-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
53+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
5454
}
5555
}
5656
?>

layouts/fields/textarea.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
if ($field->required) {
1313
$attrs[] = 'required';
1414
if (!empty(trim($field->custom_error))) {
15-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
15+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf($field->custom_error) . '"';
1616
} else {
17-
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
17+
$attrs[] = 'data-parsley-required-message="' . JText::sprintf('MOD_JDSCF_REQUIRED_ERROR', strip_tags($label)) . '"';
1818
}
1919
}
2020
if (isset($field->placeholder) && !empty($field->placeholder)) {

tmpl/default.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,9 @@
5454
$attributeArray[] = $attributeKey . '="' . $attributeValue . '"';
5555
}
5656
?>
57-
<div class="jdscf-row">
58-
<div class="jdscf-col">
59-
<div class="form-group">
60-
<div id="jdscf_recaptcha_<?php echo $module->id; ?>" class="g-recaptcha" data-sitekey="<?php echo $plugin_params->get('public_key', ''); ?>" <?php echo implode(' ', $attributeArray); ?>></div>
61-
</div>
57+
<div class="jdscf-col-md-12">
58+
<div class="form-group">
59+
<div id="jdscf_recaptcha_<?php echo $module->id; ?>" class="g-recaptcha" data-sitekey="<?php echo $plugin_params->get('public_key', ''); ?>" <?php echo implode(' ', $attributeArray); ?>></div>
6260
</div>
6361
</div>
6462
<?php

0 commit comments

Comments
 (0)