PageSourceSearch

https://rech-im-ahrtal.de/wp-content/plugins/asgaros-forum/js/script.js?ver=3.4.0

js rech-im-ahrtal.de collected 2026-09-24 11:16:26 UTC 11,740 bytes, 315 lines download raw bytes

1// Prevent replacing Font Awesome icons with SVG icons.
2window.FontAwesomeConfig = {
3    autoReplaceSvg: false
4};
5
6(function($) {
7    $(document).ready(function() {
8        // Handle click on reaction-icon.
9        $(document).on('click', '#af-wrapper .post-reactions a', function(e) {
10            e.preventDefault();
11
12            // Get relevant data first.
13            var post_id  = $(this).attr('data-post-id');
14            var reaction = $(this).attr('data-reaction');
15
16            $.ajax({
17                url: wpApiSettings.root+'asgaros-forum/v1/reaction/'+post_id+'/'+reaction,
18                method: 'POST',
19                beforeSend: function (xhr) {
20                    xhr.setRequestHeader('X-WP-Nonce', wpApiSettings.nonce);
21                }
22            })
23            .done(function(response) {
24                if (response.status === true) {
25                    $('#af-wrapper #postid-'+post_id+' .post-reactions').html(response.data.reactions);
26                    $('#af-wrapper #postid-'+post_id+' .post-reactions-summary').html(response.data.summary);
27                }
28            });
29        });
30
31        $(document).on('click', '#af-wrapper .post-reactions-summary', function(e) {
32            e.preventDefault();
33
34            var modal_content = $(this).find('.temporary-modal-container').html();
35            show_modal(modal_content);
36        });
37
38        // Sticky panel.
39        $('#af-wrapper .topic-button-sticky').click(function(e) {
40            e.preventDefault();
41
42    		$('#af-wrapper #sticky-panel').toggle();
43    	});
44
45        // Automatic submit for sticky-mode.
46        $('#af-wrapper input[name=sticky_topic]').on('change', function() {
47            $(this).closest('form').submit();
48        });
49
50        // Show editor inside another view.
51        $('a.forum-editor-button').click(function(e) {
52            e.preventDefault();
53
54            // Hide new post/topic buttons.
55            $('a.forum-editor-button').hide();
56
57            $('#forum-editor-form').slideToggle(400, function() {
58                // Focus subject line or editor.
59                var focusElement = $('.editor-row-subject input');
60
61                if (focusElement.length) {
62                    focusElement[0].focus();
63                } else {
64                    // We need to focus the form first to ensure scrolling.
65                    $('#forum-editor-form').focus();
66
67                    // Focus the editor.
68                    if (tinyMCE.activeEditor) {
69                        tinyMCE.activeEditor.focus();
70                    } else {
71                        $('textarea[id="message"]').focus();
72                    }
73                }
74            });
75        });
76
77        // Close editor.
78        $('#af-wrapper .editor-row-submit a.cancel').click(function(e) {
79            e.preventDefault();
80
81            $('#forum-editor-form').slideToggle(400, function() {
82                $('a.forum-editor-button').show();
83                $('.editor-row-subject input').val('');
84
85                if (tinyMCE.activeEditor) {
86                    // Clear TinyMCE editor.
87                    tinyMCE.activeEditor.setContent('');
88                } else {
89                    $('textarea[id="message"]').val('');
90                }
91            });
92        });
93
94        $('a.forum-editor-quote-button').click(function(e) {
95            e.preventDefault();
96
97            // Hide new post/topic buttons.
98            $('a.forum-editor-button').hide();
99
100            // Build quote.
101            var quoteID = $(this).attr('data-value-id');
102
103            // Make quotes compatible with Enlighter.
104            $('#post-quote-container-'+quoteID+' .EnlighterJSWrapper').remove();
105            $('#post-quote-container-'+quoteID+' .EnlighterJSRAW').removeAttr('style');
106
107            var quoteContent = $('#post-quote-container-'+quoteID).html();
108
109            // Add quote to the end of the editor.
110            if (tinyMCE.activeEditor) {
111                tinyMCE.activeEditor.setContent(tinyMCE.activeEditor.getContent()+quoteContent);
112            } else {
113                $('textarea[id="message"]').val($('textarea[id="message"]').val()+quoteContent);
114            }
115
116            // Call slideDown() instead of slideToggle() so we can add multiple quotes at once.
117            $('#forum-editor-form').slideDown(400, function() {
118                // We need to focus the form first to ensure scrolling.
119                $('#forum-editor-form').focus();
120
121                // Focus the editor at the last line.
122                if (tinyMCE.activeEditor) {
123                    tinyMCE.activeEditor.focus();
124                    tinyMCE.activeEditor.selection.select(tinyMCE.activeEditor.getBody(), true);
125                    tinyMCE.activeEditor.selection.collapse(false);
126                } else {
127                    $('textarea[id="message"]').focus();
128                }
129            });
130        });
131
132        $('a#add_file_link').click(function() {
133            // Insert new upload element.
134            $('<input type="file" name="forumfile[]"><br>').insertBefore(this);
135
136            // Check if we can add more upload elements.
137            checkUploadsMaximumNumber();
138        });
139
140        $('.uploaded-files a.delete').click(function() {
141            var filename = $(this).attr('data-filename');
142            $('#files-to-delete').append('<input type="hidden" name="deletefile[]" value="'+filename+'">');
143            $(this).parent().remove();
144
145            // Check if we can add more upload elements.
146            checkUploadsMaximumNumber();
147
148            // When there are no uploads anymore, remove the editor row.
149            var filesNumber = $('.uploaded-files li').length;
150
151            if (filesNumber == 0) {
152                $('.uploaded-files').parent().remove();
153            }
154        });
155
156        // Disable submit-button after first submit
157        $.fn.preventDoubleSubmission = function() {
158            $(this).on('submit', function(e) {
159                var form = $(this);
160
161                if (form.data('submitted') === true) {
162                    e.preventDefault();
163                } else {
164                    form.data('submitted', true);
165                }
166            });
167
168            return this;
169        };
170        $('#forum-editor-form').preventDoubleSubmission();
171
172        function checkUploadsMaximumNumber() {
173            var linkElement   = $('a#add_file_link');
174            var maximumNumber = linkElement.attr('data-maximum-number');
175
176            if (maximumNumber > 0) {
177                var inputsNumber = $('.editor-row-uploads input[type="file"]').length;
178                var filesNumber  = $('.uploaded-files li').length;
179                var totalNumber  = inputsNumber + filesNumber;
180
181                if (totalNumber >= maximumNumber) {
182                    linkElement.hide();
183                } else {
184                    linkElement.show();
185                }
186            }
187        }
188
189        // Add ability to toggle truncated quotes.
190        $('#af-wrapper .post-message > blockquote').click(function() {
191            $(this).toggleClass('full-quote');
192        });
193
194        // Mobile navigation.
195        $('#forum-navigation-mobile').click(function() {
196            $('#forum-navigation').toggleClass('show-navigation');
197        });
198
199        // Automatic submit for subscription settings.
200        $('#af-wrapper input[name=subscription_level]').on('change', function() {
201            $(this).closest('form').submit();
202        });
203
204        // Focus search input when clicking on container.
205        $('#af-wrapper #forum-search').click(function() {
206            $('#af-wrapper #forum-search input[name=keywords]').focus();
207        });
208
209        // Memberslist filter toggle.
210        $('#af-wrapper #memberslist-filter-toggle').click(function() {
211            $('#af-wrapper #memberslist-filter').slideToggle(0, function() {
212                var final_state = $(this).is(':hidden') ? 'hidden' : 'visible';
213
214                if (final_state === 'hidden') {
215                    $('#af-wrapper #memberslist-filter-toggle .title-element-icon').attr('class', 'title-element-icon fas fa-chevron-down');
216                    $('#af-wrapper #memberslist-filter-toggle .title-element-text').html($("#af-wrapper #memberslist-filter").attr('data-value-show-filters'));
217                } else {
218                    $('#af-wrapper #memberslist-filter-toggle .title-element-icon').attr('class', 'title-element-icon fas fa-chevron-up');
219                    $('#af-wrapper #memberslist-filter-toggle .title-element-text').html($("#af-wrapper #memberslist-filter").attr('data-value-hide-filters'));
220                }
221            });
222        });
223
224        // Polls form add.
225        $('#af-wrapper .add-poll').click(function() {
226            $('#af-wrapper #poll-form').css('display', 'block');
227        });
228
229        // Polls form remove.
230        $('#af-wrapper .remove-poll').click(function() {
231            $('#af-wrapper #poll-form').css('display', 'none');
232            clear_form_elements('#af-wrapper #poll-form');
233        });
234
235        $('#af-wrapper .poll-option-add').click(function() {
236            var content = $('#af-wrapper #poll-option-template').html();
237            $(content).insertBefore(this);
238        });
239
240        $(document).on('click', '#af-wrapper .poll-option-delete', function(event) {
241            event.preventDefault();
242            $(this).parent().remove();
243        });
244
245        // Warn user when he made changes inside the editor and leaves the page.
246        $(window).on('beforeunload', function() {
247            if (typeof tinyMCE !== 'undefined') {
248                if (tinyMCE.activeEditor) {
249                    if (tinyMCE.activeEditor.isDirty()) {
250                        return 'Are you sure you want to leave?';
251                    }
252                }
253            }
254        });
255
256        // Avoid dirty-check when submitting/cancelling the editor.
257        $('#af-wrapper .editor-row-submit .button-red').on('click', function(e) {
258            editor_not_dirty();
259        });
260
261        $('#af-wrapper #forum-editor-form').on('submit', function(e) {
262            editor_not_dirty();
263        });
264
265        function editor_not_dirty() {
266            if (typeof tinyMCE !== 'undefined') {
267                if (tinyMCE.activeEditor) {
268                    tinyMCE.activeEditor.isNotDirty = true;
269                }
270            }
271        }
272
273        // Clears all form-elements inside of a selected DOM-element.
274        function clear_form_elements(selector) {
275            $(selector).find(':input').each(function() {
276                switch (this.type) {
277                    case 'password':
278                    case 'text':
279                    case 'textarea':
280                    case 'file':
281                    case 'select-one':
282                    case 'select-multiple':
283                    case 'date':
284                    case 'number':
285                    case 'tel':
286                    case 'email':
287                        $(this).val('');
288                    break;
289                    case 'checkbox':
290                    case 'radio':
291                        this.checked = false;
292                    break;
293                }
294            });
295        }
296
297        // Creates a Modal.
298        function show_modal(modal_content) {
299            var modalHTML = '';
300            modalHTML    += '<div class="modal-layer">';
301            modalHTML    += '<div class="modal-content">';
302            modalHTML    += modal_content;
303            modalHTML    += '</div>';
304            modalHTML    += '</div>';
305
306            $('#af-wrapper').append(modalHTML);
307        }
308
309        $(document).on('click', '#af-wrapper .modal-layer', function(e) {
310            e.preventDefault();
311
312            $(this).remove();
313        });
314    });
315})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.