all files / document-editor/implementation/dialogs/ form-field-check-box-dialog.js

91.77% Statements 223/243
85.71% Branches 72/84
93.33% Functions 14/15
91.77% Lines 223/243
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 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354   507× 507×         507×               507×   507×             507×   507×     33×         14461×                                                                                                                                                 755× 755×     755× 755×   755×   755×   755×   755× 755× 755×   755×   755× 755×   755×   755×   755×   755×   755×   755×   755×   755×   755×   755×   755×   755×   755×   755×   755×   755×   755×   755×   755×   755×          
define(["require", "exports", "@syncfusion/ej2-base", "@syncfusion/ej2-buttons", "../viewer/page", "@syncfusion/ej2-inputs"], function (require, exports, ej2_base_1, ej2_buttons_1, page_1, ej2_inputs_1) {
    "use strict";
    Object.defineProperty(exports, "__esModule", { value: true });
    var CheckBoxFormFieldDialog = (function () {
        function CheckBoxFormFieldDialog(owner) {
            var _this = this;
            this.changeBidirectional = function (event) {
                if (event.value === 'exact') {
                    _this.autoButton.checked = !_this.exactButton.checked;
                    _this.exactlyNumber.enabled = true;
                }
                else {
                    _this.exactButton.checked = !_this.autoButton.checked;
                    _this.exactlyNumber.enabled = false;
                }
            };
            this.changeBidirect = function (event) {
                if (event.value === 'check') {
                    _this.notCheckedButton.checked = !_this.checkedButton.checked;
                }
                else {
                    _this.checkedButton.checked = !_this.notCheckedButton.checked;
                }
            };
            this.onCancelButtonClick = function () {
                _this.documentHelper.dialog.hide();
            };
            this.insertCheckBoxField = function () {
                _this.closeCheckBoxField();
                var checkBoxField = new page_1.CheckBoxFormField();
                checkBoxField.defaultValue = _this.checkedButton.checked;
                checkBoxField.name = _this.bookmarkInputText.value;
                checkBoxField.helpText = _this.tooltipInputText.value;
                checkBoxField.checked = checkBoxField.defaultValue;
                checkBoxField.enabled = _this.checBoxEnableElement.checked;
                Iif (_this.exactButton.checked) {
                    checkBoxField.sizeType = 'Exactly';
                    checkBoxField.size = _this.exactlyNumber.value;
                }
                else {
                    checkBoxField.sizeType = 'Auto';
                    checkBoxField.size = 11;
                }
                _this.owner.editorModule.editFormField('CheckBox', checkBoxField);
            };
            this.closeCheckBoxField = function () {
                _this.documentHelper.dialog.hide();
                _this.documentHelper.dialog.element.style.pointerEvents = '';
            };
            this.owner = owner;
        }
        Object.defineProperty(CheckBoxFormFieldDialog.prototype, "documentHelper", {
            get: function () {
                return this.owner.documentHelper;
            },
            enumerable: true,
            configurable: true
        });
        CheckBoxFormFieldDialog.prototype.getModuleName = function () {
            return 'CheckBoxFormFieldDialog';
        };
        CheckBoxFormFieldDialog.prototype.initCheckBoxDialog = function (localValue, isRtl) {
            this.target = ej2_base_1.createElement('div');
            this.dialogDiv = ej2_base_1.createElement('div');
            this.headingLabel = ej2_base_1.createElement('div', {
                className: 'e-de-para-dlg-heading',
                innerHTML: localValue.getConstant('Check box size')
            });
            this.sizeParentDiv = ej2_base_1.createElement('div', { className: 'e-de-container-row' });
            this.autoDiv = ej2_base_1.createElement('div', { className: 'e-de-ff-radio-scnd-div' });
            this.exactDiv = ej2_base_1.createElement('div', { className: 'e-de-ff-radio-scnd-div' });
            this.autoEle = ej2_base_1.createElement('input', { className: 'e-de-rtl-btn-div', attrs: { 'aria-label': localValue.getConstant('Auto') } });
            this.exactEle = ej2_base_1.createElement('input', { className: 'e-de-rtl-btn-div', attrs: { 'aria-label': localValue.getConstant('Exactly') } });
            this.autoButton = new ej2_buttons_1.RadioButton({
                label: localValue.getConstant('Auto'), cssClass: 'e-small', change: this.changeBidirectional, checked: true,
                enableRtl: isRtl
            });
            this.exactButton = new ej2_buttons_1.RadioButton({
                label: localValue.getConstant('Exactly'), value: 'exact', cssClass: 'e-small', change: this.changeBidirectional,
                enableRtl: isRtl
            });
            this.exactNumberDiv = ej2_base_1.createElement('div', { className: 'e-de-ff-chck-exact' });
            this.exactNumber = ej2_base_1.createElement('input', { attrs: { 'type': 'text', 'aria-label': localValue.getConstant('Exactly') } });
            this.exactlyNumber = new ej2_inputs_1.NumericTextBox({
                format: 'n', value: 10, min: 1, max: 1584, enablePersistence: false, enabled: false, cssClass: 'e-de-check-exactnumbr-width',
                enableRtl: isRtl
            });
            this.defaultValueLabel = ej2_base_1.createElement('div', {
                className: 'e-de-para-dlg-heading',
                innerHTML: localValue.getConstant('Default value')
            });
            this.defaultcheckDiv = ej2_base_1.createElement('div', { className: 'e-de-container-row' });
            this.notcheckDiv = ej2_base_1.createElement('div', { className: 'e-de-ff-radio-div' });
            this.checkDiv = ej2_base_1.createElement('div', { className: 'e-de-ff-radio-div' });
            this.notcheckEle = ej2_base_1.createElement('input', { className: 'e-de-rtl-btn-div', attrs: { 'aria-label': localValue.getConstant('Not checked') } });
            this.checkEle = ej2_base_1.createElement('input', { className: 'e-de-rtl-btn-div', attrs: { 'aria-label': localValue.getConstant('Checked') } });
            this.notCheckedButton = new ej2_buttons_1.RadioButton({
                label: localValue.getConstant('Not checked'), enableRtl: isRtl, cssClass: 'e-small', change: this.changeBidirect
            });
            this.checkedButton = new ej2_buttons_1.RadioButton({
                label: localValue.getConstant('Checked'), value: 'check', enableRtl: isRtl, cssClass: 'e-small',
                change: this.changeBidirect, checked: true
            });
            this.fieldSettingsLabel = ej2_base_1.createElement('div', {
                className: 'e-de-para-dlg-heading',
                innerHTML: localValue.getConstant('Field settings')
            });
            this.settingsTotalDiv = ej2_base_1.createElement('div', { className: 'e-de-container-row' });
            this.totalToolTipDiv = ej2_base_1.createElement('div', { className: 'e-de-subcontainer-left' });
            this.totalBookmarkDiv = ej2_base_1.createElement('div', { className: 'e-de-subcontainer-right' });
            this.tooltipInputText = ej2_base_1.createElement('input', { className: 'e-input e-bookmark-textbox-input', attrs: { 'aira-label': localValue.getConstant('Tooltip') } });
            this.bookmarkInputText = ej2_base_1.createElement('input', { className: 'e-input e-bookmark-textbox-input', attrs: { 'aira-label': localValue.getConstant('Name') } });
            this.checkBoxEnableDiv = ej2_base_1.createElement('div');
            this.checBoxEnableEle = ej2_base_1.createElement('input', { attrs: { type: 'checkbox' } });
            this.checBoxEnableEle.setAttribute('aria-label', localValue.getConstant('Check box enabled'));
            this.checBoxEnableElement = new ej2_buttons_1.CheckBox({
                cssClass: 'e-de-ff-dlg-check',
                label: localValue.getConstant('Check box enabled'),
                enableRtl: isRtl
            });
            Iif (isRtl) {
                this.autoDiv.classList.add('e-de-rtl');
                this.exactDiv.classList.add('e-de-rtl');
                this.exactNumberDiv.classList.add('e-de-rtl');
                this.notcheckDiv.classList.add('e-de-rtl');
                this.checkDiv.classList.add('e-de-rtl');
                this.totalToolTipDiv.classList.add('e-de-rtl');
                this.totalBookmarkDiv.classList.add('e-de-rtl');
            }
            this.target.appendChild(this.dialogDiv);
            this.dialogDiv.appendChild(this.defaultValueLabel);
            this.dialogDiv.appendChild(this.defaultcheckDiv);
            this.defaultcheckDiv.appendChild(this.notcheckDiv);
            this.notcheckDiv.appendChild(this.notcheckEle);
            this.notCheckedButton.appendTo(this.notcheckEle);
            this.defaultcheckDiv.appendChild(this.checkDiv);
            this.checkDiv.appendChild(this.checkEle);
            this.checkedButton.appendTo(this.checkEle);
            this.dialogDiv.appendChild(this.headingLabel);
            this.dialogDiv.appendChild(this.sizeParentDiv);
            this.sizeParentDiv.appendChild(this.autoDiv);
            this.autoDiv.appendChild(this.autoEle);
            this.autoButton.appendTo(this.autoEle);
            this.sizeParentDiv.appendChild(this.exactDiv);
            this.exactDiv.appendChild(this.exactEle);
            this.exactButton.appendTo(this.exactEle);
            this.exactDiv.appendChild(this.exactNumberDiv);
            this.exactNumberDiv.appendChild(this.exactNumber);
            this.exactlyNumber.appendTo(this.exactNumber);
            this.dialogDiv.appendChild(this.fieldSettingsLabel);
            this.dialogDiv.appendChild(this.settingsTotalDiv);
            this.settingsTotalDiv.appendChild(this.totalToolTipDiv);
            this.settingsTotalDiv.appendChild(this.totalBookmarkDiv);
            this.totalToolTipDiv.appendChild(this.tooltipInputText);
            this.totalBookmarkDiv.appendChild(this.bookmarkInputText);
            this.dialogDiv.appendChild(this.checkBoxEnableDiv);
            this.checkBoxEnableDiv.appendChild(this.checBoxEnableEle);
            this.checBoxEnableElement.appendTo(this.checBoxEnableEle);
            new ej2_inputs_1.TextBox({ placeholder: localValue.getConstant('Tooltip'), floatLabelType: 'Always' }, this.tooltipInputText);
            new ej2_inputs_1.TextBox({ placeholder: localValue.getConstant('Name'), floatLabelType: 'Always' }, this.bookmarkInputText);
        };
        CheckBoxFormFieldDialog.prototype.show = function () {
            var localObj = new ej2_base_1.L10n('documenteditor', this.documentHelper.owner.defaultLocale);
            localObj.setLocale(this.documentHelper.owner.locale);
            Eif (ej2_base_1.isNullOrUndefined(this.target)) {
                this.initCheckBoxDialog(localObj, this.documentHelper.owner.enableRtl);
            }
            this.loadCheckBoxDialog();
            this.documentHelper.dialog.header = localObj.getConstant('Check Box Form Field');
            this.documentHelper.dialog.position = { X: 'center', Y: 'center' };
            this.documentHelper.dialog.height = 'auto';
            this.documentHelper.dialog.width = '400px';
            this.documentHelper.dialog.content = this.target;
            this.documentHelper.dialog.buttons = [{
                    click: this.insertCheckBoxField,
                    buttonModel: { content: localObj.getConstant('Ok'), cssClass: 'e-flat e-table-cell-margin-okay', isPrimary: true }
                },
                {
                    click: this.onCancelButtonClick,
                    buttonModel: { content: localObj.getConstant('Cancel'), cssClass: 'e-flat e-table-cell-margin-cancel' }
                }];
            this.documentHelper.dialog.show();
        };
        CheckBoxFormFieldDialog.prototype.loadCheckBoxDialog = function () {
            var inline = this.owner.selectionModule.getCurrentFormField();
            if (inline instanceof page_1.FieldElementBox) {
                this.fieldBegin = inline;
                var fieldData = this.fieldBegin.formFieldData;
                Eif (!fieldData.defaultValue) {
                    this.checkedButton.checked = false;
                    this.notCheckedButton.checked = true;
                }
                else {
                    this.checkedButton.checked = true;
                    this.notCheckedButton.checked = false;
                }
                Iif (fieldData.sizeType !== 'Auto') {
                    this.exactButton.checked = true;
                    this.autoButton.checked = false;
                    this.exactlyNumber.enabled = true;
                }
                else {
                    this.autoButton.checked = true;
                    this.exactButton.checked = false;
                    this.exactlyNumber.enabled = false;
                }
                Eif (fieldData.size) {
                    this.exactlyNumber.value = fieldData.size;
                }
                Eif (fieldData.enabled) {
                    this.checBoxEnableElement.checked = true;
                }
                else {
                    this.checBoxEnableElement.checked = false;
                }
                Eif (fieldData.name && fieldData.name !== '') {
                    this.bookmarkInputText.value = fieldData.name;
                }
                else {
                    this.bookmarkInputText.value = '';
                }
                Iif (fieldData.helpText && fieldData.helpText !== '') {
                    this.tooltipInputText.value = fieldData.helpText;
                }
                else {
                    this.tooltipInputText.value = '';
                }
            }
        };
        CheckBoxFormFieldDialog.prototype.destroy = function () {
            var checkBoxDialogTarget = this.target;
            if (checkBoxDialogTarget) {
                if (checkBoxDialogTarget.parentElement) {
                    checkBoxDialogTarget.parentElement.removeChild(checkBoxDialogTarget);
                }
                this.target = undefined;
            }
            this.owner = undefined;
            if (this.autoButton) {
                this.autoButton.destroy();
                this.autoButton = undefined;
            }
            if (this.exactButton) {
                this.exactButton.destroy();
                this.exactButton = undefined;
            }
            if (this.notCheckedButton) {
                this.notCheckedButton.destroy();
                this.notCheckedButton = undefined;
            }
            if (this.checkedButton) {
                this.checkedButton.destroy();
                this.checkedButton = undefined;
            }
            this.bookmarkInputText = undefined;
            this.tooltipInputText = undefined;
            if (this.checBoxEnableElement) {
                this.checBoxEnableElement.destroy();
                this.checBoxEnableElement = undefined;
            }
            if (this.exactlyNumber) {
                this.exactlyNumber.destroy();
                this.exactlyNumber = undefined;
            }
            this.exactNumberDiv = undefined;
            this.removeElements();
        };
        CheckBoxFormFieldDialog.prototype.removeElements = function () {
            if (this.dialogDiv) {
                this.dialogDiv.remove();
                this.dialogDiv = undefined;
            }
            if (this.headingLabel) {
                this.headingLabel.remove();
                this.headingLabel = undefined;
            }
            if (this.sizeParentDiv) {
                this.sizeParentDiv.remove();
                this.sizeParentDiv = undefined;
            }
            if (this.autoDiv) {
                this.autoDiv.remove();
                this.autoDiv = undefined;
            }
            if (this.exactDiv) {
                this.exactDiv.remove();
                this.exactDiv = undefined;
            }
            if (this.autoEle) {
                this.autoEle.remove();
                this.autoEle = undefined;
            }
            if (this.exactEle) {
                this.exactEle.remove();
                this.exactEle = undefined;
            }
            if (this.exactNumber) {
                this.exactNumber.remove();
                this.exactNumber = undefined;
            }
            if (this.defaultValueLabel) {
                this.defaultValueLabel.remove();
                this.defaultValueLabel = undefined;
            }
            if (this.defaultcheckDiv) {
                this.defaultcheckDiv.remove();
                this.defaultcheckDiv = undefined;
            }
            if (this.notcheckDiv) {
                this.notcheckDiv.remove();
                this.notcheckDiv = undefined;
            }
            if (this.checkDiv) {
                this.checkDiv.remove();
                this.checkDiv = undefined;
            }
            if (this.notcheckEle) {
                this.notcheckEle.remove();
                this.notcheckEle = undefined;
            }
            if (this.checkEle) {
                this.checkEle.remove();
                this.checkEle = undefined;
            }
            if (this.checkBoxEnableDiv) {
                this.checkBoxEnableDiv.remove();
                this.checkBoxEnableDiv = undefined;
            }
            if (this.checBoxEnableEle) {
                this.checBoxEnableEle.remove();
                this.checBoxEnableEle = undefined;
            }
            if (this.fieldSettingsLabel) {
                this.fieldSettingsLabel.remove();
                this.fieldSettingsLabel = undefined;
            }
            if (this.settingsTotalDiv) {
                this.settingsTotalDiv.remove();
                this.settingsTotalDiv = undefined;
            }
            if (this.totalToolTipDiv) {
                this.totalToolTipDiv.remove();
                this.totalToolTipDiv = undefined;
            }
            if (this.totalBookmarkDiv) {
                this.totalBookmarkDiv.remove();
                this.totalBookmarkDiv = undefined;
            }
        };
        return CheckBoxFormFieldDialog;
    }());
    exports.CheckBoxFormFieldDialog = CheckBoxFormFieldDialog;
});