Fix all tab bug.
This commit is contained in:
parent
1900dada0a
commit
1a4c305149
|
@ -2376,15 +2376,32 @@ var wpex = {};
|
|||
if ($filter.length) {
|
||||
var $filterLinks = $filter.find(window.wpexAnimsition.filter_option);
|
||||
activeItems = '';
|
||||
if($filterLinks.length != 0){
|
||||
var filter_constraint = $filterLinks.eq(0).attr(window.wpexAnimsition.filter_attr);
|
||||
if(filter_constraint == "all"){
|
||||
filter_constraint = "["+window.wpexAnimsition.filter_attr+"]";
|
||||
}else{
|
||||
if(window.wpexAnimsition.use_attr_filter){
|
||||
filter_constraint = "["+window.wpexAnimsition.filter_attr+"=\""+filter_constraint+"\"]";
|
||||
}
|
||||
}
|
||||
if($filterLinks.eq(0).data("count_limit") != undefined){
|
||||
filter_constraint = filter_constraint+":nth-child(-n+"+$filterLinks.eq(0).data("count_limit")+")";
|
||||
}
|
||||
activeItems = filter_constraint;
|
||||
}
|
||||
$filterLinks.click(function () {
|
||||
var filter_constraint = $(this).attr(window.wpexAnimsition.filter_attr);
|
||||
if(filter_constraint == "all"){
|
||||
filter_constraint = undefined;
|
||||
filter_constraint = "["+window.wpexAnimsition.filter_attr+"]";
|
||||
}else{
|
||||
if(window.wpexAnimsition.use_attr_filter){
|
||||
filter_constraint = "["+window.wpexAnimsition.filter_attr+"=\""+filter_constraint+"\"]";
|
||||
}
|
||||
}
|
||||
if(window.wpexAnimsition.use_attr_filter){
|
||||
filter_constraint = "["+window.wpexAnimsition.filter_attr+"=\""+filter_constraint+"\"]";
|
||||
}
|
||||
}
|
||||
if($(this).data("count_limit") != undefined){
|
||||
filter_constraint = filter_constraint+":nth-child(-n+"+$(this).data("count_limit")+")";
|
||||
}
|
||||
$grid.isotope({ filter: filter_constraint});
|
||||
self.equalHeights();
|
||||
return false;
|
||||
|
|
|
@ -148,9 +148,6 @@ class AnnouncementsController < ApplicationController
|
|||
if @tab_option == 1
|
||||
cats = ["all"] + cats
|
||||
anns = anns.sort{|v1,v2| v2["postdate"]<=>v1["postdate"]}
|
||||
if @all_setting_option == 0
|
||||
anns = anns.deep_dup.map{|a| a["category"] = "All";a}[0...OrbitHelper.widget_data_count] + anns
|
||||
end
|
||||
end
|
||||
cats = cats.uniq
|
||||
cats_translations = cats.map{|cat_id|
|
||||
|
@ -163,11 +160,7 @@ class AnnouncementsController < ApplicationController
|
|||
}.to_h
|
||||
cats_relations = cats_translations.map{|cat_id,t|
|
||||
if cat_id == "all"
|
||||
if @all_setting_option == 0
|
||||
t = "All"
|
||||
else
|
||||
t = "all"
|
||||
end
|
||||
t = "all"
|
||||
end
|
||||
[cat_id,t]
|
||||
}.to_h
|
||||
|
@ -178,6 +171,7 @@ class AnnouncementsController < ApplicationController
|
|||
if all_cats.count == 0
|
||||
all_cats = ["all"]
|
||||
end
|
||||
max_all_count = [OrbitHelper.widget_data_count,anns.count].min
|
||||
if @tab_option != 0
|
||||
OrbitHelper.set_widget_title(OrbitHelper.widget_title +
|
||||
"<div style=\"clear: both;\"></div>" +
|
||||
|
@ -193,7 +187,7 @@ class AnnouncementsController < ApplicationController
|
|||
nil
|
||||
end
|
||||
end
|
||||
"<li class=\"filter_tab#{i == 0 ? ' active' : ''}\" data-read_more_text=\"#{read_more_text}\" data-read_more=\"#{read_more_url}\" data-category=\"#{cats_relations[cat]}\">#{cats_translations[cat]}</li>"
|
||||
"<li class=\"filter_tab#{i == 0 ? ' active' : ''}\" #{(cat == 'all' && @all_setting_option == 0) ? "data-count_limit=\"#{max_all_count}\"" : ''} data-read_more_text=\"#{read_more_text}\" data-read_more=\"#{read_more_url}\" data-category=\"#{cats_relations[cat]}\">#{cats_translations[cat]}</li>"
|
||||
}.join("") +
|
||||
"</ul>"
|
||||
)
|
||||
|
@ -327,7 +321,6 @@ class AnnouncementsController < ApplicationController
|
|||
end
|
||||
extra_after_html = ""
|
||||
if @all_setting_option == 0 && @tab_option == 1
|
||||
max_all_count = [OrbitHelper.widget_data_count,anns.count / 2].min
|
||||
extra_after_html = "
|
||||
<script>
|
||||
$(\"[data-subpart-id=\\\"#{subpart.id}\\\"] [data-list] [data-category]\").css(\"display\",\"none\");
|
||||
|
@ -420,8 +413,8 @@ class AnnouncementsController < ApplicationController
|
|||
def get_anncs_for_pack_data(cats,is_random = false)
|
||||
tags = OrbitHelper.widget_tags || []
|
||||
subpart = OrbitHelper.get_current_widget
|
||||
anns_cache = AnnsCache.where(parent_id: subpart.id.to_s + cats.to_s,locale: I18n.locale.to_s)
|
||||
widget_data_count = OrbitHelper.widget_data_count
|
||||
anns_cache = AnnsCache.where(parent_id: subpart.id.to_s + cats.to_s + widget_data_count.to_s,locale: I18n.locale.to_s)
|
||||
set_image_version_for_widget()
|
||||
devide_flag = (!(defined? SiteFeed).nil?)
|
||||
if anns_cache.count != 1 || is_random
|
||||
|
@ -439,10 +432,10 @@ class AnnouncementsController < ApplicationController
|
|||
now_anns = sorted_anns.to_a
|
||||
top_anns = now_anns.select{|v| v.is_top}.map{|v| data_to_human_type(v)}
|
||||
not_top_anns = now_anns.select{|v| !v.is_top}.map{|v| data_to_human_type(v)}
|
||||
AnnsCache.create(parent_id: subpart.id.to_s + cats.to_s,locale: I18n.locale.to_s,filter_result: {top: top_anns,not_top: not_top_anns})
|
||||
AnnsCache.create(parent_id: subpart.id.to_s + cats.to_s + widget_data_count.to_s,locale: I18n.locale.to_s,filter_result: {top: top_anns,not_top: not_top_anns})
|
||||
else
|
||||
anns = sorted_anns.map{|v| data_to_human_type(v)}
|
||||
AnnsCache.create(parent_id: subpart.id.to_s + cats.to_s,locale: I18n.locale.to_s,filter_result: anns)
|
||||
AnnsCache.create(parent_id: subpart.id.to_s + cats.to_s + widget_data_count.to_s,locale: I18n.locale.to_s,filter_result: anns)
|
||||
end
|
||||
else
|
||||
if devide_flag
|
||||
|
|
Loading…
Reference in New Issue