מדיה ויקי:Common.js: הבדלים בין גרסאות בדף
Make the table appear only after the collapsible styles are loaded, so that it won't delay showing the search results |
אין תקציר עריכה |
||
| (51 גרסאות ביניים של 10 משתמשים אינן מוצגות) | |||
| שורה 13: | שורה 13: | ||
for ( var arg = 0; arg < args.length; arg++ ) { | for ( var arg = 0; arg < args.length; arg++ ) { | ||
try { | try { | ||
importScript( | importScript( 'MediaWiki:סקריפטים/' + args[arg] + '.js' ); | ||
} | } | ||
catch(e) { | catch( e ) { | ||
} | } | ||
} | } | ||
| שורה 25: | שורה 25: | ||
// Deprecated | // Deprecated | ||
} | } | ||
mw.loader.using( 'mediawiki.util', function () { | mw.loader.using( 'mediawiki.util', function () { | ||
| שורה 44: | שורה 41: | ||
} | } | ||
} | } | ||
if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) { | |||
mw.loader.load( 'ext.gadget.ime' ); | |||
if ( mw.config.get( ' | |||
} | } | ||
// סקריפטים עבור אנונימיים ו/או | // סקריפטים עבור אנונימיים ו/או חדשיםs | ||
if ( $.inArray( 'autoconfirmed', mw.config.get( 'wgUserGroups' ) ) === -1 ) { | if ( $.inArray( 'autoconfirmed', mw.config.get( 'wgUserGroups' ) ) === -1 ) { | ||
importScript( 'MediaWiki:Autopurge.js' ); // הוספת אפשרות לרענון אוטומטי על ידי אנונימיים, ללא מעבר בטופס | importScript( 'MediaWiki:Autopurge.js' ); // הוספת אפשרות לרענון אוטומטי על ידי אנונימיים, ללא מעבר בטופס | ||
| שורה 74: | שורה 58: | ||
!$( '#wpTextbox1' ).prop( 'readonly' ) | !$( '#wpTextbox1' ).prop( 'readonly' ) | ||
) { | ) { | ||
importScript( 'MediaWiki:Templateslist.js' ); // הצגת רשימת תבניות | importScript( 'MediaWiki:Templateslist.js' ); // הצגת רשימת תבניות | ||
importScript( 'MediaWiki:Nosaving.js' ); // חיוב תצוגה מקדימה למשתמשים אנונימיים | importScript( 'MediaWiki:Nosaving.js' ); // חיוב תצוגה מקדימה למשתמשים אנונימיים | ||
| שורה 153: | שורה 136: | ||
} | } | ||
// create an event when | // create an event when util.addPortletLink() is called, so scripts that manipulate menus ca readjust. | ||
var oldFunc = mw.util.addPortletLink; | var oldFunc = mw.util.addPortletLink; | ||
if ( typeof oldFunc === 'function' ) { | if ( typeof oldFunc === 'function' ) { | ||
| שורה 166: | שורה 149: | ||
if ( $.inArray( mw.config.get( 'wgPageName' ), [ | if ( $.inArray( mw.config.get( 'wgPageName' ), [ | ||
'ויקיפדיה:בוקמרקלטים', | |||
'שיחת_ויקיפדיה:בוקמרקלטים' | |||
] ) + 1 ) { | ] ) + 1 ) { | ||
importScript( 'MediaWiki:bookmarkletsInit.js' ); // דף הבוקמרקלטים | importScript( 'MediaWiki:bookmarkletsInit.js' ); // דף הבוקמרקלטים | ||
| שורה 175: | שורה 158: | ||
importScript( 'MediaWiki:SearchEngines.js' ); // בחירה במנועי חיפוש שונים | importScript( 'MediaWiki:SearchEngines.js' ); // בחירה במנועי חיפוש שונים | ||
importScript( 'Mediawiki:Gadget-advanceSearch.js' ); | importScript( 'Mediawiki:Gadget-advanceSearch.js' ); | ||
} | } | ||
/* | /* | ||
* Adds an automatic | * Adds an automatic '{{תב|מוגן}}' or '{{תב|מוגן חלקית}}' template when the page is protected. | ||
* You can use the {{תב|ללא הודעת הגנה אוטומטית}} to prevent the protection notice from being inserted. | * You can use the {{תב|ללא הודעת הגנה אוטומטית}} to prevent the protection notice from being inserted. | ||
* | * | ||
| שורה 192: | שורה 167: | ||
* | * | ||
*/ | */ | ||
$(function(){ | |||
var restrictionEdit = mw.config.get('wgRestrictionCreate') || mw.config.get('wgRestrictionEdit'); | |||
if( restrictionEdit && | |||
restrictionEdit.length > 0 && | |||
( | |||
restrictionEdit[0] === 'sysop' || | |||
restrictionEdit[0] === 'autoconfirmed' || | |||
restrictionEdit[0] === 'templateeditor' || | |||
restrictionEdit[0] === 'editautopatrolprotected' | |||
) && | |||
$( '#pl-noprotectionnotice, #pl-autoconfirmed, #pl-protected' ).length === 0 && | |||
( $.inArray( mw.config.get( 'wgAction' ), [ 'view', 'submit' ] ) + 1 ) | |||
) { | |||
var restrictionEditMapping = { | |||
'sysop': 'מוגן', | |||
'templateeditor': 'הגנת ממשק', | |||
'editautopatrolprotected': 'הגנה מוגברת', | |||
'autoconfirmed': 'מוגן חלקית' | |||
}; | |||
$.get( mw.util.wikiScript( 'api' ), { | |||
action: 'parse', | |||
format: 'json', | |||
text: '{{' + restrictionEditMapping[restrictionEdit[0]] + '}}', | |||
prop: 'text|indicators', | |||
title: mw.config.get('wgPageName'), | |||
contentmodel: 'wikitext' | |||
}, function( data ) { | |||
$( function () { | |||
} | $( '.printfooter' ).before( $( '<div>', { | ||
'class': 'plprotected', | |||
'html': data.parse.text['*'] | |||
} ) ); | |||
var newList = []; | |||
$.each( data.parse.indicators, function ( name, indicator ) { | |||
newList.push( | |||
$( '<div>' ) | |||
.addClass( 'mw-indicator' ) | |||
.attr( 'id', mw.util.escapeIdForAttribute( 'mw-indicator-' + indicator.name ) ) | |||
.html( indicator['*'] ) | |||
.get( 0 ), | |||
// Add a whitespace between the <div>s because | |||
// they get displayed with display: inline-block | |||
document.createTextNode( '\n' ) | |||
); | |||
} ); | |||
$( '.mw-indicators' ).append( newList ); | |||
} ); | |||
} ); | } ); | ||
} | } | ||
}); | |||
} ); | } ); | ||
// search meta-commands: make the table display clickabe keywords. | // search meta-commands: make the table display clickabe keywords. | ||
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ) { | if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ) { | ||
mw.hook( 'he.wikipedia.collapsetables.loaded' ).add( function () { | |||
$( 'span.mw-search-meta-string' ).wrap( $( '<a>' ) | 'use strict'; | ||
var $searchBox = $( '#searchText input' ), | |||
$metaStringsTable = $( '#mw-search-meta-strings' ); | |||
$metaStringsTable.find( 'span.mw-search-meta-string' ).wrap( $( '<a>' ) | |||
.click( function( e ) { | .click( function( e ) { | ||
var currentText, newText; | |||
e.preventDefault(); | e.preventDefault(); | ||
searchBox.val ( | currentText = $searchBox.val(); | ||
newText = $( this ).text(); | |||
$searchBox.val( currentText + newText ); | |||
} ) | } ) | ||
); | ); | ||
// Make the table appear only after the collapsible styles are loaded, | |||
// so that it won't delay showing the search results | |||
$metaStringsTable.css( 'display', 'table' ); | |||
} ); | } ); | ||
} | } | ||
// | // On demand loading of scripts and gadgets, initial version from ruwiki. | ||
// Detects uses of template "טען סקריפט" | |||
// and loads specifically-named scripts or gadgets. | |||
// for a gadget, its name as defined in gadgets-definition must begin with "ondemand-" | |||
if ( mw.config.get('wgCanonicalNamespace') !== 'Special' ) | |||
mw.hook( 'wikipage.content' ).add( function( content ) { | mw.hook( 'wikipage.content' ).add( function( content ) { | ||
var beenthere = {}; | |||
$( '.executeJS', content ).each( function () { | |||
var gadget = $( this ).data( 'gadgetname' ); | |||
if ( gadget && $.trim( gadget ) ) mw.loader.load( 'ext.gadget.ondemand-' + $.trim( gadget ) ); // np repetitions - resourceloader takes care | |||
} ); | } ); | ||
} ); | } ); | ||