Bmansurov has uploaded a new change for review.

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

Change subject: Load correct page actions images
......................................................................

Load correct page actions images

Hide page action icons on page load and then show once the correct
classes have been added. Also cache jquery selectors.

Take care of the issues at I359eaa45d82193ac3133daa425d83c3e4b0c1fea

Bug: T74851
Change-Id: Ideb4398c203fb7a10bac8a32e0862013202d0f68
---
M includes/skins/SkinMinerva.php
M javascripts/modules/editor/init.js
M javascripts/modules/uploads/PhotoUploaderButton.js
M javascripts/modules/watchstar/Watchstar.js
4 files changed, 20 insertions(+), 10 deletions(-)


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

diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index ceb7ce3..e84d4e3 100644
--- a/includes/skins/SkinMinerva.php
+++ b/includes/skins/SkinMinerva.php
@@ -778,7 +778,7 @@
                if ( $this->isAllowedPageAction( 'edit' ) ) {
                        $menu['edit'] = array( 'id' => 'ca-edit', 'text' => '',
                                'itemtitle' => $this->msg( 
'mobile-frontend-pageaction-edit-tooltip' ),
-                               'class' => MobileUI::iconClass( 'edit', 
'element', 'icon-32px' ),
+                               'class' => MobileUI::iconClass( 'edit', 
'element', 'icon-32px hidden' ),
                        );
                }
 
@@ -789,14 +789,15 @@
                ) {
                        $menu['photo'] = array( 'id' => 'ca-upload', 'text' => 
'',
                                'itemtitle' => $this->msg( 
'mobile-frontend-pageaction-upload-tooltip' ),
-                               'class' => MobileUI::iconClass( 'addimage', 
'element', 'icon-32px' ),
+                               'class' => MobileUI::iconClass( 'addimage', 
'element', 'icon-32px hidden' ),
                        );
                }
 
                if ( $this->isAllowedPageAction( 'watch' ) ) {
                        $watchTemplate = array(
                                'id' => 'ca-watch',
-                               'class' => MobileUI::iconClass( 'watch', 
'element', 'icon-32px watch-this-article' ),
+                               'class' => MobileUI::iconClass( 'watch', 
'element',
+                                       'icon-32px watch-this-article hidden' ),
                        );
                        // standardise watch article into one menu item
                        if ( isset( $actions['watch'] ) ) {
diff --git a/javascripts/modules/editor/init.js 
b/javascripts/modules/editor/init.js
index f80d572..c025c95 100644
--- a/javascripts/modules/editor/init.js
+++ b/javascripts/modules/editor/init.js
@@ -33,7 +33,8 @@
                                returntoquery: 'article_action=signup-edit'
                        },
                        content: mw.msg( 'mobile-frontend-editor-cta' )
-               } );
+               } ),
+               $caEdit = $( '#ca-edit' );
 
        if ( pendingToast ) {
                // delete the pending toast
@@ -154,10 +155,10 @@
 
                        return result;
                } );
-               $( '#ca-edit' ).addClass( enabledClass ).removeClass( 
disabledClass );
+               $caEdit.addClass( enabledClass ).removeClass( disabledClass 
).removeClass( 'hidden' );
 
                // Make sure we never create two edit links by accident
-               if ( $( '#ca-edit .edit-page' ).length === 0 ) {
+               if ( $caEdit.find( '.edit-page' ).length === 0 ) {
                        // FIXME: unfortunately the main page is special cased.
                        if ( mw.config.get( 'wgIsMainPage' ) || isNewPage || 
page.getLeadSectionElement().text() ) {
                                // if lead section is not empty, open editor 
with lead section
@@ -179,6 +180,7 @@
                        if ( isEditable ) {
                                setupEditor( page );
                        } else {
+                               $caEdit.removeClass( 'hidden' );
                                showSorryToast( 
'mobile-frontend-editor-disabled' );
                        }
                } );
@@ -192,9 +194,10 @@
                // Initialize edit button links (to show Cta) only, if page is 
editable, otherwise show an error toast
                M.getCurrentPage().isEditable( user ).done( function ( 
isEditable ) {
                        if ( isEditable ) {
-                               $( '#ca-edit' ).addClass( enabledClass 
).removeClass( disabledClass );
+                               $caEdit
+                                       .addClass( enabledClass ).removeClass( 
disabledClass ).removeClass( 'hidden' );
                                // Init lead section edit button
-                               makeCta( $( '#ca-edit' ), 0 );
+                               makeCta( $caEdit, 0 );
 
                                // Init all edit links (including lead section, 
if anonymous editing is enabled)
                                $( '.edit-page' ).each( function () {
@@ -207,6 +210,7 @@
                                        makeCta( $a, section );
                                } );
                        } else {
+                               $caEdit.removeClass( 'hidden' );
                                showSorryToast( 
'mobile-frontend-editor-disabled' );
                        }
                } );
@@ -227,8 +231,10 @@
 
        if ( !isEditingSupported ) {
                // Editing is disabled (or browser is blacklisted)
+               $caEdit.removeClass( 'hidden' );
                showSorryToast( 'mobile-frontend-editor-unavailable' );
        } else if ( isNewFile ) {
+               $caEdit.removeClass( 'hidden' );
                // Is a new file page (enable upload image only) Bug 58311
                showSorryToast( 'mobile-frontend-editor-uploadenable' );
        } else {
@@ -241,6 +247,7 @@
                        }
                } else {
                        if ( mw.config.get( 'wgMFIsLoggedInUserBlocked' ) ) {
+                               $caEdit.removeClass( 'hidden' );
                                // User is blocked. Both anonymous and logged 
in users can be blocked.
                                showSorryToast( 
'mobile-frontend-editor-blocked' );
                        } else {
diff --git a/javascripts/modules/uploads/PhotoUploaderButton.js 
b/javascripts/modules/uploads/PhotoUploaderButton.js
index a4db3be..97536c6 100644
--- a/javascripts/modules/uploads/PhotoUploaderButton.js
+++ b/javascripts/modules/uploads/PhotoUploaderButton.js
@@ -58,6 +58,8 @@
                        var self = this,
                                $input = this.$( 'input' );
 
+                       self.$el.removeClass( 'hidden' );
+
                        function handleFile( file ) {
                                // FIXME: this is hacky but it would be hard to 
pass a file in a route
                                M.emit( '_upload-preview', file );
diff --git a/javascripts/modules/watchstar/Watchstar.js 
b/javascripts/modules/watchstar/Watchstar.js
index 7f3fc42..8125313 100644
--- a/javascripts/modules/watchstar/Watchstar.js
+++ b/javascripts/modules/watchstar/Watchstar.js
@@ -122,9 +122,9 @@
 
                        // Add watched class if necessary
                        if ( !user.isAnon() && api.isWatchedPage( page ) ) {
-                               $el.addClass( watchedClass ).removeClass( 
unwatchedClass );
+                               $el.addClass( watchedClass ).removeClass( 
unwatchedClass ).removeClass( 'hidden' );
                        } else {
-                               $el.addClass( unwatchedClass ).removeClass( 
watchedClass );
+                               $el.addClass( unwatchedClass ).removeClass( 
watchedClass ).removeClass( 'hidden' );
                        }
                }
        } );

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

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

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

Reply via email to