LLWiki正在建设中,欢迎加入我们

“MediaWiki:Gadget-Cat-a-lot.js”的版本间差异

跳转到导航 跳转到搜索
删除3,014字节 、​ 2020年8月1日 (六) 12:27
禁用用户设置
(禁用用户设置)
* @author Perhelion (2017)
 
* Requires [[MediaWiki:Gadget-SettingsManager.js]] and [[MediaWiki:Gadget-SettingsUI.js]] (properly registered) for per-user-settings
*
* READ THIS PAGE IF YOU WANT TO TRANSLATE OR USE THIS ON ANOTHER SITE:
* http://commons.wikimedia.org/wiki/MediaWiki:Gadget-Cat-a-lot.js/translating
// There is only one Cat-a-lot on one page
var $body, $container, $dataContainer, $searchInputContainer, $searchInput, $resultList, $markCounter, $selections,
$selectFiles, $selectPages, $selectNone, $selectInvert, $settingsWrapper, $settingsLink, $head, $link, $overcat,
commonsURL = 'https://commons.wikimedia.org/w/index.php',
is_rtl = $( 'body' ).hasClass( 'rtl' ),
.text( msg( 'select' ) + ':' )
.appendTo( $dataContainer );
$settingsWrapper = $( '<div>' )
.attr( 'id', 'cat_a_lot_settings' )
.appendTo( $dataContainer );
$settingsLink = $( '<a>', {
id: 'cat_a_lot_config_settings',
title: 'Version ' + this.version,
text: msg( 'config-settings' )
} )
.appendTo( $settingsWrapper );
$head = $( '<div>' )
.attr( 'id', 'cat_a_lot_head' )
.text( 'Cat-a-lot' )
.appendTo( $head );
$settingsWrapper.append( $( '<a>', {
href: commonsURL + '?title=Special:MyLanguage/Help:Gadget-Cat-a-lot',
target: '_blank',
style: 'float:right',
title: ( $( '#n-help a' ).attr( 'title' ) || '' ) + ' (v. ' + this.version + ')'
} ).text( '?' ) );
$container.one( 'mouseover', function () { // Try load on demand earliest as possible
mw.loader.load( [ 'jquery.ui'] );
} else { CAL.run(); }
} );
$settingsLink
.on( 'click', CAL.manageSettings );
this.localCatName = formattedNS[ 14 ] + ':';
mw.loader.using( 'mediawiki.cookie', function () { // Let catAlot stay open
 
$resultList.css( {
maxHeight: Math.min( this.setHeight, $( window ).height() - $container.position().top /* - $settingsLink.outerHeight() */ - $selections.outerHeight() - 15 ),
height: ''
} );
mw.cookie.set( 'catAlotO', null );
}
},
 
manageSettings: function () {
mw.loader.using( [ 'ext.gadget.SettingsManager', 'ext.gadget.SettingsUI', 'jquery.ui' ], CAL._manageSettings );
},
 
_manageSettings: function () {
mw.libs.SettingsUI( CAL.defaults, 'Cat-a-lot' )
.show()
.done( function ( s, verbose, loc, settingsOut, $dlg ) {
var mustRestart = false,
_restart = function () {
if ( !mustRestart ) { return; }
$container.remove();
CAL.labels.off( 'click.catALot' );
CAL.init();
},
_saveToJS = function () {
var opt = mw.libs.settingsManager.option( {
optionName: 'catALotPrefs',
value: CAL.settings,
encloseSignature: 'catALot',
encloseBlock: '////////// Cat-a-lot user preferences //////////\n',
triggerSaveAt: /Cat.?A.?Lot/i,
editSummary: msg( 'pref-save-summary' )
} ),
oldHeight = $dlg.height(),
$prog = $( '<div>' );
 
$dlg.css( 'height', oldHeight )
.html( '' );
$prog.css( {
height: Math.round( oldHeight / 8 ),
'margin-top': Math.round( ( 7 * oldHeight ) / 16 )
} )
.appendTo( $dlg );
 
$dlg.parent()
.find( '.ui-dialog-buttonpane button' )
.button( 'option', 'disabled', true );
 
opt.save()
.done( function ( text, progress ) {
$prog.progressbar( {
value: progress
} );
$prog.fadeOut( function () {
$dlg.dialog( 'close' );
_restart();
} );
} )
.progress( function ( text, progress ) {
$prog.progressbar( {
value: progress
} );
// TODO: Add "details" to progressbar
} )
.fail( function ( text ) {
$prog.addClass( 'ui-state-error' );
$dlg.prepend( $( '<p>' )
.text( text ) );
} );
};
$.each( settingsOut, function ( n, v ) {
if ( v.forcerestart && CAL.settings[ v.name ] !== v.value ) { mustRestart = true; }
CAL.settings[ v.name ] = CAL.catALotPrefs[ v.name ] = v.value;
} );
switch ( loc ) {
case 'page':
$dlg.dialog( 'close' );
_restart();
break;
case 'account-publicly':
_saveToJS();
break;
}
} );
},
 
16,874

个编辑

导航菜单