init: 从宝塔同步到 Gitea
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
|
||||
// 图片上传
|
||||
$(function() {
|
||||
|
||||
// 多图
|
||||
Imgupload(".upload_file",".upload_btn_item","more",1);
|
||||
|
||||
|
||||
});
|
||||
function Imgupload(btn,uploadBox,Type,maxCount){
|
||||
// 允许上传的图片类型
|
||||
var allowTypes = ['image/jpg', 'image/jpeg', 'image/png', 'image/gif'];
|
||||
// 1024KB,也就是 1MB
|
||||
var maxSize = 1024 * (1024*4); //小于4MB
|
||||
// 图片最大宽度
|
||||
var maxWidth = 10000;
|
||||
// 最大上传图片数量
|
||||
var maxCount = maxCount||1;
|
||||
var imgArray=[];
|
||||
$(btn).on('change', function(event) {
|
||||
var files = event.target.files;
|
||||
$(uploadBox).addClass("login-img")
|
||||
// 如果没有选中文件,直接返回
|
||||
if (files.length === 0) {
|
||||
$(uploadBox).removeClass("login-img")
|
||||
return;
|
||||
}
|
||||
if (files.length>maxCount) {
|
||||
$(uploadBox).removeClass("login-img")
|
||||
alert_box('最多只能上传' + maxCount + '张图片');
|
||||
return;
|
||||
};
|
||||
for (var i = 0, len = files.length; i < len; i++) {
|
||||
var file = files[i];
|
||||
|
||||
var reader = new FileReader();
|
||||
// 如果类型不在允许的类型范围内
|
||||
if (allowTypes.indexOf(file.type) === -1) {
|
||||
$(uploadBox).removeClass("login-img")
|
||||
alert_box("该类型不允许上传");
|
||||
continue;
|
||||
}
|
||||
if (file.size > maxSize) {
|
||||
$(uploadBox).removeClass("login-img")
|
||||
alert_box("图片太大,不允许上传");
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($('.item_file').length >= maxCount) {
|
||||
$(uploadBox).removeClass("login-img")
|
||||
alert_box('最多只能上传' + maxCount + '张图片');
|
||||
return;
|
||||
}
|
||||
reader.onload = function(e) {
|
||||
var img = new Image();
|
||||
img.onload = function() {
|
||||
$(uploadBox).removeClass("login-img")
|
||||
// 不要超出最大宽度
|
||||
var w = Math.min(maxWidth, img.width);
|
||||
// 高度按比例计算
|
||||
var h = img.height * (w / img.width);
|
||||
var canvas = document.createElement('canvas');
|
||||
var ctx = canvas.getContext('2d');
|
||||
// 设置 canvas 的宽度和高度
|
||||
canvas.width = w;
|
||||
canvas.height = h;
|
||||
ctx.drawImage(img, 0, 0, w, h);
|
||||
// var base64 = canvas.toDataURL('image/png');
|
||||
|
||||
var base64 =canvas.toDataURL('image/jpeg',0.8);
|
||||
|
||||
// 插入到预览区
|
||||
var progress = 0;
|
||||
// 多图
|
||||
//侦查附件上传情况 ,这个方法大概0.05-0.1秒执行一次
|
||||
function OnProgRess(event) {
|
||||
var event = event || window.event;
|
||||
// console.log("已经上传:"+ event.loaded); //已经上传大小情况(已上传大小,上传完毕后就 等于 附件总大小)
|
||||
|
||||
var loaded = Math.floor(100 * (event.loaded / event.total)); //已经上传的百分比
|
||||
// console.log(loaded+"%");
|
||||
if (Type=="more") {
|
||||
$preview.find('.uploader_num').text(loaded + '%');
|
||||
}else{
|
||||
$(uploadBox).find('.uploader_num').text(loaded + '%');
|
||||
}
|
||||
};
|
||||
if (Type=="more") {
|
||||
var $preview = $('<li class="item_file uploader_bg" ><div class="uploader_num">0%</div></li>');
|
||||
$('.img-box').append($preview);
|
||||
var num = $('.item_file').length;
|
||||
$('.num_counter').text(num + '/' + maxCount);
|
||||
function depositupload(){
|
||||
var data = {};
|
||||
data.base64 = base64;
|
||||
xhr = $.ajaxSettings.xhr();
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
url:'/recharge/deposit',
|
||||
dataType: 'json',
|
||||
async: true,
|
||||
data: data,
|
||||
xhr: function() {
|
||||
if(OnProgRess && xhr.upload) {
|
||||
xhr.upload.addEventListener("progress", OnProgRess, false);
|
||||
return xhr;
|
||||
}
|
||||
},
|
||||
success: function(data) {
|
||||
var Url='url(' +data.msg+ ')';
|
||||
$(".save .upload .img-box").find(".error").remove();
|
||||
$preview.css("background-image",Url);
|
||||
$('#img_url').val(data.msg);
|
||||
$preview.append('<i class="iconfont remove_btn">X</i><span class="preview-open"></span>');
|
||||
$preview.removeClass('uploader_bg').find('.uploader_num').remove();
|
||||
|
||||
},
|
||||
error: function(msg) {
|
||||
alert_box("上传失败")
|
||||
$preview.removeClass('uploader_bg').find('.uploader_num').remove();
|
||||
$preview.html('<div class="error"></div>');
|
||||
$(".save .upload .img-box").on("click",".error",function(){
|
||||
return depositupload();
|
||||
})
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
depositupload();
|
||||
|
||||
}
|
||||
if (imgArray.length == maxCount) {
|
||||
$(".upload_btn_item").css("display","none");
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
img.src = e.target.result;
|
||||
imgArray.push(img.src);
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
|
||||
});
|
||||
// 删除图片
|
||||
if (Type=="more") {
|
||||
$(".save .upload .img-box").on("click",".remove_btn",function(){
|
||||
var b= $(this).parents(".item_file").index()
|
||||
imgArray.splice(b,1);
|
||||
var num = $('.item_file').length-1;
|
||||
$('.num_counter').text(num + '/' + maxCount);
|
||||
if (imgArray.length < maxCount) {
|
||||
$(".upload_btn_item").css("display","block");
|
||||
}
|
||||
$(this).parents(".item_file").remove();
|
||||
|
||||
// console.log(imgArray)
|
||||
|
||||
})
|
||||
// 预览
|
||||
$(".save .upload .img-box").on("click",".preview-open",function(){
|
||||
var c= $(this).parents(".item_file").index();
|
||||
// console.log(imgArray[c])
|
||||
$("#preview-img").attr("src",imgArray[c])
|
||||
$(".preview").css("display","block");
|
||||
})
|
||||
$(".close_btn").click(function(){
|
||||
$(".preview").css("display","none");
|
||||
$("#preview-img").attr("src","");
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,236 @@
|
||||
/* @license
|
||||
* jQuery.print, version 1.3.2
|
||||
* (c) Sathvik Ponangi, Doers' Guild
|
||||
* Licence: CC-By (http://creativecommons.org/licenses/by/3.0/)
|
||||
*--------------------------------------------------------------------------*/
|
||||
(function ($) {
|
||||
"use strict";
|
||||
// A nice closure for our definitions
|
||||
function getjQueryObject(string) {
|
||||
// Make string a vaild jQuery thing
|
||||
var jqObj = $("");
|
||||
try {
|
||||
jqObj = $(string)
|
||||
.clone();
|
||||
} catch (e) {
|
||||
jqObj = $("<span />")
|
||||
.html(string);
|
||||
}
|
||||
return jqObj;
|
||||
}
|
||||
|
||||
function printFrame(frameWindow) {
|
||||
// Print the selected window/iframe
|
||||
var def = $.Deferred();
|
||||
try {
|
||||
setTimeout(function () {
|
||||
// Fix for IE : Allow it to render the iframe
|
||||
frameWindow.focus();
|
||||
try {
|
||||
// Fix for IE11 - printng the whole page instead of the iframe content
|
||||
if (!frameWindow.document.execCommand('print', false, null)) {
|
||||
// document.execCommand returns false if it failed -http://stackoverflow.com/a/21336448/937891
|
||||
frameWindow.print();
|
||||
}
|
||||
} catch (e) {
|
||||
frameWindow.print();
|
||||
}
|
||||
frameWindow.close();
|
||||
def.resolve();
|
||||
}, 250);
|
||||
} catch (err) {
|
||||
def.reject(err);
|
||||
}
|
||||
return def;
|
||||
}
|
||||
|
||||
function printContentInNewWindow(content) {
|
||||
// Open a new window and print selected content
|
||||
var w = window.open();
|
||||
w.document.write(content);
|
||||
w.document.close();
|
||||
return printFrame(w);
|
||||
}
|
||||
|
||||
function isNode(o) {
|
||||
/* http://stackoverflow.com/a/384380/937891 */
|
||||
return !!(typeof Node === "object" ? o instanceof Node : o && typeof o === "object" && typeof o.nodeType === "number" && typeof o.nodeName === "string");
|
||||
}
|
||||
$.print = $.fn.print = function () {
|
||||
// Print a given set of elements
|
||||
var options, $this, self = this;
|
||||
// console.log("Printing", this, arguments);
|
||||
if (self instanceof $) {
|
||||
// Get the node if it is a jQuery object
|
||||
self = self.get(0);
|
||||
}
|
||||
if (isNode(self)) {
|
||||
// If `this` is a HTML element, i.e. for
|
||||
// $(selector).print()
|
||||
$this = $(self);
|
||||
if (arguments.length > 0) {
|
||||
options = arguments[0];
|
||||
}
|
||||
} else {
|
||||
if (arguments.length > 0) {
|
||||
// $.print(selector,options)
|
||||
$this = $(arguments[0]);
|
||||
if (isNode($this[0])) {
|
||||
if (arguments.length > 1) {
|
||||
options = arguments[1];
|
||||
}
|
||||
} else {
|
||||
// $.print(options)
|
||||
options = arguments[0];
|
||||
$this = $("html");
|
||||
}
|
||||
} else {
|
||||
// $.print()
|
||||
$this = $("html");
|
||||
}
|
||||
}
|
||||
// Default options
|
||||
var defaults = {
|
||||
globalStyles: true,
|
||||
mediaPrint: false,
|
||||
stylesheet: null,
|
||||
noPrintSelector: ".no-print",
|
||||
iframe: true,
|
||||
append: null,
|
||||
prepend: null,
|
||||
manuallyCopyFormValues: true,
|
||||
deferred: $.Deferred()
|
||||
};
|
||||
// Merge with user-options
|
||||
options = $.extend({}, defaults, (options || {}));
|
||||
var $styles = $("");
|
||||
if (options.globalStyles) {
|
||||
// Apply the stlyes from the current sheet to the printed page
|
||||
$styles = $("style, link, meta, title");
|
||||
} else if (options.mediaPrint) {
|
||||
// Apply the media-print stylesheet
|
||||
$styles = $("link[media=print]");
|
||||
}
|
||||
if (options.stylesheet) {
|
||||
// Add a custom stylesheet if given
|
||||
$styles = $.merge($styles, $('<link rel="stylesheet" href="' + options.stylesheet + '">'));
|
||||
}
|
||||
// Create a copy of the element to print
|
||||
var copy = $this.clone();
|
||||
// Wrap it in a span to get the HTML markup string
|
||||
copy = $("<span/>")
|
||||
.append(copy);
|
||||
// Remove unwanted elements
|
||||
copy.find(options.noPrintSelector)
|
||||
.remove();
|
||||
// Add in the styles
|
||||
copy.append($styles.clone());
|
||||
// Appedned content
|
||||
copy.append(getjQueryObject(options.append));
|
||||
// Prepended content
|
||||
copy.prepend(getjQueryObject(options.prepend));
|
||||
if (options.manuallyCopyFormValues) {
|
||||
// Manually copy form values into the HTML for printing user-modified input fields
|
||||
// http://stackoverflow.com/a/26707753
|
||||
copy.find("input")
|
||||
.each(function () {
|
||||
var $field = $(this);
|
||||
if ($field.is("[type='radio']") || $field.is("[type='checkbox']")) {
|
||||
if ($field.prop("checked")) {
|
||||
$field.attr("checked", "checked");
|
||||
}
|
||||
} else {
|
||||
$field.attr("value", $field.val());
|
||||
}
|
||||
});
|
||||
copy.find("select").each(function () {
|
||||
var $field = $(this);
|
||||
$field.find(":selected").attr("selected", "selected");
|
||||
});
|
||||
copy.find("textarea").each(function () {
|
||||
// Fix for https://github.com/DoersGuild/jQuery.print/issues/18#issuecomment-96451589
|
||||
var $field = $(this);
|
||||
$field.text($field.val());
|
||||
});
|
||||
}
|
||||
// Get the HTML markup string
|
||||
var content = copy.html();
|
||||
// Notify with generated markup & cloned elements - useful for logging, etc
|
||||
try {
|
||||
options.deferred.notify('generated_markup', content, copy);
|
||||
} catch (err) {
|
||||
console.warn('Error notifying deferred', err);
|
||||
}
|
||||
// Destroy the copy
|
||||
copy.remove();
|
||||
if (options.iframe) {
|
||||
// Use an iframe for printing
|
||||
try {
|
||||
var $iframe = $(options.iframe + "");
|
||||
var iframeCount = $iframe.length;
|
||||
if (iframeCount === 0) {
|
||||
// Create a new iFrame if none is given
|
||||
$iframe = $('<iframe height="0" width="0" border="0" wmode="Opaque"/>')
|
||||
.prependTo('body')
|
||||
.css({
|
||||
"position": "absolute",
|
||||
"top": -999,
|
||||
"left": -999
|
||||
});
|
||||
}
|
||||
var w, wdoc;
|
||||
w = $iframe.get(0);
|
||||
w = w.contentWindow || w.contentDocument || w;
|
||||
wdoc = w.document || w.contentDocument || w;
|
||||
wdoc.open();
|
||||
wdoc.write(content);
|
||||
wdoc.close();
|
||||
printFrame(w)
|
||||
.done(function () {
|
||||
// Success
|
||||
setTimeout(function () {
|
||||
// Wait for IE
|
||||
if (iframeCount === 0) {
|
||||
// Destroy the iframe if created here
|
||||
$iframe.remove();
|
||||
}
|
||||
}, 100);
|
||||
})
|
||||
.fail(function (err) {
|
||||
// Use the pop-up method if iframe fails for some reason
|
||||
console.error("Failed to print from iframe", err);
|
||||
printContentInNewWindow(content);
|
||||
})
|
||||
.always(function () {
|
||||
try {
|
||||
options.deferred.resolve();
|
||||
} catch (err) {
|
||||
console.warn('Error notifying deferred', err);
|
||||
}
|
||||
});
|
||||
} catch (e) {
|
||||
// Use the pop-up method if iframe fails for some reason
|
||||
console.error("Failed to print from iframe", e.stack, e.message);
|
||||
printContentInNewWindow(content)
|
||||
.always(function () {
|
||||
try {
|
||||
options.deferred.resolve();
|
||||
} catch (err) {
|
||||
console.warn('Error notifying deferred', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Use a new window for printing
|
||||
printContentInNewWindow(content)
|
||||
.always(function () {
|
||||
try {
|
||||
options.deferred.resolve();
|
||||
} catch (err) {
|
||||
console.warn('Error notifying deferred', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
return this;
|
||||
};
|
||||
})(jQuery);
|
||||
+2
File diff suppressed because one or more lines are too long
@@ -0,0 +1,171 @@
|
||||
$(function () {
|
||||
//加载弹出层
|
||||
layui.use(['form','element'],
|
||||
function() {
|
||||
layer = layui.layer;
|
||||
element = layui.element;
|
||||
});
|
||||
|
||||
//触发事件
|
||||
var tab = {
|
||||
tabAdd: function(title,url,id){
|
||||
//新增一个Tab项
|
||||
element.tabAdd('xbs_tab', {
|
||||
title: title
|
||||
,content: '<iframe tab-id="'+id+'" frameborder="0" src="'+url+'" scrolling="yes" class="x-iframe"></iframe>'
|
||||
,id: id
|
||||
})
|
||||
}
|
||||
,tabDelete: function(othis){
|
||||
//删除指定Tab项
|
||||
element.tabDelete('xbs_tab', '44'); //删除:“商品管理”
|
||||
|
||||
|
||||
othis.addClass('layui-btn-disabled');
|
||||
}
|
||||
,tabChange: function(id){
|
||||
//切换到指定Tab项
|
||||
element.tabChange('xbs_tab', id); //切换到:用户管理
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
tableCheck = {
|
||||
init:function () {
|
||||
$(".layui-form-checkbox").click(function(event) {
|
||||
if($(this).hasClass('layui-form-checked')){
|
||||
$(this).removeClass('layui-form-checked');
|
||||
if($(this).hasClass('header')){
|
||||
$(".layui-form-checkbox").removeClass('layui-form-checked');
|
||||
}
|
||||
}else{
|
||||
$(this).addClass('layui-form-checked');
|
||||
if($(this).hasClass('header')){
|
||||
$(".layui-form-checkbox").addClass('layui-form-checked');
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
getData:function () {
|
||||
var obj = $(".layui-form-checked").not('.header');
|
||||
var arr=[];
|
||||
obj.each(function(index, el) {
|
||||
arr.push(obj.eq(index).attr('data-id'));
|
||||
});
|
||||
return arr;
|
||||
}
|
||||
}
|
||||
|
||||
//开启表格多选
|
||||
tableCheck.init();
|
||||
|
||||
|
||||
$('.container .left_open i').click(function(event) {
|
||||
if($('.left-nav').css('left')=='0px'){
|
||||
$('.left-nav').animate({left: '-221px'}, 100);
|
||||
$('.page-content').animate({left: '0px'}, 100);
|
||||
$('.page-content-bg').hide();
|
||||
}else{
|
||||
$('.left-nav').animate({left: '0px'}, 100);
|
||||
$('.page-content').animate({left: '221px'}, 100);
|
||||
if($(window).width()<768){
|
||||
$('.page-content-bg').show();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
$('.page-content-bg').click(function(event) {
|
||||
$('.left-nav').animate({left: '-221px'}, 100);
|
||||
$('.page-content').animate({left: '0px'}, 100);
|
||||
$(this).hide();
|
||||
});
|
||||
|
||||
$('.layui-tab-close').click(function(event) {
|
||||
$('.layui-tab-title li').eq(0).find('i').remove();
|
||||
});
|
||||
|
||||
//左侧菜单效果
|
||||
// $('#content').bind("click",function(event){
|
||||
$('.left-nav #nav li').click(function (event) {
|
||||
|
||||
if($(this).children('.sub-menu').length){
|
||||
if($(this).hasClass('open')){
|
||||
$(this).removeClass('open');
|
||||
$(this).find('.nav_right').html('');
|
||||
$(this).children('.sub-menu').stop().slideUp();
|
||||
$(this).siblings().children('.sub-menu').slideUp();
|
||||
}else{
|
||||
$(this).addClass('open');
|
||||
$(this).children('a').find('.nav_right').html('');
|
||||
$(this).children('.sub-menu').stop().slideDown();
|
||||
$(this).siblings().children('.sub-menu').stop().slideUp();
|
||||
$(this).siblings().find('.nav_right').html('');
|
||||
$(this).siblings().removeClass('open');
|
||||
}
|
||||
}else{
|
||||
|
||||
var url = $(this).children('a').attr('_href');
|
||||
var title = $(this).find('cite').html();
|
||||
var index = $('.left-nav #nav li').index($(this));
|
||||
|
||||
for (var i = 0; i <$('.x-iframe').length; i++) {
|
||||
if($('.x-iframe').eq(i).attr('tab-id')==index+1){
|
||||
tab.tabChange(index+1);
|
||||
event.stopPropagation();
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
tab.tabAdd(title,url,index+1);
|
||||
tab.tabChange(index+1);
|
||||
}
|
||||
|
||||
event.stopPropagation();
|
||||
|
||||
})
|
||||
|
||||
})
|
||||
|
||||
/*弹出层*/
|
||||
/*
|
||||
参数解释:
|
||||
title 标题
|
||||
url 请求的url
|
||||
id 需要操作的数据id
|
||||
w 弹出层宽度(缺省调默认值)
|
||||
h 弹出层高度(缺省调默认值)
|
||||
*/
|
||||
function x_admin_show(title,url,w,h){
|
||||
if (title == null || title == '') {
|
||||
title=false;
|
||||
};
|
||||
if (url == null || url == '') {
|
||||
url="404.html";
|
||||
};
|
||||
if (w == null || w == '') {
|
||||
w=($(window).width()*0.9);
|
||||
};
|
||||
if (h == null || h == '') {
|
||||
h=($(window).height() - 50);
|
||||
};
|
||||
layer.open({
|
||||
type: 2,
|
||||
area: [w+'px', h +'px'],
|
||||
fix: false, //不固定
|
||||
maxmin: true,
|
||||
shadeClose: true,
|
||||
shade:0.4,
|
||||
title: title,
|
||||
content: url
|
||||
});
|
||||
}
|
||||
|
||||
/*关闭弹出框口*/
|
||||
function x_admin_close(){
|
||||
var index = parent.layer.getFrameIndex(window.name);
|
||||
parent.layer.close(index);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user