Skip to content
This repository was archived by the owner on Dec 12, 2021. It is now read-only.

Commit 4443086

Browse files
committed
Merge branch 'dev'
2 parents 4c8e38a + c51e1fd commit 4443086

File tree

3 files changed

+38
-15
lines changed

3 files changed

+38
-15
lines changed

lib/snippet-injector.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ export default {
7171
title: 'Choose a snippet to inject:',
7272
placeholder: 'Search snippets',
7373
listItems: listitems,
74-
btncancel: 'Cancel'
74+
btncancel: 'Cancel',
75+
nothingfound: 'No Snippets found that match you search.'
7576
},function(element) {
7677
var snippet = new Snippet(JSON.parse(storage.retrieveFile(element)));
7778
atom.workspace.getActiveTextEditor().insertText(snippet.getContent(),{

lib/util.js

Lines changed: 19 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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();

styles/snippet-injector.less

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,35 @@
99

1010
#input-prompt {
1111
min-width: 500px;
12-
height: auto;
12+
height: 30px;
1313

1414
#prompt-input {
15-
width: 60%;
15+
width: 62%;
1616
padding-left: 5px;
1717
float: left;
1818
margin-right: 1%;
19+
height: 30px;
1920
}
2021

2122
#prompt-confirm, #prompt-cancel {
2223
width: 18%;
23-
margin-right: 1%;
24+
height: 30px;
25+
font-size: 14px;
2426
}
2527
}
2628

2729
#search-prompt {
2830

31+
.title {
32+
margin-top: 0;
33+
margin-bottom: 10px;
34+
}
35+
2936
#prompt-list {
3037
margin-bottom: 20px;
31-
38+
max-height: 250px;
39+
overflow-y: scroll;
40+
3241
.list-item {
3342
padding: 10px;
3443
font-size: 13px;
@@ -37,6 +46,10 @@
3746
.value {
3847
margin: 0;
3948
}
49+
50+
&:first-of-type {
51+
border-top: 1px solid grey;
52+
}
4053
}
4154
}
4255
}

0 commit comments

Comments
 (0)