« MediaWiki:Gadget-CreerNouveauMot.js » : différence entre les versions

Contenu supprimé Contenu ajouté
fix : ajout code langue aux modèle {{M|au singulier uniquement}} et {{M|au pluriel uniquement}}
changement des liens de recherche vers les autres projets en fonction de la langue choisie
Ligne 20 :
* v5.0.3 2020-08-05 added date template in etymology section
* v5.0.4 2020-08-05 reordering level 4 sections
* v5.0.5 2020-08-10 sister projects search links now update on language selection
* ------------------------------------------------------------------------------------
* [[Catégorie:JavaScript du Wiktionnaire|CreerNouveauMot.js]]
Ligne 39 ⟶ 40 :
*/
_OTHER_PROJECTS: {
w: {label: "Wikipédia", templateName: "WP", urlDomain: "fr{0}.wikipedia.org"},
s: {label: "Wikisource", templateName: "WS", urlDomain: "fr{0}.wikisource.org"},
q: {label: "Wikiquote", templateName: "WQ", urlDomain: "fr{0}.wikiquote.org"},
v: {label: "Wikiversité", templateName: "WV", urlDomain: "fr{0}.wikiversity.org"},
l: {label: "Wikilivres", templateName: "WL", urlDomain: "fr{0}.wikibooks.org"},
species: {label: "Wikispecies", templateName: "WSP", urlDomain: "wikispecies.org"},
voy: {label: "Wikivoyage", templateName: "VOY", urlDomain: "fr{0}.wikivoyage.org"},
n: {label: "Wikinews", templateName: "WN", urlDomain: "fr{0}.wikinews.org"},
c: {label: "Commons", templateName: "Commons", urlDomain: "commons.wikimedia.org"},
vikidia: {label: "Vikidia", templateName: "Vikidia", urlDomain: "{0}.vikidia.org"},
dicoado: {label: "Le Dico des Ados", templateName: "Dicoado", urlDomain: "dicoado.org", urlBase: "dico"},
},
 
Ligne 541 ⟶ 544 :
wikt.gadgets.creerNouveauMot.Gui.call(this);
 
this._word = word;
/**
* Tabs list.
Ligne 567 ⟶ 571 :
this._seeOtherProjectsChk = {};
this._sortKeyFld = null;
this._otherProjects = otherProjects;
 
// Deleting all content above edit box.
Ligne 781 ⟶ 786 :
var linksEnabled = false;
 
for (var projectCode in otherProjectsself._otherProjects) {
if (otherProjectsself._otherProjects.hasOwnProperty(projectCode)) {
// * DO NOT REMOVE FUNCTION *
// This function in necessary to avoid “textFld”
// changing value in checkbox.on() after each iteration.
(function () {
var projectName = otherProjectsself._otherProjects[projectCode].label;
var projectDomain = otherProjects[projectCode].urlDomain;
var checkbox = new OO.ui.CheckboxInputWidget({
value: projectCode,
Ligne 806 ⟶ 810 :
"textfield": textFld,
};
 
var url = "https://{0}/wiki/{1}".format(projectDomain, encodeURI(word));
// noinspection HtmlUnknownTarget
var label = new OO.ui.HtmlSnippet('<a href="{0}" target="_blank">Rechercher</a>'.format(url));
 
otherProjectsFields.push(new OO.ui.ActionFieldLayout(
Ligne 816 :
{
align: "inline",
id: "cnm-sister-project-{0}".format(projectCode),
label: labelnew OO.ui.HtmlSnippet('<a href="#" target="_blank">Rechercher</a>'),
}
));
Ligne 981 :
// gadgetBox.$element.removeClass("oo-ui-fieldLayout-align-left");
 
for (var projectCode in otherProjectsself._otherProjects) {
if (otherProjectsself._otherProjects.hasOwnProperty(projectCode)) {
$("#sister-project-{0} span.oo-ui-actionFieldLayout-button".format(projectCode)).attr("style", "width: 100%");
$("#sister-project-{0} span.oo-ui-fieldLayout-field".format(projectCode)).attr("style", "width: 100%");
Ligne 1 025 :
}
this._updateFields(language);
this._updateSisterProjectsLinks(language);
this._languageSelectFld.getMenu().selectItemByData(language.code);
this._pronunciationPnl.setLabel(this._formatApi(language.ipaSymbols));
Ligne 1 074 ⟶ 1 075 :
this._pronunciationFld.setDisabled(language.code === "conv");
};
 
/**
* Updates the link search links to sister projects based on the selected language.
* @param language {wikt.gadgets.creerNouveauMot.Language} The selected language.
* @private
*/
wikt.gadgets.creerNouveauMot.MainGui.prototype._updateSisterProjectsLinks = function (language) {
for (var projectCode in this._otherProjects) {
if (this._otherProjects.hasOwnProperty(projectCode)) {
var projectDomain = otherProjectsthis._otherProjects[projectCode].urlDomain;
var urlBase = this._otherProjects[projectCode].urlBase || "wiki";
var $link = $("#cnm-sister-project-{0} a".format(projectCode));
var url = this._generateProjectLink(projectDomain, urlBase, language.code, this._word);
$link.attr("href", url);
if (url === "#") {
$link.hide();
}
else {
$link.show();
}
}
}
}
 
// noinspection JSValidateJSDoc
Ligne 1 149 ⟶ 1 173 :
return $links;
};
 
/**
* Generates the URL to the given sister project’s search page.
* @param projectDomain {string} Project’s domain name.
* @param urlBase {string} The base URL (usually wiki).
* @param langCode {string} Project’s domain language code.
* @param word {string} The word to search for.
* @return {string} The search URL.
*/
wikt.gadgets.creerNouveauMot.MainGui.prototype._generateProjectLink = function (projectDomain, urlBase, langCode, word) {
if (langCode !== "conv") {
projectDomain = projectDomain.format(langCode);
var url =return "https://{0}/wiki/{1}/{2}".format(projectDomain, urlBase, encodeURI(word));
}
return "#";
}
 
/*