Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: 修复[data-images]放大一组图片展示顺序问题 #134

Open
wants to merge 1 commit into
base: v2
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 17 additions & 25 deletions public/static/plugs/easy-admin/easy-admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -1030,35 +1030,27 @@ define(["jquery", "tableSelect","xmSelect", "ckeditor"], function ($, tableSelec

// 放大一组图片
$('body').on('click', '[data-images]', function () {
var title = $(this).attr('data-images'),
// 从当前元素向上找layuimini-upload-show找到第一个后停止, 再找其所有子元素li
doms = $(this).closest(".layuimini-upload-show").children("li"),
// 被点击的图片地址
now_src = $(this).attr('src'),
alt = $(this).attr('alt'),
var doms = $(this).closest(".layuimini-upload-show").children("li"), // 从当前元素向上找layuimini-upload-show找到第一个后停止, 再找其所有子元素li
currentSrc = $(this).attr('src'), // 被点击的图片地址
start = 0,
data = [];
$.each(doms, function(key, value){
var src = $(value).find('img').attr('src');
if(src != now_src){
// 压入其他图片地址
data.push({
"alt": alt,
"pid": Math.random(),
"src": src,
"thumb": src
});
}else{
// 把当前图片插入到头部
data.unshift({
"alt": alt,
"pid": Math.random(),
"src": now_src,
"thumb": now_src
});
$.each(doms, function (key, value) {
var img = $(value).find('img'),
src = img.attr('src'),
alt = img.attr('alt');
data.push({
"alt": alt,
"pid": Math.random(),
"src": src,
"thumb": src
});
if (src === currentSrc) {
start = key;
}
});
var photos = {
"title": title,
"title": '',
"start": start,
"id": Math.random(),
"data": data,
};
Expand Down