// Main Module for searchthedocs demo
define(function (require) {
  var _ = require('underscore'),
    $ = require('jquery'),
    // The xdomainajax plugin is required if we wish to load content
    // from another domain.
    xdomainajax = require('xdomainajax'),
    LocalContentView = require('stfd/local_content'),
    RemoteContentView = require('stfd/remote_content'),
    SearchTheDocsView = require('stfd/searchthedocs');

  var searchthedocs_main = function() {

    var search_options = {
      default_endpoint: 'sections',
      endpoints: {
        sections: {
          ContentViewClass: LocalContentView,
          data_type: 'jsonp',
          default_params: {format: 'jsonp'},
          api_url: 'http://readthedocs.org/api/v2/search/section/',
          content_url_format:
            'http://{{domain}}.readthedocs.org/en/'
            + '{{version}}/{{path}}.html#{{page_id}}',
          param_map: {
            search: 'q',
            domain: 'project'
          },
          result_format: {
            records_path: 'results.hits.hits',
            record_format: {
              // Fields used in sidebar display
              domain: 'fields.project',
              title: 'fields.title',
              content: 'fields.content',
              // Fields used to build record_url
              version: 'fields.version',
              path: 'fields.path',
              page_id: 'fields.page_id'
            }
          },
      }
    }
  };

    window.searchtd = new SearchTheDocsView({
      brand: 'searchthedocs',
      brand_href: '#',
      search_options: search_options
    });

   $('#searchthedocs-container').append(searchtd.render().el);

  };

  return searchthedocs_main;

});


@@ -424,16 +424,377 @@
 ocs');%0A%0A
+  // Create class map for view class lookup by string name.%0A  // Custom classes can be added here, then used in the search_options hash.%0A  // This also allows the search_options hash to remain pure data, allowing%0A  // dynamic configuration by the server.%0A  var class_map = %7B%0A    LocalContentView: LocalContentView,%0A    RemoteContentView: RemoteContentView%0A  %7D%0A%0A
   var se
@@ -825,16 +825,16 @@
 ion() %7B%0A
-
 %0A    var
@@ -942,26 +942,36 @@
     
-C
+c
 ontent
-ViewC
+_view_c
 lass
+_string
 : 
+'
 Loca
@@ -978,24 +978,25 @@
 lContentView
+'
 ,%0A          
@@ -1972,16 +1972,44 @@
 _options
+,%0A      class_map: class_map
 %0A    %7D);

Create class map with string keys so search_options can remain pure data