Daniel Werner has uploaded a new change for review.

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


Change subject: Improved jQuery.ui.inputextender/jQuery.ui.listrotator destroy 
implementations
......................................................................

Improved jQuery.ui.inputextender/jQuery.ui.listrotator destroy implementations

Change-Id: I0c6a377bafab7132ddd4be44b86c79efb5da39cb
---
M ValueView/resources/jquery.ui/jquery.ui.inputextender.js
M ValueView/resources/jquery.ui/jquery.ui.listrotator.js
2 files changed, 22 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/DataValues 
refs/changes/45/76745/1

diff --git a/ValueView/resources/jquery.ui/jquery.ui.inputextender.js 
b/ValueView/resources/jquery.ui/jquery.ui.inputextender.js
index 8064753..1aae484 100644
--- a/ValueView/resources/jquery.ui/jquery.ui.inputextender.js
+++ b/ValueView/resources/jquery.ui/jquery.ui.inputextender.js
@@ -212,10 +212,6 @@
                                this.options.initCallback();
                        }
 
-                       $.each( this.options.content, function( i, node ) {
-                               $( node ).addClass( self.widgetBaseClass + 
'-contentnode' );
-                       } );
-
                        this.$extension.hide();
                },
 
@@ -223,10 +219,25 @@
                 * @see jQuery.Widget.destroy
                 */
                destroy: function() {
-                       this.$extension.remove();
+                       if( !this.$extension ) {
+                               return; // already destroyed
+                       }
+
+                       clearTimeout( this._animationTimeout );
+                       this._animationTimeout = null;
+
+                       this.element.removeClass( this.widgetBaseClass + 
'-input' );
+
+                       this.$extension.stop( true );
+                       this.$extension.detach();
+                       // There might be references to extension's content 
nodes on the outside, so make sure
+                       // those content nodes get cleaned up as well:
+                       this.$extension.children().removeClass( 
this.widgetBaseClass + '-contentnode' );
+                       this.$extension = null;
 
                        $.Widget.prototype.destroy.call( this );
 
+                       // TODO: Improve performance by maintaining array with 
widget references instead.
                        if( $( ':' + this.widgetBaseClass ).length === 0 ) {
                                $( 'html' ).off( '.' + this.widgetName );
                        }
@@ -241,6 +252,7 @@
                        this.$extension.empty().append( this.$closeIcon );
 
                        $.each( this.options.content, function( i, $node ) {
+                               $node.addClass( self.widgetBaseClass + 
'-contentnode' );
                                self.$extension.append( $node );
                        } );
                },
diff --git a/ValueView/resources/jquery.ui/jquery.ui.listrotator.js 
b/ValueView/resources/jquery.ui/jquery.ui.listrotator.js
index 4a562aa..4659fc3 100644
--- a/ValueView/resources/jquery.ui/jquery.ui.listrotator.js
+++ b/ValueView/resources/jquery.ui/jquery.ui.listrotator.js
@@ -243,9 +243,12 @@
                 * @see $.Widget.destroy
                 */
                destroy: function() {
-                       this.$menu.data( 'menu' ).destroy();
-                       this.$menu.remove();
+                       var menu = this.$menu.data( 'menu' );
+                       if( menu ) {
+                               menu.destroy();
+                       }
 
+                       this.$menu.remove();
                        this.$auto.remove();
                        this.$curr.remove();
                        this.$prev.remove();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0c6a377bafab7132ddd4be44b86c79efb5da39cb
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/DataValues
Gerrit-Branch: master
Gerrit-Owner: Daniel Werner <[email protected]>

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

Reply via email to