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 | 1×
1×
1×
1×
1×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
1×
36×
1×
14×
14×
1×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
5×
5×
5×
5×
5×
1×
1×
14×
1×
5×
1×
5×
1×
1×
1×
1×
1×
1×
1×
1×
2×
1×
1×
1×
1×
1×
1×
1×
1×
1×
6×
6×
6×
6×
6×
6×
6×
1×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
14×
1×
1×
| define(["require", "exports", "@syncfusion/ej2-base", "../ribbon-base/ribbon-constants", "@syncfusion/ej2-ribbon", "../../helper/bullet-list-helper"], function (require, exports, ej2_base_1, ribbon_constants_1, ej2_ribbon_1, bullet_list_helper_1) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.NUMBER_LIST_ID = '_number_list';
var NumberingGroup = (function () {
function NumberingGroup(container) {
this.appliedNumberingStyle = 'arabic';
this.numberedAndBulletNoneClickHandler = this.bulletNoneClick.bind(this);
this.numberedNumberDotClickHandler = this.numberedNumberDotClick.bind(this);
this.numberedLowLetterClickHandler = this.numberedLowLetterClick.bind(this);
this.numberedUpLetterClickHandler = this.numberedUpLetterClick.bind(this);
this.numberedLowRomanClickHandler = this.numberedLowRomanClick.bind(this);
this.numberedUpRomanClickHandler = this.numberedUpRomanClick.bind(this);
this.container = container;
this.ribbonId = this.container.element.id + ribbon_constants_1.RIBBON_ID;
this.localObj = this.container.localObj;
}
Object.defineProperty(NumberingGroup.prototype, "documentEditor", {
get: function () {
return this.container.documentEditor;
},
enumerable: true,
configurable: true
});
NumberingGroup.prototype.getNumberingListItem = function () {
var id = this.ribbonId;
return {
type: 'SplitButton',
keyTip: 'N',
allowedSizes: ej2_ribbon_1.RibbonItemSize.Small,
splitButtonSettings: this.createNumberingSplitButton(),
id: id + exports.NUMBER_LIST_ID,
ribbonTooltipSettings: { content: this.localObj.getConstant('Numbering') }
};
};
NumberingGroup.prototype.createNumberingSplitButton = function () {
var _this = this;
var numberIconCss = 'e-de-ctnr-numbering e-icons';
Iif (this.container.enableRtl) {
numberIconCss += ' e-de-flip';
}
var numberListDropDiv = ej2_base_1.createElement('div', {
id: this.ribbonId + '_number_list_div',
styles: 'width: 211px;height: auto;visibility: hidden'
});
var numberListDropUlTag = ej2_base_1.createElement('ul', {
styles: 'visibility: visible; outline: 0px;',
id: this.ribbonId + '_numberListMenu',
className: 'e-de-floating-menu e-de-bullets-menu e-de-list-container e-de-list-thumbnail'
});
numberListDropDiv.appendChild(numberListDropUlTag);
this.noneNumberTag = bullet_list_helper_1.BulletListHelper.createNumberNoneListTag(numberListDropUlTag, this.localObj);
this.noneNumberTag.addEventListener('click', this.numberedAndBulletNoneClickHandler);
this.numberList = bullet_list_helper_1.BulletListHelper.createNumberListTag(numberListDropUlTag, '1.', '2.', '3.');
this.numberList.addEventListener('click', this.numberedNumberDotClickHandler);
this.lowLetter = bullet_list_helper_1.BulletListHelper.createNumberListTag(numberListDropUlTag, 'a.', 'b.', 'c.');
this.lowLetter.addEventListener('click', this.numberedLowLetterClickHandler);
this.upLetter = bullet_list_helper_1.BulletListHelper.createNumberListTag(numberListDropUlTag, 'A.', 'B.', 'C.');
this.upLetter.addEventListener('click', this.numberedUpLetterClickHandler);
this.lowRoman = bullet_list_helper_1.BulletListHelper.createNumberListTag(numberListDropUlTag, 'i.', 'ii.', 'iii.');
this.lowRoman.addEventListener('click', this.numberedLowRomanClickHandler);
this.upRoman = bullet_list_helper_1.BulletListHelper.createNumberListTag(numberListDropUlTag, 'I.', 'II.', 'III.');
this.upRoman.addEventListener('click', this.numberedUpRomanClickHandler);
this.numberElements = {
'none': this.noneNumberTag,
'number': this.numberList,
'lowletter': this.lowLetter,
'upletter': this.upLetter,
'lowroman': this.lowRoman,
'uproman': this.upRoman
};
return {
target: numberListDropDiv,
iconCss: numberIconCss,
items: this.getNumberingItems(),
content: this.localObj.getConstant('Numbering'),
select: this.handleNumberingSelection.bind(this),
beforeOpen: function () {
numberListDropDiv.style.visibility = 'visible';
var levelPattern = bullet_list_helper_1.BulletListHelper.getCurrentListPattern(_this.documentEditor);
_this.updateSelectedNumberedListType(levelPattern);
},
beforeClose: function () {
numberListDropDiv.style.visibility = 'hidden';
_this.removeSelectedList();
},
click: function () {
_this.applyLastAppliedNumbering();
}
};
};
NumberingGroup.prototype.getNumberingItems = function () {
return [
{ id: this.ribbonId + '_number-none', text: this.localObj.getConstant('None') },
{ id: this.ribbonId + '_number-arabic', text: this.localObj.getConstant('Arabic') },
{ id: this.ribbonId + '_number-lowletter', text: this.localObj.getConstant('Lower Letter') },
{ id: this.ribbonId + '_number-upletter', text: this.localObj.getConstant('Upper Letter') },
{ id: this.ribbonId + '_number-lowroman', text: this.localObj.getConstant('Lower Roman') },
{ id: this.ribbonId + '_number-uproman', text: this.localObj.getConstant('Upper Roman') }
];
};
NumberingGroup.prototype.removeSelectedList = function () {
bullet_list_helper_1.BulletListHelper.removeSelectedList(this.numberElements);
};
NumberingGroup.prototype.updateSelectedNumberedListType = function (listPattern) {
bullet_list_helper_1.BulletListHelper.updateSelectedNumberedListType(listPattern, this.numberElements);
};
NumberingGroup.prototype.applyLastAppliedNumbering = function () {
switch (this.appliedNumberingStyle) {
case 'arabic':
this.numberedNumberDotClick();
break;
case this.ribbonId + '_lowroman':
this.numberedLowRomanClick();
break;
case this.ribbonId + '_uproman':
this.numberedUpRomanClick();
break;
case this.ribbonId + '_lowletter':
this.numberedLowLetterClick();
break;
case this.ribbonId + '_upletter':
this.numberedUpLetterClick();
break;
default:
this.numberedNumberDotClick();
break;
}
};
NumberingGroup.prototype.handleNumberingSelection = function (args) {
switch (args.item.id) {
case this.ribbonId + '_number-none':
this.bulletNoneClick();
break;
case this.ribbonId + '_number-arabic':
this.numberedNumberDotClick();
break;
case this.ribbonId + '_number-lowroman':
this.numberedLowRomanClick();
break;
case this.ribbonId + '_number-uproman':
this.numberedUpRomanClick();
break;
case this.ribbonId + '_number-lowletter':
this.numberedLowLetterClick();
break;
case this.ribbonId + '_number-upletter':
this.numberedUpLetterClick();
break;
}
};
NumberingGroup.prototype.bulletNoneClick = function () {
bullet_list_helper_1.BulletListHelper.clearList(this.documentEditor);
};
NumberingGroup.prototype.numberedNumberDotClick = function () {
this.applyNumbering('Arabic', 'arabic');
};
NumberingGroup.prototype.numberedLowLetterClick = function () {
this.applyNumbering('LowLetter', 'lowletter');
};
NumberingGroup.prototype.numberedUpLetterClick = function () {
this.applyNumbering('UpLetter', 'upletter');
};
NumberingGroup.prototype.numberedLowRomanClick = function () {
this.applyNumbering('LowRoman', 'lowroman');
};
NumberingGroup.prototype.numberedUpRomanClick = function () {
this.applyNumbering('UpRoman', 'uproman');
};
NumberingGroup.prototype.applyNumbering = function (pattern, style) {
var _this = this;
Eif (!this.documentEditor.isReadOnly && this.documentEditor.editorModule) {
this.appliedNumberingStyle = style;
var format = bullet_list_helper_1.BulletListHelper.getLevelFormatNumber(this.documentEditor);
this.documentEditor.editorModule.applyNumbering(format, pattern);
setTimeout(function () {
_this.documentEditor.focusIn();
}, 30);
}
};
NumberingGroup.prototype.destroy = function () {
Eif (this.noneNumberTag) {
this.noneNumberTag.removeEventListener('click', this.numberedAndBulletNoneClickHandler);
}
Eif (this.numberList) {
this.numberList.removeEventListener('click', this.numberedNumberDotClickHandler);
}
Eif (this.lowLetter) {
this.lowLetter.removeEventListener('click', this.numberedLowLetterClickHandler);
}
Eif (this.upLetter) {
this.upLetter.removeEventListener('click', this.numberedUpLetterClickHandler);
}
Eif (this.lowRoman) {
this.lowRoman.removeEventListener('click', this.numberedLowRomanClickHandler);
}
Eif (this.upRoman) {
this.upRoman.removeEventListener('click', this.numberedUpRomanClickHandler);
}
this.noneNumberTag = null;
this.numberList = null;
this.lowLetter = null;
this.upLetter = null;
this.lowRoman = null;
this.upRoman = null;
};
return NumberingGroup;
}());
exports.NumberingGroup = NumberingGroup;
});
|