summaryrefslogtreecommitdiff
path: root/extensions/WikiEditor/modules
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/WikiEditor/modules')
-rw-r--r--extensions/WikiEditor/modules/contentCollector.js22
-rw-r--r--extensions/WikiEditor/modules/ext.wikiEditor.tests.toolbar.js4
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js181
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js8
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.highlight.js24
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.iframe.js100
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.js54
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.preview.js10
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.previewDialog.js2
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.publish.js8
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.templateEditor.js114
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.toc.js52
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.config.js14
-rw-r--r--extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js24
14 files changed, 335 insertions, 282 deletions
diff --git a/extensions/WikiEditor/modules/contentCollector.js b/extensions/WikiEditor/modules/contentCollector.js
index af8d796a..2c289212 100644
--- a/extensions/WikiEditor/modules/contentCollector.js
+++ b/extensions/WikiEditor/modules/contentCollector.js
@@ -4,13 +4,13 @@
/**
* Copyright 2009 Google Inc.
- *
+ *
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS-IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -103,7 +103,7 @@ function makeContentCollector( browser, domInterface ) {
},
// call flush only when you're done
flush : function(withNewline) {
-
+
}
};
self.startNew();
@@ -182,7 +182,7 @@ function makeContentCollector( browser, domInterface ) {
state.listType = oldListType;
}
function _produceListMarker(state) {
-
+
}
function _startNewLine(state) {
if (state) {
@@ -262,14 +262,14 @@ function makeContentCollector( browser, domInterface ) {
_produceListMarker(state);
}
lines.appendText(textify(txt2));
-
+
x += consumed;
txt = rest;
if (txt.length > 0) {
_startNewLine(state);
}
}
-
+
} else {
var cls = dom.nodeProp(node, "className");
var tname = (dom.nodeTagName(node) || "").toLowerCase();
@@ -279,7 +279,7 @@ function makeContentCollector( browser, domInterface ) {
// ignore
} else if (!isEmpty) {
var styl = dom.nodeAttr(node, "style");
-
+
var isPre = (tname == "pre");
if ((!isPre) && browser.safari) {
isPre = (styl && /\bwhite-space:\s*pre\b/i.exec(styl));
@@ -301,7 +301,7 @@ function makeContentCollector( browser, domInterface ) {
if (isPre)
_decrementFlag(state, 'preMode');
-
+
if (oldListTypeOrNull) {
_exitList(state, oldListTypeOrNull);
}
@@ -384,7 +384,7 @@ function makeContentCollector( browser, domInterface ) {
lengthToTake = lineLimit;
newStrings.push(oldString.substring(0, lengthToTake));
oldString = oldString.substring(lengthToTake);
-
+
}
if (oldString.length > 0) {
newStrings.push(oldString);
@@ -414,7 +414,7 @@ function makeContentCollector( browser, domInterface ) {
newStrings.unshift(i, 1);
lineStrings.splice.apply(lineStrings, newStrings);
-
+
}
}
return {
diff --git a/extensions/WikiEditor/modules/ext.wikiEditor.tests.toolbar.js b/extensions/WikiEditor/modules/ext.wikiEditor.tests.toolbar.js
index de01f34f..69fe2905 100644
--- a/extensions/WikiEditor/modules/ext.wikiEditor.tests.toolbar.js
+++ b/extensions/WikiEditor/modules/ext.wikiEditor.tests.toolbar.js
@@ -121,7 +121,7 @@ var wikiEditorTests = {
'pre': 0,
'post': 9
},
- // Add
+ // Add
'add_pages_characters': {
'call': 'addToToolbar',
'data': {
@@ -141,7 +141,7 @@ var wikiEditorTests = {
'pre': 0,
'post': 1
},
- // Add
+ // Add
'add_characters': {
'call': 'addToToolbar',
'data': {
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js b/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js
index 4ab6ce46..0c24c368 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.config.js
@@ -72,7 +72,7 @@ replaceIcons: function( $textarea ) {
}
} );
},
-
+
getDefaultConfig: function () {
return { 'dialogs': {
'insert-link': {
@@ -129,7 +129,7 @@ getDefaultConfig: function () {
$( '.ui-dialog:visible .ui-dialog-buttonpane button:first' )
.attr( 'disabled', true )
.addClass( 'disabled' );
- } else {
+ } else {
$( '.ui-dialog:visible .ui-dialog-buttonpane button:first' )
.removeAttr('disabled')
.removeClass('disabled');
@@ -138,7 +138,7 @@ getDefaultConfig: function () {
// Updates the UI to show if the page title being inputed by the user exists or not
// accepts parameter internal for bypassing external link detection
function updateExistence( internal ) {
- // ensure the internal parameter is a boolean
+ // ensure the internal parameter is a boolean
if ( internal != true ) internal = false;
// Abort previous request
var request = $( '#wikieditor-toolbar-link-int-target-status' ).data( 'request' );
@@ -259,7 +259,7 @@ getDefaultConfig: function () {
.data( 'tooltip-mode', true );
}
});
-
+
// Automatically copy the value of the internal link page title field to the link text field unless the
// user has changed the link text field - this is a convenience thing since most link texts are going to
// be the the same as the page title - Also change the internal/external radio button accordingly
@@ -275,7 +275,7 @@ getDefaultConfig: function () {
updateExistence();
}
if ( $( '#wikieditor-toolbar-link-int-text' ).data( 'untouched' ) )
- if ( $( '#wikieditor-toolbar-link-int-target' ).val() ==
+ if ( $( '#wikieditor-toolbar-link-int-target' ).val() ==
$( '#wikieditor-toolbar-link-int-target' ).data( 'tooltip' ) ) {
$( '#wikieditor-toolbar-link-int-text' )
.addClass( 'wikieditor-toolbar-dialog-hint' )
@@ -330,7 +330,7 @@ getDefaultConfig: function () {
)
.data( 'existencecache', {} )
.children().hide();
-
+
$( '#wikieditor-toolbar-link-int-target' )
.bind( 'keyup paste cut', function() {
// Cancel the running timer if applicable
@@ -350,24 +350,24 @@ getDefaultConfig: function () {
// Fetch right now
updateExistence();
} );
-
+
// Title suggestions
$( '#wikieditor-toolbar-link-int-target' ).data( 'suggcache', {} ).suggestions( {
fetch: function( query ) {
var that = this;
var title = $(this).val();
-
+
if ( isExternalLink( title ) || title.indexOf( '|' ) != -1 || title == '') {
$(this).suggestions( 'suggestions', [] );
return;
}
-
+
var cache = $(this).data( 'suggcache' );
if ( typeof cache[title] != 'undefined' ) {
$(this).suggestions( 'suggestions', cache[title] );
return;
}
-
+
var request = $.ajax( {
url: mw.util.wikiScript( 'api' ),
data: {
@@ -435,7 +435,7 @@ getDefaultConfig: function () {
alert( mediaWiki.msg( 'wikieditor-toolbar-tool-link-int-invalid' ) );
return;
}
-
+
if ( target == text || !text.length )
insertText = '[[' + target + ']]';
else
@@ -444,7 +444,7 @@ getDefaultConfig: function () {
// Prepend http:// if there is no protocol
if ( !target.match( /^[a-z]+:\/\/./ ) )
target = 'http://' + target;
-
+
// Detect if this is really an internal link in disguise
var match = target.match( $(this).data( 'articlePathRegex' ) );
if ( match && !$(this).data( 'ignoreLooksInternal' ) ) {
@@ -468,10 +468,10 @@ getDefaultConfig: function () {
);
return;
}
-
+
var escTarget = escapeExternalTarget( target );
var escText = escapeExternalText( text );
-
+
if ( escTarget == escText )
insertText = escTarget;
else if ( text == '' )
@@ -488,7 +488,7 @@ getDefaultConfig: function () {
pre: insertText
}
}, $(this) );
-
+
// Blank form
$( '#wikieditor-toolbar-link-int-target, #wikieditor-toolbar-link-int-text' ).val( '' );
$( '#wikieditor-toolbar-link-type-int, #wikieditor-toolbar-link-type-ext' )
@@ -514,7 +514,7 @@ getDefaultConfig: function () {
// Restore and immediately save selection state, needed for inserting stuff later
context.fn.restoreCursorAndScrollTop();
context.fn.saveCursorAndScrollTop();
- var selection = context.$textarea.textSelection( 'getSelection' );
+ var selection = context.$textarea.textSelection( 'getSelection' );
$( '#wikieditor-toolbar-link-int-target' ).focus();
// Trigger the change event, so the link status indicator is up to date
$( '#wikieditor-toolbar-link-int-target' ).change();
@@ -549,7 +549,7 @@ getDefaultConfig: function () {
);
}
}
-
+
// Change the value by calling val() doesn't trigger the change event, so let's do that
// ourselves
if ( typeof text != 'undefined' )
@@ -565,18 +565,18 @@ getDefaultConfig: function () {
$( '#wikieditor-toolbar-link-int-text' ).hasClass( 'wikieditor-toolbar-dialog-hint' )
);
$( '#wikieditor-toolbar-link-int-target' ).suggestions();
-
+
//don't overwrite user's text
if( selection != '' ){
$( '#wikieditor-toolbar-link-int-text' ).data( 'untouched', false );
}
-
+
$( '#wikieditor-toolbar-link-int-text, #wikiedit-toolbar-link-int-target' )
.each( function() {
if ( $(this).val() == '' )
$(this).parent().find( 'label' ).show();
});
-
+
if ( !( $(this).data( 'dialogkeypressset' ) ) ) {
$(this).data( 'dialogkeypressset', true );
// Execute the action associated with the first button
@@ -588,7 +588,7 @@ getDefaultConfig: function () {
e.preventDefault();
}
});
-
+
// Make tabbing to a button and pressing
// Enter do what people expect
$(this).closest( '.ui-dialog' ).find( 'button' ).focus( function() {
@@ -616,7 +616,7 @@ getDefaultConfig: function () {
$( this ).find( '[rel]' ).each( function() {
$( this ).text( mediaWiki.msg( $( this ).attr( 'rel' ) ) );
} );
-
+
},
dialog: {
dialogClass: 'wikiEditor-toolbar-dialog',
@@ -656,7 +656,7 @@ getDefaultConfig: function () {
// Restore and immediately save selection state, needed for inserting stuff later
context.fn.restoreCursorAndScrollTop();
context.fn.saveCursorAndScrollTop();
- var selection = context.$textarea.textSelection( 'getSelection' );
+ var selection = context.$textarea.textSelection( 'getSelection' );
// set focus
$( '#wikieditor-toolbar-reference-text' ).focus();
$( '#wikieditor-toolbar-reference-dialog' )
@@ -766,13 +766,13 @@ getDefaultConfig: function () {
});
// Set tabindexes on form fields
$.wikiEditor.modules.dialogs.fn.setTabindexes( $(this).find( 'input' ).not( '[tabindex]' ) );
-
+
$( '#wikieditor-toolbar-table-dimensions-rows' ).val( 3 );
$( '#wikieditor-toolbar-table-dimensions-columns' ).val( 3 );
$( '#wikieditor-toolbar-table-wikitable' ).click( function() {
$( '.wikieditor-toolbar-table-preview' ).toggleClass( 'wikitable' );
});
-
+
// Hack for sortable preview: dynamically adding
// sortable class doesn't work, so we use a clone
$( '#wikieditor-toolbar-table-preview' )
@@ -783,7 +783,7 @@ getDefaultConfig: function () {
.hide();
mw.loader.using( 'jquery.tablesorter', function() {
- $( '#wikieditor-toolbar-table-preview2' ).tablesorter();
+ $( '#wikieditor-toolbar-table-preview2' ).tablesorter();
});
$( '#wikieditor-toolbar-table-sortable' ).click( function() {
@@ -796,7 +796,7 @@ getDefaultConfig: function () {
.show();
$( '#wikieditor-toolbar-table-preview3' ).attr( 'id', 'wikieditor-toolbar-table-preview2' );
});
-
+
$( '#wikieditor-toolbar-table-dimensions-header' ).click( function() {
// Instead of show/hiding, switch the HTML around
// We do this because the sortable tables script styles the first row,
@@ -872,7 +872,7 @@ getDefaultConfig: function () {
},
$(this)
);
-
+
// Restore form state
$( '#wikieditor-toolbar-table-dimensions-rows' ).val( 3 );
$( '#wikieditor-toolbar-table-dimensions-columns' ).val( 3 );
@@ -902,7 +902,7 @@ getDefaultConfig: function () {
e.preventDefault();
}
});
-
+
// Make tabbing to a button and pressing
// Enter do what people expect
$(this).closest( '.ui-dialog' ).find( 'button' ).focus( function() {
@@ -964,28 +964,35 @@ getDefaultConfig: function () {
});
// Set tabindexes on form fields
$.wikiEditor.modules.dialogs.fn.setTabindexes( $(this).find( 'input' ).not( '[tabindex]' ) );
-
+
// TODO: Find a cleaner way to share this function
$(this).data( 'replaceCallback', function( mode ) {
$( '#wikieditor-toolbar-replace-nomatch, #wikieditor-toolbar-replace-success, #wikieditor-toolbar-replace-emptysearch, #wikieditor-toolbar-replace-invalidregex' ).hide();
+
+ // Search string cannot be empty
var searchStr = $( '#wikieditor-toolbar-replace-search' ).val();
if ( searchStr == '' ) {
$( '#wikieditor-toolbar-replace-emptysearch' ).show();
return;
}
+
+ // Replace string can be empty
var replaceStr = $( '#wikieditor-toolbar-replace-replace' ).val();
+
+ // Prepare the regular expression flags
var flags = 'm';
var matchCase = $( '#wikieditor-toolbar-replace-case' ).is( ':checked' );
- var isRegex = $( '#wikieditor-toolbar-replace-regex' ).is( ':checked' );
if ( !matchCase ) {
flags += 'i';
}
- if ( mode == 'replaceAll' ) {
- flags += 'g';
- }
+ var isRegex = $( '#wikieditor-toolbar-replace-regex' ).is( ':checked' );
if ( !isRegex ) {
searchStr = $.escapeRE( searchStr );
}
+ if ( mode == 'replaceAll' ) {
+ flags += 'g';
+ }
+
try {
var regex = new RegExp( searchStr, flags );
} catch( e ) {
@@ -995,22 +1002,28 @@ getDefaultConfig: function () {
.show();
return;
}
+
var $textarea = $(this).data( 'context' ).$textarea;
var text = $textarea.textSelection( 'getContents' );
var match = false;
- var offset, s;
+ var offset, textRemainder;
if ( mode != 'replaceAll' ) {
- offset = $(this).data( 'offset' );
- s = text.substr( offset );
- match = s.match( regex );
+ if (mode == 'replace') {
+ offset = $(this).data( 'matchIndex' );
+ } else {
+ offset = $(this).data( 'offset' );
+ }
+ textRemainder = text.substr( offset );
+ match = textRemainder.match( regex );
}
if ( !match ) {
// Search hit BOTTOM, continuing at TOP
+ // TODO: Add a "Wrap around" option.
offset = 0;
- s = text;
- match = s.match( regex );
+ textRemainder = text;
+ match = textRemainder.match( regex );
}
-
+
if ( !match ) {
$( '#wikieditor-toolbar-replace-nomatch' ).show();
} else if ( mode == 'replaceAll' ) {
@@ -1022,14 +1035,14 @@ getDefaultConfig: function () {
// in Firefox/Webkit, but in IE replacing the entire content once is better.
var index;
for ( var i = 0; i < match.length; i++ ) {
- index = s.indexOf( match[i] );
+ index = textRemainder.indexOf( match[i] );
if ( index == -1 ) {
// This shouldn't happen
break;
}
- var matchedText = s.substr( index, match[i].length );
- s = s.substr( index + match[i].length );
-
+ var matchedText = textRemainder.substr( index, match[i].length );
+ textRemainder = textRemainder.substr( index + match[i].length );
+
var start = index + offset;
var end = start + match[i].length;
// Make regex placeholder substitution ($1) work
@@ -1048,27 +1061,63 @@ getDefaultConfig: function () {
.show();
$(this).data( 'offset', 0 );
} else {
- // Make regex placeholder substitution ($1) work
- var replace = isRegex ? match[0].replace( regex, replaceStr ): replaceStr;
- var start = match.index + offset;
- var end = start + match[0].length;
- var newEnd = start + replace.length;
- var context = $( this ).data( 'context' );
- $textarea.textSelection( 'setSelection', { 'start': start,
- 'end': end } );
+ var start, end;
+
if ( mode == 'replace' ) {
- $textarea
- .textSelection( 'encapsulateSelection', {
- 'peri': replace,
- 'replace': true } )
- .textSelection( 'setSelection', {
- 'start': start,
- 'end': newEnd } );
+ var actualReplacement;
+
+ if (isRegex) {
+ // If backreferences (like $1) are used, the actual actual replacement string will be different
+ actualReplacement = match[0].replace( regex, replaceStr );
+ } else {
+ actualReplacement = replaceStr;
+ }
+
+ if (match) {
+ // Do the replacement
+ $textarea.textSelection( 'encapsulateSelection', {
+ 'peri': actualReplacement,
+ 'replace': true } );
+ // Reload the text after replacement
+ text = $textarea.textSelection( 'getContents' );
+ }
+
+ // Find the next instance
+ offset = offset + match[0].length + actualReplacement.length;
+ textRemainder = text.substr( offset );
+ match = textRemainder.match( regex );
+
+ if (match) {
+ start = offset + match.index;
+ end = start + match[0].length;
+ } else {
+ // If no new string was found, try searching from the beginning.
+ // TODO: Add a "Wrap around" option.
+ textRemainder = text;
+ match = textRemainder.match( regex );
+ if (match) {
+ start = match.index;
+ end = start + match[0].length;
+ } else {
+ // Give up
+ start = 0;
+ end = 0;
+ }
+ }
+ } else {
+ start = offset + match.index;
+ end = start + match[0].length;
}
+
+ $( this ).data( 'matchIndex', start);
+
+ $textarea.textSelection( 'setSelection', {
+ 'start': start,
+ 'end': end
+ } );
$textarea.textSelection( 'scrollToCaretPosition' );
- $textarea.textSelection( 'setSelection', { 'start': start,
- 'end': mode == 'replace' ? newEnd : end } );
- $( this ).data( 'offset', mode == 'replace' ? newEnd : end );
+ $( this ).data( 'offset', end );
+ var context = $( this ).data( 'context' );
var textbox = typeof context.$iframe != 'undefined' ?
context.$iframe[0].contentWindow : $textarea[0];
textbox.focus();
@@ -1083,7 +1132,7 @@ getDefaultConfig: function () {
$(this).closest( '.ui-dialog' ).data( 'dialogaction', e.target );
$(this).data( 'replaceCallback' ).call( this, 'find' );
},
- 'wikieditor-toolbar-tool-replace-button-replacenext': function( e ) {
+ 'wikieditor-toolbar-tool-replace-button-replace': function( e ) {
$(this).closest( '.ui-dialog' ).data( 'dialogaction', e.target );
$(this).data( 'replaceCallback' ).call( this, 'replace' );
},
@@ -1097,6 +1146,8 @@ getDefaultConfig: function () {
},
open: function() {
$(this).data( 'offset', 0 );
+ $(this).data( 'matchIndex', 0 );
+
$( '#wikieditor-toolbar-replace-search' ).focus();
$( '#wikieditor-toolbar-replace-nomatch, #wikieditor-toolbar-replace-success, #wikieditor-toolbar-replace-emptysearch, #wikieditor-toolbar-replace-invalidregex' ).hide();
if ( !( $(this).data( 'onetimeonlystuff' ) ) ) {
@@ -1121,7 +1172,7 @@ getDefaultConfig: function () {
var context = $(this).data( 'context' );
var textbox = typeof context.$iframe != 'undefined' ?
context.$iframe[0].contentWindow.document : context.$textarea;
-
+
$( textbox )
.bind( 'keypress.srdialog', function( e ) {
if ( ( e.keyCode || e.which ) == 13 ) {
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js b/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js
index 9b291466..6f5404f5 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.dialogs.js
@@ -45,12 +45,12 @@ api: {
$.wikiEditor.modules.dialogs.fn.reallyCreate( context, mod, module );
$dialog = $( '#' + mod.id );
}
-
+
// Workaround for bug in jQuery UI: close button in top right retains focus
$dialog.closest( '.ui-dialog' )
.find( '.ui-dialog-titlebar-close' )
.removeClass( 'ui-state-focus' );
-
+
$dialog.dialog( 'open' );
}
},
@@ -147,7 +147,7 @@ fn: {
dialogDiv.bind( 'dialogclose', function() {
context.fn.restoreSelection();
} );
-
+
// Let the outside world know we set up this dialog
context.$textarea.trigger( 'wikiEditor-dialogs-loaded-' + name );
},
@@ -187,7 +187,7 @@ fn: {
$(this).css( 'white-space', oldWS );
oldHidden.each( function() {
$(this).attr( 'style', $(this).data( 'oldstyle' ) );
- });
+ });
},
/**
* Set the right tabindexes on elements in a dialog
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.highlight.js b/extensions/WikiEditor/modules/jquery.wikiEditor.highlight.js
index c804b3aa..48140206 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.highlight.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.highlight.js
@@ -33,7 +33,7 @@
'fn': {
/**
* Creates a highlight module within a wikiEditor
- *
+ *
* @param config Configuration object to create module from
*/
'create': function( context, config ) {
@@ -41,7 +41,7 @@
},
/**
* Scans text division for tokens
- *
+ *
* @param division
*/
'scan': function( context, division ) {
@@ -82,7 +82,7 @@
},
/**
* Marks up text with HTML
- *
+ *
* @param division
* @param tokens
*/
@@ -91,7 +91,7 @@
'mark': function( context, division, tokens ) {
// Reset markers
var markers = [];
-
+
// Recycle markers that will be skipped in this run
if ( context.modules.highlight.markers && division != '' ) {
for ( var i = 0; i < context.modules.highlight.markers.length; i++ ) {
@@ -101,11 +101,11 @@
}
}
context.modules.highlight.markers = markers;
-
+
// Get all markers
context.fn.trigger( 'mark' );
markers.sort( function( a, b ) { return a.start - b.start || a.end - b.end; } );
-
+
// Serialize the markers array to a string and compare it with the one stored in the previous run - if they're
// equal, there's no markers to change
var markersStr = '';
@@ -117,15 +117,15 @@
return;
}
context.modules.highlight.markersStr = markersStr;
-
+
// Traverse the iframe DOM, inserting markers where they're needed - store visited markers here so we know which
// markers should be removed
var visited = [], v = 0;
for ( var i = 0; i < markers.length; i++ ) {
- if ( typeof markers[i].skipDivision !== 'undefined' && ( division == markers[i].skipDivision ) ) {
+ if ( typeof markers[i].skipDivision !== 'undefined' && ( division == markers[i].skipDivision ) ) {
continue;
}
-
+
// We want to isolate each marker, so we may need to split textNodes if a marker starts or ends halfway one.
var start = markers[i].start;
var s = context.fn.getOffset( start );
@@ -134,7 +134,7 @@
continue;
}
var startNode = s.node;
-
+
// Don't wrap leading BRs, produces undesirable results
// FIXME: It's also possible that the offset is a bit high because getOffset() has incremented .length to
// fake the newline caused by startNode being in a P. In this case, prevent the textnode splitting below
@@ -144,7 +144,7 @@
s = context.fn.getOffset( start );
startNode = s.node;
}
-
+
// The next marker starts somewhere in this textNode or at this BR
if ( s.offset > 0 && s.node.nodeName == '#text' ) {
// Split off the prefix - this leaves the prefix in the current node and puts the rest in a new node
@@ -349,7 +349,7 @@
}
context.fn.purgeOffsets();
});
-
+
}
}
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.iframe.js b/extensions/WikiEditor/modules/jquery.wikiEditor.iframe.js
index 5a0cc153..4d425012 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.iframe.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.iframe.js
@@ -2,9 +2,9 @@
( function( $ ) { $.wikiEditor.extensions.iframe = function( context ) {
-/*
+/*
* Event Handlers
- *
+ *
* These act as filters returning false if the event should be ignored or returning true if it should be passed
* on to all modules. This is also where we can attach some extra information to the events.
*/
@@ -130,13 +130,13 @@ context.evt = $.extend( context.evt, {
var cursorPos = context.fn.getCaretPosition();
var oldLength = context.fn.getContents().length;
var positionFromEnd = oldLength - cursorPos[1];
-
- //give everything the wikiEditor class so that we can easily pick out things without that class as pasted
+
+ //give everything the wikiEditor class so that we can easily pick out things without that class as pasted
context.$content.find( '*' ).addClass( 'wikiEditor' );
if ( $.layout.name !== 'webkit' ) {
context.$content.addClass( 'pasting' );
}
-
+
setTimeout( function() {
// Kill stuff we know we don't want
context.$content.find( 'script,style,img,input,select,textarea,hr,button,link,meta' ).remove();
@@ -156,7 +156,7 @@ context.evt = $.extend( context.evt, {
} else {
firstDirtyNode = elementAtCursor.node;
}
-
+
//this is ugly but seems like the best way to handle the case where we select and replace all editor contents
try {
firstDirtyNode.parentNode;
@@ -164,11 +164,11 @@ context.evt = $.extend( context.evt, {
context.$content.prepend( '<p class = wikiEditor></p>' );
firstDirtyNode = context.$content.children()[0];
}
-
+
while ( firstDirtyNode != null ) {
- //we're going to replace the contents of the entire parent node.
- while ( firstDirtyNode.parentNode && firstDirtyNode.parentNode.nodeName != 'BODY'
- && ! $( firstDirtyNode ).hasClass( 'wikiEditor' )
+ //we're going to replace the contents of the entire parent node.
+ while ( firstDirtyNode.parentNode && firstDirtyNode.parentNode.nodeName != 'BODY'
+ && ! $( firstDirtyNode ).hasClass( 'wikiEditor' )
) {
firstDirtyNode = firstDirtyNode.parentNode;
}
@@ -176,33 +176,33 @@ context.evt = $.extend( context.evt, {
while ( firstDirtyNode.previousSibling != null
&& ! $( firstDirtyNode.previousSibling ).hasClass( 'wikiEditor' )
) {
-
+
if ( $( firstDirtyNode.previousSibling ).hasClass( '#comment' ) ) {
$( firstDirtyNode ).remove();
} else {
firstDirtyNode = firstDirtyNode.previousSibling;
}
}
-
+
if ( firstDirtyNode.previousSibling != null ) {
$lastDirtyNode = $( firstDirtyNode.previousSibling );
} else {
$lastDirtyNode = $( firstDirtyNode );
}
-
+
var cc = makeContentCollector( $.browser, null );
while ( firstDirtyNode != null ) {
cc.collectContent(firstDirtyNode);
- cc.notifyNextNode(firstDirtyNode.nextSibling);
-
+ cc.notifyNextNode(firstDirtyNode.nextSibling);
+
nodeToDelete.push( firstDirtyNode );
-
+
firstDirtyNode = firstDirtyNode.nextSibling;
if ( $( firstDirtyNode ).hasClass( 'wikiEditor' ) ) {
break;
}
}
-
+
var ccData = cc.finish();
pastedContent = ccData.lines;
var pastedPretty = '';
@@ -216,8 +216,8 @@ context.evt = $.extend( context.evt, {
leadingSpace = match[0].replace(/[\s]/g, '&nbsp;');
pastedPretty = leadingSpace + pastedPretty.substring(index, pastedPretty.length);
}
-
-
+
+
if( !pastedPretty && $.browser.msie && i == 0 ) {
continue;
}
@@ -228,17 +228,17 @@ context.evt = $.extend( context.evt, {
$newElement.html( '<br class="wikiEditor">' );
}
$newElement.insertAfter( $lastDirtyNode );
-
+
$lastDirtyNode = $newElement;
-
+
}
-
+
//now delete all the original nodes that we prettified already
while ( nodeToDelete.length > 0 ) {
$deleteNode = $( nodeToDelete.pop() );
$deleteNode.remove();
}
-
+
//anything without wikiEditor class was pasted.
$selection = context.$content.find( ':not(.wikiEditor)' );
if ( $selection.length == 0 ) {
@@ -248,14 +248,14 @@ context.evt = $.extend( context.evt, {
}
}
context.$content.find( '.wikiEditor' ).removeClass( 'wikiEditor' );
-
+
//now place the cursor at the end of pasted content
var newLength = context.fn.getContents().length;
var newPos = newLength - positionFromEnd;
-
+
context.fn.purgeOffsets();
context.fn.setSelection( { start: newPos, end: newPos } );
-
+
context.fn.scrollToCaretPosition();
}, 0 );
return true;
@@ -289,7 +289,7 @@ context.fn = $.extend( context.fn, {
return context.htmlToTextMap[html];
}
var origHTML = html;
-
+
// We use this elaborate trickery for cross-browser compatibility
// IE does overzealous whitespace collapsing for $( '<pre />' ).html( html );
// We also do <br> and easy cases for <p> conversion here, complicated cases are handled later
@@ -320,7 +320,7 @@ context.fn = $.extend( context.fn, {
// If this <p> is preceded by some text, add a \n at the beginning, and if
// it's followed by a textnode, add a \n at the end
// We need the traverser because there can be other weird stuff in between
-
+
// Check for preceding text
var t = new context.fn.rawTraverser( this.firstChild, this, $pre.get( 0 ), true ).prev();
while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) {
@@ -329,7 +329,7 @@ context.fn = $.extend( context.fn, {
if ( t ) {
text = "\n" + text;
}
-
+
// Check for following text
t = new context.fn.rawTraverser( this.lastChild, this, $pre.get( 0 ), true ).next();
while ( t && t.node.nodeName != '#text' && t.node.nodeName != 'BR' && t.node.nodeName != 'P' ) {
@@ -377,7 +377,7 @@ context.fn = $.extend( context.fn, {
} else {
return null;
}
-
+
// When the cursor is on an empty line, Opera gives us a bogus range object with
// startContainer=endContainer=body and startOffset=endOffset=1
var body = context.$iframe[0].contentWindow.document.body;
@@ -420,7 +420,7 @@ context.fn = $.extend( context.fn, {
}
e = newE || e;
}
-
+
// We'd normally use if( $( e ).hasClass( class ) in the while loop, but running the jQuery
// constructor thousands of times is very inefficient
var classStr = ' ' + classname + ' ';
@@ -641,18 +641,18 @@ context.fn = $.extend( context.fn, {
* Update the history queue
*
* @param htmlChange pass true or false to inidicate if there was a text change that should potentially
- * be given a new history state.
+ * be given a new history state.
*/
'updateHistory': function( htmlChange ) {
var newHTML = context.$content.html();
var newSel = context.fn.getCaretPosition();
- // Was text changed? Was it because of a REDO or UNDO action?
+ // Was text changed? Was it because of a REDO or UNDO action?
if (
context.history.length == 0 ||
( htmlChange && context.oldDelayedHistoryPosition == context.historyPosition )
) {
context.oldDelayedSel = newSel;
- // Do we need to trim extras from our history?
+ // Do we need to trim extras from our history?
// FIXME: this should really be happing on change, not on the delay
if ( context.historyPosition < -1 ) {
//clear out the extras
@@ -753,7 +753,7 @@ context.fn = $.extend( context.fn, {
/&lt;span( |&nbsp;)class=("|&quot;)wikiEditor-tab("|&quot;)&gt;&lt;\/span&gt;/g,
'<span class="wikiEditor-tab"></span>'
)
- // Empty <p> tags need <br> tags in them
+ // Empty <p> tags need <br> tags in them
.replace( /<p><\/p>/g, '<p><br></p>' )
// Unescape &esc; stuff
.replace( /&amp;esc;&amp;amp;nbsp;/g, '&amp;nbsp;' )
@@ -765,7 +765,7 @@ context.fn = $.extend( context.fn, {
)
.replace( /&amp;esc;esc;/g, '&amp;esc;' );
context.$content.html( html );
-
+
// Reflect direction of parent frame into child
if ( $( 'body' ).is( '.rtl' ) ) {
context.$content.addClass( 'rtl' ).attr( 'dir', 'rtl' );
@@ -789,7 +789,7 @@ context.fn = $.extend( context.fn, {
.bind( 'keydown', function( event ) {
event.jQueryNode = context.fn.getElementAtCursor();
return context.fn.trigger( 'keydown', event );
-
+
} )
.bind( 'keyup', function( event ) {
event.jQueryNode = context.fn.getElementAtCursor();
@@ -828,12 +828,12 @@ context.fn = $.extend( context.fn, {
}
};
},
-
- /*
+
+ /**
* Compatibility with the $.textSelection jQuery plug-in. When the iframe is in use, these functions provide
* equivilant functionality to the otherwise textarea-based functionality.
*/
-
+
'getElementAtCursor': function() {
if ( context.$iframe[0].contentWindow.getSelection ) {
// Firefox and Opera
@@ -851,7 +851,7 @@ context.fn = $.extend( context.fn, {
return $( selection.parentElement() );
}
},
-
+
/**
* Gets the complete contents of the iframe (in plain text, not HTML)
*/
@@ -948,8 +948,8 @@ context.fn = $.extend( context.fn, {
if ( context.$iframe[0].contentWindow.getSelection ) {
// Firefox and Opera
var range = context.$iframe[0].contentWindow.getSelection().getRangeAt( 0 );
- // if our test above indicated that this was a sucessive button press, we need to collapse the
- // selection to the end to avoid replacing text
+ // if our test above indicated that this was a sucessive button press, we need to collapse the
+ // selection to the end to avoid replacing text
if ( collapseToEnd ) {
// Make sure we're not collapsing ourselves into a BR tag
if ( range.endContainer.nodeName == 'BR' ) {
@@ -1073,7 +1073,7 @@ context.fn = $.extend( context.fn, {
if ( range2.text != "\r" && range2.text != "\n" && range2.text != "" ) {
pre = "\n" + pre;
}
-
+
// Check if we're at the end of a line
// If not, append a newline
var range3 = context.$iframe[0].contentWindow.document.selection.createRange();
@@ -1095,7 +1095,7 @@ context.fn = $.extend( context.fn, {
for( var j = 0; j < selTextArr.length; j++ ) {
insertText = insertText + pre + selTextArr[j] + post;
if( j != selTextArr.length - 1 ) {
- insertText += "\n";
+ insertText += "\n";
}
}
} else {
@@ -1113,7 +1113,7 @@ context.fn = $.extend( context.fn, {
range.select();
}
}
-
+
if ( setSelectionTo ) {
context.fn.setSelection( setSelectionTo );
}
@@ -1154,7 +1154,7 @@ context.fn = $.extend( context.fn, {
ec = n;
eo = 0;
}
-
+
// Make sure sc and ec are leaf nodes
while ( sc.firstChild ) {
sc = sc.firstChild;
@@ -1292,7 +1292,7 @@ context.fn = $.extend( context.fn, {
// Give up
return context.$textarea;
}
-
+
var sel = context.$iframe[0].contentWindow.getSelection();
while ( sc.firstChild && sc.nodeName != '#text' ) {
sc = sc.firstChild;
@@ -1314,14 +1314,14 @@ context.fn = $.extend( context.fn, {
}
range.collapse();
range.moveEnd( 'character', options.start );
-
+
var range2 = context.$iframe[0].contentWindow.document.body.createTextRange();
if ( ec ) {
range2.moveToElementText( ec );
}
range2.collapse();
range2.moveEnd( 'character', options.end );
-
+
// IE does newline emulation for <p>s: <p>foo</p><p>bar</p> becomes foo\nbar just fine
// but <p>foo</p><br><br><p>bar</p> becomes foo\n\n\n\nbar , one \n too many
// Correct for this
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.js b/extensions/WikiEditor/modules/jquery.wikiEditor.js
index 1f3d1fa5..c2fb4094 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.js
@@ -1,12 +1,12 @@
/**
* This plugin provides a way to build a wiki-text editing user interface around a textarea.
- *
+ *
* @example To intialize without any modules:
* $( 'div#edittoolbar' ).wikiEditor();
- *
+ *
* @example To initialize with one or more modules, or to add modules after it's already been initialized:
* $( 'textarea#wpTextbox1' ).wikiEditor( 'addModule', 'toolbar', { ... config ... } );
- *
+ *
*/
( function( $ ) {
@@ -117,7 +117,7 @@ $.wikiEditor = {
/**
* Provides a way to extract messages from objects. Wraps the mediaWiki.msg() function, which
* may eventually become a wrapper for some kind of core MW functionality.
- *
+ *
* @param object Object to extract messages from
* @param property String of name of property which contains the message. This should be the base name of the
* property, which means that in the case of the object { this: 'that', fooMsg: 'bar' }, passing property as 'this'
@@ -152,7 +152,7 @@ $.wikiEditor = {
* 'default' or 'default-rtl'. If such key doesn't exist, the object itself is considered the actual value, which
* should ideally be the case so that you may use a string or object of any number of strings keyed by language
* with a default.
- *
+ *
* @param object Object to extract property from
* @param lang Language code, defaults to wgUserLanguage
*/
@@ -163,7 +163,7 @@ $.wikiEditor = {
/**
* Provides a way to extract the path of an icon in a certain language, automatically appending a version number for
* caching purposes and prepending an image path when icon paths are relative.
- *
+ *
* @param icon Icon object from e.g. toolbar config
* @param path Default icon path, defaults to $.wikiEditor.imgPath
* @param lang Language code, defaults to wgUserLanguage
@@ -214,7 +214,7 @@ if ( !$.wikiEditor.isSupported() ) {
var context = $(this).data( 'wikiEditor-context' );
// On first call, we need to set things up, but on all following calls we can skip right to the API handling
if ( !context || typeof context == 'undefined' ) {
-
+
// Star filling the context with useful data - any jQuery selections, as usual should be named with a preceding $
context = {
// Reference to the textarea element which the wikiEditor is being built around
@@ -248,18 +248,18 @@ if ( !context || typeof context == 'undefined' ) {
// List of extensions active on this context
'extensions': []
};
-
- /*
+
+ /**
* Externally Accessible API
- *
+ *
* These are available using calls to $(selection).wikiEditor( call, data ) where selection is a jQuery selection
* of the textarea that the wikiEditor instance was built around.
*/
-
+
context.api = {
/**
* Activates a module on a specific context with optional configuration data.
- *
+ *
* @param data Either a string of the name of a module to add without any additional configuration parameters,
* or an object with members keyed with module names and valued with configuration objects.
*/
@@ -272,7 +272,7 @@ if ( !context || typeof context == 'undefined' ) {
}
for ( var module in modules ) {
// Check for the existance of an available / supported module with a matching name and a create function
- if ( typeof module == 'string' && typeof $.wikiEditor.modules[module] !== 'undefined' &&
+ if ( typeof module == 'string' && typeof $.wikiEditor.modules[module] !== 'undefined' &&
$.wikiEditor.isSupported( $.wikiEditor.modules[module] ) )
{
// Extend the context's core API with this module's own API calls
@@ -295,20 +295,20 @@ if ( !context || typeof context == 'undefined' ) {
}
}
};
-
- /*
+
+ /**
* Event Handlers
- *
+ *
* These act as filters returning false if the event should be ignored or returning true if it should be passed
* on to all modules. This is also where we can attach some extra information to the events.
*/
-
+
context.evt = {
/* Empty until extensions add some; see jquery.wikiEditor.iframe.js for examples. */
};
-
+
/* Internal Functions */
-
+
context.fn = {
/**
* Executes core event filters as well as event handlers provided by modules.
@@ -322,7 +322,7 @@ if ( !context || typeof context == 'undefined' ) {
if ( typeof event.data == 'undefined' ) {
event.data = {};
}
-
+
// Allow filtering to occur
if ( name in context.evt ) {
if ( !context.evt[name]( event ) ) {
@@ -331,7 +331,7 @@ if ( !context || typeof context == 'undefined' ) {
}
var returnFromModules = null; //they return null by default
// Pass the event around to all modules activated on this context
-
+
for ( var module in context.modules ) {
if (
module in $.wikiEditor.modules &&
@@ -342,10 +342,10 @@ if ( !context || typeof context == 'undefined' ) {
if (ret != null) {
//if 1 returns false, the end result is false
if( returnFromModules == null ) {
- returnFromModules = ret;
+ returnFromModules = ret;
} else {
returnFromModules = returnFromModules && ret;
- }
+ }
}
}
}
@@ -460,15 +460,15 @@ if ( !context || typeof context == 'undefined' ) {
}
}
};
-
- /*
+
+ /**
* Base UI Construction
- *
+ *
* The UI is built from several containers, the outer-most being a div classed as "wikiEditor-ui". These containers
* provide a certain amount of "free" layout, but in some situations procedural layout is needed, which is performed
* as a response to the "resize" event.
*/
-
+
// Assemble a temporary div to place over the wikiEditor while it's being constructed
/* Disabling our loading div for now
var $loader = $( '<div></div>' )
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js b/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js
index 634672a8..22c6d89e 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.preview.js
@@ -78,7 +78,7 @@ fn: {
);
}
} );
-
+
context.$changesTab = context.fn.addView( {
'name': 'changes',
'titleMsg': 'wikieditor-preview-changes-tab',
@@ -91,7 +91,7 @@ fn: {
}
context.$changesTab.find( 'table.diff tbody' ).empty();
context.$changesTab.find( '.wikiEditor-preview-loading' ).show();
-
+
// Call the API. First PST the input, then diff it
var postdata = {
'action': 'parse',
@@ -99,7 +99,7 @@ fn: {
'text': wikitext,
'format': 'json'
};
-
+
$.post( mw.util.wikiScript( 'api' ), postdata, function( data ) {
try {
var postdata2 = {
@@ -114,7 +114,7 @@ fn: {
var section = $( '[name=wpSection]' ).val();
if ( section != '' )
postdata2['rvsection'] = section;
-
+
$.post( mw.util.wikiScript( 'api' ), postdata2, function( data ) {
// Add diff CSS
mw.loader.load( 'mediawiki.action.history.diff' );
@@ -133,7 +133,7 @@ fn: {
}, 'json' );
}
} );
-
+
var loadingMsg = mediaWiki.msg( 'wikieditor-preview-loading' );
context.modules.preview.$preview
.add( context.$changesTab )
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.previewDialog.js b/extensions/WikiEditor/modules/jquery.wikiEditor.previewDialog.js
index 72003055..ca88c79a 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.previewDialog.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.previewDialog.js
@@ -81,7 +81,7 @@ fn: {
if ( context.modules.preview.previewText == wikitext ) {
return;
}
-
+
$dialog.find( '.wikiEditor-preview-dialog-contents' ).empty();
$dialog.find( '.wikiEditor-ui-loading' ).show();
$.post(
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.publish.js b/extensions/WikiEditor/modules/jquery.wikiEditor.publish.js
index 5a758e43..5a3b6cd6 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.publish.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.publish.js
@@ -65,7 +65,7 @@ fn: {
$(this).find( '[rel]' ).each( function() {
$(this).text( mediaWiki.msg( $(this).attr( 'rel' ) ) );
});
-
+
/* REALLY DIRTY HACK! */
// Reformat the copyright warning stuff
var copyWarnHTML = $( '#editpage-copywarn p' ).html();
@@ -80,11 +80,11 @@ fn: {
}
newCopyWarnHTML += '</ul>';
// No list if there's only one element
- $(this).find( '.wikiEditor-publish-dialog-copywarn' ).html(
+ $(this).find( '.wikiEditor-publish-dialog-copywarn' ).html(
copyWarnStatements.length > 1 ? newCopyWarnHTML : copyWarnHTML
);
/* END OF REALLY DIRTY HACK */
-
+
if ( $( '#wpMinoredit' ).size() == 0 )
$( '#wikiEditor-' + context.instance + '-dialog-minor' ).hide();
else if ( $( '#wpMinoredit' ).is( ':checked' ) )
@@ -95,7 +95,7 @@ fn: {
else if ( $( '#wpWatchthis' ).is( ':checked' ) )
$( '#wikiEditor-' + context.instance + '-dialog-watch' )
.attr( 'checked', 'checked' );
-
+
$(this).find( 'form' ).submit( function( e ) {
$(this).closest( '.ui-dialog' ).find( 'button:first' ).click();
e.preventDefault();
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.templateEditor.js b/extensions/WikiEditor/modules/jquery.wikiEditor.templateEditor.js
index 794bddc7..9857b9e8 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.templateEditor.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.templateEditor.js
@@ -6,9 +6,9 @@
'nameMappings': { //keep these all lowercase to navigate web of redirects
"infobox skyscraper": "building_name",
"infobox settlement": "official_name"
-},
+},
+
-
/**
* Compatability map
*/
@@ -36,13 +36,13 @@
* Event handlers
*/
evt: {
-
+
mark: function( context, event ) {
// The markers returned by this function are skipped on realchange, so don't regenerate them in that case
if ( context.modules.highlight.currentScope == 'realchange' ) {
return;
}
-
+
// Get references to the markers and tokens from the current context
var markers = context.modules.highlight.markers;
var tokenArray = context.modules.highlight.tokenArray;
@@ -96,10 +96,10 @@ evt: {
// No change
return;
}
-
+
// Text changed, regenerate model
var model = $.wikiEditor.modules.templateEditor.fn.updateModel( $( node ) );
-
+
// Update template name if needed
if ( $( node ).parent().hasClass( 'wikiEditor-template' ) ) {
var $label = $( node ).parent().find( '.wikiEditor-template-label' );
@@ -108,7 +108,7 @@ evt: {
$label.text( displayName );
}
}
-
+
// Wrap or unwrap the template if needed
if ( $( node ).parent().hasClass( 'wikiEditor-template' ) &&
!model.isCollapsible() ) {
@@ -133,7 +133,7 @@ evt: {
}//if opentemplates
}
}, //mark
-
+
keydown: function( context, event ) {
// Reset our ignoreKeypress variable if it's set to true
if ( context.$iframe.data( 'ignoreKeypress' ) ) {
@@ -156,7 +156,7 @@ evt: {
case 38:// Up
case 39:// Right
case 40: //Down
- return true;
+ return true;
default:
// Set the ignroreKeypress variable so we don't allow typing if the key is held
context.$iframe.data( 'ignoreKeypress', true );
@@ -197,7 +197,7 @@ exp: [
{ 'regex': /}}/, 'label': "TEMPLATE_END", 'markAfter': true }
],
/**
- * Configuration
+ * Configuration
*/
cfg: {
},
@@ -229,7 +229,7 @@ fn: {
.prepend(
'<span class="wikiEditor-template-expand wikiEditor-noinclude"></span>' +
'<span class="wikiEditor-template-name wikiEditor-noinclude">' +
- '<span class="wikiEditor-template-label wikiEditor-noinclude">' +
+ '<span class="wikiEditor-template-label wikiEditor-noinclude">' +
$.wikiEditor.modules.templateEditor.fn.getTemplateDisplayName( model ) + '</span>' +
'<span class="wikiEditor-template-dialog wikiEditor-noinclude"></span>' +
'</span>'
@@ -252,21 +252,21 @@ fn: {
if ( typeof ( opera ) == "undefined" ) {
$template.parent().attr('contentEditable', 'false');
}
-
+
$template.click( function(event) {event.preventDefault(); return false;} );
-
+
$template.find( '.wikiEditor-template-name' )
- .click( function( event ) {
- $.wikiEditor.modules.templateEditor.fn.createDialog( $wrapper );
- event.stopPropagation();
- return false;
+ .click( function( event ) {
+ $.wikiEditor.modules.templateEditor.fn.createDialog( $wrapper );
+ event.stopPropagation();
+ return false;
} )
.mousedown( function( event ) { event.stopPropagation(); return false; } );
$template.find( '.wikiEditor-template-expand' )
- .click( function( event ) {
- $.wikiEditor.modules.templateEditor.fn.toggleWikiTextEditor( $wrapper );
+ .click( function( event ) {
+ $.wikiEditor.modules.templateEditor.fn.toggleWikiTextEditor( $wrapper );
event.stopPropagation();
- return false;
+ return false;
} )
.mousedown( function( event ) { event.stopPropagation(); return false; } );
},
@@ -281,22 +281,22 @@ fn: {
$template
.toggleClass( 'wikiEditor-template-expanded' )
.toggleClass( 'wikiEditor-template-collapsed' ) ;
-
- var $templateText = $template.find( '.wikiEditor-template-text' );
+
+ var $templateText = $template.find( '.wikiEditor-template-text' );
$templateText.toggleClass( 'wikiEditor-template-text-shrunken' );
$templateText.toggleClass( 'wikiEditor-template-text-visible' );
if( $templateText.hasClass('wikiEditor-template-text-shrunken') ){
//we just closed the template
-
+
// Update the model if we need to
if ( $templateText.html() != $templateText.data( 'oldHTML' ) ) {
var templateModel = $.wikiEditor.modules.templateEditor.fn.updateModel( $templateText );
-
+
//this is the only place the template name can be changed; keep the template name in sync
var $tLabel = $template.find( '.wikiEditor-template-label' );
$tLabel.text( $.wikiEditor.modules.templateEditor.fn.getTemplateDisplayName( templateModel ) );
}
-
+
}
},
/**
@@ -424,10 +424,10 @@ fn: {
// Remove any leftover rows
$rows.remove();
$fields.find( 'label' ).autoEllipsis();
- // Ensure our close button doesn't recieve the ui-state-focus class
+ // Ensure our close button doesn't recieve the ui-state-focus class
$( this ).parent( '.ui-dialog' ).find( '.ui-dialog-titlebar-close' )
.removeClass( 'ui-state-focus' );
-
+
// Set tabindexes on form fields if needed
// First unset the tabindexes on the buttons and existing form fields
// so the order doesn't get messed up
@@ -470,7 +470,7 @@ fn: {
}
return model;
},
-
+
/**
* Gets template display name
*/
@@ -485,24 +485,24 @@ fn: {
}
return tName;
},
-
+
/**
* Builds a template model from given wikitext representation, allowing object-oriented manipulation of the contents
* of the template while preserving whitespace and formatting.
- *
+ *
* @param wikitext String of wikitext content
*/
model: function( wikitext ) {
-
+
/* Private members */
-
+
var collapsible = true;
-
+
/* Private Functions */
-
+
/**
* Builds a Param object.
- *
+ *
* @param name
* @param value
* @param number
@@ -520,7 +520,7 @@ fn: {
}
/**
* Builds a Range object.
- *
+ *
* @param begin
* @param end
*/
@@ -530,7 +530,7 @@ fn: {
}
/**
* Set 'original' to true if you want the original value irrespective of whether the model's been changed
- *
+ *
* @param name
* @param value
* @param original
@@ -567,9 +567,9 @@ fn: {
}
return retVal;
};
-
+
/* Public Functions */
-
+
/**
* Get template name
*/
@@ -582,7 +582,7 @@ fn: {
};
/**
* Set template name (if we want to support this)
- *
+ *
* @param name
*/
this.setName = function( name ) {
@@ -590,7 +590,7 @@ fn: {
};
/**
* Set value for a given param name / number
- *
+ *
* @param name
* @param value
*/
@@ -599,7 +599,7 @@ fn: {
};
/**
* Get value for a given param name / number
- *
+ *
* @param name
*/
this.getValue = function( name ) {
@@ -607,7 +607,7 @@ fn: {
};
/**
* Get original value of a param
- *
+ *
* @param name
*/
this.getOriginalValue = function( name ) {
@@ -645,11 +645,11 @@ fn: {
}
return newText;
};
-
+
this.isCollapsible = function() {
return collapsible;
};
-
+
/**
* Update ranges if there's been a change in one or more 'segments' of the template.
* Removes adjustment function so adjustment is only made once ever.
@@ -668,7 +668,7 @@ fn: {
ranges[i].end += adjustment;
}
};
-
+
// Whitespace* {{ whitespace* nonwhitespace:
if ( wikitext.match( /\s*{{\s*[^\s|]*:/ ) ) {
collapsible = false; // is a parser function
@@ -685,8 +685,8 @@ fn: {
sanatizedStr = sanatizedStr.substring( 0, endBraces.index ) + " " +
sanatizedStr.substring( endBraces.index + 2 );
}
-
-
+
+
//treat HTML comments like whitespace
while ( sanatizedStr.indexOf( '<!' ) != -1 ) {
startIndex = sanatizedStr.indexOf( '<!' );
@@ -698,7 +698,7 @@ fn: {
sanatizedStr =
sanatizedStr.substring( 0, startIndex ) + sanatizedSegment + sanatizedStr.substring( endIndex );
}
-
+
// Match the open braces we just found with equivalent closing braces note, works for any level of braces
while ( sanatizedStr.indexOf( '{{' ) != -1 ) {
startIndex = sanatizedStr.indexOf( '{{' ) + 1;
@@ -725,7 +725,7 @@ fn: {
sanatizedStr =
sanatizedStr.substring( 0, startIndex ) + sanatizedSegment + sanatizedStr.substring( endIndex );
}
-
+
/*
* Parse 1 param at a time
*/
@@ -771,11 +771,11 @@ fn: {
currentField = sanatizedStr.substring( oldDivider+1, divider );
if ( currentField.indexOf( '=' ) == -1 ) {
// anonymous field, gets a number
-
+
//default values, since we'll allow empty values
valueBeginIndex = oldDivider + 1;
valueEndIndex = oldDivider + 1;
-
+
valueBegin = currentField.match( /\S+/ ); //first nonwhitespace character
if( valueBegin != null ){
valueBeginIndex = valueBegin.index + oldDivider+1;
@@ -816,16 +816,16 @@ fn: {
continue;
}
nameEndIndex = nameEnd.index + oldDivider + 2;
- // All the chars upto now
+ // All the chars upto now
ranges.push( new Range( ranges[ranges.length-1].end, nameBeginIndex ) );
nameIndex = ranges.push( new Range( nameBeginIndex, nameEndIndex ) ) - 1;
currentValue = currentField.substring( currentField.indexOf( '=' ) + 1);
oldDivider += currentField.indexOf( '=' ) + 1;
-
+
//default values, since we'll allow empty values
valueBeginIndex = oldDivider + 1;
valueEndIndex = oldDivider + 1;
-
+
// First nonwhitespace character
valueBegin = currentValue.match( /\S+/ );
if( valueBegin != null ){
@@ -853,7 +853,7 @@ fn: {
}
// The rest of the string
ranges.push( new Range( valueEndIndex, wikitext.length ) );
-
+
// Save vars
this.ranges = ranges;
this.wikitext = wikitext;
@@ -861,5 +861,5 @@ fn: {
this.paramsByName = paramsByName;
this.templateNameIndex = templateNameIndex;
} //model
-}
+}
}; } )( jQuery );
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.toc.js b/extensions/WikiEditor/modules/jquery.wikiEditor.toc.js
index a01335e2..a714d253 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.toc.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.toc.js
@@ -70,11 +70,11 @@ evt: {
},
resize: function( context, event ) {
var availableWidth = context.$wikitext.width() - parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ),
- totalMinWidth = parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) +
+ totalMinWidth = parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ) +
parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth );
context.$ui.find( '.wikiEditor-ui-right' )
.resizable( 'option', 'maxWidth', availableWidth );
- if ( context.modules.toc.$toc.data( 'positionMode' ) != 'disabled' &&
+ if ( context.modules.toc.$toc.data( 'positionMode' ) != 'disabled' &&
context.$wikitext.width() < totalMinWidth ) {
$.wikiEditor.modules.toc.fn.disable( context );
} else if ( context.modules.toc.$toc.data( 'positionMode' ) == 'disabled' &&
@@ -97,7 +97,7 @@ evt: {
// reset the height of the TOC
if ( !context.modules.toc.$toc.data( 'collapsed' ) ){
context.modules.toc.$toc.height(
- context.$ui.find( '.wikiEditor-ui-left' ).height() -
+ context.$ui.find( '.wikiEditor-ui-left' ).height() -
context.$ui.find( '.tab-toc' ).outerHeight()
);
}
@@ -219,20 +219,20 @@ fn: {
// store position mode
context.modules.toc.$toc.data( 'positionMode', 'goofy' );
// store the width of the TOC, to ensure we dont allow it to be larger than this when switching back
- context.modules.toc.$toc.data( 'positionModeChangeAt',
+ context.modules.toc.$toc.data( 'positionModeChangeAt',
context.$ui.find( '.wikiEditor-ui-right' ).width() );
width = $.wikiEditor.modules.toc.cfg.textMinimumWidth;
// set our styles for goofy mode
context.$ui.find( '.wikiEditor-ui-left' )
.css( $.wikiEditor.modules.toc.cfg.flexProperty, '')
.css( { 'position': 'absolute', 'float': 'none',
- 'left': $.wikiEditor.modules.toc.cfg.rtl ? 'auto': 0,
+ 'left': $.wikiEditor.modules.toc.cfg.rtl ? 'auto': 0,
'right' : $.wikiEditor.modules.toc.cfg.rtl ? 0 : 'auto' } )
.children()
.css( $.wikiEditor.modules.toc.cfg.flexProperty, '' );
context.$ui.find( '.wikiEditor-ui-right' )
.css( { 'width': 'auto', 'position': 'absolute', 'float': 'none',
- 'right': $.wikiEditor.modules.toc.cfg.rtl ? 'auto': 0,
+ 'right': $.wikiEditor.modules.toc.cfg.rtl ? 'auto': 0,
'left' : $.wikiEditor.modules.toc.cfg.rtl ? 0 : 'auto' } );
context.$wikitext
.css( 'position', 'relative' );
@@ -296,7 +296,7 @@ fn: {
* @param {Object} context
*/
update: function( context ) {
- //temporarily commenting this out because it is causing all kinds of cursor
+ //temporarily commenting this out because it is causing all kinds of cursor
//and text jumping issues in IE. WIll get back to this --pdhanda
/*
var div = context.fn.beforeSelection( 'wikiEditor-toc-header' );
@@ -304,16 +304,16 @@ fn: {
// beforeSelection couldn't figure it out, keep the old highlight state
return;
}
-
+
$.wikiEditor.modules.toc.fn.unhighlight( context );
var section = div.data( 'section' ) || 0;
if ( context.data.outline.length > 0 ) {
var sectionLink = context.modules.toc.$toc.find( 'div.section-' + section );
sectionLink.addClass( 'current' );
-
+
// Scroll the highlighted link into view if necessary
var relTop = sectionLink.offset().top - context.modules.toc.$toc.offset().top;
-
+
var scrollTop = context.modules.toc.$toc.scrollTop();
var divHeight = context.modules.toc.$toc.height();
var sectionHeight = sectionLink.height();
@@ -326,14 +326,14 @@ fn: {
}
*/
},
-
+
/**
* Collapse the contents module
*
* @param {Object} event Event object with context as data
*/
collapse: function( event ) {
- var $this = $( this ),
+ var $this = $( this ),
context = $this.data( 'context' );
if( context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' ) {
$.wikiEditor.modules.toc.fn.switchLayout( context );
@@ -348,15 +348,15 @@ fn: {
$( this ).css( $.wikiEditor.modules.toc.cfg.flexProperty, 0 );
} )
.children()
- .animate( leftChildParam, 'fast', function() {
- $( this ).css( $.wikiEditor.modules.toc.cfg.flexProperty, 0 );
+ .animate( leftChildParam, 'fast', function() {
+ $( this ).css( $.wikiEditor.modules.toc.cfg.flexProperty, 0 );
} );
context.$ui.find( '.wikiEditor-ui-right' )
- .css( {
- 'marginTop' : '1px',
- 'position' : 'absolute',
- 'left' : $.wikiEditor.modules.toc.cfg.rtl ? 0 : 'auto',
- 'right' : $.wikiEditor.modules.toc.cfg.rtl ? 'auto' : 0,
+ .css( {
+ 'marginTop' : '1px',
+ 'position' : 'absolute',
+ 'left' : $.wikiEditor.modules.toc.cfg.rtl ? 0 : 'auto',
+ 'right' : $.wikiEditor.modules.toc.cfg.rtl ? 'auto' : 0,
'top' : pT } )
.fadeOut( 'fast', function() {
$( this ).hide()
@@ -366,11 +366,11 @@ fn: {
context.fn.trigger( 'tocCollapse' );
context.fn.trigger( 'resize' );
} );
-
+
$.cookie( 'wikiEditor-' + context.instance + '-toc-width', 0 );
return false;
},
-
+
/**
* Expand the contents module
*
@@ -472,7 +472,7 @@ fn: {
$( this ).addClass( 'current' );
//$( this ).removeClass( 'current' );
setTimeout( function() { $.wikiEditor.modules.toc.fn.unhighlight( context ) }, 1000 );
-
+
if ( typeof $.trackAction != 'undefined' )
$.trackAction( 'ntoc.heading' );
event.preventDefault();
@@ -541,7 +541,7 @@ fn: {
.data( 'resizableDone', true )
.find( '.wikiEditor-ui-right' )
.data( 'wikiEditor-ui-left', context.$ui.find( '.wikiEditor-ui-left' ) )
- .resizable( { handles: 'w,e', preventPositionLeftChange: true,
+ .resizable( { handles: 'w,e', preventPositionLeftChange: true,
minWidth: parseFloat( $.wikiEditor.modules.toc.cfg.minimumWidth ),
start: function( e, ui ) {
var $this = $( this );
@@ -557,7 +557,7 @@ fn: {
'right': 0
} )
.appendTo( context.$ui.find( '.wikiEditor-ui-left' ) );
- $this.resizable( 'option', 'maxWidth', $this.parent().width() -
+ $this.resizable( 'option', 'maxWidth', $this.parent().width() -
parseFloat( $.wikiEditor.modules.toc.cfg.textMinimumWidth ) );
if(context.modules.toc.$toc.data( 'positionMode' ) == 'goofy' ) {
$.wikiEditor.modules.toc.fn.switchLayout( context );
@@ -611,7 +611,7 @@ fn: {
$.wikiEditor.modules.toc.fn.redraw( context, initialWidth );
}
}
-
+
// Normalize heading levels for list creation
// This is based on Linker::generateTOC(), so it should behave like the
// TOC on rendered articles does - which is considdered to be correct
@@ -640,7 +640,7 @@ fn: {
structure.unshift( { 'text': mw.config.get( 'wgPageName' ).replace( /_/g, ' ' ), 'level': 1, 'index': 0 } );
}
context.modules.toc.$toc.html( buildList( structure ) );
-
+
if ( !context.$ui.data( 'resizableDone' ) ) {
buildResizeControls();
buildCollapseControls();
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.config.js b/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.config.js
index ab92d173..15ecb36a 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.config.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.config.js
@@ -492,12 +492,12 @@ getDefaultConfig: function() {
"\u0127", "\u00cd", "\u00ed", "\u00cc", "\u00ec", "\u00ce", "\u00ee", "\u00cf", "\u00ef",
"\u0128", "\u0129", "\u01cf", "\u01d0", "\u012a", "\u012b", "\u012c", "\u012d", "\u0130",
"\u0131", "\u012e", "\u012f", "\u0134", "\u0135", "\u0136", "\u0137", "\u0139", "\u013a",
- "\u013b", "\u013c", "\u013d", "\u013e", "\u0141", "\u0142", "\u013f", "\u0140", "\u0143",
- "\u0144", "\u00d1", "\u00f1", "\u0145", "\u0146", "\u0147", "\u0148", "\u00d3", "\u00f3",
- "\u00d2", "\u00f2", "\u00d4", "\u00f4", "\u00d6", "\u00f6", "\u00d5", "\u00f5", "\u01d1",
- "\u01d2", "\u014c", "\u014d", "\u014e", "\u014f", "\u01ea", "\u01eb", "\u0150", "\u0151",
- "\u0154", "\u0155", "\u0156", "\u0157", "\u0158", "\u0159", "\u015a", "\u015b", "\u015c",
- "\u015d", "\u015e", "\u015f", "\u0160", "\u0161", "\u0162", "\u0163", "\u0164", "\u0165",
+ "\u013b", "\u013c", "\u013d", "\u013e", "\u0141", "\u0142", "\u0143", "\u0144", "\u00d1",
+ "\u00f1", "\u0145", "\u0146", "\u0147", "\u0148", "\u00d3", "\u00f3", "\u00d2", "\u00f2",
+ "\u00d4", "\u00f4", "\u00d6", "\u00f6", "\u00d5", "\u00f5", "\u01d1", "\u01d2", "\u014c",
+ "\u014d", "\u014e", "\u014f", "\u01ea", "\u01eb", "\u0150", "\u0151", "\u0154", "\u0155",
+ "\u0156", "\u0157", "\u0158", "\u0159", "\u015a", "\u015b", "\u015c", "\u015d", "\u015e",
+ "\u015f", "\u0160", "\u0161", "\u0218", "\u0219", "\u021a", "\u021b", "\u0164", "\u0165",
"\u00da", "\u00fa", "\u00d9", "\u00f9", "\u00db", "\u00fb", "\u00dc", "\u00fc", "\u0168",
"\u0169", "\u016e", "\u016f", "\u01d3", "\u01d4", "\u016a", "\u016b", "\u01d6", "\u01d8",
"\u01da", "\u01dc", "\u016c", "\u016d", "\u0172", "\u0173", "\u0170", "\u0171", "\u0174",
@@ -749,7 +749,7 @@ getDefaultConfig: function() {
"\u06D4", "\u06FD", "\u06FE",
// special digits
"\u06F0", "\u06F1", "\u06F2", "\u06F3", "\u06F4", "\u06F5", "\u06F6", "\u06F7",
- "\u06F8", "\u06F9",
+ "\u06F8", "\u06F9"
]
},
'hebrew': {
diff --git a/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js b/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js
index 7a72c923..20d8ecd9 100644
--- a/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js
+++ b/extensions/WikiEditor/modules/jquery.wikiEditor.toolbar.js
@@ -438,13 +438,13 @@ fn: {
}
},
buildBookmark : function( context, id, page ) {
- var label = $.wikiEditor.autoMsg( page,
- 'label' );
+ var label = $.wikiEditor.autoMsg( page, 'label' );
return $( '<div/>' )
.text( label )
.attr( 'rel', id )
.data( 'context', context )
.mousedown( function( e ) {
+ context.fn.saveCursorAndScrollTop();
// No dragging!
e.preventDefault();
return false;
@@ -464,6 +464,7 @@ fn: {
if ( $.trackAction !== undefined){
$.trackAction(section + '.' + $(this).attr('rel'));
}
+ context.fn.restoreCursorAndScrollTop();
// No dragging!
event.preventDefault();
return false;
@@ -488,7 +489,7 @@ fn: {
html += $.wikiEditor.modules.toolbar.fn.buildRow( context, page.rows[i] );
}
}
- $page.html( html );
+ $page.html( html + '</table>');
break;
case 'characters':
$page.addClass( 'page-characters' );
@@ -534,7 +535,7 @@ fn: {
for ( var i = 0; i< headings.length; i++ ) {
html += '<th>' + $.wikiEditor.autoMsg( headings[i], ['html', 'text'] ) + '</th>';
}
- return html;
+ return html + '</tr>';
},
buildRow : function( context, row ) {
var html = '<tr>';
@@ -542,8 +543,7 @@ fn: {
html += '<td class="cell cell-' + cell + '" valign="top"><span>' +
$.wikiEditor.autoMsg( row[cell], ['html', 'text'] ) + '</span></td>';
}
- html += '</tr>';
- return html;
+ return html + '</tr>';
},
buildCharacter : function( character, actions ) {
if ( typeof character == 'string' ) {
@@ -557,7 +557,7 @@ fn: {
}
}
};
- } else if ( 0 in character && 1 in character ) {
+ } else if ( character && 0 in character && 1 in character ) {
character = {
'label' : character[0],
'action' : {
@@ -569,10 +569,12 @@ fn: {
}
};
}
- if ( 'action' in character && 'label' in character ) {
+ if ( character && 'action' in character && 'label' in character ) {
actions[character.label] = character.action;
return '<span rel="' + character.label + '">' + character.label + '</span>';
}
+ mw.log( "A character for the toolbar was undefined. This is not supposed to happen. Double check the config." );
+ return ""; // bug 31673; also an additional fix for bug 24208...
},
buildTab : function( context, id, section ) {
var selected = $.cookie( 'wikiEditor-' + context.instance + '-toolbar-section' );
@@ -580,7 +582,7 @@ fn: {
if ( selected !== null ) {
$.cookie( 'wikiEditor-' + context.instance + '-toolbar-section', selected, { expires: 30, path: '/' } );
}
- var $link =
+ var $link =
$( '<a/>' )
.addClass( selected == id ? 'current' : null )
.attr( 'href', '#' )
@@ -661,7 +663,7 @@ fn: {
var $section = $( '<div/>' ).attr( { 'class': section.type + ' section section-' + id, 'rel': id } );
var selected = $.cookie( 'wikiEditor-' + context.instance + '-toolbar-section' );
var show = selected == id;
-
+
if ( section.deferLoad !== undefined && section.deferLoad && id !== 'main' && !show ) {
// This class shows the spinner and serves as a marker for the click handler in buildTab()
$section.addClass( 'loading' ).append( $( '<div/>' ).addClass( 'spinner' ) );
@@ -672,7 +674,7 @@ fn: {
} else {
$.wikiEditor.modules.toolbar.fn.reallyBuildSection( context, id, section, $section );
}
-
+
// Show or hide section
if ( id !== 'main' ) {
$section.css( 'display', show ? 'block' : 'none' );