all files / document-editor/implementation/search/ search-results.js

76.6% Statements 36/47
11.11% Branches 1/9
69.23% Functions 9/13
76.6% Lines 36/47
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75   146×                                                                            
define(["require", "exports"], function (require, exports) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var SearchResults = (function () {
        function SearchResults(search) {
            this.searchModule = search;
        }
        Object.defineProperty(SearchResults.prototype, "length", {
            get: function () {
                return this.searchModule.textSearchResults.length;
            },
            enumerable: true,
            configurable: true
        });
        Object.defineProperty(SearchResults.prototype, "index", {
            get: function () {
                return this.searchModule.textSearchResults.currentIndex;
            },
            set: function (value) {
                if (this.length === 0 || value < 0 || value > this.searchModule.textSearchResults.length - 1) {
                    return;
                }
                this.searchModule.textSearchResults.currentIndex = value;
                this.navigate();
            },
            enumerable: true,
            configurable: true
        });
        SearchResults.prototype.getTextSearchResultsOffset = function () {
            var index = [];
            var searchIndex;
            for (var i = 0; i < this.searchModule.textSearchResults.innerList.length; i++) {
                searchIndex = this.getOffset(this.searchModule.textSearchResults.innerList[parseInt(i.toString(), 10)]);
                index.push(searchIndex);
            }
            return index;
        };
        SearchResults.prototype.getOffset = function (innerList) {
            var start = innerList.start;
            var end = innerList.end;
            var blockInfo = this.searchModule.documentHelper.owner.selectionModule.getParagraphInfo(start);
            var startIndex = this.searchModule.documentHelper.owner.selectionModule.getHierarchicalIndex(blockInfo.paragraph, blockInfo.offset.toString());
            blockInfo = this.searchModule.documentHelper.owner.selectionModule.getParagraphInfo(end);
            var endIndex = this.searchModule.documentHelper.owner.selectionModule.getHierarchicalIndex(blockInfo.paragraph, blockInfo.offset.toString());
            return { 'startOffset': startIndex, 'endOffset': endIndex };
        };
        SearchResults.prototype.getModuleName = function () {
            return 'SearchResults';
        };
        SearchResults.prototype.replace = function (textToReplace) {
            if (this.index === -1) {
                return;
            }
            this.searchModule.replaceInternal(textToReplace);
        };
        SearchResults.prototype.replaceAll = function (textToReplace) {
            Iif (this.index === -1) {
                return;
            }
            this.searchModule.replaceAllInternal(textToReplace);
        };
        SearchResults.prototype.navigate = function () {
            this.searchModule.navigate(this.searchModule.textSearchResults.currentSearchResult);
            this.searchModule.highlight(this.searchModule.textSearchResults);
        };
        SearchResults.prototype.clear = function () {
            this.searchModule.textSearchResults.clearResults();
            this.searchModule.clearSearchHighlight();
            this.searchModule.viewer.renderVisiblePages();
        };
        return SearchResults;
    }());
    exports.SearchResults = SearchResults;
});