diff --git a/admin/js/bootstrap-notify.min.js b/admin/js/bootstrap-notify.min.js new file mode 100644 index 0000000..f5ad385 --- /dev/null +++ b/admin/js/bootstrap-notify.min.js @@ -0,0 +1,2 @@ +/* Project: Bootstrap Growl = v3.1.3 | Description: Turns standard Bootstrap alerts into "Growl-like" notifications. | Author: Mouse0270 aka Robert McIntosh | License: MIT License | Website: https://github.com/mouse0270/bootstrap-growl */ +!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):t("object"==typeof exports?require("jquery"):jQuery)}(function(t){function e(e,i,n){var i={content:{message:"object"==typeof i?i.message:i,title:i.title?i.title:"",icon:i.icon?i.icon:"",url:i.url?i.url:"#",target:i.target?i.target:"-"}};n=t.extend(!0,{},i,n),this.settings=t.extend(!0,{},s,n),this._defaults=s,"-"==this.settings.content.target&&(this.settings.content.target=this.settings.url_target),this.animations={start:"webkitAnimationStart oanimationstart MSAnimationStart animationstart",end:"webkitAnimationEnd oanimationend MSAnimationEnd animationend"},"number"==typeof this.settings.offset&&(this.settings.offset={x:this.settings.offset,y:this.settings.offset}),this.init()}var s={element:"body",position:null,type:"info",allow_dismiss:!0,newest_on_top:!1,showProgressbar:!1,placement:{from:"top",align:"right"},offset:20,spacing:10,z_index:1031,delay:5e3,timer:1e3,url_target:"_blank",mouse_over:null,animate:{enter:"animated fadeInDown",exit:"animated fadeOutUp"},onShow:null,onShown:null,onClose:null,onClosed:null,icon_type:"class",template:''};String.format=function(){for(var t=arguments[0],e=1;e .progress-bar').removeClass("progress-bar-"+t.settings.type),t.settings.type=i[e],this.$ele.addClass("alert-"+i[e]).find('[data-notify="progressbar"] > .progress-bar').addClass("progress-bar-"+i[e]);break;case"icon":var n=this.$ele.find('[data-notify="icon"]');"class"==t.settings.icon_type.toLowerCase()?n.removeClass(t.settings.content.icon).addClass(i[e]):(n.is("img")||n.find("img"),n.attr("src",i[e]));break;case"progress":var a=t.settings.delay-t.settings.delay*(i[e]/100);this.$ele.data("notify-delay",a),this.$ele.find('[data-notify="progressbar"] > div').attr("aria-valuenow",i[e]).css("width",i[e]+"%");break;case"url":this.$ele.find('[data-notify="url"]').attr("href",i[e]);break;case"target":this.$ele.find('[data-notify="url"]').attr("target",i[e]);break;default:this.$ele.find('[data-notify="'+e+'"]').html(i[e])}var o=this.$ele.outerHeight()+parseInt(t.settings.spacing)+parseInt(t.settings.offset.y);t.reposition(o)},close:function(){t.close()}}},buildNotify:function(){var e=this.settings.content;this.$ele=t(String.format(this.settings.template,this.settings.type,e.title,e.message,e.url,e.target)),this.$ele.attr("data-notify-position",this.settings.placement.from+"-"+this.settings.placement.align),this.settings.allow_dismiss||this.$ele.find('[data-notify="dismiss"]').css("display","none"),(this.settings.delay<=0&&!this.settings.showProgressbar||!this.settings.showProgressbar)&&this.$ele.find('[data-notify="progressbar"]').remove()},setIcon:function(){"class"==this.settings.icon_type.toLowerCase()?this.$ele.find('[data-notify="icon"]').addClass(this.settings.content.icon):this.$ele.find('[data-notify="icon"]').is("img")?this.$ele.find('[data-notify="icon"]').attr("src",this.settings.content.icon):this.$ele.find('[data-notify="icon"]').append('Notify Icon')},styleURL:function(){this.$ele.find('[data-notify="url"]').css({backgroundImage:"url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)",height:"100%",left:"0px",position:"absolute",top:"0px",width:"100%",zIndex:this.settings.z_index+1}),this.$ele.find('[data-notify="dismiss"]').css({position:"absolute",right:"10px",top:"5px",zIndex:this.settings.z_index+2})},placement:function(){var e=this,s=this.settings.offset.y,i={display:"inline-block",margin:"0px auto",position:this.settings.position?this.settings.position:"body"===this.settings.element?"fixed":"absolute",transition:"all .5s ease-in-out",zIndex:this.settings.z_index},n=!1,a=this.settings;switch(t('[data-notify-position="'+this.settings.placement.from+"-"+this.settings.placement.align+'"]:not([data-closing="true"])').each(function(){return s=Math.max(s,parseInt(t(this).css(a.placement.from))+parseInt(t(this).outerHeight())+parseInt(a.spacing))}),1==this.settings.newest_on_top&&(s=this.settings.offset.y),i[this.settings.placement.from]=s+"px",this.settings.placement.align){case"left":case"right":i[this.settings.placement.align]=this.settings.offset.x+"px";break;case"center":i.left=0,i.right=0}this.$ele.css(i).addClass(this.settings.animate.enter),t.each(Array("webkit","moz","o","ms",""),function(t,s){e.$ele[0].style[s+"AnimationIterationCount"]=1}),t(this.settings.element).append(this.$ele),1==this.settings.newest_on_top&&(s=parseInt(s)+parseInt(this.settings.spacing)+this.$ele.outerHeight(),this.reposition(s)),t.isFunction(e.settings.onShow)&&e.settings.onShow.call(this.$ele),this.$ele.one(this.animations.start,function(){n=!0}).one(this.animations.end,function(){t.isFunction(e.settings.onShown)&&e.settings.onShown.call(this)}),setTimeout(function(){n||t.isFunction(e.settings.onShown)&&e.settings.onShown.call(this)},600)},bind:function(){var e=this;if(this.$ele.find('[data-notify="dismiss"]').on("click",function(){e.close()}),this.$ele.mouseover(function(){t(this).data("data-hover","true")}).mouseout(function(){t(this).data("data-hover","false")}),this.$ele.data("data-hover","false"),this.settings.delay>0){e.$ele.data("notify-delay",e.settings.delay);var s=setInterval(function(){var t=parseInt(e.$ele.data("notify-delay"))-e.settings.timer;if("false"===e.$ele.data("data-hover")&&"pause"==e.settings.mouse_over||"pause"!=e.settings.mouse_over){var i=(e.settings.delay-t)/e.settings.delay*100;e.$ele.data("notify-delay",t),e.$ele.find('[data-notify="progressbar"] > div').attr("aria-valuenow",i).css("width",i+"%")}t<=-e.settings.timer&&(clearInterval(s),e.close())},e.settings.timer)}},close:function(){var e=this,s=parseInt(this.$ele.css(this.settings.placement.from)),i=!1;this.$ele.data("closing","true").addClass(this.settings.animate.exit),e.reposition(s),t.isFunction(e.settings.onClose)&&e.settings.onClose.call(this.$ele),this.$ele.one(this.animations.start,function(){i=!0}).one(this.animations.end,function(){t(this).remove(),t.isFunction(e.settings.onClosed)&&e.settings.onClosed.call(this)}),setTimeout(function(){i||(e.$ele.remove(),e.settings.onClosed&&e.settings.onClosed(e.$ele))},600)},reposition:function(e){var s=this,i='[data-notify-position="'+this.settings.placement.from+"-"+this.settings.placement.align+'"]:not([data-closing="true"])',n=this.$ele.nextAll(i);1==this.settings.newest_on_top&&(n=this.$ele.prevAll(i)),n.each(function(){t(this).css(s.settings.placement.from,e),e=parseInt(e)+parseInt(s.settings.spacing)+t(this).outerHeight()})}}),t.notify=function(t,s){var i=new e(this,t,s);return i.notify},t.notifyDefaults=function(e){return s=t.extend(!0,{},s,e)},t.notifyClose=function(e){"undefined"==typeof e||"all"==e?t("[data-notify]").find('[data-notify="dismiss"]').trigger("click"):t('[data-notify-position="'+e+'"]').find('[data-notify="dismiss"]').trigger("click")}}); \ No newline at end of file diff --git a/admin/js/jquery.dragsort-0.5.2.min.js b/admin/js/jquery.dragsort-0.5.2.min.js new file mode 100644 index 0000000..5007cc3 --- /dev/null +++ b/admin/js/jquery.dragsort-0.5.2.min.js @@ -0,0 +1,3 @@ +// jQuery List DragSort v0.5.2 +// License: http://dragsort.codeplex.com/license +(function(e){e.fn.dragsort=function(t){if(t=="destroy"){e(this.selector).trigger("dragsort-uninit");return}var n=e.extend({},e.fn.dragsort.defaults,t);var r=[];var i=null,s=null;this.each(function(t,o){if(e(o).is("table")&&e(o).children().size()==1&&e(o).children().is("tbody"))o=e(o).children().get(0);var u={draggedItem:null,placeHolderItem:null,pos:null,offset:null,offsetLimit:null,scroll:null,container:o,init:function(){n.tagName=e(this.container).children().size()==0?"li":e(this.container).children().get(0).tagName.toLowerCase();if(n.itemSelector=="")n.itemSelector=n.tagName;if(n.dragSelector=="")n.dragSelector=n.tagName;if(n.placeHolderTemplate=="")n.placeHolderTemplate="<"+n.tagName+"> ";e(this.container).attr("data-listidx",t).mousedown(this.grabItem).bind("dragsort-uninit",this.uninit);this.styleDragHandlers(true)},uninit:function(){var t=r[e(this).attr("data-listidx")];e(t.container).unbind("mousedown",t.grabItem).unbind("dragsort-uninit");t.styleDragHandlers(false)},getItems:function(){return e(this.container).children(n.itemSelector)},styleDragHandlers:function(t){this.getItems().map(function(){return e(this).is(n.dragSelector)?this:e(this).find(n.dragSelector).get()}).css("cursor",t?"pointer":"")},grabItem:function(t){var i=r[e(this).attr("data-listidx")];var s=e(t.target).closest("[data-listidx] > "+n.tagName).get(0);var o=i.getItems().filter(function(){return this==s}).size()>0;if(t.which!=1||e(t.target).is(n.dragSelectorExclude)||e(t.target).closest(n.dragSelectorExclude).size()>0||!o)return;t.preventDefault();var u=t.target;while(!e(u).is(n.dragSelector)){if(u==this)return;u=u.parentNode}e(u).attr("data-cursor",e(u).css("cursor"));e(u).css("cursor","move");var a=this;var f=function(){i.dragStart.call(a,t);e(i.container).unbind("mousemove",f)};e(i.container).mousemove(f).mouseup(function(){e(i.container).unbind("mousemove",f);e(u).css("cursor",e(u).attr("data-cursor"))})},dragStart:function(t){if(i!=null&&i.draggedItem!=null)i.dropItem();i=r[e(this).attr("data-listidx")];i.draggedItem=e(t.target).closest("[data-listidx] > "+n.tagName);i.draggedItem.attr("data-origpos",e(this).attr("data-listidx")+"-"+e(i.container).children().index(i.draggedItem));var s=parseInt(i.draggedItem.css("marginTop"));var o=parseInt(i.draggedItem.css("marginLeft"));i.offset=i.draggedItem.offset();i.offset.top=t.pageY-i.offset.top+(isNaN(s)?0:s)-1;i.offset.left=t.pageX-i.offset.left+(isNaN(o)?0:o)-1;if(!n.dragBetween){var u=e(i.container).outerHeight()==0?Math.max(1,Math.round(.5+i.getItems().size()*i.draggedItem.outerWidth()/e(i.container).outerWidth()))*i.draggedItem.outerHeight():e(i.container).outerHeight();i.offsetLimit=e(i.container).offset();i.offsetLimit.right=i.offsetLimit.left+e(i.container).outerWidth()-i.draggedItem.outerWidth();i.offsetLimit.bottom=i.offsetLimit.top+u-i.draggedItem.outerHeight()}var a=i.draggedItem.height();var f=i.draggedItem.width();if(n.tagName=="tr"){i.draggedItem.children().each(function(){e(this).width(e(this).width())});i.placeHolderItem=i.draggedItem.clone().attr("data-placeholder",true);i.draggedItem.after(i.placeHolderItem);i.placeHolderItem.children().each(function(){e(this).css({borderWidth:0,width:e(this).width()+1,height:e(this).height()+1}).html(" ")})}else{i.draggedItem.after(n.placeHolderTemplate);i.placeHolderItem=i.draggedItem.next().css({height:a,width:f}).attr("data-placeholder",true)}if(n.tagName=="td"){var l=i.draggedItem.closest("table").get(0);e("
").appendTo("body").children().append(i.draggedItem)}var c=i.draggedItem.attr("style");i.draggedItem.attr("data-origstyle",c?c:"");i.draggedItem.css({position:"absolute",opacity:.8,"z-index":999,height:a,width:f});i.scroll={moveX:0,moveY:0,maxX:e(document).width()-e(window).width(),maxY:e(document).height()-e(window).height()};i.scroll.scrollY=window.setInterval(function(){if(n.scrollContainer!=window){e(n.scrollContainer).scrollTop(e(n.scrollContainer).scrollTop()+i.scroll.moveY);return}var t=e(n.scrollContainer).scrollTop();if(i.scroll.moveY>0&&t0){e(n.scrollContainer).scrollTop(t+i.scroll.moveY);i.draggedItem.css("top",i.draggedItem.offset().top+i.scroll.moveY+1)}},10);i.scroll.scrollX=window.setInterval(function(){if(n.scrollContainer!=window){e(n.scrollContainer).scrollLeft(e(n.scrollContainer).scrollLeft()+i.scroll.moveX);return}var t=e(n.scrollContainer).scrollLeft();if(i.scroll.moveX>0&&t0){e(n.scrollContainer).scrollLeft(t+i.scroll.moveX);i.draggedItem.css("left",i.draggedItem.offset().left+i.scroll.moveX+1)}},10);e(r).each(function(e,t){t.createDropTargets();t.buildPositionTable()});i.setPos(t.pageX,t.pageY);e(document).bind("mousemove",i.swapItems);e(document).bind("mouseup",i.dropItem);if(n.scrollContainer!=window)e(window).bind("wheel",i.wheel)},setPos:function(t,r){var s=r-this.offset.top;var o=t-this.offset.left;if(!n.dragBetween){s=Math.min(this.offsetLimit.bottom,Math.max(s,this.offsetLimit.top));o=Math.min(this.offsetLimit.right,Math.max(o,this.offsetLimit.left))}var u=this.draggedItem.offsetParent().not("body").offset();if(u!=null){s-=u.top;o-=u.left}if(n.scrollContainer==window){r-=e(window).scrollTop();t-=e(window).scrollLeft();r=Math.max(0,r-e(window).height()+5)+Math.min(0,r-5);t=Math.max(0,t-e(window).width()+5)+Math.min(0,t-5)}else{var a=e(n.scrollContainer);var f=a.offset();r=Math.max(0,r-a.height()-f.top)+Math.min(0,r-f.top);t=Math.max(0,t-a.width()-f.left)+Math.min(0,t-f.left)}i.scroll.moveX=t==0?0:t*n.scrollSpeed/Math.abs(t);i.scroll.moveY=r==0?0:r*n.scrollSpeed/Math.abs(r);this.draggedItem.css({top:s,left:o})},wheel:function(t){if(i&&n.scrollContainer!=window){var r=e(n.scrollContainer);var s=r.offset();t=t.originalEvent;if(t.clientX>s.left&&t.clientXs.top&&t.clientY0)o.before(i.draggedItem);else if(s[1]==0)e(r[s[0]].container).prepend(i.draggedItem);else e(r[s[0]].container).append(i.draggedItem)}i.draggedItem.removeAttr("data-origpos");i.draggedItem=null;e(document).unbind("mousemove",i.swapItems);e(document).unbind("mouseup",i.dropItem);if(n.scrollContainer!=window)e(window).unbind("wheel",i.wheel);return false},swapItems:function(t){if(i.draggedItem==null)return false;i.setPos(t.pageX,t.pageY);var o=i.findPos(t.pageX,t.pageY);var u=i;for(var a=0;o==-1&&n.dragBetween&&ai.draggedItem.offset().top||s.left>i.draggedItem.offset().left)e(u.pos[o].elm).before(i.placeHolderItem);else e(u.pos[o].elm).after(i.placeHolderItem);l.each(function(){var t=f().eq(this.idx).get(0);if(this!=t&&f().index(this)e&&this.pos[n].topt)return n}return-1},createDropTargets:function(){if(!n.dragBetween)return;e(r).each(function(){var t=e(this.container).find("[data-placeholder]");var r=e(this.container).find("[data-droptarget]");if(t.size()>0&&r.size()>0)r.remove();else if(t.size()==0&&r.size()==0){if(n.tagName=="td")e(n.placeHolderTemplate).attr("data-droptarget",true).appendTo(this.container);else e(this.container).append(i.placeHolderItem.removeAttr("data-placeholder").clone().attr("data-droptarget",true));i.placeHolderItem.attr("data-placeholder",true)}})}};u.init();r.push(u)});return this};e.fn.dragsort.defaults={itemSelector:"",dragSelector:"",dragSelectorExclude:"input, textarea",dragEnd:function(){},dragBetween:false,placeHolderTemplate:"",scrollContainer:window,scrollSpeed:5}})(jQuery) diff --git a/admin/js/lightyear.js b/admin/js/lightyear.js new file mode 100644 index 0000000..2de588d --- /dev/null +++ b/admin/js/lightyear.js @@ -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('
Loading...
'); + } + } 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); + } + }; +}(); \ No newline at end of file diff --git a/admin/js/link.js b/admin/js/link.js new file mode 100644 index 0000000..718e244 --- /dev/null +++ b/admin/js/link.js @@ -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: "", + }); + }, + 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: "" }); +}); + +//显示保存 +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; + } + }); +} \ No newline at end of file