mirror of
https://github.com/Mibew/mibew.git
synced 2025-01-31 13:24:41 +03:00
Provide easy way to override views in JS application
This commit is contained in:
parent
210e82e798
commit
964e917f4a
@ -24,17 +24,25 @@
|
|||||||
Mibew.Views.MessagesCollection = Mibew.Views.CollectionBase.extend(
|
Mibew.Views.MessagesCollection = Mibew.Views.CollectionBase.extend(
|
||||||
/** @lends Mibew.Views.MessagesCollection.prototype */
|
/** @lends Mibew.Views.MessagesCollection.prototype */
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Default item view constructor.
|
|
||||||
* @type Function
|
|
||||||
*/
|
|
||||||
childView: Mibew.Views.Message,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class name for view's DOM element
|
* Class name for view's DOM element
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
className: 'messages-collection'
|
className: 'messages-collection',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns default child view constructor.
|
||||||
|
*
|
||||||
|
* The function is used instead of "childView" property to provide
|
||||||
|
* an ability to override child view constructor without this class
|
||||||
|
* overriding.
|
||||||
|
*
|
||||||
|
* @param {Backbone.Model} model The model the view created for.
|
||||||
|
* @returns {Backbone.Marionette.ItemView}
|
||||||
|
*/
|
||||||
|
getChildView: function(model) {
|
||||||
|
return Mibew.Views.Message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -24,17 +24,25 @@
|
|||||||
Mibew.Views.StatusCollection = Mibew.Views.CollectionBase.extend(
|
Mibew.Views.StatusCollection = Mibew.Views.CollectionBase.extend(
|
||||||
/** @lends Mibew.Views.StatusCollection.prototype */
|
/** @lends Mibew.Views.StatusCollection.prototype */
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Default item view constructor.
|
|
||||||
* @type Function
|
|
||||||
*/
|
|
||||||
childView: Mibew.Views.Status,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class name for view's DOM element
|
* Class name for view's DOM element
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
className: 'status-collection'
|
className: 'status-collection',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns default child view constructor.
|
||||||
|
*
|
||||||
|
* The function is used instead of "childView" property to provide
|
||||||
|
* an ability to override child view constructor without this class
|
||||||
|
* overriding.
|
||||||
|
*
|
||||||
|
* @param {Backbone.Model} model The model the view created for.
|
||||||
|
* @returns {Backbone.Marionette.ItemView}
|
||||||
|
*/
|
||||||
|
getChildView: function(model) {
|
||||||
|
return Mibew.Views.Status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -24,17 +24,25 @@
|
|||||||
Mibew.Views.ControlsCollection = Mibew.Views.CollectionBase.extend(
|
Mibew.Views.ControlsCollection = Mibew.Views.CollectionBase.extend(
|
||||||
/** @lends Mibew.Views.ControlsCollection.prototype */
|
/** @lends Mibew.Views.ControlsCollection.prototype */
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Default item view constructor.
|
|
||||||
* @type Function
|
|
||||||
*/
|
|
||||||
childView: Mibew.Views.Control,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class name for view's DOM element
|
* Class name for view's DOM element
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
className: 'controls-collection'
|
className: 'controls-collection',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns default child view constructor.
|
||||||
|
*
|
||||||
|
* The function is used instead of "childView" property to provide
|
||||||
|
* an ability to override child view constructor without this class
|
||||||
|
* overriding.
|
||||||
|
*
|
||||||
|
* @param {Backbone.Model} model The model the view created for.
|
||||||
|
* @returns {Backbone.Marionette.ItemView}
|
||||||
|
*/
|
||||||
|
getChildView: function(model) {
|
||||||
|
return Mibew.Views.Control;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -24,17 +24,25 @@
|
|||||||
Mibew.Views.MessagesCollection = Mibew.Views.CollectionBase.extend(
|
Mibew.Views.MessagesCollection = Mibew.Views.CollectionBase.extend(
|
||||||
/** @lends Mibew.Views.MessagesCollection.prototype */
|
/** @lends Mibew.Views.MessagesCollection.prototype */
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Default item view constructor.
|
|
||||||
* @type Function
|
|
||||||
*/
|
|
||||||
childView: Mibew.Views.Message,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class name for view's DOM element
|
* Class name for view's DOM element
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
className: 'messages-collection'
|
className: 'messages-collection',
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns default child view constructor.
|
||||||
|
*
|
||||||
|
* The function is used instead of "childView" property to provide
|
||||||
|
* an ability to override child view constructor without this class
|
||||||
|
* overriding.
|
||||||
|
*
|
||||||
|
* @param {Backbone.Model} model The model the view created for.
|
||||||
|
* @returns {Backbone.Marionette.ItemView}
|
||||||
|
*/
|
||||||
|
getChildView: function(model) {
|
||||||
|
return Mibew.Views.Message;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -24,12 +24,6 @@
|
|||||||
Mibew.Views.AgentsCollection = Mibew.Views.CollectionBase.extend(
|
Mibew.Views.AgentsCollection = Mibew.Views.CollectionBase.extend(
|
||||||
/** @lends Mibew.Views.AgentsCollection.prototype */
|
/** @lends Mibew.Views.AgentsCollection.prototype */
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Default item view constructor.
|
|
||||||
* @type Function
|
|
||||||
*/
|
|
||||||
childView: Mibew.Views.Agent,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class name for view's DOM element
|
* Class name for view's DOM element
|
||||||
* @type String
|
* @type String
|
||||||
@ -44,6 +38,20 @@
|
|||||||
'sort add remove reset': 'render'
|
'sort add remove reset': 'render'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns default child view constructor.
|
||||||
|
*
|
||||||
|
* The function is used instead of "childView" property to provide
|
||||||
|
* an ability to override child view constructor without this class
|
||||||
|
* overriding.
|
||||||
|
*
|
||||||
|
* @param {Backbone.Model} model The model the view created for.
|
||||||
|
* @returns {Backbone.Marionette.ItemView}
|
||||||
|
*/
|
||||||
|
getChildView: function(model) {
|
||||||
|
return Mibew.Views.Agent;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* View initializer
|
* View initializer
|
||||||
*/
|
*/
|
||||||
|
@ -26,24 +26,12 @@
|
|||||||
{
|
{
|
||||||
template: Handlebars.templates['users/threads_collection'],
|
template: Handlebars.templates['users/threads_collection'],
|
||||||
|
|
||||||
/**
|
|
||||||
* Default item view constructor.
|
|
||||||
* @type Function
|
|
||||||
*/
|
|
||||||
childView: Mibew.Views.QueuedThread,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DOM element for collection items
|
* DOM element for collection items
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
childViewContainer: '#threads-container',
|
childViewContainer: '#threads-container',
|
||||||
|
|
||||||
/**
|
|
||||||
* Empty view constructor.
|
|
||||||
* @type Function
|
|
||||||
*/
|
|
||||||
emptyView: Mibew.Views.NoThreads,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class name for view's DOM element
|
* Class name for view's DOM element
|
||||||
* @type String
|
* @type String
|
||||||
@ -60,6 +48,33 @@
|
|||||||
'add': 'threadAdded'
|
'add': 'threadAdded'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns default child view constructor.
|
||||||
|
*
|
||||||
|
* The function is used instead of "childView" property to provide
|
||||||
|
* an ability to override child view constructor without this class
|
||||||
|
* overriding.
|
||||||
|
*
|
||||||
|
* @param {Backbone.Model} model The model the view created for.
|
||||||
|
* @returns {Backbone.Marionette.ItemView}
|
||||||
|
*/
|
||||||
|
getChildView: function(model) {
|
||||||
|
return Mibew.Views.QueuedThread;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns empty view constructor.
|
||||||
|
*
|
||||||
|
* The function is used instead of "emptyView" property to provide
|
||||||
|
* an ability to override empty view constructor without this class
|
||||||
|
* overriding.
|
||||||
|
*
|
||||||
|
* @returns {Backbone.Marionette.ItemView}
|
||||||
|
*/
|
||||||
|
getEmptyView: function() {
|
||||||
|
return Mibew.Views.NoThreads;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass some options to item view
|
* Pass some options to item view
|
||||||
* @returns {Object} Options object
|
* @returns {Object} Options object
|
||||||
|
@ -26,24 +26,12 @@
|
|||||||
{
|
{
|
||||||
template: Handlebars.templates['users/visitors_collection'],
|
template: Handlebars.templates['users/visitors_collection'],
|
||||||
|
|
||||||
/**
|
|
||||||
* Default item view constructor.
|
|
||||||
* @type Function
|
|
||||||
*/
|
|
||||||
childView: Mibew.Views.Visitor,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DOM element for collection items
|
* DOM element for collection items
|
||||||
* @type String
|
* @type String
|
||||||
*/
|
*/
|
||||||
childViewContainer: '#visitors-container',
|
childViewContainer: '#visitors-container',
|
||||||
|
|
||||||
/**
|
|
||||||
* Empty view constructor.
|
|
||||||
* @type Function
|
|
||||||
*/
|
|
||||||
emptyView: Mibew.Views.NoVisitors,
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class name for view's DOM element
|
* Class name for view's DOM element
|
||||||
* @type String
|
* @type String
|
||||||
@ -58,6 +46,33 @@
|
|||||||
'sort': 'render'
|
'sort': 'render'
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns default child view constructor.
|
||||||
|
*
|
||||||
|
* The function is used instead of "childView" property to provide
|
||||||
|
* an ability to override child view constructor without this class
|
||||||
|
* overriding.
|
||||||
|
*
|
||||||
|
* @param {Backbone.Model} model The model the view created for.
|
||||||
|
* @returns {Backbone.Marionette.ItemView}
|
||||||
|
*/
|
||||||
|
getChildView: function(model) {
|
||||||
|
return Mibew.Views.Visitor;
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns empty view constructor.
|
||||||
|
*
|
||||||
|
* The function is used instead of "emptyView" property to provide
|
||||||
|
* an ability to override empty view constructor without this class
|
||||||
|
* overriding.
|
||||||
|
*
|
||||||
|
* @returns {Backbone.Marionette.ItemView}
|
||||||
|
*/
|
||||||
|
getEmptyView: function() {
|
||||||
|
return Mibew.Views.NoVisitors;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Pass some options to item view
|
* Pass some options to item view
|
||||||
* @returns {Object} Options object
|
* @returns {Object} Options object
|
||||||
|
Loading…
Reference in New Issue
Block a user