From 656fd2ffd4a01f5076f2ffdefd49f76e75e8c01b Mon Sep 17 00:00:00 2001 From: Timo Tijhof Date: Fri, 28 Jun 2013 18:56:58 -0700 Subject: [PATCH] mw.ViewPageTarget: Support for non-paragraphs in #showWarning We need this for captcha's. They'll be added and displayed as a warning, and cleared like all others. But they shouldn't be wrapped in a paragraph and aren't delivered as html text but as a jQuery object (can't serialise to static html since we'll have to keep a reference to the TextInputWidget and what not). Change-Id: I3734fbd3c6f0270094db014bbc76d065a73ab918 --- .../mw/targets/ve.init.mw.ViewPageTarget.js | 25 ++++++++++++------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js b/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js index a38c57e674..399cb71e36 100644 --- a/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve/init/mw/targets/ve.init.mw.ViewPageTarget.js @@ -2074,17 +2074,24 @@ ve.init.mw.ViewPageTarget.prototype.restoreEditSection = function () { /** * Show an inline warning. * @param {string} name Warning's unique name - * @param {string} messageHtml Warning message HTML + * @param {string|jQuery} message Warning message (string of HTML, not text, or jQuery object) + * @param {Object} [options] + * @param {boolean} [options.wrap=true] Wrap the message in a paragraph. */ -ve.init.mw.ViewPageTarget.prototype.showWarning = function ( name, messageHtml ) { +ve.init.mw.ViewPageTarget.prototype.showWarning = function ( name, message, options ) { + var $warning; if ( !this.warnings[name] ) { - var warning = $( - '

' + messageHtml + '

' - ); - this.$saveDialog - .find( '.ve-init-mw-viewPageTarget-saveDialog-warnings' ) - .append( warning ); - this.warnings[name] = warning; + options = options || {}; + $warning = $( '
' ); + if ( options.wrap !== false ) { + $warning.append( $( '

').append( message ) ); + } else { + $warning.append( message ); + } + this.$saveDialog.find( '.ve-init-mw-viewPageTarget-saveDialog-warnings' ) + .append( $warning ); + + this.warnings[name] = $warning; } };