מדיה ויקי:Gadget-TemplateParamWizard.js: הבדלים בין גרסאות בדף
בג? |
גזר |
||
| שורה 48: | שורה 48: | ||
var name = $.trim(paramPair.shift()); | var name = $.trim(paramPair.shift()); | ||
if (name && paramPair.length) { | if (name && paramPair.length) { | ||
templateParams[name] = templateParams[name] || {}; | templateParams[name] = templateParams[name] || {options: {notInParamPage: 1}}; | ||
$.extend(templateParams[name].options, {'defval': paramPair.join('=')}); | |||
} | } | ||
} | } | ||
| שורה 153: | שורה 153: | ||
case 'able templates category name': return 'תבניות הנתמכות על ידי אשף התבניות'; | case 'able templates category name': return 'תבניות הנתמכות על ידי אשף התבניות'; | ||
case 'template selector title': return 'אנא בחרו תבנית מהרשימה:'; | case 'template selector title': return 'אנא בחרו תבנית מהרשימה:'; | ||
case 'notInParamPage': return 'השדה ' + param + ' לא מופיע ברשימת הפרמטרים של התבנית'; | |||
} | } | ||
| שורה 173: | שורה 174: | ||
case 'able templates category name': throw('Must define category name for wizard-capable templates'); | case 'able templates category name': throw('Must define category name for wizard-capable templates'); | ||
case 'template selector title': return 'Please select a template from this list'; | case 'template selector title': return 'Please select a template from this list'; | ||
case 'notInParamPage': return 'field ' + param + ' does not appear in the template\'s parameters list'; | |||
} | } | ||
| שורה 261: | שורה 263: | ||
timer = setTimeout(function(){lastVisited.tipsy('hide');}, 500); | timer = setTimeout(function(){lastVisited.tipsy('hide');}, 500); | ||
} | } | ||
} | |||
function tipsyContent() { | |||
var | |||
paramName = $(this).text(), | |||
def = templateParams[paramName], | |||
desc = def.desc || ''; | |||
if (def.htmlDesc) | |||
return def.htmlDesc; | |||
if (def.options.notInParamPage) | |||
return i18n('notInParamPage', paramName); | |||
if (/[\[\]\{\}\<\>]/.test(desc)) // does it need parsing? | |||
$.ajax({ | |||
url: mw.util.wikiScript('api'), | |||
async: false, | |||
type: 'post', | |||
data: {action: 'parse', text: desc, disablepp: 1, format: 'json'}, // parse it. | |||
success: function(data) { | |||
var div = $('<div>').html(data.parse.text['*']); | |||
$('a', div).attr({target: '_blank'}); | |||
def.htmlDesc = div.html(); | |||
} | |||
}); | |||
else | |||
def.htmlDesc = desc; | |||
return def.htmlDesc; | |||
} | } | ||
function addRow(paramName, table) { | function addRow(paramName, table) { | ||
var | |||
def = templateParams[paramName], | |||
inputField = createInputField(paramName), | |||
nameColor = def.desc ? 'blue' : (def.options.notInParamPage ? 'red' : 'black'), | |||
tr = $('<tr>') | tr = $('<tr>') | ||
.append( | .append( | ||
$('<td>', {width: 120}) | $('<td>', {width: 120}) | ||
.css({fontWeight: 'bold', color: | .css({fontWeight: 'bold', color: nameColor}) | ||
.text(paramName) | .text(paramName) | ||
.tipsy({html: true, trigger: 'manual', title: tipsyContent}) | .tipsy({html: true, trigger: 'manual', title: tipsyContent}) | ||