{"size": 1563, "ext": "js", "max_stars_repo_path": "src/PatentSpoiler/Scripts/custom/item/itemHistoryDirective.js", "max_stars_repo_name": "spadger/patent-spoiler", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/PatentSpoiler/Scripts/custom/item/itemHistoryDirective.js", "max_issues_repo_name": "spadger/patent-spoiler", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/PatentSpoiler/Scripts/custom/item/itemHistoryDirective.js", "max_forks_repo_name": "spadger/patent-spoiler", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.26, "max_line_length": 79, "alphanum_fraction": 0.383237364}
﻿///<reference path="module.js" />
'use strict';
angular.module('item').directive('itemHistory', function() {
    return {
        restrict: 'AE',
        scope: {
            setId: '@',
            ssIi:'@'
        },
        templateUrl: '/scripts/custom/item/itemhistory.html',
        controller:function($scope, itemService) {

            var initialised = false;

            $scope.$on('OpenHistory', function() {
                if (!initialised) {
                    $scope.moreItems();
                    initialised = true;
                }
            });

            $scope.items = [];
            $scope.showMore = true;

            $scope.commentFor = function(comment)
            {
                return comment || '<no commant>';
            }
            
            $scope.working = false;
            $scope.moreItems = function () {
                $scope.working = true;
                itemService.previousVersions($scope.setId, $scope.items.length)
                           .then(function (result) {

                               for (var i in result.items) {
                                   $scope.items.push(result.items[i]);
                               }

                               if ($scope.items.length >= result.count) {
                                   $scope.showMore = false;
                               }
                    })
                           .finally(function () {
                               $scope.working = false;
                            });
            }
        }
    }
});