@@ -31,6 +31,9 @@ export default class Util {
3131 visible : false
3232 } ) ;
3333
34+ if ( options . title !== undefined && options . title !== null ) {
35+ $ ( '#input-prompt' ) . append ( '<h4 class="title">' + options . title + '</h4>' ) ;
36+ }
3437 var edit = atom . workspace . buildTextEditor ( { mini : true } ) ;
3538 edit . setPlaceholderText ( '' + options . placeholder ) ;
3639 $ ( '#input-prompt' ) . append ( atom . views . getView ( edit ) ) ;
@@ -47,7 +50,7 @@ export default class Util {
4750 $ ( '#prompt-confirm' ) . removeClass ( 'disabled' ) ;
4851 }
4952 }
50- } )
53+ } ) ;
5154 $ ( '#prompt-confirm' ) . on ( 'click' , function ( e ) {
5255 if ( ! $ ( this ) . hasClass ( 'disabled' ) ) {
5356 modal . destroy ( ) ;
@@ -76,13 +79,15 @@ export default class Util {
7679 visible : false
7780 } ) ;
7881
82+ if ( options . title !== undefined && options . title !== null ) {
83+ $ ( '#search-prompt' ) . append ( '<h4 class="title">' + options . title + '</h4>' ) ;
84+ }
7985 var edit = atom . workspace . buildTextEditor ( { mini : true } ) ;
8086 edit . setPlaceholderText ( '' + options . placeholder ) ;
8187 $ ( '#search-prompt' ) . append ( atom . views . getView ( edit ) ) ;
8288 $ ( '#search-prompt' ) . find ( 'atom-text-editor' ) . attr ( 'id' , 'prompt-search' ) ;
8389
84- var listDOMstring = '<h4 class="title">' + options . title + '</h4>' ;
85- listDOMstring += '<ul class="nav" id="prompt-list">' ;
90+ var listDOMstring = '<ul class="nav" id="prompt-list">' ;
8691 options . listItems . forEach ( function ( currentValue ) {
8792 listDOMstring += '<li class="list-item"><p class="value">' ;
8893 listDOMstring += currentValue ;
@@ -93,7 +98,7 @@ export default class Util {
9398
9499 edit . onDidChange ( function ( ) {
95100 var text = edit . getText ( ) ;
96- $ ( '#prompt-list' ) . find ( '.list-item' ) . remove ( ) ;
101+ $ ( '#prompt-list' ) . find ( '.list-item, .notice ' ) . remove ( ) ;
97102 var filteredItems = options . listItems . filter ( function ( element ) {
98103 element = element . toLowerCase ( ) ;
99104 text = text . toLowerCase ( ) ;
@@ -104,13 +109,17 @@ export default class Util {
104109 }
105110 } ) ;
106111 var listDOMstring = '' ;
107- filteredItems . forEach ( function ( currentValue ) {
108- listDOMstring += '<li class="list-item"><p class="value">' ;
109- listDOMstring += currentValue ;
110- listDOMstring += '</p></li>' ;
111- } ) ;
112+ if ( filteredItems . length > 0 ) {
113+ filteredItems . forEach ( function ( currentValue ) {
114+ listDOMstring += '<li class="list-item"><p class="value">' ;
115+ listDOMstring += currentValue ;
116+ listDOMstring += '</p></li>' ;
117+ } ) ;
118+ } else {
119+ listDOMstring += '<p class="notice"><i>' + options . nothingfound + '</i></p>' ;
120+ }
112121 $ ( '#prompt-list' ) . append ( listDOMstring ) ;
113- } )
122+ } ) ;
114123 $ ( '#search-prompt' ) . find ( '.list-item' ) . on ( 'click' , function ( e ) {
115124 if ( $ ( e . target ) . hasClass ( 'value' ) ) {
116125 var value = $ ( e . target ) . text ( ) ;
0 commit comments