2012-06-14 00:00:24 +02:00
|
|
|
/**
|
|
|
|
* @requires phabricator-notification
|
|
|
|
* javelin-stratcom
|
|
|
|
* javelin-behavior
|
|
|
|
* @provides javelin-behavior-phabricator-notification-example
|
|
|
|
*/
|
|
|
|
|
2014-06-23 19:27:47 +02:00
|
|
|
JX.behavior('phabricator-notification-example', function() {
|
2012-10-09 00:22:29 +02:00
|
|
|
|
|
|
|
var sequence = 0;
|
|
|
|
|
2012-06-14 00:00:24 +02:00
|
|
|
JX.Stratcom.listen(
|
|
|
|
'click',
|
|
|
|
'notification-example',
|
|
|
|
function(e) {
|
|
|
|
e.kill();
|
|
|
|
|
2012-06-17 20:35:36 +02:00
|
|
|
var notification = new JX.Notification();
|
2012-10-09 00:22:29 +02:00
|
|
|
switch (sequence % 4) {
|
|
|
|
case 0:
|
|
|
|
var update = function() {
|
|
|
|
notification.setContent('It is ' + new Date().toString());
|
|
|
|
};
|
|
|
|
|
|
|
|
update();
|
|
|
|
setInterval(update, 1000);
|
|
|
|
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
notification
|
|
|
|
.setContent('Permanent alert notification (until clicked).')
|
|
|
|
.setDuration(0)
|
|
|
|
.alterClassName('jx-notification-alert', true);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
notification
|
|
|
|
.setContent('This notification reacts when you click it.');
|
|
|
|
|
|
|
|
notification.listen(
|
|
|
|
'activate',
|
|
|
|
function() {
|
2014-06-23 19:35:39 +02:00
|
|
|
if (!confirm('Close notification?')) {
|
2012-10-09 00:22:29 +02:00
|
|
|
JX.Stratcom.context().kill();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
notification
|
|
|
|
.setDuration(2000)
|
|
|
|
.setContent('This notification will close after 2 seconds ' +
|
|
|
|
'unless you keep clicking it!');
|
|
|
|
|
|
|
|
notification.listen(
|
|
|
|
'activate',
|
|
|
|
function() {
|
|
|
|
notification.setDuration(2000);
|
|
|
|
JX.Stratcom.context().kill();
|
|
|
|
});
|
|
|
|
break;
|
2012-06-17 20:35:36 +02:00
|
|
|
}
|
2012-10-09 00:22:29 +02:00
|
|
|
|
|
|
|
notification.show();
|
|
|
|
sequence++;
|
2012-06-14 00:00:24 +02:00
|
|
|
});
|
|
|
|
|
|
|
|
});
|