all files / document-editor-container/ribbon/view-tab/ zoom-group.js

95.56% Statements 43/45
81.82% Branches 18/22
100% Functions 16/16
95.24% Lines 40/42
11 statements, 6 functions, 9 branches Ignored     
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          14×   14×                                                                                                                                                                                                        
/* istanbul ignore next */ 
var __extends = (this && this.__extends) || (function () {
    var extendStatics = function (d, b) {
        extendStatics = Object.setPrototypeOf ||
            ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
            function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
        return extendStatics(d, b);
    };
    return function (d, b) {
        extendStatics(d, b);
        function __() { this.constructor = d; }
        d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
    };
})();
define(["require", "exports", "../ribbon-interfaces", "../ribbon-constants"], function (require, exports, ribbon_interfaces_1, ribbon_constants_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var ZoomGroup = (function (_super) {
        __extends(ZoomGroup, _super);
        function ZoomGroup() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        ZoomGroup.prototype.getGroupModel = function () {
            return {
                header: this.localObj.getConstant(ribbon_constants_1.RibbonConstants.ZOOM_GROUP_HEADER),
                groupIconCss: ribbon_constants_1.RibbonConstants.ZOOM_GROUP_ICON_CSS,
                orientation: 'Column',
                enableGroupOverflow: true,
                overflowHeader: this.localObj.getConstant(ribbon_constants_1.RibbonConstants.ZOOM_GROUP_HEADER),
                collections: [
                    {
                        items: [
                            {
                                type: 'Button',
                                keyTip: 'W',
                                buttonSettings: {
                                    content: this.localObj.getConstant('Zoom In'),
                                    iconCss: 'e-icons e-de-ctnr-zoom-in',
                                    clicked: this.zoomInHandler.bind(this)
                                },
                                id: this.ribbonId + ribbon_constants_1.RibbonConstants.ZOOM_IN_BUTTON_ID,
                                ribbonTooltipSettings: {
                                    content: this.localObj.getConstant('Zoom In')
                                }
                            },
                            {
                                type: 'Button',
                                keyTip: 'E',
                                buttonSettings: {
                                    content: this.localObj.getConstant('Zoom Out'),
                                    iconCss: 'e-icons e-de-ctnr-zoom-out',
                                    clicked: this.zoomOutHandler.bind(this)
                                },
                                id: this.ribbonId + ribbon_constants_1.RibbonConstants.ZOOM_OUT_BUTTON_ID,
                                ribbonTooltipSettings: {
                                    content: this.localObj.getConstant('Zoom Out')
                                }
                            }
                        ]
                    }, {
                        items: [
                            {
                                type: 'Button',
                                keyTip: '1',
                                buttonSettings: {
                                    content: this.localObj.getConstant('100%'),
                                    iconCss: 'e-icons e-de-ctnr-fit-100',
                                    clicked: this.hundredpercentHandler.bind(this)
                                },
                                id: this.ribbonId + ribbon_constants_1.RibbonConstants.HUNDRED_PERCENT_BUTTON_ID,
                                ribbonTooltipSettings: {
                                    content: this.localObj.getConstant('100%')
                                }
                            },
                            {
                                type: 'Button',
                                keyTip: '2',
                                buttonSettings: {
                                    content: this.localObj.getConstant('One Page'),
                                    iconCss: 'e-icons e-icons e-de-ctnr-columns',
                                    clicked: this.fitOnePageHandler.bind(this)
                                },
                                id: this.ribbonId + ribbon_constants_1.RibbonConstants.ONE_PAGE_BUTTON_ID,
                                ribbonTooltipSettings: {
                                    content: this.localObj.getConstant('One Page')
                                }
                            },
                            {
                                type: 'Button',
                                keyTip: 'I',
                                buttonSettings: {
                                    content: this.localObj.getConstant('Page Width'),
                                    iconCss: 'e-icons e-de-ctnr-page-width',
                                    clicked: this.pageWidthHandler.bind(this)
                                },
                                id: this.ribbonId + ribbon_constants_1.RibbonConstants.PAGE_WIDTH_BUTTON_ID,
                                ribbonTooltipSettings: {
                                    content: this.localObj.getConstant('Page Width')
                                }
                            }
                        ]
                    }
                ]
            };
        };
        ZoomGroup.prototype.zoomInHandler = function () {
            this.documentEditor.zoomFactor += 0.1;
        };
        ZoomGroup.prototype.zoomOutHandler = function () {
            Eif (this.documentEditor.zoomFactor > 0.1) {
                this.documentEditor.zoomFactor -= 0.1;
            }
        };
        ZoomGroup.prototype.fitOnePageHandler = function () {
            this.documentEditor.fitPage('FitOnePage');
        };
        ZoomGroup.prototype.hundredpercentHandler = function () {
            this.documentEditor.zoomFactor = 1;
        };
        ZoomGroup.prototype.pageWidthHandler = function () {
            this.documentEditor.fitPage('FitPageWidth');
        };
        ZoomGroup.prototype.updateZoomButtonState = function () {
            var ribbon = this.container.ribbon.ribbon;
            Eif (ribbon) {
                var zoomInButtonId = this.ribbonId + ribbon_constants_1.RibbonConstants.ZOOM_IN_BUTTON_ID;
                var zoomOutButtonId = this.ribbonId + ribbon_constants_1.RibbonConstants.ZOOM_OUT_BUTTON_ID;
                Iif (this.documentEditor.zoomFactor >= 5) {
                    ribbon.disableItem(zoomInButtonId);
                }
                else {
                    ribbon.enableItem(zoomInButtonId);
                }
                Iif (this.documentEditor.zoomFactor <= 0.10) {
                    ribbon.disableItem(zoomOutButtonId);
                }
                else {
                    ribbon.enableItem(zoomOutButtonId);
                }
            }
        };
        return ZoomGroup;
    }(ribbon_interfaces_1.RibbonGroupBase));
    exports.ZoomGroup = ZoomGroup;
});