7
7
import $ from "jquery" ;
8
8
9
9
import notify from "../notify.js" ;
10
- import { isUrlValid } from "../validation.js" ;
10
+ import { isUrlValid , isEmpty } from "../validation.js" ;
11
11
import { extractPrettyUrl } from "../utils.js" ;
12
12
import { showError , showSuccess , hideSuccess } from "../ui-utils.js" ;
13
13
import { sendAnalyticsEvent } from "../analytics.js" ;
14
14
15
15
const urlField = $ ( "#url" ) ;
16
16
const nextStepButton = $ ( ".next-url" ) ;
17
+ const urlDesc = $ ( "#desc-url" ) ;
18
+ const noUrlDesc = $ ( "#desc-no-url" ) ;
17
19
18
20
const showNextStep = ( id , data ) => notify . publish ( "showStep" , { id, data } ) ;
19
21
@@ -43,11 +45,19 @@ const onBlur = (value) => {
43
45
handleEvent ( value , ( ) => showError ( urlField , "A valid URL is required." ) ) ;
44
46
} ;
45
47
48
+ const updateDescription = ( val ) => {
49
+ if ( ! isEmpty ( val ) ) {
50
+ urlDesc . removeClass ( "is-hidden" ) ;
51
+ noUrlDesc . addClass ( "is-hidden" ) ;
52
+ }
53
+ } ;
54
+
46
55
const initListeners = ( ) => {
47
56
urlField . on ( "input" , ( event ) => onChange ( event . target . value ) ) ;
48
57
urlField . on ( "blur" , ( event ) => onBlur ( event . target . value ) ) ;
49
58
nextStepButton . on ( "click" , onClick ) ;
50
59
urlField . trigger ( "input" ) ;
60
+ updateDescription ( urlField . val ( ) ) ;
51
61
} ;
52
62
53
63
initListeners ( ) ;
@@ -57,5 +67,6 @@ export default {
57
67
update : ( { url } ) => {
58
68
if ( ! url ) return ;
59
69
urlField . val ( url ) . trigger ( "input" ) ;
70
+ updateDescription ( url ) ;
60
71
} ,
61
72
} ;
0 commit comments