From ab13c162cfe0a092326b86030dee8af7f5800ba8 Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 22 Nov 2013 12:55:25 +0000 Subject: [PATCH] jquery.wikiEditor.iframe: Restore function signatures Follows-up 1a2daca06a6ad637262356, which broke this file due to a bad find/replace action. Change-Id: Ia6db450296ac579dade2ec4ff116e2519d69c6d3 --- modules/jquery.wikiEditor.iframe.js | 36 ++++++++++++++++------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/modules/jquery.wikiEditor.iframe.js b/modules/jquery.wikiEditor.iframe.js index cb21debc..538fcb18 100644 --- a/modules/jquery.wikiEditor.iframe.js +++ b/modules/jquery.wikiEditor.iframe.js @@ -277,7 +277,11 @@ context.evt = $.extend( context.evt, { * Internally used functions */ context.fn = $.extend( context.fn, { - highlightLine: function ( highlightLine ) { + /** + * @param {jQuery} $element + * @param mode + */ + highlightLine: function ( $element ) { if ( !$element.is( '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.css( 'backgroundColor', 'white' ); }, 1000 ); }, - htmlToText: function ( htmlToText ) { + htmlToText: function ( html ) { // This function is slow for large inputs, so aggressively cache input/output pairs if ( html in context.htmlToTextMap ) { 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) * @return jQuery object or null if unknown */ - beforeSelection: function ( beforeSelection ) { + beforeSelection: function ( classname, strict ) { if ( typeof classname === 'undefined' ) { 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 */ - rawTraverser: function ( rawTraverser ) { + rawTraverser: function ( node, inP, ancestor, skipNoinclude ) { this.node = node; this.inP = inP; 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 * previous/next node */ - traverser: function ( traverser ) { + traverser: function ( start ) { // Find the leftmost leaf node in the tree var startNode = start.jquery ? start.get( 0 ) : start; var node = startNode; - var inP = node.nodeName == 'P' ? node : null; + var inP = node.nodeName === 'P' ? node : null; do { // Filter nodes with the wikiEditor-noinclude class // Don't use $( p ).hasClass( 'wikiEditor-noinclude' ) because // $() 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; } if ( node && node.firstChild ) { node = node.firstChild; - if ( node.nodeName == 'P' ) { + if ( node.nodeName === 'P' ) { inP = node; } } } while ( node && node.firstChild ); return new context.fn.rawTraverser( node, inP, startNode, true ); }, - getOffset: function ( getOffset ) { + getOffset: function ( offset ) { if ( !context.offsets ) { context.fn.refreshOffsets(); } @@ -642,10 +646,10 @@ 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 + * @param htmlChange Pass true or false to inidicate if there was a text change that should potentially * be given a new history state. */ - updateHistory: function ( updateHistory ) { + 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? @@ -917,7 +921,7 @@ context.fn = $.extend( context.fn, { * selection is empty. * DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead */ - encapsulateSelection: function ( encapsulateSelection ) { + encapsulateSelection: function ( options ) { var selText = $(this).textSelection( 'getSelection' ); var selTextArr; 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 * DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead */ - getCaretPosition: function ( getCaretPosition ) { + getCaretPosition: function ( options ) { var startPos = null, endPos = null; if ( 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 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; sc = sc && sc.jquery ? sc[0] : sc; 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() * DO NOT CALL THIS DIRECTLY, use $.textSelection( 'functionname', options ) instead */ - scrollToCaretPosition: function ( scrollToCaretPosition ) { + scrollToCaretPosition: function ( options ) { 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 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' ), body = context.$content.closest( 'body' ), parentHtml = $( 'html' ),