mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/WikiEditor
synced 2024-11-12 09:57:16 +00:00
Merge "jquery.wikiEditor.iframe: Restore function signatures"
This commit is contained in:
commit
cf897155b0
|
@ -277,7 +277,11 @@ context.evt = $.extend( context.evt, {
|
||||||
* Internally used functions
|
* Internally used functions
|
||||||
*/
|
*/
|
||||||
context.fn = $.extend( context.fn, {
|
context.fn = $.extend( context.fn, {
|
||||||
highlightLine: function ( highlightLine ) {
|
/**
|
||||||
|
* @param {jQuery} $element
|
||||||
|
* @param mode
|
||||||
|
*/
|
||||||
|
highlightLine: function ( $element ) {
|
||||||
if ( !$element.is( 'p' ) ) {
|
if ( !$element.is( 'p' ) ) {
|
||||||
$element = $element.closest( 'p' );
|
$element = $element.closest( 'p' );
|
||||||
}
|
}
|
||||||
|
@ -285,7 +289,7 @@ context.fn = $.extend( context.fn, {
|
||||||
setTimeout( function() { $element.animate( { 'backgroundColor': 'white' }, 'slow' ); }, 100 );
|
setTimeout( function() { $element.animate( { 'backgroundColor': 'white' }, 'slow' ); }, 100 );
|
||||||
setTimeout( function() { $element.css( 'backgroundColor', 'white' ); }, 1000 );
|
setTimeout( function() { $element.css( 'backgroundColor', 'white' ); }, 1000 );
|
||||||
},
|
},
|
||||||
htmlToText: function ( htmlToText ) {
|
htmlToText: function ( html ) {
|
||||||
// This function is slow for large inputs, so aggressively cache input/output pairs
|
// This function is slow for large inputs, so aggressively cache input/output pairs
|
||||||
if ( html in context.htmlToTextMap ) {
|
if ( html in context.htmlToTextMap ) {
|
||||||
return context.htmlToTextMap[html];
|
return context.htmlToTextMap[html];
|
||||||
|
@ -359,7 +363,7 @@ context.fn = $.extend( context.fn, {
|
||||||
* @param strict If true, the element the selection starts in cannot match (default: false)
|
* @param strict If true, the element the selection starts in cannot match (default: false)
|
||||||
* @return jQuery object or null if unknown
|
* @return jQuery object or null if unknown
|
||||||
*/
|
*/
|
||||||
beforeSelection: function ( beforeSelection ) {
|
beforeSelection: function ( classname, strict ) {
|
||||||
if ( typeof classname === 'undefined' ) {
|
if ( typeof classname === 'undefined' ) {
|
||||||
classname = '';
|
classname = '';
|
||||||
}
|
}
|
||||||
|
@ -442,7 +446,7 @@ context.fn = $.extend( context.fn, {
|
||||||
/**
|
/**
|
||||||
* Object used by traverser(). Don't use this unless you know what you're doing
|
* Object used by traverser(). Don't use this unless you know what you're doing
|
||||||
*/
|
*/
|
||||||
rawTraverser: function ( rawTraverser ) {
|
rawTraverser: function ( node, inP, ancestor, skipNoinclude ) {
|
||||||
this.node = node;
|
this.node = node;
|
||||||
this.inP = inP;
|
this.inP = inP;
|
||||||
this.ancestor = ancestor;
|
this.ancestor = ancestor;
|
||||||
|
@ -530,28 +534,28 @@ context.fn = $.extend( context.fn, {
|
||||||
* @return Traverser object, use .next() or .prev() to get a traverser object referring to the
|
* @return Traverser object, use .next() or .prev() to get a traverser object referring to the
|
||||||
* previous/next node
|
* previous/next node
|
||||||
*/
|
*/
|
||||||
traverser: function ( traverser ) {
|
traverser: function ( start ) {
|
||||||
// Find the leftmost leaf node in the tree
|
// Find the leftmost leaf node in the tree
|
||||||
var startNode = start.jquery ? start.get( 0 ) : start;
|
var startNode = start.jquery ? start.get( 0 ) : start;
|
||||||
var node = startNode;
|
var node = startNode;
|
||||||
var inP = node.nodeName == 'P' ? node : null;
|
var inP = node.nodeName === 'P' ? node : null;
|
||||||
do {
|
do {
|
||||||
// Filter nodes with the wikiEditor-noinclude class
|
// Filter nodes with the wikiEditor-noinclude class
|
||||||
// Don't use $( p ).hasClass( 'wikiEditor-noinclude' ) because
|
// Don't use $( p ).hasClass( 'wikiEditor-noinclude' ) because
|
||||||
// $() is slow in a tight loop
|
// $() is slow in a tight loop
|
||||||
while ( node && ( ' ' + node.className + ' ' ).indexOf( ' wikiEditor-noinclude ' ) != -1 ) {
|
while ( node && ( ' ' + node.className + ' ' ).indexOf( ' wikiEditor-noinclude ' ) !== -1 ) {
|
||||||
node = node.nextSibling;
|
node = node.nextSibling;
|
||||||
}
|
}
|
||||||
if ( node && node.firstChild ) {
|
if ( node && node.firstChild ) {
|
||||||
node = node.firstChild;
|
node = node.firstChild;
|
||||||
if ( node.nodeName == 'P' ) {
|
if ( node.nodeName === 'P' ) {
|
||||||
inP = node;
|
inP = node;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while ( node && node.firstChild );
|
} while ( node && node.firstChild );
|
||||||
return new context.fn.rawTraverser( node, inP, startNode, true );
|
return new context.fn.rawTraverser( node, inP, startNode, true );
|
||||||
},
|
},
|
||||||
getOffset: function ( getOffset ) {
|
getOffset: function ( offset ) {
|
||||||
if ( !context.offsets ) {
|
if ( !context.offsets ) {
|
||||||
context.fn.refreshOffsets();
|
context.fn.refreshOffsets();
|
||||||
}
|
}
|
||||||
|
@ -642,10 +646,10 @@ context.fn = $.extend( context.fn, {
|
||||||
/**
|
/**
|
||||||
* Update the history queue
|
* Update the history queue
|
||||||
*
|
*
|
||||||
* @param htmlChange pass true or false to inidicate if there was a text change that should potentially
|
* @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 ( updateHistory ) {
|
updateHistory: function ( htmlChange ) {
|
||||||
var newHTML = context.$content.html();
|
var newHTML = context.$content.html();
|
||||||
var newSel = context.fn.getCaretPosition();
|
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?
|
||||||
|
@ -917,7 +921,7 @@ context.fn = $.extend( context.fn, {
|
||||||
* selection is empty.
|
* selection is empty.
|
||||||
* DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead
|
* DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead
|
||||||
*/
|
*/
|
||||||
encapsulateSelection: function ( encapsulateSelection ) {
|
encapsulateSelection: function ( options ) {
|
||||||
var selText = $(this).textSelection( 'getSelection' );
|
var selText = $(this).textSelection( 'getSelection' );
|
||||||
var selTextArr;
|
var selTextArr;
|
||||||
var collapseToEnd = false;
|
var collapseToEnd = false;
|
||||||
|
@ -1129,7 +1133,7 @@ context.fn = $.extend( context.fn, {
|
||||||
* Gets the position (in resolution of bytes not nessecarily characters) in a textarea
|
* Gets the position (in resolution of bytes not nessecarily characters) in a textarea
|
||||||
* DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead
|
* DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead
|
||||||
*/
|
*/
|
||||||
getCaretPosition: function ( getCaretPosition ) {
|
getCaretPosition: function ( options ) {
|
||||||
var startPos = null, endPos = null;
|
var startPos = null, endPos = null;
|
||||||
if ( context.$iframe[0].contentWindow.getSelection ) {
|
if ( context.$iframe[0].contentWindow.getSelection ) {
|
||||||
var selection = context.$iframe[0].contentWindow.getSelection();
|
var selection = context.$iframe[0].contentWindow.getSelection();
|
||||||
|
@ -1266,7 +1270,7 @@ context.fn = $.extend( context.fn, {
|
||||||
* @param startContainer Element in iframe to start selection in. If not set, start is a character offset
|
* @param startContainer Element in iframe to start selection in. If not set, start is a character offset
|
||||||
* @param endContainer Element in iframe to end selection in. If not set, end is a character offset
|
* @param endContainer Element in iframe to end selection in. If not set, end is a character offset
|
||||||
*/
|
*/
|
||||||
setSelection: function ( setSelection ) {
|
setSelection: function ( options ) {
|
||||||
var sc = options.startContainer, ec = options.endContainer;
|
var sc = options.startContainer, ec = options.endContainer;
|
||||||
sc = sc && sc.jquery ? sc[0] : sc;
|
sc = sc && sc.jquery ? sc[0] : sc;
|
||||||
ec = ec && ec.jquery ? ec[0] : ec;
|
ec = ec && ec.jquery ? ec[0] : ec;
|
||||||
|
@ -1353,7 +1357,7 @@ context.fn = $.extend( context.fn, {
|
||||||
* Scroll a textarea to the current cursor position. You can set the cursor position with setSelection()
|
* Scroll a textarea to the current cursor position. You can set the cursor position with setSelection()
|
||||||
* DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead
|
* DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead
|
||||||
*/
|
*/
|
||||||
scrollToCaretPosition: function ( scrollToCaretPosition ) {
|
scrollToCaretPosition: function ( options ) {
|
||||||
context.fn.scrollToTop( context.fn.getElementAtCursor(), true );
|
context.fn.scrollToTop( context.fn.getElementAtCursor(), true );
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@ -1363,7 +1367,7 @@ context.fn = $.extend( context.fn, {
|
||||||
* @param $element jQuery object containing an element in the iframe
|
* @param $element jQuery object containing an element in the iframe
|
||||||
* @param force If true, scroll the element even if it's already visible
|
* @param force If true, scroll the element even if it's already visible
|
||||||
*/
|
*/
|
||||||
scrollToTop: function ( scrollToTop ) {
|
scrollToTop: function ( $element, force ) {
|
||||||
var html = context.$content.closest( 'html' ),
|
var html = context.$content.closest( 'html' ),
|
||||||
body = context.$content.closest( 'body' ),
|
body = context.$content.closest( 'body' ),
|
||||||
parentHtml = $( 'html' ),
|
parentHtml = $( 'html' ),
|
||||||
|
|
Loading…
Reference in a new issue