Skip to content

Commit 51c5b81

Browse files
committed
Merge pull request #329 from stim371/fancy_tags
Improve the tag inputs when creating a protip
2 parents 32f6b38 + dffab31 commit 51c5b81

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ source 'https://rubygems.org' do
1010
# Assets
1111
gem 'autoprefixer-rails'
1212
gem 'jquery-rails', '= 2.0.3'
13+
gem 'selectize-rails'
1314

1415
# Load environment variables first
1516
gem 'dotenv-rails', groups: [:development, :test]

Gemfile.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -663,6 +663,7 @@ GEM
663663
addressable (~> 2.3.5)
664664
faraday (~> 0.8, < 0.10)
665665
sax-machine (1.3.1)
666+
selectize-rails (0.12.1)
666667
selenium-webdriver (2.45.0)
667668
childprocess (~> 0.5)
668669
multi_json (~> 1.0)
@@ -878,6 +879,7 @@ DEPENDENCIES
878879
sanitize
879880
sass!
880881
sass-rails!
882+
selectize-rails!
881883
selenium-webdriver
882884
shoulda-matchers
883885
sidekiq!

app/assets/javascripts/protips.js.coffee

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
#= require blur
66
#= require jquery.filedrop
77
#= require jquery.textselection
8-
#= require local_time
8+
#= require local_time
9+
#= require selectize
910

1011
window.handle_redirect = (response)->
1112
window.location = response.to if (response.status == "redirect")
@@ -31,6 +32,16 @@ $ ->
3132
if event.keyCode == 13
3233
search(null)
3334

35+
$('#protip_tags').selectize
36+
delimiter: ','
37+
persist: false
38+
placeholder: "Tags, comma separated"
39+
create: (input) ->
40+
{
41+
value: input,
42+
text: input
43+
}
44+
3445
enablePreviewEditing()
3546

3647

app/views/protips/_new_or_edit.html.haml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
%li.full-list=link_to('How to write a great pro tip', 'https://coderwall.com/p/o42nvq', target: "_blank")
3232

3333
.rule.edit-tags
34-
= p.input :topic_list, placeholder: "Tags, comma separated", label: false, input_html: {class: "tags cf", value: @protip.topic_list.join(","), id: "protip_tags", :autocomplete=>'off'}
34+
= p.input :topic_list, label: false, input_html: {class: "tags cf", value: @protip.topic_list.join(","), id: "protip_tags", :autocomplete=>'off'}
3535

3636
.x-tip-content.preview.back.side.cf#x-protip-preview
3737

0 commit comments

Comments
 (0)