新增tip和查看大图功能

pull/39/head
MiniLing 2018-02-14 19:31:38 +08:00
parent 8439298f98
commit 9e162bd8ab
1 changed files with 252 additions and 234 deletions

18
public/assets/js/backend.js 100755 → 100644
View File

@ -221,6 +221,24 @@ define(['fast', 'moment'], function (Fast, Moment) {
if ($(".layer-footer").size() > 0 && self === top) { if ($(".layer-footer").size() > 0 && self === top) {
$(".layer-footer").show(); $(".layer-footer").show();
} }
//点击包含data-tips-image的元素弹出预览图片在需要使用的img元素增加 data-tips-image="图片地址" 即可
$(document).on('click', '[data-tips-image]', function () {
var img = new Image(), src = this.getAttribute('data-tips-image') || this.src;
var imgWidth = this.getAttribute('data-width') || '480px';
img.onload = function () {
var $content = $(img).appendTo('body').css({background: '#fff', width: imgWidth, height: 'auto'});
layer.open({type: 1, area: imgWidth, title: false, closeBtn: 1, skin: 'layui-layer-nobg', shadeClose: true, content: $content, end: function () {
$(img).remove();
}
});
};
img.src = src;
});
//鼠标移入包含data-tips-text的元素触发tips提示在需要使用的元素增加 data-tips-text="提示文字" 即可
$(document).on('mouseenter', '[data-tips-text]', function () {
var text = $(this).attr('data-tips-text'), placement = $(this).attr('data-tips-placement') || 'auto';
$(this).tooltip({title: text, placement: placement}).tooltip('show');
});
} }
}; };
Backend.api = $.extend(Fast.api, Backend.api); Backend.api = $.extend(Fast.api, Backend.api);