Permalink
Browse files

begin iphone layout

  • Loading branch information...
1 parent f50356c commit b0fae7387995f1ccc5465d3184017135f22162c3 Sébastien Gruhier committed Apr 7, 2012
@@ -1,21 +0,0 @@
-$(document).ready(function () {
- /**
- * Autocomplete the secondary effects in edit form
- */
- $("#medication_secondary_effects").tagsInput({autocomplete_url:"/secondary_effects", defaultText:"Choose or enter a secondary effect, seperated by commas"});
-
- /**
- * Search in the background for similiar exisiting medications
- */
- $('form.new_medication #medication_name, form.new_medication #medication_generic_name').change(function() {
-
- $.ajax({
- url: "/medications/search.json?q=" + $("form.new_medication #medication_name").val(),
- success: function(data) {
- $.each(data, function(index, value) {
- $('#search_result').append("<div>There is already a medication called " + value.name + " ("+ value.generic_name + "), you can visit it here: " + '<a href="/medications/' + value.name.toLowerCase() + '">' + value.name + "</a></div>" );
- });
- }
- });
- });
-});
@@ -0,0 +1,18 @@
+$ ->
+ tagAdded = ->
+ console.log 'okok'
+ # Autocomplete the secondary effects in edit form
+ $("#medication_secondary_effects").tagsInput
+ autocomplete_url:"/secondary_effects"
+ width:'auto'
+ height:'auto'
+ defaultText: ""
+ onAddTag: tagAdded
+
+ # Search in the background for similiar exisiting medications
+ $('form#new_medication #medication_name, form#new_medication #medication_generic_name').change ->
+ $.ajax
+ url: "/medications/search.json?q=" + $("form#new_medication #medication_name").val()
+ success: (data) ->
+ $.each data, (index, value) ->
+ $('#search_result').append("<div>There is already a medication called " + value.name + " ("+ value.generic_name + "), you can visit it here: " + '<a href="/medications/' + value.name.toLowerCase() + '">' + value.name + "</a></div>" );
@@ -0,0 +1,22 @@
+ul.ui-autocomplete {
+ position: absolute;
+ list-style: none;
+ margin: 0;
+ padding: 0;
+ border: solid 1px #999;
+ cursor: default;
+ li {
+ background-color: #FFF;
+ border-top: solid 1px #DDD;
+ margin: 0;
+ padding: 0;
+ a {
+ color: #000;
+ display: block;
+ padding: 3px;
+ }
+ a.ui-state-hover, a.ui-state-active {
+ background-color: #FFFCB2;
+ }
+ }
+}

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -12,7 +12,7 @@ def index
# GET /medications/search
def elastic_search
- @medications = Medication.search params
+ @medications = Medication.elastic_search params
@facets = @medications.facets['secondary_effects']["terms"]
respond_to do |format|
@@ -22,7 +22,7 @@ def elastic_search
end
def search
- @medications = Medication.search(params[:q])
+ @medications = Medication.where(:name => params[:q])
respond_to do |format|
format.html # index.html.erb
View
@@ -31,7 +31,7 @@ def to_indexed_json
field :generic_name, :type => String
taggable :secondary_effects, :separator => ','
- def self.search(params)
+ def self.elastic_search(params)
query = params[:q].present? ? "*#{params[:q]}*" : "*"
t = params[:terms].present? ? params[:terms].split(',') : []
@@ -3,6 +3,7 @@
<head>
<title>BBPHealth</title>
<link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=Convergence|Open+Sans">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
@@ -1,8 +1,8 @@
<%= simple_form_for(@medication, :html => {:class => 'form-horizontal' }) do |form| %>
- <%= form.input :name %>
- <%= form.input :generic_name %>
- <%= form.input :secondary_effects, :as => :text %>
+ <%= form.input :name, :input_html => {:class => :span} %>
+ <%= form.input :generic_name, :input_html => {:class => :span} %>
+ <%= form.input :secondary_effects, :as => :text, :input_html => {:class => :span}, :hint => "Choose or enter a secondary effect, seperated by commas" %>
<div class="form-actions">
<%= form.button :submit, :class => 'btn btn-primary' %>
<%= link_to 'Back', medications_path , :class=>"btn" %>

0 comments on commit b0fae73

Please sign in to comment.