##// END OF EJS Templates
rhodecode-toasts: allow removing single elements from toast queue.
marcink -
r1513:940ac693 default
parent child Browse files
Show More
@@ -10,13 +10,12 b''
10 <div class$="container toast-message-holder [[conditionalClass(isFixed)]]">
10 <div class$="container toast-message-holder [[conditionalClass(isFixed)]]">
11 <template is="dom-repeat" items="[[toasts]]">
11 <template is="dom-repeat" items="[[toasts]]">
12 <div class$="alert alert-[[item.level]]">
12 <div class$="alert alert-[[item.level]]">
13 <div on-tap="dismissNotification" class="toast-close" index-pos="[[index]]">
14 <span>[[_gettext('Close')]]</span>
15 </div>
13 <rhodecode-unsafe-html text="[[item.message]]"></rhodecode-unsafe-html>
16 <rhodecode-unsafe-html text="[[item.message]]"></rhodecode-unsafe-html>
14 </div>
17 </div>
15 </template>
18 </template>
16
17 <div class="toast-close">
18 <button on-tap="dismissNotifications" class="btn btn-default">[[_gettext('Close')]]</button>
19 </div>
20 </div>
19 </div>
21 </template>
20 </template>
22 </template>
21 </template>
@@ -74,6 +74,12 b' Polymer({'
74 _changedToasts: function(newValue, oldValue){
74 _changedToasts: function(newValue, oldValue){
75 $.Topic('/favicon/update').publish({count: this.toasts.length});
75 $.Topic('/favicon/update').publish({count: this.toasts.length});
76 },
76 },
77 dismissNotification: function(e) {
78 $.Topic('/favicon/update').publish({count: this.toasts.length-1});
79 var idx = e.target.parentNode.indexPos
80 this.splice('toasts', idx, 1);
81
82 },
77 dismissNotifications: function(){
83 dismissNotifications: function(){
78 $.Topic('/favicon/update').publish({count: 0});
84 $.Topic('/favicon/update').publish({count: 0});
79 this.splice('toasts', 0);
85 this.splice('toasts', 0);
@@ -5,11 +5,10 b''
5 margin: 10px 0;
5 margin: 10px 0;
6 }
6 }
7
7
8 .toast-close{
8 .toast-close {
9 text-align: right;
9 margin: 0;
10 .btn {
10 float: right;
11 margin: 0;
11 cursor: pointer;
12 }
13 }
12 }
14
13
15 .toast-message-holder{
14 .toast-message-holder{
@@ -80,9 +80,33 b''
80 ctrlr.testNotifications = function(event){
80 ctrlr.testNotifications = function(event){
81 var levels = ['info', 'error', 'warning', 'success'];
81 var levels = ['info', 'error', 'warning', 'success'];
82 var level = levels[Math.floor(Math.random()*levels.length)];
82 var level = levels[Math.floor(Math.random()*levels.length)];
83 function getRandomArbitrary(min, max) {
84 return parseInt(Math.random() * (max - min) + min);
85 }
86 function shuffle(a) {
87 var j, x, i;
88 for (i = a.length; i; i--) {
89 j = Math.floor(Math.random() * i);
90 x = a[i - 1];
91 a[i - 1] = a[j];
92 a[j] = x;
93 }
94 }
95 var wordDb = [
96 "Leela,", "Bender,", "we are", "going", "grave", "robbing.",
97 "Oh,", "I", "think", "we", "should", "just", "stay", "friends.",
98 "got", "to", "find", "a", "way", "to", "escape", "the", "horrible",
99 "ravages", "of", "youth.", "Suddenly,", "going", "to",
100 "the", "bathroom", "like", "clockwork,", "every", "three",
101 "hours.", "And", "those", "jerks", "at", "Social", "Security",
102 "stopped", "sending", "me", "checks.", "Now", "have", "to", "pay"
103 ];
104 shuffle(wordDb);
105 wordDb = wordDb.slice(0, getRandomArbitrary(3, wordDb.length));
106 var randomMessage = wordDb.join(" ");
83 var payload = {
107 var payload = {
84 message: {
108 message: {
85 message: 'This is a test notification. ' + new Date(),
109 message: randomMessage + " " + new Date(),
86 level: level,
110 level: level,
87 force: true
111 force: true
88 }
112 }
General Comments 0
You need to be logged in to leave comments. Login now