Santhosh has uploaded a new change for review.

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

Change subject: Enable formatting toolbar for non-Chrome browsers
......................................................................

Enable formatting toolbar for non-Chrome browsers

* Hide the list tools - they dont work sensibly outside chrome
* Avoid animating the formatting toolbar
* Remove the 'beta' url param hack
* Avoid js error while executing document.queryCommandState by
  checking document.queryCommandEnabled

Change-Id: I66a5dd675abe588209eaa1487c30d7664313ab3a
---
M modules/tools/ext.cx.tools.formatter.js
M modules/tools/styles/ext.cx.tools.formatter.less
2 files changed, 16 insertions(+), 14 deletions(-)


  git pull 
ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/ContentTranslation 
refs/changes/21/207421/1

diff --git a/modules/tools/ext.cx.tools.formatter.js 
b/modules/tools/ext.cx.tools.formatter.js
index 2e2cd4a..e3722b9 100644
--- a/modules/tools/ext.cx.tools.formatter.js
+++ b/modules/tools/ext.cx.tools.formatter.js
@@ -39,18 +39,29 @@
                        orderedlist: this.$card.find( 
'.card__format--orderedlist' ),
                        unorderedlist: this.$card.find( 
'.card__format--unorderedlist' )
                };
+
+               if ( window.chrome ) {
+                       // Following controls work only in Chrome.
+                       this.$buttons.orderedlist.hide();
+                       this.$buttons.unorderedlist.hide();
+               }
+
                this.$card.hide();
        };
+
+       function getState( command ) {
+               return document.queryCommandEnabled( command ) && 
document.queryCommandState( command );
+       }
 
        /**
         * Show the card.
         */
        FormatTool.prototype.show = function () {
                // Highlight the buttons based on the current state of the 
selection
-               this.$buttons.bold.toggleClass( 'highlight', 
document.queryCommandState( 'bold' ) );
-               this.$buttons.italic.toggleClass( 'highlight', 
document.queryCommandState( 'italic' ) );
-               this.$buttons.orderedlist.toggleClass( 'highlight', 
document.queryCommandState( 'insertOrderedList' ) );
-               this.$buttons.unorderedlist.toggleClass( 'highlight', 
document.queryCommandState( 'insertUnorderedList' ) );
+               this.$buttons.bold.toggleClass( 'highlight', getState( 'bold' ) 
);
+               this.$buttons.italic.toggleClass( 'highlight', getState( 
'italic' ) );
+               this.$buttons.orderedlist.toggleClass( 'highlight', getState( 
'insertOrderedList' ) );
+               this.$buttons.unorderedlist.toggleClass( 'highlight', getState( 
'insertUnorderedList' ) );
                this.$card.show();
                this.onShow();
        };
@@ -182,14 +193,7 @@
                // Capture the selection
                mw.cx.selection.save( 'format', mw.cx.selection.get() );
                this.listen();
-
-               // Format tool is shown only in Chrome. It is show in other 
browsers
-               // if URL hash contains beta
-               if ( window.chrome || location.hash.match( /beta/ ) ) {
-                       this.show();
-               } else {
-                       this.stop();
-               }
+               this.show();
        };
 
        FormatTool.prototype.stop = function () {
diff --git a/modules/tools/styles/ext.cx.tools.formatter.less 
b/modules/tools/styles/ext.cx.tools.formatter.less
index d47d886..e71e609 100644
--- a/modules/tools/styles/ext.cx.tools.formatter.less
+++ b/modules/tools/styles/ext.cx.tools.formatter.less
@@ -1,8 +1,6 @@
 @import "mediawiki.mixins";
 
 .card__format {
-       animation-name: card-show-animation;
-       animation-duration: 0.5s;
        position: relative;
        min-height: 30px;
        padding: 5px;

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I66a5dd675abe588209eaa1487c30d7664313ab3a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/ContentTranslation
Gerrit-Branch: master
Gerrit-Owner: Santhosh <santhosh.thottin...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to