Skip to content

Commit 2179cf3

Browse files
committed
Moved link scheme to frontend
#722
1 parent 0bf5e47 commit 2179cf3

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

app/Http/Controllers/UserController.php

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -273,14 +273,12 @@ public function saveLink(request $request)
273273
'title' => $sanitizedText,
274274
]);
275275
}elseif($linkType->typename == "email"){
276-
$LinkURL = "mailto:".$LinkURL;
277276
$OrigLink->update([
278277
'link' => $LinkURL,
279278
'button_id' => $button?->id,
280279
'title' => $LinkTitle,
281280
]);
282281
}elseif($linkType->typename == "telephone"){
283-
$LinkURL = "tel:".$LinkURL;
284282
$OrigLink->update([
285283
'link' => $LinkURL,
286284
'button_id' => $button?->id,
@@ -398,10 +396,8 @@ public function saveLink(request $request)
398396
$links->button_id = "93";
399397
$links->title = $sanitizedText;
400398
}elseif($linkType->typename == "email"){
401-
$links->link = "mailto:".$links->link;
402399
$links->button_id = $button?->id;
403400
}elseif($linkType->typename == "telephone"){
404-
$links->link = "tel:".$links->link;
405401
$links->button_id = $button?->id;
406402
}elseif($linkType->typename == "vcard"){
407403

resources/views/components/pageitems/email-form.blade.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,14 @@
1010
<input type='email' name='link' value='{{str_replace("mailto:", "", $link_url)}}' class='form-control' required />
1111
<span class='small text-muted'>{{__('messages.Enter your E-Mail')}}</span>
1212

13+
<script>
14+
$(document).ready(function() {
15+
$('form').on('submit', function(e) {
16+
var linkInput = $(this).find('input[name="link"]');
17+
var linkValue = linkInput.val();
18+
if (!linkValue.toLowerCase().startsWith('mailto:')) {
19+
linkInput.val('mailto:' + linkValue);
20+
}
21+
});
22+
});
23+
</script>

resources/views/components/pageitems/telephone-form.blade.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,14 @@
1010
<input type='tel' name='link' value='{{str_replace("tel:", "", $link_url)}}' class='form-control' required />
1111
<span class='small text-muted'>{{__('messages.Enter your telephone number')}}</span>
1212

13+
<script>
14+
$(document).ready(function() {
15+
$('form').on('submit', function(e) {
16+
var linkInput = $(this).find('input[name="link"]');
17+
var linkValue = linkInput.val();
18+
if (!linkValue.toLowerCase().startsWith('tel:')) {
19+
linkInput.val('tel:' + linkValue);
20+
}
21+
});
22+
});
23+
</script>

0 commit comments

Comments
 (0)