[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/webroot/rsrc/js/application/differential/ -> behavior-show-all-comments.js (source)

   1  /**
   2   * @provides javelin-behavior-phabricator-show-all-transactions
   3   * @requires javelin-behavior
   4   *           javelin-stratcom
   5   *           javelin-dom
   6   */
   7  
   8  /**
   9   * Automatically show older transactions if the user follows an anchor to a
  10   * transaction which is hidden by the "N older changes are hidden." shield.
  11   */
  12  JX.behavior('phabricator-show-all-transactions', function(config) {
  13  
  14    var revealed = false;
  15  
  16    function get_hash() {
  17      return window.location.hash.replace(/^#/, '');
  18    }
  19  
  20    function hash_is_hidden() {
  21      var hash = get_hash();
  22      for (var ii = 0; ii < config.anchors.length; ii++) {
  23        if (config.anchors[ii] == hash) {
  24          return true;
  25        }
  26      }
  27      return false;
  28    }
  29  
  30    function reveal() {
  31      if (revealed) {
  32        return false;
  33      }
  34  
  35      JX.DOM.hide(JX.$(config.hideID));
  36      JX.DOM.show(JX.$(config.showID));
  37      revealed = true;
  38  
  39      return true;
  40    }
  41  
  42    function check_hash() {
  43      if (hash_is_hidden()) {
  44        if (reveal()) {
  45          try {
  46            var target = JX.$(get_hash());
  47            JX.DOM.scrollTo(target);
  48          } catch (ignored) {
  49            // We did our best.
  50          }
  51        }
  52      }
  53    }
  54  
  55    JX.DOM.listen(
  56      JX.$(config.linkID),
  57      'click',
  58      null,
  59      function (e) {
  60        e.kill();
  61        reveal();
  62      });
  63  
  64    JX.Stratcom.listen('hashchange', null, check_hash);
  65    check_hash();
  66  });


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1