mw.widgets.CategoryCapsuleItemWidget: Improve marking of missing categories
authorBartosz Dziewoński <matma.rex@gmail.com>
Mon, 23 Nov 2015 14:24:16 +0000 (15:24 +0100)
committerMarkTraceur <mtraceur@member.fsf.org>
Mon, 23 Nov 2015 16:42:01 +0000 (16:42 +0000)
* Add a 'title' attribute like for wikitext links
* Add a 'missing' property to make it easy to check for redlinks
  in the input programatically

Change-Id: I647af4dee947a6572f0202cf6b8b28777bbdc17e

resources/Resources.php
resources/src/mediawiki.widgets/mw.widgets.CategoryCapsuleItemWidget.js

index ebdcbee..66e373a 100644 (file)
@@ -2042,6 +2042,9 @@ return array(
                        'mediawiki.ForeignApi',
                        'mediawiki.Title',
                ),
+               'messages' => array(
+                       'red-link-title',
+               ),
                'targets' => array( 'desktop', 'mobile' ),
        ),
        'mediawiki.widgets.UserInputWidget' => array(
index 24b0e72..617aa81 100644 (file)
                        title = new ForeignTitle( this.title.getPrefixedText() ), // HACK
                        prefix = this.apiUrl.replace( '/w/api.php', '' ); // HACK
 
+               this.missing = missing;
+
                if ( !missing ) {
                        this.$link
                                .attr( 'href', prefix + title.getUrl() )
+                               .attr( 'title', title.getPrefixedText() )
                                .removeClass( 'new' );
                } else {
                        this.$link
                                .attr( 'href', prefix + title.getUrl( { action: 'edit', redlink: 1 } ) )
+                               .attr( 'title', mw.message( 'red-link-title', title.getPrefixedText() ) )
                                .addClass( 'new' );
                }
        };