Trevor Parscal has uploaded a new change for review.
https://gerrit.wikimedia.org/r/90374
Change subject: Split out popup functionality from ve.ui.PopupButtonWidget to
ve.ui.PopuppableElement
......................................................................
Split out popup functionality from ve.ui.PopupButtonWidget to
ve.ui.PopuppableElement
Change-Id: I522d852d81d9674723a3262da3f030417f4fc3be
---
M VisualEditor.php
M demos/ve/index.php
M modules/ve/test/index.php
A modules/ve/ui/elements/ve.ui.PopuppableElement.js
M modules/ve/ui/widgets/ve.ui.PopupButtonWidget.js
5 files changed, 73 insertions(+), 44 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/VisualEditor
refs/changes/74/90374/1
diff --git a/VisualEditor.php b/VisualEditor.php
index 7d01ede..82a55d9 100644
--- a/VisualEditor.php
+++ b/VisualEditor.php
@@ -427,6 +427,7 @@
've/ui/elements/ve.ui.IconedElement.js',
've/ui/elements/ve.ui.GroupElement.js',
've/ui/elements/ve.ui.FlaggableElement.js',
+ 've/ui/elements/ve.ui.PopuppableElement.js',
've/ui/ve.ui.Surface.js',
've/ui/ve.ui.Context.js',
diff --git a/demos/ve/index.php b/demos/ve/index.php
index ec32f9f..420233e 100644
--- a/demos/ve/index.php
+++ b/demos/ve/index.php
@@ -226,6 +226,7 @@
<script
src="../../modules/ve/ui/elements/ve.ui.IconedElement.js"></script>
<script
src="../../modules/ve/ui/elements/ve.ui.GroupElement.js"></script>
<script
src="../../modules/ve/ui/elements/ve.ui.FlaggableElement.js"></script>
+ <script
src="../../modules/ve/ui/elements/ve.ui.PopuppableElement.js"></script>
<script src="../../modules/ve/ui/ve.ui.Surface.js"></script>
<script src="../../modules/ve/ui/ve.ui.Context.js"></script>
<script src="../../modules/ve/ui/ve.ui.Frame.js"></script>
diff --git a/modules/ve/test/index.php b/modules/ve/test/index.php
index 5802de3..cdaf2b8 100644
--- a/modules/ve/test/index.php
+++ b/modules/ve/test/index.php
@@ -170,6 +170,7 @@
<script
src="../../ve/ui/elements/ve.ui.IconedElement.js"></script>
<script
src="../../ve/ui/elements/ve.ui.GroupElement.js"></script>
<script
src="../../ve/ui/elements/ve.ui.FlaggableElement.js"></script>
+ <script
src="../../ve/ui/elements/ve.ui.PopuppableElement.js"></script>
<script src="../../ve/ui/ve.ui.Surface.js"></script>
<script src="../../ve/ui/ve.ui.Context.js"></script>
<script src="../../ve/ui/ve.ui.Frame.js"></script>
diff --git a/modules/ve/ui/elements/ve.ui.PopuppableElement.js
b/modules/ve/ui/elements/ve.ui.PopuppableElement.js
new file mode 100644
index 0000000..beac1c6
--- /dev/null
+++ b/modules/ve/ui/elements/ve.ui.PopuppableElement.js
@@ -0,0 +1,62 @@
+/*!
+ * VisualEditor UserInterface PopuppableElement class.
+ *
+ * @copyright 2011-2013 VisualEditor Team and others; see AUTHORS.txt
+ * @license The MIT License (MIT); see LICENSE.txt
+ */
+
+/**
+ * Popuppable element.
+ *
+ * @class
+ * @abstract
+ *
+ * @constructor
+ * @param {Object} [config] Configuration options
+ * @cfg {number} [popupWidth=320] Width of popup
+ * @cfg {number} [popupHeight] Height of popup
+ * @cfg {Object} [popup] Configuration to pass to popup
+ */
+ve.ui.PopuppableElement = function VeUiPopuppableElement( config ) {
+ // Configuration initialization
+ config = ve.extendObject( { 'popupWidth': 320 }, config );
+
+ // Properties
+ this.popup = new ve.ui.PopupWidget( ve.extendObject(
+ { 'align': 'center', 'autoClose': true },
+ config.popup,
+ { '$$': this.$$, '$autoCloseIgnore': this.$ }
+ ) );
+ this.popupWidth = config.popupWidth;
+ this.popupHeight = config.popupHeight;
+};
+
+/* Methods */
+
+/**
+ * Get popup.
+ *
+ * @method
+ * @returns {ve.ui.PopupWidget} Popup widget
+ */
+ve.ui.PopuppableElement.prototype.getPopup = function () {
+ return this.popup;
+};
+
+/**
+ * Show popup.
+ *
+ * @method
+ */
+ve.ui.PopuppableElement.prototype.showPopup = function () {
+ this.popup.show().display( this.popupWidth, this.popupHeight );
+};
+
+/**
+ * Hide popup.
+ *
+ * @method
+ */
+ve.ui.PopuppableElement.prototype.hidePopup = function () {
+ this.popup.hide();
+};
diff --git a/modules/ve/ui/widgets/ve.ui.PopupButtonWidget.js
b/modules/ve/ui/widgets/ve.ui.PopupButtonWidget.js
index 6220656..f66fb5b 100644
--- a/modules/ve/ui/widgets/ve.ui.PopupButtonWidget.js
+++ b/modules/ve/ui/widgets/ve.ui.PopupButtonWidget.js
@@ -10,37 +10,29 @@
*
* @class
* @extends ve.ui.IconButtonWidget
+ * @mixins ve.ui.PopuppableElement
*
* @constructor
* @param {Object} [config] Configuration options
- * @cfg {number} [width=320] Width of popup
- * @cfg {number} [height] Height of popup
- * @cfg {Object} [popup] Configuration to pass to popup
*/
ve.ui.PopupButtonWidget = function VeUiPopupButtonWidget( config ) {
- // Configuration initialization
- config = ve.extendObject( { 'width': 320 }, config );
-
// Parent constructor
ve.ui.IconButtonWidget.call( this, config );
- // Properties
- this.popup = new ve.ui.PopupWidget( ve.extendObject(
- { 'align': 'center', 'autoClose': true },
- config.popup,
- { '$$': this.$$, '$autoCloseIgnore': this.$ }
- ) );
- this.width = config.width;
- this.height = config.height;
+ // Mixin constructors
+ ve.ui.PopuppableElement.call( this, config );
// Initialization
- this.$.addClass( 've-ui-popupButtonWidget' );
- this.$.append( this.popup.$ );
+ this.$
+ .addClass( 've-ui-popupButtonWidget' )
+ .append( this.popup.$ );
};
/* Inheritance */
ve.inheritClass( ve.ui.PopupButtonWidget, ve.ui.IconButtonWidget );
+
+ve.mixinClass( ve.ui.PopupButtonWidget, ve.ui.PopuppableElement );
/* Methods */
@@ -65,32 +57,4 @@
ve.ui.IconButtonWidget.prototype.onClick.call( this );
}
return false;
-};
-
-/**
- * Get popup.
- *
- * @method
- * @returns {ve.ui.PopupWidget} Popup widget
- */
-ve.ui.PopupButtonWidget.prototype.getPopup = function () {
- return this.popup;
-};
-
-/**
- * Show popup.
- *
- * @method
- */
-ve.ui.PopupButtonWidget.prototype.showPopup = function () {
- this.popup.show().display( this.width, this.height );
-};
-
-/**
- * Hide popup.
- *
- * @method
- */
-ve.ui.PopupButtonWidget.prototype.hidePopup = function () {
- this.popup.hide();
};
--
To view, visit https://gerrit.wikimedia.org/r/90374
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I522d852d81d9674723a3262da3f030417f4fc3be
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Trevor Parscal <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits