Slight enhacements on aspect-navigation widget
This commit is contained in:
parent
e0ffd7c63e
commit
dc0c23da2f
2 changed files with 20 additions and 10 deletions
|
|
@ -38,7 +38,7 @@ Feature: posting from the main page
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
Then I should see "I am eating a yogurt"
|
Then I should see "I am eating a yogurt"
|
||||||
|
|
||||||
When I follow "Your Aspects" within "#aspect_nav"
|
When I am on the aspects page
|
||||||
And I follow "NotPostingThingsHere" within "#aspect_nav"
|
And I follow "NotPostingThingsHere" within "#aspect_nav"
|
||||||
And I wait for the ajax to finish
|
And I wait for the ajax to finish
|
||||||
Then I should not see "I am eating a yogurt"
|
Then I should not see "I am eating a yogurt"
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,6 @@
|
||||||
self.initializeSelectedAspects();
|
self.initializeSelectedAspects();
|
||||||
self.calculateToggleText();
|
self.calculateToggleText();
|
||||||
self.aspectSelectors.click(self.toggleAspect);
|
self.aspectSelectors.click(self.toggleAspect);
|
||||||
self.aspectSelectors.debounce("click", self.performAjax, 250);
|
|
||||||
self.toggleSelector.click(self.toggleAll);
|
self.toggleSelector.click(self.toggleAll);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -38,25 +37,32 @@
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
|
||||||
$(this).parent().toggleClass("active");
|
$(this).parent().toggleClass("active");
|
||||||
self.calculateToggleText();
|
self.perform();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.toggleAll = function(evt) {
|
this.toggleAll = function(evt) {
|
||||||
evt.preventDefault();
|
evt.preventDefault();
|
||||||
|
|
||||||
if (self.aspectLis.not(".active").length === 0) {
|
if (self.allSelected()) {
|
||||||
self.aspectLis.removeClass("active");
|
self.aspectLis.removeClass("active");
|
||||||
|
} else {
|
||||||
|
self.aspectLis.addClass("active");
|
||||||
|
}
|
||||||
|
self.perform();
|
||||||
|
};
|
||||||
|
|
||||||
|
this.perform = function() {
|
||||||
|
if (self.noneSelected()) {
|
||||||
self.abortAjax();
|
self.abortAjax();
|
||||||
self.fadeIn();
|
self.fadeIn();
|
||||||
} else {
|
} else {
|
||||||
self.aspectLis.addClass("active");
|
|
||||||
self.performAjax();
|
self.performAjax();
|
||||||
}
|
}
|
||||||
self.calculateToggleText();
|
self.calculateToggleText();
|
||||||
};
|
};
|
||||||
|
|
||||||
this.calculateToggleText = function() {
|
this.calculateToggleText = function() {
|
||||||
if (self.aspectLis.not(".active").length === 0) {
|
if (self.allSelected()) {
|
||||||
self.toggleSelector.text(Diaspora.I18n.t('aspect_navigation.deselect_all'));
|
self.toggleSelector.text(Diaspora.I18n.t('aspect_navigation.deselect_all'));
|
||||||
} else {
|
} else {
|
||||||
self.toggleSelector.text(Diaspora.I18n.t('aspect_navigation.select_all'));
|
self.toggleSelector.text(Diaspora.I18n.t('aspect_navigation.select_all'));
|
||||||
|
|
@ -98,10 +104,6 @@
|
||||||
photos[img.attr("data-id")] = img.attr("src");
|
photos[img.attr("data-id")] = img.attr("src");
|
||||||
});
|
});
|
||||||
|
|
||||||
if (typeof(history.pushState) == 'function') {
|
|
||||||
history.pushState(null, document.title, newURL);
|
|
||||||
}
|
|
||||||
|
|
||||||
self.abortAjax();
|
self.abortAjax();
|
||||||
self.fadeOut();
|
self.fadeOut();
|
||||||
|
|
||||||
|
|
@ -133,6 +135,14 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.noneSelected = function() {
|
||||||
|
return self.aspectLis.filter(".active").length === 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.allSelected = function() {
|
||||||
|
return self.aspectLis.not(".active").length === 0;
|
||||||
|
}
|
||||||
|
|
||||||
this.fadeOut = function() {
|
this.fadeOut = function() {
|
||||||
$("#aspect_stream_container").fadeTo(100, 0.4);
|
$("#aspect_stream_container").fadeTo(100, 0.4);
|
||||||
$("#selected_aspect_contacts").fadeTo(100, 0.4);
|
$("#selected_aspect_contacts").fadeTo(100, 0.4);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue