Skip to content

Commit

Permalink
Moved link scheme to frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianPrieber committed Feb 10, 2024
1 parent 0bf5e47 commit 2179cf3
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
4 changes: 0 additions & 4 deletions app/Http/Controllers/UserController.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,14 +273,12 @@ public function saveLink(request $request)
'title' => $sanitizedText,
]);
}elseif($linkType->typename == "email"){
$LinkURL = "mailto:".$LinkURL;
$OrigLink->update([
'link' => $LinkURL,
'button_id' => $button?->id,
'title' => $LinkTitle,
]);
}elseif($linkType->typename == "telephone"){
$LinkURL = "tel:".$LinkURL;
$OrigLink->update([
'link' => $LinkURL,
'button_id' => $button?->id,
Expand Down Expand Up @@ -398,10 +396,8 @@ public function saveLink(request $request)
$links->button_id = "93";
$links->title = $sanitizedText;
}elseif($linkType->typename == "email"){
$links->link = "mailto:".$links->link;
$links->button_id = $button?->id;
}elseif($linkType->typename == "telephone"){
$links->link = "tel:".$links->link;
$links->button_id = $button?->id;
}elseif($linkType->typename == "vcard"){

Expand Down
11 changes: 11 additions & 0 deletions resources/views/components/pageitems/email-form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@
<input type='email' name='link' value='{{str_replace("mailto:", "", $link_url)}}' class='form-control' required />
<span class='small text-muted'>{{__('messages.Enter your E-Mail')}}</span>

<script>
$(document).ready(function() {
$('form').on('submit', function(e) {
var linkInput = $(this).find('input[name="link"]');
var linkValue = linkInput.val();
if (!linkValue.toLowerCase().startsWith('mailto:')) {
linkInput.val('mailto:' + linkValue);
}
});
});
</script>
11 changes: 11 additions & 0 deletions resources/views/components/pageitems/telephone-form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,14 @@
<input type='tel' name='link' value='{{str_replace("tel:", "", $link_url)}}' class='form-control' required />
<span class='small text-muted'>{{__('messages.Enter your telephone number')}}</span>

<script>
$(document).ready(function() {
$('form').on('submit', function(e) {
var linkInput = $(this).find('input[name="link"]');
var linkValue = linkInput.val();
if (!linkValue.toLowerCase().startsWith('tel:')) {
linkInput.val('tel:' + linkValue);
}
});
});
</script>

0 comments on commit 2179cf3

Please # to comment.