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