Path: blob/master/webroot/rsrc/js/application/uiexample/notification-example.js
12242 views
/**1* @requires phabricator-notification2* javelin-stratcom3* javelin-behavior4* @provides javelin-behavior-phabricator-notification-example5*/67JX.behavior('phabricator-notification-example', function() {89var sequence = 0;1011JX.Stratcom.listen(12'click',13'notification-example',14function(e) {15e.kill();1617var notification = new JX.Notification();18switch (sequence % 4) {19case 0:20var update = function() {21notification.setContent('It is ' + new Date().toString());22};2324update();25setInterval(update, 1000);2627break;28case 1:29notification30.setContent('Permanent alert notification (until clicked).')31.setDuration(0)32.alterClassName('jx-notification-alert', true);33break;34case 2:35notification36.setContent('This notification reacts when you click it.');3738notification.listen(39'activate',40function() {41if (!window.confirm('Close notification?')) {42JX.Stratcom.context().kill();43}44});45break;46case 3:47notification48.setDuration(2000)49.setContent('This notification will close after 2 seconds ' +50'unless you keep clicking it!');5152notification.listen(53'activate',54function() {55notification.setDuration(2000);56JX.Stratcom.context().kill();57});58break;59}6061notification.show();62sequence++;63});6465});666768