PageSourceSearch

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

js rech-im-ahrtal.de collected 2026-09-24 11:16:31 UTC 3,902 bytes, 120 lines download raw bytes

1window.asgaros = window.asgaros || {};
2
3(function(asgaros, $) {
4	var mentionsQueryCache = [];
5
6	// Adds @mentions to form inputs.
7	$.fn.suggestions = function() {
8		var opts = {
9			at:					'@',
10			delay:				200,
11			displayTpl:			'<li data-value="@${ID}"><img src="${image}"><span class="username">@${ID}</span><small>${name}</small></li>',
12			hideWithoutSuffix:	true,
13			insertTpl:			'@${ID}',
14			limit:				10,
15			searchKey:			'ID',
16			startWithSpace:		false,
17			suffix:				'',
18			callbacks: {
19				remoteFilter: function(query, render_view) {
20					// Cancel if query-string is empty.
21					if (!query) {
22						return;
23					}
24
25					// Try to get matches from cache first.
26					var mentionsItem = mentionsQueryCache[query];
27
28					if (typeof mentionsItem === 'object') {
29						render_view(mentionsItem);
30						return;
31					}
32
33					// If no matches available, do a request.
34					$.ajax({
35		                url: wpApiSettings.root+'asgaros-forum/v1/suggestions/mentioning/'+query,
36		                method: 'POST',
37						data: {
38							topicid: wpApiSettings.topicid
39						}
40		            })
41					.done(function(response) {
42		                if (response.status === true) {
43							mentionsQueryCache[query] = response.data;
44							render_view(response.data);
45						}
46		            });
47				},
48				beforeReposition: function(offset) {
49					var caret;
50					var line;
51					var iframeOffset;
52					var move;
53					var $view          = $('#atwho-ground-'+this.id+' .atwho-view');
54					var $body          = $('body');
55					var atwhoDataValue = this.$inputor.data('atwho');
56
57					if ('undefined' !== atwhoDataValue && 'undefined' !== atwhoDataValue.iframe && null !== atwhoDataValue.iframe) {
58						caret = this.$inputor.caret('offset', { iframe: atwhoDataValue.iframe });
59						// Caret.js no longer calculates iframe caret position from the window (it's now just within the iframe).
60						// We need to get the iframe offset from the window and merge that into our object.
61						iframeOffset = $(atwhoDataValue.iframe).offset();
62						if ('undefined' !== iframeOffset) {
63							caret.left += iframeOffset.left;
64							caret.top  += iframeOffset.top;
65						}
66					} else {
67						caret = this.$inputor.caret('offset');
68					}
69
70					// If the caret is past horizontal half, then flip it, yo
71					if (caret.left > ($body.width() / 2)) {
72						$view.addClass('right');
73						move = caret.left - offset.left - this.view.$el.width();
74					} else {
75						$view.removeClass('right');
76						move = caret.left - offset.left + 1;
77					}
78
79					// If we're on a small screen, scroll to caret
80					if ($body.width() <= 400) {
81						$(document).scrollTop(caret.top - 6);
82					}
83
84					// New position is under the caret (never above) and positioned to follow
85					// Dynamic sizing based on the input area (remove 'px' from end)
86					line = parseInt(this.$inputor.css('line-height').substr(0, this.$inputor.css('line-height').length - 2), 10);
87					if (!line || line < 5) { // sanity check, and catch no line-height
88						line = 19;
89					}
90
91					offset.top   = caret.top + line;
92					offset.left += move;
93				}
94			},
95			functionOverrides: {
96				// Override default behaviour which inserts junk tags in the WordPress Visual editor.
97				insert: function(content, $li) {
98					data = $li.data('item-data');
99					this.query.el.removeAttr('class').html(content).attr('contenteditable', "false");
100
101					if (!this.$inputor.is(':focus')) {
102						this.$inputor.focus();
103					}
104
105					return this.$inputor.change();
106				}
107			}
108		};
109
110		return $.fn.atwho.call(this, opts);
111	};
112
113	asgaros.suggestions_initialize = function() {
114		if (typeof window.tinyMCE === 'undefined' || window.tinyMCE.activeEditor === null || typeof window.tinyMCE.activeEditor === 'undefined') {
115			return;
116		} else {
117			$(window.tinyMCE.activeEditor.contentDocument.activeElement).atwho('setIframe', $('.wp-editor-wrap iframe')[0]).suggestions();
118		}
119	};
120})(asgaros, 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.