diff --git a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js index 27f3df55d7..24fead74ab 100644 --- a/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js +++ b/modules/ve-mw/init/targets/ve.init.mw.ViewPageTarget.js @@ -907,9 +907,8 @@ ve.init.mw.ViewPageTarget.prototype.getSaveOptions = function () { // Firefox has Object.prototype.watch options.watch = undefined; } - this.saveDialog.$saveOptions - .find( '.ve-ui-mwSaveDialog-checkboxes' ) - .find( 'input:not(#wpMinoredit, #wpWatchthis)' ) + this.$checkboxes + .not( '#wpMinoredit, #wpWatchthis' ) .each( function () { var $this = $( this ); // We can't just use $this.val() because .val() always returns the value attribute of @@ -1219,7 +1218,7 @@ ve.init.mw.ViewPageTarget.prototype.setupSaveDialog = function () { } ); // Setup edit summary and checkboxes this.saveDialog.setEditSummary( this.initialEditSummary ); - this.saveDialog.setupCheckboxes( ve.getObjectValues( this.checkboxes ).join( '\n' ) ); + this.saveDialog.setupCheckboxes( this.$checkboxes ); }; /** diff --git a/modules/ve-mw/init/ve.init.mw.Target.js b/modules/ve-mw/init/ve.init.mw.Target.js index 3d2c58895e..a1e9faa328 100644 --- a/modules/ve-mw/init/ve.init.mw.Target.js +++ b/modules/ve-mw/init/ve.init.mw.Target.js @@ -68,7 +68,7 @@ ve.init.mw.Target = function VeInitMwTarget( $container, pageName, revisionId ) this.startTimeStamp = null; this.doc = null; this.editNotices = null; - this.checkboxes = null; + this.$checkboxes = null; this.remoteNotices = []; this.localNoticeMessages = []; this.isMobileDevice = ( @@ -190,7 +190,18 @@ ve.init.mw.Target.onLoad = function ( response ) { this.doc = ve.createDocumentFromHtml( this.originalHtml ); this.remoteNotices = ve.getObjectValues( data.notices ); - this.checkboxes = data.checkboxes; + this.$checkboxes = $( ve.getObjectValues( data.checkboxes ).join( '' ) ); + // Populate checkboxes with default values for minor and watch + this.$checkboxes + .filter( '#wpMinoredit' ) + .prop( 'checked', mw.user.options.get( 'minordefault' ) ) + .end() + .filter( '#wpWatchthis' ) + .prop( 'checked', + mw.user.options.get( 'watchdefault' ) || + ( mw.user.options.get( 'watchcreations' ) && !this.pageExists ) || + mw.config.get( 'wgVisualEditor' ).isPageWatched + ); this.baseTimeStamp = data.basetimestamp; this.startTimeStamp = data.starttimestamp; diff --git a/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js b/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js index 40efb00377..4b0fb2f521 100644 --- a/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js +++ b/modules/ve-mw/ui/dialogs/ve.ui.MWSaveDialog.js @@ -240,27 +240,18 @@ ve.ui.MWSaveDialog.prototype.reset = function () { * * This method is safe to call even when the dialog hasn't been initialized yet. * - * @param {string} checkboxes Multiline HTML + * @param {jQuery} $checkboxes jQuery collection of checkboxes */ -ve.ui.MWSaveDialog.prototype.setupCheckboxes = function ( checkboxes ) { +ve.ui.MWSaveDialog.prototype.setupCheckboxes = function ( $checkboxes ) { var saveDialog = this; this.setupDeferred.done( function () { saveDialog.$saveOptions.find( '.ve-ui-mwSaveDialog-checkboxes' ) - .html( checkboxes ) + .html( $checkboxes ) .find( 'a' ) .attr( 'target', '_blank' ) .end() - .find( '#wpMinoredit' ) - .prop( 'checked', mw.user.options.get( 'minordefault' ) ) - .prop( 'tabIndex', 0 ) - .end() - .find( '#wpWatchthis' ) - .prop( 'checked', - mw.user.options.get( 'watchdefault' ) || - ( mw.user.options.get( 'watchcreations' ) && !this.pageExists ) || - mw.config.get( 'wgVisualEditor' ).isPageWatched - ).prop( 'tabIndex', 0 ); - // TODO: Need to set all checkboxes provided by api tabindex to 0 for proper accessibility + .find( 'input' ) + .prop( 'tabIndex', 0 ); } ); };