Anonymous user
MediaWiki:Gadget-morebits.js: Difference between revisions
v2.0 at 83fff83: Ignore file/category embeds when removing links (#239)
imported>MusikAnimal (v2.0 at 19598c4: Clean up, avoid unnecessary jQuery use (#399)) |
(v2.0 at 83fff83: Ignore file/category embeds when removing links (#239)) |
||
Line 1:
//
/**
* morebits.js
Line 750:
return element.parentNode.getElementsByTagName("label")[0];
}
};
Line 1,360 ⟶ 1,358:
if( Morebits.wiki.actionCompleted.redirect ) {
// if it isn't a URL, make it one. TODO: This breaks on the articles 'http://', 'ftp://', and similar ones.
if( !( (/^\w+
Morebits.wiki.actionCompleted.redirect = mw.util.getUrl( Morebits.wiki.actionCompleted.redirect );
if( Morebits.wiki.actionCompleted.followRedirect === false ) {
Line 1,442 ⟶ 1,440:
return $.ajax( ajaxparams ).done(
function(xml, statusText
this.statusText = statusText;
this.responseXML = xml;
Line 1,714 ⟶ 1,712:
*/
var ctx = {
pageName: pageName,
pageExists: false,
Line 1,720 ⟶ 1,718:
callbackParameters: null,
statusElement: new Morebits.status(currentAction),
pageText: null,
editMode: 'all', // save() replaces entire contents of the page by default
Line 1,734 ⟶ 1,733:
watchlistOption: 'nochange',
creator: null,
revertOldID: null,
moveDestination: null,
moveTalkPage: false,
moveSubpages: false,
moveSuppressRedirect: false,
protectEdit: null,
protectMove: null,
protectCreate: null,
protectCascade: false,
flaggedRevs: null,
pageLoaded: false,
editToken: null,
Line 1,759 ⟶ 1,763:
conflictRetries: 0,
retries: 0,
onLoadSuccess: null,
onLoadFailure: null,
Line 1,773 ⟶ 1,778:
onStabilizeSuccess: null,
onStabilizeFailure: null,
loadQuery: null,
loadApi: null,
Line 2,526 ⟶ 2,532:
var purgeApi = new Morebits.wiki.api("Edit conflict detected, purging server cache", purgeQuery, null, ctx.statusElement);
--Morebits.wiki.numberOfActionsLeft; // allow for normal completion if retry succeeds
Line 3,019 ⟶ 3,025:
var first_char = link_target.substr( 0, 1 );
var link_re_string = "[" + first_char.toUpperCase() + first_char.toLowerCase() + ']' + RegExp.escape( link_target.substr( 1 ), true );
var link_simple_re = new RegExp( "\\[\\[:?(" + link_re_string + ")\\]\\]", 'g' );▼
// Files and Categories become links with a leading colon.
var link_named_re = new RegExp( "\\[\\[:?" + link_re_string + "\\|(.+?)\\]\\]", 'g' );▼
// e.g. [[:File:Test.png]]
var special_ns_re = /^(?:[Ff]ile|[Ii]mage|[Cc]ategory):/;
var colon = special_ns_re.test( link_target ) ? ':' : '';
this.text = this.text.replace( link_simple_re, "$1" ).replace( link_named_re, "$1" );
},
Line 3,306 ⟶ 3,318:
// hack to force the page not to reload when an error is output - see also Morebits.status() above
Morebits.wiki.numberOfActionsLeft = 1000;
// call error callback
if (Morebits.status.errorEvent) {
Morebits.status.errorEvent();
}
// also log error messages in the browser console
▲ console.error(this.textRaw + ": " + status);
}▼
}
}
Line 3,402 ⟶ 3,414:
function clickHandler(event) {
var
if (event.shiftKey && lastCheckbox !== null) {
var cbs = $(jQuerySelector, jQueryContext); //can't cache them, obviously, if we want to support resorting
var index = -1, lastIndex = -1, i;
for (
if (cbs[i] === thisCb) {
{▼
if (cbs[i]==cb) { index=i; if (lastIndex>-1) break; }▼
if (
break;
▲ }
if (cbs[i] === lastCheckbox) {
lastIndex = i;
break;
}
▲ if (index>-1 && lastIndex>-1)
{▼
//inspired by wikibits
var endState =
var start, finish;
if (index < lastIndex) {
start = index + 1;
▲ start = index+1;
finish = lastIndex;
} else {
start = lastIndex;
finish = index - 1;
cbs[i].checked = endState;
}
▲ for (var i=start; i<=finish; i++) cbs[i].checked = endState;
}
}
lastCheckbox =
return true;
}
Line 3,647 ⟶ 3,665:
// to that of the old SimpleWindow
height: height + 20,
close: function(event
// dialogs and their content can be destroyed once closed
$(event.target).dialog("destroy").remove();
},
resizeStart: function(
this.scrollbox = $(this).find(".morebits-scrollbox")[0];
if (this.scrollbox) {
Line 3,657 ⟶ 3,675:
}
},
resizeEnd: function(
this.scrollbox = null;
},
resize: function(
this.style.maxHeight = "";
if (this.scrollbox) {
Line 3,698 ⟶ 3,716:
// Focuses the dialog. This might work, or on the contrary, it might not.
focus: function(
$(this.content).dialog("moveToTop");
Line 3,726 ⟶ 3,744:
if (window.setupTooltips && window.pg && window.pg.re && window.pg.re.diff) { // tie in with NAVPOP
dialog.parent()[0].ranSetupTooltipsAlready = false;
window.setupTooltips(dialog.parent()[0]);
}
this.setHeight( this.height ); // init height algorithm
Line 3,865 ⟶ 3,883:
if ( typeof arguments === "undefined" ) { // typeof is here for a reason...
/* global Morebits */
window.SimpleWindow = Morebits.simpleWindow;
window.QuickForm = Morebits.quickForm;
Line 3,872 ⟶ 3,891:
}
▲// </nowiki>
|