Mooeypoo has uploaded a new change for review.

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

Change subject: [BREAKING CHANGE] Allow access to surface through window manager
......................................................................

[BREAKING CHANGE] Allow access to surface through window manager

We've been back and forth on this, but we really just need a way for
inspectors to be able to open dialogs.

Bonus: Re-use the dialog manager for the language inspector's language
selection dialog.

Change-Id: I3d9caef38755eb39c97e7ce35f7559ee7efdff0b
(cherry picked from commit 37ac76370a564e2b987f9e87b4767af7086e456a)
---
M .jsduck/eg-iframe.html
M build/modules.json
M demos/ve/desktop.html
M demos/ve/mobile.html
M src/ui/inspectors/ve.ui.LanguageInspector.js
M src/ui/ve.ui.DesktopContext.js
M src/ui/ve.ui.DesktopSurface.js
M src/ui/ve.ui.MobileContext.js
M src/ui/ve.ui.MobileSurface.js
M src/ui/ve.ui.Surface.js
M src/ui/windowmanagers/ve.ui.DesktopInspectorWindowManager.js
M src/ui/windowmanagers/ve.ui.MobileWindowManager.js
A src/ui/windowmanagers/ve.ui.SurfaceWindowManager.js
M src/ui/windowmanagers/ve.ui.ToolbarDialogWindowManager.js
M tests/index.html
15 files changed, 71 insertions(+), 18 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/VisualEditor/VisualEditor 
refs/changes/63/198263/1

diff --git a/.jsduck/eg-iframe.html b/.jsduck/eg-iframe.html
index 00bf7b6..8ce6c4c 100644
--- a/.jsduck/eg-iframe.html
+++ b/.jsduck/eg-iframe.html
@@ -319,6 +319,7 @@
                <script 
src="../src/ui/ve.ui.DataTransferHandlerFactory.js"></script>
                <script src="../src/ui/ve.ui.DataTransferItem.js"></script>
                <script src="../src/ui/ve.ui.WindowManager.js"></script>
+               <script 
src="../src/ui/windowmanagers/ve.ui.SurfaceWindowManager.js"></script>
                <script 
src="../src/ui/actions/ve.ui.AnnotationAction.js"></script>
                <script src="../src/ui/actions/ve.ui.ContentAction.js"></script>
                <script src="../src/ui/actions/ve.ui.FormatAction.js"></script>
diff --git a/build/modules.json b/build/modules.json
index 7a3b019..2f10281 100644
--- a/build/modules.json
+++ b/build/modules.json
@@ -343,6 +343,7 @@
                        "src/ui/ve.ui.DataTransferHandlerFactory.js",
                        "src/ui/ve.ui.DataTransferItem.js",
                        "src/ui/ve.ui.WindowManager.js",
+                       "src/ui/windowmanagers/ve.ui.SurfaceWindowManager.js",
                        "src/ui/actions/ve.ui.AnnotationAction.js",
                        "src/ui/actions/ve.ui.ContentAction.js",
                        "src/ui/actions/ve.ui.FormatAction.js",
diff --git a/demos/ve/desktop.html b/demos/ve/desktop.html
index 2da040f..25c4679 100644
--- a/demos/ve/desktop.html
+++ b/demos/ve/desktop.html
@@ -337,6 +337,7 @@
                <script 
src="../../src/ui/ve.ui.DataTransferHandlerFactory.js"></script>
                <script src="../../src/ui/ve.ui.DataTransferItem.js"></script>
                <script src="../../src/ui/ve.ui.WindowManager.js"></script>
+               <script 
src="../../src/ui/windowmanagers/ve.ui.SurfaceWindowManager.js"></script>
                <script 
src="../../src/ui/actions/ve.ui.AnnotationAction.js"></script>
                <script 
src="../../src/ui/actions/ve.ui.ContentAction.js"></script>
                <script 
src="../../src/ui/actions/ve.ui.FormatAction.js"></script>
diff --git a/demos/ve/mobile.html b/demos/ve/mobile.html
index 96558fd..80a7c6c 100644
--- a/demos/ve/mobile.html
+++ b/demos/ve/mobile.html
@@ -338,6 +338,7 @@
                <script 
