Jonas Kress (WMDE) has uploaded a new change for review.

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

Change subject: Remember textual representation visibility state with cookie
......................................................................

Remember textual representation visibility state with cookie

Change-Id: Ic99e0c6d662bc97c873d1027a977b1357ca33921
---
M style.css
M wikibase/queryService/ui/App.js
2 files changed, 18 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/wikidata/query/gui 
refs/changes/03/294903/1

diff --git a/style.css b/style.css
index c153be1..800e199 100644
--- a/style.css
+++ b/style.css
@@ -131,8 +131,6 @@
        margin-right: 0;
 }
 
-
-
 .label {
        font-size: 100%;
 }
@@ -378,6 +376,11 @@
     background: rgba(255,255,255,0.9);
 }
 
+.visual-editor .panel-heading {
+       background: rgba(255, 255, 255, 0.9);
+       padding: 8px 10px;
+}
+
 .visual-editor .panel-body {
        font-size: 120%;
 }
diff --git a/wikibase/queryService/ui/App.js b/wikibase/queryService/ui/App.js
index 76ea4be..24e78d3 100644
--- a/wikibase/queryService/ui/App.js
+++ b/wikibase/queryService/ui/App.js
@@ -3,7 +3,7 @@
 wikibase.queryService.ui = wikibase.queryService.ui || {};
 window.mediaWiki = window.mediaWiki || {};
 
-wikibase.queryService.ui.App = ( function( $, mw, download, EXPLORER, window, 
_ ) {
+wikibase.queryService.ui.App = ( function( $, mw, download, EXPLORER, window, 
_, Cookies ) {
        'use strict';
 
        var SHORTURL_API = '//tinyurl.com/api-create.php?url=';
@@ -195,7 +195,9 @@
         * @private
         */
        SELF.prototype._initVisualEditor = function() {
-               var self = this;
+               var self = this,
+                       cookieHide = 'visual-editor-hide';
+
                if ( !this._visualEditor ) {
                        this._visualEditor = new 
wikibase.queryService.ui.visualEditor.VisualEditor();
                }
@@ -203,18 +205,24 @@
                        self._editor.setValue( ve.getQuery() );
                } );
 
+               if ( Cookies.get( cookieHide ) === 'true' ) {
+                       $( '.visual-editor-trigger' ).show();
+               }
+
                if ( this._editor ) {
                        this._editor.registerCallback( 'change', _.debounce( 
function() {
                                if ( $( '.visual-editor-trigger' ).is( 
':visible' ) ||
                                                self._editor.getValue() === 
self._visualEditor.getQuery() ) {
                                        return;
                                }
+
                                $( '.visual-editor' ).hide();
                                self._drawVisualEditor();
-                       }, 500 ) );
+                       }, 1500 ) );
                }
 
                $( '.visual-editor .panel-heading .close' ).click( function() {
+                       Cookies.set( cookieHide, true );
                        $( '.visual-editor' ).hide();
                        $( '.visual-editor-trigger' ).show();
                        return false;
@@ -222,6 +230,7 @@
 
                $( '.visual-editor-trigger' ).click( function() {
                        $( '.visual-editor-trigger' ).hide();
+                       Cookies.set( cookieHide, false );
                        self._drawVisualEditor();
                        return false;
                } );
@@ -690,4 +699,4 @@
        };
 
        return SELF;
-}( jQuery, mediaWiki, download, EXPLORER, window, _ ) );
+}( jQuery, mediaWiki, download, EXPLORER, window, _, Cookies ) );

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic99e0c6d662bc97c873d1027a977b1357ca33921
Gerrit-PatchSet: 1
Gerrit-Project: wikidata/query/gui
Gerrit-Branch: master
Gerrit-Owner: Jonas Kress (WMDE) <jonas.kr...@wikimedia.de>

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

Reply via email to