מדיה ויקי:Gadget-TemplateParamWizard.js: הבדלים בין גרסאות בדף
מ שחזור לגרסה 30511848 מ־01:48, 30 בינואר 2021 מאת קיפודנחש המשך יבוא |
ניסוי |
||
| שורה 109: | שורה 109: | ||
paramOrder = data.paramOrder; | paramOrder = data.paramOrder; | ||
function optionsOfParam(param) { | |||
var options = {}; | |||
if (param.required) options.required = true; | |||
if (param.suggestedvalues && param.suggestedvalues.length) options.choices = param.suggestedvalues.join(','); | |||
return options; | |||
} | |||
function onemore(name) { | function onemore(name) { | ||
| שורה 114: | שורה 120: | ||
templateParams[name] = { | templateParams[name] = { | ||
desc: param.description || '', | desc: param.description || '', | ||
options: | options: optionsOfParam(param), | ||
label: param.label || name, | label: param.label || name, | ||
param: param | param: param | ||
| שורה 509: | שורה 515: | ||
var choices = options.choices.split(/\s*,\s*/); | var choices = options.choices.split(/\s*,\s*/); | ||
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: '' })); | ||
for (var i in choices) | for (var i in choices) { | ||
var choice = choices[i].trim(); // first and last may carry spaces | |||
var option = $('<option>', {text: choice, value: choice}); | |||
f.append(option); | |||
} | |||
} | } | ||
else { | else { | ||
checkbox = true; | checkbox = true; | ||
f = $('<input>', {type: 'checkbox', value: choices[0], text: choices[0]}) | var choice = choices[0].trim(); | ||
f = $('<input>', {type: 'checkbox', value: choices[0], text: choices[0].trim()}) | |||
.css({float: rtl ? 'right' : 'left'}); | .css({float: rtl ? 'right' : 'left'}); | ||
f.prop('checked', options.defval && options.defval == choices[0]); | f.prop('checked', options.defval && options.defval.trim() == choices[0]); | ||
} | } | ||
} | } | ||
| שורה 536: | שורה 546: | ||
.on('paste cut drop input change', updateRawPreview); | .on('paste cut drop input change', updateRawPreview); | ||
if (options.defval) | if (options.defval && ! checkbox) | ||
f.val(options.defval); | f.val(options.defval.trim()); | ||
if (options.required) | if (options.required) | ||