Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

begin iphone layout

  • Loading branch information...
commit b0fae7387995f1ccc5465d3184017135f22162c3 1 parent f50356c
Sébastien Gruhier authored
View
21 app/assets/javascripts/medications.js
@@ -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>" );
- });
- }
- });
- });
-});
View
18 app/assets/javascripts/medications.js.coffee
@@ -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>" );
View
22 app/assets/stylesheets/autocomplete.css.scss
@@ -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;
+ }
+ }
+}
View
6 app/assets/stylesheets/jquery.tagedit.css
@@ -1,6 +1,6 @@
-div.tagsinput { border:1px solid #CCC; background: #FFF; padding:5px; width:300px; height:100px; overflow-y: auto;}
+div.tagsinput { background: #FFF; width:300px; height:100px; overflow-y: auto;}
div.tagsinput span.tag { border: 1px solid #a5d24a; -moz-border-radius:2px; -webkit-border-radius:2px; display: block; float: left; padding: 5px; text-decoration:none; background: #cde69c; color: #638421; margin-right: 5px; margin-bottom:5px;font-family: helvetica; font-size:13px;}
div.tagsinput span.tag a { font-weight: bold; color: #82ad2b; text-decoration:none; font-size: 11px; }
-div.tagsinput input { width:80px; margin:0px; font-family: helvetica; font-size: 13px; border:1px solid transparent; padding:5px; background: transparent; color: #000; outline:0px; margin-right:5px; margin-bottom:5px; }
-div.tagsinput div { display:block; float: left; }
+div.tagsinput input { width:100%; margin:0px; font-family: helvetica; font-size: 13px; padding:5px; background: transparent; color: #000; outline:0px; margin-right:5px; margin-bottom:5px; }
+div.tagsinput div { width: 95%; display:block; float: left; }
.tags_clear { clear: both; width: 100%; height: 0px; }
View
4 app/controllers/medications_controller.rb
@@ -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
2  app/models/medication.rb
@@ -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(',') : []
View
1  app/views/layouts/application.html.erb
@@ -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 %>
View
6 app/views/medications/_form.html.erb
@@ -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" %>
Please sign in to comment.
Something went wrong with that request. Please try again.