[fixes #17,view][s]: read-only mode (where editing options are hidden).

This commit is contained in:
Rufus Pollock
2012-01-07 03:09:45 +00:00
parent f1c5b8a430
commit 638eff6c3c
4 changed files with 40 additions and 1 deletions

View File

@@ -7,6 +7,19 @@ var my = {};
// The primary view for the entire application.
//
// To pass in configuration options use the config key in initialization hash
// e.g.
//
// var explorer = new DataExplorer({
// config: {...}
// })
//
// Config 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.
my.DataExplorer = Backbone.View.extend({
tagName: 'div',
@@ -47,7 +60,11 @@ my.DataExplorer = Backbone.View.extend({
this.config = options.config || {};
_.extend(this.config, {
displayCount: 10
, readOnly: false
});
if (this.config.readOnly) {
this.setReadOnly();
}
this.draw();
},
@@ -79,6 +96,10 @@ my.DataExplorer = Backbone.View.extend({
});
},
setReadOnly: function() {
this.el.addClass('read-only');
},
render: function() {
var tmplData = this.model.toTemplateJSON();
tmplData.displayCount = this.config.displayCount;