/*global define */ define(['jquery', 'underscore', 'backbone', 'models/SolrHeader', 'models/SolrResult', 'models/LogsSearch'], function($, _, Backbone, SolrHeader, SolrResult, LogsSearch) { 'use strict'; // SolrResults Collection // ------------------------ // The collection of SolrResult var SolrResultList = Backbone.Collection.extend({ // Reference to this collection's model. model: SolrResult, initialize: function(models, options) { if( typeof options === "undefined" || !options ){ var options = {}; } this.docsCache = options.docsCache || null; this.currentquery = options.query || '*:*'; this.fields = options.fields || "id,title"; this.rows = options.rows || 25; this.start = options.start || 0; this.sort = options.sort || 'dateUploaded desc'; this.facet = options.facet || []; this.facetCounts = "nothing"; this.stats = options.stats || false; this.minYear = options.minYear || 1900; this.maxYear = options.maxYear || new Date().getFullYear(); //If POST queries are disabled in the whole app, don't use POSTs here if( MetacatUI.appModel.get("disableQueryPOSTs") ){ this.usePOST = false; } //If this collection was initialized with the usePOST option, use POSTs here else if( options.usePOST ){ this.usePOST = true; } //Otherwise default to using GET else{ this.usePOST = false; } }, url: function() { //Convert facet keywords to a string var facetFields = ""; this.facet = _.uniq(this.facet); for (var i=0; i 0) { facetFields += "&facet.mincount=1"; // only facets meeting the current search facetFields += "&facet.limit=-1"; // CAREFUL: -1 means no limit on the number of facets } //Do we need stats? if (!this.stats){ var stats = ""; } else{ var stats = "&stats=true"; for(var i=0; i