Migrate the inline poll management to the newer API
authorAlexander Ebert <ebert@woltlab.com>
Fri, 28 Apr 2023 13:29:33 +0000 (15:29 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Fri, 28 Apr 2023 13:56:32 +0000 (15:56 +0200)
com.woltlab.wcf/templates/__messageFormPoll.tpl
com.woltlab.wcf/templates/__messageFormPollInline.tpl
com.woltlab.wcf/templates/__pollOptionsFormField.tpl

index 66c410fe788b3169df979b53adb647d6c3875a09..12b5e0665ffaa30a16930a12b42e167e28907a92 100644 (file)
@@ -1,17 +1,17 @@
 {if $__showPoll|isset && $__showPoll}
        <script data-relocate="true">
-               require(['Language', 'WoltLabSuite/Core/Ui/Poll/Editor', 'EventHandler'], function (Language, UiPollEditor, EventHandler) {
-                       Language.addObject({
-                               'wcf.poll.button.addOption': '{jslang}wcf.poll.button.addOption{/jslang}',
-                               'wcf.poll.button.removeOption': '{jslang}wcf.poll.button.removeOption{/jslang}',
-                       });
-
+               require(["WoltLabSuite/Core/Ui/Poll/Editor"], (UiPollEditor) => {
+                       {jsphrase name='wcf.poll.button.addOption'}
+                       {jsphrase name='wcf.poll.button.removeOption'}
+                       {jsphrase name='wcf.poll.endTime.error.invalid'}
+                       {jsphrase name='wcf.poll.maxVotes.error.invalid'}
+                       
                        new UiPollEditor(
-                               'pollOptionContainer',
+                               "pollOptionContainer",
                                [ {implode from=$pollOptions item=pollOption}{ optionID: {@$pollOption[optionID]}, optionValue: '{@$pollOption[optionValue]|encodeJS}' }{/implode} ],
                                "",
                                {
-                                       maxOptions: {@POLL_MAX_OPTIONS}
+                                       maxOptions: {POLL_MAX_OPTIONS}
                                }
                        );
                });
index 21a04ee4680307188c7713e87d7dea4b7372de59..6768f812dfd50386d8552e4c22e314aee34c9c47 100644 (file)
@@ -1,18 +1,19 @@
 {if $__showPoll|isset && $__showPoll}
        <script data-relocate="true">
-               $(function() {
-                       WCF.Language.addObject({
-                               'wcf.poll.button.addOption': '{jslang}wcf.poll.button.addOption{/jslang}',
-                               'wcf.poll.button.removeOption': '{jslang}wcf.poll.button.removeOption{/jslang}',
-                               'wcf.poll.endTime.error.invalid': '{jslang}wcf.poll.endTime.error.invalid{/jslang}',
-                               'wcf.poll.maxVotes.error.invalid': '{jslang}wcf.poll.maxVotes.error.invalid{/jslang}'
-                       });
+               require(["WoltLabSuite/Core/Ui/Poll/Editor"], (UiPollEditor) => {
+                       {jsphrase name='wcf.poll.button.addOption'}
+                       {jsphrase name='wcf.poll.button.removeOption'}
+                       {jsphrase name='wcf.poll.endTime.error.invalid'}
+                       {jsphrase name='wcf.poll.maxVotes.error.invalid'}
                        
-                       new WCF.Poll.Management(
-                               'pollOptionContainer_{$wysiwygSelector}',
+                       new UiPollEditor(
+                               "pollOptionContainer_{$wysiwygSelector}",
                                [ {implode from=$pollOptions item=pollOption}{ optionID: {@$pollOption[optionID]}, optionValue: '{@$pollOption[optionValue]|encodeJS}' }{/implode} ],
-                               {@POLL_MAX_OPTIONS},
-                               '{$wysiwygSelector}'
+                               "{$wysiwygSelector}",
+                               {
+                                       isAjax: true,
+                                       maxOptions: {POLL_MAX_OPTIONS}
+                               }
                        );
                });
        </script>
        <div class="jsOnly messageTabMenuContent">
                <dl>
                        <dt>
-                               <label for="pollQuestion_{$wysiwygSelector}">{lang}wcf.poll.question{/lang}</label>
+                               <label for="{$wysiwygSelector}Poll_question">{lang}wcf.poll.question{/lang}</label>
                        </dt>
                        <dd>
-                               <input type="text" name="pollQuestion" id="pollQuestion_{$wysiwygSelector}" value="{$pollQuestion}" class="long" maxlength="255">
+                               <input type="text" name="pollQuestion" id="{$wysiwygSelector}Poll_question" value="{$pollQuestion}" class="long" maxlength="255">
                        </dd>
                        <dt>
                                <label>{lang}wcf.poll.options{/lang}</label>
                </dl>
                <dl>
                        <dt>
-                               <label for="pollEndTime_{$wysiwygSelector}">{lang}wcf.poll.endTime{/lang}</label>
+                               <label for="{$wysiwygSelector}Poll_endTime">{lang}wcf.poll.endTime{/lang}</label>
                        </dt>
                        <dd>
-                               <input type="datetime" tabindex="-1" name="pollEndTime" id="pollEndTime_{$wysiwygSelector}" value="{if $pollEndTime}{@$pollEndTime|date:'c'}{/if}" class="medium">
+                               <input type="datetime" tabindex="-1" name="pollEndTime" id="{$wysiwygSelector}Poll_endTime" value="{if $pollEndTime}{@$pollEndTime|date:'c'}{/if}" class="medium">
                        </dd>
                </dl>
                <dl>
                        <dt>
-                               <label for="pollMaxVotes_{$wysiwygSelector}">{lang}wcf.poll.maxVotes{/lang}</label>
+                               <label for="{$wysiwygSelector}Poll_maxVotes">{lang}wcf.poll.maxVotes{/lang}</label>
                        </dt>
                        <dd>
-                               <input type="number" name="pollMaxVotes" id="pollMaxVotes_{$wysiwygSelector}" value="{$pollMaxVotes}" min="1" class="tiny">
+                               <input type="number" name="pollMaxVotes" id="{$wysiwygSelector}Poll_maxVotes" value="{$pollMaxVotes}" min="1" class="tiny">
                        </dd>
                </dl>
                <dl>
                        <dt></dt>
                        <dd>
-                               <label><input type="checkbox" name="pollIsChangeable" value="1"{if $pollIsChangeable} checked{/if}> {lang}wcf.poll.isChangeable{/lang}</label>
+                               <label><input type="checkbox" name="pollIsChangeable" id="{$wysiwygSelector}Poll_isChangeable" value="1"{if $pollIsChangeable} checked{/if}> {lang}wcf.poll.isChangeable{/lang}</label>
                        </dd>
                        {if !$pollID && $__wcf->getPollManager()->canStartPublicPoll()}
                                <dd>
-                                       <label><input type="checkbox" name="pollIsPublic" value="1"{if $pollIsPublic} checked{/if}> {lang}wcf.poll.isPublic{/lang}</label>
+                                       <label><input type="checkbox" name="pollIsPublic" id="{$wysiwygSelector}Poll_isPublic" value="1"{if $pollIsPublic} checked{/if}> {lang}wcf.poll.isPublic{/lang}</label>
                                </dd>
                        {/if}
                        <dd>
-                               <label><input type="checkbox" name="pollResultsRequireVote" value="1"{if $pollResultsRequireVote} checked{/if}> {lang}wcf.poll.resultsRequireVote{/lang}</label>
+                               <label><input type="checkbox" name="pollResultsRequireVote" id="{$wysiwygSelector}Poll_resultsRequireVote" value="1"{if $pollResultsRequireVote} checked{/if}> {lang}wcf.poll.resultsRequireVote{/lang}</label>
                                <small>{lang}wcf.poll.resultsRequireVote.description{/lang}</small>
                        </dd>
                        <dd>
-                               <label><input type="checkbox" name="pollSortByVotes" value="1"{if $pollSortByVotes} checked{/if}> {lang}wcf.poll.sortByVotes{/lang}</label>
+                               <label><input type="checkbox" name="pollSortByVotes" id="{$wysiwygSelector}Poll_sortByVotes" value="1"{if $pollSortByVotes} checked{/if}> {lang}wcf.poll.sortByVotes{/lang}</label>
                        </dd>
                </dl>
                
index fb9000d34cfd818cca626a87852c660ce25c454f..c7a4d94350fffc627cbe4ea3350b7b34313e6341 100644 (file)
@@ -5,15 +5,13 @@
                'Dom/Traverse',
                'Dom/Util',
                'EventHandler',
-               'Language',
                'WoltLabSuite/Core/Form/Builder/Manager',
                'WoltLabSuite/Core/Ui/Poll/Editor'
-       ], function(DomTraverse, DomUtil, EventHandler, Language, FormBuilderManager, UiPollEditor) {
-               Language.addObject({
-                       'wcf.poll.button.addOption': '{jslang}wcf.poll.button.addOption{/jslang}',
-                       'wcf.poll.button.removeOption': '{jslang}wcf.poll.button.removeOption{/jslang}',
-                       'wcf.poll.maxVotes.error.invalid': '{jslang}wcf.poll.maxVotes.error.invalid{/jslang}'
-               });
+       ], (DomTraverse, DomUtil, EventHandler, FormBuilderManager, UiPollEditor) => {
+               {jsphrase name='wcf.poll.button.addOption'}
+               {jsphrase name='wcf.poll.button.removeOption'}
+               {jsphrase name='wcf.poll.endTime.error.invalid'}
+               {jsphrase name='wcf.poll.maxVotes.error.invalid'}
                
                var pollEditor = new UiPollEditor(
                        DomUtil.identify(DomTraverse.childByTag(elById('{@$field->getPrefixedId()|encodeJS}Container'), 'DD')),
@@ -21,7 +19,7 @@
                        '{@$field->getPrefixedWysiwygId()}',
                        {
                                isAjax: {if $field->getDocument()->isAjax()}true{else}false{/if},
-                               maxOptions: {@POLL_MAX_OPTIONS}
+                               maxOptions: {POLL_MAX_OPTIONS}
                        }
                );