filters are now working in ajax. inf. scroll and publisher pending ajax.
This commit is contained in:
parent
c64865d32e
commit
f02c13ee73
3 changed files with 28 additions and 4 deletions
1
app/views/aspects/index.js.erb
Normal file
1
app/views/aspects/index.js.erb
Normal file
|
|
@ -0,0 +1 @@
|
|||
$('#main_stream').html("<%= escape_javascript(render('shared/stream', :posts => @post_hashes)) %>");
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
#aspect_nav
|
||||
%ul
|
||||
%li{:class => ("selected" if @aspect == :all)}
|
||||
= link_to t('_home'), root_path
|
||||
= link_to t('_home'), root_path, :class => 'home_selector'
|
||||
|
||||
- for aspect in @all_aspects
|
||||
%li{:data=>{:guid=>aspect.id}, :class => ("selected" if current_aspect?(aspect))}
|
||||
|
|
|
|||
|
|
@ -17,13 +17,18 @@ $(function(){
|
|||
});
|
||||
|
||||
$("#aspect_nav a.aspect_selector").click(function(e){
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
// loading animation
|
||||
$("#main_stream").fadeTo(100, 0.4);
|
||||
|
||||
|
||||
// filtering //////////////////////
|
||||
var $this = $(this),
|
||||
listElement = $this.parent(),
|
||||
guid = listElement.attr('data-guid'),
|
||||
baseURL = location.href.split("?")[0];
|
||||
baseURL = location.href.split("?")[0],
|
||||
homeListElement = $("#aspect_nav a.home_selector").parent();
|
||||
|
||||
if( listElement.hasClass('selected') ){
|
||||
// remove filter
|
||||
|
|
@ -31,12 +36,20 @@ $(function(){
|
|||
if( idx != -1 ){
|
||||
selectedGUIDS.splice(idx,1);
|
||||
}
|
||||
listElement.removeClass('selected');
|
||||
|
||||
if(selectedGUIDS.length == 0){
|
||||
homeListElement.addClass('selected');
|
||||
}
|
||||
|
||||
} else {
|
||||
// append filter
|
||||
if(selectedGUIDS.indexOf( guid == 1)){
|
||||
selectedGUIDS.push( guid );
|
||||
}
|
||||
listElement.addClass('selected');
|
||||
|
||||
homeListElement.removeClass('selected');
|
||||
}
|
||||
|
||||
// generate new url
|
||||
|
|
@ -45,7 +58,17 @@ $(function(){
|
|||
baseURL += 'a_ids[]='+ selectedGUIDS[i] +'&';
|
||||
}
|
||||
baseURL = baseURL.slice(0,baseURL.length-1);
|
||||
///////////////////////////////////
|
||||
|
||||
|
||||
//window.location = baseURL;
|
||||
$.ajax({
|
||||
url : baseURL,
|
||||
dataType : 'script',
|
||||
success : function(data){
|
||||
$("#main_stream").fadeTo(100, 1);
|
||||
}
|
||||
});
|
||||
|
||||
window.location = baseURL;
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue