Ankita-ks has uploaded a new change for review.

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

Change subject: adapted extension.json and made minor edits
......................................................................

adapted extension.json and made minor edits

Change-Id: I3c88e2e18b318e72af5ccf5cae2f0893ba9561fa
---
M LanguageTool.php
A extension.json
M modules/ext.LanguageTool.js
M modules/ext.LanguageToolAction.js
M modules/ext.LanguageToolCommand.js
D modules/ext.LanguageToolDialog.css
D modules/ext.LanguageToolDialog.js
7 files changed, 87 insertions(+), 700 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/LanguageTool 
refs/changes/93/220693/1

diff --git a/LanguageTool.php b/LanguageTool.php
index 08f8a0d..4fa3cd5 100644
--- a/LanguageTool.php
+++ b/LanguageTool.php
@@ -13,9 +13,9 @@
        'path' => __FILE__,
        'name' => 'LanguageTool',
        'author' => array(
-               'Ankita Kumari',
-               'Eran Rosenthal',
-               'Amir E. Aharoni',
+            'Ankita Kumari',
+            'Eran Rosenthal',
+            'Amir E. Aharoni'
        ),
        'version'  => '0.0.0',
        'url' => 'https://www.mediawiki.org/wiki/Extension:LanguageTool',
@@ -31,25 +31,30 @@
 $wgMessagesDirs['LanguageTool'] = __DIR__ . '/i18n';
 $wgExtensionMessagesFiles['LanguageToolAlias'] = __DIR__ . 
'/LanguageTool.i18n.alias.php';
 
+// Register hooks
+#$wgHooks['NameOfHook'][] = 'LanguageToolHooks::onNameOfHook';
+
+// Register special pages
+//$wgSpecialPages['HelloWorld'] = 'SpecialHelloWorld';
+
 // Register modules
 $wgResourceModules['ext.languageTool.foo'] = array(
        'scripts' => array(
                'modules/ext.languageTool.js',
                'modules/ext.languageToolAction.js',
-               'modules/ext.languageToolCommand.js',
-               'modules/ext.languageToolDialog.js'
+        'modules/ext.languageToolCommand.js'
        ),
        'styles' => array(
-               'modules/ext.languageTool.foo.css',
-               'modules/ext.languageToolDialog.css',
+            'modules/ext.languageTool.foo.css'
        ),
        'messages' => array(
        ),
-       'dependencies' => array(
+    'dependencies' => array(
+            'ext.visualEditor.mwcore'
        ),
 
        'localBasePath' => __DIR__,
-       'remoteExtPath' => 'examples/LanguageTool',
+       'remoteExtPath' => 'LanguageTool',
 );
 
 
diff --git a/extension.json b/extension.json
new file mode 100644
index 0000000..28dfc18
--- /dev/null
+++ b/extension.json
@@ -0,0 +1,45 @@
+{
+       "name": "LanguageTool",
+       "version": "0.0.0",
+       "author": [
+               "Ankita Kumari"
+       ],
+       "url": "https://www.mediawiki.org/wiki/Extension:LanguageTool";,
+       "descriptionmsg": "languagetool-desc",
+       "license-name": "MIT",
+       "type": "other",
+       "MessagesDirs": {
+               "LanguageTool": [
+                       "i18n"
+               ]
+       },
+       "ExtensionMessagesFiles": {
+       },
+       "AutoloadClasses": {
+               "LanguageToolHooks": "LanguageTool.hooks.php"
+       },
+       "ResourceModules": {
+               "ext.languageTool.foo": {
+                       "scripts": [
+                               "modules/ext.languageTool.js",
+                               "modules/ext.languageToolAction.js",
+                               "modules/ext.languageToolCommand.js"
+                       ],
+                       "styles": [
+                               "modules/ext.languageTool.foo.css"
+                       ],
+                       "messages": [],
+                       "dependencies": ["ext.visualEditor.mwcore"]
+               }
+       },
+       "ResourceFileModulePaths": {
+               "localBasePath": "",
+               "remoteExtPath": "LanguageTool"
+       },
+       "config": {
+               "LanguageToolEnableFoo": true,
+               "VisualEditorPluginModules": [
+                       "ext.languageTool.foo"
+               ]
+       }
+}
diff --git a/modules/ext.LanguageTool.js b/modules/ext.LanguageTool.js
index b933684..ac84364 100644
--- a/modules/ext.LanguageTool.js
+++ b/modules/ext.LanguageTool.js
@@ -9,14 +9,9 @@
                };
        OO.inheritClass( mw.languageTool, ve.ui.DialogTool );
        mw.languageTool.static.name = 'LanguageTool';
