From 71e8909365709a5c847a8e0a2f5b7fa6a722028e Mon Sep 17 00:00:00 2001
From: drigato <denise.rigato@sourcefabric.org>
Date: Tue, 14 Jul 2015 10:08:56 -0400
Subject: [PATCH] SAAS-940: Provide usability hints to user

Fixed bug where hints were not showing up sometimes
---
 airtime_mvc/application/layouts/scripts/layout.phtml   |  1 -
 airtime_mvc/public/js/airtime/common/common.js         | 10 +++++++---
 .../js/airtime/schedule/full-calendar-functions.js     |  1 +
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/airtime_mvc/application/layouts/scripts/layout.phtml b/airtime_mvc/application/layouts/scripts/layout.phtml
index 51c1e8624..154f658f4 100644
--- a/airtime_mvc/application/layouts/scripts/layout.phtml
+++ b/airtime_mvc/application/layouts/scripts/layout.phtml
@@ -73,7 +73,6 @@ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
 <div class="wrapper" id="content">
     <?php
     $hint = Application_Common_UsabilityHints::getUsabilityHint();
-    Logging::info($hint);
     if ($hint != "") { ?>
         <div class="usability_hint"><?php echo $hint; ?></div>
     <?php
diff --git a/airtime_mvc/public/js/airtime/common/common.js b/airtime_mvc/public/js/airtime/common/common.js
index 53a9ff3a1..e03b0e87f 100644
--- a/airtime_mvc/public/js/airtime/common/common.js
+++ b/airtime_mvc/public/js/airtime/common/common.js
@@ -165,20 +165,24 @@ function removeSuccessMsg() {
 function getUsabilityHint() {
     var pathname = window.location.pathname;
     $.getJSON("/api/get-usability-hint", {"format": "json", "userPath": pathname}, function(json) {
-        console.log(json);
         var $hint_div = $('.usability_hint');
         var current_hint = $hint_div.html();
         if (json === "") {
+            // there are no more hints to display to the user
             $hint_div.hide();
         } else if (current_hint !== json) {
-            console.log($hint_div);
+            // we only change the message if it is new
             if ($hint_div.is(":hidden")) {
-                console.log("hidden");
                 $hint_div.show();
             }
             $hint_div.slideUp("slow");
             $hint_div.html(json);
             $hint_div.slideDown("slow");
+        } else {
+            // hint is the same before we hid it so we just need to show it
+            if ($hint_div.is(":hidden")) {
+                $hint_div.show();
+            }
         }
     });
 }
diff --git a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js
index f51b7d8fe..56d3df509 100644
--- a/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js
+++ b/airtime_mvc/public/js/airtime/schedule/full-calendar-functions.js
@@ -354,6 +354,7 @@ function getFullCalendarEvents(start, end, callback) {
         var d = new Date();
             $.post(url, {format: "json", start: start_date, end: end_date, cachep: d.getTime()}, function(json){
                 callback(json.events);
+                getUsabilityHint();
             });
     }
 }