Show More
@@ -10,13 +10,12 b'' | |||
|
10 | 10 | <div class$="container toast-message-holder [[conditionalClass(isFixed)]]"> |
|
11 | 11 | <template is="dom-repeat" items="[[toasts]]"> |
|
12 | 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 | 16 | <rhodecode-unsafe-html text="[[item.message]]"></rhodecode-unsafe-html> |
|
14 | 17 | </div> |
|
15 | 18 | </template> |
|
16 | ||
|
17 | <div class="toast-close"> | |
|
18 | <button on-tap="dismissNotifications" class="btn btn-default">[[_gettext('Close')]]</button> | |
|
19 | </div> | |
|
20 | 19 | </div> |
|
21 | 20 | </template> |
|
22 | 21 | </template> |
@@ -74,6 +74,12 b' Polymer({' | |||
|
74 | 74 | _changedToasts: function(newValue, oldValue){ |
|
75 | 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 | 83 | dismissNotifications: function(){ |
|
78 | 84 | $.Topic('/favicon/update').publish({count: 0}); |
|
79 | 85 | this.splice('toasts', 0); |
@@ -5,11 +5,10 b'' | |||
|
5 | 5 | margin: 10px 0; |
|
6 | 6 | } |
|
7 | 7 | |
|
8 | .toast-close{ | |
|
9 | text-align: right; | |
|
10 | .btn { | |
|
11 | margin: 0; | |
|
12 | } | |
|
8 | .toast-close { | |
|
9 | margin: 0; | |
|
10 | float: right; | |
|
11 | cursor: pointer; | |
|
13 | 12 | } |
|
14 | 13 | |
|
15 | 14 | .toast-message-holder{ |
@@ -80,9 +80,33 b'' | |||
|
80 | 80 | ctrlr.testNotifications = function(event){ |
|
81 | 81 | var levels = ['info', 'error', 'warning', 'success']; |
|
82 | 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 | 107 | var payload = { |
|
84 | 108 | message: { |
|
85 |
message: |
|
|
109 | message: randomMessage + " " + new Date(), | |
|
86 | 110 | level: level, |
|
87 | 111 | force: true |
|
88 | 112 | } |
General Comments 0
You need to be logged in to leave comments.
Login now