Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updating sdc tooltips to use flatblocks. requires loading flatblocks …

…fixture.
  • Loading branch information...
commit 184f968308a55da91283e87ece0e4787960365e3 1 parent 067b7e1
@sfletche sfletche authored
View
20 marco/fixtures/flatblocks.json
@@ -1,11 +1,29 @@
[
{
+ "pk": 3,
+ "model": "flatblocks.flatblock",
+ "fields": {
+ "content": "AWS-Truewind created this modeled wind speed Eastern Dataset with oversight and assistance from NREL.",
+ "header": "",
+ "slug": "info_wind_speed"
+ }
+ },
+ {
+ "pk": 4,
+ "model": "flatblocks.flatblock",
+ "fields": {
+ "content": "The National Renewable Energy Laboratory (2011) recommends siting of offshore wind facilities in areas with average wind speeds greater than 15.7 mph.",
+ "header": "",
+ "slug": "info_wind_speed_widget"
+ }
+ },
+ {
"pk": 2,
"model": "flatblocks.flatblock",
"fields": {
"content": "<a href=\"http://www.midatlanticocean.org/index.htm\" target=\"_blank\">The Mid-Atlantic Regional Council on the Ocean (MARCO)</a> is a collaborative effort between the mid-atlantic states to maintain and improve the health of the ocean and coastal resources and ensure that they continue to contribute to the high quality of life and economic vitality of the region's communities.",
"header": "",
- "slug": "about paragraph1"
+ "slug": "about_paragraph_1"
}
}
]
View
97 marco/scenarios/templates/scenario/form.html
@@ -1,6 +1,7 @@
{% extends "common/panel.html" %}
{% block title %}{{title}}{% endblock %}
{% block panel %}
+{% load flatblock_tags %}
<script type="text/javascript" charset="utf-8">
@@ -148,6 +149,7 @@
wizard();
});
+
$('img.info').each( function() {
var id = $(this).attr('id');
var text = "none";
@@ -155,95 +157,49 @@
topLeft = false;
topRight = false;
switch(id) {
-
//Step 1 Categories
case 'info_wind_speed':
topRight = true;
- text = "AWS-Truewind created this modeled wind speed Eastern Dataset with oversight and assistance from NREL.";
+ text = $('#info_wind_speed_content').html();
break;
case 'info_wind_speed_widget':
topLeft = true;
- text = "The National Renewable Energy Laboratory (2011) recommends siting of offshore wind facilities in areas with average wind speeds greater than 15.7 mph.";
+ text = $('#info_wind_speed_widget_content').html();
break;
default:
$(this).hide();
}
- if (text!='none' && topMiddle) {
- $(this).qtip({
- content: text,
- show: {
- delay: 0,
- when: { event: 'mouseover' }
- },
- position: {
- corner: {
- target: 'topMiddle',
- tooltip: 'bottomMiddle'
- }
- },
- hide: { when: {event: 'mouseleave'} },
- style: {
- width: 320,
- name: 'blue'
- }
- });
- } else if (text!='none' && topLeft) {
- $(this).qtip({
- content: text,
- show: {
- delay: 0,
- when: { event: 'mouseover' }
- },
- position: {
- corner: {
- target: 'topRight',
- tooltip: 'bottomRight'
- }
- },
- hide: { when: {event: 'mouseleave'} },
- style: {
- width: 270,
- name: 'blue'
- }
- });
- } else if (text!='none' && topRight) {
- $(this).qtip({
+ if (text != 'none') {
+ var my_configuration_object = {
content: text,
show: {
delay: 0,
when: { event: 'mouseover' }
},
- position: {
- corner: {
- target: 'topLeft',
- tooltip: 'bottomLeft'
- }
- },
+ position: { corner: {} },
hide: { when: {event: 'mouseleave'} },
style: {
- width: 270,
name: 'blue'
}
- });
- } else if (text!='none') {
- $(this).qtip({
- content: text,
- show: {
- delay: 0,
- when: { event: 'mouseover' }
- },
- position: {
- corner: {
- target: 'rightMiddle',
- tooltip: 'leftMiddle'
- }
- },
- hide: { when: {event: 'mouseleave'} },
- style: {
- width: 270,
- name: 'blue'
- }
- });
+ };
+ if (topMiddle) {
+ my_configuration_object.position.corner.target = 'topMiddle';
+ my_configuration_object.position.corner.tooltip = 'bottomMiddle';
+ my_configuration_object.style.width = 320;
+ } else if (topLeft) {
+ my_configuration_object.position.corner.target = 'topRight';
+ my_configuration_object.position.corner.tooltip = 'bottomRight';
+ my_configuration_object.style.width = 270;
+ } else if (topRight) {
+ my_configuration_object.position.corner.target = 'topLeft';
+ my_configuration_object.position.corner.tooltip = 'bottomLeft';
+ my_configuration_object.style.width = 270;
+ } else {
+ my_configuration_object.position.corner.target = 'rightMiddle';
+ my_configuration_object.position.corner.tooltip = 'leftMiddle';
+ my_configuration_object.style.width = 270;
+ }
+ $(this).qtip(my_configuration_object);
}
});
@@ -324,6 +280,7 @@
<label>
{{ form.input_parameter_wind_speed }} Wind Speed
<img src="/media/marco/img/info.png" id="info_wind_speed" class="info" />
+ <span id="info_wind_speed_content" style="display: none;">{% flatblock "info_wind_speed" %}</span>
</label>
<div id="wind_speed_widget" class="inputfield">
<div class="label">Potential: <span id="wind_speed_text" class="potential">Good</span></div>
View
11 marco/scenarios/widgets.py
@@ -27,7 +27,16 @@ def __init__(self, min, max, step, id):
def render(self, *args, **kwargs):
output = super(SliderWidgetWithTooltip, self).render(*args,**kwargs)
- output = output.replace('\n', '<img src="/media/marco/img/info.png" id="%s" class="info" />\n' %self.id, 1)
+ img_id = self.id
+ span_id = "%s_content" %self.id
+ #grabbing flatblock outright as including the flatblock template tag in the output html resulted in a literal output of the template tag
+ from flatblocks.models import FlatBlock
+ try:
+ flatblock = str(FlatBlock.objects.get(slug=self.id).content)
+ except:
+ flatblock = ""
+ output = output.replace('\n', ' <img src="/media/marco/img/info.png" id="%s" class="info" />\n' %img_id, 1)
+ output = output.replace('\n', ' <span id="%s" style="display: none;">%s</span>\n' %(span_id, flatblock), 1)
return mark_safe(output)
class DualSliderWidgetWithTooltip(DualSliderWidget):
View
2  marco/templates/news/about.html
@@ -1,4 +1,4 @@
{% load appname %}
{% load flatblock_tags %}
<h2> {% appname %}</h2>
-<p> {% flatblock "about paragraph1" %}</p>
+<p> {% flatblock "about_paragraph_1" %}</p>
Please sign in to comment.
Something went wrong with that request. Please try again.