ব্যবহারকারী:R1F4T/test2.js
অবয়ব
লক্ষ্য করুন: প্রকাশ করার পর, পরিবর্তনগুলো দেখতে আপনাকে আপনার ব্রাউজারের ক্যাশে পরিষ্কার করার প্রয়োজন হতে পারে।
- ফায়ারফক্স / সাফারি: পুনরায় লোড-এ ক্লিক করার সময় শিফট টিপে ধরে রাখুন, অথবা হয় Ctrl-F5 বা Ctrl-R টিপুন (ম্যাকে ⌘-R টিপুন)
- গুগল ক্রোম: Ctrl-Shift-R (ম্যাকে ⌘-Shift-R) টিপুন
- এজ: Ctrl ধরে রাখা অবস্থায় Refresh-এ ক্লিক করুন, অথবা Ctrl-F5 টিপুন।
- অপেরা: Ctrl-F5 টিপুন।
// Load the OOUI library
mw.loader.using( 'oojs-ui-windows' ).then( function () {
// Define a simple dialog class
function WikidataSearchDialog( config ) {
WikidataSearchDialog.super.call( this, config );
}
OO.inheritClass( WikidataSearchDialog, OO.ui.Dialog );
// Specify the size and title of the dialog
WikidataSearchDialog.static.name = 'wikidataSearchDialog';
WikidataSearchDialog.static.title = 'Wikidata';
WikidataSearchDialog.static.size = 'medium';
// Set up the content of the dialog
WikidataSearchDialog.prototype.initialize = function () {
WikidataSearchDialog.super.prototype.initialize.apply( this, arguments );
// Create a search input widget
var searchInput = new OO.ui.SearchInputWidget({
placeholder: 'Search Wikidata'
});
// Set the content of the dialog to be just the search input
this.$body.append( searchInput.$element );
};
// Create the window manager and add the dialog
var windowManager = new OO.ui.WindowManager();
$( 'body' ).append( windowManager.$element );
var wikidataSearchDialog = new WikidataSearchDialog();
windowManager.addWindows( [ wikidataSearchDialog ] );
// Add a button to the sidebar that opens the dialog
var portletLink = mw.util.addPortletLink(
'p-tb', // This is the id of the "Tools" section in the sidebar
'#', // We'll use JavaScript to open the dialog, so the href is just '#'
'Search Wikidata', // The link text
't-wikidataSearch', // The link id
'Search Wikidata' // The title text (tooltip)
);
$( portletLink ).click( function ( e ) {
e.preventDefault(); // Prevent the browser from navigating to '#'
windowManager.openWindow( wikidataSearchDialog );
});
});