This commit is contained in:
BoHung Chiu 2021-06-09 12:35:36 +08:00
parent 174e0d657b
commit 93c7fc6bfb
2 changed files with 19 additions and 18 deletions

View File

@ -38,7 +38,7 @@
</div>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
function combineul(){
function combineul_{{subpart-id}}(){
var parents = $('[data-subpart-id=\"{{subpart-id}}\"] ul.w-annc__list').parent();
parents.each(function(i,v){
for(var i=1;i<$(v).find('ul.w-annc__list').length;i++)
@ -50,7 +50,7 @@
};
var num;
var lilength = $('[data-subpart-id=\"{{subpart-id}}\"] li.w-annc__item').length;
function reorganize(num){
function reorganize_{{subpart-id}}(num){
var uls = $('[data-subpart-id=\"{{subpart-id}}\"] ul.w-annc__list').toArray();
var currentul = uls.findIndex(function(v){
return $(v).hasClass("active") && !$(v).hasClass("hidden_item");
@ -60,7 +60,7 @@
var li_active_idx = 0;
if(currentul != 0)
li_active_idx = $(uls[currentul]).find("li.w-annc__item").eq(0).index("li.w-annc__item");
combineul();
combineul_{{subpart-id}}();
var parents = $('[data-subpart-id=\"{{subpart-id}}\"] ul.w-annc__list').parent();
parents.each(function(i,v){
var lilength = $(v).find('li.w-annc__item').length;
@ -99,25 +99,25 @@
};
$(window).resize(function(){
if($(window).width()>1024){
reorganize(3);
reorganize_{{subpart-id}}(3);
num=3;
}else if($(window).width()>576){
reorganize(2);
reorganize_{{subpart-id}}(2);
num=2;
}else{
reorganize(1);
reorganize_{{subpart-id}}(1);
num=1;
}
})
$(document).ready(function(){
if($(window).width()>1024){
reorganize(3);
reorganize_{{subpart-id}}(3);
num=3;
}else if($(window).width()>576){
reorganize(2);
reorganize_{{subpart-id}}(2);
num=2;
}else{
reorganize(1);
reorganize_{{subpart-id}}(1);
num=1;
}
var flag=false;

View File

@ -38,7 +38,7 @@
}
</style>
<script>
function combineul(){
function combineul_{{subpart-id}}(){
var parents = $('[data-subpart-id=\"{{subpart-id}}\"] ul.w-annc__list').parent();
parents.each(function(i,v){
for(var i=1;i<$(v).find('ul.w-annc__list').length;i++)
@ -50,8 +50,8 @@
};
var num;
var lilength = $('[data-subpart-id=\"{{subpart-id}}\"] li.w-annc__item').length;
function reorganize(num){
combineul();
function reorganize_{{subpart-id}}(num){
combineul_{{subpart-id}}();
var parents = $('[data-subpart-id=\"{{subpart-id}}\"] ul.w-annc__list').parent();
parents.each(function(i,v){
var lilength = $(v).find('li.w-annc__item').length;
@ -79,28 +79,29 @@
$(v).find('ul.w-annc__list').eq(0).find("li.w-annc__item").eq(num).remove();
})
$('[data-subpart-id=\"{{subpart-id}}\"] ul.w-annc__list >li').css('width','calc('+100/num+'% - '+20/16+'em)'); //20px=>li的margin
$('[data-subpart-id=\"{{subpart-id}}\"] ul.w-annc__list >li').css("float","left");
};
$(window).resize(function(){
if($(window).width()>1024){
reorganize(3);
reorganize_{{subpart-id}}(3);
num=3;
}else if($(window).width()>576){
reorganize(2);
reorganize_{{subpart-id}}(2);
num=2;
}else{
reorganize(1);
reorganize_{{subpart-id}}(1);
num=1;
}
})
$(document).ready(function(){
if($(window).width()>1024){
reorganize(3);
reorganize_{{subpart-id}}(3);
num=3;
}else if($(window).width()>576){
reorganize(2);
reorganize_{{subpart-id}}(2);
num=2;
}else{
reorganize(1);
reorganize_{{subpart-id}}(1);
num=1;
}
})