Jdlrobson has uploaded a new change for review.

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

Change subject: Hygiene: Move DOM handling out of postRender
......................................................................

Hygiene: Move DOM handling out of postRender

postRender in theory can be run multiple times. We only want to add
this to the DOM once.

Change-Id: I6096960578846f1c264dc8bcc65ca65f2002e028
---
M javascripts/modules/wikigrok/WikiGrokDialog.js
M javascripts/modules/wikigrok/wikigrokeval.js
2 files changed, 11 insertions(+), 11 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/MobileFrontend 
refs/changes/34/162134/1

diff --git a/javascripts/modules/wikigrok/WikiGrokDialog.js 
b/javascripts/modules/wikigrok/WikiGrokDialog.js
index 136d460..c6f0c0e 100644
--- a/javascripts/modules/wikigrok/WikiGrokDialog.js
+++ b/javascripts/modules/wikigrok/WikiGrokDialog.js
@@ -124,16 +124,6 @@
                postRender: function( options ) {
                        var self = this;
 
-                       // Insert the dialog into the page
-                       $( function() {
-                               // If there is a table of contents, insert 
before it.
-                               if ( $( '.toc-mobile' ).length ) {
-                                       self.insertBefore( '.toc-mobile' );
-                               } else {
-                                       self.appendTo( M.getLeadSection() );
-                               }
-                       } );
-
                        // Initialize all the buttons and links
                        // ...for final 'Thanks' step
                        if ( options.thankUser ) {
diff --git a/javascripts/modules/wikigrok/wikigrokeval.js 
b/javascripts/modules/wikigrok/wikigrokeval.js
index 0bde32c..9e42a55 100644
--- a/javascripts/modules/wikigrok/wikigrokeval.js
+++ b/javascripts/modules/wikigrok/wikigrokeval.js
@@ -22,6 +22,7 @@
                        dataType: 'jsonp',
                        success: function( data ) {
                                var instanceClaims,
+                                       dialog,
                                        loadWikiGrokDialog = false;
 
                                // See if the page has any 'instance of' claims.
@@ -39,7 +40,16 @@
                                                }
                                        } );
                                        if ( loadWikiGrokDialog ) {
-                                               new WikiGrokDialog( { itemId: 
wikidataID } );
+                                               dialog = new WikiGrokDialog( { 
itemId: wikidataID } );
+                                               // Insert the dialog into the 
page
+                                               $( function() {
+                                                       // If there is a table 
of contents, insert before it.
+                                                       if ( $( '.toc-mobile' 
).length ) {
+                                                               
dialog.insertBefore( '.toc-mobile' );
+                                                       } else {
+                                                               
dialog.appendTo( M.getLeadSection() );
+                                                       }
+                                               } );
                                        }
                                }
                        }

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6096960578846f1c264dc8bcc65ca65f2002e028
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/MobileFrontend
Gerrit-Branch: master
Gerrit-Owner: Jdlrobson <[email protected]>

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

Reply via email to