[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/webroot/rsrc/js/application/uiexample/ -> notification-example.js (source)

   1  /**
   2   * @requires phabricator-notification
   3   *           javelin-stratcom
   4   *           javelin-behavior
   5   * @provides javelin-behavior-phabricator-notification-example
   6   */
   7  
   8  JX.behavior('phabricator-notification-example', function() {
   9  
  10    var sequence = 0;
  11  
  12    JX.Stratcom.listen(
  13      'click',
  14      'notification-example',
  15      function(e) {
  16        e.kill();
  17  
  18        var notification = new JX.Notification();
  19        switch (sequence % 4) {
  20          case 0:
  21            var update = function() {
  22              notification.setContent('It is ' + new Date().toString());
  23            };
  24  
  25            update();
  26            setInterval(update, 1000);
  27  
  28            break;
  29          case 1:
  30            notification
  31              .setContent('Permanent alert notification (until clicked).')
  32              .setDuration(0)
  33              .alterClassName('jx-notification-alert', true);
  34            break;
  35          case 2:
  36            notification
  37              .setContent('This notification reacts when you click it.');
  38  
  39            notification.listen(
  40              'activate',
  41              function() {
  42                if (!confirm('Close notification?')) {
  43                  JX.Stratcom.context().kill();
  44                }
  45              });
  46            break;
  47          case 3:
  48            notification
  49              .setDuration(2000)
  50              .setContent('This notification will close after 2 seconds ' +
  51                          'unless you keep clicking it!');
  52  
  53            notification.listen(
  54              'activate',
  55              function() {
  56                notification.setDuration(2000);
  57                JX.Stratcom.context().kill();
  58              });
  59            break;
  60        }
  61  
  62        notification.show();
  63        sequence++;
  64      });
  65  
  66  });


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