add_poll_form

NAML documentation   Watch a video
   Usages of this macro
... in poll.naml
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
<macro name="add_poll_form" requires="node_page">
    <script type="text/javascript">
        function addPoll() {
            $('#poll').show();
            if ( $('#poll-options div').size() == 0 ) {
                addOption(false);
                addOption(false);
            } else
                updateOptions();
            Nabble.resizeFrames();
        };
        function removeOption(e) {
            $(e).parent().remove();
            updateOptions();
            Nabble.resizeFrames();
        };
        function addOption(focus) {
            $('#poll-options').append('<n.javascript_string_encode
Binary
Namespace: NabbleNamespace
Parameters: text
.poll_option_input_row
Macro
Parameters: poll_option
/>');
            updateOptions();
            if (focus)
                $('#poll-options div input').last().focus();
            Nabble.resizeFrames();
        };
        function updateOptions() {
            var c = 1;
            $('#poll-options div').each(function() {
                $('a,span', this).remove();
                $(this).prepend('<span>'+c+'.</span>');
                if (c++ > 2) {
                    $(this).append('<a class="removeOption" href="javascript:void(0)" onclick="removeOption(this)"><t>remove</t></a>');
                }
            });
        };
        function removePoll() {
            $('input[name=poll_question]').val('');
            $('#poll').hide();
        };
        <n.if
Binary
Namespace: BasicNamespace
Parameters: condition, else, then
.not
Binary
Namespace: BasicNamespace
Parameters: condition
.is_empty
Binary
Namespace: BasicNamespace
Parameters: value
.poll_question_field
Macro
Parameters: do
.value
Binary
Namespace: FieldNamespace
>
            <then>
                $(document).ready(function() {
                    updateOptions();
                });
            </then>
        </n.if.not.is_empty.poll_question_field.value>
    </script>
    <a href="javascript: void(0)" onclick="addPoll()"><t>Add new poll</t></a>
 
    <div id="poll" class="extra-field-details medium-border-color" style="[n.if
Binary
Namespace: BasicNamespace
Parameters: condition, else, then
.is_empty
Binary
Namespace: BasicNamespace
Parameters: value
.poll_question_field
Macro
Parameters: do
.value
Binary
Namespace: FieldNamespace
][then]display:none[/then][/n.if.is_empty.poll_question_field.value]">
        <table>
            <tr valign="top">
                <td style="text-align:right;padding-top:.4em"><t>Question:</t></td>
                <td style="padding-left:1.8em"><n.poll_question_field
Macro
Parameters: do
.input
Macro
Requires: field
Parameters: size, maxlength, tabindex, type
 type="text" size="40"/></td>
            </tr>
            <tr valign="top">
                <td style="text-align:right;padding-top:.4em"><t>Answers:</t></td>
                <td style="padding-left:.7em">
                    <div id="poll-options" style="padding-bottom:.3em">
                        <n.get_parameter_values
Binary
Namespace: RequestNamespace
Parameters: name, do
. name="poll_option">
                            <n.loop
Macro
Requires: sequence
Parameters: by, do
.poll_option_input_row
Macro
Parameters: poll_option
.current_parameter_value
Binary
Namespace: ParameterValueList
/>
                        </n.get_parameter_values.>
                    </div>
                    <a href="javascript: void addOption(true)"><t>Add new answer</t></a>
                </td>
            </tr>
        </table>
        <n.poll_settings
Macro
/>
        <a href="javascript: void(0)" onclick="removePoll()"><t>Remove Poll</t></a>
    </div>
</macro>