-       mw.languageTool.static.group = 'dialog';
+       mw.languageTool.static.group = 'object';
        mw.languageTool.static.icon = 'picture';
        mw.languageTool.static.title = 'LanguageTool';
-       mw.languageTool.static.commandName = 'languageTool';
-       mw.languageTool.static.activeWindow = 'languageTool';
-       //mw.languageTool.static.modelClasses = [ ve.dm.MWBlockImageNode, 
ve.dm.MWInlineImageNode ];
-       //mw.languageTool.static.commandName = 'media';
-       //mw.languageTool.static.autoAddToCatchall = false;
-       //mw.languageTool.static.autoAddToGroup = false;
+       mw.languageTool.static.commandName = 'send';
        ve.ui.toolFactory.register( mw.languageTool );
 }() );
diff --git a/modules/ext.LanguageToolAction.js 
b/modules/ext.LanguageToolAction.js
index 9c6a13b..14e09e0 100644
--- a/modules/ext.LanguageToolAction.js
+++ b/modules/ext.LanguageToolAction.js
@@ -50,7 +50,7 @@
                        var i;
  
                        for ( i = 0; i < obj.children.length; i++ ) {
-                               if ( obj.children[i].type == 'text'){
+                               if ( obj.children[i].type === 'text'){
                                        nodes.push(obj.children[i]);
                                }
  
@@ -67,7 +67,7 @@
  * Send text to LanguageTool server
  *
  * @method
- * @return {boolean} Action was executed
+ * @return {NULL} Action was executed
  */
 mw.languageToolAction.prototype.send = function () {
                var textNodes = this.extract();
@@ -78,77 +78,36 @@
                        var nodeRange = node.getRange();
                        var nodeText = 
model.getLinearFragment(nodeRange).getText();
                        text += nodeText;
-                       //console.log(nodeText);
                }
-               //console.log(text);
                var lang = mw.config.get( 'wgPageContentLanguage' );
-               //console.log(lang);
                var params = "language=" + lang + "&text=" + text;
-               //console.log(params);
-               $.ajax('https://tools.wmflabs.org/languageproofing', {data: 
{language: lang,  text: text}}).done(function(d){console.log(window.d=d)})
-               return params;
+               $.ajax(
+               {
+                       type: 'POST',
+                       dataType: 'text',
+                       url: 'http://127.0.0.1:8081/', 
+                       data: {language: lang,  text: text}
+               }
+               )
+               .done(function(d)
+               {
+                       // Example: Creating and opening a message dialog 
window.
+                       var messageDialog = new OO.ui.MessageDialog();
+                       // Create and append a window manager.
+                       var windowManager = new OO.ui.WindowManager();
+                       $( 'body' ).append( windowManager.$element );
+                       windowManager.addWindows( [ messageDialog ] );
+                       // Open the window.
+                       windowManager.openWindow( messageDialog, {
+                       title: 'LanguageTool Response',
+                       message: d
+                       } );    
+               });
+               return;
        }
-
-/*xhr request part*/
-// Create the XHR object.
-mw.languageToolAction.prototype.createCORSRequest = function (method, url) {
-       var xhr = new XMLHttpRequest();
-       if ("withCredentials" in xhr) {
-       // XHR for Chrome/Firefox/Opera/Safari.
-       xhr.open(method, url, true);
-       } else if (typeof XDomainRequest != "undefined") {
-       // XDomainRequest for IE.
-       xhr = new XDomainRequest();
-       xhr.open(method, url, true);
-       } else {
-       // CORS not supported.
-       xhr = null;
-       }
-       return xhr;
-}
-
-/*
-// Helper method to parse the title tag from the response.
-function getTitle(text) {
-  return text.match('<title>(.*)?</title>')[1];
-}
-*/
-
-// Make the actual CORS request.
-mw.languageToolAction.prototype.sendWrong = function () {
-       /*var url = "http://tools.wmflabs.org/languageproofing/";;
-       var xhr = this.createCORSRequest('POST', url);
-       xhr.setRequestHeader('Content-Type', 'text/xml');
-       xhr.setRequestHeader('charset', 'UTF-8');
-       //xhr.setRequestHeader('Access-Control-Allow-Origin', '*');
-       if (!xhr) {
-       alert('CORS not supported');
-       return;
-       }
-
-       // Response handlers.
-       
-       xhr.onload = function() {
-           var text = xhr.responseXML;
-           console.log(text);
-       //var title = getTitle(text);
-       //alert('Response from CORS request to ' + url + ': ' + title);
-       };
-       
-       xhr.onerror = function() {
-       alert('Woops, there was an error making the request.');
-       };
-       console.log( this.extractParams() );
-       xhr.send( this.extractParams() );
-       */
-       var lang = mw.config.get( 'wgPageContentLanguage' );
-
-       $.ajax('https://tools.wmflabs.org/languageproofing', {data: 
{language:'en',  text: 'a simple 
test'}}).done(function(d){console.log(window.d=d)})
-       return;
-}
 
 /* Registration */
 
 ve.ui.actionFactory.register( mw.languageToolAction );
 
-}() );
\ No newline at end of file
+}() );
diff --git a/modules/ext.LanguageToolCommand.js 
b/modules/ext.LanguageToolCommand.js
index 2e37401..f235d80 100644
--- a/modules/ext.LanguageToolCommand.js
+++ b/modules/ext.LanguageToolCommand.js
@@ -19,12 +19,6 @@
 mw.languageToolCommand = function VeUiHistoryCommand( name, method ) {
        // Parent constructor
        mw.languageToolCommand.super.call( this, name, 'languageTool', method );
-       /*
-       this.check = {
-               undo: 'canUndo',
-               redo: 'canRedo'
-       }[method];
-       */
 };
 
 /* Inheritance */
