Verzeichnisstruktur phpBB-3.2.0


Veröffentlicht
06.01.2017

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.
Auf den Verzeichnisnamen klicken, dies zeigt nur das Verzeichnis mit Inhalt an

(Beispiel Datei-Icons)

Auf das Icon klicken um den Quellcode anzuzeigen

ajax.js

Zuletzt modifiziert: 09.10.2024, 12:54 - Dateigröße: 11.60 KiB


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');
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.closeDarkenWrapper(3000);
105      }
106  });
107   
108  // This callback will mark a notification read
109  phpbb.addAjaxCallback('notification.mark_read', function(res) {
110      if (typeof res.success !== 'undefined') {
111          var unreadCount = Number($('#notification_list_button strong').html()) - 1;
112          phpbb.markNotifications($(this).parent('li.bg2'), unreadCount);
113      }
114  });
115   
116  /**
117   * Mark notification popup rows as read.
118   *
119   * @param {jQuery} $popup jQuery object(s) to mark read.
120   * @param {int} unreadCount The new unread notifications count.
121   */
122  phpbb.markNotifications = function($popup, unreadCount) {
123      // Remove the unread status.
124      $popup.removeClass('bg2');
125      $popup.find('a.mark_read').remove();
126   
127      // Update the notification link to the real URL.
128      $popup.each(function() {
129          var link = $(this).find('a');
130          link.attr('href', link.attr('data-real-url'));
131      });
132   
133      // Update the unread count.
134      $('strong', '#notification_list_button').html(unreadCount);
135      // Remove the Mark all read link and hide notification count if there are no unread notifications.
136      if (!unreadCount) {
137          $('#mark_all_notifications').remove();
138          $('#notification_list_button > strong').addClass('hidden');
139      }
140   
141      // Update page title
142      var $title = $('title');
143      var originalTitle = $title.text().replace(/(\((\d+)\))/, '');
144      $title.text((unreadCount ? '(' + unreadCount + ')' : '') + originalTitle);
145  };
146   
147  // This callback finds the post from the delete link, and removes it.
148  phpbb.addAjaxCallback('post_delete', function() {
149      var $this = $(this),
150          postId;
151   
152      if ($this.attr('data-refresh') === undefined) {
153          postId = $this[0].href.split('&p=')[1];
154          var post = $this.parents('#p' + postId).css('pointer-events', 'none');
155          if (post.hasClass('bg1') || post.hasClass('bg2')) {
156              var posts1 = post.nextAll('.bg1');
157              post.nextAll('.bg2').removeClass('bg2').addClass('bg1');
158              posts1.removeClass('bg1').addClass('bg2');
159          }
160          post.fadeOut(function() {
161              $(this).remove();
162          });
163      }
164  });
165   
166  // This callback removes the approve / disapprove div or link.
167  phpbb.addAjaxCallback('post_visibility', function(res) {
168      var remove = (res.visible) ? $(this) : $(this).parents('.post');
169      $(remove).css('pointer-events', 'none').fadeOut(function() {
170          $(this).remove();
171      });
172   
173      if (res.visible) {
174          // Remove the "Deleted by" message from the post on restoring.
175          remove.parents('.post').find('.post_deleted_msg').css('pointer-events', 'none').fadeOut(function() {
176              $(this).remove();
177          });
178      }
179  });
180   
181  // This removes the parent row of the link or form that fired the callback.
182  phpbb.addAjaxCallback('row_delete', function() {
183      $(this).parents('tr').remove();
184  });
185   
186  // This handles friend / foe additions removals.
187  phpbb.addAjaxCallback('zebra', function(res) {
188      var zebra;
189   
190      if (res.success) {
191          zebra = $('.zebra');
192          zebra.first().html(res.MESSAGE_TEXT);
193          zebra.not(':first').html(' ').prev().html(' ');
194      }
195  });
196   
197  /**
198   * This callback updates the poll results after voting.
199   */
200  phpbb.addAjaxCallback('vote_poll', function(res) {
201      if (typeof res.success !== 'undefined') {
202          var poll = $('.topic_poll');
203          var panel = poll.find('.panel');
204          var resultsVisible = poll.find('dl:first-child .resultbar').is(':visible');
205          var mostVotes = 0;
206   
207          // Set min-height to prevent the page from jumping when the content changes
208          var updatePanelHeight = function (height) {
209              height = (typeof height === 'undefined') ? panel.find('.inner').outerHeight() : height;
210              panel.css('min-height', height);
211          };
212          updatePanelHeight();
213   
214          // Remove the View results link
215          if (!resultsVisible) {
216              poll.find('.poll_view_results').hide(500);
217          }
218   
219          if (!res.can_vote) {
220              poll.find('.polls, .poll_max_votes, .poll_vote, .poll_option_select').fadeOut(500, function () {
221                  poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show();
222              });
223          } else {
224              // If the user can still vote, simply slide down the results
225              poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500);
226          }
227   
228          // Get the votes count of the highest poll option
229          poll.find('[data-poll-option-id]').each(function() {
230              var option = $(this);
231              var optionId = option.attr('data-poll-option-id');
232              mostVotes = (res.vote_counts[optionId] >= mostVotes) ? res.vote_counts[optionId] : mostVotes;
233          });
234   
235          // Update the total votes count
236          poll.find('.poll_total_vote_cnt').html(res.total_votes);
237   
238          // Update each option
239          poll.find('[data-poll-option-id]').each(function() {
240              var $this = $(this);
241              var optionId = $this.attr('data-poll-option-id');
242              var voted = (typeof res.user_votes[optionId] !== 'undefined');
243              var mostVoted = (res.vote_counts[optionId] === mostVotes);
244              var percent = (!res.total_votes) ? 0 : Math.round((res.vote_counts[optionId] / res.total_votes) * 100);
245              var percentRel = (mostVotes === 0) ? 0 : Math.round((res.vote_counts[optionId] / mostVotes) * 100);
246              var altText;
247   
248              altText = $this.attr('data-alt-text');
249              if (voted) {
250                  $this.attr('title', $.trim(altText));
251              } else {
252                  $this.attr('title', '');
253              };
254              $this.toggleClass('voted', voted);
255              $this.toggleClass('most-votes', mostVoted);
256   
257              // Update the bars
258              var bar = $this.find('.resultbar div');
259              var barTimeLapse = (res.can_vote) ? 500 : 1500;
260              var newBarClass = (percent === 100) ? 'pollbar5' : 'pollbar' + (Math.floor(percent / 20) + 1);
261   
262              setTimeout(function () {
263                  bar.animate({ width: percentRel + '%' }, 500)
264                      .removeClass('pollbar1 pollbar2 pollbar3 pollbar4 pollbar5')
265                      .addClass(newBarClass)
266                      .html(res.vote_counts[optionId]);
267   
268                  var percentText = percent ? percent + '%' : res.NO_VOTES;
269                  $this.find('.poll_option_percent').html(percentText);
270              }, barTimeLapse);
271          });
272   
273          if (!res.can_vote) {
274              poll.find('.polls').delay(400).fadeIn(500);
275          }
276   
277          // Display "Your vote has been cast." message. Disappears after 5 seconds.
278          var confirmationDelay = (res.can_vote) ? 300 : 900;
279          poll.find('.vote-submitted').delay(confirmationDelay).slideDown(200, function() {
280              if (resultsVisible) {
281                  updatePanelHeight();
282              }
283   
284              $(this).delay(5000).fadeOut(500, function() {
285                  resizePanel(300);
286              });
287          });
288   
289          // Remove the gap resulting from removing options
290          setTimeout(function() {
291              resizePanel(500);
292          }, 1500);
293   
294          var resizePanel = function (time) {
295              var panelHeight = panel.height();
296              var innerHeight = panel.find('.inner').outerHeight();
297   
298              if (panelHeight !== innerHeight) {
299                  panel.css({ minHeight: '', height: panelHeight })
300                      .animate({ height: innerHeight }, time, function () {
301                          panel.css({ minHeight: innerHeight, height: '' });
302                      });
303              }
304          };
305      }
306  });
307   
308  /**
309   * Show poll results when clicking View results link.
310   */
311  $('.poll_view_results a').click(function(e) {
312      // Do not follow the link
313      e.preventDefault();
314   
315      var $poll = $(this).parents('.topic_poll');
316   
317      $poll.find('.resultbar, .poll_option_percent, .poll_total_votes').show(500);
318      $poll.find('.poll_view_results').hide(500);
319  });
320   
321  $('[data-ajax]').each(function() {
322      var $this = $(this);
323      var ajax = $this.attr('data-ajax');
324      var filter = $this.attr('data-filter');
325   
326      if (ajax !== 'false') {
327          var fn = (ajax !== 'true') ? ajax : null;
328          filter = (filter !== undefined) ? phpbb.getFunctionByName(filter) : null;
329   
330          phpbb.ajaxify({
331              selector: this,
332              refresh: $this.attr('data-refresh') !== undefined,
333              filter: filter,
334              callback: fn
335          });
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  * Toggle the member search panel in memberlist.php.
366  *
367  * If user returns to search page after viewing results the search panel is automatically displayed.
368  * In any case the link will toggle the display status of the search panel and link text will be
369  * appropriately changed based on the status of the search panel.
370  */
371  $('#member_search').click(function () {
372      var $memberlistSearch = $('#memberlist_search');
373   
374      $memberlistSearch.slideToggle('fast');
375      phpbb.ajaxCallbacks.alt_text.call(this);
376   
377      // Focus on the username textbox if it's available and displayed
378      if ($memberlistSearch.is(':visible')) {
379          $('#username').focus();
380      }
381      return false;
382  });
383   
384  /**
385  * Automatically resize textarea
386  */
387  $(function() {
388      var $textarea = $('textarea:not(#message-box textarea, .no-auto-resize)');
389      phpbb.resizeTextArea($textarea, { minHeight: 75, maxHeight: 250 });
390      phpbb.resizeTextArea($('textarea', '#message-box'));
391  });
392   
393   
394  })(jQuery); // Avoid conflicts with other libraries
395