Common.js: Unterschied zwischen den Versionen
Zeile 38: | Zeile 38: | ||
}; | }; | ||
− | / | + | loadCSS( "https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" ); |
+ | |||
+ | |||
first().then(second).done(function(){ | first().then(second).done(function(){ | ||
console.log("LAZY LOAD 04.0 done"); | console.log("LAZY LOAD 04.0 done"); | ||
Zeile 44: | Zeile 46: | ||
//acromap.html("MAP"); | //acromap.html("MAP"); | ||
}); | }); | ||
− | |||
+ | /* | ||
$.when( | $.when( | ||
$.getScript( "https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" ), | $.getScript( "https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" ), | ||
Zeile 57: | Zeile 59: | ||
} | } | ||
); | ); | ||
+ | */ | ||
Version vom 7. Mai 2020, 00:44 Uhr
/* Das folgende JavaScript wird für alle Benutzer geladen. */ $(function () { /***********************************************************************************************************************/ // var myElement = document.getElementById('mw-mywiki-example'); // myElement.innerHTML = 'any HTML'; // Lazy Load Acro Map $(document).ready(function() { var acromap = $( "#acromap" ); if ( $("#mapid").length ) { acromap.html("........."); function first() { return $.getScript( "https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" ); } function css(data, textStatus, jqXHR) { return $.getStylesheet( "https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" ); } function second(data, textStatus, jqXHR) { return $.getScript( "https://wiki.acrotricks.com/w/resources/lib/acromap/script.js" ); } loadCSS = function(href) { var cssLink = $("<link>"); $("head").append(cssLink); //IE hack: append before setting href cssLink.attr({ rel: "stylesheet", type: "text/css", href: href }); }; loadCSS( "https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" ); first().then(second).done(function(){ console.log("LAZY LOAD 04.0 done"); //place your code here, the scripts are all loaded //acromap.html("MAP"); }); /* $.when( $.getScript( "https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" ), loadCSS( "https://unpkg.com/leaflet@1.6.0/dist/leaflet.css" ) ) .then( $.getScript( "https://wiki.acrotricks.com/w/resources/lib/acromap/script.js" ), function () { console.log('an error occurred somewhere'); } ); */ /* $.when( $.getScript( "https://unpkg.com/leaflet@1.6.0/dist/leaflet.js" ), $.getScript( "https://wiki.acrotricks.com/w/resources/lib/acromap/script.js" ), $.Deferred(function( deferred ){ $( deferred.resolve ); }) ).done(function(){ console.log("LAZY LOAD 04.0"); //place your code here, the scripts are all loaded //acromap.html("MAP"); }); */ } }); /***************************/ var customizeToolbar = function () { /* Your code goes here */ /***************************/ /* $('#wpTextbox1').wikiEditor('addToToolbar', { section: 'advanced', group: 'format', tools: { "strikethrough": { label: 'Strike', type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/3/30/Btn_toolbar_rayer.png', action: { type: 'encapsulate', options: { pre: "<s>", post: "</s>" } } } } }); */ /* $( '#wpTextbox1' ).wikiEditor( 'addToToolbar', { 'section': 'emoticons', 'group': 'faces', 'tools': { 'smile': { label: 'Smile!', // or use labelMsg for a localized label, see above type: 'button', icon: '//upload.wikimedia.org/wikipedia/commons/thumb/a/a4/Gnome-face-smile.svg/22px-Gnome-face-smile.svg.png', action: { type: 'encapsulate', options: { pre: ":)" // text to be inserted } } } } }); */ /***************************/ }; /* Check if view is in edit mode and that the required modules are available. Then, customize the toolbar … */ if ( [ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) !== -1 ) { mw.loader.using( 'user.options' ).then( function () { // This can be the string "0" if the user disabled the preference ([[phab:T54542#555387]]) if ( mw.user.options.get( 'usebetatoolbar' ) == 1 ) { $.when( mw.loader.using( 'ext.wikiEditor' ), $.ready ).then( customizeToolbar ); } } ); } /***********************************************************************************************************************/ }());