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

Contenu supprimé Contenu ajouté
Phe (discussion | contributions)
mAucun résumé des modifications
migration vers le wiki editor
Ligne 1 :
( function ( mw, $, tl ) {
/**
* Setup the TextLayer object:
*/
if ( window.TextLayer === undefined ) {
window.TextLayer = {};
}
 
/**
* The global TextLayer object
*/
( function ( mw, $, tl ) {
'use strict';
 
tl.hasGadget = function hasGadget(name, modules) {
return $.inArray('ext.gadget.' + name, modules) != -1;
}
 
tl.function setText = function(text) {
var $text_box1 = $('#wpTextbox1');
if (!$text_box1.length) {
Ligne 26 ⟶ 16 :
var modules = mw.loader.getModuleNames();
 
if (tl.hasGadget('MiseEnPage', modules)) {
window.mise_en_page.exec('auto_create');
}
 
if (tl.hasGadget('Typo', modules)) {
$.typo.exec();
}
};
 
tl.function getTextLayer = function(djvuname, page_nr) {
$.ajax({
url: mw.util.wikiScript( 'api' ),
Ligne 59 ⟶ 49 :
}
if (text) {
tl.setText(text);
}
}
});
};
 
tl.onClick = function() {
var datas = mw.config.get('wgTitle').split('/');
tl.getTextLayer(datas[0], datas[1]);
};
 
tl.editForm = function () {
window.insert_button.editForm( {
'img_classic' : '//upload.wikimedia.org/wikisource/fr/1/1d/TL.png',
'img_advanced' : '//upload.wikimedia.org/wikisource/fr/1/1d/TL.png',
'tooltip' : 'Remplace le texte de la Page: actuel par la couche texte',
'img_id' : 'wsTextLayer',
'on_click' : tl.onClick
} );
};
 
if ($.inArray(mw.config.get('wgAction'), ['edit', 'submit']) !== -1 && mw.config.get('wgCanonicalNamespace') == 'Page') {
mw.loader.using('ext.wikiEditor', function() {
$.when(
tl.onClick = $(function() {
mw.loader.using( [ 'ext.gadget.InsertButton' ] )
$('#wpTextbox1').wikiEditor('addToToolbar', {
).then(
section: 'advanced',
tl.editForm
group: 'format',
);
tools: {
'textLayer': {
'tooltip' label: 'Remplace le texte de la Page: actuel par la couche texte',
type: 'button',
'img_classic' icon: '//upload.wikimedia.org/wikisource/fr/1/1d/TL.png',
action: {
type: 'callback',
execute: function() {
var datas = mw.config.get('wgTitle').split('/');
tl. getTextLayer(datas[0], datas[1]);
}
}
}
}
});
});
} });
}
}( mediaWiki, jQuery, window.TextLayer ) );