Merge branch '3.1' into 5.2
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / acp / templates / __pollOptionsFormField.tpl
1 <ol class="sortableList"></ol>
2
3 <script data-relocate="true">
4 require([
5 'Dom/Traverse',
6 'Dom/Util',
7 'EventHandler',
8 'Language',
9 'WoltLabSuite/Core/Form/Builder/Manager',
10 'WoltLabSuite/Core/Ui/Poll/Editor'
11 ], function(DomTraverse, DomUtil, EventHandler, Language, FormBuilderManager, UiPollEditor) {
12 Language.addObject({
13 'wcf.poll.button.addOption': '{lang}wcf.poll.button.addOption{/lang}',
14 'wcf.poll.button.removeOption': '{lang}wcf.poll.button.removeOption{/lang}',
15 'wcf.poll.maxVotes.error.invalid': '{lang}wcf.poll.maxVotes.error.invalid{/lang}'
16 });
17
18 var pollEditor = new UiPollEditor(
19 DomUtil.identify(DomTraverse.childByTag(elById('{@$field->getPrefixedId()}Container'), 'DD')),
20 [ {implode from=$field->getValue() item=pollOption}{ optionID: {@$pollOption[optionID]}, optionValue: '{$pollOption[optionValue]|encodeJS}' }{/implode} ],
21 '{@$field->getPrefixedWysiwygId()}',
22 {
23 isAjax: {if $field->getDocument()->isAjax()}true{else}false{/if},
24 maxOptions: {@POLL_MAX_OPTIONS}
25 }
26 );
27
28 EventHandler.add('WoltLabSuite/Core/Form/Builder/Manager', 'registerField', function(data) {
29 if (data.formId === '{@$field->getDocument()->getId()}' && data.field.getId() === '{@$field->getPrefixedId()}') {
30 data.field.setPollEditor(pollEditor);
31 }
32 });
33 });
34 </script>