all files / document-editor-container/ribbon/home-tab/ styles-group.js

95.24% Statements 40/42
86.67% Branches 26/30
100% Functions 13/13
94.87% Lines 37/39
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          14×   14× 14× 14×                                                                               14×   231×     231× 231×     231× 231× 231× 231×        
/* 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", "../../helper/styles-helper", "@syncfusion/ej2-base"], function (require, exports, ribbon_interfaces_1, styles_helper_1, ej2_base_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    exports.STYLES_GROUP_ID = '_styles_group';
    var StylesGroup = (function (_super) {
        __extends(StylesGroup, _super);
        function StylesGroup() {
            return _super !== null && _super.apply(this, arguments) || this;
        }
        StylesGroup.prototype.getGroupModel = function () {
            var _this = this;
            var id = this.ribbonId;
            return {
                id: id + exports.STYLES_GROUP_ID,
                cssClass: 'e-styles-group',
                header: this.localObj.getConstant('Styles'),
                enableGroupOverflow: true,
                keyTip: 'L',
                overflowHeader: this.localObj.getConstant('Styles'),
                groupIconCss: 'e-icons e-de-ctnr-paste',
                orientation: 'Row',
                showLauncherIcon: true,
                launcherIconKeyTip: 'FY',
                collections: [
                    {
                        id: this.ribbonId + '_style-gallery',
                        items: [
                            {
                                type: 'Gallery',
                                gallerySettings: {
                                    groups: [
                                        {
                                            header: this.localObj.getConstant('Styles'),
                                            items: this.getStyleItems()
                                        }
                                    ],
                                    itemCount: 3,
                                    select: function (args) {
                                        Eif (!_this.documentEditor.isReadOnly && _this.documentEditor.editorModule) {
                                            var styleName = _this.documentEditor.stylesDialogModule.getStyleName(ej2_base_1.SanitizeHtmlHelper.sanitize(args.currentItem.content));
                                            Eif (!ej2_base_1.isNullOrUndefined(_this.documentEditor.documentHelper.styles.findByName(styleName))) {
                                                _this.documentEditor.editorModule.applyStyle(styleName, true);
                                            }
                                        }
                                    },
                                    popupWidth: '150px',
                                    popupHeight: '300px'
                                },
                                id: this.ribbonId + '_style-item-gallery',
                                ribbonTooltipSettings: { content: this.localObj.getConstant('Styles') }
                            }
                        ]
                    }
                ]
            };
        };
        StylesGroup.prototype.getStyleItems = function () {
            return styles_helper_1.StylesHelper.getStyleItems(this.documentEditor, this.localObj);
        };
        StylesGroup.prototype.updateStyleGallery = function () {
            Iif (!this.container || !this.container.ribbon || !this.container.ribbon.ribbon) {
                return;
            }
            var galleryItem = this.container.ribbon.ribbon.getItem(this.ribbonId + '_style-item-gallery');
            Iif (!galleryItem || !galleryItem.gallerySettings || !galleryItem.gallerySettings.groups) {
                return;
            }
            galleryItem.gallerySettings.groups[0].items = styles_helper_1.StylesHelper.getStyleItems(this.documentEditor, this.localObj);
            var currentStyle = styles_helper_1.StylesHelper.getCurrentStyleName(this.documentEditor, this.localObj);
            galleryItem.gallerySettings.selectedItemIndex = styles_helper_1.StylesHelper.findStyleIndex(currentStyle, galleryItem.gallerySettings.groups[0].items);
            this.container.ribbon.ribbon.updateItem(galleryItem);
        };
        return StylesGroup;
    }(ribbon_interfaces_1.RibbonGroupBase));
    exports.StylesGroup = StylesGroup;
});