Verzeichnisstruktur phpBB-3.3.15
- Veröffentlicht
- 28.08.2024
So funktioniert es
|
Auf das letzte Element klicken. Dies geht jeweils ein Schritt zurück |
Auf das Icon klicken, dies öffnet das Verzeichnis. Nochmal klicken schließt das Verzeichnis. |
|
(Beispiel Datei-Icons)
|
Auf das Icon klicken um den Quellcode anzuzeigen |
ajax.js
001 /* global phpbb */
002
003 (function($) { // Avoid conflicts with other libraries
004
005 'use strict';
006
007 // This callback will mark all forum icons read
008 phpbb.addAjaxCallback('mark_forums_read', function(res) {
009 var readTitle = res.NO_UNREAD_POSTS;
010 var unreadTitle = res.UNREAD_POSTS;
011 var iconsArray = {
012 forum_unread: 'forum_read',
013 forum_unread_subforum: 'forum_read_subforum',
014 forum_unread_locked: 'forum_read_locked'
015 };
016
017 $('li.row').find('dl[class*="forum_unread"]').each(function() {
018 var $this = $(this);
019
020 $.each(iconsArray, function(unreadClass, readClass) {
021 if ($this.hasClass(unreadClass)) {
022 $this.removeClass(unreadClass).addClass(readClass);
023 }
024 });
025 $this.children('dt[title="' + unreadTitle + '"]').attr('title', readTitle);
026 });
027
028 // Mark subforums read
029 $('a.subforum[class*="unread"]').removeClass('unread').addClass('read').children('.icon.icon-red').removeClass('icon-red').addClass('icon-blue');
030
031 // Mark topics read if we are watching a category and showing active topics
032 if ($('#active_topics').length) {
033 phpbb.ajaxCallbacks.mark_topics_read.call(this, res, false);
034 }
035
036 // Update mark forums read links
037 $('[data-ajax="mark_forums_read"]').attr('href', res.U_MARK_FORUMS);
038
039 phpbb.closeDarkenWrapper(3000);
040 });
041
042 /**
043 * This callback will mark all topic icons read
044 *
045 * @param {bool} [update_topic_links=true] Whether "Mark topics read" links
046 * should be updated. Defaults to true.
047 */
048 phpbb.addAjaxCallback('mark_topics_read', function(res, updateTopicLinks) {
049 var readTitle = res.NO_UNREAD_POSTS;
050 var unreadTitle = res.UNREAD_POSTS;
051 var iconsArray = {
052 global_unread: 'global_read',
053 announce_unread: 'announce_read',
054 sticky_unread: 'sticky_read',
055 topic_unread: 'topic_read'
056 };
057 var iconsState = ['', '_hot', '_hot_mine', '_locked', '_locked_mine', '_mine'];
058 var unreadClassSelectors;
059 var classMap = {};
060 var classNames = [];
061
062 if (typeof updateTopicLinks === 'undefined') {
063 updateTopicLinks = true;
064 }
065
066 $.each(iconsArray, function(unreadClass, readClass) {
067 $.each(iconsState, function(key, value) {
068 // Only topics can be hot
069 if ((value === '_hot' || value === '_hot_mine') && unreadClass !== 'topic_unread') {
070 return true;
071 }
072 classMap[unreadClass + value] = readClass + value;
073 classNames.push(unreadClass + value);
074 });
075 });
076
077 unreadClassSelectors = '.' + classNames.join(',.');
078
079 $('li.row').find(unreadClassSelectors).each(function() {
080 var $this = $(this);
081 $.each(classMap, function(unreadClass, readClass) {
082 if ($this.hasClass(unreadClass)) {
083 $this.removeClass(unreadClass).addClass(readClass);
084 }
085 });
086 $this.children('dt[title="' + unreadTitle + '"]').attr('title', readTitle);
087 });
088
089 // Remove link to first unread post
090 $('a.unread').has('.icon-red').remove();
091
092 // Update mark topics read links
093 if (updateTopicLinks) {
094 $('[data-ajax="mark_topics_read"]').attr('href', res.U_MARK_TOPICS);
095 }
096
097 phpbb.closeDarkenWrapper(3000);
098 });
099
100 // This callback will mark all notifications read
101 phpbb.addAjaxCallback('notification.mark_all_read', function(res) {
102 if (typeof res.success !== 'undefined') {
103 phpbb.markNotifications($('#notification_list li.bg2'), 0);
104 phpbb.toggleDropdown.call($('#notification_list_button'));
105 phpbb.closeDarkenWrapper(3000);
106 }
107 });
108
109 // This callback will mark a notification read
110 phpbb.addAjaxCallback('notification.mark_read', function(res) {
111 if (typeof res.success !== 'undefined') {
112 var unreadCount = Number($('#notification_list_button strong').html()) - 1;
113 phpbb.markNotifications($(this).parent('li.bg2'), unreadCount);
114 }
115 });
116
117 /**
118 * Mark notification popup rows as read.
119 *
120 * @param {jQuery} $popup jQuery object(s) to mark read.
121 * @param {int} unreadCount The new unread notifications count.
122 */
123 phpbb.markNotifications = function($popup, unreadCount) {
124 // Remove the unread status.
125 $popup.removeClass('bg2');
126 $popup.find('a.mark_read').remove();
127
128 // Update the notification link to the real URL.
129 $popup.each(function() {
130 var link = $(this).find('a');
131 link.attr('href', link.attr('data-real-url'));
132 });
133
134 // Update the unread count.
135 $('strong', '#notification_list_button').html(unreadCount);
136 // Remove the Mark all read link and hide notification count if there are no unread notifications.
137 if (!unreadCount) {
138 $('#mark_all_notifications').remove();
139 $('#notification_list_button > strong').addClass('hidden');
140 }
141
142 // Update page title
143 var $title = $('title');
144 var originalTitle = $title.text().replace(/(\((\d+)\))/, '');
145 $title.text((unreadCount ? '(' + unreadCount + ')' : '') + originalTitle);
146 };
147
148 // This callback finds the post from the delete link, and removes it.
149 phpbb.addAjaxCallback('post_delete', function() {
150 var $this = $(this),
151 postId;
152
153 if ($this.attr('data-refresh') === undefined) {
154 postId = $this[0].href.split('&p=')[1];
155 var post = $this.parents('#p' + postId).css('pointer-events', 'none');
156 if (post.hasClass('bg1') || post.hasClass('bg2')) {
157 var posts1 = post.nextAll('.bg1');
158 post.nextAll('.bg2').removeClass('bg2').addClass('bg1');
159 posts1.removeClass('bg1').addClass('bg2');
160 }
161 post.fadeOut(function() {
162 $(this).remove();
163 });
164 }
165 });
166
167 // This callback removes the approve / disapprove div or link.
168 phpbb.addAjaxCallback('post_visibility', function(res) {
169 var remove = (res.visible) ? $(this) : $(this).parents('.post');
170 $(remove).css('pointer-events', 'none').fadeOut(function() {
171 $(this).remove();
172 });
173
174 if (res.visible) {
175 // Remove the "Deleted by" message from the post on restoring.
176 remove.parents('.post').find('.post_deleted_msg').css('pointer-events', 'none').fadeOut(function() {
177 $(this).remove();
178 });
179 }
180 });
181
182 // This removes the parent row of the link or form that fired the callback.
183 phpbb.addAjaxCallback('row_delete', function() {
184 $(this).parents('tr').remove();
185 });
186
187 // This handles friend / foe additions removals.
188 phpbb.addAjaxCallback('zebra', function(res) {
189 var zebra;
190
191 if (res.success) {
192 zebra = $('.zebra');
193 zebra.first().html(res.MESSAGE_TEXT);
194 zebra.not(':first').html(' ').prev().html(' ');
195 }
196 });
197
198 /**
199 * This callback updates the poll results after voting.
200 */
201 phpbb.addAjaxCallback('vote_poll', function(res) {
202 if (typeof res.success !== 'undefined') {
203 var poll = $(this).closest('.topic_poll');
204 var panel = poll.find('.panel');
205 var resultsVisible = poll.find('dl:first-child .resultbar').is(':visible');
206 var mostVotes = 0;
207
208 // Set min-height to prevent the page from jumping when the content changes
209 var updatePanelHeight = function (height) {
210 height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height;
211 panel.css('min-height', height);
212 };
213 updatePanelHeight();
214
215 // Remove the View results link
216 if (!resultsVisible) {
217 poll.find('.poll_view_results').hide(500);
218 }
219
220 if (!res.can_vote) {
221 poll.find('.polls, .poll_max_votes, .poll_vote, .poll_option_select').fadeOut(500, function () {
222 poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show();
223 });
224 } else {
225 // If the user can still vote, simply slide down the results
226 poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500);
227 }
228
229 // Get the votes count of the highest poll option
230 poll.find('[data-poll-option-id]').each(function() {
231 var option = $(this);
232 var optionId = option.attr('data-poll-option-id');
233 mostVotes = (res.vote_counts[optionId] >= mostVotes) ? res.vote_counts[optionId] : mostVotes;
234 });
235
236 // Update the total votes count
237 poll.find('.poll_total_vote_cnt').html(res.total_votes);
238
239 // Update each option
240 poll.find('[data-poll-option-id]').each(function() {
241 var $this = $(this);
242 var optionId = $this.attr('data-poll-option-id');
243 var voted = (typeof res.user_votes[optionId] !== 'undefined');
244 var mostVoted = (res.vote_counts[optionId] === mostVotes);
245 var percent = (!res.total_votes) ? 0 : Math.round((res.vote_counts[optionId] / res.total_votes) * 100);
246 var percentRel = (mostVotes === 0) ? 0 : Math.round((res.vote_counts[optionId] / mostVotes) * 100);
247 var altText;
248
249 altText = $this.attr('data-alt-text');
250 if (voted) {
251 $this.attr('title', $.trim(altText));
252 } else {
253 $this.attr('title', '');
254 };
255 $this.toggleClass('voted', voted);
256 $this.toggleClass('most-votes', mostVoted);
257
258 // Update the bars
259 var bar = $this.find('.resultbar div');
260 var barTimeLapse = (res.can_vote) ? 500 : 1500;
261 var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1);
262
263 setTimeout(function () {
264 bar.animate({ width: percentRel + '%' }, 500)
265 .removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5')
266 .addClass(newBarClass)
267 .html(res.vote_counts[optionId]);
268
269 var percentText = percent ? percent + '%' : res.NO_VOTES;
270 $this.find('.poll_option_percent').html(percentText);
271 }, barTimeLapse);
272 });
273
274 if (!res.can_vote) {
275 poll.find('.polls').delay(400).fadeIn(500);
276 }
277
278 // Display "Your vote has been cast." message. Disappears after 5 seconds.
279 var confirmationDelay = (res.can_vote) ? 300 : 900;
280 poll.find('.vote-submitted').delay(confirmationDelay).slideDown(200, function() {
281 if (resultsVisible) {
282 updatePanelHeight();
283 }
284
285 $(this).delay(5000).fadeOut(500, function() {
286 resizePanel(300);
287 });
288 });
289
290 // Remove the gap resulting from removing options
291 setTimeout(function() {
292 resizePanel(500);
293 }, 1500);
294
295 var resizePanel = function (time) {
296 var panelHeight = panel.height();
297 var innerHeight = panel.find('.inner').outerHeight();
298
299 if (panelHeight !== innerHeight) {
300 panel.css({ minHeight: '', height: panelHeight })
301 .animate({ height: innerHeight }, time, function () {
302 panel.css({ minHeight: innerHeight, height: '' });
303 });
304 }
305 };
306 }
307 });
308
309 /**
310 * Show poll results when clicking View results link.
311 */
312 $('.poll_view_results a').click(function(e) {
313 // Do not follow the link
314 e.preventDefault();
315
316 var $poll = $(this).parents('.topic_poll');
317
318 $poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500);
319 $poll.find('.poll_view_results').hide(500);
320 });
321
322 $('[data-ajax]').each(function() {
323 var $this = $(this);
324 var ajax = $this.attr('data-ajax');
325 var filter = $this.attr('data-filter');
326
327 if (ajax !== 'false') {
328 var fn = (ajax !== 'true') ? ajax : null;
329 filter = (filter !== undefined) ? phpbb.getFunctionByName(filter) : null;
330
331 phpbb.ajaxify({
332 selector: this,
333 refresh: $this.attr('data-refresh') !== undefined,
334 filter: filter,
335 callback: fn
336 });
337 }
338 });
339
340 /**
341 * This simply appends #preview to the action of the
342 * QR action when you click the Full Editor & Preview button
343 */
344 $('#qr_full_editor').click(function() {
345 $('#qr_postform').attr('action', function(i, val) {
346 return val + '#preview';
347 });
348 });
349
350
351 /**
352 * Make the display post links to use JS
353 */
354 $('.display_post').click(function(e) {
355 // Do not follow the link
356 e.preventDefault();
357
358 var postId = $(this).attr('data-post-id');
359 $('#post_content' + postId).show();
360 $('#profile' + postId).show();
361 $('#post_hidden' + postId).hide();
362 });
363
364 /**
365 * Display hidden post on post review page
366 */
367 $('.display_post_review').on('click', function(e) {
368 e.preventDefault();
369
370 let $displayPostLink = $(this);
371 $displayPostLink.closest('.post-ignore').removeClass('post-ignore');
372 $displayPostLink.hide();
373 });
374
375 /**
376 * Toggle the member search panel in memberlist.php.
377 *
378 * If user returns to search page after viewing results the search panel is automatically displayed.
379 * In any case the link will toggle the display status of the search panel and link text will be
380 * appropriately changed based on the status of the search panel.
381 */
382 $('#member_search').click(function () {
383 var $memberlistSearch = $('#memberlist_search');
384
385 $memberlistSearch.slideToggle('fast');
386 phpbb.ajaxCallbacks.alt_text.call(this);
387
388 // Focus on the username textbox if it's available and displayed
389 if ($memberlistSearch.is(':visible')) {
390 $('#username').focus();
391 }
392 return false;
393 });
394
395 /**
396 * Automatically resize textarea
397 */
398 $(function() {
399 var $textarea = $('textarea:not(#message-box textarea, .no-auto-resize)');
400 phpbb.resizeTextArea($textarea, { minHeight: 75, maxHeight: 250 });
401 phpbb.resizeTextArea($('textarea', '#message-box'));
402 });
403
404
405 })(jQuery); // Avoid conflicts with other libraries
406