src="../../src/ui/ve.ui.DataTransferHandlerFactory.js"></script>
                <script src="../../src/ui/ve.ui.DataTransferItem.js"></script>
                <script src="../../src/ui/ve.ui.WindowManager.js"></script>
+               <script 
src="../../src/ui/windowmanagers/ve.ui.SurfaceWindowManager.js"></script>
                <script 
src="../../src/ui/actions/ve.ui.AnnotationAction.js"></script>
                <script 
src="../../src/ui/actions/ve.ui.ContentAction.js"></script>
                <script 
src="../../src/ui/actions/ve.ui.FormatAction.js"></script>
diff --git a/src/ui/inspectors/ve.ui.LanguageInspector.js 
b/src/ui/inspectors/ve.ui.LanguageInspector.js
index ec10259..b72142a 100644
--- a/src/ui/inspectors/ve.ui.LanguageInspector.js
+++ b/src/ui/inspectors/ve.ui.LanguageInspector.js
@@ -72,7 +72,10 @@
        ve.ui.LanguageInspector.super.prototype.initialize.call( this );
 
        // Properties
-       this.languageInput = new ve.ui.LanguageInputWidget( { $: this.$ } );
+       this.languageInput = new ve.ui.LanguageInputWidget( {
+               $: this.$,
+               dialogManager: this.manager.getSurface().getDialogs()
+       } );
 
        // Initialization
        this.form.$element.append( this.languageInput.$element );
