מדיה ויקי: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( "MediaWiki:סקריפטים/" + args[arg] + ".js" );
importScript( 'MediaWiki:סקריפטים/' + args[arg] + '.js' );
}
}
catch(e) {
catch( e ) {
}
}
}
}
שורה 25: שורה 25:
// Deprecated
// Deprecated
}
}
/* פונקציה לקבלת ערך של פרמטר משורת הכתובת */
mw.log.deprecate( window, 'getParamValue', mw.util.getParamValue, 'Use mediawiki.util instead.' );


mw.loader.using( 'mediawiki.util', function () {
mw.loader.using( 'mediawiki.util', function () {
שורה 44: שורה 41:
}
}
}
}
 
// סקריפטים כלליים
if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) {
importScript( 'MediaWiki:Collapsetables.js' ); // טבלאות מוסתרות
mw.loader.load( 'ext.gadget.ime' );
importScript( 'MediaWiki:Tabs.js' ); // תמיכה בלשוניות
importScript( 'MediaWiki:ImgToggle.js' ); // החלפת תמונות, עבור [[תבנית:מפת מיקום]]
importScript( 'MediaWiki:LoadingContent.js' ); // הצגת טקסטים הנטענים באופן דינמי
importScript( 'Mediawiki:Imagemap-Highlight.js' ); // עבור [[תבנית:מפת תמונה]] עם סימון=כן
 
if ( mw.config.get( 'wgAction' ) === 'history' ) {
importScript( 'MediaWiki:FixHistPage.js' );     // הסתרת קישורים ותיבות checkbox בדף ההיסטוריה והוספת אפשרות להפעלתם באמצעות כפתור מתאים.
}
}


if ( mw.config.get( 'wgNamespaceNumber' ) === 6 ) {
try {
mw.loader.load( '//tools.wmflabs.org/imagemapedit/ime.js' );
}
catch( e ) {
} // surround with try/catch in case other server behaves badly.
}


// סקריפטים עבור אנונימיים ו/או חדשים
// סקריפטים עבור אנונימיים ו/או חדשים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:Edittoolbar.js' ); // תוספות לסרגל העריכה
importScript( 'MediaWiki:Templateslist.js' ); // הצגת רשימת תבניות
importScript( 'MediaWiki:Templateslist.js' ); // הצגת רשימת תבניות
importScript( 'MediaWiki:Nosaving.js' ); // חיוב תצוגה מקדימה למשתמשים אנונימיים
importScript( 'MediaWiki:Nosaving.js' ); // חיוב תצוגה מקדימה למשתמשים אנונימיים
שורה 153: שורה 136:
}
}


// create an event when "addportellink" is called, so scripts that manipulate menus ca readjust.
// 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' );
}
// Adding results from Wikidata to search, when a page doesn't exist:
if ( mw.config.get( 'wgCanonicalSpecialPageName' ) === 'Search' ||
( mw.config.get( 'wgArticleId' ) === 0 && mw.config.get( 'wgCanonicalSpecialPageName' ) === false )
) {
mw.loader.load( '//en.wikipedia.org/w/index.php?title=MediaWiki:Wdsearch.js&action=raw&ctype=text/javascript' );
}
}


