Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
//
// Instead of dataset.loadGeoData, ideally this would allow a call
// to the server to load the geo data rendered.
//
// girder.RestRequest({
// type: "POST"
// url: "adapter/" + dataset._id + "/" + layerType.toString()(),
// params: userInput,
// }).success(function (data){
// createLayer
// });
}
};
}
const adapterRegistry = _.extend(new AdapterRegistry(), Backbone.Events);
export default adapterRegistry;
const rendering = { geo: {} };
/**
* Utility function to define a map representation and add it to the Adapter Registry.
* @param {string} layerType - The type of map visualization used to render the dataset
* @param {rendering.geo.MapRepresentation} layerDefinition - The definition of a GeoJs layer representation
* @param {rendering.geo.MapRepresentation} [ParentDefinition] - The definition of a GeoJs layer representation,
* to be used as the constructor set as the prototype of layerDefinition
*/
rendering.geo.defineMapLayer = function (layerType, layerDefinition, ParentDefinition) {
if (ParentDefinition) {
layerDefinition.prototype = new ParentDefinition();
}
// isFetchingModel: dictionary of ids as keys and individual models as the values. Used
// when we need to make sure to fetch an individual model
//
// fetchedModels is a cache of models which have been fetched by id
this.isFetchingModel = {};
this.fetchedModels = {};
// isFetchingMore: True or false depending on whether the next page of data
// for this.models is being fetched
this.isFetchingMore = false;
this.initialize.apply(this, arguments);
};
_.extend(Store.prototype, Backbone.Events, {
// ---------------
// Event listeners
// ---------------
clearCache: function() {
this.models = null;
this.queryModels = {};
},
addChangeListener: function(callback) {
this.on(CHANGE_EVENT, callback);
},
removeChangeListener: function(callback) {
this.off(CHANGE_EVENT, callback);
},
constructor(storage, model) {
_.extend(this, Backbone.Events);
this._storage = normalizeStorage(storage);
this._data = {}; /* key: dataItem */
this._orignal = {}; /* original data array from dataStorage */
this._changedData = {}; /* primaryKey: {item, editState, onCommit} */
this._commandChain = [];
this._head = -1;
this._serverEditID = _.uniqueId('serverEditID');
this.model = model;
this._autoCommit = false;
}
// On Change their new values are pushed to the object it is tracking
this.cache = {
model: new Rebound.Model({}, lineage),
collection: new Rebound.Collection([], lineage),
value: undefined
};
// Listen to objects in the cache and push changes to them on modify
this.listenTo(this.cache.model, 'all', this.onModify);
this.listenTo(this.cache.collection, 'all', this.onModify);
this.wire();
};
_.extend(ComputedProperty.prototype, Backbone.Events, {
isComputedProperty: true,
isData: true,
__path: function(){ return ''; },
getter: NOOP,
setter: NOOP,
// If the Computed Property is not already dirty, mark it as such and trigger
// a `dirty` event.
markDirty: function(){
if(this.isDirty){ return void 0; }
this.isDirty = true;
this.trigger('dirty', this);
},
it('should contain Backbone.Events', function() {
expect(Metal.Events)
.to.contain(Backbone.Events);
});
});
this._createRepresentation = function (container, dataset, layerType, visProperties) {
if (layerType === null || !_.has(this.registry, layerType)) {
var message = 'This dataset cannot be adapted to a map layer of type [' + layerType + '].';
console.error(message);
return Promise.reject(message);
} else {
var Adapter = this.registry[layerType];
var layerRepr = _.extend(new Adapter(), Backbone.Events);
return dataset
.loadGeoData()
.then(() => {
try {
layerRepr.init(container, dataset, visProperties, dataset.get('geoData'));
return layerRepr;
} catch (err) {
throw layerRepr;
}
});
}
};
}
import Backbone from 'backbone';
import Mixin from './mixin';
/**
* A `Metal.Mixin` version of `Backbone.Events`.
*
* @mixin Events
* @memberOf Metal
* @memberOf Backbone
* @extends Metal.Mixin
* @mixes Backbone.Events
*/
const Events = new Mixin(Backbone.Events);
export default Events;
storage.set('watchlist', newList);
if(newList.length !== list.length) {
this.trigger('removed');
}
},
has(id) {
const list = this.getList();
return !!_.findWhere(list, { id });
}
};
module.exports = _.extend(watchlist, Events);
/**
* stringify a message, exposed for testing
*
* @param {String} name
* @param {Object} [data]
* @returns {String}
*/
stringify(name, data = {}) {
return JSON.stringify({
data: data,
name: name,
});
},
};
_.extend(BroadcastChannelAdapter.prototype, Backbone.Events);
export default BroadcastChannelAdapter;
uploadHandlers.s3 = function (params) {
this.params = params;
this.startByte = 0;
return _.extend(this, Backbone.Events);
};