Update stream's title and publisher's dropdown on aspect selection
This commit is contained in:
parent
8d202e481b
commit
ed4020b9b3
4 changed files with 38 additions and 9 deletions
|
|
@ -20,6 +20,6 @@ app.collections.Aspects = Backbone.Collection.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
toSentence: function(){
|
toSentence: function(){
|
||||||
return this.selectedAspects('name').join(", ").replace(/,\s([^,]+)$/, ' and $1')
|
return this.selectedAspects('name').join(", ").replace(/,\s([^,]+)$/, ' and $1') || 'My Aspects'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -97,7 +97,9 @@ app.Router = Backbone.Router.extend({
|
||||||
app.stream.fetch();
|
app.stream.fetch();
|
||||||
|
|
||||||
app.page = new app.views.Stream({model : app.stream});
|
app.page = new app.views.Stream({model : app.stream});
|
||||||
app.publisher = new app.views.Publisher({collection : app.stream.items});
|
app.publisher = app.publisher || new app.views.Publisher({collection : app.stream.items});
|
||||||
|
app.publisher.updateAspectsSelector(ids);
|
||||||
|
|
||||||
var streamFacesView = new app.views.StreamFaces({collection : app.stream.items});
|
var streamFacesView = new app.views.StreamFaces({collection : app.stream.items});
|
||||||
|
|
||||||
$("#main_stream").html(app.page.render().el);
|
$("#main_stream").html(app.page.render().el);
|
||||||
|
|
|
||||||
|
|
@ -9,11 +9,13 @@ app.views.AspectsList = app.views.Base.extend({
|
||||||
|
|
||||||
initialize: function(){
|
initialize: function(){
|
||||||
this.collection.on('change', this.toggleSelector, this);
|
this.collection.on('change', this.toggleSelector, this);
|
||||||
|
this.collection.on('change', this.updateStreamTitle, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
postRenderTemplate: function() {
|
postRenderTemplate: function() {
|
||||||
this.collection.each(this.appendAspect, this);
|
this.collection.each(this.appendAspect, this);
|
||||||
this.$('a[rel*=facebox]').facebox();
|
this.$('a[rel*=facebox]').facebox();
|
||||||
|
this.updateStreamTitle();
|
||||||
this.toggleSelector();
|
this.toggleSelector();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
@ -45,5 +47,9 @@ app.views.AspectsList = app.views.Base.extend({
|
||||||
} else {
|
} else {
|
||||||
selector.text(Diaspora.I18n.t('aspect_navigation.select_all'));
|
selector.text(Diaspora.I18n.t('aspect_navigation.select_all'));
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
updateStreamTitle: function(){
|
||||||
|
$('.stream_title').text(this.collection.toSentence());
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -21,16 +21,28 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
// update the selection summary
|
// update the selection summary
|
||||||
AspectsDropdown.updateNumber(
|
this._updateAspectsNumber(el);
|
||||||
el.closest(".dropdown_list"),
|
|
||||||
null,
|
|
||||||
el.parent().find('li.selected').length,
|
|
||||||
''
|
|
||||||
);
|
|
||||||
|
|
||||||
this._updateSelectedAspectIds();
|
this._updateSelectedAspectIds();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
updateAspectsSelector: function(ids){
|
||||||
|
var el = this.$("ul.dropdown_list");
|
||||||
|
this.$('.dropdown_list > li').each(function(){
|
||||||
|
var el = $(this);
|
||||||
|
var aspectId = el.data('aspect_id');
|
||||||
|
if (_.contains(ids, aspectId)) {
|
||||||
|
el.addClass('selected');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
el.removeClass('selected');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this._updateAspectsNumber(el);
|
||||||
|
this._updateSelectedAspectIds();
|
||||||
|
},
|
||||||
|
|
||||||
// take care of the form fields that will indicate the selected aspects
|
// take care of the form fields that will indicate the selected aspects
|
||||||
_updateSelectedAspectIds: function() {
|
_updateSelectedAspectIds: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
@ -52,6 +64,15 @@
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_updateAspectsNumber: function(el){
|
||||||
|
AspectsDropdown.updateNumber(
|
||||||
|
el.closest(".dropdown_list"),
|
||||||
|
null,
|
||||||
|
el.parent().find('li.selected').length,
|
||||||
|
''
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
_addHiddenAspectInput: function(id) {
|
_addHiddenAspectInput: function(id) {
|
||||||
var uid = _.uniqueId('aspect_ids_');
|
var uid = _.uniqueId('aspect_ids_');
|
||||||
this.$('.content_creation form').append(
|
this.$('.content_creation form').append(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue