rhodecode-toast.js
40 lines
| 1.1 KiB
| application/javascript
|
JavascriptLexer
r703 | Polymer({ | |||
is: 'rhodecode-toast', | ||||
properties: { | ||||
toasts: { | ||||
type: Array, | ||||
value: function(){ | ||||
return [] | ||||
} | ||||
} | ||||
}, | ||||
observers: [ | ||||
'_changedToasts(toasts.splices)' | ||||
], | ||||
_changedToasts: function(newValue, oldValue){ | ||||
this.$['p-toast'].notifyResize(); | ||||
r882 | $.Topic('/favicon/update').publish({count: this.toasts.length}); | |||
r703 | }, | |||
dismissNotifications: function(){ | ||||
this.$['p-toast'].close(); | ||||
r882 | $.Topic('/favicon/update').publish({count: 0}); | |||
r778 | }, | |||
handleClosed: function(){ | ||||
r703 | this.splice('toasts', 0); | |||
}, | ||||
open: function(){ | ||||
this.$['p-toast'].open(); | ||||
}, | ||||
r787 | handleNotification: function(data){ | |||
if (!templateContext.rhodecode_user.notification_status && !data.message.force) { | ||||
// do not act if notifications are disabled | ||||
return | ||||
} | ||||
this.push('toasts',{ | ||||
level: data.message.level, | ||||
message: data.message.message | ||||
}); | ||||
this.open(); | ||||
}, | ||||
r703 | _gettext: _gettext | |||
}); | ||||