diff --git a/demo/js/app.js b/demo/js/app.js index cbfeddc2..a78bcf9d 100755 --- a/demo/js/app.js +++ b/demo/js/app.js @@ -2,9 +2,26 @@ $(function() { var $el = $('
'); $el.appendTo($('.data-explorer-here')); var dataset = demoDataset(); + var views = [ + { + id: 'grid', + label: 'Grid', + view: new recline.View.DataTable({ + model: dataset + }) + }, + { + id: 'graph', + label: 'Graph', + view: new recline.View.FlotGraph({ + model: dataset + }) + } + ]; window.dataExplorer = new recline.View.DataExplorer({ el: $el , model: dataset + , views: views }); Backbone.history.start(); setupLoadFromWebstore(function(dataset) { diff --git a/src/view.js b/src/view.js index 166e2a05..1cf5ec47 100644 --- a/src/view.js +++ b/src/view.js @@ -1,30 +1,57 @@ this.recline = this.recline || {}; this.recline.View = this.recline.View || {}; -// Views module following classic module pattern (function($, my) { // ## DataExplorer // -// The primary view for the entire application. -// -// It should be initialized with a recline.Model.Dataset object and an existing -// dom element to attach to (the existing DOM element is important for -// rendering of FlotGraph subview). +// The primary view for the entire application. Usage: // -// To pass in configuration options use the config key in initialization hash -// e.g. +//
+// var myExplorer = new model.recline.DataExplorer({
+// model: {{recline.Model.Dataset instance}}
+// el: {{an existing dom element}}
+// views: {{page views}}
+// config: {{config options -- see below}}
+// });
+//
//
-// var explorer = new DataExplorer({
-// config: {...}
+// ### Parameters
+//
+// **:param model:** (required) Dataset instance.
+//
+// **:param el:** (required) DOM element.
+//
+// **:param views:** (optional) the views (Grid, Graph etc) for DataExplorer to
+// show. This is an array with the key used in routing. If not provided
+// just initialize a DataTable with key 'grid'. Example:
+//
+//
+// var views = [
+// {
+// id: 'grid',
+// label: 'Grid',
+// view: new recline.View.DataTable({
+// model: dataset
// })
+// },
+// {
+// id: 'graph',
+// label: 'Graph',
+// view: new recline.View.FlotGraph({
+// model: dataset
+// })
+// }
+// ];
+//
//
-// Config options:
+// **:param config:** Config options like:
//
-// * displayCount: how many documents to display initially (default: 10)
-// * readOnly: true/false (default: false) value indicating whether to
-// operate in read-only mode (hiding all editing options).
+// * displayCount: how many documents to display initially (default: 10)
+// * readOnly: true/false (default: false) value indicating whether to
+// operate in read-only mode (hiding all editing options).
//
-// All other views as contained in this one.
+// NB: the element already being in the DOM is important for rendering of
+// FlotGraph subview.
my.DataExplorer = Backbone.View.extend({
template: ' \