Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
backbone.overview
Advanced tools
Readme
This package provides two new types of Backbone Views.
An Overview is a View that references and keeps track of sub-views (i.e. just normal Backbone.Views) Kind of like what a Collection is to a Model.
An Overview provides methods for handling the views it keeps track of:
An OrderedListView is a special type of Overview which handles the case where you have a list of items that need to be presented in a certain order.
The order is determined by your Overview's comparator attribute or method.
The OrderedListView relies on a few conventions and then has three attributes which you set in order to configure it for your usecase.
These are:
listItems
(Default value 'model'
)
The listItems
attribute denotes the path (from this View) to the
list of items. This list must be a Backbone.Collection.sortEvent
(Default value 'change'
)
The sortEvent
attribute specifies the event which should cause the
ordered list to be sorted.listSelector
(Default value '.ordered-items'
)
The listSelector
is the selector used to query for the DOM list
element which contains the ordered items.ItemView
(Default value undefined
)
The itemView
is constructor which should be called to create a
View for a new item to be rendered in the list.When an item changes, as defined by the sortEvent
, then the OrderedListView
will automatically sort the list and rerender the items in order.
When new items are added to the Backbone.Collection specified by listItems
,
then the OrderedListView will automatically add a new View for that item (as
specified by ItemView
) and insert it into the ordered list.
Include Backbone.Overview after having included Backbone.js:
<script type="text/javascript" src="backbone.js"></script>
<script type="text/javascript" src="backbone.overview.js"></script>
Create your overview like this:
this.RosterView = Backbone.Overview.extend({
// ... same customizations as you would make for a normal Backbone.View
});
You can use the usual underscore methdods, like you can with Backbone Collections.
For example:
this.rosterview = new this.RosterView();
this.rosterview.add(new Backbone.View({model: new Backbone.Model()));
this.rosterview.each(function (view) {
// Do something
});
this.RosterView = Backbone.OrderedListView.extend({
// The `listItems` attribute denotes the path (from this View) to the
// list of items.
listItems: 'model',
// The `sortEvent` attribute specifies the event which should cause the
// ordered list to be sorted.
sortEvent: 'change',
// The `listSelector` is the selector used to query for the DOM list
// element which contains the ordered items.
listSelector: '.ordered-items',
// The `itemView` is constructor which should be called to create a
// View for a new item.
ItemView: undefined,
// The `subviewIndex` is the attribute of the list element model which
// acts as the index of the subview in the overview.
// An overview is a "Collection" of views, and they can be retrieved
// via an index. By default this is the 'id' attribute, but it could be
// set to something else.
subviewIndex: 'id',
initialize () {
Backbone.OrderedListView.prototype.initialize.apply(this, arguments);
}
});
Include RequireJS:
<script type="text/javascript" src="lib/require.js"></script>
RequireJS config:
require.config({
paths: {
jquery: "lib/jquery",
underscore: "lib/underscore",
backbone: "lib/backbone",
backbone.overview: "lib/backbone.overview"
}
});
define(["backbone.overview"], function() {
this.RosterView = Backbone.Overview.extend({
// ... same customizations as you would make for a normal Backbone.View
});
});
Backbone can be used without jQuery by using Backbone.NativeView instead of Backbone.View.
If Backbone.NativeView is available, then the Overview and OrderedListView will use that instead of Backbone.View.
Overviews and OrderedListViews are used in converse.js
FAQs
An Overview is a View that contains and keeps track of sub-views. Kind of like what a Collection is to a Model.
The npm package backbone.overview receives a total of 18 weekly downloads. As such, backbone.overview popularity was classified as not popular.
We found that backbone.overview demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.