Verzeichnisstruktur phpBB-3.1.0


Veröffentlicht
27.10.2014

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