all files / pdfviewer/organize-pdf/ organize-pdf.js

33.17% Statements 69/208
5.56% Branches 2/36
8.2% Functions 5/61
33.33% Lines 69/207
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 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 2971×   1× 1× 1×                                                                                                                                     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×                                               1×     1×     1×     1×     1×                             1×                   1×     1×     1×     1×     1×     1×     1×     1×     1×     1×     1×   1× 1× 1× 1× 1× 1× 1× 1×   1× 1×       1×   1× 1× 1×                                 1×   1×    
define(["require", "exports", "@syncfusion/ej2-base", "./organize-core/organize-initialization", "./organize-core/tile-interaction", "./organize-core/organize-toolbar", "./organize-core/slider-zoomaction", "./organize-core/organizepages-editor", "./organize-core/organize-undoredo", "./organize-core/organize-math-utils", "./organize-core/organize-utils", "./organize-core/organize-preview", "./organize-core/organize-thumbnail", "./organize-core/organize-event-handler", "./organize-core/organize-undoredoutils", "./organize-core/organize-importaction", "./organize-core/organize-saveaction", "./organize-core/organize-extract"], function (require, exports, ej2_base_1, organize_initialization_1, tile_interaction_1, organize_toolbar_1, slider_zoomaction_1, organizepages_editor_1, organize_undoredo_1, organize_math_utils_1, organize_utils_1, organize_preview_1, organize_thumbnail_1, organize_event_handler_1, organize_undoredoutils_1, organize_importaction_1, organize_saveaction_1, organize_extract_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var PageOrganizer = (function () {
        function PageOrganizer(pdfViewer, pdfViewerBase) {
            var _this = this;
            this.previewLimit = 5;
            this.lastRequestedPageIndex = 0;
            this.pageZoomSliderStep = 0.25;
            this.dataDetails = [];
            this.mobileContextMenu = [];
            this.organizePagesCollection = [];
            this.tempOrganizePagesCollection = [];
            this.isSkipRevert = false;
            this.isAllImagesReceived = false;
            this.selectedPageIndexes = [];
            this.autoScrollInterval = null;
            this.gapBetweenDivs = 48;
            this.previousImageZoom = 1;
            this.isDocumentModified = false;
            this.undoOrganizeCollection = [];
            this.redoOrganizeCollection = [];
            this.toolbarUndoRedoCollection = [];
            this.isTouchEvent = false;
            this.isPageZoomChanged = false;
            this.isInitialLoading = true;
            this.isOrganizeWindowOpen = false;
            this.isPageZoomPopupOpen = false;
            this.isExtractToolbarVisible = false;
            this.deleteExtractValue = '';
            this.thumbnailMouseOver = function (event) {
                organize_thumbnail_1.thumbnailMouseOver.call(_this, event);
            };
            this.thumbnailMouseLeave = function (event) {
                if (event.currentTarget instanceof HTMLElement) {
                    var childrenArray = Array.from(event.currentTarget.children);
                    for (var _i = 0, childrenArray_1 = childrenArray; _i < childrenArray_1.length; _i++) {
                        var subchild = childrenArray_1[_i];
                        var childArray = Array.from(subchild.children);
                        for (var _a = 0, childArray_1 = childArray; _a < childArray_1.length; _a++) {
                            var child = childArray_1[_a];
                            if (!(child.classList.contains('e-pv-image-container'))) {
                                if (event.currentTarget.classList.contains('e-pv-organize-node-selection-ring')) {
                                    if (child.classList.contains('e-checkbox-wrapper')) {
                                        child.style.display = 'block';
                                    }
                                    else {
                                        child.style.display = 'none';
                                    }
                                }
                                else {
                                    child.style.display = 'none';
                                }
                            }
                        }
                    }
                }
            };
            this.undo = function () {
                organize_undoredo_1.undo.call(_this);
            };
            this.redo = function () {
                organize_undoredo_1.redo.call(_this);
            };
            this.pdfViewer = pdfViewer;
            this.pdfViewerBase = pdfViewerBase;
            this.setPageOrganizerSettings(this.pdfViewer.pageOrganizerSettings);
            this.currentImageZoom = this.pdfViewer.pageOrganizerSettings.imageZoom;
            this.currentPageZoomSliderValue = this.pdfViewer.pageOrganizerSettings.imageZoom;
            this.previouslyRequestedImageZoom = Math.round(this.pdfViewer.pageOrganizerSettings.imageZoom);
        }
        PageOrganizer.prototype.createOrganizeWindow = function (isReConstruct) {
            organize_initialization_1.createOrganizeWindow.call(this, isReConstruct);
        };
        PageOrganizer.prototype.createOrganizeWindowForMobile = function (isReConstruct) {
            organize_initialization_1.createOrganizeWindowForMobile.call(this, isReConstruct);
        };
        PageOrganizer.prototype.setPageOrganizerSettings = function (pageOrganizerSettings, oldPageOrganizerSettings) {
            organize_initialization_1.setPageOrganizerSettings.call(this, pageOrganizerSettings, oldPageOrganizerSettings);
        };
        PageOrganizer.prototype.updateToolbarItemState = function (property) {
            organize_toolbar_1.updateToolbarItemState.call(this, property);
        };
        PageOrganizer.prototype.getImageZoomMin = function () {
            return slider_zoomaction_1.getImageZoomMin.call(this);
        };
        PageOrganizer.prototype.getImageZoomMax = function () {
            return slider_zoomaction_1.getImageZoomMax.call(this);
        };
        PageOrganizer.prototype.createRequestForPreview = function () {
            return organize_preview_1.createRequestForPreview.call(this);
        };
        PageOrganizer.prototype.requestPreviewCreation = function (proxy) {
            organize_preview_1.requestPreviewCreation.call(this, proxy);
        };
        PageOrganizer.prototype.updatePreviewCollection = function (data) {
            organize_preview_1.updatePreviewCollection.call(this, data);
        };
        PageOrganizer.prototype.previewOnMessage = function (event) {
            organize_preview_1.previewOnMessage.call(this, event);
        };
        PageOrganizer.prototype.getData = function (data, isClientRender) {
            return organize_preview_1.getData.call(this, data, isClientRender);
        };
        PageOrganizer.prototype.pageDragDrop = function (event) {
            organizepages_editor_1.pageDragDrop.call(this, event);
        };
        PageOrganizer.prototype.sorting = function (a, b) {
            return organize_math_utils_1.sorting.call(this, a, b);
        };
        PageOrganizer.prototype.tileImageRender = function (pageIndex, subIndex, pageOrder, targetElement, isNewPage, isBefore, isEmptyPage, isImportedPage, documentName) {
            organize_thumbnail_1.tileImageRender.call(this, pageIndex, subIndex, pageOrder, targetElement, isNewPage, isBefore, isEmptyPage, isImportedPage, documentName);
        };
        PageOrganizer.prototype.autoScroll = function (e) {
            organize_event_handler_1.autoScroll.call(this, e);
        };
        PageOrganizer.prototype.handlePageMove = function (e, tileRect, gapBetweenDivs, outerBorder) {
            organize_event_handler_1.handlePageMove.call(this, e, tileRect, gapBetweenDivs, outerBorder);
        };
        PageOrganizer.prototype.addSelectionRingStyle = function () {
            organize_initialization_1.addSelectionRingStyle.call(this);
        };
        PageOrganizer.prototype.removeSelectionRingStyle = function () {
            organize_initialization_1.removeSelectionRingStyle.call(this);
        };
        PageOrganizer.prototype.isHoveredOnSelectedPages = function (selectedPageIndexes, hoveredIndex) {
            return tile_interaction_1.isHoveredOnSelectedPages.call(this, selectedPageIndexes, hoveredIndex);
        };
        PageOrganizer.prototype.addOrganizeAction = function (UndoRedoTileActions, actionString, toolbarActions, selectedPageIndexes, dropIndex, isRightInsertion) {
            organize_undoredo_1.addOrganizeAction.call(this, UndoRedoTileActions, actionString, toolbarActions, selectedPageIndexes, dropIndex, isRightInsertion);
        };
        PageOrganizer.prototype.onSaveClicked = function () {
            organize_saveaction_1.onSaveClicked.call(this);
        };
        PageOrganizer.prototype.showOrganizeLoadingIndicator = function (isShow) {
            organize_initialization_1.showOrganizeLoadingIndicator.call(this, isShow);
        };
        PageOrganizer.prototype.deletePageElement = function (mainTileElement) {
            tile_interaction_1.deletePageElement.call(this, mainTileElement);
        };
        PageOrganizer.prototype.clonedCollection = function (tempCollecion) {
            return organize_undoredoutils_1.clonedCollection.call(this, tempCollecion);
        };
        PageOrganizer.prototype.loadImportDoc = function (documentData, password, isPasswordCorrect) {
            organize_importaction_1.loadImportDoc.call(this, documentData, password, isPasswordCorrect);
        };
        PageOrganizer.prototype.importDocuments = function (password, documentName, documentData) {
            organize_importaction_1.importDocuments.call(this, password, documentName, documentData);
        };
        PageOrganizer.prototype.updateOrganizePageCollection = function () {
            this.organizePagesCollection = JSON.parse(JSON.stringify(this.tempOrganizePagesCollection));
        };
        PageOrganizer.prototype.applyElementStyles = function (pageCanvas, pageNumber) {
            organize_initialization_1.applyElementStyles.call(this, pageCanvas, pageNumber);
        };
        PageOrganizer.prototype.onSaveasClicked = function () {
            organize_saveaction_1.onSaveasClicked.call(this);
        };
        PageOrganizer.prototype.updateOrganizePageActions = function () {
            organize_saveaction_1.updateOrganizePageActions.call(this);
        };
        PageOrganizer.prototype.rotateAllPages = function (pageRotateAngle) {
            organize_utils_1.rotateAllPages.call(this, pageRotateAngle);
        };
        PageOrganizer.prototype.rotatePages = function (arg1, arg2) {
            if (this.pdfViewer.pageOrganizerSettings.canRotate) {
                if (Array.isArray(arg1)) {
                    if (arg2 !== undefined && typeof arg2 === 'number') {
                        var pageIndexes = arg1;
                        var rotateAngle = arg2;
                        organize_math_utils_1.processRotation(pageIndexes, rotateAngle);
                    }
                    else {
                        var pageRotations = arg1;
                        for (var _i = 0, pageRotations_1 = pageRotations; _i < pageRotations_1.length; _i++) {
                            var pageRotation = pageRotations_1[_i];
                            organize_math_utils_1.processRotation([pageRotation.pageIndex], pageRotation.rotationAngle);
                        }
                    }
                }
                else if (typeof arg1 === 'number' && typeof arg2 === 'number') {
                    var pageStartIndex = arg1;
                    var pageEndIndex = arg2;
                    var rotateAngle = arguments[2];
                    organize_math_utils_1.processRotation(this.generateRange(pageStartIndex, pageEndIndex), rotateAngle);
                }
            }
        };
        PageOrganizer.prototype.generateRange = function (start, end) {
            return Array.from({ length: end - start + 1 }, function (_, index) { return start + index; });
        };
        PageOrganizer.prototype.updateOrganizePageImageSize = function (newSize, oldSize) {
            slider_zoomaction_1.updateOrganizePageImageSize.call(this, newSize, oldSize);
        };
        PageOrganizer.prototype.rotateClockwise = function (pageNumbers) {
            organize_math_utils_1.rotateClockwise.call(this, pageNumbers);
        };
        PageOrganizer.prototype.rotateCounterclockwise = function (pageNumbers) {
            organize_math_utils_1.rotateCounterclockwise.call(this, pageNumbers);
        };
        PageOrganizer.prototype.openPageOrganizer = function () {
            if (!ej2_base_1.isNullOrUndefined(this.pdfViewer.pageOrganizer)) {
                if (this.isAllImagesReceived) {
                    if (!ej2_base_1.Browser.isDevice || this.pdfViewer.enableDesktopMode) {
                        this.createOrganizeWindow();
                    }
                    else {
                        this.createOrganizeWindowForMobile();
                    }
                }
            }
            else {
                this.pdfViewerBase.getModuleWarningMessage('PageOrganizer');
            }
        };
        PageOrganizer.prototype.closePageOrganizer = function () {
            if (!ej2_base_1.isNullOrUndefined(this.pdfViewer.pageOrganizer)) {
                if (!ej2_base_1.isNullOrUndefined(this.organizeDialog) && this.isOrganizeWindowOpen) {
                    this.organizeDialog.hide();
                }
            }
            else {
                this.pdfViewerBase.getModuleWarningMessage('PageOrganizer');
            }
        };
        PageOrganizer.prototype.handleImageSizeBoundsChange = function (newProp) {
            slider_zoomaction_1.handleImageSizeBoundsChange.call(this, newProp);
        };
        PageOrganizer.prototype.handleImageResizerVisibility = function (showImageZoomingSlider) {
            organize_initialization_1.handleImageResizerVisibility.call(this, showImageZoomingSlider);
        };
        PageOrganizer.prototype.switchPageOrganizer = function () {
            organize_initialization_1.switchPageOrganizer.call(this);
        };
        PageOrganizer.prototype.getModuleName = function () {
            return 'PageOrganizer';
        };
        PageOrganizer.prototype.getImageZoomValue = function (isImageRequest, size) {
            return organize_math_utils_1.getImageZoomValue.call(this, isImageRequest, size);
        };
        PageOrganizer.prototype.handlePageZoomChange = function (currentValue, previousValue) {
            slider_zoomaction_1.handlePageZoomChange.call(this, currentValue, previousValue);
        };
        PageOrganizer.prototype.showRemoveExtractIcon = function (isShowRemove) {
            organize_extract_1.showRemoveExtractIcon.call(this, isShowRemove);
        };
        PageOrganizer.prototype.showHideExtractIcon = function (canExtractPages) {
            organize_extract_1.showHideExtractIcon.call(this, canExtractPages);
        };
        PageOrganizer.prototype.clear = function () {
            organize_initialization_1.clear.call(this);
        };
        PageOrganizer.prototype.destroy = function () {
            this.clear();
        };
        return PageOrganizer;
    }());
    exports.PageOrganizer = PageOrganizer;
    var PdfPageRotateAngle;
    (function (PdfPageRotateAngle) {
        PdfPageRotateAngle[PdfPageRotateAngle["RotateAngle0"] = 1] = "RotateAngle0";
        PdfPageRotateAngle[PdfPageRotateAngle["RotateAngle90"] = 2] = "RotateAngle90";
        PdfPageRotateAngle[PdfPageRotateAngle["RotateAngle180"] = 3] = "RotateAngle180";
        PdfPageRotateAngle[PdfPageRotateAngle["RotateAngle270"] = 4] = "RotateAngle270";
        PdfPageRotateAngle[PdfPageRotateAngle["RotateAngle360"] = 1] = "RotateAngle360";
    })(PdfPageRotateAngle = exports.PdfPageRotateAngle || (exports.PdfPageRotateAngle = {}));
    var PageRotation = (function () {
        function PageRotation(pageIndex, rotationAngle) {
            this.pageIndex = pageIndex;
            this.rotationAngle = rotationAngle;
        }
        return PageRotation;
    }());
    exports.PageRotation = PageRotation;
    var OrganizeDetails = (function () {
        function OrganizeDetails(currentPageIndex, pageIndex, copiedPageIndex, isInserted, isDeleted, isCopied, istargetCopied, hasEmptyPageAfter, hasEmptyPageBefore, rotateAngle, pageSize, isImportedDoc, documentName, password, documentData) {
            this.currentPageIndex = currentPageIndex;
            this.pageIndex = pageIndex;
            this.copiedPageIndex = copiedPageIndex;
            this.isInserted = isInserted;
            this.isDeleted = isDeleted;
            this.isCopied = isCopied;
            this.istargetCopied = istargetCopied;
            this.hasEmptyPageAfter = hasEmptyPageAfter;
            this.hasEmptyPageBefore = hasEmptyPageBefore;
            this.rotateAngle = rotateAngle;
            this.pageSize = pageSize;
            this.isImportedDoc = isImportedDoc;
            this.documentName = documentName;
            this.password = password;
            this.documentData = documentData;
        }
        return OrganizeDetails;
    }());
    exports.OrganizeDetails = OrganizeDetails;
});