aboutsummaryrefslogtreecommitdiffstats
path: root/app/inputs
diff options
context:
space:
mode:
authorLuc Donnet2014-12-02 11:47:49 +0100
committerLuc Donnet2014-12-02 11:47:49 +0100
commit228c5a383eff1c6175a97a8ed446d6777b9310c8 (patch)
tree742766cde2cac2d495d1e7995d64646269eb22d6 /app/inputs
parentc5379f821a7f280f296f0b0dd0180aa57ce6b9c8 (diff)
downloadchouette-core-228c5a383eff1c6175a97a8ed446d6777b9310c8.tar.bz2
Fix autocomplete stop areas in one line Refs #0030224
Diffstat (limited to 'app/inputs')
-rw-r--r--app/inputs/search_stop_area_input.rb41
1 files changed, 27 insertions, 14 deletions
diff --git a/app/inputs/search_stop_area_input.rb b/app/inputs/search_stop_area_input.rb
index 901715dc1..2365947d0 100644
--- a/app/inputs/search_stop_area_input.rb
+++ b/app/inputs/search_stop_area_input.rb
@@ -1,29 +1,42 @@
class SearchStopAreaInput < Formtastic::Inputs::SearchInput
-
+
def search
if options[:json]
tokenLimit = options[:tokenLimit].present? ? options[:tokenLimit] : "null"
template.content_tag( :script,
("$(document).ready(function() {
+
var item_name = function( item){
- var result = item.name;
- console.log( item );
- console.log( item.registration_number );
- if ( item.registration_number !=null && item.registration_number.length > 0) {
- result += ' (' + item.registration_number + ')';
+ var result = item.short_name;
+ if ( item.short_registration_number != '' ) {
+ result += ' <small>[' + item.short_registration_number + ']</small>';
}
return result;
};
- var item_format = function( item ){
- var info = '';
- if ( item.zip_code != null ) {
- info += item.zip_code + ' ';
- }
- if ( item.city_name != null ) {
- info += item.city_name;
+
+ var item_localization = function( item){
+ var localization = item.zip_code + ' ' + item.short_city_name;
+ return localization;
+ };
+
+ var item_format = function( item ){
+ var name = item_name( item );
+ var localization = item_localization( item );
+
+ html_result = '<li>';
+ html_result += '<span><image src=\"' + item.stop_area_path + '\" height=\"25px\" width=\"25px\"></span>'
+ if(name != '')
+ {
+ html_result += '<span style=\"height:25px; line-height:25px; margin-left: 5px; \">' + name + '</span>' ;
+ }
+ if(localization != '')
+ {
+ html_result += '<small style=\"height:25px; line-height:25px; margin-left: 10px; color: #555; \">' + localization + '</small>';
}
- return '<li><div class=\"name\">' + item_name( item) + '</div><div class=\"info\">' + item.area_type + '</div><div class=\"info\">' + info + '</div></li>'
+ html_result += '</li>';
+ return html_result;
};
+
$('##{dom_id}').tokenInput('#{options[:json]}', {
crossDomain: false,
tokenLimit: #{tokenLimit},