Permalink
Browse files

Merge pull request #14 from elvanja/nicer_modal_search

Nicer modal search
  • Loading branch information...
2 parents 325d613 + 05a5053 commit 0ef24490c6b117bcfcf769caea8aec6f3b27ec57 @levity levity committed Feb 28, 2014
Showing with 25 additions and 5 deletions.
  1. +11 −5 app/assets/stylesheets/deckhand/index.css.scss
  2. +14 −0 app/helpers/deckhand/templates_helper.rb
@@ -62,11 +62,6 @@ a {
}
}
-#search {
- position: fixed;
- width: 100%;
-}
-
[ng-click] {
cursor: pointer;
}
@@ -107,6 +102,17 @@ a {
}
}
+.modal-search {
+ .glyphicon {
+ position: absolute;
+ right: 24px;
+ top: 10px;
+ &.loading {
+ opacity: 0.25;
+ }
+ }
+}
+
#opened-cards .list-group-item {
position: relative;
padding-right: 33px;
@@ -18,8 +18,13 @@ def angular_input(name, options)
args = {'ng-model' => name, 'class' => 'form-control'}
if options[:model]
+ args['type'] = 'text'
args['typeahead'] = "object as object._label for object in search($viewValue, '#{options[:model]}')"
+ args['typeahead-loading'] = "loading_#{parameterize(name)}"
args['typeahead-template-url'] = 'typeahead-search'
+ args['typeahead-on-select'] = 'select()'
+ args['typeahead-wait-ms'] = '300'
+ args['placeholder'] = options[:placeholder] || 'Start typing ...'
elsif options[:type] == :boolean
args['type'] = 'checkbox'
args.delete('class')
@@ -38,6 +43,7 @@ def angular_input(name, options)
# nothing
else
args['type'] = 'text'
+ args['placeholder'] = options[:placeholder] if options[:placeholder]
end # TODO more types & HTML5 validators
if options[:choices]
@@ -52,10 +58,18 @@ def angular_input(name, options)
content_tag :textarea, '', args
elsif options[:type] == Time
content_tag :div, content_tag(:timepicker), args
+ elsif options[:model]
+ content_tag(:span, '', class: 'modal-search') do
+ content_tag(:i, '', class: 'glyphicon glyphicon-search', "ng-class" => "{loading: loading_#{parameterize(name)}}") +
+ content_tag(:input, '', args)
+ end
else
content_tag :input, '', args
end
end
+ def parameterize(string)
+ string.gsub('.', '_')
+ end
end

0 comments on commit 0ef2449

Please sign in to comment.