[build][xs]: regular build of recline.js.
This commit is contained in:
56
recline.js
56
recline.js
@@ -285,7 +285,8 @@ my.DocumentList = Backbone.Collection.extend({
|
|||||||
// * format: (optional) used to indicate how the data should be formatted. For example:
|
// * format: (optional) used to indicate how the data should be formatted. For example:
|
||||||
// * type=date, format=yyyy-mm-dd
|
// * type=date, format=yyyy-mm-dd
|
||||||
// * type=float, format=percentage
|
// * type=float, format=percentage
|
||||||
// * type=float, format='###,###.##'
|
// * type=string, format=link (render as hyperlink)
|
||||||
|
// * type=string, format=markdown (render as markdown if Showdown available)
|
||||||
// * is_derived: (default: false) attribute indicating this field has no backend data but is just derived from other fields (see below).
|
// * is_derived: (default: false) attribute indicating this field has no backend data but is just derived from other fields (see below).
|
||||||
//
|
//
|
||||||
// Following additional instance properties:
|
// Following additional instance properties:
|
||||||
@@ -341,6 +342,22 @@ my.Field = Backbone.Model.extend({
|
|||||||
if (format === 'percentage') {
|
if (format === 'percentage') {
|
||||||
return val + '%';
|
return val + '%';
|
||||||
}
|
}
|
||||||
|
return val;
|
||||||
|
},
|
||||||
|
'string': function(val, field, doc) {
|
||||||
|
var format = field.get('format');
|
||||||
|
if (format === 'link') {
|
||||||
|
return '<a href="VAL">VAL</a>'.replace(/VAL/g, val);
|
||||||
|
} else if (format === 'markdown') {
|
||||||
|
if (typeof Showdown !== 'undefined') {
|
||||||
|
var showdown = new Showdown.converter();
|
||||||
|
out = showdown.makeHtml(val);
|
||||||
|
return out;
|
||||||
|
} else {
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -1626,9 +1643,12 @@ my.Map = Backbone.View.extend({
|
|||||||
|
|
||||||
if (!(docs instanceof Array)) docs = [docs];
|
if (!(docs instanceof Array)) docs = [docs];
|
||||||
|
|
||||||
|
var count = 0;
|
||||||
|
var wrongSoFar = 0;
|
||||||
_.every(docs,function(doc){
|
_.every(docs,function(doc){
|
||||||
|
count += 1;
|
||||||
var feature = self._getGeometryFromDocument(doc);
|
var feature = self._getGeometryFromDocument(doc);
|
||||||
if (typeof feature === 'undefined'){
|
if (typeof feature === 'undefined' || feature === null){
|
||||||
// Empty field
|
// Empty field
|
||||||
return true;
|
return true;
|
||||||
} else if (feature instanceof Object){
|
} else if (feature instanceof Object){
|
||||||
@@ -1647,14 +1667,18 @@ my.Map = Backbone.View.extend({
|
|||||||
try {
|
try {
|
||||||
self.features.addGeoJSON(feature);
|
self.features.addGeoJSON(feature);
|
||||||
} catch (except) {
|
} catch (except) {
|
||||||
|
wrongSoFar += 1;
|
||||||
var msg = 'Wrong geometry value';
|
var msg = 'Wrong geometry value';
|
||||||
if (except.message) msg += ' (' + except.message + ')';
|
if (except.message) msg += ' (' + except.message + ')';
|
||||||
|
if (wrongSoFar <= 10) {
|
||||||
my.notify(msg,{category:'error'});
|
my.notify(msg,{category:'error'});
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
wrongSoFar += 1
|
||||||
|
if (wrongSoFar <= 10) {
|
||||||
my.notify('Wrong geometry value',{category:'error'});
|
my.notify('Wrong geometry value',{category:'error'});
|
||||||
return false;
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
@@ -1687,6 +1711,9 @@ my.Map = Backbone.View.extend({
|
|||||||
return doc.attributes[this.state.get('geomField')];
|
return doc.attributes[this.state.get('geomField')];
|
||||||
} else if (this.state.get('lonField') && this.state.get('latField')){
|
} else if (this.state.get('lonField') && this.state.get('latField')){
|
||||||
// We'll create a GeoJSON like point object from the two lat/lon fields
|
// We'll create a GeoJSON like point object from the two lat/lon fields
|
||||||
|
var lon = doc.get(this.state.get('lonField'));
|
||||||
|
var lat = doc.get(this.state.get('latField'));
|
||||||
|
if (lon && lat) {
|
||||||
return {
|
return {
|
||||||
type: 'Point',
|
type: 'Point',
|
||||||
coordinates: [
|
coordinates: [
|
||||||
@@ -1695,6 +1722,7 @@ my.Map = Backbone.View.extend({
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@@ -1705,12 +1733,16 @@ my.Map = Backbone.View.extend({
|
|||||||
// If not found, the user can define them via the UI form.
|
// If not found, the user can define them via the UI form.
|
||||||
_setupGeometryField: function(){
|
_setupGeometryField: function(){
|
||||||
var geomField, latField, lonField;
|
var geomField, latField, lonField;
|
||||||
|
this.geomReady = (this.state.get('geomField') || (this.state.get('latField') && this.state.get('lonField')));
|
||||||
|
// should not overwrite if we have already set this (e.g. explicitly via state)
|
||||||
|
if (!this.geomReady) {
|
||||||
this.state.set({
|
this.state.set({
|
||||||
geomField: this._checkField(this.geometryFieldNames),
|
geomField: this._checkField(this.geometryFieldNames),
|
||||||
latField: this._checkField(this.latitudeFieldNames),
|
latField: this._checkField(this.latitudeFieldNames),
|
||||||
lonField: this._checkField(this.longitudeFieldNames)
|
lonField: this._checkField(this.longitudeFieldNames)
|
||||||
});
|
});
|
||||||
this.geomReady = (this.state.get('geomField') || (this.state.get('latField') && this.state.get('lonField')));
|
this.geomReady = (this.state.get('geomField') || (this.state.get('latField') && this.state.get('lonField')));
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
// Private: Check if a field in the current model exists in the provided
|
// Private: Check if a field in the current model exists in the provided
|
||||||
@@ -2172,8 +2204,8 @@ my.DataExplorer = Backbone.View.extend({
|
|||||||
initialize: function(options) {
|
initialize: function(options) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.el = $(this.el);
|
this.el = $(this.el);
|
||||||
// Hash of 'page' views (i.e. those for whole page) keyed by page name
|
|
||||||
this._setupState(options.state);
|
this._setupState(options.state);
|
||||||
|
// Hash of 'page' views (i.e. those for whole page) keyed by page name
|
||||||
if (options.views) {
|
if (options.views) {
|
||||||
this.pageViews = options.views;
|
this.pageViews = options.views;
|
||||||
} else {
|
} else {
|
||||||
@@ -2772,6 +2804,13 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
// backends (see recline.Model.Dataset.initialize).
|
// backends (see recline.Model.Dataset.initialize).
|
||||||
__type__: 'base',
|
__type__: 'base',
|
||||||
|
|
||||||
|
|
||||||
|
// ### readonly
|
||||||
|
//
|
||||||
|
// Class level attribute indicating that this backend is read-only (that
|
||||||
|
// is, cannot be written to).
|
||||||
|
readonly: true,
|
||||||
|
|
||||||
// ### sync
|
// ### sync
|
||||||
//
|
//
|
||||||
// An implementation of Backbone.sync that will be used to override
|
// An implementation of Backbone.sync that will be used to override
|
||||||
@@ -2891,6 +2930,7 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
// Note that this is a **read-only** backend.
|
// Note that this is a **read-only** backend.
|
||||||
my.DataProxy = my.Base.extend({
|
my.DataProxy = my.Base.extend({
|
||||||
__type__: 'dataproxy',
|
__type__: 'dataproxy',
|
||||||
|
readonly: true,
|
||||||
defaults: {
|
defaults: {
|
||||||
dataproxy_url: 'http://jsonpdataproxy.appspot.com'
|
dataproxy_url: 'http://jsonpdataproxy.appspot.com'
|
||||||
},
|
},
|
||||||
@@ -2970,6 +3010,7 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
// <pre>http://localhost:9200/twitter/tweet</pre>
|
// <pre>http://localhost:9200/twitter/tweet</pre>
|
||||||
my.ElasticSearch = my.Base.extend({
|
my.ElasticSearch = my.Base.extend({
|
||||||
__type__: 'elasticsearch',
|
__type__: 'elasticsearch',
|
||||||
|
readonly: true,
|
||||||
_getESUrl: function(dataset) {
|
_getESUrl: function(dataset) {
|
||||||
var out = dataset.get('elasticsearch_url');
|
var out = dataset.get('elasticsearch_url');
|
||||||
if (out) return out;
|
if (out) return out;
|
||||||
@@ -3088,6 +3129,7 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
// </pre>
|
// </pre>
|
||||||
my.GDoc = my.Base.extend({
|
my.GDoc = my.Base.extend({
|
||||||
__type__: 'gdoc',
|
__type__: 'gdoc',
|
||||||
|
readonly: true,
|
||||||
getUrl: function(dataset) {
|
getUrl: function(dataset) {
|
||||||
var url = dataset.get('url');
|
var url = dataset.get('url');
|
||||||
if (url.indexOf('feeds/list') != -1) {
|
if (url.indexOf('feeds/list') != -1) {
|
||||||
@@ -3450,6 +3492,7 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
// </pre>
|
// </pre>
|
||||||
my.Memory = my.Base.extend({
|
my.Memory = my.Base.extend({
|
||||||
__type__: 'memory',
|
__type__: 'memory',
|
||||||
|
readonly: false,
|
||||||
initialize: function() {
|
initialize: function() {
|
||||||
this.datasets = {};
|
this.datasets = {};
|
||||||
},
|
},
|
||||||
@@ -3537,7 +3580,8 @@ this.recline.Backend = this.recline.Backend || {};
|
|||||||
_.each(terms, function(term) {
|
_.each(terms, function(term) {
|
||||||
var foundmatch = false;
|
var foundmatch = false;
|
||||||
dataset.fields.each(function(field) {
|
dataset.fields.each(function(field) {
|
||||||
var value = rawdoc[field.id].toString();
|
var value = rawdoc[field.id];
|
||||||
|
if (value !== null) { value = value.toString(); }
|
||||||
// TODO regexes?
|
// TODO regexes?
|
||||||
foundmatch = foundmatch || (value === term);
|
foundmatch = foundmatch || (value === term);
|
||||||
// TODO: early out (once we are true should break to spare unnecessary testing)
|
// TODO: early out (once we are true should break to spare unnecessary testing)
|
||||||
|
|||||||
Reference in New Issue
Block a user