@@ -45,15 +39,5 @@
 };
 
 /* Registration */
-
-ve.ui.commandRegistry.register( new mw.languageToolCommand( 'extract', 
'extract' ) );
-
 ve.ui.commandRegistry.register( new mw.languageToolCommand( 'send', 'send' ) );
-ve.ui.commandRegistry.register(
-       new ve.ui.Command(
-               'languageTool', 'window', 'open', { args: ['languageTool'] }
-       )
-);
-
-
 }() );
\ No newline at end of file
diff --git a/modules/ext.LanguageToolDialog.css 
b/modules/ext.LanguageToolDialog.css
deleted file mode 100644
index fa10d70..0000000
--- a/modules/ext.LanguageToolDialog.css
+++ /dev/null
@@ -1,77 +0,0 @@
-/*!
- * VisualEditor UserInterface LanguageToolDialog styles.
- *
- * @copyright 2011-2015 VisualEditor Team and others; see 
http://ve.mit-license.org
- */
-
-.ve-ui-LanguageToolDialog-row {
-       display: table;
-       min-width: 30em;
-       padding-bottom: 0.3em;
-}
-
-.ve-ui-LanguageToolDialog-row:last-child {
-       /* Extra pixel for button shadows */
-       padding-bottom: 1px;
-}
-
-.ve-ui-LanguageToolDialog-cell {
-       display: table-cell;
-       vertical-align: middle;
-       white-space: nowrap;
-       padding-right: 1em;
-}
-
-.ve-ui-LanguageToolDialog-cell:last-child {
-       padding-right: 0;
-}
-
-.ve-ui-LanguageToolDialog-cell-input {
-       width: 100%;
-}
-
-.ve-ui-LanguageToolDialog-cell-input .oo-ui-textInputWidget {
-       max-width: none;
-}
-
-.ve-ui-LanguageToolDialog-findText-error input {
-       background-color: #edd;
-}
-
-/* @noflip */
-.ve-ui-LanguageToolDialog-findResults {
-       position: absolute;
-       top: 0;
-       left: 0;
-       pointer-events: none;
-}
-
-.ve-ui-LanguageToolDialog-findResult {
-       opacity: 0.2;
-}
-
-.ve-ui-LanguageToolDialog-findResult > div {
-       background: #28bb0b;
-       position: absolute;
-       margin-top: -0.15em;
-       padding: 0.15em 0;
-       border-radius: 0.15em;
-}
-
-.ve-ui-LanguageToolDialog-findResult-focused {
-       opacity: 0.4;
-}
-
-.ve-ui-LanguageToolDialog-findResult-focused > div {
-       background: #1f850b;
-}
-
-/* Set opacity directly on the highlights, rather than their containers,
-   otherwise the opacity isn't applied at all */
-.ve-init-target-ie .ve-ui-LanguageToolDialog-findResult > div {
-       opacity: 0.2;
-}
-
-.ve-init-target-ie .ve-ui-LanguageToolDialog-findResult-focused > div {
-       opacity: 0.4;
-}
diff --git a/modules/ext.LanguageToolDialog.js 
b/modules/ext.LanguageToolDialog.js
deleted file mode 100644
index d2f0d18..0000000
--- a/modules/ext.LanguageToolDialog.js
+++ /dev/null
@@ -1,524 +0,0 @@
-       ( function () {
-/*!
- * VisualEditor UserInterface LanguageToolDialog class.
- *
- * @copyright 2011-2015 VisualEditor Team and others; see 
http://ve.mit-license.org
- */
-
-/**
- * Find and replace dialog.
- *
- * @class
- * @extends ve.ui.ToolbarDialog
- *
- * @constructor
- * @param {Object} [config] Configuration options
- */
-ve.ui.LanguageToolDialog = function VeUiLanguageToolDialog( config ) {
-       // Parent constructor
-       ve.ui.LanguageToolDialog.super.call( this, config );
-
-       // Properties
-       this.surface = null;
-       //this.invalidRegex = false;
-
-       // Pre-initialization
-       this.$element.addClass( 've-ui-LanguageToolDialog' );
-       console.log('dialog');
-};
-
-/* Inheritance */
-
-OO.inheritClass( ve.ui.LanguageToolDialog, ve.ui.ToolbarDialog );
-
-ve.ui.LanguageToolDialog.static.name = 'languageTool';
-
-ve.ui.LanguageToolDialog.static.title = 'languageTool';
-//OO.ui.deferMsg( 'visualeditor-find-and-replace-title' );
-
-/**
- * Maximum number of results to render
- *
- * @property {number}
- */
-ve.ui.LanguageToolDialog.static.maxRenderedResults = 100;
-
-/* Methods */
-
-/**
- * @inheritdoc
- */
-ve.ui.LanguageToolDialog.prototype.initialize = function () {
-       // Parent method
-       ve.ui.LanguageToolDialog.super.prototype.initialize.call( this );
-
-       this.$findResults = this.$( '<div>' ).addClass( 
've-ui-LanguageToolDialog-findResults' );
-       this.fragments = [];
-       this.results = 0;
-       // Range over the list of fragments indicating which ones where 
rendered,
-       // e.g. [1,3] means fragments 1 & 2 were rendered
-       this.renderedFragments = null;
-       this.replacing = false;
-       this.focusedIndex = 0;
-       this.query = null;
-       /*
-       this.findText = new OO.ui.TextInputWidget( {
-               $: this.$,
-               placeholder: ve.msg( 'visualeditor-find-and-replace-find-text' )
-       } );*/
-       /*
-       this.matchCaseToggle = new OO.ui.ToggleButtonWidget( {
-               $: this.$,
-               icon: 'case-sensitive',
-               iconTitle: ve.msg( 'visualeditor-find-and-replace-match-case' )
-       } );
-       */
-       /*this.regexToggle = new OO.ui.ToggleButtonWidget( {
-               $: this.$,
-               icon: 'regular-expression',
-               iconTitle: ve.msg( 
'visualeditor-find-and-replace-regular-expression' )
-       } );*/
-
-       /*
-       this.previousButton = new OO.ui.ButtonWidget( {
-               $: this.$,
-               icon: 'previous',
-               iconTitle: ve.msg( 
'visualeditor-find-and-replace-previous-button' ) + ' ' +
-                       ve.ui.triggerRegistry.getMessages( 'findPrevious' 
).join( ', ' )
-       } );
-       */
-       /*
-       this.nextButton = new OO.ui.ButtonWidget( {
-               $: this.$,
-               icon: 'next',
-               iconTitle: ve.msg( 'visualeditor-find-and-replace-next-button' 
) + ' ' +
-                       ve.ui.triggerRegistry.getMessages( 'findNext' ).join( 
', ' )
-       } );*/
-       /*
-       this.replaceText = new OO.ui.TextInputWidget( {
-               $: this.$,
-               placeholder: ve.msg( 
'visualeditor-find-and-replace-replace-text' )
-       } );*/
-       /*
-       this.replaceButton = new OO.ui.ButtonWidget( {
-               $: this.$,
-               label: ve.msg( 'visualeditor-find-and-replace-replace-button' )
-       } );
-       */
-       /*
-       this.replaceAllButton = new OO.ui.ButtonWidget( {
-               $: this.$,
-               label: ve.msg( 
'visualeditor-find-and-replace-replace-all-button' )
-       } );
-       */
-       var optionsGroup = new OO.ui.ButtonGroupWidget( {
-                       $: this.$,
-                       classes: ['ve-ui-LanguageToolDialog-cell'],
-                       items: [
-                               //this.matchCaseToggle,
-                               //this.regexToggle
-                       ]
-               } ),
-               navigateGroup = new OO.ui.ButtonGroupWidget( {
-                       $: this.$,
-                       classes: ['ve-ui-LanguageToolDialog-cell'],
-                       items: [
-                               //this.previousButton,
-                               //this.nextButton
-                       ]
-               } ),
-               
-               replaceGroup = new OO.ui.ButtonGroupWidget( {
-                       $: this.$,
-                       classes: ['ve-ui-LanguageToolDialog-cell'],
-                       items: [
-                               //this.replaceButton,
-                               //this.replaceAllButton
-                       ]
-               } ),
-               doneButton = new OO.ui.ButtonWidget( {
-                       $: this.$,
-                       classes: ['ve-ui-LanguageToolDialog-cell'],
-                       label: ve.msg( 'visualeditor-find-and-replace-done' )
-               } ),
-               $findRow = this.$( '<div>' ).addClass( 
've-ui-LanguageToolDialog-row' ),
-               $replaceRow = this.$( '<div>' ).addClass( 
've-ui-LanguageToolDialog-row' );
-
-       // Events
-       this.onWindowScrollDebounced = ve.debounce( this.onWindowScroll.bind( 
this ), 250 );
-       //this.updateFragmentsDebounced = ve.debounce( 
this.updateFragments.bind( this ) );
-       this.renderFragmentsDebounced = ve.debounce( this.renderFragments.bind( 
this ) );
-       /*
-       this.findText.connect( this, {
-               change: 'onFindChange',
-               enter: 'onFindTextEnter'
-       } );*/
-       //this.matchCaseToggle.connect( this, { change: 'onFindChange' } );
-       //this.regexToggle.connect( this, { change: 'onFindChange' } );
-       //this.nextButton.connect( this, { click: 'findNext' } );
-       //this.previousButton.connect( this, { click: 'findPrevious' } );
-       //this.replaceButton.connect( this, { click: 'onReplaceButtonClick' } );
-       //this.replaceAllButton.connect( this, { click: 
'onReplaceAllButtonClick' } );
-       doneButton.connect( this, { click: 'close' } );
-
-       // Initialization
-       //this.findText.$input.prop( 'tabIndex', 1 );
-       //this.replaceText.$input.prop( 'tabIndex', 2 );
-       this.$content.addClass( 've-ui-LanguageToolDialog-content' );
-       this.$body
-               .append(
-                       $findRow.append(
-                               /*this.$( '<div>' ).addClass( 
've-ui-LanguageToolDialog-cell ve-ui-LanguageToolDialog-cell-input' ).append(
-                                       this.findText.$element
-                               ),*/
-                               navigateGroup.$element,
-                               optionsGroup.$element
-                       ),
-                       $replaceRow.append(
-                               /*this.$( '<div>' ).addClass( 
've-ui-LanguageToolDialog-cell ve-ui-LanguageToolDialog-cell-input' ).append(
-                                       this.replaceText.$element
-                               ),*/
-                               replaceGroup.$element,
-                               doneButton.$element
-                       )
-               );
-};
-
-/**
- * @inheritdoc
- */
-ve.ui.LanguageToolDialog.prototype.getSetupProcess = function ( data ) {
-       data = data || {};
-       return ve.ui.LanguageToolDialog.super.prototype.getSetupProcess.call( 
this, data )
-               .first( function () {
-                       this.surface = data.surface;
-                       this.surface.$selections.append( this.$findResults );
-
-                       // Events
-                       //this.surface.getModel().connect( this, { 
documentUpdate: this.updateFragmentsDebounced } );
-                       this.surface.getView().connect( this, { position: 
this.renderFragmentsDebounced } );
-                       this.surface.getView().$window.on( 'scroll', 
this.onWindowScrollDebounced );
-
-                       var text = data.fragment.getText();
-                       if ( text /*&& text !== this.findText.getValue()*/ ) {
-                               //this.findText.setValue( text );
-                       } else {
-                               this.onFindChange();
-                       }
-               }, this );
-};
-
-/**
- * @inheritdoc
- */
-ve.ui.LanguageToolDialog.prototype.getReadyProcess = function ( data ) {
-       return ve.ui.LanguageToolDialog.super.prototype.getReadyProcess.call( 
this, data )
-               .next( function () {
-                       //this.findText.focus().select();
-               }, this );
-};
-
-/**
- * @inheritdoc
- */
-ve.ui.LanguageToolDialog.prototype.getTeardownProcess = function ( data ) {
-       return 
ve.ui.LanguageToolDialog.super.prototype.getTeardownProcess.call( this, data )
-               .next( function () {
-                       var surfaceView = this.surface.getView();
-
-                       // Events
-                       this.surface.getModel().disconnect( this );
-                       surfaceView.disconnect( this );
-                       this.surface.getView().$window.off( 'scroll', 
this.onWindowScrollDebounced );
-
-                       surfaceView.focus();
-                       this.$findResults.empty().detach();
-                       this.fragments = [];
-                       this.surface = null;
-               }, this );
-};
-
-/**
- * Handle window scroll events
- */
-ve.ui.LanguageToolDialog.prototype.onWindowScroll = function () {
-       if ( this.renderedFragments.getLength() < this.results ) {
-               // If viewport clipping is being used, reposition results based 
on the current viewport
-               this.renderFragments();
-       }
-};
-
-/**
- * Handle change events to the find inputs (text or match case)
- */
-ve.ui.LanguageToolDialog.prototype.onFindChange = function () {
-       //this.updateFragments();
-       this.renderFragments();
-       this.highlightFocused( true );
-};
-
-/**
- * Handle enter events on the find text input
- *
- * @param {jQuery.Event} e
- */
-ve.ui.LanguageToolDialog.prototype.onFindTextEnter = function ( e ) {
-       if ( !this.results ) {
-               return;
-       }
-       if ( e.shiftKey ) {
-               //this.findPrevious();
-       } else {
-               //this.findNext();
-       }
-};
-
-/**
- * Update search result fragments
- */
- /*
-ve.ui.LanguageToolDialog.prototype.updateFragments = function () {
-       var i, l,
-               surfaceModel = this.surface.getModel(),
-               documentModel = surfaceModel.getDocument(),
-               ranges = [],
-               //matchCase = this.matchCaseToggle.getValue(),
-               //isRegex = this.regexToggle.getValue(),
-       //      find = 'text'/*this.findText.getValue()*/;
-
-       //this.invalidRegex = false;
-       /*
-       if ( isRegex && find ) {
-               try {
-                       this.query = new RegExp( find );
-               } catch ( e ) {
-                       this.invalidRegex = true;
-               }
-       } else {
-       //      this.query = find;
-       //}
-       //this.findText.$element.toggleClass( 
've-ui-LanguageToolDialog-findText-error', this.invalidRegex );
-
-       this.fragments = [];
-       if ( this.query ) {
-               ranges = documentModel.findText( this.query, /*matchCase, true 
);
-               for ( i = 0, l = ranges.length; i < l; i++ ) {
-                       this.fragments.push( surfaceModel.getLinearFragment( 
ranges[i], true, true ) );
-               }
-       }
-       this.results = this.fragments.length;
-       this.focusedIndex = Math.min( this.focusedIndex, this.results ? 
this.results - 1 : 0 );
-       //this.nextButton.setDisabled( !this.results );
-       //this.previousButton.setDisabled( !this.results );
-       //this.replaceButton.setDisabled( !this.results );
-       //this.replaceAllButton.setDisabled( !this.results );
-};
-*/
-/**
- * Position results markers
- */
-ve.ui.LanguageToolDialog.prototype.renderFragments = function () {
-       if ( this.replacing ) {
-               return;
-       }
-
-       var i, selection, viewportRange,
-               start = 0,
-               end = this.results;
-
-       // When there are a large number of results, calculate the viewport 
range for clipping
-       if ( this.results > 50 ) {
-               viewportRange = this.surface.getView().getViewportRange();
-               for ( i = 0; i < this.results; i++ ) {
-                       selection = this.fragments[i].getSelection();
-                       if ( viewportRange && selection.getRange().start < 
viewportRange.start ) {
-                               start = i + 1;
-                               continue;
-                       }
-                       if ( viewportRange && selection.getRange().end > 
viewportRange.end ) {
-                               end = i;
-                               break;
-                       }
-               }
-       }
-
-       // When there are too many results to render, just render the current 
one
-       if ( end - start <= this.constructor.static.maxRenderedResults ) {
-               this.renderRangeOfFragments( new ve.Range( start, end ) );
-       } else {
-               this.renderRangeOfFragments( new ve.Range( this.focusedIndex, 
this.focusedIndex + 1 ) );
-       }
-};
-
-/**
- * Render subset of search result fragments
- *
- * @param {ve.Range} range Range of fragments to render
- */
-ve.ui.LanguageToolDialog.prototype.renderRangeOfFragments = function ( range ) 
{
-       var i, j, jlen, rects, $result, top;
-       this.$findResults.empty();
-       for ( i = range.start; i < range.end; i++ ) {
-               rects = this.surface.getView().getSelectionRects( 
this.fragments[i].getSelection() );
-               $result = this.$( '<div>' ).addClass( 
've-ui-LanguageToolDialog-findResult' );
-               top = Infinity;
-               for ( j = 0, jlen = rects.length; j < jlen; j++ ) {
-                       top = Math.min( top, rects[j].top );
-                       $result.append( this.$( '<div>' ).css( {
-                               top: rects[j].top,
-                               left: rects[j].left,
-                               width: rects[j].width,
-                               height: rects[j].height
-                       } ) );
-               }
-               $result.data( 'top', top );
-               this.$findResults.append( $result );
-       }
-       this.renderedFragments = range;
-       this.highlightFocused();
-};
-
-/**
- * Highlight the focused result marker
- *
- * @param {boolean} scrollIntoView Scroll the marker into view
- */
-ve.ui.LanguageToolDialog.prototype.highlightFocused = function ( 
scrollIntoView ) {
-       var $result, rect, top,
-               offset, windowScrollTop, windowScrollHeight,
-               surfaceView = this.surface.getView();
-
-       if ( this.results ) {
-               /*this.findText.setLabel(
-                       ve.msg( 'visualeditor-find-and-replace-results', 
this.focusedIndex + 1, this.results )
-               );*/
-       } else {
-               /*this.findText.setLabel(
-                       //this.invalidRegex ? ve.msg( 
'visualeditor-find-and-replace-invalid-regex' ) : ''
-               );*/
-               return;
-       }
-
-       this.$findResults
-               .find( '.ve-ui-LanguageToolDialog-findResult-focused' )
-               .removeClass( 've-ui-LanguageToolDialog-findResult-focused' );
-
-       if ( this.renderedFragments.containsOffset( this.focusedIndex ) ) {
-               $result = this.$findResults.children().eq( this.focusedIndex - 
this.renderedFragments.start )
-                       .addClass( 
've-ui-LanguageToolDialog-findResult-focused' );
-
-               top = $result.data( 'top' );
-       } else {
-               // Focused result hasn't been rendered yet so find its offset 
manually
-               rect = surfaceView.getSelectionBoundingRect( 
this.fragments[this.focusedIndex].getSelection() );
-               top = rect.top;
-               this.renderRangeOfFragments( new ve.Range( this.focusedIndex, 
this.focusedIndex + 1 ) );
-       }
-
-       if ( scrollIntoView ) {
-               surfaceView = this.surface.getView();
-               offset = top + surfaceView.$element.offset().top;
-               windowScrollTop = surfaceView.$window.scrollTop() + 
this.surface.toolbarHeight;
-               windowScrollHeight = surfaceView.$window.height() - 
this.surface.toolbarHeight;
-
-               if ( offset < windowScrollTop || offset > windowScrollTop + 
windowScrollHeight ) {
-                       surfaceView.$( 'body, html' ).animate( { scrollTop: 
offset - ( windowScrollHeight / 2  ) }, 'fast' );
-               }
-       }
-};
-
-/**
- * Find the next result
- */
- /*
-ve.ui.LanguageToolDialog.prototype.findNext = function () {
-       this.focusedIndex = ( this.focusedIndex + 1 ) % this.results;
-       this.highlightFocused( true );
-};*/
-
-/**
- * Find the previous result
- */
- /*
-ve.ui.LanguageToolDialog.prototype.findPrevious = function () {
-       this.focusedIndex = ( this.focusedIndex + this.results - 1 ) % 
this.results;
-       this.highlightFocused( true );
-};
-*/
-
-/**
- * Handle click events on the replace button
- */
- /*
-ve.ui.LanguageToolDialog.prototype.onReplaceButtonClick = function () {
-       var end;
-
-       if ( !this.results ) {
-               return;
-       }
-
-       this.replace( this.focusedIndex );
-
-       // Find the next fragment after this one ends. Ensures that if we 
replace
-       // 'foo' with 'foofoo' we don't select the just-inserted text.
-       end = this.fragments[this.focusedIndex].getSelection().getRange().end;
-       // updateFragmentsDebounced is triggered by insertContent, but call it 
immediately
-       // so we can find the next fragment to select.
-       this.updateFragments();
-       if ( !this.results ) {
-               this.focusedIndex = 0;
-               return;
-       }
-       while ( this.fragments[this.focusedIndex] && 
this.fragments[this.focusedIndex].getSelection().getRange().end <= end ) {
-               this.focusedIndex++;
-       }
-       // We may have iterated off the end
-       this.focusedIndex = this.focusedIndex % this.results;
-};
-*/
-
-/**
- * Handle click events on the previous all button
- */
- /*
-ve.ui.LanguageToolDialog.prototype.onReplaceAllButtonClick = function () {
-       var i, l;
-
-       for ( i = 0, l = this.results; i < l; i++ ) {
-               this.replace( i );
-       }
-};
-*/
-/**
- * Replace the result at a specified index
- *
- * @param {number} index Index to replace
- */
- /*
-ve.ui.LanguageToolDialog.prototype.replace = function ( index ) {
-       var replace = this.replaceText.getValue();
-
-       /*if ( this.query instanceof RegExp ) {
-               this.fragments[index].insertContent(
-                       this.fragments[index].getText().replace( this.query, 
replace ),
-                       true
-               );
-       } else {
-               this.fragments[index].insertContent( replace, true );
-       //}
-};*/
-
-/**
- * @inheritdoc
- */
-ve.ui.LanguageToolDialog.prototype.getActionProcess = function ( action ) {
-       /*if ( action === 'findNext' || action === 'findPrevious' ) {
-               return new OO.ui.Process( this[action], this );
-       }*/
-       return ve.ui.LanguageToolDialog.super.prototype.getActionProcess.call( 
this, action );
-};
-
-/* Registration */
-
-ve.ui.windowFactory.register( ve.ui.LanguageToolDialog );
-}() );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3c88e2e18b318e72af5ccf5cae2f0893ba9561fa
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/LanguageTool
Gerrit-Branch: master
Gerrit-Owner: Ankita-ks <kumariankita...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to