Form:SMW e MediaWiki:MarcEditorDynamicLinks.js: mudanças entre as páginas
(Diferenças entre páginas)
Ir para navegação
Ir para pesquisar
m (Substituição de texto - "text with autocomplete" por "combobox") Etiquetas: Edição móvel Edição feita através do site móvel |
Sem resumo de edição |
||
Linha 1: | Linha 1: | ||
/* jshint esversion: 10 */ |
|||
<includeonly>=SMW= |
|||
function main() { |
|||
{{{info|create title=Criar|edit title=Editar}}} |
|||
// calling main functions |
|||
<div id="wikiPreview" style="display: none; padding-bottom: 25px; margin-bottom: 25px; border-bottom: 1px solid #AAAAAA;"></div> |
|||
makeMarcFieldHelpLink(); |
|||
{{{for template|SMW}}} |
|||
authorityLinks(); |
|||
{| class="formtable" |
|||
rmCarriageReturn(); |
|||
! Has type: |
|||
rmHtmlTags(); |
|||
| {{{field|hasType|size=100|default=Text|placeholder=Text}}} |
|||
|- |
|||
! Imported from: |
|||
| {{{field|importedFrom|size=100|input type=combobox|values from property=Imported from|placeholder=dc:creator}}} |
|||
|- |
|||
! Source: |
|||
| {{{field|source|size=100|input type=combobox|values from property=Source|delimiter=;|placeholder=RDA 6.9}}} |
|||
|- |
|||
! Source (URL): |
|||
| {{{field|url|size=100|input type=combobox|values from property=Has uniform resource locator|delimiter=;|placeholder=URL}}} |
|||
|- |
|||
! Allows value: |
|||
| {{{field|allowsValue|size=100|input type=combobox|values from property=Allows value|delimiter=;|placeholder=yes; no; true; false;}}} |
|||
|- |
|||
! Allows value list: |
|||
| {{{field|allowsValueList|size=100|input type=combobox|values from property=Allows value list}}} |
|||
|- |
|||
! Allows pattern: |
|||
| {{{field|allowsPattern|size=100|input type=combobox|values from property=Allows pattern}}} |
|||
|- |
|||
! Subproperty of: |
|||
| {{{field|subpropertyOf|size=100|input type=combobox|values from namespace=Propriedade|delimiter=;|placeholder=Creator}}} |
|||
|- |
|||
! Schema: |
|||
| {{{field|schema|size=100|input type=combobox|values from namespace=smw/schema|delimiter=;|placeholder=Profile:Sequence}}} |
|||
|- |
|||
! Has default form: |
|||
| {{{field|hasDefaultForm|size=100|input type=combobox|values from namespace=Form|placeholder=Agent}}} |
|||
|- |
|||
! Creates pages with form: |
|||
| {{{field|createsPagesWithForm|size=100|input type=combobox|values from namespace=Form|placeholder=Agent}}} |
|||
|- |
|||
! Note: |
|||
| {{{field|note|size=100|input type=combobox|placeholder=Propriedade desencorajada no Wikincat}}} |
|||
|} |
|||
{{{end template}}} |
|||
// Como instâncias do formulário são criadas pelo botão "Adicionar campo", |
|||
{{{standard input|free text|rows=10}}} |
|||
// é necessário observar o DOM a partir da classe ".multipleTemplateList". |
|||
// Toda vez que o DOM é alterado (mais especificamente, quando uma nova |
|||
// child de ".multipleTemplateList" é criada), as funções |
|||
// makeMarcFieldHelpLink() e authorityLinks() são novamente chamadas. |
|||
// https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver |
|||
// create an observer instance |
|||
{{{standard input|save}}} {{{standard input|preview}}} {{{standard input|changes}}} {{{standard input|cancel}}} |
|||
const observer = new MutationObserver((mutations) => { |
|||
</includeonly> |
|||
mutations.forEach((mutation) => { |
|||
const newNodes = mutation.addedNodes; // DOM NodeList |
|||
if (newNodes.length !== 0) { |
|||
// if there are new nodes added |
|||
makeMarcFieldHelpLink(); |
|||
authorityLinks(); |
|||
} |
|||
}); |
|||
}); |
|||
// select the target node |
|||
const target = document.querySelector('.multipleTemplateList'); |
|||
// configuration of the observer |
|||
const config = { |
|||
childList: true, |
|||
attributes: false, |
|||
subtree: false, |
|||
}; |
|||
// pass in the target node, as well as the observer options |
|||
observer.observe(target, config); |
|||
// when clicking save... |
|||
const saveBtn = document.body.querySelector('#wpSave'); |
|||
saveBtn.addEventListener('click', () => { |
|||
observer.disconnect(); |
|||
rmTxtFromHiddenFields(); |
|||
rmCarriageReturn(); |
|||
rmHtmlTags(); |
|||
normalizeInput(); |
|||
}); |
|||
} |
|||
document.addEventListener('DOMContentLoaded', function (event) { |
|||
main(); |
|||
}); |
|||
// for no obvious reason to me, the first call to the "main" function is not |
|||
// occurring, so wait 3 seconds and call it anyway. |
|||
setTimeout(main, 3000); |
Edição das 13h40min de 18 de março de 2024
/* jshint esversion: 10 */
function main() {
// calling main functions
makeMarcFieldHelpLink();
authorityLinks();
rmCarriageReturn();
rmHtmlTags();
// Como instâncias do formulário são criadas pelo botão "Adicionar campo",
// é necessário observar o DOM a partir da classe ".multipleTemplateList".
// Toda vez que o DOM é alterado (mais especificamente, quando uma nova
// child de ".multipleTemplateList" é criada), as funções
// makeMarcFieldHelpLink() e authorityLinks() são novamente chamadas.
// https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
// create an observer instance
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
const newNodes = mutation.addedNodes; // DOM NodeList
if (newNodes.length !== 0) {
// if there are new nodes added
makeMarcFieldHelpLink();
authorityLinks();
}
});
});
// select the target node
const target = document.querySelector('.multipleTemplateList');
// configuration of the observer
const config = {
childList: true,
attributes: false,
subtree: false,
};
// pass in the target node, as well as the observer options
observer.observe(target, config);
// when clicking save...
const saveBtn = document.body.querySelector('#wpSave');
saveBtn.addEventListener('click', () => {
observer.disconnect();
rmTxtFromHiddenFields();
rmCarriageReturn();
rmHtmlTags();
normalizeInput();
});
}
document.addEventListener('DOMContentLoaded', function (event) {
main();
});
// for no obvious reason to me, the first call to the "main" function is not
// occurring, so wait 3 seconds and call it anyway.
setTimeout(main, 3000);