smartmachine 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.rdoc +0 -0
- data/README.rdoc +87 -0
- data/bin/buildpacker +8 -0
- data/bin/prereceiver +8 -0
- data/bin/smartmachine +81 -0
- data/bin/smartrunner +28 -0
- data/lib/smart_machine.rb +24 -0
- data/lib/smart_machine/apps.rb +14 -0
- data/lib/smart_machine/apps/app.rb +182 -0
- data/lib/smart_machine/apps/rails.rb +250 -0
- data/lib/smart_machine/base.rb +11 -0
- data/lib/smart_machine/boot.rb +31 -0
- data/lib/smart_machine/buildpacker.rb +106 -0
- data/lib/smart_machine/credentials.rb +126 -0
- data/lib/smart_machine/docker.rb +144 -0
- data/lib/smart_machine/engine.rb +82 -0
- data/lib/smart_machine/engine/Dockerfile +27 -0
- data/lib/smart_machine/engine/buildpacks/rails/Dockerfile +21 -0
- data/lib/smart_machine/gem_version.rb +17 -0
- data/lib/smart_machine/grids.rb +15 -0
- data/lib/smart_machine/grids/elasticsearch.rb +97 -0
- data/lib/smart_machine/grids/elasticsearch/.keep +0 -0
- data/lib/smart_machine/grids/minio.rb +77 -0
- data/lib/smart_machine/grids/minio/.keep +0 -0
- data/lib/smart_machine/grids/mysql.rb +66 -0
- data/lib/smart_machine/grids/mysql/docker-entrypoint-initdb.d/.keep +0 -0
- data/lib/smart_machine/grids/nginx.rb +137 -0
- data/lib/smart_machine/grids/nginx/.keep +0 -0
- data/lib/smart_machine/grids/prereceiver.rb +170 -0
- data/lib/smart_machine/grids/prereceiver/Dockerfile +20 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/APKBUILD +49 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/fcgiwrap.confd +6 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/fcgiwrap.initd +43 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/fcgiwrap.pre-install +7 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/packages/main/x86_64/APKINDEX.tar.gz +0 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/packages/main/x86_64/fcgiwrap-1.1.1-r4.apk +0 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/packages/main/x86_64/fcgiwrap-doc-1.1.1-r4.apk +0 -0
- data/lib/smart_machine/grids/prereceiver/fcgiwrap/packages/main/x86_64/fcgiwrap-openrc-1.1.1-r4.apk +0 -0
- data/lib/smart_machine/grids/redis.rb +58 -0
- data/lib/smart_machine/grids/redis/.keep +0 -0
- data/lib/smart_machine/grids/solr.rb +99 -0
- data/lib/smart_machine/grids/solr/config/.keep +0 -0
- data/lib/smart_machine/grids/solr/config/README.txt +77 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/contractions_ca.txt +8 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/contractions_fr.txt +15 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/contractions_ga.txt +5 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/contractions_it.txt +23 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/hyphenations_ga.txt +5 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stemdict_nl.txt +6 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stoptags_ja.txt +420 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ar.txt +125 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_bg.txt +193 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ca.txt +220 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_cz.txt +172 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_da.txt +110 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_de.txt +294 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_el.txt +78 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_en.txt +54 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_es.txt +356 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_eu.txt +99 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_fa.txt +313 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_fi.txt +97 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_fr.txt +186 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ga.txt +110 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_gl.txt +161 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_hi.txt +235 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_hu.txt +211 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_hy.txt +46 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_id.txt +359 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_it.txt +303 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ja.txt +127 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_lv.txt +172 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_nl.txt +119 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_no.txt +194 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_pt.txt +253 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ro.txt +233 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_ru.txt +243 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_sv.txt +133 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_th.txt +119 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/stopwords_tr.txt +212 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/lang/userdict_ja.txt +29 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/managed-schema +1007 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/params.json +20 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/protwords.txt +21 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/solrconfig.xml +1355 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/stopwords.txt +14 -0
- data/lib/smart_machine/grids/solr/config/configsets/_default/conf/synonyms.txt +29 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/_rest_managed.json +1 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/_schema_analysis_stopwords_english.json +38 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/_schema_analysis_synonyms_english.json +11 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/clustering/carrot2/README.txt +11 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/clustering/carrot2/kmeans-attributes.xml +19 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/clustering/carrot2/lingo-attributes.xml +24 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/clustering/carrot2/stc-attributes.xml +19 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/currency.xml +67 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/elevate.xml +42 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/contractions_ca.txt +8 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/contractions_fr.txt +15 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/contractions_ga.txt +5 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/contractions_it.txt +23 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/hyphenations_ga.txt +5 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stemdict_nl.txt +6 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stoptags_ja.txt +420 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ar.txt +125 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_bg.txt +193 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ca.txt +220 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ckb.txt +136 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_cz.txt +172 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_da.txt +110 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_de.txt +294 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_el.txt +78 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_en.txt +54 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_es.txt +356 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_eu.txt +99 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_fa.txt +313 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_fi.txt +97 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_fr.txt +186 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ga.txt +110 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_gl.txt +161 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_hi.txt +235 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_hu.txt +211 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_hy.txt +46 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_id.txt +359 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_it.txt +303 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ja.txt +127 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_lv.txt +172 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_nl.txt +119 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_no.txt +194 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_pt.txt +253 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ro.txt +233 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_ru.txt +243 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_sv.txt +133 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_th.txt +119 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/stopwords_tr.txt +212 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/lang/userdict_ja.txt +29 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/managed-schema +1187 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/mapping-FoldToASCII.txt +3813 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/params.json +11 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/protwords.txt +21 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/solrconfig.xml +1616 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/spellings.txt +2 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/stopwords.txt +14 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/synonyms.txt +29 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/update-script.js +53 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/README.txt +101 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/VM_global_library.vm +186 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/browse.vm +33 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/cluster.vm +19 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/cluster_results.vm +31 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/debug.vm +28 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/did_you_mean.vm +11 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/error.vm +11 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facet_fields.vm +24 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facet_pivot.vm +12 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facet_queries.vm +12 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facet_ranges.vm +23 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/facets.vm +10 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/footer.vm +43 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/head.vm +37 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/header.vm +7 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/hit.vm +25 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/hit_grouped.vm +43 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/hit_plain.vm +25 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/join_doc.vm +20 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/jquery.autocomplete.css +48 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/jquery.autocomplete.js +763 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/layout.vm +24 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/main.css +231 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/mime_type_lists.vm +68 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/pagination_bottom.vm +22 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/pagination_top.vm +29 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/product_doc.vm +32 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/query.vm +42 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/query_form.vm +64 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/query_group.vm +43 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/query_spatial.vm +75 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/results_list.vm +22 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/richtext_doc.vm +153 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/suggest.vm +8 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/tabs.vm +50 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/example.xsl +132 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/example_atom.xsl +67 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/example_rss.xsl +66 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/luke.xsl +337 -0
- data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/xslt/updateXml.xsl +70 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/_rest_managed.json +1 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/admin-extra.html +31 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/currency.xml +67 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/elevate.xml +36 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/lang/stopwords_en.txt +54 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/mapping-ISOLatin1Accent.txt +246 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/protwords.txt +21 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/schema.xml +278 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/scripts.conf +24 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/solrconfig.xml +632 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/spellings.txt +2 -0
- data/lib/smart_machine/grids/solr/config/configsets/sunspot/conf/synonyms.txt +29 -0
- data/lib/smart_machine/grids/solr/config/lib/.keep +0 -0
- data/lib/smart_machine/grids/solr/config/solr.xml +53 -0
- data/lib/smart_machine/grids/solr/config/zoo.cfg +31 -0
- data/lib/smart_machine/grids/solr/docker-entrypoint-initdb.d/.keep +0 -0
- data/lib/smart_machine/grids/solr/sunspot/conf/schema.xml +278 -0
- data/lib/smart_machine/grids/solr/sunspot/conf/solrconfig.xml +632 -0
- data/lib/smart_machine/logger.rb +35 -0
- data/lib/smart_machine/machine.rb +192 -0
- data/lib/smart_machine/ssh.rb +43 -0
- data/lib/smart_machine/sync.rb +108 -0
- data/lib/smart_machine/templates/dotsmartmachine/apps/containers/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/apps/repositories/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/environment.rb +18 -0
- data/lib/smart_machine/templates/dotsmartmachine/config/users.yml +4 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/elasticsearch/data/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/elasticsearch/logs/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/minio/data/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/mysql/data/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/nginx/certificates/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/nginx/fastcgi.conf +11 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/nginx/htpasswd/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/nginx/nginx.tmpl +373 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/prereceiver/pre-receive +17 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/redis/data/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/grids/solr/solr/.keep +0 -0
- data/lib/smart_machine/templates/dotsmartmachine/tmp/.keep +0 -0
- data/lib/smart_machine/user.rb +38 -0
- data/lib/smart_machine/version.rb +10 -0
- metadata +297 -12
- data/README.md +0 -9
@@ -0,0 +1,31 @@
|
|
1
|
+
#**
|
2
|
+
* Actual rendering of Clusters
|
3
|
+
*#
|
4
|
+
|
5
|
+
## For each cluster
|
6
|
+
#foreach ($clusters in $response.response.clusters)
|
7
|
+
|
8
|
+
#set($labels = $clusters.get('labels'))
|
9
|
+
#set($docs = $clusters.get('docs'))
|
10
|
+
|
11
|
+
## This Cluster's Heading
|
12
|
+
<h3>
|
13
|
+
#foreach ($label in $labels)
|
14
|
+
## Keep the following line together to prevent
|
15
|
+
## a space appearing before each comma
|
16
|
+
$label#if( $foreach.hasNext ),#end
|
17
|
+
#end
|
18
|
+
</h3>
|
19
|
+
|
20
|
+
## This Cluster's Documents
|
21
|
+
<ol>
|
22
|
+
## For each doc in this cluster
|
23
|
+
#foreach ($cluDoc in $docs)
|
24
|
+
<li>
|
25
|
+
<a href="#url_for_home?q=id:$cluDoc">
|
26
|
+
$cluDoc</a>
|
27
|
+
</li>
|
28
|
+
#end
|
29
|
+
</ol>
|
30
|
+
|
31
|
+
#end ## end for each Cluster
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#**
|
2
|
+
* Show Debugging Information, if enabled
|
3
|
+
*#
|
4
|
+
|
5
|
+
#if( $params.getBool("debugQuery",false) )
|
6
|
+
<a href="#" onclick='jQuery(this).siblings("pre").toggle(); return false;'>
|
7
|
+
toggle explain</a>
|
8
|
+
|
9
|
+
<pre style="display:none">
|
10
|
+
$response.getExplainMap().get($doc.getFirstValue('id'))
|
11
|
+
</pre>
|
12
|
+
|
13
|
+
<a href="#" onclick='jQuery(this).siblings("pre2").toggle(); return false;'>
|
14
|
+
toggle all fields</a>
|
15
|
+
|
16
|
+
<pre2 style="display:none">
|
17
|
+
#foreach($fieldname in $doc.fieldNames)
|
18
|
+
<br>
|
19
|
+
<span class="field-name">$fieldname :</span>
|
20
|
+
<span>
|
21
|
+
#foreach($value in $doc.getFieldValues($fieldname))
|
22
|
+
$esc.html($value)
|
23
|
+
#end
|
24
|
+
</span>
|
25
|
+
</br>
|
26
|
+
#end
|
27
|
+
</pre2>
|
28
|
+
#end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
#**
|
2
|
+
* Hyperlinked spelling suggestions in results list
|
3
|
+
*#
|
4
|
+
|
5
|
+
#set($collations = $response.response.spellcheck.collations.getAll("collation"))
|
6
|
+
#if($collations.size() > 0)
|
7
|
+
Did you mean
|
8
|
+
#foreach($collation in $collations)
|
9
|
+
<a href="#{url_for_home}#{lensNoQ}&q=$esc.url($collation.collationQuery)">$esc.html($collation.collationQuery)</a> ($collation.hits)?
|
10
|
+
#end
|
11
|
+
#end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
#**
|
2
|
+
* Display facets based on field values
|
3
|
+
* e.g.: fields specified by &facet.field=
|
4
|
+
*#
|
5
|
+
|
6
|
+
#if($response.facetFields)
|
7
|
+
<h2 #annTitle("Facets generated by adding &facet.field= to the request")>
|
8
|
+
Field Facets
|
9
|
+
</h2>
|
10
|
+
#foreach($field in $response.facetFields)
|
11
|
+
## Hide facets without value
|
12
|
+
#if($field.values.size() > 0)
|
13
|
+
<span class="facet-field">$field.name</span>
|
14
|
+
<ul>
|
15
|
+
#foreach($facet in $field.values)
|
16
|
+
<li>
|
17
|
+
<a href="#url_for_facet_filter($field.name, $facet.name)" title="$esc.html($facet.name)">
|
18
|
+
#if($facet.name!=$null)$esc.html($display.truncate($facet.name,20))#else<em>missing</em>#end</a> ($facet.count)
|
19
|
+
</li>
|
20
|
+
#end
|
21
|
+
</ul>
|
22
|
+
#end ## end if > 0
|
23
|
+
#end ## end for each facet field
|
24
|
+
#end ## end if response has facet fields
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#**
|
2
|
+
* Display Pivot-Based Facets
|
3
|
+
* e.g.: facets specified by &facet.pivot=
|
4
|
+
*#
|
5
|
+
|
6
|
+
<h2 #annTitle("Facets generated by adding &facet.pivot= to the request")>
|
7
|
+
Pivot Facets
|
8
|
+
</h2>
|
9
|
+
|
10
|
+
#set($pivot = $response.response.facet_counts.facet_pivot)
|
11
|
+
|
12
|
+
#display_facet_pivot($pivot, "")
|
@@ -0,0 +1,12 @@
|
|
1
|
+
#**
|
2
|
+
* Display facets based on specific facet queries
|
3
|
+
* e.g.: facets specified by &facet.query=
|
4
|
+
*#
|
5
|
+
|
6
|
+
#set($field = $response.response.facet_counts.facet_queries)
|
7
|
+
|
8
|
+
<h2 #annTitle("Facets generated by adding &facet.query= to the request")>
|
9
|
+
Query Facets
|
10
|
+
</h2>
|
11
|
+
|
12
|
+
#display_facet_query($field, "", "")
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#**
|
2
|
+
* Display facets based on ranges of values, AKA "Bukets"
|
3
|
+
* e.g.: ranges specified by &facet.range=
|
4
|
+
*#
|
5
|
+
|
6
|
+
<h2 #annTitle("Facets generated by adding &facet.range= to the request")>
|
7
|
+
Range Facets
|
8
|
+
</h2>
|
9
|
+
|
10
|
+
#foreach ($field in $response.response.facet_counts.facet_ranges)
|
11
|
+
## Hide facets without value
|
12
|
+
#if($field.value.counts.size() > 0)
|
13
|
+
#set($name = $field.key)
|
14
|
+
#set($display = $name)
|
15
|
+
#set($f = $field.value.counts)
|
16
|
+
#set($start = $field.value.start)
|
17
|
+
#set($end = $field.value.end)
|
18
|
+
#set($gap = $field.value.gap)
|
19
|
+
#set($before = $field.value.before)
|
20
|
+
#set($after = $field.value.after)
|
21
|
+
#display_facet_range($f, $display, $name, $start, $end, $gap, $before, $after)
|
22
|
+
#end ## end if has any values
|
23
|
+
#end ## end for each facet range
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#**
|
2
|
+
* Render the bottom section of the page visible to users
|
3
|
+
*#
|
4
|
+
|
5
|
+
<hr/>
|
6
|
+
<div>
|
7
|
+
<span>Options:</span>
|
8
|
+
|
9
|
+
#if($request.params.get('debugQuery'))
|
10
|
+
<a href="#url_for_home?#q#if($list.size($request.params.getParams('fq')) > 0)&#fqs($request.params.getParams('fq'))#end">
|
11
|
+
disable debug</a>
|
12
|
+
#else
|
13
|
+
<a href="#url_for_lens&debugQuery=true&fl=*,score">
|
14
|
+
enable debug</a>
|
15
|
+
#end
|
16
|
+
-
|
17
|
+
#if($annotate)
|
18
|
+
<a href="#url_for_home?#q#if($list.size($request.params.getParams('fq')) > 0)&#fqs($request.params.getParams('fq'))#end#boostPrice">
|
19
|
+
disable annotation</a>
|
20
|
+
#else
|
21
|
+
<a href="#url_for_lens&annotateBrowse=true">
|
22
|
+
enable annotation</a>
|
23
|
+
#end
|
24
|
+
-
|
25
|
+
<a #annTitle("Click to switch to an XML response: &wt=xml") href="#url_for_lens&wt=xml#if($request.params.get('debugQuery'))&debugQuery=true#end">
|
26
|
+
XML results</a>
|
27
|
+
|
28
|
+
</div>
|
29
|
+
|
30
|
+
<div>
|
31
|
+
Generated by <a href="http://wiki.apache.org/solr/VelocityResponseWriter">VelocityResponseWriter</a>
|
32
|
+
</div>
|
33
|
+
<div>
|
34
|
+
<span>Documentation: </span>
|
35
|
+
<a href="http://lucene.apache.org/solr">Solr Home Page</a>, <a href="http://wiki.apache.org/solr">
|
36
|
+
Solr Wiki</a>
|
37
|
+
</div>
|
38
|
+
<div>
|
39
|
+
Disclaimer:
|
40
|
+
The locations displayed in this demonstration are purely fictional.
|
41
|
+
It is more than likely that no store with the items listed actually
|
42
|
+
exists at that location!
|
43
|
+
</div>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
#**
|
2
|
+
* Provide elements for the <head> section of the HTML document
|
3
|
+
*#
|
4
|
+
|
5
|
+
## An example of using an arbitrary request parameter
|
6
|
+
<title>#param('title')</title>
|
7
|
+
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
8
|
+
|
9
|
+
<script type="text/javascript" src="#{url_root}/libs/jquery-1.7.2.min.js"></script>
|
10
|
+
<link rel="stylesheet" type="text/css" href="#{url_for_solr}/admin/file?file=/velocity/main.css&contentType=text/css"/>
|
11
|
+
<link rel="stylesheet" href="#{url_for_solr}/admin/file?file=/velocity/jquery.autocomplete.css&contentType=text/css" type="text/css" />
|
12
|
+
<link rel="icon" type="image/x-icon" href="#{url_root}/img/favicon.ico"/>
|
13
|
+
<link rel="shortcut icon" type="image/x-icon" href="#{url_root}/img/favicon.ico"/>
|
14
|
+
<script type="text/javascript" src="#{url_for_solr}/admin/file?file=/velocity/jquery.autocomplete.js&contentType=text/javascript"></script>
|
15
|
+
|
16
|
+
|
17
|
+
<script>
|
18
|
+
$(document).ready(function(){
|
19
|
+
$("\#q").autocomplete('#{url_for_solr}/terms', { ## backslash escaped #q as that is a macro defined in VM_global_library.vm
|
20
|
+
extraParams:{
|
21
|
+
'terms.prefix': function() { return $("\#q").val();},
|
22
|
+
'terms.sort': 'count',
|
23
|
+
'terms.fl': 'name',
|
24
|
+
'wt': 'velocity',
|
25
|
+
'v.template': 'suggest'
|
26
|
+
}
|
27
|
+
}
|
28
|
+
).keydown(function(e){
|
29
|
+
if (e.keyCode === 13){
|
30
|
+
$("#query-form").trigger('submit');
|
31
|
+
}
|
32
|
+
});
|
33
|
+
|
34
|
+
// http://localhost:8983/solr/collection1/terms?terms.fl=name&terms.prefix=i&terms.sort=count&wt=velocity&v.template=suggest
|
35
|
+
});
|
36
|
+
|
37
|
+
</script>
|
data/lib/smart_machine/grids/solr/config/configsets/sample_techproducts_configs/conf/velocity/hit.vm
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#**
|
2
|
+
* Called for each matching document but then
|
3
|
+
* calls one of product_doc, join_doc or richtext_doc
|
4
|
+
* depending on which fields the doc has
|
5
|
+
*#
|
6
|
+
|
7
|
+
#set($docId = $doc.getFieldValue('id'))
|
8
|
+
|
9
|
+
<div class="result-document">
|
10
|
+
|
11
|
+
## Has a "name" field ?
|
12
|
+
#if($doc.getFieldValue('name'))
|
13
|
+
#parse("product_doc.vm")
|
14
|
+
|
15
|
+
## Has a "compName_s" field ?
|
16
|
+
#elseif($doc.getFieldValue('compName_s'))
|
17
|
+
#parse("join_doc.vm")
|
18
|
+
|
19
|
+
## Fallback to richtext_doc
|
20
|
+
#else
|
21
|
+
#parse("richtext_doc.vm")
|
22
|
+
|
23
|
+
#end
|
24
|
+
|
25
|
+
</div>
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#**
|
2
|
+
* Display grouped results
|
3
|
+
*#
|
4
|
+
|
5
|
+
<div class="result-document">
|
6
|
+
|
7
|
+
<div class="result-title">
|
8
|
+
<b>$grouping.key</b>
|
9
|
+
</div>
|
10
|
+
|
11
|
+
<div>
|
12
|
+
Total Matches in Group: $grouping.value.matches
|
13
|
+
</div>
|
14
|
+
|
15
|
+
<div> ## list of groups
|
16
|
+
|
17
|
+
#foreach ($group in $grouping.value.groups)
|
18
|
+
<div class="group-value">
|
19
|
+
#if($group.groupValue)$group.groupValue#{else}<i>No group</i>#end
|
20
|
+
<span #annTitle("The count of the number of documents in this group")>
|
21
|
+
($group.doclist.numFound)
|
22
|
+
</span>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<div class="group-doclist"
|
26
|
+
#annTitle("Contains the top scoring documents in the group")
|
27
|
+
>
|
28
|
+
#foreach ($doc in $group.doclist)
|
29
|
+
#set($docId = $doc.getFieldValue('id'))
|
30
|
+
#if($doc.getFieldValue('name'))
|
31
|
+
#parse("product_doc.vm")
|
32
|
+
#elseif($doc.getFieldValue('compName_s'))
|
33
|
+
#parse("join_doc.vm")
|
34
|
+
#else
|
35
|
+
#parse("richtext_doc.vm")
|
36
|
+
#end
|
37
|
+
#end
|
38
|
+
</div>
|
39
|
+
|
40
|
+
#end ## end of foreach group in grouping.value.groups
|
41
|
+
</div> ## div tag for entire list of groups
|
42
|
+
|
43
|
+
</div> ## end of div class=result-document
|
@@ -0,0 +1,25 @@
|
|
1
|
+
#**
|
2
|
+
* An extremely plain / debug version of hit.vm
|
3
|
+
*#
|
4
|
+
|
5
|
+
<table>
|
6
|
+
## For each field
|
7
|
+
#foreach( $fieldName in $doc.fieldNames )
|
8
|
+
## For each value
|
9
|
+
#foreach( $value in $doc.getFieldValues($fieldName) )
|
10
|
+
<tr>
|
11
|
+
## Field Name
|
12
|
+
<th align="right" valign="top">
|
13
|
+
#if( $foreach.count == 1 )
|
14
|
+
$fieldName:
|
15
|
+
#end
|
16
|
+
</th>
|
17
|
+
## Field Value(s)
|
18
|
+
<td align="left" valign="top">
|
19
|
+
$esc.html($value) <br/>
|
20
|
+
</td>
|
21
|
+
</tr>
|
22
|
+
#end ## end for each value
|
23
|
+
#end ## end for each field
|
24
|
+
</table>
|
25
|
+
<hr/>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#**
|
2
|
+
* Display documents that are joined to other documents
|
3
|
+
*#
|
4
|
+
|
5
|
+
<div class="result-title">
|
6
|
+
<b>#field('compName_s')</b>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<div>
|
10
|
+
Id: #field('id')
|
11
|
+
(company-details document for
|
12
|
+
<a href="http://wiki.apache.org/solr/Join" target="_new">join</a>
|
13
|
+
)
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<div>
|
17
|
+
Address: #field('address_s')
|
18
|
+
</div>
|
19
|
+
|
20
|
+
#parse('debug.vm')
|
@@ -0,0 +1,48 @@
|
|
1
|
+
.ac_results {
|
2
|
+
padding: 0px;
|
3
|
+
border: 1px solid black;
|
4
|
+
background-color: white;
|
5
|
+
overflow: hidden;
|
6
|
+
z-index: 99999;
|
7
|
+
}
|
8
|
+
|
9
|
+
.ac_results ul {
|
10
|
+
width: 100%;
|
11
|
+
list-style-position: outside;
|
12
|
+
list-style: none;
|
13
|
+
padding: 0;
|
14
|
+
margin: 0;
|
15
|
+
}
|
16
|
+
|
17
|
+
.ac_results li {
|
18
|
+
margin: 0px;
|
19
|
+
padding: 2px 5px;
|
20
|
+
cursor: default;
|
21
|
+
display: block;
|
22
|
+
/*
|
23
|
+
if width will be 100% horizontal scrollbar will apear
|
24
|
+
when scroll mode will be used
|
25
|
+
*/
|
26
|
+
/*width: 100%;*/
|
27
|
+
font: menu;
|
28
|
+
font-size: 12px;
|
29
|
+
/*
|
30
|
+
it is very important, if line-height not setted or setted
|
31
|
+
in relative units scroll will be broken in firefox
|
32
|
+
*/
|
33
|
+
line-height: 16px;
|
34
|
+
overflow: hidden;
|
35
|
+
}
|
36
|
+
|
37
|
+
.ac_loading {
|
38
|
+
background: white url('indicator.gif') right center no-repeat;
|
39
|
+
}
|
40
|
+
|
41
|
+
.ac_odd {
|
42
|
+
background-color: #eee;
|
43
|
+
}
|
44
|
+
|
45
|
+
.ac_over {
|
46
|
+
background-color: #0A246A;
|
47
|
+
color: white;
|
48
|
+
}
|
@@ -0,0 +1,763 @@
|
|
1
|
+
/*
|
2
|
+
* Autocomplete - jQuery plugin 1.1pre
|
3
|
+
*
|
4
|
+
* Copyright (c) 2007 Dylan Verheul, Dan G. Switzer, Anjesh Tuladhar, Jörn Zaefferer
|
5
|
+
*
|
6
|
+
* Dual licensed under the MIT and GPL licenses:
|
7
|
+
* http://www.opensource.org/licenses/mit-license.php
|
8
|
+
* http://www.gnu.org/licenses/gpl.html
|
9
|
+
*
|
10
|
+
* Revision: Id: jquery.autocomplete.js 5785 2008-07-12 10:37:33Z joern.zaefferer $
|
11
|
+
*
|
12
|
+
*/
|
13
|
+
|
14
|
+
;(function($) {
|
15
|
+
|
16
|
+
$.fn.extend({
|
17
|
+
autocomplete: function(urlOrData, options) {
|
18
|
+
var isUrl = typeof urlOrData == "string";
|
19
|
+
options = $.extend({}, $.Autocompleter.defaults, {
|
20
|
+
url: isUrl ? urlOrData : null,
|
21
|
+
data: isUrl ? null : urlOrData,
|
22
|
+
delay: isUrl ? $.Autocompleter.defaults.delay : 10,
|
23
|
+
max: options && !options.scroll ? 10 : 150
|
24
|
+
}, options);
|
25
|
+
|
26
|
+
// if highlight is set to false, replace it with a do-nothing function
|
27
|
+
options.highlight = options.highlight || function(value) { return value; };
|
28
|
+
|
29
|
+
// if the formatMatch option is not specified, then use formatItem for backwards compatibility
|
30
|
+
options.formatMatch = options.formatMatch || options.formatItem;
|
31
|
+
|
32
|
+
return this.each(function() {
|
33
|
+
new $.Autocompleter(this, options);
|
34
|
+
});
|
35
|
+
},
|
36
|
+
result: function(handler) {
|
37
|
+
return this.bind("result", handler);
|
38
|
+
},
|
39
|
+
search: function(handler) {
|
40
|
+
return this.trigger("search", [handler]);
|
41
|
+
},
|
42
|
+
flushCache: function() {
|
43
|
+
return this.trigger("flushCache");
|
44
|
+
},
|
45
|
+
setOptions: function(options){
|
46
|
+
return this.trigger("setOptions", [options]);
|
47
|
+
},
|
48
|
+
unautocomplete: function() {
|
49
|
+
return this.trigger("unautocomplete");
|
50
|
+
}
|
51
|
+
});
|
52
|
+
|
53
|
+
$.Autocompleter = function(input, options) {
|
54
|
+
|
55
|
+
var KEY = {
|
56
|
+
UP: 38,
|
57
|
+
DOWN: 40,
|
58
|
+
DEL: 46,
|
59
|
+
TAB: 9,
|
60
|
+
RETURN: 13,
|
61
|
+
ESC: 27,
|
62
|
+
COMMA: 188,
|
63
|
+
PAGEUP: 33,
|
64
|
+
PAGEDOWN: 34,
|
65
|
+
BACKSPACE: 8
|
66
|
+
};
|
67
|
+
|
68
|
+
// Create $ object for input element
|
69
|
+
var $input = $(input).attr("autocomplete", "off").addClass(options.inputClass);
|
70
|
+
|
71
|
+
var timeout;
|
72
|
+
var previousValue = "";
|
73
|
+
var cache = $.Autocompleter.Cache(options);
|
74
|
+
var hasFocus = 0;
|
75
|
+
var lastKeyPressCode;
|
76
|
+
var config = {
|
77
|
+
mouseDownOnSelect: false
|
78
|
+
};
|
79
|
+
var select = $.Autocompleter.Select(options, input, selectCurrent, config);
|
80
|
+
|
81
|
+
var blockSubmit;
|
82
|
+
|
83
|
+
// prevent form submit in opera when selecting with return key
|
84
|
+
$.browser.opera && $(input.form).bind("submit.autocomplete", function() {
|
85
|
+
if (blockSubmit) {
|
86
|
+
blockSubmit = false;
|
87
|
+
return false;
|
88
|
+
}
|
89
|
+
});
|
90
|
+
|
91
|
+
// only opera doesn't trigger keydown multiple times while pressed, others don't work with keypress at all
|
92
|
+
$input.bind(($.browser.opera ? "keypress" : "keydown") + ".autocomplete", function(event) {
|
93
|
+
// track last key pressed
|
94
|
+
lastKeyPressCode = event.keyCode;
|
95
|
+
switch(event.keyCode) {
|
96
|
+
|
97
|
+
case KEY.UP:
|
98
|
+
event.preventDefault();
|
99
|
+
if ( select.visible() ) {
|
100
|
+
select.prev();
|
101
|
+
} else {
|
102
|
+
onChange(0, true);
|
103
|
+
}
|
104
|
+
break;
|
105
|
+
|
106
|
+
case KEY.DOWN:
|
107
|
+
event.preventDefault();
|
108
|
+
if ( select.visible() ) {
|
109
|
+
select.next();
|
110
|
+
} else {
|
111
|
+
onChange(0, true);
|
112
|
+
}
|
113
|
+
break;
|
114
|
+
|
115
|
+
case KEY.PAGEUP:
|
116
|
+
event.preventDefault();
|
117
|
+
if ( select.visible() ) {
|
118
|
+
select.pageUp();
|
119
|
+
} else {
|
120
|
+
onChange(0, true);
|
121
|
+
}
|
122
|
+
break;
|
123
|
+
|
124
|
+
case KEY.PAGEDOWN:
|
125
|
+
event.preventDefault();
|
126
|
+
if ( select.visible() ) {
|
127
|
+
select.pageDown();
|
128
|
+
} else {
|
129
|
+
onChange(0, true);
|
130
|
+
}
|
131
|
+
break;
|
132
|
+
|
133
|
+
// matches also semicolon
|
134
|
+
case options.multiple && $.trim(options.multipleSeparator) == "," && KEY.COMMA:
|
135
|
+
case KEY.TAB:
|
136
|
+
case KEY.RETURN:
|
137
|
+
if( selectCurrent() ) {
|
138
|
+
// stop default to prevent a form submit, Opera needs special handling
|
139
|
+
event.preventDefault();
|
140
|
+
blockSubmit = true;
|
141
|
+
return false;
|
142
|
+
}
|
143
|
+
break;
|
144
|
+
|
145
|
+
case KEY.ESC:
|
146
|
+
select.hide();
|
147
|
+
break;
|
148
|
+
|
149
|
+
default:
|
150
|
+
clearTimeout(timeout);
|
151
|
+
timeout = setTimeout(onChange, options.delay);
|
152
|
+
break;
|
153
|
+
}
|
154
|
+
}).focus(function(){
|
155
|
+
// track whether the field has focus, we shouldn't process any
|
156
|
+
// results if the field no longer has focus
|
157
|
+
hasFocus++;
|
158
|
+
}).blur(function() {
|
159
|
+
hasFocus = 0;
|
160
|
+
if (!config.mouseDownOnSelect) {
|
161
|
+
hideResults();
|
162
|
+
}
|
163
|
+
}).click(function() {
|
164
|
+
// show select when clicking in a focused field
|
165
|
+
if ( hasFocus++ > 1 && !select.visible() ) {
|
166
|
+
onChange(0, true);
|
167
|
+
}
|
168
|
+
}).bind("search", function() {
|
169
|
+
// TODO why not just specifying both arguments?
|
170
|
+
var fn = (arguments.length > 1) ? arguments[1] : null;
|
171
|
+
function findValueCallback(q, data) {
|
172
|
+
var result;
|
173
|
+
if( data && data.length ) {
|
174
|
+
for (var i=0; i < data.length; i++) {
|
175
|
+
if( data[i].result.toLowerCase() == q.toLowerCase() ) {
|
176
|
+
result = data[i];
|
177
|
+
break;
|
178
|
+
}
|
179
|
+
}
|
180
|
+
}
|
181
|
+
if( typeof fn == "function" ) fn(result);
|
182
|
+
else $input.trigger("result", result && [result.data, result.value]);
|
183
|
+
}
|
184
|
+
$.each(trimWords($input.val()), function(i, value) {
|
185
|
+
request(value, findValueCallback, findValueCallback);
|
186
|
+
});
|
187
|
+
}).bind("flushCache", function() {
|
188
|
+
cache.flush();
|
189
|
+
}).bind("setOptions", function() {
|
190
|
+
$.extend(options, arguments[1]);
|
191
|
+
// if we've updated the data, repopulate
|
192
|
+
if ( "data" in arguments[1] )
|
193
|
+
cache.populate();
|
194
|
+
}).bind("unautocomplete", function() {
|
195
|
+
select.unbind();
|
196
|
+
$input.unbind();
|
197
|
+
$(input.form).unbind(".autocomplete");
|
198
|
+
});
|
199
|
+
|
200
|
+
|
201
|
+
function selectCurrent() {
|
202
|
+
var selected = select.selected();
|
203
|
+
if( !selected )
|
204
|
+
return false;
|
205
|
+
|
206
|
+
var v = selected.result;
|
207
|
+
previousValue = v;
|
208
|
+
|
209
|
+
if ( options.multiple ) {
|
210
|
+
var words = trimWords($input.val());
|
211
|
+
if ( words.length > 1 ) {
|
212
|
+
v = words.slice(0, words.length - 1).join( options.multipleSeparator ) + options.multipleSeparator + v;
|
213
|
+
}
|
214
|
+
v += options.multipleSeparator;
|
215
|
+
}
|
216
|
+
|
217
|
+
$input.val(v);
|
218
|
+
hideResultsNow();
|
219
|
+
$input.trigger("result", [selected.data, selected.value]);
|
220
|
+
return true;
|
221
|
+
}
|
222
|
+
|
223
|
+
function onChange(crap, skipPrevCheck) {
|
224
|
+
if( lastKeyPressCode == KEY.DEL ) {
|
225
|
+
select.hide();
|
226
|
+
return;
|
227
|
+
}
|
228
|
+
|
229
|
+
var currentValue = $input.val();
|
230
|
+
|
231
|
+
if ( !skipPrevCheck && currentValue == previousValue )
|
232
|
+
return;
|
233
|
+
|
234
|
+
previousValue = currentValue;
|
235
|
+
|
236
|
+
currentValue = lastWord(currentValue);
|
237
|
+
if ( currentValue.length >= options.minChars) {
|
238
|
+
$input.addClass(options.loadingClass);
|
239
|
+
if (!options.matchCase)
|
240
|
+
currentValue = currentValue.toLowerCase();
|
241
|
+
request(currentValue, receiveData, hideResultsNow);
|
242
|
+
} else {
|
243
|
+
stopLoading();
|
244
|
+
select.hide();
|
245
|
+
}
|
246
|
+
};
|
247
|
+
|
248
|
+
function trimWords(value) {
|
249
|
+
if ( !value ) {
|
250
|
+
return [""];
|
251
|
+
}
|
252
|
+
var words = value.split( options.multipleSeparator );
|
253
|
+
var result = [];
|
254
|
+
$.each(words, function(i, value) {
|
255
|
+
if ( $.trim(value) )
|
256
|
+
result[i] = $.trim(value);
|
257
|
+
});
|
258
|
+
return result;
|
259
|
+
}
|
260
|
+
|
261
|
+
function lastWord(value) {
|
262
|
+
if ( !options.multiple )
|
263
|
+
return value;
|
264
|
+
var words = trimWords(value);
|
265
|
+
return words[words.length - 1];
|
266
|
+
}
|
267
|
+
|
268
|
+
// fills in the input box w/the first match (assumed to be the best match)
|
269
|
+
// q: the term entered
|
270
|
+
// sValue: the first matching result
|
271
|
+
function autoFill(q, sValue){
|
272
|
+
// autofill in the complete box w/the first match as long as the user hasn't entered in more data
|
273
|
+
// if the last user key pressed was backspace, don't autofill
|
274
|
+
if( options.autoFill && (lastWord($input.val()).toLowerCase() == q.toLowerCase()) && lastKeyPressCode != KEY.BACKSPACE ) {
|
275
|
+
// fill in the value (keep the case the user has typed)
|
276
|
+
$input.val($input.val() + sValue.substring(lastWord(previousValue).length));
|
277
|
+
// select the portion of the value not typed by the user (so the next character will erase)
|
278
|
+
$.Autocompleter.Selection(input, previousValue.length, previousValue.length + sValue.length);
|
279
|
+
}
|
280
|
+
};
|
281
|
+
|
282
|
+
function hideResults() {
|
283
|
+
clearTimeout(timeout);
|
284
|
+
timeout = setTimeout(hideResultsNow, 200);
|
285
|
+
};
|
286
|
+
|
287
|
+
function hideResultsNow() {
|
288
|
+
var wasVisible = select.visible();
|
289
|
+
select.hide();
|
290
|
+
clearTimeout(timeout);
|
291
|
+
stopLoading();
|
292
|
+
if (options.mustMatch) {
|
293
|
+
// call search and run callback
|
294
|
+
$input.search(
|
295
|
+
function (result){
|
296
|
+
// if no value found, clear the input box
|
297
|
+
if( !result ) {
|
298
|
+
if (options.multiple) {
|
299
|
+
var words = trimWords($input.val()).slice(0, -1);
|
300
|
+
$input.val( words.join(options.multipleSeparator) + (words.length ? options.multipleSeparator : "") );
|
301
|
+
}
|
302
|
+
else
|
303
|
+
$input.val( "" );
|
304
|
+
}
|
305
|
+
}
|
306
|
+
);
|
307
|
+
}
|
308
|
+
if (wasVisible)
|
309
|
+
// position cursor at end of input field
|
310
|
+
$.Autocompleter.Selection(input, input.value.length, input.value.length);
|
311
|
+
};
|
312
|
+
|
313
|
+
function receiveData(q, data) {
|
314
|
+
if ( data && data.length && hasFocus ) {
|
315
|
+
stopLoading();
|
316
|
+
select.display(data, q);
|
317
|
+
autoFill(q, data[0].value);
|
318
|
+
select.show();
|
319
|
+
} else {
|
320
|
+
hideResultsNow();
|
321
|
+
}
|
322
|
+
};
|
323
|
+
|
324
|
+
function request(term, success, failure) {
|
325
|
+
if (!options.matchCase)
|
326
|
+
term = term.toLowerCase();
|
327
|
+
var data = cache.load(term);
|
328
|
+
data = null; // Avoid buggy cache and go to Solr every time
|
329
|
+
// recieve the cached data
|
330
|
+
if (data && data.length) {
|
331
|
+
success(term, data);
|
332
|
+
// if an AJAX url has been supplied, try loading the data now
|
333
|
+
} else if( (typeof options.url == "string") && (options.url.length > 0) ){
|
334
|
+
|
335
|
+
var extraParams = {
|
336
|
+
timestamp: +new Date()
|
337
|
+
};
|
338
|
+
$.each(options.extraParams, function(key, param) {
|
339
|
+
extraParams[key] = typeof param == "function" ? param() : param;
|
340
|
+
});
|
341
|
+
|
342
|
+
$.ajax({
|
343
|
+
// try to leverage ajaxQueue plugin to abort previous requests
|
344
|
+
mode: "abort",
|
345
|
+
// limit abortion to this input
|
346
|
+
port: "autocomplete" + input.name,
|
347
|
+
dataType: options.dataType,
|
348
|
+
url: options.url,
|
349
|
+
data: $.extend({
|
350
|
+
q: lastWord(term),
|
351
|
+
limit: options.max
|
352
|
+
}, extraParams),
|
353
|
+
success: function(data) {
|
354
|
+
var parsed = options.parse && options.parse(data) || parse(data);
|
355
|
+
cache.add(term, parsed);
|
356
|
+
success(term, parsed);
|
357
|
+
}
|
358
|
+
});
|
359
|
+
} else {
|
360
|
+
// if we have a failure, we need to empty the list -- this prevents the the [TAB] key from selecting the last successful match
|
361
|
+
select.emptyList();
|
362
|
+
failure(term);
|
363
|
+
}
|
364
|
+
};
|
365
|
+
|
366
|
+
function parse(data) {
|
367
|
+
var parsed = [];
|
368
|
+
var rows = data.split("\n");
|
369
|
+
for (var i=0; i < rows.length; i++) {
|
370
|
+
var row = $.trim(rows[i]);
|
371
|
+
if (row) {
|
372
|
+
row = row.split("|");
|
373
|
+
parsed[parsed.length] = {
|
374
|
+
data: row,
|
375
|
+
value: row[0],
|
376
|
+
result: options.formatResult && options.formatResult(row, row[0]) || row[0]
|
377
|
+
};
|
378
|
+
}
|
379
|
+
}
|
380
|
+
return parsed;
|
381
|
+
};
|
382
|
+
|
383
|
+
function stopLoading() {
|
384
|
+
$input.removeClass(options.loadingClass);
|
385
|
+
};
|
386
|
+
|
387
|
+
};
|
388
|
+
|
389
|
+
$.Autocompleter.defaults = {
|
390
|
+
inputClass: "ac_input",
|
391
|
+
resultsClass: "ac_results",
|
392
|
+
loadingClass: "ac_loading",
|
393
|
+
minChars: 1,
|
394
|
+
delay: 400,
|
395
|
+
matchCase: false,
|
396
|
+
matchSubset: true,
|
397
|
+
matchContains: false,
|
398
|
+
cacheLength: 10,
|
399
|
+
max: 100,
|
400
|
+
mustMatch: false,
|
401
|
+
extraParams: {},
|
402
|
+
selectFirst: false,
|
403
|
+
formatItem: function(row) { return row[0]; },
|
404
|
+
formatMatch: null,
|
405
|
+
autoFill: false,
|
406
|
+
width: 0,
|
407
|
+
multiple: false,
|
408
|
+
multipleSeparator: ", ",
|
409
|
+
highlight: function(value, term) {
|
410
|
+
return value.replace(new RegExp("(?![^&;]+;)(?!<[^<>]*)(" + term.replace(/([\^\$\(\)\[\]\{\}\*\.\+\?\|\\])/gi, "\\$1") + ")(?![^<>]*>)(?![^&;]+;)", "gi"), "<strong>$1</strong>");
|
411
|
+
},
|
412
|
+
scroll: true,
|
413
|
+
scrollHeight: 180
|
414
|
+
};
|
415
|
+
|
416
|
+
$.Autocompleter.Cache = function(options) {
|
417
|
+
|
418
|
+
var data = {};
|
419
|
+
var length = 0;
|
420
|
+
|
421
|
+
function matchSubset(s, sub) {
|
422
|
+
if (!options.matchCase)
|
423
|
+
s = s.toLowerCase();
|
424
|
+
var i = s.indexOf(sub);
|
425
|
+
if (options.matchContains == "word"){
|
426
|
+
i = s.toLowerCase().search("\\b" + sub.toLowerCase());
|
427
|
+
}
|
428
|
+
if (i == -1) return false;
|
429
|
+
return i == 0 || options.matchContains;
|
430
|
+
};
|
431
|
+
|
432
|
+
function add(q, value) {
|
433
|
+
if (length > options.cacheLength){
|
434
|
+
flush();
|
435
|
+
}
|
436
|
+
if (!data[q]){
|
437
|
+
length++;
|
438
|
+
}
|
439
|
+
data[q] = value;
|
440
|
+
}
|
441
|
+
|
442
|
+
function populate(){
|
443
|
+
if( !options.data ) return false;
|
444
|
+
// track the matches
|
445
|
+
var stMatchSets = {},
|
446
|
+
nullData = 0;
|
447
|
+
|
448
|
+
// no url was specified, we need to adjust the cache length to make sure it fits the local data store
|
449
|
+
if( !options.url ) options.cacheLength = 1;
|
450
|
+
|
451
|
+
// track all options for minChars = 0
|
452
|
+
stMatchSets[""] = [];
|
453
|
+
|
454
|
+
// loop through the array and create a lookup structure
|
455
|
+
for ( var i = 0, ol = options.data.length; i < ol; i++ ) {
|
456
|
+
var rawValue = options.data[i];
|
457
|
+
// if rawValue is a string, make an array otherwise just reference the array
|
458
|
+
rawValue = (typeof rawValue == "string") ? [rawValue] : rawValue;
|
459
|
+
|
460
|
+
var value = options.formatMatch(rawValue, i+1, options.data.length);
|
461
|
+
if ( value === false )
|
462
|
+
continue;
|
463
|
+
|
464
|
+
var firstChar = value.charAt(0).toLowerCase();
|
465
|
+
// if no lookup array for this character exists, look it up now
|
466
|
+
if( !stMatchSets[firstChar] )
|
467
|
+
stMatchSets[firstChar] = [];
|
468
|
+
|
469
|
+
// if the match is a string
|
470
|
+
var row = {
|
471
|
+
value: value,
|
472
|
+
data: rawValue,
|
473
|
+
result: options.formatResult && options.formatResult(rawValue) || value
|
474
|
+
};
|
475
|
+
|
476
|
+
// push the current match into the set list
|
477
|
+
stMatchSets[firstChar].push(row);
|
478
|
+
|
479
|
+
// keep track of minChars zero items
|
480
|
+
if ( nullData++ < options.max ) {
|
481
|
+
stMatchSets[""].push(row);
|
482
|
+
}
|
483
|
+
};
|
484
|
+
|
485
|
+
// add the data items to the cache
|
486
|
+
$.each(stMatchSets, function(i, value) {
|
487
|
+
// increase the cache size
|
488
|
+
options.cacheLength++;
|
489
|
+
// add to the cache
|
490
|
+
add(i, value);
|
491
|
+
});
|
492
|
+
}
|
493
|
+
|
494
|
+
// populate any existing data
|
495
|
+
setTimeout(populate, 25);
|
496
|
+
|
497
|
+
function flush(){
|
498
|
+
data = {};
|
499
|
+
length = 0;
|
500
|
+
}
|
501
|
+
|
502
|
+
return {
|
503
|
+
flush: flush,
|
504
|
+
add: add,
|
505
|
+
populate: populate,
|
506
|
+
load: function(q) {
|
507
|
+
if (!options.cacheLength || !length)
|
508
|
+
return null;
|
509
|
+
/*
|
510
|
+
* if dealing w/local data and matchContains than we must make sure
|
511
|
+
* to loop through all the data collections looking for matches
|
512
|
+
*/
|
513
|
+
if( !options.url && options.matchContains ){
|
514
|
+
// track all matches
|
515
|
+
var csub = [];
|
516
|
+
// loop through all the data grids for matches
|
517
|
+
for( var k in data ){
|
518
|
+
// don't search through the stMatchSets[""] (minChars: 0) cache
|
519
|
+
// this prevents duplicates
|
520
|
+
if( k.length > 0 ){
|
521
|
+
var c = data[k];
|
522
|
+
$.each(c, function(i, x) {
|
523
|
+
// if we've got a match, add it to the array
|
524
|
+
if (matchSubset(x.value, q)) {
|
525
|
+
csub.push(x);
|
526
|
+
}
|
527
|
+
});
|
528
|
+
}
|
529
|
+
}
|
530
|
+
return csub;
|
531
|
+
} else
|
532
|
+
// if the exact item exists, use it
|
533
|
+
if (data[q]){
|
534
|
+
return data[q];
|
535
|
+
} else
|
536
|
+
if (options.matchSubset) {
|
537
|
+
for (var i = q.length - 1; i >= options.minChars; i--) {
|
538
|
+
var c = data[q.substr(0, i)];
|
539
|
+
if (c) {
|
540
|
+
var csub = [];
|
541
|
+
$.each(c, function(i, x) {
|
542
|
+
if (matchSubset(x.value, q)) {
|
543
|
+
csub[csub.length] = x;
|
544
|
+
}
|
545
|
+
});
|
546
|
+
return csub;
|
547
|
+
}
|
548
|
+
}
|
549
|
+
}
|
550
|
+
return null;
|
551
|
+
}
|
552
|
+
};
|
553
|
+
};
|
554
|
+
|
555
|
+
$.Autocompleter.Select = function (options, input, select, config) {
|
556
|
+
var CLASSES = {
|
557
|
+
ACTIVE: "ac_over"
|
558
|
+
};
|
559
|
+
|
560
|
+
var listItems,
|
561
|
+
active = -1,
|
562
|
+
data,
|
563
|
+
term = "",
|
564
|
+
needsInit = true,
|
565
|
+
element,
|
566
|
+
list;
|
567
|
+
|
568
|
+
// Create results
|
569
|
+
function init() {
|
570
|
+
if (!needsInit)
|
571
|
+
return;
|
572
|
+
element = $("<div/>")
|
573
|
+
.hide()
|
574
|
+
.addClass(options.resultsClass)
|
575
|
+
.css("position", "absolute")
|
576
|
+
.appendTo(document.body);
|
577
|
+
|
578
|
+
list = $("<ul/>").appendTo(element).mouseover( function(event) {
|
579
|
+
if(target(event).nodeName && target(event).nodeName.toUpperCase() == 'LI') {
|
580
|
+
active = $("li", list).removeClass(CLASSES.ACTIVE).index(target(event));
|
581
|
+
$(target(event)).addClass(CLASSES.ACTIVE);
|
582
|
+
}
|
583
|
+
}).click(function(event) {
|
584
|
+
$(target(event)).addClass(CLASSES.ACTIVE);
|
585
|
+
select();
|
586
|
+
// TODO provide option to avoid setting focus again after selection? useful for cleanup-on-focus
|
587
|
+
input.focus();
|
588
|
+
return false;
|
589
|
+
}).mousedown(function() {
|
590
|
+
config.mouseDownOnSelect = true;
|
591
|
+
}).mouseup(function() {
|
592
|
+
config.mouseDownOnSelect = false;
|
593
|
+
});
|
594
|
+
|
595
|
+
if( options.width > 0 )
|
596
|
+
element.css("width", options.width);
|
597
|
+
|
598
|
+
needsInit = false;
|
599
|
+
}
|
600
|
+
|
601
|
+
function target(event) {
|
602
|
+
var element = event.target;
|
603
|
+
while(element && element.tagName != "LI")
|
604
|
+
element = element.parentNode;
|
605
|
+
// more fun with IE, sometimes event.target is empty, just ignore it then
|
606
|
+
if(!element)
|
607
|
+
return [];
|
608
|
+
return element;
|
609
|
+
}
|
610
|
+
|
611
|
+
function moveSelect(step) {
|
612
|
+
listItems.slice(active, active + 1).removeClass(CLASSES.ACTIVE);
|
613
|
+
movePosition(step);
|
614
|
+
var activeItem = listItems.slice(active, active + 1).addClass(CLASSES.ACTIVE);
|
615
|
+
if(options.scroll) {
|
616
|
+
var offset = 0;
|
617
|
+
listItems.slice(0, active).each(function() {
|
618
|
+
offset += this.offsetHeight;
|
619
|
+
});
|
620
|
+
if((offset + activeItem[0].offsetHeight - list.scrollTop()) > list[0].clientHeight) {
|
621
|
+
list.scrollTop(offset + activeItem[0].offsetHeight - list.innerHeight());
|
622
|
+
} else if(offset < list.scrollTop()) {
|
623
|
+
list.scrollTop(offset);
|
624
|
+
}
|
625
|
+
}
|
626
|
+
};
|
627
|
+
|
628
|
+
function movePosition(step) {
|
629
|
+
active += step;
|
630
|
+
if (active < 0) {
|
631
|
+
active = listItems.size() - 1;
|
632
|
+
} else if (active >= listItems.size()) {
|
633
|
+
active = 0;
|
634
|
+
}
|
635
|
+
}
|
636
|
+
|
637
|
+
function limitNumberOfItems(available) {
|
638
|
+
return options.max && options.max < available
|
639
|
+
? options.max
|
640
|
+
: available;
|
641
|
+
}
|
642
|
+
|
643
|
+
function fillList() {
|
644
|
+
list.empty();
|
645
|
+
var max = limitNumberOfItems(data.length);
|
646
|
+
for (var i=0; i < max; i++) {
|
647
|
+
if (!data[i])
|
648
|
+
continue;
|
649
|
+
var formatted = options.formatItem(data[i].data, i+1, max, data[i].value, term);
|
650
|
+
if ( formatted === false )
|
651
|
+
continue;
|
652
|
+
var li = $("<li/>").html( options.highlight(formatted, term) ).addClass(i%2 == 0 ? "ac_even" : "ac_odd").appendTo(list)[0];
|
653
|
+
$.data(li, "ac_data", data[i]);
|
654
|
+
}
|
655
|
+
listItems = list.find("li");
|
656
|
+
if ( options.selectFirst ) {
|
657
|
+
listItems.slice(0, 1).addClass(CLASSES.ACTIVE);
|
658
|
+
active = 0;
|
659
|
+
}
|
660
|
+
// apply bgiframe if available
|
661
|
+
if ( $.fn.bgiframe )
|
662
|
+
list.bgiframe();
|
663
|
+
}
|
664
|
+
|
665
|
+
return {
|
666
|
+
display: function(d, q) {
|
667
|
+
init();
|
668
|
+
data = d;
|
669
|
+
term = q;
|
670
|
+
fillList();
|
671
|
+
},
|
672
|
+
next: function() {
|
673
|
+
moveSelect(1);
|
674
|
+
},
|
675
|
+
prev: function() {
|
676
|
+
moveSelect(-1);
|
677
|
+
},
|
678
|
+
pageUp: function() {
|
679
|
+
if (active != 0 && active - 8 < 0) {
|
680
|
+
moveSelect( -active );
|
681
|
+
} else {
|
682
|
+
moveSelect(-8);
|
683
|
+
}
|
684
|
+
},
|
685
|
+
pageDown: function() {
|
686
|
+
if (active != listItems.size() - 1 && active + 8 > listItems.size()) {
|
687
|
+
moveSelect( listItems.size() - 1 - active );
|
688
|
+
} else {
|
689
|
+
moveSelect(8);
|
690
|
+
}
|
691
|
+
},
|
692
|
+
hide: function() {
|
693
|
+
element && element.hide();
|
694
|
+
listItems && listItems.removeClass(CLASSES.ACTIVE);
|
695
|
+
active = -1;
|
696
|
+
},
|
697
|
+
visible : function() {
|
698
|
+
return element && element.is(":visible");
|
699
|
+
},
|
700
|
+
current: function() {
|
701
|
+
return this.visible() && (listItems.filter("." + CLASSES.ACTIVE)[0] || options.selectFirst && listItems[0]);
|
702
|
+
},
|
703
|
+
show: function() {
|
704
|
+
var offset = $(input).offset();
|
705
|
+
element.css({
|
706
|
+
width: typeof options.width == "string" || options.width > 0 ? options.width : $(input).width(),
|
707
|
+
top: offset.top + input.offsetHeight,
|
708
|
+
left: offset.left
|
709
|
+
}).show();
|
710
|
+
if(options.scroll) {
|
711
|
+
list.scrollTop(0);
|
712
|
+
list.css({
|
713
|
+
maxHeight: options.scrollHeight,
|
714
|
+
overflow: 'auto'
|
715
|
+
});
|
716
|
+
|
717
|
+
if($.browser.msie && typeof document.body.style.maxHeight === "undefined") {
|
718
|
+
var listHeight = 0;
|
719
|
+
listItems.each(function() {
|
720
|
+
listHeight += this.offsetHeight;
|
721
|
+
});
|
722
|
+
var scrollbarsVisible = listHeight > options.scrollHeight;
|
723
|
+
list.css('height', scrollbarsVisible ? options.scrollHeight : listHeight );
|
724
|
+
if (!scrollbarsVisible) {
|
725
|
+
// IE doesn't recalculate width when scrollbar disappears
|
726
|
+
listItems.width( list.width() - parseInt(listItems.css("padding-left")) - parseInt(listItems.css("padding-right")) );
|
727
|
+
}
|
728
|
+
}
|
729
|
+
|
730
|
+
}
|
731
|
+
},
|
732
|
+
selected: function() {
|
733
|
+
var selected = listItems && listItems.filter("." + CLASSES.ACTIVE).removeClass(CLASSES.ACTIVE);
|
734
|
+
return selected && selected.length && $.data(selected[0], "ac_data");
|
735
|
+
},
|
736
|
+
emptyList: function (){
|
737
|
+
list && list.empty();
|
738
|
+
},
|
739
|
+
unbind: function() {
|
740
|
+
element && element.remove();
|
741
|
+
}
|
742
|
+
};
|
743
|
+
};
|
744
|
+
|
745
|
+
$.Autocompleter.Selection = function(field, start, end) {
|
746
|
+
if( field.createTextRange ){
|
747
|
+
var selRange = field.createTextRange();
|
748
|
+
selRange.collapse(true);
|
749
|
+
selRange.moveStart("character", start);
|
750
|
+
selRange.moveEnd("character", end);
|
751
|
+
selRange.select();
|
752
|
+
} else if( field.setSelectionRange ){
|
753
|
+
field.setSelectionRange(start, end);
|
754
|
+
} else {
|
755
|
+
if( field.selectionStart ){
|
756
|
+
field.selectionStart = start;
|
757
|
+
field.selectionEnd = end;
|
758
|
+
}
|
759
|
+
}
|
760
|
+
field.focus();
|
761
|
+
};
|
762
|
+
|
763
|
+
})(jQuery);
|