The peers information was only request after login. But as the
information can change during the login time, it is better to request it
on every menu selection.
Also fix some typos: drowdown to dropdown.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
---
ui/css/theme-default/topbar.css | 4 ++--
ui/js/src/kimchi.main.js | 49 +++++++++++++++++++++++++++++------------
ui/pages/kimchi-ui.html.tmpl | 6 ++---
3 files changed, 40 insertions(+), 19 deletions(-)
diff --git a/ui/css/theme-default/topbar.css b/ui/css/theme-default/topbar.css
index 127c56a..d21fc50 100644
--- a/ui/css/theme-default/topbar.css
+++ b/ui/css/theme-default/topbar.css
@@ -194,7 +194,7 @@ a#btn-logout:hover {
width: 0;
}
-.peers .drowdown {
+.peers .dropdown {
top: 45px;
right: 110px;
color: black;
@@ -204,7 +204,7 @@ a#btn-logout:hover {
width: inherit;
}
-.peers .drowdown a {
+.peers .dropdown a {
display: block;
padding: 10px;
}
diff --git a/ui/js/src/kimchi.main.js b/ui/js/src/kimchi.main.js
index a3305e9..a8ae42a 100644
--- a/ui/js/src/kimchi.main.js
+++ b/ui/js/src/kimchi.main.js
@@ -20,24 +20,13 @@ kimchi.tabMode = {};
kimchi.capabilities = undefined;
kimchi.getCapabilities(function(result) {
kimchi.capabilities = result;
- kimchi.setupPeers();
+
+ if(kimchi.capabilities.federation=="on")
+ $('#peers').removeClass('hide-content');
}, function() {
kimchi.capabilities = {};
});
-kimchi.setupPeers = function(){
- if(kimchi.capabilities.federation=="on"){
- $('#peers').removeClass('hide-content');
- kimchi.getPeers(function(data){
- var hints = $('p', $('.drowdown', '#peers'));
- data.length==0 ? hints.toggleClass('hide-content'):
hints.addClass('hide-content');
- for(var i=0; i<data.length; i++){
- $('.drowdown', '#peers').append("<a
href='"+data[i]+"'
target='_blank'>"+data[i]+"</a>");
- }
- });
- }
-};
-
kimchi.main = function() {
kimchi.isLoggingOut = false;
kimchi.popable();
@@ -220,7 +209,11 @@ kimchi.main = function() {
* 2) hashchange event
* 3) Tab list click event
* 4) Log-out button click event
+ * 5) About button click event
+ * 6) Help button click event
+ * 7) Peers button click event
*/
+ var searchingPeers = false;
var initListeners = function() {
kimchi.topic('languageChanged').subscribe(onLanguageChanged);
kimchi.topic('redirect').subscribe(onKimchiRedirect);
@@ -260,12 +253,40 @@ kimchi.main = function() {
kimchi.message.error(err.responseJSON.reason);
});
});
+
+ // Set handler for about button
$('#btn-about').on('click', function(event) {
kimchi.window.open({"content": $('#about-tmpl').html()});
event.preventDefault();
});
+ // Set handler for help button
$('#btn-help').on('click', kimchi.getHelp);
+
+ // Set handler to peers drop down
+ $('#peers').on('click', function() {
+
+ // Check if any request is in progress
+ if ($('.popover', '#peers').is(':visible') ||
searchingPeers == true)
+ return
+
+ $('#search-peers').show();
+ $('#no-peers').addClass('hide-content');
+ $('a', '#peers').remove();
+
+ searchingPeers = true;
+
+ kimchi.getPeers(function(data){
+ $('#search-peers').hide();
+ if (data.length == 0)
+ $('#no-peers').removeClass('hide-content');
+
+ for(var i=0; i<data.length; i++){
+ $('.dropdown', '#peers').append("<a
href='"+data[i]+"'
target='_blank'>"+data[i]+"</a>");
+ }
+ searchingPeers = false;
+ });
+ });
};
var initUI = function() {
diff --git a/ui/pages/kimchi-ui.html.tmpl b/ui/pages/kimchi-ui.html.tmpl
index 867ee36..aee3c4a 100644
--- a/ui/pages/kimchi-ui.html.tmpl
+++ b/ui/pages/kimchi-ui.html.tmpl
@@ -74,9 +74,9 @@
<div id="peers" class="peers hide-content
popable">
<span>$_("Peers")</span>
<span class="arrow"></span>
- <div class="drowdown popover right-side">
- <p>$_("Searching")...</p>
- <p class="hide-content">$_("No peers
found.")</p>
+ <div class="dropdown popover right-side">
+ <p
id="search-peers">$_("Searching")...</p>
+ <p id="no-peers"
class="hide-content">$_("No peers found.")</p>
</div>
</div>
</li>
--
1.9.3
Show replies by date
Reviewed-by: Crístian Viana <vianac(a)linux.vnet.ibm.com>
On 24-09-2014 17:35, Aline Manera wrote:
The peers information was only request after login. But as the
information can change during the login time, it is better to request it
on every menu selection.
Also fix some typos: drowdown to dropdown.
Signed-off-by: Aline Manera <alinefm(a)linux.vnet.ibm.com>
Applied. Thanks.
Regards,
Aline Manera