Skip to content

Commit

Permalink
Work on affixes (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmanko committed Nov 16, 2013
1 parent ebbc613 commit 47d2f2d
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 22 deletions.
7 changes: 7 additions & 0 deletions app/assets/javascripts/patient.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
# You can use CoffeeScript in this file: http://coffeescript.org/

$ ->
$('body').scrollspy({ target: '#profile-nav', offset: 0 })

# Fix for anchor offset problems caused by the fixed main navbar
$("#profile-nav .nav a[href!=#]").each ->
$($(this).attr("href")).css("padding-top", "50px").prev().css "margin-bottom", "-50px"

# Highcharts
if $("#chart").length > 0
$("#chart").highcharts
chart:
Expand Down
2 changes: 2 additions & 0 deletions app/assets/less/base.less
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@


.main-container {
padding: 50px 0 0 0;
}
Expand Down
42 changes: 26 additions & 16 deletions app/assets/less/patient.less
Original file line number Diff line number Diff line change
@@ -1,25 +1,35 @@
#patient-profile {
.affix-top {


}
.affix {
width: inherit;
top: 65px;
}

.affix-bottom {
position: absolute;
}

.sidebar {
margin-top: 10px;
margin-bottom: 10px;
padding-top: 10px;
padding-bottom: 10px;
text-shadow: 0 1px 0 #fff;
background-color: #f7f5fa;
border-radius: 5px;

.active {
font-weight: bold;
color: #563d7c;
background-color: transparent;
border-right: 1px solid #563d7c;
#profile-nav {

.sidebar {
margin-top: 10px;
margin-bottom: 10px;
padding-top: 10px;
padding-bottom: 10px;
text-shadow: 0 1px 0 #fff;
background-color: #f7f5fa;
border-radius: 5px;

.active {
font-weight: bold;
color: #563d7c;
background-color: transparent;
border-right: 1px solid #563d7c;
}
}


}

.survey-date {
Expand Down
1 change: 1 addition & 0 deletions app/assets/stylesheets/main.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
@import "base";
@import "navigation";
@import "patient";

52 changes: 51 additions & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,57 @@ def after_sign_in_path_for(user)
patient_profile_path(user)

end
end

def send_message(service, form_data = {}, method = "get", limit = 1, service_url = '')
return { result: '', error: 'No Task Tracker URL provided' } if false #if .blank? or TT_EMAIL.blank? or TT_PASSWORD.blank?
error = ''
data = ''
response = ''
return { result: data, error: 'HTTP redirect too deep' } if limit < 0

t_msg_start = Time.now

service_url = "#{}/#{service}" if service_url.blank?

begin
url = URI.parse(service_url)
use_secure = (url.scheme == 'https')

https = Net::HTTP.new(url.host, url.port)
https.open_timeout = 1000 # in seconds
https.read_timeout = 3000 # in seconds
https.use_ssl = true if use_secure
https.verify_mode = OpenSSL::SSL::VERIFY_NONE if use_secure

headers = { 'Content-Type' => 'text/html', 'WWW-Authenticate' => 'Basic realm="Application"', 'Authorization' => "Basic #{Base64.strict_encode64("#{}:#{}")}" }

url = URI.parse(service_url)
req = if method == "post"
Net::HTTP::Post.new(url.path, headers)
else # elsif method == "get"
Net::HTTP::Get.new(url.path, headers)
end
req.set_form_data(form_data.stringify_keys, ';') unless form_data.blank?

https.start do |http|
response = http.request(req)
end
data = response.body

if response.kind_of?(Net::HTTPSuccess)
# Do nothing, success!
elsif response.kind_of?(Net::HTTPRedirection)
return send_message(service, form_data, method, limit - 1, response['location'])
else
error = "Error: #{response.class.name} #{data}"
data = ''
end
rescue => e
error = e.to_s
Rails.logger.debug "Error: #{error} #{data}"
data = ''
end

{ result: data, error: error }
end
end
10 changes: 5 additions & 5 deletions app/views/patient/profile.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@
<div class="container">
<div class="row">
<div class="col-md-3">
<div class="affix" data-offset-top="200">
<div id="profile-nav" data-offset-top="220" data-spy="affix">
<ul class="nav sidebar">
<li class="active"><a href="">Basic Information</a></li>
<li><a href="">Labs & Measurements</a></li>
<li><a href="#basic-info">Basic Information</a></li>
<li><a href="#labs-measurements">Labs & Measurements</a></li>
<li><a href="#medical-record">Medical Record</a></li>
<li><a href="">Surveys</a></li>
<li><a href="">Connections</a></li>
<li><a href="#surveys-questionnaires">Surveys</a></li>
<li><a href="#connections">Connections</a></li>
</ul>
</div>
</div>
Expand Down

0 comments on commit 47d2f2d

Please sign in to comment.