jenkins-bot has submitted this change and it was merged.

Change subject: Split out isPending, pushPending, popPending, etc. into 
PendingElement
......................................................................


Split out isPending, pushPending, popPending, etc. into PendingElement

And use it as a mixin on ActionWidget, for I65b5de4a

Change-Id: Ib2c8f3361b6a674e22e41588cafdd833be391a54
---
M build/modules.json
M src/Dialog.js
A src/elements/PendingElement.js
M src/styles/Dialog.less
M src/styles/widgets/ActionWidget.less
M src/styles/widgets/TextInputWidget.less
M src/themes/apex/widgets.less
M src/widgets/ActionWidget.js
M src/widgets/TextInputWidget.js
9 files changed, 111 insertions(+), 85 deletions(-)

Approvals:
  Trevor Parscal: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/build/modules.json b/build/modules.json
index 2277721..10bf902 100644
--- a/build/modules.json
+++ b/build/modules.json
@@ -4,6 +4,8 @@
                        "src/intro.js.txt",
                        "src/core.js",
 
+                       "src/elements/PendingElement.js",
+
                        "src/ActionSet.js",
                        "src/Element.js",
                                "src/Layout.js",
diff --git a/src/Dialog.js b/src/Dialog.js
index b2a80c4..b5c8baf 100644
--- a/src/Dialog.js
+++ b/src/Dialog.js
@@ -22,6 +22,7 @@
  * @abstract
  * @class
  * @extends OO.ui.Window
+ * @mixins OO.ui.PendingElement
  *
  * @constructor
  * @param {Object} [config] Configuration options
@@ -30,11 +31,13 @@
        // Parent constructor
        OO.ui.Dialog.super.call( this, config );
 
+       // Mixin constructors
+       OO.ui.PendingElement.call( this );
+
        // Properties
        this.actions = new OO.ui.ActionSet();
        this.attachedActions = [];
        this.currentAction = null;
