-
+ https://
+
+
Suportamos: Mercado Livre, Amazon, Magazine Luiza, Americanas, Shopee, e outros e-commerces conhecidos.
@@ -895,6 +901,29 @@
font-size: 0.875rem;
margin-top: 0.25rem;
}
+
+/* URL Input Styling */
+.input-group .input-group-text.bg-primary,
+.input-group .input-group-text.bg-success {
+ border-right: 1px solid rgba(255,255,255,0.2);
+ font-weight: 600;
+ min-width: 85px;
+ justify-content: center;
+}
+
+.input-group .form-control {
+ border-left: none;
+ padding-left: 0.75rem;
+}
+
+.input-group .form-control:focus {
+ box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
+ border-color: #86b7fe;
+}
+
+.input-group:focus-within .input-group-text {
+ border-color: #86b7fe;
+}
@section Scripts {
@@ -911,6 +940,9 @@
// Initialize image upload
initializeImageUpload();
+ // Initialize URL input handlers
+ initializeUrlInputs();
+
// Check for validation errors and show toast + open accordion
checkValidationErrors();
@@ -974,11 +1006,6 @@
return;
}
- if (!url.startsWith('http://') && !url.startsWith('https://')) {
- alert('Por favor, insira uma URL válida que comece com http:// ou https://');
- return;
- }
-
extractProductData(url);
});
@@ -1161,11 +1188,6 @@
return;
}
- if (!url.startsWith('http://') && !url.startsWith('https://')) {
- alert('Por favor, insira uma URL válida que comece com http:// ou https://');
- return;
- }
-
addLinkInput(title, url, description, icon, 'Normal');
closeModalAndReset();
}
@@ -1187,11 +1209,6 @@
return;
}
- if (!url.startsWith('http://') && !url.startsWith('https://')) {
- alert('Por favor, insira uma URL válida que comece com http:// ou https://');
- return;
- }
-
addProductLinkInput(title, url, description, price, image);
closeModalAndReset();
}
@@ -1312,6 +1329,13 @@
function closeModalAndReset() {
// Clear modal form
$('#addLinkForm')[0].reset();
+
+ // Limpar campos de URL específicos
+ $('#linkUrlInput').val('');
+ $('#linkUrl').val('');
+ $('#productUrlInput').val('');
+ $('#productUrl').val('');
+
$('#productImagePreview').hide();
$('#productImagePlaceholder').show();
$('#productImage').val('');
@@ -1577,6 +1601,57 @@
}
}
+ // URL Input Functions
+ function initializeUrlInputs() {
+ // Setup para link normal
+ setupUrlField('#linkUrlInput', '#linkUrl');
+
+ // Setup para link de produto (se existir)
+ if ($('#productUrlInput').length) {
+ setupUrlField('#productUrlInput', '#productUrl');
+ }
+ }
+
+ function setupUrlField(inputSelector, hiddenSelector) {
+ const $input = $(inputSelector);
+ const $hidden = $(hiddenSelector);
+
+ // Eventos para tratar entrada do usuário
+ $input.on('input paste keyup', function() {
+ let value = $(this).val().trim();
+
+ // Remover https:// ou http:// se o usuário digitou
+ if (value.startsWith('https://')) {
+ value = value.substring(8);
+ $(this).val(value);
+ } else if (value.startsWith('http://')) {
+ value = value.substring(7);
+ $(this).val(value);
+ }
+
+ // Atualizar campo hidden com URL completa
+ if (value) {
+ $hidden.val('https://' + value);
+ } else {
+ $hidden.val('');
+ }
+ });
+
+ // Para modal de edição - detectar se já tem URL e separar
+ if ($hidden.val()) {
+ const existingUrl = $hidden.val();
+ if (existingUrl.startsWith('https://')) {
+ $input.val(existingUrl.substring(8));
+ } else if (existingUrl.startsWith('http://')) {
+ $input.val(existingUrl.substring(7));
+ $hidden.val('https://' + existingUrl.substring(7)); // Converter para https
+ } else {
+ $input.val(existingUrl);
+ $hidden.val('https://' + existingUrl);
+ }
+ }
+ }
+
// Image Upload Functions
function initializeImageUpload() {
const fileInput = $('#profileImageInput');