Update Marionette.js to v2.3.0

This commit is contained in:
Dmitriy Simushev 2014-12-18 12:57:44 +00:00
parent bcd2bb9242
commit a72a602120
22 changed files with 48 additions and 47 deletions

File diff suppressed because one or more lines are too long

View File

@ -28,7 +28,7 @@
* Default item view constructor. * Default item view constructor.
* @type Function * @type Function
*/ */
itemView: Mibew.Views.Message, childView: Mibew.Views.Message,
/** /**
* Class name for view's DOM element * Class name for view's DOM element

View File

@ -28,7 +28,7 @@
* Default item view constructor. * Default item view constructor.
* @type Function * @type Function
*/ */
itemView: Mibew.Views.Status, childView: Mibew.Views.Status,
/** /**
* Class name for view's DOM element * Class name for view's DOM element

View File

@ -21,7 +21,7 @@
/** /**
* Represents chat layout * Represents chat layout
*/ */
Mibew.Layouts.Chat = Backbone.Marionette.Layout.extend( Mibew.Layouts.Chat = Backbone.Marionette.LayoutView.extend(
/** @lends Mibew.Layouts.Chat.prototype */ /** @lends Mibew.Layouts.Chat.prototype */
{ {
/** /**
@ -39,7 +39,7 @@
avatarRegion: '#avatar-region', avatarRegion: '#avatar-region',
messagesRegion: { messagesRegion: {
selector: '#messages-region', selector: '#messages-region',
regionType: Mibew.Regions.Messages regionClass: Mibew.Regions.Messages
}, },
statusRegion: '#status-region', statusRegion: '#status-region',
messageFormRegion: '#message-form-region' messageFormRegion: '#message-form-region'

View File

@ -21,7 +21,7 @@
/** /**
* Represents invitation layout * Represents invitation layout
*/ */
Mibew.Layouts.Invitation = Backbone.Marionette.Layout.extend( Mibew.Layouts.Invitation = Backbone.Marionette.LayoutView.extend(
/** @lends Mibew.Layouts.Invitation.prototype */ /** @lends Mibew.Layouts.Invitation.prototype */
{ {
/** /**
@ -37,7 +37,7 @@
regions: { regions: {
messagesRegion: { messagesRegion: {
selector: '#invitation-messages-region', selector: '#invitation-messages-region',
regionType: Mibew.Regions.Messages regionClass: Mibew.Regions.Messages
} }
} }
} }

View File

@ -21,7 +21,7 @@
/** /**
* Represents leave message page layout * Represents leave message page layout
*/ */
Mibew.Layouts.LeaveMessage = Backbone.Marionette.Layout.extend( Mibew.Layouts.LeaveMessage = Backbone.Marionette.LayoutView.extend(
/** @lends Mibew.Layouts.LeaveMessage.prototype */ /** @lends Mibew.Layouts.LeaveMessage.prototype */
{ {
/** /**

View File

@ -21,7 +21,7 @@
/** /**
* Represents survey layout * Represents survey layout
*/ */
Mibew.Layouts.Survey = Backbone.Marionette.Layout.extend( Mibew.Layouts.Survey = Backbone.Marionette.LayoutView.extend(
/** @lends Mibew.Layouts.Survey.prototype */ /** @lends Mibew.Layouts.Survey.prototype */
{ {
/** /**

View File

@ -254,7 +254,7 @@
// Add module finalizer // Add module finalizer
chat.addFinalizer(function() { chat.addFinalizer(function() {
// Close layout // Close layout
Mibew.Objects.chatLayout.close(); Mibew.Objects.chatLayout.destroy();
// Stop call functions periodically // Stop call functions periodically

View File

@ -95,7 +95,7 @@
// Add module finalizer // Add module finalizer
invitation.addFinalizer(function() { invitation.addFinalizer(function() {
// Close layout // Close layout
Mibew.Objects.invitationLayout.close(); Mibew.Objects.invitationLayout.destroy();
// Stop call functions periodically // Stop call functions periodically

View File

@ -58,8 +58,8 @@
// When message sent form should be hide and description should be // When message sent form should be hide and description should be
// changed // changed
models.leaveMessageForm.on('submit:complete', function() { models.leaveMessageForm.on('submit:complete', function() {
objs.leaveMessageLayout.leaveMessageFormRegion.close(); objs.leaveMessageLayout.leaveMessageFormRegion.empty();
objs.leaveMessageLayout.descriptionRegion.close(); objs.leaveMessageLayout.descriptionRegion.empty();
objs.leaveMessageLayout.descriptionRegion.show( objs.leaveMessageLayout.descriptionRegion.show(
new Mibew.Views.LeaveMessageSentDescription() new Mibew.Views.LeaveMessageSentDescription()
@ -71,7 +71,7 @@
// Add module finalizer // Add module finalizer
leaveMessage.addFinalizer(function() { leaveMessage.addFinalizer(function() {
// Close layout // Close layout
Mibew.Objects.leaveMessageLayout.close(); Mibew.Objects.leaveMessageLayout.destroy();
// Remove instance of leaveMessage form model // Remove instance of leaveMessage form model
delete Mibew.Objects.Models.leaveMessageForm; delete Mibew.Objects.Models.leaveMessageForm;

View File

@ -50,7 +50,7 @@
// Add module finalizer // Add module finalizer
survey.addFinalizer(function() { survey.addFinalizer(function() {
// Close layout // Close layout
Mibew.Objects.surveyLayout.close(); Mibew.Objects.surveyLayout.destroy();
// Remove instance of survey form model // Remove instance of survey form model
delete Mibew.Objects.Models.surveyForm; delete Mibew.Objects.Models.surveyForm;

View File

@ -26,11 +26,11 @@
{ {
/** /**
* Show view event handler. Register handler to view's * Show view event handler. Register handler to view's
* 'after:item:added' event. * 'add:child' event.
* @param {Backbone.Marionette.ItemView} view View to show in region * @param {Backbone.Marionette.ItemView} view View to show in region
*/ */
onShow: function(view) { onShow: function(view) {
view.on('after:item:added', this.scrollToBottom, this); view.on('add:child', this.scrollToBottom, this);
}, },
/** /**

View File

@ -24,22 +24,22 @@
* Mibew.Views.CompositeBase * Mibew.Views.CompositeBase
* @private * @private
* @param {Backbone.Model} item Collection item * @param {Backbone.Model} item Collection item
* @param {Function} ItemViewType Default item view constructor * @param {Function} ChildViewType Default item view constructor
* @param {Object} itemViewOptions Additional item view options * @param {Object} childViewOptions Additional item view options
* @returns Item view instance * @returns Item view instance
*/ */
var buildItemView = function(item, ItemViewType, itemViewOptions) { var buildChildView = function(item, ChildViewType, childViewOptions) {
// Build options object // Build options object
var options = _.extend({model: item}, itemViewOptions); var options = _.extend({model: item}, childViewOptions);
// Try to find special view for this model // Try to find special view for this model
if (typeof item.getModelType != 'function') { if (typeof item.getModelType != 'function') {
return new ItemViewType(options); return new ChildViewType(options);
} }
var modelType = item.getModelType(); var modelType = item.getModelType();
if (modelType && Mibew.Views[modelType]) { if (modelType && Mibew.Views[modelType]) {
return new Mibew.Views[modelType](options); return new Mibew.Views[modelType](options);
} else { } else {
return new ItemViewType(options); return new ChildViewType(options);
} }
} }
@ -53,13 +53,13 @@
* Default item view constructor. * Default item view constructor.
* @type Function * @type Function
*/ */
itemView: Backbone.Marionette.ItemView, childView: Backbone.Marionette.ItemView,
/** /**
* Return special contructor for an item view if it exists or the * Return special contructor for an item view if it exists or the
* default constructor otherwise. * default constructor otherwise.
*/ */
buildItemView: buildItemView buildChildView: buildChildView
} }
); );
@ -70,7 +70,7 @@
* Return special contructor for an item view if it exists or the * Return special contructor for an item view if it exists or the
* default constructor otherwise. * default constructor otherwise.
*/ */
buildItemView: buildItemView buildChildView: buildChildView
} }
); );

View File

@ -28,7 +28,7 @@
* Default item view constructor. * Default item view constructor.
* @type Function * @type Function
*/ */
itemView: Mibew.Views.Control, childView: Mibew.Views.Control,
/** /**
* Class name for view's DOM element * Class name for view's DOM element

View File

@ -28,7 +28,7 @@
* Default item view constructor. * Default item view constructor.
* @type Function * @type Function
*/ */
itemView: Mibew.Views.Message, childView: Mibew.Views.Message,
/** /**
* Class name for view's DOM element * Class name for view's DOM element

View File

@ -28,7 +28,7 @@
* Default item view constructor. * Default item view constructor.
* @type Function * @type Function
*/ */
itemView: Mibew.Views.Agent, childView: Mibew.Views.Agent,
/** /**
* Class name for view's DOM element * Class name for view's DOM element
@ -49,7 +49,7 @@
*/ */
initialize: function() { initialize: function() {
// Register events // Register events
this.on('itemview:before:render', this.updateIndexes, this); this.on('childview:before:render', this.updateIndexes, this);
}, },
/** /**

View File

@ -30,13 +30,13 @@
* Default item view constructor. * Default item view constructor.
* @type Function * @type Function
*/ */
itemView: Mibew.Views.QueuedThread, childView: Mibew.Views.QueuedThread,
/** /**
* DOM element for collection items * DOM element for collection items
* @type String * @type String
*/ */
itemViewContainer: '#threads-container', childViewContainer: '#threads-container',
/** /**
* Empty view constructor. * Empty view constructor.
@ -64,7 +64,7 @@
* Pass some options to item view * Pass some options to item view
* @returns {Object} Options object * @returns {Object} Options object
*/ */
itemViewOptions: function(model) { childViewOptions: function(model) {
var page = Mibew.Objects.Models.page; var page = Mibew.Objects.Models.page;
return { return {
tagName: page.get('threadTag'), tagName: page.get('threadTag'),
@ -79,8 +79,8 @@
// Update time in timers // Update time in timers
window.setInterval(_.bind(this.updateTimers, this), 2 * 1000); window.setInterval(_.bind(this.updateTimers, this), 2 * 1000);
// Register events // Register events
this.on('itemview:before:render', this.updateStyles, this); this.on('childview:before:render', this.updateStyles, this);
this.on('composite:collection:rendered', this.updateTimers, this); this.on('render:collection', this.updateTimers, this);
}, },
/** /**

View File

@ -30,13 +30,13 @@
* Default item view constructor. * Default item view constructor.
* @type Function * @type Function
*/ */
itemView: Mibew.Views.Visitor, childView: Mibew.Views.Visitor,
/** /**
* DOM element for collection items * DOM element for collection items
* @type String * @type String
*/ */
itemViewContainer: '#visitors-container', childViewContainer: '#visitors-container',
/** /**
* Empty view constructor. * Empty view constructor.
@ -62,7 +62,7 @@
* Pass some options to item view * Pass some options to item view
* @returns {Object} Options object * @returns {Object} Options object
*/ */
itemViewOptions: function(model) { childViewOptions: function(model) {
var page = Mibew.Objects.Models.page; var page = Mibew.Objects.Models.page;
return { return {
tagName: page.get('visitorTag'), tagName: page.get('visitorTag'),
@ -77,7 +77,7 @@
// Update time in timers // Update time in timers
window.setInterval(_.bind(this.updateTimers, this), 2 * 1000); window.setInterval(_.bind(this.updateTimers, this), 2 * 1000);
// Register events // Register events
this.on('composite:collection:rendered', this.updateTimers, this); this.on('render:collection', this.updateTimers, this);
}, },
/** /**

View File

@ -33,7 +33,7 @@
/** /**
* View initializer * View initializer
* @param {Object} options Options object passed from * @param {Object} options Options object passed from
* {@link Mibew.Views.ThreadsCollection.prototype.itemViewOptions} * {@link Mibew.Views.ThreadsCollection.prototype.childViewOptions}
*/ */
initialize: function(options) { initialize: function(options) {
this.tagName = options.tagName; this.tagName = options.tagName;

View File

@ -33,7 +33,7 @@
/** /**
* View initializer * View initializer
* @param {Object} options Options object passed from * @param {Object} options Options object passed from
* {@link Mibew.Views.VisitorsCollection.prototype.itemViewOptions} * {@link Mibew.Views.VisitorsCollection.prototype.childViewOptions}
*/ */
initialize: function(options) { initialize: function(options) {
this.tagName = options.tagName; this.tagName = options.tagName;

View File

@ -34,13 +34,13 @@
* Default item view constructor. * Default item view constructor.
* @type Function * @type Function
*/ */
itemView: Mibew.Views.Control, childView: Mibew.Views.Control,
/** /**
* DOM element for collection items * DOM element for collection items
* @type String * @type String
*/ */
itemViewContainer: '.thread-controls', childViewContainer: '.thread-controls',
/** /**
* CSS class name for view's DOM element * CSS class name for view's DOM element

View File

@ -34,13 +34,13 @@
* Default item view constructor. * Default item view constructor.
* @type Function * @type Function
*/ */
itemView: Mibew.Views.Control, childView: Mibew.Views.Control,
/** /**
* DOM element for collection items * DOM element for collection items
* @type String * @type String
*/ */
itemViewContainer: '.visitor-controls', childViewContainer: '.visitor-controls',
/** /**
* CSS class name for view's DOM element * CSS class name for view's DOM element