1 |
{% extends "base.html" %} |
2 |
{%- block view %} |
3 |
<div class="grid-item"> |
4 |
<a href="/context/questions/{{context['guid']}}"> |
5 |
<img class="question-icon" src="/static/icons/button-question.png" /> |
6 |
</a> |
7 |
<a href="/context/ideas/{{context['guid']}}"> |
8 |
<img class="idea-icon" src="/static/icons/button-idea.png" /> |
9 |
</a> |
10 |
<a href="/context/problems/{{context['guid']}}"> |
11 |
<img class="problem-icon" src="/static/icons/button-problem.png" /> |
12 |
</a> |
13 |
<div class="iconbox"> |
14 |
<a href="/launch/{{context['guid']}}"> |
15 |
<img class="grid-icon" src="/context/icon/{{context['guid']}}" /> |
16 |
</a> |
17 |
</div> |
18 |
<div class="context-label"> |
19 |
<span class="context-controls"> |
20 |
<img id="moon-{{context['guid']}}" |
21 |
{% if context['keep_impl'] %} |
22 |
style="background-color:{{fill}}; border: 1px solid {{stroke}};" |
23 |
data-keep_impl="true" |
24 |
{% endif %} |
25 |
class="moon-emblem" src="/static/icons/moon.png"/> |
26 |
<img id="star-{{context['guid']}}" |
27 |
{% if context['keep'] %} |
28 |
style="background-color:{{fill}}; border: 1px solid {{stroke}};" |
29 |
data-keep="true" |
30 |
{% endif %} |
31 |
class="star-emblem" src="/static/icons/add-link-small.png"/> |
32 |
</span> |
33 |
|
34 |
{{context['title']}} |
35 |
</div> |
36 |
</div> |
37 |
<div id="accordion"> |
38 |
<h2 class="current">{{_('Description')}}</h2> |
39 |
<div class="pane" style="display:block">{{context['description']}}</div> |
40 |
|
41 |
<h2>{{_('Owner(s)')}}</h2> |
42 |
<div class="pane"> |
43 |
<div id="sugar-man"> |
44 |
<img class="grid-icon" src="/static/icons/sugar-xo.png" /> |
45 |
</div> |
46 |
</div> |
47 |
|
48 |
<h2>{{_('License')}}</h2> |
49 |
<div class="pane">... pane content ...</div> |
50 |
</div> |
51 |
<div id="resource-section"> |
52 |
{% include inner_template or '_context-resource-list.html' %} |
53 |
</div> |
54 |
{%- endblock view %} |
55 |
{%- block script %} |
56 |
{{ super() }} |
57 |
|
58 |
function initComments () { |
59 |
var guid = $(this).data('guid'); |
60 |
$('#throbber_'+guid).slideDown(); |
61 |
$('#comments-button-'+guid).slideUp( function () { |
62 |
}); |
63 |
$.get('/_comments/'+guid, { resource_type:'{{resource_type}}' }, function ( data ) { |
64 |
$('#comments-'+guid).empty().append( data ); |
65 |
$('#throbber_'+guid).slideUp( |
66 |
function() { |
67 |
$('#comments-'+guid).slideDown(); |
68 |
}); |
69 |
$('#comment_form_'+guid).submit(onSubmit_Comment); |
70 |
initCollapse (guid); |
71 |
}); |
72 |
} |
73 |
|
74 |
function initCollapse (guid) { |
75 |
$('span.collapse-button').click( function() { |
76 |
$('#comments-'+guid).slideUp(); |
77 |
$('#comments-button-'+guid).slideDown(); |
78 |
}); |
79 |
} |
80 |
|
81 |
// This is what happens when we (re)load the comments section. |
82 |
function onSubmit_Comment (e) { |
83 |
e.preventDefault(); |
84 |
var guid = $(this).data('guid'); |
85 |
$('#comment_form_'+guid).slideUp(); |
86 |
$('#comment_button_'+guid).slideUp(); |
87 |
$('#comment_throbber_'+guid).slideDown(); |
88 |
$.post( '/submit_comment', |
89 |
$(this).serialize(), |
90 |
function(response) { |
91 |
$.get('/_comments/'+guid, |
92 |
{ resource_type:'{{resource_type}}' }, function ( data ) { |
93 |
$('#comment_throbber_'+guid).slideUp(); |
94 |
$('#comments-'+guid).empty().append( data ); |
95 |
$('#comment_form_'+guid).submit(onSubmit_Comment); |
96 |
initCollapse (guid); |
97 |
}); |
98 |
}); |
99 |
}; |
100 |
|
101 |
$(function() { |
102 |
/* var source = new EventSource('/_events/solution'); |
103 |
source.onmessage = function(data) { |
104 |
alert(data); |
105 |
};*/ |
106 |
init_styles('#e5e5e5'); |
107 |
$("#accordion").tabs( |
108 |
"#accordion div.pane", |
109 |
{tabs: 'h2', effect: 'slide', initialIndex: null} |
110 |
); |
111 |
|
112 |
$('#solution-form').submit( function() { |
113 |
$('#contribute-button').slideUp(); |
114 |
$('#textarea-solution').slideUp(); |
115 |
/* $('#contribute-button').attr("disabled", "disabled");*/ |
116 |
}); |
117 |
|
118 |
$('span.comments-button').click( initComments ); |
119 |
|
120 |
$('.solution-link').click( function() { |
121 |
$.get($(this).data('href') + '?_pjax', {}, function ( data ) { |
122 |
$('#resource-section').empty().append( data ); |
123 |
$('span.comments-button').click( initComments ); |
124 |
}); |
125 |
$('#bottom-palette').slideUp(); |
126 |
$( '#info' ).empty(); |
127 |
$( '#meta' ).empty(); |
128 |
history.pushState(null,null, $(this).data('href')); |
129 |
return false; //prevents form from being submitted. |
130 |
}); |
131 |
|
132 |
// When viewing solutions |
133 |
if ($(".resource-header-column").length) { |
134 |
$('#bottom-palette').slideUp(); |
135 |
}; |
136 |
|
137 |
// When displaying notice |
138 |
if ($(".notice").length) { |
139 |
$("#mejorar-sistema").css( "left", "49%"); |
140 |
$("#mejorar-sistema").css( "top", "40%"); |
141 |
}; |
142 |
|
143 |
// When viewing resources |
144 |
if ($(".resource-scrollable").length) { |
145 |
// initialize scrollable |
146 |
$(".resource-scrollable").scrollable( {vertical:true} ); |
147 |
var api = $("#resource-scrollable").data("scrollable"); |
148 |
var last_page = {{page or 0}}; |
149 |
api.seekTo({{ (page or 0) -1}},0); |
150 |
api.onSeek( function() { |
151 |
new_page = api.getIndex()+1; |
152 |
history.pushState(null,null,'?page=' + new_page); |
153 |
$.get( '?page='+new_page+'&_pjax', { }, |
154 |
function( data ) { |
155 |
$( '#resource-page-'+new_page ).empty().append( data ); |
156 |
} |
157 |
); |
158 |
$( '#resource-page-'+last_page ).empty().append('<div id="throbber-box"><img id="throbber" src="/static/images/throbber10.gif" /></div>'); |
159 |
last_page=new_page; |
160 |
$( '#info' ).empty().append('{% trans %}page '+new_page+' of{% endtrans %} {{total_pages}}'); |
161 |
}); |
162 |
}; |
163 |
}); |
164 |
{%- endblock script %} |