<commit_before>/* Copyright 2013-2014 Extended Mind Technologies Oy
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 'use strict';

/*
* TODO: Loading prompt is not shown when it is initially hidden and then items are added passing the limit:
*        -list has to become inactive and active again
*/
function listPromptDirective($animate, $rootScope, UISessionService, UserSessionService) {
  return {
    restrict: 'A',
    require: '^list',
    scope: {
      promptType: '@listPrompt',
      listInfos: '=listPromptInfos',
      noItemsVisible: '=listPromptHide'
    },
    templateUrl: $rootScope.urlBase + 'app/base/listPrompt.html',
    link: function(scope, element, attrs, listController) {
      var loadingAnimationElementVisible;
      var loadingAnimationElement;
      var animateNoItemsPromptWhenEmpty = false;

      function init() {
        loadingAnimationElementVisible = listController.registerIsNearListBottomCallback(isNearListBottom);

        loadingAnimationElement = element[0].firstElementChild.lastElementChild;
        if (loadingAnimationElement && loadingAnimationElementVisible) {
          // Set loading animation element initially visible.
          loadingAnimationElement.style.display = 'block';
        }
      }

      if (!scope.listInfos.array) {
        // Wait for array.
        var listInfosWatcher = scope.$watch('listInfos', function(newListInfos) {
          if (newListInfos && newListInfos.array) {
            // Array arrived, initialize.
            // NOTE:  Returns zero length when changing feature even though array has items, because filter
            //        has not yet rendered items into DOM.
            //
            //        Register array visible callback into listController to get the correct info, but that
            //        callback is only executed when list has an array with items, so we need to keep
            //        listInfos watcher for lists with an actual zero-length array.
            //
            //        Initially empty lists executes init() here and also in array visible callback
            console.log(1);
            init();
          }
          listInfosWatcher(); // Unbind list infos watcher.
        });
        listController.registerArrayVisibleCallback(arrayVisible);
      } else {
        // Array initially ready.
        console.log(2);
        init();
      }

      /*
      * Array is visible and rendered into DOM, initialize.
      */
      function arrayVisible() {
        console.log(3);
        init();
        listController.unregisterArrayVisibleCallback();
      }

      function listHasItems() {
        if (scope.listInfos && scope.listInfos.array && scope.listInfos.array.length) {
          // List has items. Animate prompt when it becomes visible.
          animateNoItemsPromptWhenEmpty = true;
          return true;
        }<commit_msg>Removed console.log.<commit_after>/* Copyright 2013-2014 Extended Mind Technologies Oy
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
 'use strict';

/*
* TODO: Loading prompt is not shown when it is initially hidden and then items are added passing the limit:
*        -list has to become inactive and active again
*/
function listPromptDirective($animate, $rootScope, UISessionService, UserSessionService) {
  return {
    restrict: 'A',
    require: '^list',
    scope: {
      promptType: '@listPrompt',
      listInfos: '=listPromptInfos',
      noItemsVisible: '=listPromptHide'
    },
    templateUrl: $rootScope.urlBase + 'app/base/listPrompt.html',
    link: function(scope, element, attrs, listController) {
      var loadingAnimationElementVisible;
      var loadingAnimationElement;
      var animateNoItemsPromptWhenEmpty = false;

      function init() {
        loadingAnimationElementVisible = listController.registerIsNearListBottomCallback(isNearListBottom);

        loadingAnimationElement = element[0].firstElementChild.lastElementChild;
        if (loadingAnimationElement && loadingAnimationElementVisible) {
          // Set loading animation element initially visible.
          loadingAnimationElement.style.display = 'block';
        }
      }

      if (!scope.listInfos.array) {
        // Wait for array.
        var listInfosWatcher = scope.$watch('listInfos', function(newListInfos) {
          if (newListInfos && newListInfos.array) {
            // Array arrived, initialize.
            // NOTE:  Returns zero length when changing feature even though array has items, because filter
            //        has not yet rendered items into DOM.
            //
            //        Register array visible callback into listController to get the correct info, but that
            //        callback is only executed when list has an array with items, so we need to keep
            //        listInfos watcher for lists with an actual zero-length array.
            //
            //        Initially empty lists executes init() here and also in array visible callback
            init();
          }
          listInfosWatcher(); // Unbind list infos watcher.
        });
        listController.registerArrayVisibleCallback(arrayVisible);
      } else {
        // Array initially ready.
        init();
      }

      /*
      * Array is visible and rendered into DOM, initialize.
      */
      function arrayVisible() {
        init();
        listController.unregisterArrayVisibleCallback();
      }

      function listHasItems() {
        if (scope.listInfos && scope.listInfos.array && scope.listInfos.array.length) {
          // List has items. Animate prompt when it becomes visible.
          animateNoItemsPromptWhenEmpty = true;
          return true;
        }
{'fraction_non_alphanumeric': 0.0810126582278481, 'fraction_numerical': 0.004318689501116903, 'mean_word_length': 2.483402489626556, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '829763', 'n_tokens_mistral': 1673, 'n_tokens_neox': 1631, 'n_words': 588}