##// END OF EJS Templates
dependencies: bumped rhodecode-tools to 1.0.0 release
dependencies: bumped rhodecode-tools to 1.0.0 release

File last commit:

r1513:940ac693 default
r3097:7291c47c default
Show More
rhodecode-toast.js
98 lines | 2.5 KiB | application/javascript | JavascriptLexer
components: reorganize build pipeline to have nice separation of html/js/css
r703 Polymer({
is: 'rhodecode-toast',
properties: {
toasts: {
type: Array,
value: function(){
return []
}
notifications: different approach with fixed/standard container
r1483 },
isFixed: {
type: Boolean,
value: false
},
hasToasts: {
type: Boolean,
computed: '_computeHasToasts(toasts.*)'
toasts: hide messages on escape.
r1486 },
keyEventTarget: {
type: Object,
value: function() {
return document.body;
}
components: reorganize build pipeline to have nice separation of html/js/css
r703 }
},
toasts: hide messages on escape.
r1486 behaviors: [
Polymer.IronA11yKeysBehavior
],
components: reorganize build pipeline to have nice separation of html/js/css
r703 observers: [
'_changedToasts(toasts.splices)'
],
notifications: different approach with fixed/standard container
r1483
toasts: hide messages on escape.
r1486 keyBindings: {
'esc:keyup': '_hideOnEsc'
},
_hideOnEsc: function (event) {
return this.dismissNotifications();
},
notifications: different approach with fixed/standard container
r1483 _computeHasToasts: function(){
return this.toasts.length > 0;
},
_debouncedCalc: function(){
// calculate once in a while
this.debounce('debouncedCalc', this.toastInWindow, 25);
},
conditionalClass: function(){
return this.isFixed ? 'fixed': '';
},
toastInWindow: function() {
if (!this._headerNode){
return true
}
var headerHeight = this._headerNode.offsetHeight;
var scrollPosition = window.scrollY;
if (this.isFixed){
this.isFixed = 1 <= scrollPosition;
}
else{
this.isFixed = headerHeight <= scrollPosition;
}
},
attached: function(){
this._headerNode = document.querySelector('.header', document);
this.listen(window,'scroll', '_debouncedCalc');
this.listen(window,'resize', '_debouncedCalc');
this._debouncedCalc();
},
components: reorganize build pipeline to have nice separation of html/js/css
r703 _changedToasts: function(newValue, oldValue){
favicon: added favicon notifications
r882 $.Topic('/favicon/update').publish({count: this.toasts.length});
components: reorganize build pipeline to have nice separation of html/js/css
r703 },
rhodecode-toasts: allow removing single elements from toast queue.
r1513 dismissNotification: function(e) {
$.Topic('/favicon/update').publish({count: this.toasts.length-1});
var idx = e.target.parentNode.indexPos
this.splice('toasts', idx, 1);
},
components: reorganize build pipeline to have nice separation of html/js/css
r703 dismissNotifications: function(){
favicon: added favicon notifications
r882 $.Topic('/favicon/update').publish({count: 0});
components: reorganize build pipeline to have nice separation of html/js/css
r703 this.splice('toasts', 0);
},
frontend: introduce rhodecode-app for more complex cross element wiring
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
});
},
components: reorganize build pipeline to have nice separation of html/js/css
r703 _gettext: _gettext
});