Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict';
import {Collection, Model} from 'backbone';
import ClientError from 'background/model/clientError';
var ClientErrors = Collection.extend({
model: ClientError,
url: function() {
return StreamusBG.serverUrl + 'ClientError/';
},
// Don't allow duplicate ClientErrors by stack + lineNumber.
add: function(clientError) {
var isAddingModel = clientError instanceof Model;
var lineNumber = isAddingModel ? clientError.get('lineNumber') : clientError.lineNumber;
var stack = isAddingModel ? clientError.get('stack') : clientError.stack;
var hasDuplicate = this._hasDuplicate(lineNumber, stack);
return hasDuplicate ? false : Collection.prototype.add.apply(this, arguments);
},
import {Collection} from 'backbone';
import CollectionMultiSelect from 'background/mixin/collectionMultiSelect';
import SearchResult from 'background/model/searchResult';
var SearchResults = Collection.extend({
model: SearchResult,
mixins: [CollectionMultiSelect],
// SearchResults are unable to be destroyed by 'Delete' actions because they don't exist in a mutable collection.
isImmutable: true,
userFriendlyName: chrome.i18n.getMessage('searchResults'),
addVideos: function(videos) {
if (videos.length > 0) {
var searchResults = this._mapVideosAsSearchResults(videos);
this.add(searchResults);
// Emit a custom event signaling items have been added.
// Useful for not responding to add until all items have been added.
this.trigger('add:completed', this);
}
},
import {Collection} from 'backbone';
import Model from './model';
export default Collection.extend({
model: Model
});
'use strict';
import {Collection} from 'backbone';
import Checkbox from 'foreground/model/element/checkbox';
var Checkboxes = Collection.extend({
model: Checkbox,
isChecked: function(property) {
return this.findWhere({
property: property
}).get('checked');
}
});
export default Checkboxes;
import { Collection } from 'backbone';
import Snackbar from './snackbar.js';
export default Collection.extend({
model: Snackbar
});
import {Collection} from 'backbone';
import Model from './model';
export default Collection.extend({
url: '/api/books',
model: Model
});
import {Collection} from 'backbone';
import {Notification} from '../models/notification';
export const NotificationList = Collection.extend({
model: Notification,
addSuccessMsg: function(msg) {
this.add({
alert_text: msg,
alert_type: 'success'
});
},
addErrorMsg: function(msg) {
this.add({
alert_text: msg,
alert_type: 'error'
});
},
import _ from 'underscore';
const Collection = require('backbone').Collection;
import Config from '../../Config';
import PlaylistItemModel from './../models/PlaylistItemModel';
const PlaylistItems = Collection.extend({
model: PlaylistItemModel,
url() {
return Config.endpoints.playlistItems + '?playlistId=' + this._playlistId;
},
setPlaylistId(val) {
this._playlistId = val;
},
/** @returns {PlaylistListItem} */
getNextPlaylistItem(videoId) {
const model = this.getCurrentPlaylistItem(videoId);
const index = this.indexOf(model) + 1;
'use strict';
import {Collection} from 'backbone';
import SimpleListItem from 'foreground/model/element/simpleListItem';
var SimpleListItems = Collection.extend({
model: SimpleListItem
});
export default SimpleListItems;
import _ from 'underscore';
import $ from 'jquery';
import {Collection} from 'backbone';
import Config from '../../../Config';
import PlaylistModel from './Playlist';
const defaultResults = 24;
/**
* @class PlaylistsCollection
*/
const Playlists = Collection.extend({
model: PlaylistModel,
comparator: 'title',
_playlistIds: [],
_displayResults: defaultResults,
url() {
let param = '';
if (this._playlistIds.length) {
param = '?' +
$.param([
{ name: 'id', value: this._playlistIds.join(',') }
]);