Commit 65e509c1 authored by Kjetil Thuen's avatar Kjetil Thuen

Render study metadata using handlebars template

parent cf015f46
.*.swp
*_template.js
tags
......@@ -20,15 +20,7 @@
<div id="content"></div>
<h2 id="target"></h2>
<div id="expander">
<div class="metadata">
<div class="abstract lead"></div>
<div class="buttons">
<button class="btn btn-info"><i class="icon-info-sign"></i> Mer metadata</button>
<button class="btn btn-success"><i class="icon-ok-sign"></i> Velg studie</button>
</div>
</div>
</div>
<div id="expander"> </div>
</body>
</html>
......@@ -143,7 +143,7 @@ inScroll = false;
scrollInProgress = false;
if (details !== null) {
//FIXME: Stop depending on an existing div.abstract here
$('#' + settings.revealDivId + ' div.abstract').html(details);
$('#' + settings.revealDivId).html(details);
$('#' + settings.revealDivId).slideDown('fast', function() {
scrollListenersEnabled = true;
});
......
......@@ -54,7 +54,7 @@ ul#studies_list li.selected {
background-color: rgba(0,0,0,0.8);
}
h2 {
h2, #studies_list li div.study_title {
margin: 0px;
padding: 0.5em;
z-index: 3;
......
<ul class="nav nav-list" id="studies_list">
{{#each studies}}
<li id="{{id}}">
<div>{{name}}</div>
<div class="study_title">{{name}}</div>
</li>
{{/each}}
</ul>
......@@ -2,6 +2,7 @@ head.js("http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.2/jquery.min.js")
.js("http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.min.js")
.js("http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min.js")
.js("listPeek.js")
.js("studymetadata_template.js")
.js("studylist_template.js", function() {
var jsondata = {};
var build_list = function() {
......@@ -32,12 +33,10 @@ head.js("http://cdnjs.cloudflare.com/ajax/libs/jquery/2.0.2/jquery.min.js")
return v.id === id; // filter out appropriate one
});
var metadata = "No metadata found for " + id;
var studyMetadataTemplate = Handlebars.templates.studymetadata;
var metadatahtml = studyMetadataTemplate(studyMetadata[0]);
if (studyMetadata.length > 0) {
metadata = studyMetadata[0].abstractText;
}
return metadata;
return metadatahtml;
};
head.ready(function() {
......
(function() {
var template = Handlebars.template, templates = Handlebars.templates = Handlebars.templates || {};
templates['studylist'] = template(function (Handlebars,depth0,helpers,partials,data) {
this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};
var buffer = "", stack1, functionType="function", escapeExpression=this.escapeExpression, self=this;
function program1(depth0,data) {
var buffer = "", stack1;
buffer += "\n <li id=\"";
if (stack1 = helpers.id) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.id; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "\">\n <div>";
if (stack1 = helpers.name) { stack1 = stack1.call(depth0, {hash:{},data:data}); }
else { stack1 = depth0.name; stack1 = typeof stack1 === functionType ? stack1.apply(depth0) : stack1; }
buffer += escapeExpression(stack1)
+ "</div>\n </li>\n ";
return buffer;
}
buffer += "<ul class=\"nav nav-list\" id=\"studies_list\">\n ";
stack1 = helpers.each.call(depth0, depth0.studies, {hash:{},inverse:self.noop,fn:self.program(1, program1, data),data:data});
if(stack1 || stack1 === 0) { buffer += stack1; }
buffer += "\n</ul>\n";
return buffer;
});
})();
<div class="metadata" id="studymetadata">
<div class="abstract">{{abstractText}}</div>
<div class="buttons">
<button class="btn btn-info"><i class="icon-info-sign"></i> Mer metadata</button>
<button class="btn btn-success"><i class="icon-ok-sign"></i> Velg studie</button>
</div>
</div>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment