מדיה ויקי:Common.js: הבדלים בין גרסאות בדף

גרסה חדשה של גיא
אין תקציר עריכה
 
(29 גרסאות ביניים של 6 משתמשים אינן מוצגות)
שורה 41: שורה 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
// סקריפטים עבור אנונימיים ו/או חדשיםs
שורה 188: שורה 175:
restrictionEdit[0] === 'autoconfirmed' ||
restrictionEdit[0] === 'autoconfirmed' ||
restrictionEdit[0] === 'templateeditor' ||
restrictionEdit[0] === 'templateeditor' ||
restrictionEdit[0] === 'autopatrol'
restrictionEdit[0] === 'editautopatrolprotected'
) &&
) &&
$( '#pl-noprotectionnotice, #pl-autoconfirmed, #pl-protected' ).length === 0 &&
$( '#pl-noprotectionnotice, #pl-autoconfirmed, #pl-protected' ).length === 0 &&
שורה 196: שורה 183:
'sysop': 'מוגן',
'sysop': 'מוגן',
'templateeditor': 'הגנת ממשק',
'templateeditor': 'הגנת ממשק',
'autopatrol': 'הגנה מוגברת',
'editautopatrolprotected': 'הגנה מוגברת',
'autoconfirmed': 'מוגן חלקית'
'autoconfirmed': 'מוגן חלקית'
};
};
שורה 204: שורה 191:
format: 'json',
format: 'json',
text: '{{' + restrictionEditMapping[restrictionEdit[0]] + '}}',
text: '{{' + restrictionEditMapping[restrictionEdit[0]] + '}}',
prop: 'text',
prop: 'text|indicators',
title: mw.config.get('wgPageName'),
title: mw.config.get('wgPageName'),
contentmodel: 'wikitext'
contentmodel: 'wikitext'
שורה 213: שורה 200:
'html': data.parse.text['*']
'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' ) );
});
}
} );
} );


שורה 253: שורה 248:
}
}


// check to see if page contains pgnwrapper, and if so, load pgnviewer
// 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 ) {
if ( $( '.pgn-source-wrapper', content ).length ) {
var beenthere = {};
mw.loader.load( 'ext.gadget.pgnViewer' );
$( '.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
 
// if paramvalidator wrappers are visible, add a 'close' button, make them close on click, and tile them.
mw.hook( 'wikipage.content' ).add( function( content ) {
$( '.paramvalidator-wrapper', content ).filter(':visible')
.prepend(
$( '<input>', { 'type': 'button' } )
.val( 'סימון' )
.click( function( e ) {
e.stopPropagation();
var wrapper = $( this ).closest( '.paramvalidator-wrapper' ).filter(':visible');
wrapper
.css( { position: 'inherit' } )
.next()   // hopefully, the offending template itself
.css( { border: 'solid red 3px' } );
;
} )
)
.prepend( $( '<input>', { 'type': 'button' } ).val( 'סגירה' ) )
.click( function() {
var $this = $( this );
$this.slideUp( 'slow', function() { $this.remove(); } );  
} );
} );
if ( $( '.paramvalidator-wrapper',  content ).filter(':visible').length > 1 ) {
$( '.paramvalidator-wrapper',  content ).filter(':visible')
.prepend(
$( '<input>', { 'type': 'button' } )
.val( 'סגירת הכול' )
.click( function() { $( '.paramvalidator-wrapper' ).remove(); } )
)
.prepend(
$( '<input>', { 'type': 'button' } )
.val( 'סימון הכול' )
.click( function( e ) {
e.stopPropagation();
$( '.paramvalidator-wrapper' ).filter(':visible')
.css( { position: 'inherit' } )
.next()
.css( { border: 'solid red 3px' } );
} )
);
}
} );
} );
// Temporary workaround until T198449 is fixed
// Temporary workaround until T198449 is fixed
if (mw.config.get('wgAction') === 'rollback') {
mw.loader.using('mediawiki.api').done(function () {
var latestRevID, pageID = mw.config.get('wgArticleId'), api = new mw.Api();
api.get({
prop: 'revisions',
rvprop: 'ids',
rvlimit: 1,
pageids: pageID
}).then(function (data) {
latestRevID = data.query.pages[pageID].revisions[0].revid;
api.postWithToken('patrol', {
action: 'patrol',
revid: latestRevID
});
});
});
}