Bmansurov has uploaded a new change for review.

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

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.

Bug: T74851
Change-Id: Ifa41e725b972d09624ed95161a83a7451de41b63
---
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, 15 insertions(+), 10 deletions(-)


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

diff --git a/includes/skins/SkinMinerva.php b/includes/skins/SkinMinerva.php
index d7706d9..88479f9 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 6410117..3847679 100644
--- a/javascripts/modules/editor/init.js
+++ b/javascripts/modules/editor/init.js
@@ -32,7 +32,8 @@
                                returntoquery: 'article_action=signup-edit'
                        },
                        content: mw.msg( 'mobile-frontend-editor-cta' )
-               } );
+               } ),
+               $caEdit = $( '#ca-edit' );
 
        if ( pendingToast ) {
                // delete the pending toast
@@ -153,10 +154,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
@@ -191,9 +192,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 () {
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/180315
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifa41e725b972d09624ed95161a83a7451de41b63
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