Merge "build: Enable jscs rule 'requireVarDeclFirst' and make pass"

This commit is contained in:
jenkins-bot 2015-08-19 20:45:13 +00:00 committed by Gerrit Code Review
commit 90b2717bb9
25 changed files with 210 additions and 164 deletions

View file

@ -1,6 +1,5 @@
{
"preset": "wikimedia",
"requireVarDeclFirst": null,
"jsDoc": null
}

View file

@ -35,8 +35,9 @@ module.exports = function ( grunt ) {
targetCat.forEach( function ( targetGroupName ) {
// ... find the category in the aggregate source
srcCategories.forEach( function ( aggrCat ) {
var targetGroup;
if ( aggrCat.name === targetGroupName ) {
var targetGroup = {
targetGroup = {
name: targetGroupName,
classes: []
};

View file

@ -57,17 +57,19 @@ ve.dm.MWInternalLinkAnnotation.static.toDataElement = function ( domElements, co
* @returns {Object} Plain object with 'title' and 'hrefPrefix' keys.
*/
ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref = function ( href, doc ) {
var relativeBase, relativeBaseRegex, relativeHref, matches;
function regexEscape( str ) {
return str.replace( /([.?*+^$[\]\\(){}|-])/g, '\\$1' );
}
var // Protocol relative base
relativeBase = ve.resolveUrl( mw.config.get( 'wgArticlePath' ), doc ).replace( /^https?:/, '' ),
relativeBaseRegex = new RegExp( regexEscape( relativeBase ).replace( regexEscape( '$1' ), '(.*)' ) ),
// Protocol relative href
relativeHref = href.replace( /^https?:/, '' ),
// Check if this matches the server's article path
matches = relativeHref.match( relativeBaseRegex );
// Protocol relative base
relativeBase = ve.resolveUrl( mw.config.get( 'wgArticlePath' ), doc ).replace( /^https?:/, '' );
relativeBaseRegex = new RegExp( regexEscape( relativeBase ).replace( regexEscape( '$1' ), '(.*)' ) );
// Protocol relative href
relativeHref = href.replace( /^https?:/, '' );
// Check if this matches the server's article path
matches = relativeHref.match( relativeBaseRegex );
if ( matches ) {
// Take the relative path

View file

@ -208,14 +208,15 @@ ve.dm.MWTemplateModel.prototype.getParameterNames = function () {
}
// Unknown parameters in alpha-numeric order second, empty string at the very end
paramNames.sort( function ( a, b ) {
var aIsNaN = isNaN( a ),
bIsNaN = isNaN( b );
if ( a === '' ) {
return 1;
}
if ( b === '' ) {
return -1;
}
var aIsNaN = isNaN( a ),
bIsNaN = isNaN( b );
if ( aIsNaN && bIsNaN ) {
// Two strings
return a < b ? -1 : a === b ? 0 : 1;

View file

@ -194,14 +194,15 @@
/** */
ve.dm.MWTransclusionModel.prototype.fetch = function () {
var i, len, item, title, queue,
titles = [],
specs = {};
if ( !this.queue.length ) {
return;
}
var i, len, item, title,
titles = [],
specs = {},
queue = this.queue.slice();
queue = this.queue.slice();
// Clear shared queue for future calls
this.queue.length = 0;

View file

@ -79,6 +79,10 @@ ve.dm.MWBlockImageNode.static.classAttributes = {
};
ve.dm.MWBlockImageNode.static.toDataElement = function ( domElements, converter ) {
var dataElement, newDimensions, attributes,
figure, imgWrapper, img, caption,
classAttr, typeofAttrs, errorIndex, width, height, altText;
// Workaround for jQuery's .children() being expensive due to
// https://github.com/jquery/sizzle/issues/311
function findChildren( parent, nodeNames ) {
@ -87,17 +91,16 @@ ve.dm.MWBlockImageNode.static.toDataElement = function ( domElements, converter
} );
}
var dataElement, newDimensions, attributes,
figure = domElements[ 0 ],
imgWrapper = findChildren( figure, [ 'a', 'span' ] )[ 0 ] || null,
img = imgWrapper && findChildren( imgWrapper, [ 'img' ] )[ 0 ] || null,
caption = findChildren( figure, [ 'figcaption' ] )[ 0 ] || null,
classAttr = figure.getAttribute( 'class' ),
typeofAttrs = figure.getAttribute( 'typeof' ).split( ' ' ),
errorIndex = typeofAttrs.indexOf( 'mw:Error' ),
width = img && img.getAttribute( 'width' ),
height = img && img.getAttribute( 'height' ),
altText = img && img.getAttribute( 'alt' );
figure = domElements[ 0 ];
imgWrapper = findChildren( figure, [ 'a', 'span' ] )[ 0 ] || null;
img = imgWrapper && findChildren( imgWrapper, [ 'img' ] )[ 0 ] || null;
caption = findChildren( figure, [ 'figcaption' ] )[ 0 ] || null;
classAttr = figure.getAttribute( 'class' );
typeofAttrs = figure.getAttribute( 'typeof' ).split( ' ' );
errorIndex = typeofAttrs.indexOf( 'mw:Error' );
width = img && img.getAttribute( 'width' );
height = img && img.getAttribute( 'height' );
altText = img && img.getAttribute( 'alt' );
if ( errorIndex !== -1 ) {
typeofAttrs.splice( errorIndex, 1 );

View file

@ -59,27 +59,28 @@ ve.dm.MWReferenceNode.static.blacklistedAnnotationTypes = [ 'link' ];
ve.dm.MWReferenceNode.static.listKeyRegex = /^(auto|literal)\/(.*)$/;
ve.dm.MWReferenceNode.static.toDataElement = function ( domElements, converter ) {
var dataElement, mwDataJSON, mwData, reflistItemId, body, refGroup, listGroup, autoKeyed, listKey, queueResult, listIndex, contentsUsed;
function getReflistItemHtml( id ) {
var elem = converter.getHtmlDocument().getElementById( id );
return elem && elem.innerHTML || '';
}
var dataElement,
mwDataJSON = domElements[ 0 ].getAttribute( 'data-mw' ),
mwData = mwDataJSON ? JSON.parse( mwDataJSON ) : {},
reflistItemId = mwData.body && mwData.body.id,
body = ( mwData.body && mwData.body.html ) ||
( reflistItemId && getReflistItemHtml( reflistItemId ) ) ||
'',
refGroup = mwData.attrs && mwData.attrs.group || '',
listGroup = this.name + '/' + refGroup,
autoKeyed = !mwData.attrs || mwData.attrs.name === undefined,
listKey = autoKeyed ?
'auto/' + converter.internalList.getNextUniqueNumber() :
'literal/' + mwData.attrs.name,
queueResult = converter.internalList.queueItemHtml( listGroup, listKey, body ),
listIndex = queueResult.index,
contentsUsed = ( body !== '' && queueResult.isNew );
mwDataJSON = domElements[ 0 ].getAttribute( 'data-mw' );
mwData = mwDataJSON ? JSON.parse( mwDataJSON ) : {};
reflistItemId = mwData.body && mwData.body.id;
body = ( mwData.body && mwData.body.html ) ||
( reflistItemId && getReflistItemHtml( reflistItemId ) ) ||
'';
refGroup = mwData.attrs && mwData.attrs.group || '';
listGroup = this.name + '/' + refGroup;
autoKeyed = !mwData.attrs || mwData.attrs.name === undefined;
listKey = autoKeyed ?
'auto/' + converter.internalList.getNextUniqueNumber() :
'literal/' + mwData.attrs.name;
queueResult = converter.internalList.queueItemHtml( listGroup, listKey, body );
listIndex = queueResult.index;
contentsUsed = ( body !== '' && queueResult.isNew );
dataElement = {
type: this.name,

View file

@ -123,8 +123,9 @@ ve.dm.MWTransclusionNode.static.toDomElements = function ( dataElement, doc, con
originalMw = dataElement.attributes.originalMw;
function wrapTextNode( node ) {
var wrapper;
if ( node.nodeType === Node.TEXT_NODE ) {
var wrapper = doc.createElement( 'span' );
wrapper = doc.createElement( 'span' );
wrapper.appendChild( node );
return wrapper;
}
@ -285,12 +286,13 @@ ve.dm.MWTransclusionNode.prototype.isCellable = function () {
* @return {boolean} Transclusion only contains a single template, which is one of the ones in templates
*/
ve.dm.MWTransclusionNode.prototype.isSingleTemplate = function ( templates ) {
var i, len, partsList = this.getPartsList();
function normalizeTitle( name ) {
var title = mw.Title.newFromText( name );
return title ? title.getPrefixedText() : name;
}
var i, len, partsList = this.getPartsList();
if ( partsList.length !== 1 ) {
return false;
}

View file

@ -30,6 +30,8 @@
plugins = [];
function showLoading() {
var $content, contentRect, offsetTop, windowHeight, top, bottom, middle;
if ( !init.$loading ) {
init.$loading = $(
'<div class="ve-init-mw-desktopArticleTarget-loading-overlay">' +
@ -40,13 +42,14 @@
'</div>'
);
}
var $content = $( '#content' ),
contentRect = $content[ 0 ].getBoundingClientRect(),
offsetTop = $content.offset().top,
windowHeight = $( window ).height(),
top = Math.max( contentRect.top, 0 ),
bottom = Math.min( contentRect.bottom, windowHeight ),
middle = ( top + bottom ) / 2;
$content = $( '#content' );
contentRect = $content[ 0 ].getBoundingClientRect();
offsetTop = $content.offset().top;
windowHeight = $( window ).height();
top = Math.max( contentRect.top, 0 );
bottom = Math.min( contentRect.bottom, windowHeight );
middle = ( top + bottom ) / 2;
init.$loading.css( 'top', middle - offsetTop );
@ -116,10 +119,12 @@
return mw.libs.ve.targetLoader.loadModules();
} )
.then( function () {
var target;
// Transfer methods
ve.init.mw.DesktopArticleTarget.prototype.setupSectionEditLinks = init.setupSectionLinks;
var target = new ve.init.mw.DesktopArticleTarget();
target = new ve.init.mw.DesktopArticleTarget();
$( '#content' ).append( target.$element );
return target;
}, function ( e ) {
@ -278,14 +283,6 @@
},
setupTabs: function () {
// HACK: Remove this when the Education Program offers a proper way to detect and disable.
if (
// HACK: Work around jscs.requireCamelCaseOrUpperCaseIdentifiers
mw.config.get( 'wgNamespaceIds' )[ true && 'education_program' ] === mw.config.get( 'wgNamespaceNumber' )
) {
return;
}
var caVeEdit,
action = pageExists ? 'edit' : 'create',
pTabsId = $( '#p-views' ).length ? 'p-views' : 'p-cactions',
@ -296,7 +293,19 @@
$caVeEditLink = $caVeEdit.find( 'a' ),
reverseTabOrder = $( 'body' ).hasClass( 'rtl' ) && pTabsId === 'p-views',
/*jshint bitwise:false */
caVeEditNextnode = ( reverseTabOrder ^ conf.tabPosition === 'before' ) ? $caEdit.get( 0 ) : $caEdit.next().get( 0 );
caVeEditNextnode =
( reverseTabOrder ^ conf.tabPosition === 'before' ) ?
/*jshint bitwise:true */
$caEdit.get( 0 ) :
$caEdit.next().get( 0 );
// HACK: Remove this when the Education Program offers a proper way to detect and disable.
if (
// HACK: Work around jscs.requireCamelCaseOrUpperCaseIdentifiers
mw.config.get( 'wgNamespaceIds' )[ true && 'education_program' ] === mw.config.get( 'wgNamespaceNumber' )
) {
return;
}
if ( !$caVeEdit.length ) {
// The below duplicates the functionality of VisualEditorHooks::onSkinTemplateNavigation()

View file

@ -230,12 +230,13 @@ ve.init.mw.DesktopArticleTarget.prototype.setupLocalNoticeMessages = function ()
* @inheritdoc
*/
ve.init.mw.DesktopArticleTarget.prototype.loadSuccess = function ( response ) {
var $checkboxes, defaults, data,
target = this;
// Parent method
ve.init.mw.DesktopArticleTarget.super.prototype.loadSuccess.apply( this, arguments );
var $checkboxes, defaults,
target = this,
data = response ? response.visualeditor : {};
data = response ? response.visualeditor : {};
this.checkboxFields = [];
this.checkboxesByName = {};
@ -603,11 +604,11 @@ ve.init.mw.DesktopArticleTarget.prototype.onSurfaceReady = function () {
* @param {jQuery.Event} e Keydown event
*/
ve.init.mw.DesktopArticleTarget.prototype.onDocumentKeyDown = function ( e ) {
var target = this;
// Parent method
ve.init.mw.DesktopArticleTarget.super.prototype.onDocumentKeyDown.apply( this, arguments );
var target = this;
if ( e.which === OO.ui.Keys.ESCAPE ) {
setTimeout( function () {
// Listeners should stopPropagation if they handle the escape key, but
@ -641,10 +642,11 @@ ve.init.mw.DesktopArticleTarget.prototype.onViewTabClick = function ( e ) {
ve.init.mw.DesktopArticleTarget.prototype.saveComplete = function (
html, categoriesHtml, newid, isRedirect, displayTitle, lastModified, contentSub, modules, jsconfigvars
) {
var newUrlParams, watchChecked;
// Parent method
ve.init.mw.DesktopArticleTarget.super.prototype.saveComplete.apply( this, arguments );
var newUrlParams, watchChecked;
if ( !this.pageExists || this.restoring ) {
// This is a page creation or restoration, refresh the page
this.teardownUnloadHandlers();

View file

@ -78,10 +78,12 @@ ve.init.mw.MobileArticleTarget.static.name = 'mobile';
* @inheritdoc
*/
ve.init.mw.MobileArticleTarget.prototype.onSurfaceReady = function () {
var surfaceModel;
// Parent method
ve.init.mw.MobileArticleTarget.super.prototype.onSurfaceReady.apply( this, arguments );
var surfaceModel = this.getSurface().getModel();
surfaceModel = this.getSurface().getModel();
surfaceModel.connect( this, {
blur: 'onSurfaceBlur',
focus: 'onSurfaceFocus'

View file

@ -60,7 +60,8 @@ ve.init.mw.Platform.prototype.getMessage = mw.msg.bind( mw );
/** @inheritdoc */
ve.init.mw.Platform.prototype.addParsedMessages = function ( messages ) {
for ( var key in messages ) {
var key;
for ( key in messages ) {
this.parsedMessages[ key ] = messages[ key ];
}
};

View file

@ -427,8 +427,8 @@ ve.init.mw.Target.prototype.loadFail = function () {
* @param {string} status Text status message
*/
ve.init.mw.Target.prototype.saveSuccess = function ( doc, saveData, response ) {
this.saving = false;
var data = response.visualeditoredit;
this.saving = false;
if ( !data ) {
this.saveFail( doc, saveData, null, 'Invalid response from server', response );
} else if ( data.result !== 'success' ) {
@ -885,8 +885,8 @@ ve.init.mw.Target.prototype.noChanges = function () {
* @fires serializeComplete
*/
ve.init.mw.Target.prototype.serializeSuccess = function ( response ) {
this.serializing = false;
var data = response.visualeditor;
this.serializing = false;
if ( !data && !response.error ) {
this.serializeFail( null, 'Invalid response from server', null );
} else if ( response.error ) {
@ -1409,11 +1409,13 @@ ve.init.mw.Target.prototype.tryWithPreparedCacheKey = function ( doc, options, e
* @fires saveInitiated
*/
ve.init.mw.Target.prototype.startSave = function ( saveDeferred ) {
var saveOptions;
if ( this.deactivating ) {
return false;
}
var saveOptions = this.getSaveOptions();
saveOptions = this.getSaveOptions();
// Reset any old captcha data
if ( this.captcha ) {
@ -1572,23 +1574,24 @@ ve.init.mw.Target.prototype.showChanges = function ( doc ) {
* @returns {boolean} Submitting has been started
*/
ve.init.mw.Target.prototype.submit = function ( wikitext, fields ) {
var key, $form, params;
// Prevent duplicate requests
if ( this.submitting ) {
return false;
}
// Save DOM
this.submitting = true;
var key,
$form = $( '<form method="post" enctype="multipart/form-data" style="display: none;"></form>' ),
params = ve.extendObject( {
format: 'text/x-wiki',
model: 'wikitext',
oldid: this.requestedRevId,
wpStarttime: this.startTimeStamp,
wpEdittime: this.baseTimeStamp,
wpTextbox1: wikitext,
wpEditToken: this.editToken
}, fields );
$form = $( '<form method="post" enctype="multipart/form-data" style="display: none;"></form>' );
params = ve.extendObject( {
format: 'text/x-wiki',
model: 'wikitext',
oldid: this.requestedRevId,
wpStarttime: this.startTimeStamp,
wpEdittime: this.baseTimeStamp,
wpTextbox1: wikitext,
wpEditToken: this.editToken
}, fields );
// Add params as hidden fields
for ( key in params ) {
$form.append( $( '<input>' ).attr( { type: 'hidden', name: key, value: params[ key ] } ) );
@ -1655,8 +1658,9 @@ ve.init.mw.Target.prototype.setupSurface = function ( doc, callback ) {
var target = this;
setTimeout( function () {
// Build model
var dmDoc;
ve.track( 'trace.convertModelFromDom.enter' );
var dmDoc = ve.dm.converter.getModelFromDom( doc, {
dmDoc = ve.dm.converter.getModelFromDom( doc, {
lang: mw.config.get( 'wgVisualEditor' ).pageLanguageCode,
dir: mw.config.get( 'wgVisualEditor' ).pageLanguageDir
} );
@ -1666,14 +1670,15 @@ ve.init.mw.Target.prototype.setupSurface = function ( doc, callback ) {
dmDoc.buildNodeTree();
ve.track( 'trace.buildModelTree.exit' );
setTimeout( function () {
var surface, surfaceView, $documentNode;
// Clear dummy surfaces
target.clearSurfaces();
// Create ui.Surface (also creates ce.Surface and dm.Surface and builds CE tree)
ve.track( 'trace.createSurface.enter' );
var surface = target.addSurface( dmDoc ),
surfaceView = surface.getView(),
$documentNode = surfaceView.getDocument().getDocumentNode().$element;
surface = target.addSurface( dmDoc );
surfaceView = surface.getView();
$documentNode = surfaceView.getDocument().getDocumentNode().$element;
ve.track( 'trace.createSurface.exit' );
surface.$element
@ -1772,6 +1777,7 @@ ve.init.mw.Target.prototype.onToolbarSaveButtonClick = function () {
* @fires saveWorkflowBegin
*/
ve.init.mw.Target.prototype.showSaveDialog = function () {
var target = this;
this.emit( 'saveWorkflowBegin' );
// Preload the serialization
@ -1780,8 +1786,6 @@ ve.init.mw.Target.prototype.showSaveDialog = function () {
}
this.prepareCacheKey( this.docToSave );
var target = this;
// Connect events to save dialog
this.getSurface().getDialogs().getWindow( 'mwSave' ).done( function ( win ) {
if ( !target.saveDialog ) {
@ -1818,11 +1822,13 @@ ve.init.mw.Target.prototype.openSaveDialog = function () {
* @method
*/
ve.init.mw.Target.prototype.restoreEditSection = function () {
var surfaceView, $documentNode, $section, headingNode;
if ( this.section !== undefined && this.section > 0 ) {
var surfaceView = this.getSurface().getView(),
$documentNode = surfaceView.getDocument().getDocumentNode().$element,
$section = $documentNode.find( 'h1, h2, h3, h4, h5, h6' ).eq( this.section - 1 ),
headingNode = $section.data( 'view' );
surfaceView = this.getSurface().getView();
$documentNode = surfaceView.getDocument().getDocumentNode().$element;
$section = $documentNode.find( 'h1, h2, h3, h4, h5, h6' ).eq( this.section - 1 );
headingNode = $section.data( 'view' );
if ( $section.length && new mw.Uri().query.summary === undefined ) {
this.initialEditSummary = '/* ' +

View file

@ -8,14 +8,16 @@
*/
( function () {
var timing, editingSessionId;
if ( mw.loader.getState( 'schema.Edit' ) === null ) {
// Only route any events into the Edit schema if the module is actually available.
// It won't be if EventLogging is installed but WikimediaEvents is not.
return;
}
var timing = {},
editingSessionId = mw.user.generateRandomSessionId();
timing = {};
editingSessionId = mw.user.generateRandomSessionId();
function computeDuration( action, event, timeStamp ) {
if ( event.timing !== undefined ) {

View file

@ -45,7 +45,8 @@ QUnit.test( 'MW autolink', function ( assert ) {
method: 'autolinkUrl',
expectedRange: new ve.Range( 52, 52 ),
expectedData: function ( data ) {
for ( var i = 1; i < 51; i++ ) {
var i;
for ( i = 1; i < 51; i++ ) {
data[ i ] = [ data[ i ], [ 0 ] ];
}
},

View file

@ -6,12 +6,15 @@
*/
ve.test.utils.createSurfaceFromDocument = function ( doc ) {
var target, mwTarget;
// Prevent the target from setting up the surface immediately
ve.init.platform.initialized = $.Deferred();
// HACK: MW targets are async and heavy, use an SA target but
// override the global registration
var target = new ve.init.sa.Target(),
mwTarget = new ve.init.mw.Target();
target = new ve.init.sa.Target();
mwTarget = new ve.init.mw.Target();
$( '#qunit-fixture' ).append( target.$element );
target.addSurface( doc );

View file

@ -30,13 +30,14 @@ OO.inheritClass( ve.ui.MWUseExistingReferenceCommand, ve.ui.Command );
* @inheritdoc
*/
ve.ui.MWUseExistingReferenceCommand.prototype.isExecutable = function ( fragment ) {
var groupName, groups;
// Parent method
if ( !ve.ui.MWUseExistingReferenceCommand.super.prototype.isExecutable.apply( this, arguments ) ) {
return false;
}
var groupName,
groups = fragment.getDocument().getInternalList().getNodeGroups();
groups = fragment.getDocument().getInternalList().getNodeGroups();
for ( groupName in groups ) {
if ( groupName.lastIndexOf( 'mwReference/' ) === 0 && groups[ groupName ].indexOrder.length ) {

View file

@ -30,10 +30,10 @@ OO.inheritClass( ve.ui.MWWikitextWarningCommand, ve.ui.Command );
* @inheritdoc
*/
ve.ui.MWWikitextWarningCommand.prototype.execute = function () {
var command = this;
if ( this.warning && this.warning.isOpen ) {
return false;
}
var command = this;
mw.notify(
$( $.parseHTML( ve.init.platform.getParsedMessage( 'visualeditor-wikitext-warning' ) ) )
.filter( 'a' ).attr( 'target', '_blank' ).end(),

View file

@ -94,11 +94,11 @@ ve.ui.MWAlienExtensionInspector.prototype.getTeardownProcess = function ( data )
/** */
ve.ui.MWAlienExtensionInspector.prototype.updateMwData = function ( mwData ) {
var key;
// Parent method
ve.ui.MWAlienExtensionInspector.super.prototype.updateMwData.call( this, mwData );
var key;
if ( !ve.isEmptyObject( this.attributeInputs ) ) {
// Make sure we have an attrs object to populate
mwData.attrs = mwData.attrs || {};

View file

@ -213,31 +213,30 @@ ve.ui.MWAdvancedSettingsPage.prototype.onNewSectionEditLinkOptionChange = functi
* @param {Object} [data] Dialog setup data
*/
ve.ui.MWAdvancedSettingsPage.prototype.setup = function ( metaList ) {
this.metaList = metaList;
var // Indexing items
indexingField = this.indexing.getField(),
indexingOption = this.getMetaItem( 'mwIndex' ),
indexingType = indexingOption && indexingOption.element.type || 'default',
// New section edit link items
newSectionEditField = this.newEditSectionLink.getField(),
newSectionEditLinkOption = this.getMetaItem( 'mwNewSectionEdit' ),
newSectionEditLinkType = newSectionEditLinkOption && newSectionEditLinkOption.element.type || 'default',
displayTitleItem = this.getMetaItem( 'mwDisplayTitle' ),
displayTitle = displayTitleItem && displayTitleItem.getAttribute( 'content' ) || '',
var indexingField, indexingOption, indexingType,
newSectionEditField, newSectionEditLinkOption, newSectionEditLinkType,
displayTitleItem, displayTitle,
advancedSettingsPage = this;
this.metaList = metaList;
// Indexing items
indexingField = this.indexing.getField();
indexingOption = this.getMetaItem( 'mwIndex' );
indexingType = indexingOption && indexingOption.element.type || 'default';
indexingField.selectItemByData( indexingType );
this.indexingOptionTouched = false;
// New section edit link items
newSectionEditField = this.newEditSectionLink.getField();
newSectionEditLinkOption = this.getMetaItem( 'mwNewSectionEdit' );
newSectionEditLinkType = newSectionEditLinkOption && newSectionEditLinkOption.element.type || 'default';
newSectionEditField.selectItemByData( newSectionEditLinkType );
this.newSectionEditLinkOptionTouched = false;
// Display title items
displayTitleItem = this.getMetaItem( 'mwDisplayTitle' );
displayTitle = displayTitleItem && displayTitleItem.getAttribute( 'content' ) || '';
this.enableDisplayTitleCheckbox.setSelected( !!displayTitleItem );
this.displayTitleInput.setValue( displayTitle );
this.displayTitleInput.setDisabled( !displayTitle );
@ -256,25 +255,20 @@ ve.ui.MWAdvancedSettingsPage.prototype.setup = function ( metaList ) {
* @param {Object} [data] Dialog tear down data
*/
ve.ui.MWAdvancedSettingsPage.prototype.teardown = function ( data ) {
var currentIndexingItem, newIndexingData,
currentNewSectionEditLinkItem, newNewSectionEditLinkOptionData,
currentDisplayTitleItem, newDisplayTitle, newDisplayTitleItemData,
advancedSettingsPage = this;
// Data initialization
data = data || {};
if ( data.action !== 'apply' ) {
return;
}
var // Indexing items
currentIndexingItem = this.getMetaItem( 'mwIndex' ),
newIndexingData = this.indexing.getField().getSelectedItem(),
// New section edit link items
currentNewSectionEditLinkItem = this.getMetaItem( 'mwNewSectionEdit' ),
newNewSectionEditLinkOptionData = this.newEditSectionLink.getField().getSelectedItem(),
currentDisplayTitleItem = this.getMetaItem( 'mwDisplayTitle' ),
newDisplayTitle = this.displayTitleInput.getValue(),
newDisplayTitleItemData = { type: 'mwDisplayTitle', attributes: { content: newDisplayTitle } },
advancedSettingsPage = this;
// Indexing items
currentIndexingItem = this.getMetaItem( 'mwIndex' );
newIndexingData = this.indexing.getField().getSelectedItem();
// Alter the indexing option flag iff it's been touched & is actually different
if ( this.indexingOptionTouched ) {
@ -296,6 +290,10 @@ ve.ui.MWAdvancedSettingsPage.prototype.teardown = function ( data ) {
}
}
// New section edit link items
currentNewSectionEditLinkItem = this.getMetaItem( 'mwNewSectionEdit' );
newNewSectionEditLinkOptionData = this.newEditSectionLink.getField().getSelectedItem();
// Alter the new section edit option flag iff it's been touched & is actually different
if ( this.newSectionEditLinkOptionTouched ) {
if ( newNewSectionEditLinkOptionData.data === 'default' ) {
@ -316,6 +314,12 @@ ve.ui.MWAdvancedSettingsPage.prototype.teardown = function ( data ) {
}
}
// Display title items
currentDisplayTitleItem = this.getMetaItem( 'mwDisplayTitle' );
newDisplayTitle = this.displayTitleInput.getValue();
newDisplayTitleItemData = { type: 'mwDisplayTitle', attributes: { content: newDisplayTitle } };
// Alter the display title flag iff it's been touched & is actually different
if ( this.displayTitleTouched ) {
if ( currentDisplayTitleItem ) {
if ( newDisplayTitle ) {

View file

@ -236,26 +236,24 @@ ve.ui.MWSettingsPage.prototype.getMetaItem = function ( name ) {
* @param {Object} [data] Dialog setup data
*/
ve.ui.MWSettingsPage.prototype.setup = function ( metaList ) {
this.metaList = metaList;
var // Table of Contents items
tableOfContentsMetaItem = this.getMetaItem( 'mwTOC' ),
tableOfContentsField = this.tableOfContents.getField(),
tableOfContentsMode = tableOfContentsMetaItem &&
tableOfContentsMetaItem.getType() || 'default',
// Redirect items
redirectTargetItem = this.getMetaItem( 'mwRedirect' ),
redirectTarget = redirectTargetItem && redirectTargetItem.getAttribute( 'title' ) || '',
redirectStatic = this.getMetaItem( 'mwStaticRedirect' ),
var tableOfContentsMetaItem, tableOfContentsField, tableOfContentsMode,
redirectTargetItem, redirectTarget, redirectStatic,
settingsPage = this;
this.metaList = metaList;
// Table of Contents items
tableOfContentsMetaItem = this.getMetaItem( 'mwTOC' );
tableOfContentsField = this.tableOfContents.getField();
tableOfContentsMode = tableOfContentsMetaItem &&
tableOfContentsMetaItem.getType() || 'default';
tableOfContentsField.selectItemByData( tableOfContentsMode );
this.tableOfContentsTouched = false;
// Redirect items (disabled states set by change event)
redirectTargetItem = this.getMetaItem( 'mwRedirect' );
redirectTarget = redirectTargetItem && redirectTargetItem.getAttribute( 'title' ) || '';
redirectStatic = this.getMetaItem( 'mwStaticRedirect' );
this.enableRedirectInput.setSelected( !!redirectTargetItem );
this.redirectTargetInput.setValue( redirectTarget );
this.redirectTargetInput.setDisabled( !redirectTargetItem );
@ -276,26 +274,29 @@ ve.ui.MWSettingsPage.prototype.setup = function ( metaList ) {
* @param {Object} [data] Dialog tear down data
*/
ve.ui.MWSettingsPage.prototype.teardown = function ( data ) {
var tableOfContentsMetaItem, tableOfContentsSelectedItem, tableOfContentsValue,
currentRedirectTargetItem, newRedirectData, newRedirectItemData,
currentStaticRedirectItem, newStaticRedirectState,
settingsPage = this;
// Data initialisation
data = data || {};
if ( data.action !== 'apply' ) {
return;
}
var // Table of Contents items
tableOfContentsMetaItem = this.getMetaItem( 'mwTOC' ),
tableOfContentsSelectedItem = this.tableOfContents.getField().getSelectedItem(),
tableOfContentsValue = tableOfContentsSelectedItem && tableOfContentsSelectedItem.getData(),
// Table of Contents items
tableOfContentsMetaItem = this.getMetaItem( 'mwTOC' );
tableOfContentsSelectedItem = this.tableOfContents.getField().getSelectedItem();
tableOfContentsValue = tableOfContentsSelectedItem && tableOfContentsSelectedItem.getData();
// Redirect items
currentRedirectTargetItem = this.getMetaItem( 'mwRedirect' ),
newRedirectData = this.redirectTargetInput.getValue(),
newRedirectItemData = { type: 'mwRedirect', attributes: { title: newRedirectData } },
// Redirect items
currentRedirectTargetItem = this.getMetaItem( 'mwRedirect' );
newRedirectData = this.redirectTargetInput.getValue();
newRedirectItemData = { type: 'mwRedirect', attributes: { title: newRedirectData } };
currentStaticRedirectItem = this.getMetaItem( 'mwStaticRedirect' ),
newStaticRedirectState = this.enableStaticRedirectInput.isSelected(),
settingsPage = this;
currentStaticRedirectItem = this.getMetaItem( 'mwStaticRedirect' );
newStaticRedirectState = this.enableStaticRedirectInput.isSelected();
// Alter the TOC option flag iff it's been touched & is actually different
if ( this.tableOfContentsTouched ) {

View file

@ -128,10 +128,11 @@ ve.ui.MWCategoryPopupWidget.prototype.openPopup = function ( item ) {
* @method
*/
ve.ui.MWCategoryPopupWidget.prototype.onToggle = function ( show ) {
var newSortkey;
if ( show ) {
return;
}
var newSortkey = this.sortKeyInput.$input.val();
newSortkey = this.sortKeyInput.$input.val();
if ( !this.removed && newSortkey !== ( this.origSortkey || '' ) ) {
this.emit( 'updateSortkey', this.category, this.sortKeyInput.$input.val() );
}

View file

@ -47,8 +47,9 @@ ve.ui.MWReferenceGroupInputWidget.prototype.populateMenu = function ( internalLi
this.menu.addItems( [ placeholderGroupItem ].concat( $.map(
Object.keys( internalList.getNodeGroups() ),
function ( groupInternalName ) {
var groupName;
if ( groupInternalName.indexOf( 'mwReference/' ) === 0 ) {
var groupName = groupInternalName.slice( 'mwReference/'.length );
groupName = groupInternalName.slice( 'mwReference/'.length );
if ( groupName ) {
return new OO.ui.MenuOptionWidget( { data: groupName, label: groupName } );
}

View file

@ -116,14 +116,14 @@ ve.ui.MWReferenceSearchWidget.prototype.onListNodeUpdate = function () {
* @method
*/
ve.ui.MWReferenceSearchWidget.prototype.buildIndex = function () {
if ( this.built ) {
return;
}
var n, i, iLen, j, jLen, refModel, group, groupName, groupNames, view, text, firstNodes, indexOrder,
refGroup, refNode, matches, name, citation,
groups = this.internalList.getNodeGroups();
if ( this.built ) {
return;
}
function extractAttrs() {
text += ' ' + this.getAttribute( 'href' );
}

View file

@ -16,13 +16,15 @@
* @cfg {boolean} [showExisting] Show 're-use existing reference' as an option
*/
ve.ui.MWReferenceSourceSelectWidget = function VeUiMWReferenceSourceSelectWidget( config ) {
var i, len, tools, item, limit,
items = [];
config = config || {};
// Parent constructor
ve.ui.MWReferenceSourceSelectWidget.super.call( this, config );
var i, len, tools, item, items = [],
limit = ve.init.target.constructor.static.citationToolsLimit;
limit = ve.init.target.constructor.static.citationToolsLimit;
try {
// Must use mw.message to avoid JSON being parsed as Wikitext