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,19 +93,23 @@ $(document).ready(function(){
|
||||||
function generateURL(){
|
function generateURL(){
|
||||||
var baseURL = location.href.split("?")[0];
|
var baseURL = location.href.split("?")[0];
|
||||||
|
|
||||||
// generate new url
|
if(selectedGUIDS.length != $('li', '#aspect_nav').length-2) {
|
||||||
baseURL = baseURL.replace('#','');
|
// generate new url
|
||||||
baseURL += '?';
|
baseURL = baseURL.replace('#','');
|
||||||
for(i=0; i < selectedGUIDS.length; i++){
|
baseURL += '?';
|
||||||
baseURL += 'a_ids[]='+ selectedGUIDS[i] +'&';
|
for(i=0; i < selectedGUIDS.length; i++){
|
||||||
}
|
baseURL += 'a_ids[]='+ selectedGUIDS[i] +'&';
|
||||||
|
}
|
||||||
|
|
||||||
if(!$("#publisher").hasClass("closed")) {
|
if(!$("#publisher").hasClass("closed")) {
|
||||||
// open publisher
|
// open publisher
|
||||||
baseURL += "op=true";
|
baseURL += "op=true";
|
||||||
|
} else {
|
||||||
|
// slice last '&'
|
||||||
|
baseURL = baseURL.slice(0,baseURL.length-1);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// slice last '&'
|
selectedGUIDS = [];
|
||||||
baseURL = baseURL.slice(0,baseURL.length-1);
|
|
||||||
}
|
}
|
||||||
return baseURL;
|
return baseURL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue