nodebb-plugin-simple-contact 1.2.2 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/public/templates/contact.tpl +45 -21
package/package.json
CHANGED
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
</div>
|
|
27
27
|
|
|
28
28
|
<div class="form-group" style="margin-bottom:20px;">
|
|
29
|
-
<label for="
|
|
30
|
-
<textarea class="form-control" id="
|
|
29
|
+
<label for="contact-message" style="font-weight:600; display:block; margin-bottom:6px;">תוכן הפנייה *</label>
|
|
30
|
+
<textarea class="form-control" id="contact-message" name="content" rows="6" required style="border-radius:10px; padding:10px;"></textarea>
|
|
31
31
|
</div>
|
|
32
32
|
|
|
33
33
|
<button type="submit" class="btn btn-primary btn-block" id="submit-btn" style="border-radius:22px; font-weight:600; padding:12px; margin-top:10px;">
|
|
@@ -45,38 +45,64 @@
|
|
|
45
45
|
|
|
46
46
|
<script>
|
|
47
47
|
(function() {
|
|
48
|
-
var
|
|
48
|
+
var loadContactForm = function() {
|
|
49
|
+
if (typeof window.jQuery === 'undefined' || typeof window.app === 'undefined') {
|
|
50
|
+
setTimeout(loadContactForm, 200);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
var $ = window.jQuery;
|
|
49
55
|
var form = $('#contact-form');
|
|
56
|
+
if (!form.length) return;
|
|
57
|
+
|
|
50
58
|
var btn = $('#submit-btn');
|
|
51
59
|
var alertBox = $('#contact-alert');
|
|
60
|
+
var isLoggedIn = (app.user && app.user.uid > 0);
|
|
52
61
|
|
|
53
|
-
if (
|
|
62
|
+
if (isLoggedIn) {
|
|
54
63
|
$('#username-group').hide();
|
|
55
64
|
}
|
|
56
65
|
|
|
57
66
|
form.off('submit').on('submit', function(e) {
|
|
58
67
|
e.preventDefault();
|
|
68
|
+
|
|
69
|
+
var contentVal = $('#contact-message').val();
|
|
70
|
+
var fullNameVal = $('#fullName').val();
|
|
71
|
+
var emailVal = $('#email').val();
|
|
72
|
+
var usernameVal = isLoggedIn ? app.user.username : $('#username').val();
|
|
73
|
+
|
|
74
|
+
if (!contentVal || contentVal.trim() === '') {
|
|
75
|
+
alertBox.removeClass('alert-success').addClass('alert-danger').text('אנא כתוב תוכן לפנייה').fadeIn();
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
|
|
59
79
|
btn.prop('disabled', true).text('שולח...');
|
|
60
80
|
alertBox.hide().removeClass('alert-success alert-danger');
|
|
61
81
|
|
|
62
|
-
var
|
|
63
|
-
fullName:
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
82
|
+
var payload = {
|
|
83
|
+
fullName: fullNameVal,
|
|
84
|
+
email: emailVal,
|
|
85
|
+
content: contentVal,
|
|
86
|
+
username: usernameVal,
|
|
67
87
|
_csrf: config.csrf_token
|
|
68
88
|
};
|
|
69
89
|
|
|
90
|
+
console.log('Sending Payload:', payload);
|
|
91
|
+
|
|
70
92
|
$.ajax({
|
|
71
93
|
url: config.relative_path + '/api/contact/send',
|
|
72
94
|
type: 'POST',
|
|
73
|
-
data:
|
|
95
|
+
data: payload,
|
|
96
|
+
headers: {
|
|
97
|
+
'x-csrf-token': config.csrf_token
|
|
98
|
+
},
|
|
74
99
|
success: function(response) {
|
|
75
100
|
alertBox.addClass('alert-success').text(response.message || 'הפנייה נשלחה בהצלחה').fadeIn();
|
|
76
101
|
form[0].reset();
|
|
77
102
|
},
|
|
78
103
|
error: function(xhr) {
|
|
79
|
-
|
|
104
|
+
console.error('Error:', xhr);
|
|
105
|
+
var msg = (xhr.responseJSON && xhr.responseJSON.error) ? xhr.responseJSON.error : 'אירעה שגיאה בשליחה. נסה שוב.';
|
|
80
106
|
alertBox.addClass('alert-danger').text(msg).fadeIn();
|
|
81
107
|
},
|
|
82
108
|
complete: function() {
|
|
@@ -86,16 +112,14 @@
|
|
|
86
112
|
});
|
|
87
113
|
};
|
|
88
114
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
window.
|
|
115
|
+
loadContactForm();
|
|
116
|
+
|
|
117
|
+
if (typeof window.jQuery !== 'undefined') {
|
|
118
|
+
$(window).on('action:ajaxify.end', function(ev, data) {
|
|
119
|
+
if (data.url.indexOf('contact') !== -1) {
|
|
120
|
+
loadContactForm();
|
|
121
|
+
}
|
|
122
|
+
});
|
|
93
123
|
}
|
|
94
|
-
|
|
95
|
-
$(window).on('action:ajaxify.end', function(ev, data) {
|
|
96
|
-
if (data.url === 'contact' || data.url === 'forum/contact') {
|
|
97
|
-
init();
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
124
|
})();
|
|
101
125
|
</script>
|