Utente:Jalo/monobook.js/test: differenze tra le versioni

Contenuto cancellato Contenuto aggiunto
Nessun oggetto della modifica
Nessun oggetto della modifica
Riga 3 267:
icon: 'http://upload.wikimedia.org/wikipedia/it/c/c4/Pulsante-aiutare.gif',
action: {
type: 'encapsulatedialog',
optionsmodule: {'aiutare'
//pre: "javascript:Ficus('A');"
}
}
},
Riga 4 214 ⟶ 4 213:
} )
} );
$j( '#wpTextbox1' ).wikiEditor( 'addModule', {
'dialogs': {
'aiutare': {
titleMsg: 'Aiutare',
id: 'wikieditor-toolbar-aiutare',
html: '\
<div id="wikieditor-toolbar-replace-message">\
<div id="wikieditor-toolbar-replace-nomatch" rel="wikieditor-toolbar-tool-replace-nomatch"></div>\
<div id="wikieditor-toolbar-replace-success"></div>\
<div id="wikieditor-toolbar-replace-emptysearch" rel="wikieditor-toolbar-tool-replace-emptysearch"></div>\
<div id="wikieditor-toolbar-replace-invalidregex"></div>\
</div>\
<fieldset>\
<div class="wikieditor-toolbar-field-wrapper">\
<label for="wikieditor-toolbar-replace-search" rel="wikieditor-toolbar-tool-replace-search"></label>\
<input type="text" id="wikieditor-toolbar-replace-search" style="width: 100%;" />\
</div>\
<div class="wikieditor-toolbar-field-wrapper">\
<label for="wikieditor-toolbar-replace-replace" rel="wikieditor-toolbar-tool-replace-replace"></label>\
<input type="text" id="wikieditor-toolbar-replace-replace" style="width: 100%;" />\
</div>\
<div class="wikieditor-toolbar-field-wrapper">\
<input type="checkbox" id="wikieditor-toolbar-replace-case" />\
<label for="wikieditor-toolbar-replace-case" rel="wikieditor-toolbar-tool-replace-case"></label>\
</div>\
<div class="wikieditor-toolbar-field-wrapper">\
<input type="checkbox" id="wikieditor-toolbar-replace-regex" />\
<label for="wikieditor-toolbar-replace-regex" rel="wikieditor-toolbar-tool-replace-regex"></label>\
</div>\
</fieldset>',
init: function() {
var u = mw.usability;
$j(this).find( '[rel]' ).each( function() {
$j(this).text( u.getMsg( $j(this).attr( 'rel' ) ) );
});
// Set tabindexes on form fields
$j.wikiEditor.modules.dialogs.fn.setTabindexes( $j(this).find( 'input' ).not( '[tabindex]' ) );
// TODO: Find a cleaner way to share this function
$j(this).data( 'replaceCallback', function( mode ) {
$j( '#wikieditor-toolbar-replace-nomatch, #wikieditor-toolbar-replace-success, #wikieditor-toolbar-replace-emptysearch, #wikieditor-toolbar-replace-invalidregex' ).hide();
var searchStr = $j( '#wikieditor-toolbar-replace-search' ).val();
if ( searchStr == '' ) {
$j( '#wikieditor-toolbar-replace-emptysearch' ).show();
return;
}
var replaceStr = $j( '#wikieditor-toolbar-replace-replace' ).val();
var flags = 'm';
var matchCase = $j( '#wikieditor-toolbar-replace-case' ).is( ':checked' );
var isRegex = $j( '#wikieditor-toolbar-replace-regex' ).is( ':checked' );
if ( !matchCase ) {
flags += 'i';
}
if ( mode == 'replaceAll' ) {
flags += 'g';
}
if ( !isRegex ) {
searchStr = RegExp.escape( searchStr );
}
try {
var regex = new RegExp( searchStr, flags );
} catch( e ) {
$j( '#wikieditor-toolbar-replace-invalidregex' )
.text( u.getMsg( 'wikieditor-toolbar-tool-replace-invalidregex',
e.message ) )
.show();
return;
}
var $textarea = $j(this).data( 'context' ).$textarea;
var text = $textarea.textSelection( 'getContents' );
var match = false;
var offset, s;
if ( mode != 'replaceAll' ) {
offset = $j(this).data( 'offset' );
s = text.substr( offset );
match = s.match( regex );
}
if ( !match ) {
// Search hit BOTTOM, continuing at TOP
offset = 0;
s = text;
match = s.match( regex );
}
if ( !match ) {
$j( '#wikieditor-toolbar-replace-nomatch' ).show();
} else if ( mode == 'replaceAll' ) {
// Instead of using repetitive .match() calls, we use one .match() call with /g
// and indexOf() followed by substr() to find the offsets. This is actually
// faster because our indexOf+substr loop is faster than a match loop, and the
// /g match is so ridiculously fast that it's negligible.
var index;
for ( var i = 0; i < match.length; i++ ) {
index = s.indexOf( match[i] );
if ( index == -1 ) {
// This shouldn't happen
break;
}
s = s.substr( index + match[i].length );
var start = index + offset;
var end = start + match[i].length;
var newEnd = start + replaceStr.length;
$textarea
.textSelection( 'setSelection', { 'start': start, 'end': end } )
.textSelection( 'encapsulateSelection', {
'peri': replaceStr,
'replace': true } )
.textSelection( 'setSelection', { 'start': start, 'end': newEnd } );
offset = newEnd;
}
$j( '#wikieditor-toolbar-replace-success' )
.text( u.getMsg( 'wikieditor-toolbar-tool-replace-success', match.length ) )
.show();
$j(this).data( 'offset', 0 );
} else {
var start = match.index + offset;
var end = start + match[0].length;
var newEnd = start + replaceStr.length;
var context = $j( this ).data( 'context' );
$textarea.textSelection( 'setSelection', { 'start': start,
'end': end } );
if ( mode == 'replace' ) {
$textarea
.textSelection( 'encapsulateSelection', {
'peri': replaceStr,
'replace': true } )
.textSelection( 'setSelection', {
'start': start,
'end': newEnd } );
}
$textarea.textSelection( 'scrollToCaretPosition' );
$textarea.textSelection( 'setSelection', { 'start': start,
'end': mode == 'replace' ? newEnd : end } );
$j( this ).data( 'offset', mode == 'replace' ? newEnd : end );
var textbox = typeof context.$iframe != 'undefined' ? context.$iframe[0].contentWindow : $textarea[0];
textbox.focus();
}
});
},
dialog: {
width: 500,
dialogClass: 'wikiEditor-toolbar-dialog',
buttons: {
'wikieditor-toolbar-tool-replace-button-findnext': function( e ) {
$j(this).closest( '.ui-dialog' ).data( 'dialogaction', e.target );
$j(this).data( 'replaceCallback' ).call( this, 'find' );
},
'wikieditor-toolbar-tool-replace-button-replacenext': function( e ) {
$j(this).closest( '.ui-dialog' ).data( 'dialogaction', e.target );
$j(this).data( 'replaceCallback' ).call( this, 'replace' );
},
'wikieditor-toolbar-tool-replace-button-replaceall': function( e ) {
$j(this).closest( '.ui-dialog' ).data( 'dialogaction', e.target );
$j(this).data( 'replaceCallback' ).call( this, 'replaceAll' );
},
'wikieditor-toolbar-tool-replace-close': function() {
$j(this).dialog( 'close' );
}
},
open: function() {
$j(this).data( 'offset', 0 );
$j( '#wikieditor-toolbar-replace-search' ).focus();
$j( '#wikieditor-toolbar-replace-nomatch, #wikieditor-toolbar-replace-success, #wikieditor-toolbar-replace-emptysearch, #wikieditor-toolbar-replace-invalidregex' ).hide();
if ( !( $j(this).data( 'onetimeonlystuff' ) ) ) {
$j(this).data( 'onetimeonlystuff', true );
// Execute the action associated with the first button
// when the user presses Enter
$j(this).closest( '.ui-dialog' ).keypress( function( e ) {
if ( ( e.keyCode || e.which ) == 13 ) {
var button = $j(this).data( 'dialogaction' ) || $j(this).find( 'button:first' );
button.click();
e.preventDefault();
}
});
// Make tabbing to a button and pressing
// Enter do what people expect
$j(this).closest( '.ui-dialog' ).find( 'button' ).focus( function() {
$j(this).closest( '.ui-dialog' ).data( 'dialogaction', this );
});
}
var dialog = $j(this).closest( '.ui-dialog' );
var that = this;
var context = $j(this).data( 'context' );
var textbox = typeof context.$iframe != 'undefined' ?
context.$iframe[0].contentWindow.document : context.$textarea;
$j( textbox )
.bind( 'keypress.srdialog', function( e ) {
if ( ( e.keyCode || e.which ) == 13 ) {
// Enter
var button = dialog.data( 'dialogaction' ) || dialog.find( 'button:first' );
button.click();
e.preventDefault();
} else if ( ( e.keyCode || e.which ) == 27 ) {
// Escape
$j(that).dialog( 'close' );
}
});
},
close: function() {
var context = $j(this).data( 'context' );
var textbox = typeof context.$iframe != 'undefined' ?
context.$iframe[0].contentWindow.document : context.$textarea;
$j( textbox ).unbind( 'keypress.srdialog' );
$j(this).closest( '.ui-dialog' ).data( 'dialogaction', false );
}
}
}
}
});
}
// controlla se servonoserve la prima tendina
var tendina = $("tendina");
if (tendina.options.length == 0)
Riga 4 223 ⟶ 4 434:
caricaTendinaPersonale();
 
// controlla se servonoserve la seconda tendina
var tendina2 = $("tendina2");
if (tendina2.options.length == 0)