nodebb-plugin-simple-contact 1.2.1 → 1.2.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nodebb-plugin-simple-contact",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "תוסף טופס צור קשר עם התראות למנהלים וניהול פניות",
5
5
  "main": "library.js",
6
6
  "nbbpm": {
@@ -1,4 +1,4 @@
1
- <div class="row text-center" style="display:flex; justify-content:center; align-items:center;"> [cite: 1]
1
+ <div class="row text-center" style="display:flex; justify-content:center; align-items:center;">
2
2
  <div class="col-lg-8 col-lg-offset-2" style="margin-top:20px;">
3
3
  <div class="panel panel-default shadow-sm" style="border-radius:14px; border:none;">
4
4
 
@@ -8,35 +8,35 @@
8
8
 
9
9
  <div class="panel-body text-center" style="background:#fafafa; padding:20px 25px;">
10
10
 
11
- <form id="contact-form" role="form" style="max-width:600px; margin:0 auto;"> [cite: 2]
11
+ <form id="contact-form" role="form" style="max-width:600px; margin:0 auto;">
12
12
 
13
13
  <div class="form-group" style="margin-bottom:16px;">
14
- <label for="fullName" style="font-weight:600; display:block; margin-bottom:6px;">שם מלא *</label> [cite: 2]
15
- <input type="text" class="form-control" id="fullName" name="fullName" required style="border-radius:10px; padding:10px;"> [cite: 3]
14
+ <label for="fullName" style="font-weight:600; display:block; margin-bottom:6px;">שם מלא *</label>
15
+ <input type="text" class="form-control" id="fullName" name="fullName" required style="border-radius:10px; padding:10px;">
16
16
  </div>
17
17
 
18
- <div class="form-group" id="username-group" style="margin-bottom:16px;"> [cite: 4]
19
- <label for="username" style="font-weight:600; display:block; margin-bottom:6px;">שם משתמש בפורום</label> [cite: 4]
20
- <input type="text" class="form-control" id="username" name="username" style="border-radius:10px; padding:10px;"> [cite: 5]
18
+ <div class="form-group" id="username-group" style="margin-bottom:16px;">
19
+ <label for="username" style="font-weight:600; display:block; margin-bottom:6px;">שם משתמש בפורום</label>
20
+ <input type="text" class="form-control" id="username" name="username" style="border-radius:10px; padding:10px;">
21
21
  </div>
22
22
 
23
23
  <div class="form-group" style="margin-bottom:16px;">
24
- <label for="email" style="font-weight:600; display:block; margin-bottom:6px;">כתובת מייל *</label> [cite: 6]
25
- <input type="email" class="form-control" id="email" name="email" required style="border-radius:10px; padding:10px;"> [cite: 7]
24
+ <label for="email" style="font-weight:600; display:block; margin-bottom:6px;">כתובת מייל *</label>
25
+ <input type="email" class="form-control" id="email" name="email" required style="border-radius:10px; padding:10px;">
26
26
  </div>
27
27
 
28
28
  <div class="form-group" style="margin-bottom:20px;">
29
- <label for="content" style="font-weight:600; display:block; margin-bottom:6px;">תוכן הפנייה *</label> [cite: 8]
30
- <textarea class="form-control" id="content" name="content" rows="6" required style="border-radius:10px; padding:10px;"></textarea> [cite: 9]
29
+ <label for="content" style="font-weight:600; display:block; margin-bottom:6px;">תוכן הפנייה *</label>
30
+ <textarea class="form-control" id="content" name="content" rows="6" required style="border-radius:10px; padding:10px;"></textarea>
31
31
  </div>
32
32
 
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;"> [cite: 10]
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;">
34
34
  שלח פנייה
35
35
  </button>
36
36
 
37
37
  </form>
38
38
 
39
- <div id="contact-alert" class="alert text-center" style="display:none; margin-top:20px; border-radius:10px;"></div> [cite: 11]
39
+ <div id="contact-alert" class="alert text-center" style="display:none; margin-top:20px; border-radius:10px;"></div>
40
40
 
41
41
  </div>
42
42
  </div>
@@ -45,63 +45,57 @@
45
45
 
46
46
  <script>
47
47
  (function() {
48
- function initContactForm($) {
49
- var form = $('#contact-form'); [cite: 12]
50
- var btn = $('#submit-btn'); [cite: 12]
51
- var alertBox = $('#contact-alert'); [cite: 12]
48
+ var init = function() {
49
+ var form = $('#contact-form');
50
+ var btn = $('#submit-btn');
51
+ var alertBox = $('#contact-alert');
52
52
 
53
- if (app.user && app.user.uid > 0) {
53
+ if (window.app && app.user && app.user.uid > 0) {
54
54
  $('#username-group').hide();
55
55
  }
56
56
 
57
57
  form.off('submit').on('submit', function(e) {
58
58
  e.preventDefault();
59
-
60
- btn.prop('disabled', true).text('שולח...'); [cite: 12]
61
- alertBox.hide().removeClass('alert-success alert-danger'); [cite: 12]
59
+ btn.prop('disabled', true).text('שולח...');
60
+ alertBox.hide().removeClass('alert-success alert-danger');
62
61
 
63
62
  var formData = {
64
- fullName: form.find('#fullName').val(), [cite: 13]
65
- username: (app.user && app.user.uid > 0) ? app.user.username : form.find('#username').val(),
66
- email: form.find('#email').val(), [cite: 13]
67
- content: form.find('#content').val(), [cite: 13]
68
- _csrf: config.csrf_token [cite: 13]
63
+ fullName: $('#fullName').val(),
64
+ username: (app.user && app.user.uid > 0) ? app.user.username : $('#username').val(),
65
+ email: $('#email').val(),
66
+ content: $('#content').val(),
67
+ _csrf: config.csrf_token
69
68
  };
70
69
 
71
70
  $.ajax({
72
- url: config.relative_path + '/api/contact/send', [cite: 14]
73
- type: 'POST', [cite: 14]
74
- data: formData, [cite: 14]
71
+ url: config.relative_path + '/api/contact/send',
72
+ type: 'POST',
73
+ data: formData,
75
74
  success: function(response) {
76
- alertBox.addClass('alert-success').text(response.message || 'הפנייה נשלחה בהצלחה').fadeIn(); [cite: 15]
77
- form[0].reset(); [cite: 15]
78
- btn.text('שלח פנייה'); [cite: 15]
75
+ alertBox.addClass('alert-success').text(response.message || 'הפנייה נשלחה בהצלחה').fadeIn();
76
+ form[0].reset();
79
77
  },
80
78
  error: function(xhr) {
81
- var msg = (xhr.responseJSON && xhr.responseJSON.error) ? xhr.responseJSON.error : 'אירעה שגיאה בשליחה'; [cite: 16]
82
- alertBox.addClass('alert-danger').text(msg).fadeIn(); [cite: 16]
79
+ var msg = (xhr.responseJSON && xhr.responseJSON.error) ? xhr.responseJSON.error : 'אירעה שגיאה בשליחה';
80
+ alertBox.addClass('alert-danger').text(msg).fadeIn();
83
81
  },
84
82
  complete: function() {
85
- btn.prop('disabled', false).text('שלח פנייה'); [cite: 17]
83
+ btn.prop('disabled', false).text('שלח פנייה');
86
84
  }
87
85
  });
88
86
  });
89
- } [cite: 18]
90
-
91
- function safeBoot() {
92
- if (typeof jQuery === 'undefined' || typeof app === 'undefined') { [cite: 19]
93
- setTimeout(safeBoot, 50); [cite: 19]
94
- return; [cite: 19]
87
+ };
88
+
89
+ if (typeof jQuery !== 'undefined') {
90
+ init();
91
+ } else {
92
+ window.addEventListener('DOMContentLoaded', init);
93
+ }
94
+
95
+ $(window).on('action:ajaxify.end', function(ev, data) {
96
+ if (data.url === 'contact' || data.url === 'forum/contact') {
97
+ init();
95
98
  }
96
- var $ = jQuery;
97
- initContactForm($); [cite: 20]
98
- $(window).off('action:ajaxify.end.contact').on('action:ajaxify.end.contact', function(ev, data) { [cite: 20]
99
- if (data.url === 'contact') {
100
- initContactForm($);
101
- }
102
- });
103
- } [cite: 21]
104
-
105
- safeBoot();
99
+ });
106
100
  })();
107
101
  </script>