site/js/docurium.js in docurium-0.3.2 vs site/js/docurium.js in docurium-0.4.0

- old
+ new

@@ -335,19 +335,42 @@ var returns = _.map(data.used.returns, toPair, docurium) var needs = _.map(data.used.needs, toPair, docurium) var fileLink = {name: data.file, url: docurium.github_file(data.file, data.line, data.lineto)} - this.set('data', {tname: tname, data: data, returns: returns, needs: needs, fileLink: fileLink}) + // so it doesn't look crap, we build up a block with fields + // without a comment + var had_comment = false + var blocks = [] + var tmp = [] + _.each(data.fields, function(f) { + if (had_comment) { + blocks.push(tmp) + tmp = [] + } + + tmp.push(f) + had_comment = f.comments + }) + blocks.push(tmp) + + this.set('data', {tname: tname, data: data, blocks: blocks, returns: returns, needs: needs, fileLink: fileLink}) } }) var TypeView = Backbone.View.extend({ - template: _.template($('#type-template').html()), + enumTemplate: _.template($('#enum-template').html()), + structTemplate: _.template($('#struct-template').html()), + usesTemplate: _.template($('#uses-template').html()), render: function() { - var content = this.template(this.model.get('data')) + var type = this.model.get('data') + var uses = this.usesTemplate(type) + + var template = type.data.type == 'struct' ? this.structTemplate : this.enumTemplate + var content = template({type: type, uses: uses}) + this.el = content return this } }) @@ -501,11 +524,11 @@ this.bind('change:version', this.loadDoc) }, loadVersions: function() { $.getJSON("project.json").then(function(data) { - docurium.set({'versions': data.versions, 'github': data.github, 'signatures': data.signatures, 'name': data.name, 'groups': data.groups}) + docurium.set({'versions': data.versions, 'github': data.github, 'signatures': data.signatures, 'name': data.name}) docurium.setVersion() }) }, setVersion: function (version) { @@ -543,10 +566,10 @@ } return text }, groupOf: function (func) { - return this.get('groups')[func] + return this.get('data')['functions'][func]['group'] }, github_file: function(file, line, lineto) { var data = this.get('data') url = ['https://github.com', docurium.get('github'),