Jforrester has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/129624

Change subject: Simplify VE inspector code by extending new 
MWLiveExtensionInspector
......................................................................

Simplify VE inspector code by extending new MWLiveExtensionInspector

All live preview logic has been moved to ve.ui.MWLiveExtensionInspector so
so this can be simplified down to just static configuration.

Depends on I708c4cb012be in VE-MW.

Change-Id: I24b4788e97411eec18161709ca5d47c87d3f64da
(cherry picked from commit c12523f908f16f393eaf7cada0818e37003b881f)
---
M modules/VisualEditor/ve.ui.MWMathInspector.js
1 file changed, 5 insertions(+), 84 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Math 
refs/changes/24/129624/1

diff --git a/modules/VisualEditor/ve.ui.MWMathInspector.js 
b/modules/VisualEditor/ve.ui.MWMathInspector.js
index ac62041..0d4c441 100644
--- a/modules/VisualEditor/ve.ui.MWMathInspector.js
+++ b/modules/VisualEditor/ve.ui.MWMathInspector.js
@@ -1,7 +1,7 @@
 /*!
  * VisualEditor UserInterface MWMathInspector class.
  *
- * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @copyright 2011-2014 VisualEditor Team and others; see AUTHORS.txt
  * @license The MIT License (MIT); see LICENSE.txt
  */
 
@@ -11,21 +11,19 @@
  * MediaWiki math inspector.
  *
  * @class
- * @extends ve.ui.MWExtensionInspector
+ * @extends ve.ui.MWLiveExtensionInspector
  *
  * @constructor
  * @param {Object} [config] Configuration options
  */
 ve.ui.MWMathInspector = function VeUiMWMathInspector( config ) {
        // Parent constructor
-       ve.ui.MWExtensionInspector.call( this, config );
-
-       this.onChangeHandler = ve.debounce( ve.bind( this.updatePreview, this 
), 250 );
+       ve.ui.MWLiveExtensionInspector.call( this, config );
 };
 
 /* Inheritance */
 
-OO.inheritClass( ve.ui.MWMathInspector, ve.ui.MWExtensionInspector );
+OO.inheritClass( ve.ui.MWMathInspector, ve.ui.MWLiveExtensionInspector );
 
 /* Static properties */
 
@@ -35,86 +33,9 @@
 
 ve.ui.MWMathInspector.static.title = OO.ui.deferMsg( 
'math-visualeditor-mwmathinspector-title' );
 
-ve.ui.MWMathInspector.static.nodeView = ve.ce.MWMathNode;
-
 ve.ui.MWMathInspector.static.nodeModel = ve.dm.MWMathNode;
 
-/* Methods */
-
-/**
- * Update the math node rendering to reflect the content entered into the 
inspector.
- */
-ve.ui.MWMathInspector.prototype.updatePreview = function () {
-       var mwData = ve.copy( this.node.getAttribute( 'mw' ) ),
-               newsrc = this.input.getValue();
-
-       mwData.body.extsrc = newsrc;
-
-       if ( this.visible ) {
-               this.getFragment().changeAttributes( { 'mw': mwData } );
-       }
-};
-
-/**
- * @inheritdoc
- */
-ve.ui.MWMathInspector.prototype.setup = function ( data ) {
-       // Parent method
-       ve.ui.MWExtensionInspector.prototype.setup.call( this, data );
-
-       this.getFragment().getSurface().pushStaging();
-
-       var mwData;
-
-       this.node = this.getFragment().getSelectedNode();
-       if ( !this.node || !( this.node instanceof ve.dm.MWMathNode ) ) {
-               // Create a dummy node, needed for live preview
-               mwData = {
-                       'name': 'math',
-                       'attrs': {},
-                       'body': {
-                               'extsrc': ''
-                       }
-               };
-               this.getFragment().collapseRangeToEnd().insertContent( [
-                       {
-                               'type': 'mwMath',
-                               'attributes': {
-                                       'mw': mwData
-                               }
-                       },
-                       { 'type': '/mwMath' }
-               ] );
-               this.node = this.getFragment().getSelectedNode();
-       }
-
-       this.input.on( 'change', this.onChangeHandler );
-
-       // Override directionality settings, inspector's input
-       // should always be LTR:
-       this.input.setRTL( false );
-};
-
-/**
- * @inheritdoc
- */
-ve.ui.MWMathInspector.prototype.teardown = function ( data ) {
-       var newsrc = this.input.getValue(),
-               surfaceModel = this.getFragment().getSurface();
-
-       this.input.off( 'change', this.onChangeHandler );
-
-       this.getFragment().getSurface().applyStaging();
-
-       if ( newsrc === '' ) {
-               // The user tried to empty the node, remove it
-               surfaceModel.change( ve.dm.Transaction.newFromRemoval(
-                       surfaceModel.getDocument(), this.node.getOuterRange()
-               ) );
-       }
-       // Grandparent method; we're overriding the parent behavior with 
applyStaging
-       ve.ui.Inspector.prototype.teardown.call( this, data );
-};
+ve.ui.MWMathInspector.static.dir = 'ltr';
 
 /* Registration */
 

-- 
To view, visit https://gerrit.wikimedia.org/r/129624
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I24b4788e97411eec18161709ca5d47c87d3f64da
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Math
Gerrit-Branch: REL1_23
Gerrit-Owner: Jforrester <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to