-       this.pending = 0;
 
        // Events
        this.actions.connect( this, {
@@ -52,6 +55,7 @@
 /* Setup */
 
 OO.inheritClass( OO.ui.Dialog, OO.ui.Window );
+OO.mixinClass( OO.ui.Dialog, OO.ui.PendingElement );
 
 /* Static Properties */
 
@@ -137,15 +141,6 @@
        if ( !this.isClosing() ) {
                this.attachActions();
        }
-};
-
-/**
- * Check if input is pending.
- *
- * @return {boolean}
- */
-OO.ui.Dialog.prototype.isPending = function () {
-       return !!this.pending;
 };
 
 /**
@@ -238,6 +233,7 @@
 
        // Initialization
        this.$content.addClass( 'oo-ui-dialog-content' );
+       this.setPendingElement( this.$head );
 };
 
 /**
@@ -273,36 +269,4 @@
        this.pushPending();
        return this.getActionProcess( action ).execute()
                .always( OO.ui.bind( this.popPending, this ) );
-};
-
-/**
- * Increase the pending stack.
- *
- * @chainable
- */
-OO.ui.Dialog.prototype.pushPending = function () {
-       if ( this.pending === 0 ) {
-               this.$content.addClass( 'oo-ui-actionDialog-content-pending' );
-               this.$head.addClass( 'oo-ui-texture-pending' );
-       }
-       this.pending++;
-
-       return this;
-};
-
-/**
- * Reduce the pending stack.
- *
- * Clamped at zero.
- *
- * @chainable
- */
-OO.ui.Dialog.prototype.popPending = function () {
-       if ( this.pending === 1 ) {
-               this.$content.removeClass( 'oo-ui-actionDialog-content-pending' 
);
-               this.$head.removeClass( 'oo-ui-texture-pending' );
-       }
-       this.pending = Math.max( 0, this.pending - 1 );
-
-       return this;
 };
diff --git a/src/elements/PendingElement.js b/src/elements/PendingElement.js
new file mode 100644
index 0000000..6e0e129
--- /dev/null
+++ b/src/elements/PendingElement.js
@@ -0,0 +1,81 @@
+/**
+ * Element that can be marked as pending.
+ *
+ * @abstract
+ * @class
+ *
+ * @constructor
+ * @param {Object} [config] Configuration options
+ */
+OO.ui.PendingElement = function OoUiPendingElement( config ) {
+       // Config initialisation
+       config = config || {};
+
+       // Properties
+       this.pending = 0;
+       this.$pending = null;
+
+       // Initialisation
+       this.setPendingElement( config.$pending || this.$element );
+};
+
+/* Setup */
+
+OO.initClass( OO.ui.PendingElement );
+
+/* Methods */
+
+/**
+ * Set the pending element (and clean up any existing one).
+ *
+ * @param {jQuery} $pending The element to set to pending.
+ */
+OO.ui.PendingElement.prototype.setPendingElement = function ( $pending ) {
+       if ( this.$pending ) {
+               this.$pending.removeClass( 'oo-ui-pendingElement-pending' );
+       }
+
+       this.$pending = $pending;
+       if ( this.pending > 0 ) {
+               this.$pending.addClass( 'oo-ui-pendingElement-pending' );
+       }
+};
+
+/**
+ * Check if input is pending.
+ *
+ * @return {boolean}
+ */
+OO.ui.PendingElement.prototype.isPending = function () {
+       return !!this.pending;
+};
+
+/**
+ * Increase the pending stack.
+ *
+ * @chainable
+ */
+OO.ui.PendingElement.prototype.pushPending = function () {
+       if ( this.pending === 0 ) {
+               this.$pending.addClass( 'oo-ui-pendingElement-pending' );
+       }
+       this.pending++;
+
+       return this;
+};
+
+/**
+ * Reduce the pending stack.
+ *
+ * Clamped at zero.
+ *
+ * @chainable
+ */
+OO.ui.PendingElement.prototype.popPending = function () {
+       if ( this.pending === 1 ) {
+               this.$pending.removeClass( 'oo-ui-pendingElement-pending' );
+       }
+       this.pending = Math.max( 0, this.pending - 1 );
+
+       return this;
+};
diff --git a/src/styles/Dialog.less b/src/styles/Dialog.less
index f4bc29a..60a573e 100644
--- a/src/styles/Dialog.less
+++ b/src/styles/Dialog.less
@@ -16,6 +16,9 @@
                        &-head {
                                z-index: 1;
                                top: 0;
+                               &.oo-ui-pendingElement-pending {
+                                       
.oo-ui-background-image('@{oo-ui-default-image-path}/textures/pending.gif');
+                               }
                        }
 
                        &-body {
diff --git a/src/styles/widgets/ActionWidget.less 
b/src/styles/widgets/ActionWidget.less
index 39ed296..000b1d8 100644
--- a/src/styles/widgets/ActionWidget.less
+++ b/src/styles/widgets/ActionWidget.less
@@ -2,4 +2,8 @@
 
 .oo-ui-actionWidget {
        .theme-oo-ui-actionWidget();
+
+       &.oo-ui-pendingElement-pending {
+               
.oo-ui-background-image('@{oo-ui-default-image-path}/textures/pending.gif');
+       }
 }
diff --git a/src/styles/widgets/TextInputWidget.less 
b/src/styles/widgets/TextInputWidget.less
index d79816a..0897fd6 100644
--- a/src/styles/widgets/TextInputWidget.less
+++ b/src/styles/widgets/TextInputWidget.less
@@ -12,6 +12,12 @@
                .oo-ui-box-sizing(border-box);
        }
 
+       &.oo-ui-pendingElement-pending {
+               input, textarea {
+                       
.oo-ui-background-image('@{oo-ui-default-image-path}/textures/pending.gif');
+               }
+       }
+
        > .oo-ui-iconElement-icon,
        > .oo-ui-indicatorElement-indicator {
                position: absolute;
diff --git a/src/themes/apex/widgets.less b/src/themes/apex/widgets.less
index cc6dca4..f7f6360 100644
--- a/src/themes/apex/widgets.less
+++ b/src/themes/apex/widgets.less
@@ -185,7 +185,7 @@
                text-shadow: 0 1px 1px #fff;
        }
 
-       &-pending {
+       &.oo-ui-pendingElement-pending {
                input,
                textarea {
                        background-color: transparent;
diff --git a/src/widgets/ActionWidget.js b/src/widgets/ActionWidget.js
index d8a54a8..559e599 100644
--- a/src/widgets/ActionWidget.js
+++ b/src/widgets/ActionWidget.js
@@ -3,6 +3,7 @@
  *
  * @class
  * @extends OO.ui.ButtonWidget
+ * @mixins OO.ui.PendingElement
  *
  * @constructor
  * @param {Object} [config] Configuration options
@@ -15,6 +16,9 @@
 
        // Parent constructor
        OO.ui.ActionWidget.super.call( this, config );
+
+       // Mixin constructors
+       OO.ui.PendingElement.call( this, config );
 
        // Properties
        this.action = config.action || '';
@@ -29,6 +33,7 @@
 /* Setup */
 
 OO.inheritClass( OO.ui.ActionWidget, OO.ui.ButtonWidget );
+OO.mixinClass( OO.ui.ActionWidget, OO.ui.PendingElement );
 
 /* Events */
 
diff --git a/src/widgets/TextInputWidget.js b/src/widgets/TextInputWidget.js
index bb5fa4d..c310251 100644
--- a/src/widgets/TextInputWidget.js
+++ b/src/widgets/TextInputWidget.js
@@ -5,6 +5,7 @@
  * @extends OO.ui.InputWidget
  * @mixins OO.ui.IconElement
  * @mixins OO.ui.IndicatorElement
+ * @mixins OO.ui.PendingElement
  *
  * @constructor
  * @param {Object} [config] Configuration options
@@ -23,9 +24,9 @@
        // Mixin constructors
        OO.ui.IconElement.call( this, config );
        OO.ui.IndicatorElement.call( this, config );
+       OO.ui.PendingElement.call( this, config );
 
        // Properties
-       this.pending = 0;
        this.multiline = !!config.multiline;
        this.autosize = !!config.autosize;
        this.maxRows = config.maxRows !== undefined ? config.maxRows : 10;
@@ -51,6 +52,7 @@
 OO.inheritClass( OO.ui.TextInputWidget, OO.ui.InputWidget );
 OO.mixinClass( OO.ui.TextInputWidget, OO.ui.IconElement );
 OO.mixinClass( OO.ui.TextInputWidget, OO.ui.IndicatorElement );
+OO.mixinClass( OO.ui.TextInputWidget, OO.ui.PendingElement );
 
 /* Events */
 
@@ -211,47 +213,6 @@
  */
 OO.ui.TextInputWidget.prototype.isAutosizing = function () {
        return !!this.autosize;
-};
-
-/**
- * Check if input is pending.
- *
- * @return {boolean}
- */
-OO.ui.TextInputWidget.prototype.isPending = function () {
-       return !!this.pending;
-};
-
-/**
- * Increase the pending stack.
- *
- * @chainable
- */
-OO.ui.TextInputWidget.prototype.pushPending = function () {
-       if ( this.pending === 0 ) {
-               this.$element.addClass( 'oo-ui-textInputWidget-pending' );
-               this.$input.addClass( 'oo-ui-texture-pending' );
-       }
-       this.pending++;
-
-       return this;
-};
-
-/**
- * Reduce the pending stack.
- *
- * Clamped at zero.
- *
- * @chainable
- */
-OO.ui.TextInputWidget.prototype.popPending = function () {
-       if ( this.pending === 1 ) {
-               this.$element.removeClass( 'oo-ui-textInputWidget-pending' );
-               this.$input.removeClass( 'oo-ui-texture-pending' );
-       }
-       this.pending = Math.max( 0, this.pending - 1 );
-
-       return this;
 };
 
 /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: Ib2c8f3361b6a674e22e41588cafdd833be391a54
Gerrit-PatchSet: 5
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Alex Monk <[email protected]>
Gerrit-Reviewer: Alex Monk <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: Trevor Parscal <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

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

Reply via email to