##// END OF EJS Templates
js: use ES6 classes for polymer 2.x
js: use ES6 classes for polymer 2.x

File last commit:

r3172:d37fc984 default
r3172:d37fc984 default
Show More
rhodecode-toast.html
233 lines | 7.4 KiB | text/html | HtmlLexer
components: reorganize build pipeline to have nice separation of html/js/css
r703 <link rel="import" href="../../../../../../bower_components/paper-button/paper-button.html">
js: use ES6 classes for polymer 2.x
r3172 <link rel="import"
href="../../../../../../bower_components/iron-a11y-keys-behavior/iron-a11y-keys-behavior.html">
components: reorganize build pipeline to have nice separation of html/js/css
r703 <link rel="import" href="../rhodecode-unsafe-html/rhodecode-unsafe-html.html">
<dom-module id="rhodecode-toast">
<template>
frontend: use webpack instead of vulcanize
r3171 <style include="shared-styles">
/* inset border for buttons - does not work in ie */
/* rounded borders */
/* rounded borders - bottom only */
/* rounded borders - top only */
/* text shadow */
/* centers text in a circle - input diameter of circle and color */
/* pill version of the circle */
.absolute-center {
margin: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
js: use ES6 classes for polymer 2.x
r3172
frontend: use webpack instead of vulcanize
r3171 .top-left-rounded-corner {
-webkit-border-top-left-radius: 2px;
-khtml-border-radius-topleft: 2px;
border-top-left-radius: 2px;
}
js: use ES6 classes for polymer 2.x
r3172
frontend: use webpack instead of vulcanize
r3171 .top-right-rounded-corner {
-webkit-border-top-right-radius: 2px;
-khtml-border-radius-topright: 2px;
border-top-right-radius: 2px;
}
js: use ES6 classes for polymer 2.x
r3172
frontend: use webpack instead of vulcanize
r3171 .bottom-left-rounded-corner {
-webkit-border-bottom-left-radius: 2px;
-khtml-border-radius-bottomleft: 2px;
border-bottom-left-radius: 2px;
}
js: use ES6 classes for polymer 2.x
r3172
frontend: use webpack instead of vulcanize
r3171 .bottom-right-rounded-corner {
-webkit-border-bottom-right-radius: 2px;
-khtml-border-radius-bottomright: 2px;
border-bottom-right-radius: 2px;
}
js: use ES6 classes for polymer 2.x
r3172
frontend: use webpack instead of vulcanize
r3171 .top-left-rounded-corner-mid {
-webkit-border-top-left-radius: 2px;
-khtml-border-radius-topleft: 2px;
border-top-left-radius: 2px;
}
js: use ES6 classes for polymer 2.x
r3172
frontend: use webpack instead of vulcanize
r3171 .top-right-rounded-corner-mid {
-webkit-border-top-right-radius: 2px;
-khtml-border-radius-topright: 2px;
border-top-right-radius: 2px;
}
js: use ES6 classes for polymer 2.x
r3172
frontend: use webpack instead of vulcanize
r3171 .bottom-left-rounded-corner-mid {
-webkit-border-bottom-left-radius: 2px;
-khtml-border-radius-bottomleft: 2px;
border-bottom-left-radius: 2px;
}
js: use ES6 classes for polymer 2.x
r3172
frontend: use webpack instead of vulcanize
r3171 .bottom-right-rounded-corner-mid {
-webkit-border-bottom-right-radius: 2px;
-khtml-border-radius-bottomright: 2px;
border-bottom-right-radius: 2px;
}
js: use ES6 classes for polymer 2.x
r3172
frontend: use webpack instead of vulcanize
r3171 .alert {
margin: 10px 0;
}
js: use ES6 classes for polymer 2.x
r3172
frontend: use webpack instead of vulcanize
r3171 .toast-close {
margin: 0;
float: right;
cursor: pointer;
}
js: use ES6 classes for polymer 2.x
r3172
frontend: use webpack instead of vulcanize
r3171 .toast-message-holder {
background: rgba(255, 255, 255, 0.25);
}
js: use ES6 classes for polymer 2.x
r3172
frontend: use webpack instead of vulcanize
r3171 .toast-message-holder.fixed {
position: fixed;
padding: 10px 0;
margin-left: 10px;
margin-right: 10px;
top: 0;
left: 0;
right: 0;
z-index: 100;
}
</style>
notifications: different approach with fixed/standard container
r1483 <template is="dom-if" if="[[hasToasts]]">
rhodecode-toast: css improvements.
r1484 <div class$="container toast-message-holder [[conditionalClass(isFixed)]]">
notifications: different approach with fixed/standard container
r1483 <template is="dom-repeat" items="[[toasts]]">
<div class$="alert alert-[[item.level]]">
js: use ES6 classes for polymer 2.x
r3172 <div on-click="dismissNotification" class="toast-close" index-pos="[[index]]">
rhodecode-toasts: allow removing single elements from toast queue.
r1513 <span>[[_gettext('Close')]]</span>
</div>
notifications: different approach with fixed/standard container
r1483 <rhodecode-unsafe-html text="[[item.message]]"></rhodecode-unsafe-html>
components: reorganize build pipeline to have nice separation of html/js/css
r703 </div>
</template>
</div>
notifications: different approach with fixed/standard container
r1483 </template>
components: reorganize build pipeline to have nice separation of html/js/css
r703 </template>
polymer: prepare for 3.x migration
r3149 <script>
js: use ES6 classes for polymer 2.x
r3172
class RhodecodeToast extends Polymer.mixinBehaviors([Polymer.IronA11yKeysBehavior], Polymer.Element) {
static get is() {
return 'rhodecode-toast';
}
static get properties() {
return {
toasts: {
type: Array,
value() {
return []
}
},
isFixed: {
type: Boolean,
value: false
},
hasToasts: {
type: Boolean,
computed: '_computeHasToasts(toasts.*)'
},
keyEventTarget: {
type: Object,
value() {
return document.body;
}
polymer: prepare for 3.x migration
r3149 }
}
js: use ES6 classes for polymer 2.x
r3172 }
get keyBindings() {
return {
'esc:keyup': '_hideOnEsc'
}
}
polymer: prepare for 3.x migration
r3149
js: use ES6 classes for polymer 2.x
r3172 static get observers() {
return [
'_changedToasts(toasts.splices)'
]
}
polymer: prepare for 3.x migration
r3149
js: use ES6 classes for polymer 2.x
r3172 _hideOnEsc(event) {
polymer: prepare for 3.x migration
r3149 return this.dismissNotifications();
js: use ES6 classes for polymer 2.x
r3172 }
polymer: prepare for 3.x migration
r3149
js: use ES6 classes for polymer 2.x
r3172 _computeHasToasts() {
polymer: prepare for 3.x migration
r3149 return this.toasts.length > 0;
js: use ES6 classes for polymer 2.x
r3172 }
polymer: prepare for 3.x migration
r3149
js: use ES6 classes for polymer 2.x
r3172 _debouncedCalc() {
polymer: prepare for 3.x migration
r3149 // calculate once in a while
this.debounce('debouncedCalc', this.toastInWindow, 25);
js: use ES6 classes for polymer 2.x
r3172 }
polymer: prepare for 3.x migration
r3149
js: use ES6 classes for polymer 2.x
r3172 conditionalClass() {
return this.isFixed ? 'fixed' : '';
}
polymer: prepare for 3.x migration
r3149
js: use ES6 classes for polymer 2.x
r3172 toastInWindow() {
if (!this._headerNode) {
polymer: prepare for 3.x migration
r3149 return true
}
var headerHeight = this._headerNode.offsetHeight;
var scrollPosition = window.scrollY;
js: use ES6 classes for polymer 2.x
r3172 if (this.isFixed) {
polymer: prepare for 3.x migration
r3149 this.isFixed = 1 <= scrollPosition;
}
js: use ES6 classes for polymer 2.x
r3172 else {
polymer: prepare for 3.x migration
r3149 this.isFixed = headerHeight <= scrollPosition;
}
js: use ES6 classes for polymer 2.x
r3172 }
polymer: prepare for 3.x migration
r3149
js: use ES6 classes for polymer 2.x
r3172 connectedCallback() {
super.connectedCallback();
polymer: prepare for 3.x migration
r3149 this._headerNode = document.querySelector('.header', document);
js: use ES6 classes for polymer 2.x
r3172 this.listen(window, 'scroll', '_debouncedCalc');
this.listen(window, 'resize', '_debouncedCalc');
polymer: prepare for 3.x migration
r3149 this._debouncedCalc();
js: use ES6 classes for polymer 2.x
r3172 }
_changedToasts(newValue, oldValue) {
polymer: prepare for 3.x migration
r3149 $.Topic('/favicon/update').publish({count: this.toasts.length});
js: use ES6 classes for polymer 2.x
r3172 }
dismissNotification(e) {
$.Topic('/favicon/update').publish({count: this.toasts.length - 1});
polymer: prepare for 3.x migration
r3149 var idx = e.target.parentNode.indexPos
this.splice('toasts', idx, 1);
js: use ES6 classes for polymer 2.x
r3172 }
dismissNotifications() {
polymer: prepare for 3.x migration
r3149 $.Topic('/favicon/update').publish({count: 0});
this.splice('toasts', 0);
js: use ES6 classes for polymer 2.x
r3172 }
handleNotification(data) {
polymer: prepare for 3.x migration
r3149 if (!templateContext.rhodecode_user.notification_status && !data.message.force) {
// do not act if notifications are disabled
return
}
js: use ES6 classes for polymer 2.x
r3172 this.push('toasts', {
polymer: prepare for 3.x migration
r3149 level: data.message.level,
message: data.message.message
});
js: use ES6 classes for polymer 2.x
r3172 }
_gettext(x){
return _gettext(x)
}
}
customElements.define(RhodecodeToast.is, RhodecodeToast);
polymer: prepare for 3.x migration
r3149
</script>
components: reorganize build pipeline to have nice separation of html/js/css
r703 </dom-module>