diff --git a/src/ui/ve.ui.DesktopContext.js b/src/ui/ve.ui.DesktopContext.js
index 0847187..1c78fc4 100644
--- a/src/ui/ve.ui.DesktopContext.js
+++ b/src/ui/ve.ui.DesktopContext.js
@@ -124,7 +124,7 @@
  * @inheritdoc
  */
 ve.ui.DesktopContext.prototype.createInspectorWindowManager = function () {
-       return new ve.ui.DesktopInspectorWindowManager( {
+       return new ve.ui.DesktopInspectorWindowManager( this.surface, {
                $: this.$,
                factory: ve.ui.windowFactory,
                overlay: this.surface.getLocalOverlay(),
diff --git a/src/ui/ve.ui.DesktopSurface.js b/src/ui/ve.ui.DesktopSurface.js
index d55e5a3..cea5abf 100644
--- a/src/ui/ve.ui.DesktopSurface.js
+++ b/src/ui/ve.ui.DesktopSurface.js
@@ -37,5 +37,5 @@
  * @inheritdoc
  */
 ve.ui.DesktopSurface.prototype.createDialogWindowManager = function () {
-       return new ve.ui.WindowManager( { factory: ve.ui.windowFactory } );
+       return new ve.ui.SurfaceWindowManager( this, { factory: 
ve.ui.windowFactory } );
 };
diff --git a/src/ui/ve.ui.MobileContext.js b/src/ui/ve.ui.MobileContext.js
index d0bc494..43204dc 100644
--- a/src/ui/ve.ui.MobileContext.js
+++ b/src/ui/ve.ui.MobileContext.js
@@ -48,7 +48,7 @@
  * @inheritdoc
  */
 ve.ui.MobileContext.prototype.createInspectorWindowManager = function () {
-       return new ve.ui.MobileWindowManager( {
+       return new ve.ui.MobileWindowManager( this.surface, {
                factory: ve.ui.windowFactory,
                overlay: this.surface.getGlobalOverlay()
        } );
diff --git a/src/ui/ve.ui.MobileSurface.js b/src/ui/ve.ui.MobileSurface.js
index b71f168..65c4e9e 100644
--- a/src/ui/ve.ui.MobileSurface.js
+++ b/src/ui/ve.ui.MobileSurface.js
@@ -76,7 +76,7 @@
  * @inheritdoc
  */
 ve.ui.MobileSurface.prototype.createDialogWindowManager = function () {
-       return new ve.ui.MobileWindowManager( {
+       return new ve.ui.MobileWindowManager( this, {
                factory: ve.ui.windowFactory,
                overlay: this.globalOverlay
        } );
diff --git a/src/ui/ve.ui.Surface.js b/src/ui/ve.ui.Surface.js
index 1c4ffd9..6e211c2 100644
--- a/src/ui/ve.ui.Surface.js
+++ b/src/ui/ve.ui.Surface.js
@@ -61,7 +61,7 @@
        this.debugBar = null;
 
        this.toolbarHeight = 0;
-       this.toolbarDialogs = new ve.ui.ToolbarDialogWindowManager( {
+       this.toolbarDialogs = new ve.ui.ToolbarDialogWindowManager( this, {
                $: this.$,
                factory: ve.ui.windowFactory,
                modal: false
diff --git a/src/ui/windowmanagers/ve.ui.DesktopInspectorWindowManager.js 
b/src/ui/windowmanagers/ve.ui.DesktopInspectorWindowManager.js
index b7b0214..6b1eac2 100644
--- a/src/ui/windowmanagers/ve.ui.DesktopInspectorWindowManager.js
+++ b/src/ui/windowmanagers/ve.ui.DesktopInspectorWindowManager.js
@@ -8,20 +8,21 @@
  * Window manager for desktop inspectors.
  *
  * @class
- * @extends ve.ui.WindowManager
+ * @extends ve.ui.SurfaceWindowManager
  *
  * @constructor
+ * @param {ve.ui.Surface} Surface this belongs to
  * @param {Object} [config] Configuration options
  * @cfg {ve.ui.Overlay} [overlay] Overlay to use for menus
  */
-ve.ui.DesktopInspectorWindowManager = function 
VeUiDesktopInspectorWindowManager( config ) {
+ve.ui.DesktopInspectorWindowManager = function 
VeUiDesktopInspectorWindowManager( surface, config ) {
        // Parent constructor
-       ve.ui.DesktopInspectorWindowManager.super.call( this, config );
+       ve.ui.DesktopInspectorWindowManager.super.call( this, surface, config );
 };
 
 /* Inheritance */
 
-OO.inheritClass( ve.ui.DesktopInspectorWindowManager, ve.ui.WindowManager );
+OO.inheritClass( ve.ui.DesktopInspectorWindowManager, 
ve.ui.SurfaceWindowManager );
 
 /* Static Properties */
 
diff --git a/src/ui/windowmanagers/ve.ui.MobileWindowManager.js 
b/src/ui/windowmanagers/ve.ui.MobileWindowManager.js
index fc35678..18fa5dc 100644
--- a/src/ui/windowmanagers/ve.ui.MobileWindowManager.js
+++ b/src/ui/windowmanagers/ve.ui.MobileWindowManager.js
@@ -8,19 +8,21 @@
  * Window manager for mobile windows.
  *
  * @class
- * @extends ve.ui.WindowManager
+ * @extends ve.ui.SurfaceWindowManager
  *
  * @constructor
+ * @param {ve.ui.Surface} Surface this belongs to
  * @param {Object} [config] Configuration options
+ * @cfg {ve.ui.Overlay} [overlay] Overlay to use for menus
  */
-ve.ui.MobileWindowManager = function VeUiMobileWindowManager( config ) {
+ve.ui.MobileWindowManager = function VeUiMobileWindowManager( surface, config 
) {
        // Parent constructor
-       ve.ui.MobileWindowManager.super.call( this, config );
+       ve.ui.MobileWindowManager.super.call( this, surface, config );
 };
 
 /* Inheritance */
 
-OO.inheritClass( ve.ui.MobileWindowManager, ve.ui.WindowManager );
+OO.inheritClass( ve.ui.MobileWindowManager, ve.ui.SurfaceWindowManager );
 
 /* Static Properties */
 
diff --git a/src/ui/windowmanagers/ve.ui.SurfaceWindowManager.js 
b/src/ui/windowmanagers/ve.ui.SurfaceWindowManager.js
new file mode 100644
index 0000000..4625da8
--- /dev/null
+++ b/src/ui/windowmanagers/ve.ui.SurfaceWindowManager.js
@@ -0,0 +1,41 @@
+/*!
+ * VisualEditor UserInterface SurfaceWindowManager class.
+ *
+ * @copyright 2011-2015 VisualEditor Team and others; see 
http://ve.mit-license.org
+ */
+
+/**
+ * Window manager for desktop inspectors.
+ *
+ * @class
+ * @extends ve.ui.WindowManager
+ *
+ * @constructor
+ * @param {ve.ui.Surface} Surface this belongs to
+ * @param {Object} [config] Configuration options
+ * @cfg {ve.ui.Overlay} [overlay] Overlay to use for menus
+ */
+ve.ui.SurfaceWindowManager = function VeUiSurfaceWindowManager( surface, 
config ) {
+       // Properties
+       // Set up surface before calling the parent so we can request
+       // specific surface-related details from within the constructor.
+       this.surface = surface;
+
+       // Parent constructor
+       ve.ui.SurfaceWindowManager.super.call( this, config );
+};
+
+/* Inheritance */
+
+OO.inheritClass( ve.ui.SurfaceWindowManager, ve.ui.WindowManager );
+
+/* Methods */
+
+/**
+ * Get surface.
+ *
+ * @return {ve.ui.Surface} Surface this belongs to
+ */
+ve.ui.SurfaceWindowManager.prototype.getSurface = function () {
+       return this.surface;
+};
diff --git a/src/ui/windowmanagers/ve.ui.ToolbarDialogWindowManager.js 
b/src/ui/windowmanagers/ve.ui.ToolbarDialogWindowManager.js
index c1d0b2c..09b0359 100644
--- a/src/ui/windowmanagers/ve.ui.ToolbarDialogWindowManager.js
+++ b/src/ui/windowmanagers/ve.ui.ToolbarDialogWindowManager.js
@@ -8,20 +8,21 @@
  * Window manager for toolbar dialogs.
  *
  * @class
- * @extends ve.ui.WindowManager
+ * @extends ve.ui.SurfaceWindowManager
  *
  * @constructor
+ * @param {ve.ui.Surface} Surface this belongs to
  * @param {Object} [config] Configuration options
  * @cfg {ve.ui.Overlay} [overlay] Overlay to use for menus
  */
-ve.ui.ToolbarDialogWindowManager = function VeUiToolbarDialogWindowManager( 
config ) {
+ve.ui.ToolbarDialogWindowManager = function VeUiToolbarDialogWindowManager( 
surface, config ) {
        // Parent constructor
-       ve.ui.ToolbarDialogWindowManager.super.call( this, config );
+       ve.ui.ToolbarDialogWindowManager.super.call( this, surface, config );
 };
 
 /* Inheritance */
 
-OO.inheritClass( ve.ui.ToolbarDialogWindowManager, ve.ui.WindowManager );
+OO.inheritClass( ve.ui.ToolbarDialogWindowManager, ve.ui.SurfaceWindowManager 
);
 
 /* Static Properties */
 
diff --git a/tests/index.html b/tests/index.html
index 5b1f1e3..309026f 100644
--- a/tests/index.html
+++ b/tests/index.html
@@ -274,6 +274,7 @@
                <script 
src="../src/ui/ve.ui.DataTransferHandlerFactory.js"></script>
                <script src="../src/ui/ve.ui.DataTransferItem.js"></script>
                <script src="../src/ui/ve.ui.WindowManager.js"></script>
+               <script 
src="../src/ui/windowmanagers/ve.ui.SurfaceWindowManager.js"></script>
                <script 
src="../src/ui/actions/ve.ui.AnnotationAction.js"></script>
                <script src="../src/ui/actions/ve.ui.ContentAction.js"></script>
                <script src="../src/ui/actions/ve.ui.FormatAction.js"></script>

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d9caef38755eb39c97e7ce35f7559ee7efdff0b
Gerrit-PatchSet: 1
Gerrit-Project: VisualEditor/VisualEditor
Gerrit-Branch: wmf/1.25wmf21
Gerrit-Owner: Mooeypoo <mor...@gmail.com>
Gerrit-Reviewer: Trevor Parscal <tpars...@wikimedia.org>

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

Reply via email to