Skip to content

Commit 3eb22a1

Browse files
committed
Merge pull request #54 from 10gen/lazy-doc-viewer
performance improvements
2 parents cf4af66 + 61755b7 commit 3eb22a1

File tree

3 files changed

+36
-43
lines changed

3 files changed

+36
-43
lines changed

scout-ui/src/field-list/type-list-item.js

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ var $ = require('jquery');
33
var format = require('util').format;
44
var _ = require('underscore');
55
var numeral = require('numeral');
6+
var debug = require('debug')('scout-ui:field-list:type-list-item');
67

78
require('bootstrap/js/tooltip');
89

@@ -19,16 +20,6 @@ module.exports = AmpersandView.extend({
1920
}
2021
}
2122
],
22-
'model.probability': [
23-
{
24-
hook: 'bar',
25-
type: function(el) {
26-
$(el).css({
27-
width: Math.floor(this.model.probability * 100) + '%'
28-
});
29-
}
30-
}
31-
]
3223
},
3324
events: {
3425
'click .schema-field-wrapper': 'typeClicked'
@@ -46,6 +37,9 @@ module.exports = AmpersandView.extend({
4637
$(this.el).tooltip({
4738
title: format('%s (%s)', this.model.getId(), numeral(this.model.probability).format('%'))
4839
});
40+
$(this.queryByHook('bar')).css({
41+
width: Math.floor(this.model.probability * 100) + '%'
42+
});
4943
}.bind(this), 300));
5044
},
5145
template: require('./type-list-item.jade'),
@@ -54,6 +48,9 @@ module.exports = AmpersandView.extend({
5448
if (!fieldList.minichartModel || (fieldList.minichartModel.modelType !== this.model.modelType)) {
5549
fieldList.switchView(this.model);
5650
}
51+
},
52+
render: function() {
53+
this.renderWithTemplate(this);
54+
return this;
5755
}
58-
5956
});

scout-ui/src/home/collection.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,10 @@ module.exports = AmpersandView.extend({
6262
hook: 'stats-subview',
6363
prepareView: function(el) {
6464
return new CollectionStatsView({
65-
el: el,
66-
parent: this,
67-
model: this.model
68-
});
65+
el: el,
66+
parent: this,
67+
model: this.model
68+
});
6969
}
7070
},
7171
fields: {
@@ -84,21 +84,21 @@ module.exports = AmpersandView.extend({
8484
hook: 'refine-bar',
8585
prepareView: function(el) {
8686
return new RefineBarView({
87-
el: el,
88-
parent: this,
89-
model: app.queryOptions
90-
});
87+
el: el,
88+
parent: this,
89+
model: app.queryOptions
90+
});
9191
}
9292
},
9393
documents: {
94-
waitFor: 'model.documents',
94+
waitFor: 'open',
9595
hook: 'documents-subview',
9696
prepareView: function(el) {
9797
return new DocumentListView({
98-
el: el,
99-
parent: this,
100-
collection: this.model.documents
101-
});
98+
el: el,
99+
parent: this,
100+
collection: this.model.documents
101+
});
102102
}
103103
}
104104
}

scout-ui/src/minicharts/viz.js

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,6 @@ module.exports = AmpersandView.extend({
5151
},
5252

5353
initialize: function(opts) {
54-
if (this.model !== undefined) {
55-
this.listenTo(this.model, 'change', this.redraw);
56-
}
5754

5855
if (this.width === 'auto' || this.width === undefined) {
5956
this._autoWidth = true;
@@ -134,23 +131,22 @@ module.exports = AmpersandView.extend({
134131
});
135132
}
136133
return this;
137-
},
138-
139-
redraw: function() {
140-
this._chooseDataSource();
141-
this.data = this.transform(this.data);
142-
143-
this._measure();
144-
145-
if (this.vizFn) {
146-
this.vizFn({
147-
width: this.width,
148-
height: this.height,
149-
data: this.data,
150-
el: this.el,
151-
});
152-
}
153134
}
135+
// redraw: function() {
136+
// this._chooseDataSource();
137+
// this.data = this.transform(this.data);
138+
//
139+
// this._measure();
140+
//
141+
// if (this.vizFn) {
142+
// this.vizFn({
143+
// width: this.width,
144+
// height: this.height,
145+
// data: this.data,
146+
// el: this.el,
147+
// });
148+
// }
149+
// }
154150
});
155151

156152
/**

0 commit comments

Comments
 (0)