/*
/*
* Adds an automatic "{{תב|מוגן}}" or "{{תב|מוגן חלקית}}" template when the page is protected.
* 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:
*
*
*/
*/
var restrictionEdit = mw.config.get('wgRestrictionCreate') || mw.config.get('wgRestrictionEdit');
$(function(){
if( restrictionEdit &&
var restrictionEdit = mw.config.get('wgRestrictionCreate') || mw.config.get('wgRestrictionEdit');
restrictionEdit.length > 0 &&
if( restrictionEdit &&
(
restrictionEdit.length > 0 &&
restrictionEdit[0] === 'sysop' ||
(
restrictionEdit[0] === 'autoconfirmed' ||
restrictionEdit[0] === 'sysop' ||
restrictionEdit[0] === 'autopatrol'
restrictionEdit[0] === 'autoconfirmed' ||
) &&
restrictionEdit[0] === 'templateeditor' ||
$( '#pl-noprotectionnotice, #pl-autoconfirmed, #pl-protected' ).length === 0 &&
restrictionEdit[0] === 'editautopatrolprotected'
( $.inArray( mw.config.get( 'wgAction' ), [ 'view', 'submit' ] ) + 1 )
) &&
) {
$( '#pl-noprotectionnotice, #pl-autoconfirmed, #pl-protected' ).length === 0 &&
var restrictionEditMapping = {
( $.inArray( mw.config.get( 'wgAction' ), [ 'view', 'submit' ] ) + 1 )
'sysop': 'מוגן',
) {
'autopatrol': 'הגנה מוגברת',
var restrictionEditMapping = {
'autoconfirmed': 'מוגן חלקית'
'sysop': 'מוגן',
};
'templateeditor': 'הגנת ממשק',
 
'editautopatrolprotected': 'הגנה מוגברת',
$.get( mw.util.wikiScript( 'api' ), {
'autoconfirmed': 'מוגן חלקית'
action: 'parse',
};
format: 'json',
text: '{{' + restrictionEditMapping[restrictionEdit[0]] + '}}',
$.get( mw.util.wikiScript( 'api' ), {
prop: 'text',
action: 'parse',
title: mw.config.get('wgPageName'),
format: 'json',
contentmodel: 'wikitext'
text: '{{' + restrictionEditMapping[restrictionEdit[0]] + '}}',
}, function( data ) {
prop: 'text|indicators',
$( function () {
title: mw.config.get('wgPageName'),
$( '.printfooter' ).before( $( '<div>', {
contentmodel: 'wikitext'
'class': 'plprotected',
}, function( data ) {
'html': data.parse.text['*']
$( 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 );
} );
} );
} );
} );
}
}
});
 
/* Use http redirect for Haaretz links until there's a less ad-hoc solution */
if ( location.protocol === 'https:' ) {
$( 'a.external[href^="http://www.haaretz.co.il"]' ).each( function() {
$( this ).attr( 'href', 'http://tools.wmflabs.org/hewiki-tools/redirect.php?q=' + $( this ).attr( 'href' ) );
});
}
} );
} );


// 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' ) {
$( function() {
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();
var t = $( this ).text(),
searchBox = $( 'input#searchText' ),
current = searchBox.val();


searchBox.val ( current + t );
currentText = $searchBox.val();
newText = $( this ).text();
 
$searchBox.val( currentText + newText );
} )
} )
);
);
mw.hook( 'he.wikipedia.collapsetables.loaded' ).add( function () {
// Make the table appear only after the collapsible styles are loaded,
// Make the table appear only after the collapsible styles are loaded,
// so that it won't delay showing the search results
// so that it won't delay showing the search results
$metaStringsTable.css( 'display', 'table' );
$( '#mw-search-meta-strings' ).css( 'display', 'table' );
} );
} );
} );
}
}


// check to see if page contains pgnwrapper, and if so, load pgnviewer
// On demand loading of scripts and gadgets, initial version from ruwiki.
mw.hook( 'wikipage.content' ).add( function( content ) {
// Detects uses of template "טען סקריפט"
if ( $( '.pgn-source-wrapper', content ).length ) {
// and loads specifically-named scripts or gadgets.
mw.loader.load( 'ext.gadget.pgnViewer' );
// for a gadget, its name as defined in gadgets-definition must begin with "ondemand-"
}
if ( mw.config.get('wgCanonicalNamespace') !== 'Special' )  
} );
 
// if paramvalidator wrappers are visible, add "close" button, make them close on click, and tile them.
mw.hook( 'wikipage.content' ).add( function( content ) {
mw.hook( 'wikipage.content' ).add( function( content ) {
$( '.paramvalidator-wrapper:visible', content )
var beenthere = {};
.prepend(
$( '.executeJS', content ).each( function () {
$( '<input>', { 'type': 'button' } )
var gadget = $( this ).data( 'gadgetname' );
.val( 'סימון' )
if ( gadget && $.trim( gadget ) ) mw.loader.load( 'ext.gadget.ondemand-' + $.trim( gadget ) ); // np repetitions - resourceloader takes care
.click( function( e ) {
e.stopPropagation();
var elem = $( this ).closest( '.paramvalidator-wrapper:visible' ).next();
elem.css( { border: 'solid red 3px' } );
} )
)
.prepend( $( '<input>', { 'type': 'button' } ).val( 'סגירה' ) )
.click( function() {
var $this = $( this );
$this.slideUp( "slow", function() { $this.remove(); } );  
} );
} );
if ( $( '.paramvalidator-wrapper:visible',  content ).length > 1 ) {
$( '.paramvalidator-wrapper:visible',  content )
.prepend(
$( '<input>', { 'type': 'button' } )
.val( 'סגירת הכול' )
.click( function() { $( '.paramvalidator-wrapper' ).remove(); } )
)
.prepend(
$( '<input>', { 'type': 'button' } )
.val( 'סימון הכול' )
.click( function( e ) {
e.stopPropagation();
$( '.paramvalidator-wrapper:visible' ).next().css( { border: 'solid red 3px' } );
} )
);
}
} );
} );