מדיה ויקי:Gadget-TemplateParamWizard.js: הבדלים בין גרסאות בדף

מ שחזור לגרסה 31630591 מ־10:31, 21 ביוני 2021 מאת עלי בדיקה
מ 148 גרסאות של הדף wikipedia:he:מדיה_ויקי:Gadget-TemplateParamWizard.js יובאו
 
(9 גרסאות ביניים של 3 משתמשים אינן מוצגות)
שורה 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 (Array.isArray(tp.options.choices) && !tp.options.choices.includes(val))
if ( typeof tp.options.choices === 'string' && tp.options.choices.indexOf( val ) < 0 )
tp.options.choices.push(val);  
tp.options.choices += ( ', ' + val );  
}
}
}
}
שורה 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) {
var param = params[name];
var param = params[name];
if (param.deprecated)
return; // ignore deprecated parameters - pretend they are not in TD.
templateParams[name] = {  
templateParams[name] = {  
desc: param.description || '',  
desc: param.description || '',  
options: { required: param.required, choices: param.suggestedvalues },  
options: optionsOfParam(param),  
label: param.label || name,  
label: param.label || name,  
param: param  
param: param  
שורה 390: שורה 398:
}
}
break;
break;
case 'ru':
switch (key) {
case 'explain': return 'поля с красной рамкой обязательны, остальные - по желанию';
case 'wizard dialog title': return 'Настройте параметры для шаблона: ' + template;
case 'ok': return 'OK';
case 'cancel': return 'Отмена';
case 'params subpage': return 'Параметры';
case 'preview': return 'Просмотр';
case 'options select': return 'Выбрать:';
case 'multiline': return 'Многострочный вид';
case 'close': return 'Закрыть';
case 'required': return 'Необходимое';
case 'depends': return 'Зависит от';
case 'defval': return 'По умолчанию';
case 'choices': return 'Выбор';
case 'date': return 'Дата';
case 'extended': return 'Расширенный';
case 'button hint': return 'Мастер параметров шаблона';
case 'able templates category name': throw('Необходимо определить название категории для шаблонов с поддержкой мастера');
case 'template selector title': return 'Пожалуйста, введите имя шаблона';
case 'notInParamPage': return 'поле "' + param + '" не отображается в списке параметров шаблона';
case 'editParamPage': return 'Править страницу параметров';
case 'unknown error': return 'Произошла ошибка: \n' + param;
case 'please select template': return 'Пожалуйста, введите имя шаблона';
case 'oneliner': return 'Однострочный вид';
case 'dateFormat': return 'ММ дд, гг';
case 'extended labels': return 'Показать все параметры';
}
default:
default:
switch (key) {
switch (key) {
שורה 443: שורה 479:
}
}
function templatePage() {return mw.config.get('wgFormattedNamespaces')[10] + ':' + $.trim(template);}
function templatePage() {
var t = $.trim(template)
return t.match(':') ? t : mw.config.get('wgFormattedNamespaces')[10] + ':' + t;
}


function updateRawPreview(){
function updateRawPreview(){
שורה 506: שורה 545:
checkbox = false;
checkbox = false;


if (Array.isArray(options.choices) && options.choices.length) {
if (options.choices) {
var choices = options.choices;
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) {
f.append($('<option>', {text: choices[i], value: choices[i]}));
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: שורה 579:
.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)
שורה 567: שורה 610:
function tipsyContent() {
function tipsyContent() {
var
var
paramName = $(this).text(),
paramName = $(this).data('paramname'),
def = templateParams[paramName],
def = templateParams[paramName],
desc = def && def.desc || '';
desc = def && def.desc || '';
שורה 605: שורה 648:
$('<td>', {width: 120})
$('<td>', {width: 120})
.css({fontWeight: 'bold', color: nameColor})
.css({fontWeight: 'bold', color: nameColor})
.data({ paramname: paramName })
.text(templateParams[paramName].label || paramName)
.text(templateParams[paramName].label || paramName)
.tipsy({html: true, trigger: 'manual', title: tipsyContent})
.tipsy({html: true, trigger: 'manual', title: tipsyContent})
שורה 640: שורה 684:


function buildDialog(data) {
function buildDialog(data) {
var title = $('<span>').html(i18n('wizard dialog title', template));
$('.tpw_disposable').remove();
$('.tpw_disposable').remove();
if (rawTemplate)
if (rawTemplate)
buildParamsRaw(data);
buildParamsRaw(data);
else if (tdTemplate)  
else if (tdTemplate) {
buildParamsTd(data);
buildParamsTd(data);
if (data.description) title.find('a').attr({ title: data.description });
}
paramsFromSelection();
paramsFromSelection();
שורה 650: שורה 698:
var dialog = $('<div>', {'class': 'tpw_disposable'})
var dialog = $('<div>', {'class': 'tpw_disposable'})
.dialog({height: 'auto',
.dialog({height: 'auto',
title: i18n('wizard dialog title', template),
title: title.html(),
width: 'auto',
width: 'auto',
overflow: 'auto',
overflow: 'auto',