popstate now in aspect-filters. back button now actually works on aspect/index.
This commit is contained in:
parent
3387c20b5f
commit
326155af54
3 changed files with 44 additions and 11 deletions
|
|
@ -2,6 +2,28 @@ $('#aspect_stream_container').html("<%= escape_javascript(render('aspects/aspect
|
||||||
$('#aspect_listings').html("<%= escape_javascript(render('aspects/aspect_listings', :aspects => @aspects)) %>");
|
$('#aspect_listings').html("<%= escape_javascript(render('aspects/aspect_listings', :aspects => @aspects)) %>");
|
||||||
$('a[rel*=facebox]').facebox();
|
$('a[rel*=facebox]').facebox();
|
||||||
|
|
||||||
|
|
||||||
|
var aspectIds = <%= @aspect_ids.to_json %>,
|
||||||
|
selectors = $("li", "#aspect_nav");
|
||||||
|
|
||||||
|
if( selectors.length-2 != aspectIds.length ) {
|
||||||
|
$.each( selectors, function(){
|
||||||
|
var element = $(this);
|
||||||
|
|
||||||
|
if( $.inArray( parseInt(element.attr('data-guid')), aspectIds) != -1 ){
|
||||||
|
element.addClass('selected');
|
||||||
|
} else {
|
||||||
|
element.removeClass('selected');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
$.each( selectors, function(){
|
||||||
|
$(this).removeClass('selected');
|
||||||
|
});
|
||||||
|
|
||||||
|
selectors.first().addClass('selected');
|
||||||
|
}
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
$('#main_stream').infinitescroll({
|
$('#main_stream').infinitescroll({
|
||||||
navSelector : "#main_stream + div.pagination",
|
navSelector : "#main_stream + div.pagination",
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,9 @@ Feature: saved state
|
||||||
And I go to the aspects page
|
And I go to the aspects page
|
||||||
|
|
||||||
When I follow "Open 1"
|
When I follow "Open 1"
|
||||||
|
And I wait for the ajax to finish
|
||||||
And I follow "Open 2"
|
And I follow "Open 2"
|
||||||
|
And I wait for the ajax to finish
|
||||||
Then aspect "Open 1" should be selected
|
Then aspect "Open 1" should be selected
|
||||||
And aspect "Open 2" should be selected
|
And aspect "Open 2" should be selected
|
||||||
But aspect "Closed 1" should not be selected
|
But aspect "Closed 1" should not be selected
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,11 @@ $(document).ready(function(){
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// popstate
|
||||||
|
$(window).bind("popstate", function(){
|
||||||
|
$.getScript(location.href);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
$("a.hard_aspect_link").live("click", function(e){
|
$("a.hard_aspect_link").live("click", function(e){
|
||||||
var link = $(this);
|
var link = $(this);
|
||||||
|
|
@ -88,6 +93,7 @@ $(document).ready(function(){
|
||||||
function generateURL(){
|
function generateURL(){
|
||||||
var baseURL = location.href.split("?")[0];
|
var baseURL = location.href.split("?")[0];
|
||||||
|
|
||||||
|
if(selectedGUIDS.length != $('li', '#aspect_nav').length-2) {
|
||||||
// generate new url
|
// generate new url
|
||||||
baseURL = baseURL.replace('#','');
|
baseURL = baseURL.replace('#','');
|
||||||
baseURL += '?';
|
baseURL += '?';
|
||||||
|
|
@ -102,6 +108,9 @@ $(document).ready(function(){
|
||||||
// slice last '&'
|
// slice last '&'
|
||||||
baseURL = baseURL.slice(0,baseURL.length-1);
|
baseURL = baseURL.slice(0,baseURL.length-1);
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
selectedGUIDS = [];
|
||||||
|
}
|
||||||
return baseURL;
|
return baseURL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue