Skip to content
Extraits de code Groupes Projets
Valider ed4020b9 rédigé par Fabián Rodríguez's avatar Fabián Rodríguez
Parcourir les fichiers

Update stream's title and publisher's dropdown on aspect selection

parent 8d202e48
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -20,6 +20,6 @@ app.collections.Aspects = Backbone.Collection.extend({ ...@@ -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({ ...@@ -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({ ...@@ -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({ ...@@ -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 @@ ...@@ -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 @@ ...@@ -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(
...@@ -59,4 +80,4 @@ ...@@ -59,4 +80,4 @@
); );
} }
}; };
})(); })();
\ No newline at end of file
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter