mirror of
https://gitee.com/dotnetchina/OpenAuth.Net.git
synced 2025-09-24 04:53:33 +08:00
完成用户管理,layui弹出有问题
This commit is contained in:
@@ -1,2 +1,176 @@
|
||||
/** layui-v2.1.0 MIT License By http://www.layui.com */
|
||||
;layui.define("jquery",function(e){"use strict";var l=layui.$,o=function(e){},t='<i class="layui-anim layui-anim-rotate layui-anim-loop layui-icon "></i>';o.prototype.load=function(e){var o,i,n,r,a=this,c=0;e=e||{};var f=l(e.elem);if(f[0]){var m=l(e.scrollElem||document),u=e.mb||50,s=!("isAuto"in e)||e.isAuto,v=e.end||"没有更多了",y=e.scrollElem&&e.scrollElem!==document,d="<cite>加载更多</cite>",h=l('<div class="layui-flow-more"><a href="javascript:;">'+d+"</a></div>");f.find(".layui-flow-more")[0]||f.append(h);var p=function(e,t){e=l(e),h.before(e),t=0==t||null,t?h.html(v):h.find("a").html(d),i=t,o=null,n&&n()},g=function(){o=!0,h.find("a").html(t),"function"==typeof e.done&&e.done(++c,p)};if(g(),h.find("a").on("click",function(){l(this);i||o||g()}),e.isLazyimg)var n=a.lazyimg({elem:e.elem+" img",scrollElem:e.scrollElem});return s?(m.on("scroll",function(){var e=l(this),t=e.scrollTop();r&&clearTimeout(r),i||(r=setTimeout(function(){var i=y?e.height():l(window).height(),n=y?e.prop("scrollHeight"):document.documentElement.scrollHeight;n-t-i<=u&&(o||g())},100))}),a):a}},o.prototype.lazyimg=function(e){var o,t=this,i=0;e=e||{};var n=l(e.scrollElem||document),r=e.elem||"img",a=e.scrollElem&&e.scrollElem!==document,c=function(e,l){var o=n.scrollTop(),r=o+l,c=a?function(){return e.offset().top-n.offset().top+o}():e.offset().top;if(c>=o&&c<=r&&!e.attr("src")){var m=e.attr("lay-src");layui.img(m,function(){var l=t.lazyimg.elem.eq(i);e.attr("src",m).removeAttr("lay-src"),l[0]&&f(l),i++})}},f=function(e,o){var f=a?(o||n).height():l(window).height(),m=n.scrollTop(),u=m+f;if(t.lazyimg.elem=l(r),e)c(e,f);else for(var s=0;s<t.lazyimg.elem.length;s++){var v=t.lazyimg.elem.eq(s),y=a?function(){return v.offset().top-n.offset().top+m}():v.offset().top;if(c(v,f),i=s,y>u)break}};if(f(),!o){var m;n.on("scroll",function(){var e=l(this);m&&clearTimeout(m),m=setTimeout(function(){f(null,e)},50)}),o=!0}return f},e("flow",new o)});
|
||||
/**
|
||||
|
||||
@Name:layui.flow 流加载
|
||||
@Author:贤心
|
||||
@License:MIT
|
||||
|
||||
*/
|
||||
|
||||
|
||||
layui.define('jquery', function(exports){
|
||||
"use strict";
|
||||
|
||||
var $ = layui.$, Flow = function(options){}
|
||||
,ELEM_MORE = 'layui-flow-more'
|
||||
,ELEM_LOAD = '<i class="layui-anim layui-anim-rotate layui-anim-loop layui-icon "></i>';
|
||||
|
||||
//主方法
|
||||
Flow.prototype.load = function(options){
|
||||
var that = this, page = 0, lock, isOver, lazyimg, timer;
|
||||
options = options || {};
|
||||
|
||||
var elem = $(options.elem); if(!elem[0]) return;
|
||||
var scrollElem = $(options.scrollElem || document); //滚动条所在元素
|
||||
var mb = options.mb || 50; //与底部的临界距离
|
||||
var isAuto = 'isAuto' in options ? options.isAuto : true; //是否自动滚动加载
|
||||
var end = options.end || '没有更多了'; //“末页”显示文案
|
||||
|
||||
//滚动条所在元素是否为document
|
||||
var notDocment = options.scrollElem && options.scrollElem !== document;
|
||||
|
||||
//加载更多
|
||||
var ELEM_TEXT = '<cite>加载更多</cite>'
|
||||
,more = $('<div class="layui-flow-more"><a href="javascript:;">'+ ELEM_TEXT +'</a></div>');
|
||||
|
||||
if(!elem.find('.layui-flow-more')[0]){
|
||||
elem.append(more);
|
||||
}
|
||||
|
||||
//加载下一个元素
|
||||
var next = function(html, over){
|
||||
html = $(html);
|
||||
more.before(html);
|
||||
over = over == 0 ? true : null;
|
||||
over ? more.html(end) : more.find('a').html(ELEM_TEXT);
|
||||
isOver = over;
|
||||
lock = null;
|
||||
lazyimg && lazyimg();
|
||||
};
|
||||
|
||||
//触发请求
|
||||
var done = function(){
|
||||
lock = true;
|
||||
more.find('a').html(ELEM_LOAD);
|
||||
typeof options.done === 'function' && options.done(++page, next);
|
||||
};
|
||||
|
||||
done();
|
||||
|
||||
//不自动滚动加载
|
||||
more.find('a').on('click', function(){
|
||||
var othis = $(this);
|
||||
if(isOver) return;
|
||||
lock || done();
|
||||
});
|
||||
|
||||
//如果允许图片懒加载
|
||||
if(options.isLazyimg){
|
||||
var lazyimg = that.lazyimg({
|
||||
elem: options.elem + ' img'
|
||||
,scrollElem: options.scrollElem
|
||||
});
|
||||
}
|
||||
|
||||
if(!isAuto) return that;
|
||||
|
||||
scrollElem.on('scroll', function(){
|
||||
var othis = $(this), top = othis.scrollTop();
|
||||
|
||||
if(timer) clearTimeout(timer);
|
||||
if(isOver) return;
|
||||
|
||||
timer = setTimeout(function(){
|
||||
//计算滚动所在容器的可视高度
|
||||
var height = notDocment ? othis.height() : $(window).height();
|
||||
|
||||
//计算滚动所在容器的实际高度
|
||||
var scrollHeight = notDocment
|
||||
? othis.prop('scrollHeight')
|
||||
: document.documentElement.scrollHeight;
|
||||
|
||||
//临界点
|
||||
if(scrollHeight - top - height <= mb){
|
||||
lock || done();
|
||||
}
|
||||
}, 100);
|
||||
});
|
||||
return that;
|
||||
};
|
||||
|
||||
//图片懒加载
|
||||
Flow.prototype.lazyimg = function(options){
|
||||
var that = this, index = 0, haveScroll;
|
||||
options = options || {};
|
||||
|
||||
var scrollElem = $(options.scrollElem || document); //滚动条所在元素
|
||||
var elem = options.elem || 'img';
|
||||
|
||||
//滚动条所在元素是否为document
|
||||
var notDocment = options.scrollElem && options.scrollElem !== document;
|
||||
|
||||
//显示图片
|
||||
var show = function(item, height){
|
||||
var start = scrollElem.scrollTop(), end = start + height;
|
||||
var elemTop = notDocment ? function(){
|
||||
return item.offset().top - scrollElem.offset().top + start;
|
||||
}() : item.offset().top;
|
||||
|
||||
/* 始终只加载在当前屏范围内的图片 */
|
||||
if(elemTop >= start && elemTop <= end){
|
||||
if(!item.attr('src')){
|
||||
var src = item.attr('lay-src');
|
||||
layui.img(src, function(){
|
||||
var next = that.lazyimg.elem.eq(index);
|
||||
item.attr('src', src).removeAttr('lay-src');
|
||||
|
||||
/* 当前图片加载就绪后,检测下一个图片是否在当前屏 */
|
||||
next[0] && render(next);
|
||||
index++;
|
||||
});
|
||||
}
|
||||
}
|
||||
}, render = function(othis, scroll){
|
||||
|
||||
//计算滚动所在容器的可视高度
|
||||
var height = notDocment ? (scroll||scrollElem).height() : $(window).height();
|
||||
var start = scrollElem.scrollTop(), end = start + height;
|
||||
|
||||
that.lazyimg.elem = $(elem);
|
||||
|
||||
if(othis){
|
||||
show(othis, height);
|
||||
} else {
|
||||
//计算未加载过的图片
|
||||
for(var i = 0; i < that.lazyimg.elem.length; i++){
|
||||
var item = that.lazyimg.elem.eq(i), elemTop = notDocment ? function(){
|
||||
return item.offset().top - scrollElem.offset().top + start;
|
||||
}() : item.offset().top;
|
||||
|
||||
show(item, height);
|
||||
index = i;
|
||||
|
||||
//如果图片的top坐标,超出了当前屏,则终止后续图片的遍历
|
||||
if(elemTop > end) break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
render();
|
||||
|
||||
if(!haveScroll){
|
||||
var timer;
|
||||
scrollElem.on('scroll', function(){
|
||||
var othis = $(this);
|
||||
if(timer) clearTimeout(timer)
|
||||
timer = setTimeout(function(){
|
||||
render(null, othis);
|
||||
}, 50);
|
||||
});
|
||||
haveScroll = true;
|
||||
}
|
||||
return render;
|
||||
};
|
||||
|
||||
//暴露接口
|
||||
exports('flow', new Flow());
|
||||
});
|
||||
|
Reference in New Issue
Block a user