מדיה ויקי:Gadget-TemplateParamWizard.js: הבדלים בין גרסאות בדף
ניסוי |
מ רשימת ערכים מוצעים (suggestedvalues) |
||
| שורה 88: | שורה 88: | ||
if ( /\n/.test( val ) ) $.extend( tp.options, { multiline : 5 } ); | if ( /\n/.test( val ) ) $.extend( tp.options, { multiline : 5 } ); | ||
// next line is for the case where there are "choices"' but current value is not one of them: add it as a new choice. | // next line is for the case where there are "choices"' but current value is not one of them: add it as a new choice. | ||
if ( | if (Array.isArray(tp.options.choices) && !tp.options.choices.includes(val)) | ||
tp.options.choices | tp.options.choices.push(val); | ||
} | } | ||
} | } | ||
| שורה 114: | שורה 114: | ||
templateParams[name] = { | templateParams[name] = { | ||
desc: param.description || '', | desc: param.description || '', | ||
options: { required: param.required }, | options: { required: param.required, choices: param.suggestedvalues }, | ||
label: param.label || name, | label: param.label || name, | ||
param: param | param: param | ||
| שורה 506: | שורה 506: | ||
checkbox = false; | checkbox = false; | ||
if (options.choices) { | if (Array.isArray(options.choices) && options.choices.length) { | ||
var choices = options.choices | var choices = options.choices; | ||
if (choices.length > 1) { | if (choices.length > 1) { | ||
f = $('<select>').append($('<option>', {text: i18n('options select'), value: ''})); | f = $('<select>').append($('<option>', {text: i18n('options select'), value: ''})); | ||