define(["require", "exports"], function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.FORM_FIELDS_GROUP = '_form_fields_group';
exports.FORM_FIELDS_ID = '_form_fields';
exports.TEXT_FORM = '_text_form';
exports.CHECKBOX = '_checkbox';
exports.DROPDOWN = '_dropdown';
var FormFieldsGroup = (function () {
function FormFieldsGroup(container) {
this.container = container;
this.ribbonId = this.container.element.id + '_ribbon';
}
Object.defineProperty(FormFieldsGroup.prototype, "documentEditor", {
get: function () {
return this.container.documentEditor;
},
enumerable: true,
configurable: true
});
FormFieldsGroup.prototype.getGroupModel = function () {
var locale = this.container.localObj;
var id = this.ribbonId + exports.FORM_FIELDS_GROUP;
return {
id: id,
header: locale.getConstant('Form Fields'),
orientation: 'Row',
cssClass: 'e-formfields-group',
enableGroupOverflow: true,
overflowHeader: locale.getConstant('Form Fields'),
collections: [
{
items: [
this.getFormFieldsDropDownModel()
]
}
]
};
};
FormFieldsGroup.prototype.getFormFieldsDropDownModel = function () {
var locale = this.container.localObj;
var id = this.ribbonId;
return {
type: 'DropDown',
id: id + exports.FORM_FIELDS_ID,
dropDownSettings: {
iconCss: 'e-icons e-de-formfield',
content: locale.getConstant('Form Fields'),
items: [
{
text: locale.getConstant('Text Form'),
iconCss: 'e-icons e-de-textform',
id: id + exports.TEXT_FORM
},
{
text: locale.getConstant('Check Box'),
iconCss: 'e-icons e-de-checkbox-form',
id: id + exports.CHECKBOX
},
{
text: locale.getConstant('DropDown'),
iconCss: 'e-icons e-de-dropdownform',
id: id + exports.DROPDOWN
}
],
select: this.onFormFieldsDropDownSelect.bind(this)
},
ribbonTooltipSettings: {
content: locale.getConstant('Insert form fields')
}
};
};
FormFieldsGroup.prototype.onFormFieldsDropDownSelect = function (args) {
var _this = this;
var id = this.ribbonId;
if (args.item.id === id + exports.TEXT_FORM) {
this.documentEditor.editorModule.insertFormField('Text');
}
else if (args.item.id === id + exports.CHECKBOX) {
this.documentEditor.editorModule.insertFormField('CheckBox');
}
else Eif (args.item.id === id + exports.DROPDOWN) {
this.documentEditor.editorModule.insertFormField('DropDown');
}
setTimeout(function () {
_this.documentEditor.focusIn();
}, 30);
};
FormFieldsGroup.prototype.updateSelection = function () {
var isHeaderFooter = this.documentEditor.selection.contextType.indexOf('Header') >= 0 ||
this.documentEditor.selection.contextType.indexOf('Footer') >= 0;
var ribbon = this.container.ribbon.ribbon;
Eif (ribbon) {
if (isHeaderFooter) {
ribbon.disableItem(this.ribbonId + exports.FORM_FIELDS_ID);
}
else {
ribbon.enableItem(this.ribbonId + exports.FORM_FIELDS_ID);
}
}
};
FormFieldsGroup.prototype.destroy = function () {
Iif (this.formFieldDropDown) {
this.formFieldDropDown.destroy();
this.formFieldDropDown = undefined;
}
this.container = undefined;
this.ribbonId = undefined;
};
return FormFieldsGroup;
}());
exports.FormFieldsGroup = FormFieldsGroup;
});
|