'use strict';

define(["app"], function(app) {

  app.directive('movableEtc', ['$timeout', '$filter', function($timeout, $filter) {

    var retreiveMessage = $filter('i18n')('RETRIEVING_MESSAGES');
    var scrollToShowMessage = $filter('i18n')('SCROLL_TO_SHOW_MSG');

    return {
      link : function(scope, element, attrs) {
        var dot = '';

        function addDot(element) {
          if(dot !== undefined) {
            if(dot.length < 3) {
              dot += '.';
            } else {
              dot = ".";
            }
            element[0].innerText = retreiveMessage + dot;
            $timeout(function() {
              addDot(element);
            }, 500);
          }
        };
        addDot(element);

        var unwatch = scope.$watch(attrs["movableEtc"]+".messages", function(newVal, oldVal) {
          console.log("messages", newVal, newVal);
          if(newVal) {
            console.log('Stop recursion');
            dot = undefined;//stop dot recursion
            $timeout(function() {
              element[0].innerText = scrollToShowMessage;
            }, 500);
            unwatch();
          } else {
            element[0].innerText = retreiveMessage;
          }
        });
        element.bind("$destroy", function() {
          unwatch();
        });
      }
    };

  }]);
});
@@ -835,114 +835,20 @@
     
-console.log(%22messages%22, newVal, newVal);%0A          if(newVal) %7B%0A            console.log('Stop recursion');
+if(newVal) %7B
 %0A   

remove logs