From a686b7f580f73177f546a70c3ef7827c37185349 Mon Sep 17 00:00:00 2001 From: Derk-Jan Hartman Date: Thu, 15 Nov 2018 07:55:09 +0100 Subject: [PATCH] LinkDialog: use placeholder instead of fake values Use proper placeholder attribute instead of faking it with a value. This predated even jquery.placeholder and is no longer needed. Also fixes a bug where it was checking with the API for the existence of the placeholder value. Bug: T133716 Change-Id: I290ec48f6b1d250da28efffd7ebdb6b681c0227e --- modules/jquery.wikiEditor.dialogs.config.js | 75 +++------------------ modules/jquery.wikiEditor.dialogs.less | 3 - 2 files changed, 8 insertions(+), 70 deletions(-) diff --git a/modules/jquery.wikiEditor.dialogs.config.js b/modules/jquery.wikiEditor.dialogs.config.js index 1391aad1..6bc8960e 100644 --- a/modules/jquery.wikiEditor.dialogs.config.js +++ b/modules/jquery.wikiEditor.dialogs.config.js @@ -226,44 +226,10 @@ } ); // Set tabindexes on form fields $.wikiEditor.modules.dialogs.fn.setTabindexes( $( this ).find( 'input' ).not( '[tabindex]' ) ); - // Setup the tooltips in the textboxes - $( '#wikieditor-toolbar-link-int-target' ) - .data( 'tooltip', mw.msg( 'wikieditor-toolbar-tool-link-int-target-tooltip' ) ); - $( '#wikieditor-toolbar-link-int-text' ) - .data( 'tooltip', mw.msg( 'wikieditor-toolbar-tool-link-int-text-tooltip' ) ); - $( '#wikieditor-toolbar-link-int-target, #wikieditor-toolbar-link-int-text' ) - .each( function () { - if ( $( this ).val() === '' ) { - $( this ) - .addClass( 'wikieditor-toolbar-dialog-hint' ) - .val( $( this ).data( 'tooltip' ) ) - .data( 'tooltip-mode', true ); - } - } ) - .on( 'focus', function () { - if ( $( this ).val() === $( this ).data( 'tooltip' ) ) { - $( this ) - .val( '' ) - .removeClass( 'wikieditor-toolbar-dialog-hint' ) - .data( 'tooltip-mode', false ); - } - } ) - .on( 'change', function () { - if ( $( this ).val() !== $( this ).data( 'tooltip' ) ) { - $( this ) - .removeClass( 'wikieditor-toolbar-dialog-hint' ) - .data( 'tooltip-mode', false ); - } - } ) - .on( 'blur', function () { - if ( $( this ).val() === '' ) { - $( this ) - .addClass( 'wikieditor-toolbar-dialog-hint' ) - .val( $( this ).data( 'tooltip' ) ) - .data( 'tooltip-mode', true ); - } - } ); - + $( '#wikieditor-toolbar-link-int-target' ).attr( 'placeholder', + mw.msg( 'wikieditor-toolbar-tool-link-int-target-tooltip' ) ); + $( '#wikieditor-toolbar-link-int-text' ).attr( 'placeholder', + mw.msg( 'wikieditor-toolbar-tool-link-int-text-tooltip' ) ); // Automatically copy the value of the internal link page title field to the link text field unless the // user has changed the link text field - this is a convenience thing since most link texts are going to // be the same as the page title - Also change the internal/external radio button accordingly @@ -279,19 +245,9 @@ updateExistence(); } if ( $( '#wikieditor-toolbar-link-int-text' ).data( 'untouched' ) ) { - // eslint-disable-next-line eqeqeq - if ( $( '#wikieditor-toolbar-link-int-target' ).val() == - $( '#wikieditor-toolbar-link-int-target' ).data( 'tooltip' ) - ) { - $( '#wikieditor-toolbar-link-int-text' ) - .addClass( 'wikieditor-toolbar-dialog-hint' ) - .val( $( '#wikieditor-toolbar-link-int-text' ).data( 'tooltip' ) ) - .change(); - } else { - $( '#wikieditor-toolbar-link-int-text' ) - .val( $( '#wikieditor-toolbar-link-int-target' ).val() ) - .change(); - } + $( '#wikieditor-toolbar-link-int-text' ) + .val( $( '#wikieditor-toolbar-link-int-target' ).val() ) + .change(); } }, 0 ); } ); @@ -416,13 +372,6 @@ function escapeExternalText( s ) { return s.replace( /(\]+)/g, '$1' ); } - // check if the tooltips were passed as target or text - if ( $( '#wikieditor-toolbar-link-int-target' ).data( 'tooltip-mode' ) ) { - target = ''; - } - if ( $( '#wikieditor-toolbar-link-int-text' ).data( 'tooltip-mode' ) ) { - text = ''; - } if ( target === '' ) { // eslint-disable-next-line no-alert alert( mw.msg( 'wikieditor-toolbar-tool-link-empty' ) ); @@ -568,8 +517,7 @@ } $( '#wikieditor-toolbar-link-int-text' ).data( 'untouched', $( '#wikieditor-toolbar-link-int-text' ).val() === - $( '#wikieditor-toolbar-link-int-target' ).val() || - $( '#wikieditor-toolbar-link-int-text' ).hasClass( 'wikieditor-toolbar-dialog-hint' ) + $( '#wikieditor-toolbar-link-int-target' ).val() ); $( '#wikieditor-toolbar-link-int-target' ).suggestions(); @@ -578,13 +526,6 @@ $( '#wikieditor-toolbar-link-int-text' ).data( 'untouched', false ); } - $( '#wikieditor-toolbar-link-int-text, #wikiedit-toolbar-link-int-target' ) - .each( function () { - if ( $( this ).val() === '' ) { - $( this ).parent().find( 'label' ).show(); - } - } ); - if ( !$( this ).data( 'dialogkeypressset' ) ) { $( this ).data( 'dialogkeypressset', true ); // Execute the action associated with the first button diff --git a/modules/jquery.wikiEditor.dialogs.less b/modules/jquery.wikiEditor.dialogs.less index 394e516b..0d2f94b7 100644 --- a/modules/jquery.wikiEditor.dialogs.less +++ b/modules/jquery.wikiEditor.dialogs.less @@ -55,6 +55,3 @@ body { margin-right: 2em; } -.wikieditor-toolbar-dialog-hint { - color: #54595d; -}