增加 JS文件

This commit is contained in:
LyLme 2022-05-11 12:45:17 +08:00
parent d2c97e41b3
commit 453edcf36c
4 changed files with 304 additions and 0 deletions

2
admin/js/bootstrap-notify.min.js vendored Normal file

File diff suppressed because one or more lines are too long

3
admin/js/jquery.dragsort-0.5.2.min.js vendored Normal file

File diff suppressed because one or more lines are too long

88
admin/js/lightyear.js Normal file
View File

@ -0,0 +1,88 @@
var lightyear = function(){
/**
* 页面loading
*/
var pageLoader = function($mode) {
var $loadingEl = jQuery('#lyear-loading');
$mode = $mode || 'show';
if ($mode === 'show') {
if ($loadingEl.length) {
$loadingEl.fadeIn(250);
} else {
jQuery('body').prepend('<div id="lyear-loading"><div class="spinner-border text-primary" role="status"><span class="sr-only">Loading...</span></div></div>');
}
} else if ($mode === 'hide') {
if ($loadingEl.length) {
$loadingEl.fadeOut(250);
}
}
return false;
};
/**
* 页面小提示
* @param $msg 提示信息
* @param $type 提示类型:'info', 'success', 'warning', 'danger'
* @param $delay 毫秒数例如1000
* @param $icon 图标例如'fa fa-user' 'glyphicon glyphicon-warning-sign'
* @param $from 'top' 'bottom'
* @param $align 'left', 'right', 'center'
* @param $url 跳转链接 例如 https://www.xxxx.com
* @author CaiWeiMing <314013107@qq.com>
*/
var tips = function ($msg, $type, $delay, $icon, $from, $align, $url) {
$type = $type || 'info';
$delay = $delay || 1000;
$from = $from || 'top';
$align = $align || 'center';
$enter = $type == 'danger' ? 'animated shake' : 'animated fadeInUp';
$url = $url || url;
jQuery.notify({
icon: $icon,
message: $msg
},
{
element: 'body',
type: $type,
allow_dismiss: true,
newest_on_top: true,
showProgressbar: false,
placement: {
from: $from,
align: $align
},
offset: 20,
spacing: 10,
z_index: 10800,
delay: $delay,
//timer: 1000,
animate: {
enter: $enter,
exit: 'animated fadeOutDown'
}
});
if($url!=''){
setTimeout(function(){
window.location.href=$url;
},$delay);
}
};
var url = '';
return {
// 页面小提示
notify : function ($msg, $type, $delay, $icon, $from, $align, $url) {
tips($msg, $type, $delay, $icon, $from, $align, $url);
},
url : function ($url){
url=$url;
},
// 页面加载动画
loading : function ($mode) {
pageLoader($mode);
}
};
}();

211
admin/js/link.js Normal file
View File

@ -0,0 +1,211 @@
//请求页面
function listTable(query){
var url = window.document.location.href.toString();
var queryString = url.split("?")[1];
query = query || queryString;
layer.closeAll();
var ii = layer.load(2, {shade:[0.1,'#fff']});
$.ajax({
type : 'GET',
url : 'table_link.php?'+query,
dataType : 'html',
cache : false,
success : function(data) {
layer.close(ii);
$("#listTable").html(data);
$("#link").dragsort({
dragBetween: true,
dragSelector: "tr",
dragEnd: showbutton,
placeHolderTemplate: "<tr></tr>",
});
},
error:function(data){
layer.msg('服务器错误');
return false;
}
});
}
//载入页面
$(document).ready(function(){
if($("#listTable").length>0){
listTable()
}
});
//获取选中
function get_check(){
var chk_value =[];
$('input[name="link-check"]:checked').each(function(){
chk_value.push($(this).val());
});
return chk_value;
}
//点击排序
function sort(id,order,gid){
lightyear.loading('show');
$.ajax({
url:"ajax_link.php?submit=order",
method:"POST",
data:{id:id,order:order,gid:gid},
success:function(data){
console.log(data);
lightyear.loading('hide');
lightyear.notify('操作成功!', 'success', 1000);
listTable();
return true;
},
error:function(data){
layer.msg('服务器错误');
return false;
}
});
}
function on_link(){
//多选启用
if(get_check().length == 0){
$.alert("未选择链接");
return false;
}
lightyear.loading('show');
$.ajax({
url:"ajax_link.php?submit=on",
method:"POST",
data:{links:get_check()},
success:function(data){
console.log(data);
lightyear.loading('hide');
lightyear.notify('操作成功!', 'success', 1000);
listTable();
return true;
},
error:function(data){
layer.msg('服务器错误');
return false;
}
});
}
function off_link(){
//多选禁用
if(get_check().length == 0){
$.alert("未选择链接");
return false;
}
lightyear.loading('show');
$.ajax({
url:"ajax_link.php?submit=off",
method:"POST",
data:{links:get_check()},
success:function(data){
console.log(data);
lightyear.loading('hide');
lightyear.notify('操作成功!', 'success', 1000);
listTable();
return true;
},
error:function(data){
layer.msg('服务器错误');
return false;
}
});
}
function del_link(id){
//多选删除
var link_id = [];
link_id.push(id);
link_id = id ? link_id :get_check();
console.log(link_id);
if(link_id.length == 0){
$.alert("未选择链接");
return false;
}
$.alert({
title: '警告',
content: '确定要删除吗?删除后不可恢复',
buttons: {
confirm: {
text: '删除',
btnClass: 'btn-danger',
action: function(){
lightyear.loading('show');
$.ajax({
url:"ajax_link.php?submit=del",
method:"POST",
data:{
links:link_id
},
success:function(data){
console.log(data);
lightyear.loading('hide');
lightyear.notify('操作成功!', 'success', 1000);
listTable();
return true;
}
});
},
error:function(data){
layer.msg('服务器错误');
return false;
}
},
cancel: {
text: '取消'
}
}
});
}
//全选
function check_all(){
var ischecked = $("#check_all").prop('checked');
if(ischecked == true){
$('[name="link-check"]').prop('checked',true);
}else{
$('[name="link-check"]').prop('checked',false);
}
}
//拖拽排序
$(document).ready(function(){
$("#link").dragsort({ itemSelector: "tr",
dragEnd: showbutton,
dragBetween: true, dragSelector: "tr",placeHolderTemplate: "<tr></tr>" });
});
//显示保存
function showbutton() {
$("#save_order").show();
}
//保存拖拽排序
function save_order(){
var link_array =[];
var $inputArr = $('input[name="link-check"]');
$inputArr.each(function(){
link_array.push($(this).val());
});
lightyear.loading('show');
$.ajax({
url:"ajax_link.php?submit=allorder",
method:"POST",
data:{link_array:link_array},
success:function(data){
console.log(data);
lightyear.loading('hide');
lightyear.notify('操作成功!', 'success', 1000);
listTable();
return true;
},
error:function(data){
layer.msg('服务器错误');
return false;
}
});
}