Popup: Build as DOM instead of HTML strings

Change-Id: Ib33b6b2a1f3e0f9c50398287822ae88305855a58
This commit is contained in:
Ed Sanders 2017-07-20 15:15:49 +01:00 committed by Jforrester
parent cec399b4e3
commit 60ab939b26

View file

@ -390,16 +390,22 @@
* Add a popup for first time users (T165003) * Add a popup for first time users (T165003)
*/ */
function addPopup() { function addPopup() {
this.popuptext = '<div class=\'codemirror-popup-div\'>' + var $content =
'<div class=\'codemirror-popup-top\'>{ <span class=\'codemirror-popup-color-blue\'>' + $( '<div>' ).addClass( 'codemirror-popup-div' ).append(
mw.message( 'codemirror-popup-syntax' ).escaped() + '</span> ' + $( '<div>' ).addClass( 'codemirror-popup-top' ).append(
mw.message( 'codemirror-popup-highlighting' ).escaped() + ' }</div>' + '{ ',
'<div class=\'codemirror-popup-text\'>' + mw.message( 'codemirror-popup-desc' ).escaped() + '</div>' + $( '<span>' ).addClass( 'codemirror-popup-color-blue' ).text( mw.msg( 'codemirror-popup-syntax' ) ),
'<div class=\'codemirror-popup-btn codemirror-popup-btn-yes\'>' + mw.message( 'codemirror-popup-btn-yes' ).escaped() + '</div>' + ' ',
'<div class=\'codemirror-popup-btn codemirror-popup-btn-no\'>' + mw.message( 'codemirror-popup-btn-no' ).escaped() + '</div>' + document.createTextNode( mw.msg( 'codemirror-popup-highlighting' ) ),
'</div>'; ' }'
),
$( '<div>' ).addClass( 'codemirror-popup-text' ).text( mw.msg( 'codemirror-popup-desc' ) ),
$( '<div>' ).addClass( 'codemirror-popup-btn codemirror-popup-btn-yes' ).text( mw.msg( 'codemirror-popup-btn-yes' ) ),
$( '<div>' ).addClass( 'codemirror-popup-btn codemirror-popup-btn-no' ).text( mw.msg( 'codemirror-popup-btn-no' ) )
);
popup = new OO.ui.PopupWidget( { popup = new OO.ui.PopupWidget( {
$content: $( this.popuptext ), $content: $content,
containerPadding: 80, containerPadding: 80,
$floatableContainer: $( '#mw-editbutton-codemirror' ), $floatableContainer: $( '#mw-editbutton-codemirror' ),
padded: false, padded: false,