//= require spotlight/blocks/resources_block
SirTrevor.Blocks.SolrDocuments = (function(){
return Spotlight.Block.Resources.extend({
type: "solr_documents",
textable: true,
icon_name: "items",
autocomplete_url: function() { return this.$instance().closest('form[data-autocomplete-exhibit-catalog-index-path]').data('autocomplete-exhibit-catalog-index-path').replace("%25QUERY", "%QUERY"); },
autocomplete_template: function() { return '
{{#if thumbnail}}
{{/if}}
{{title}} {{description}} ' },
transform_autocomplete_results: function(response) {
return $.map(response['docs'], function(doc) {
return doc;
})
},
caption_option_values: function() {
var fields = $('[data-blacklight-configuration-index-fields]').data('blacklight-configuration-index-fields');
return $.map(fields, function(field) {
return $('').val(field.key).text(field.label)[0].outerHTML;
}).join("\n");
},
item_options: function() { return this.caption_options(); },
caption_options: function() { return [
'',
'',
'',
'',
'',
'
',
'',
'',
'',
'',
'',
'
',
].join("\n") },
afterPanelRender: function(data, panel) {
var context = this;
if (_.isUndefined(data['image_versions'])) {
$.getJSON(this.autocomplete_url().replace("%QUERY", "id:" + data.id), function(data) {
var doc = context.transform_autocomplete_results(data)[0];
if (!_.isUndefined(doc)) {
panel.multiImageSelector(doc['image_versions']);
}
});
} else {
panel.multiImageSelector(data['image_versions']);
}
}
});
})();