Werdna has uploaded a new change for review.

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


Change subject: Anonymous editor warning
......................................................................

Anonymous editor warning

Change-Id: I393d01618783742af1e0c366e602c75212f12566
---
M Flow.i18n.php
M Resources.php
M modules/base/action.js
M modules/base/styles/actionbox.less
M modules/discussion/topic.js
M modules/mediawiki.ui/styles/settings/colors.less
6 files changed, 69 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow 
refs/changes/45/109445/1

diff --git a/Flow.i18n.php b/Flow.i18n.php
index 634c41c..2588853 100644
--- a/Flow.i18n.php
+++ b/Flow.i18n.php
@@ -268,6 +268,10 @@
        'flow-topic-collapsed-one-line' => 'Small view',
        'flow-topic-collapsed-full' => 'Collapsed view',
        'flow-topic-complete' => 'Full view',
+
+       // Anon warning
+       'flow-anon-warning' =>  "You are not logged in.
+Your IP address will be shown next to your contributions unless you log in or 
create an account.",
 );
 
 /** Message documentation (Message documentation)
@@ -1070,6 +1074,8 @@
        'flow-topic-collapsed-full' => 'Used as title for the icon which is 
used to show collapsed view of topics.',
        'flow-topic-complete' => 'Used as title for the icon which is used to 
show full view of topics.
 {{Identical|Full view}}',
+       'flow-anon-warning' => 'Shorter version of anoneditwarning.
+Shown in a tooltip that points to the user\'s IP address being displayed as 
the author of a post.',
 );
 
 /** Achinese (Acèh)
diff --git a/Resources.php b/Resources.php
index 7063aa6..93425db 100644
--- a/Resources.php
+++ b/Resources.php
@@ -79,6 +79,7 @@
                        'jquery.tipsy',
                        'jquery.scroll',
                        'ext.flow.parsoid',
+                       'mediawiki.user',
                ),
                'messages' => array(
                        'flow-newtopic-start-placeholder',
@@ -96,6 +97,7 @@
                        'flow-paging-rev',
                        'flow-post-moderated-toggle-show',
                        'flow-post-moderated-toggle-hide',
+                       'flow-anon-warning',
                ),
                'position' => 'top',
        ),
diff --git a/modules/base/action.js b/modules/base/action.js
index 57bd5fa..ce6cc61 100644
--- a/modules/base/action.js
+++ b/modules/base/action.js
@@ -215,6 +215,11 @@
                                }
                        } );
                }.bind( this, $form, loadFunction ), 0 );
+
+               // add anon warning if required
+               if ( mw.user.getId() === 0 ) {
+                       this.showAnonWarning();
+               }
        };
 
        /**
@@ -302,13 +307,14 @@
         *
         * @param {jQuery} $element
         * @param {string} text
+        * @param {Object} options Overrides
         */
-       mw.flow.action.prototype.tipsy = function ( $element, text ) {
+       mw.flow.action.prototype.tipsy = function ( $element, text, options ) {
                $element
                        .click( function () {
                                $( this ).tipsy( 'hide' );
                        } )
-                       .tipsy( {
+                       .tipsy( $.extend( {
                                fade: true,
                                gravity: 'w',
                                html: true,
@@ -333,7 +339,35 @@
                                        var $warning = $( '<div 
class="flow-tipsy-noflyout">' ).text( text );
                                        return $( '<div>' ).append( $warning 
).html();
                                }
-                       } )
+                       }, options ) )
                        .tipsy( 'show' );
        };
+
+       /**
+        * Shows a tooltip, dismissed by keyup in the form.
+        */
+       mw.flow.action.prototype.showAnonWarning = function() {
+               var $el = this.$form.find( '.flow-creator > a' );
+
+               if ( ! $el.length ) {
+                       $el = this.$form.find( 'textarea:first' );
+               }
+
+               this.tipsy(
+                       $el,
+                       mw.msg( 'flow-anon-warning' ),
+                       {
+                               className : 'flow-tipsy-warning 
flow-anon-warning'
+                       }
+               );
+
+               this.$form.on( 'keyup', 'input, textarea', function(e) {
+                       $el.tipsy( 'hide' );
+               } );
+
+               this.$form.find( '.flow-cancel-link' )
+                       .click( function(e) {
+                               $el.tipsy( 'hide' );
+                       } );
+       };
 } ( jQuery, mediaWiki ) );
diff --git a/modules/base/styles/actionbox.less 
b/modules/base/styles/actionbox.less
index e2f0a45..6715343 100644
--- a/modules/base/styles/actionbox.less
+++ b/modules/base/styles/actionbox.less
@@ -84,6 +84,8 @@
        .tipsy-inner {
                padding: 0;
                border: 1px solid @flyout-border-color;
+               max-width: 25em;
+               border-radius: 1.5px;
        }
 
        .flow-tipsy-flyout {
@@ -94,7 +96,7 @@
        }
 
        .flow-tipsy-noflyout {
-               padding: 10px 22px;
+               padding: 10px;
        }
 
        // overwrite tipsy arrow
@@ -207,4 +209,17 @@
                        .arrow(@arrow-size, @arrow-border-size, 
@destructive-low-base, @destructive-low-base);
                }
        }
+
+       &.flow-anon-warning {
+               .tipsy-inner {
+                       background-color: @warning;
+                       box-shadow: 0 3px @warning-border;
+                       border: none;
+                       color: #fff;
+               }
+
+               .tipsy-arrow {
+                       .arrow(@arrow-size, @arrow-border-size, @warning, 
@warning-border)
+               }
+       }
 }
diff --git a/modules/discussion/topic.js b/modules/discussion/topic.js
index 6b5438c..3ecbcbb 100644
--- a/modules/discussion/topic.js
+++ b/modules/discussion/topic.js
@@ -458,6 +458,11 @@
 
                // load the form
                this.loadNewForm();
+
+               // add anon warning if required
+               if ( mw.user.getId() === 0 ) {
+                       this.showAnonWarning();
+               }
        };
 
        /**
diff --git a/modules/mediawiki.ui/styles/settings/colors.less 
b/modules/mediawiki.ui/styles/settings/colors.less
index fc281e4..b2adc0d 100644
--- a/modules/mediawiki.ui/styles/settings/colors.less
+++ b/modules/mediawiki.ui/styles/settings/colors.less
@@ -13,3 +13,6 @@
 
 @destructive-low-base: #ffb50d;
 @destructive-low-active: #e0a00b;
+
+@warning: #347bff;
+@warning-border: #1059e1;
\ No newline at end of file

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I393d01618783742af1e0c366e602c75212f12566
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: Werdna <[email protected]>

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

Reply via email to