From f22a61c000b9ad2f3114f40e918af26e7f61a783 Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Tue, 19 Feb 2019 14:58:41 +0000 Subject: [PATCH] Add support for read-only mode Change-Id: Ibf8ab22ead2ceb80e39dcab50f4fc6c1ee0ae1f0 Depends-On: Iedd1bd9ce17750ad8528c1a053293c4a7321c5de --- modules/ve-math/ve.ui.MWLatexContextItem.js | 2 +- modules/ve-math/ve.ui.MWLatexDialog.js | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/ve-math/ve.ui.MWLatexContextItem.js b/modules/ve-math/ve.ui.MWLatexContextItem.js index b7ff5b573..022259289 100644 --- a/modules/ve-math/ve.ui.MWLatexContextItem.js +++ b/modules/ve-math/ve.ui.MWLatexContextItem.js @@ -26,7 +26,7 @@ ve.ui.MWLatexContextItem = function VeUiMWLatexContextItem() { } ); // Don't show quick edit button in mobile as the primary action will be quick edit - if ( !this.context.isMobile() ) { + if ( !this.context.isMobile() && !this.isReadOnly() ) { this.actionButtons.addItems( [ this.quickEditButton ], 0 ); } diff --git a/modules/ve-math/ve.ui.MWLatexDialog.js b/modules/ve-math/ve.ui.MWLatexDialog.js index 6b816f5b0..3bb409c21 100644 --- a/modules/ve-math/ve.ui.MWLatexDialog.js +++ b/modules/ve-math/ve.ui.MWLatexDialog.js @@ -190,11 +190,13 @@ ve.ui.MWLatexDialog.prototype.getSetupProcess = function ( data ) { .next( function () { var attributes = this.selectedNode && this.selectedNode.getAttribute( 'mw' ).attrs, display = attributes && attributes.display || 'default', - id = attributes && attributes.id || ''; + id = attributes && attributes.id || '', + isReadOnly = this.isReadOnly(); // Populate form - this.displaySelect.selectItemByData( display ); - this.idInput.setValue( id ); + // TODO: This widget is not readable when disabled + this.displaySelect.selectItemByData( display ).setDisabled( isReadOnly ); + this.idInput.setValue( id ).setDisabled( isReadOnly ); // Add event handlers this.input.on( 'change', this.onChangeHandler ); @@ -305,6 +307,10 @@ ve.ui.MWLatexDialog.prototype.onListClick = function ( e ) { insert = symbol.insert, range = this.input.getRange(); + if ( this.isReadOnly() ) { + return; + } + if ( encapsulate ) { if ( range.from === range.to ) { this.input.insertContent( encapsulate.placeholder );