规整代码

develop
Jmysy 2020-06-13 23:14:01 +08:00
parent 6f5d024de0
commit 5303529fb6
4 changed files with 2259 additions and 2222 deletions

View File

@ -1,3 +1,4 @@
layui.define(['table', 'jquery', 'element', 'form', 'pearAuth', 'pearTab', 'pearMenu', 'pearNotice', 'pearFrame'],
function(exports) {
"use strict";

View File

@ -1,21 +1,4 @@
/**
layui hash extend
**/
layui.define(function (exports) {
/**
* jshashes - https://github.com/h2non/jshashes
* Released under the "New BSD" license
*
* Algorithms specification:
*
* MD5 - http://www.ietf.org/rfc/rfc1321.txt
* RIPEMD-160 - http://homes.esat.kuleuven.be/~bosselae/ripemd160.html
* SHA1 - http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
* SHA256 - http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
* SHA512 - http://csrc.nist.gov/publications/fips/fips180-4/fips-180-4.pdf
* HMAC - http://www.ietf.org/rfc/rfc2104.txt
*/
layui.define(function(exports) {
var pearHash;
function utf8Encode(str) {
@ -265,7 +248,8 @@ layui.define(function (exports) {
i, j, triplet;
b64pad = b64pad || '=';
for (i = 0; i < len; i += 3) {
triplet = (input.charCodeAt(i) << 16) | (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0) | (i + 2 < len ? input.charCodeAt(i + 2) : 0);
triplet = (input.charCodeAt(i) << 16) | (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0) | (i + 2 < len ? input.charCodeAt(
i + 2) : 0);
for (j = 0; j < 4; j += 1) {
if (i * 8 + j * 6 > input.length * 8) {
output += b64pad;
@ -288,7 +272,7 @@ layui.define(function (exports) {
* @class Base64
* @constructor
*/
Base64: function () {
Base64: function() {
// private properties
var tab = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
pad = '=', // default pad according with the RFC standard
@ -296,7 +280,7 @@ layui.define(function (exports) {
utf8 = true; // by default enable UTF-8 support encoding
// public method for encoding
this.encode = function (input) {
this.encode = function(input) {
var i, j, triplet,
output = '',
len = input.length;
@ -305,7 +289,8 @@ layui.define(function (exports) {
input = (utf8) ? utf8Encode(input) : input;
for (i = 0; i < len; i += 3) {
triplet = (input.charCodeAt(i) << 16) | (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0) | (i + 2 < len ? input.charCodeAt(i + 2) : 0);
triplet = (input.charCodeAt(i) << 16) | (i + 1 < len ? input.charCodeAt(i + 1) << 8 : 0) | (i + 2 < len ?
input.charCodeAt(i + 2) : 0);
for (j = 0; j < 4; j += 1) {
if (i * 8 + j * 6 > len * 8) {
output += pad;
@ -318,7 +303,7 @@ layui.define(function (exports) {
};
// public method for decoding
this.decode = function (input) {
this.decode = function(input) {
// var b64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
var i, o1, o2, o3, h1, h2, h3, h4, bits, ac,
dec = '',
@ -360,16 +345,16 @@ layui.define(function (exports) {
};
// set custom pad string
this.setPad = function (str) {
this.setPad = function(str) {
pad = str || pad;
return this;
};
// set custom tab string characters
this.setTab = function (str) {
this.setTab = function(str) {
tab = str || tab;
return this;
};
this.setUTF8 = function (bool) {
this.setUTF8 = function(bool) {
if (typeof bool === 'boolean') {
utf8 = bool;
}
@ -385,7 +370,7 @@ layui.define(function (exports) {
* @param {String} str Input String
* @return {String}
*/
CRC32: function (str) {
CRC32: function(str) {
var crc = 0,
x = 0,
y = 0,
@ -442,7 +427,7 @@ layui.define(function (exports) {
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* See <http://pajhome.org.uk/crypt/md5> for more infHashes.
*/
MD5: function (options) {
MD5: function(options) {
/**
* Private config properties. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
@ -453,32 +438,32 @@ layui.define(function (exports) {
utf8 = (options && typeof options.utf8 === 'boolean') ? options.utf8 : true; // enable/disable utf8 encoding
// privileged (public) methods
this.hex = function (s) {
this.hex = function(s) {
return rstr2hex(rstr(s, utf8), hexcase);
};
this.b64 = function (s) {
this.b64 = function(s) {
return rstr2b64(rstr(s), b64pad);
};
this.any = function (s, e) {
this.any = function(s, e) {
return rstr2any(rstr(s, utf8), e);
};
this.raw = function (s) {
this.raw = function(s) {
return rstr(s, utf8);
};
this.hex_hmac = function (k, d) {
this.hex_hmac = function(k, d) {
return rstr2hex(rstr_hmac(k, d), hexcase);
};
this.b64_hmac = function (k, d) {
this.b64_hmac = function(k, d) {
return rstr2b64(rstr_hmac(k, d), b64pad);
};
this.any_hmac = function (k, d, e) {
this.any_hmac = function(k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
* Perform a simple self-test to see if the VM is working
* @return {String} Hexadecimal hash sample
*/
this.vm_test = function () {
this.vm_test = function() {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
@ -486,7 +471,7 @@ layui.define(function (exports) {
* @param {Boolean}
* @return {Object} this
*/
this.setUpperCase = function (a) {
this.setUpperCase = function(a) {
if (typeof a === 'boolean') {
hexcase = a;
}
@ -497,7 +482,7 @@ layui.define(function (exports) {
* @param {String} Pad
* @return {Object} this
*/
this.setPad = function (a) {
this.setPad = function(a) {
b64pad = a || b64pad;
return this;
};
@ -506,7 +491,7 @@ layui.define(function (exports) {
* @param {Boolean}
* @return {Object} [this]
*/
this.setUTF8 = function (a) {
this.setUTF8 = function(a) {
if (typeof a === 'boolean') {
utf8 = a;
}
@ -679,7 +664,7 @@ layui.define(function (exports) {
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* See http://pajhome.org.uk/crypt/md5 for details.
*/
SHA1: function (options) {
SHA1: function(options) {
/**
* Private config properties. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
@ -690,25 +675,25 @@ layui.define(function (exports) {
utf8 = (options && typeof options.utf8 === 'boolean') ? options.utf8 : true; // enable/disable utf8 encoding
// public methods
this.hex = function (s) {
this.hex = function(s) {
return rstr2hex(rstr(s, utf8), hexcase);
};
this.b64 = function (s) {
this.b64 = function(s) {
return rstr2b64(rstr(s, utf8), b64pad);
};
this.any = function (s, e) {
this.any = function(s, e) {
return rstr2any(rstr(s, utf8), e);
};
this.raw = function (s) {
this.raw = function(s) {
return rstr(s, utf8);
};
this.hex_hmac = function (k, d) {
this.hex_hmac = function(k, d) {
return rstr2hex(rstr_hmac(k, d));
};
this.b64_hmac = function (k, d) {
this.b64_hmac = function(k, d) {
return rstr2b64(rstr_hmac(k, d), b64pad);
};
this.any_hmac = function (k, d, e) {
this.any_hmac = function(k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
@ -716,7 +701,7 @@ layui.define(function (exports) {
* @return {String} Hexadecimal hash sample
* @public
*/
this.vm_test = function () {
this.vm_test = function() {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
@ -725,7 +710,7 @@ layui.define(function (exports) {
* @return {Object} this
* @public
*/
this.setUpperCase = function (a) {
this.setUpperCase = function(a) {
if (typeof a === 'boolean') {
hexcase = a;
}
@ -737,7 +722,7 @@ layui.define(function (exports) {
* @return {Object} this
* @public
*/
this.setPad = function (a) {
this.setPad = function(a) {
b64pad = a || b64pad;
return this;
};
@ -747,7 +732,7 @@ layui.define(function (exports) {
* @return {Object} this
* @public
*/
this.setUTF8 = function (a) {
this.setUTF8 = function(a) {
if (typeof a === 'boolean') {
utf8 = a;
}
@ -872,7 +857,7 @@ layui.define(function (exports) {
* See http://pajhome.org.uk/crypt/md5 for details.
* Also http://anmar.eu.org/projects/jssha2/
*/
SHA256: function (options) {
SHA256: function(options) {
/**
* Private properties configuration variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
@ -887,25 +872,25 @@ layui.define(function (exports) {
sha256_K;
/* privileged (public) methods */
this.hex = function (s) {
this.hex = function(s) {
return rstr2hex(rstr(s, utf8));
};
this.b64 = function (s) {
this.b64 = function(s) {
return rstr2b64(rstr(s, utf8), b64pad);
};
this.any = function (s, e) {
this.any = function(s, e) {
return rstr2any(rstr(s, utf8), e);
};
this.raw = function (s) {
this.raw = function(s) {
return rstr(s, utf8);
};
this.hex_hmac = function (k, d) {
this.hex_hmac = function(k, d) {
return rstr2hex(rstr_hmac(k, d));
};
this.b64_hmac = function (k, d) {
this.b64_hmac = function(k, d) {
return rstr2b64(rstr_hmac(k, d), b64pad);
};
this.any_hmac = function (k, d, e) {
this.any_hmac = function(k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
@ -913,7 +898,7 @@ layui.define(function (exports) {
* @return {String} Hexadecimal hash sample
* @public
*/
this.vm_test = function () {
this.vm_test = function() {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
@ -922,7 +907,7 @@ layui.define(function (exports) {
* @return {Object} this
* @public
*/
this.setUpperCase = function (a) {
this.setUpperCase = function(a) {
if (typeof a === 'boolean') {
hexcase = a;
}
@ -934,7 +919,7 @@ layui.define(function (exports) {
* @return {Object} this
* @public
*/
this.setPad = function (a) {
this.setPad = function(a) {
b64pad = a || b64pad;
return this;
};
@ -944,7 +929,7 @@ layui.define(function (exports) {
* @return {Object} this
* @public
*/
this.setUTF8 = function (a) {
this.setUTF8 = function(a) {
if (typeof a === 'boolean') {
utf8 = a;
}
@ -1040,13 +1025,17 @@ layui.define(function (exports) {
}
sha256_K = [
1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993, -1841331548, -1424204075, -670586216, 310598401, 607225278, 1426881987,
1116352408, 1899447441, -1245643825, -373957723, 961987163, 1508970993, -1841331548, -1424204075, -670586216,
310598401, 607225278, 1426881987,
1925078388, -2132889090, -1680079193, -1046744716, -459576895, -272742522,
264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, -1740746414, -1473132947, -1341970488, -1084653625, -958395405, -710438585,
264347078, 604807628, 770255983, 1249150122, 1555081692, 1996064986, -1740746414, -1473132947, -1341970488, -
1084653625, -958395405, -710438585,
113926993, 338241895, 666307205, 773529912, 1294757372, 1396182291,
1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885, -1035236496, -949202525, -778901479, -694614492, -200395387, 275423344,
1695183700, 1986661051, -2117940946, -1838011259, -1564481375, -1474664885, -1035236496, -949202525, -
778901479, -694614492, -200395387, 275423344,
430227734, 506948616, 659060556, 883997877, 958139571, 1322822218,
1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872, -1866530822, -1538233109, -1090935817, -965641998
1537002063, 1747873779, 1955562222, 2024104815, -2067236844, -1933114872, -1866530822, -1538233109, -
1090935817, -965641998
];
function binb(m, l) {
@ -1115,7 +1104,7 @@ layui.define(function (exports) {
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet
* See http://pajhome.org.uk/crypt/md5 for details.
*/
SHA512: function (options) {
SHA512: function(options) {
/**
* Private properties configuration variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
@ -1131,25 +1120,25 @@ layui.define(function (exports) {
sha512_k;
/* privileged (public) methods */
this.hex = function (s) {
this.hex = function(s) {
return rstr2hex(rstr(s));
};
this.b64 = function (s) {
this.b64 = function(s) {
return rstr2b64(rstr(s), b64pad);
};
this.any = function (s, e) {
this.any = function(s, e) {
return rstr2any(rstr(s), e);
};
this.raw = function (s) {
this.raw = function(s) {
return rstr(s, utf8);
};
this.hex_hmac = function (k, d) {
this.hex_hmac = function(k, d) {
return rstr2hex(rstr_hmac(k, d));
};
this.b64_hmac = function (k, d) {
this.b64_hmac = function(k, d) {
return rstr2b64(rstr_hmac(k, d), b64pad);
};
this.any_hmac = function (k, d, e) {
this.any_hmac = function(k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
@ -1157,7 +1146,7 @@ layui.define(function (exports) {
* @return {String} Hexadecimal hash sample
* @public
*/
this.vm_test = function () {
this.vm_test = function() {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
@ -1166,7 +1155,7 @@ layui.define(function (exports) {
* @return {Object} this
* @public
*/
this.setUpperCase = function (a) {
this.setUpperCase = function(a) {
if (typeof a === 'boolean') {
hexcase = a;
}
@ -1178,7 +1167,7 @@ layui.define(function (exports) {
* @return {Object} this
* @public
*/
this.setPad = function (a) {
this.setPad = function(a) {
b64pad = a || b64pad;
return this;
};
@ -1188,7 +1177,7 @@ layui.define(function (exports) {
* @return {Object} this
* @public
*/
this.setUTF8 = function (a) {
this.setUTF8 = function(a) {
if (typeof a === 'boolean') {
utf8 = a;
}
@ -1493,7 +1482,7 @@ layui.define(function (exports) {
* See http://pajhome.org.uk/crypt/md5 for details.
* Also http://www.ocf.berkeley.edu/~jjlin/jsotp/
*/
RMD160: function (options) {
RMD160: function(options) {
/**
* Private properties configuration variables. You may need to tweak these to be compatible with
* the server-side, but the defaults work in most cases.
@ -1536,25 +1525,25 @@ layui.define(function (exports) {
];
/* privileged (public) methods */
this.hex = function (s) {
this.hex = function(s) {
return rstr2hex(rstr(s, utf8));
};
this.b64 = function (s) {
this.b64 = function(s) {
return rstr2b64(rstr(s, utf8), b64pad);
};
this.any = function (s, e) {
this.any = function(s, e) {
return rstr2any(rstr(s, utf8), e);
};
this.raw = function (s) {
this.raw = function(s) {
return rstr(s, utf8);
};
this.hex_hmac = function (k, d) {
this.hex_hmac = function(k, d) {
return rstr2hex(rstr_hmac(k, d));
};
this.b64_hmac = function (k, d) {
this.b64_hmac = function(k, d) {
return rstr2b64(rstr_hmac(k, d), b64pad);
};
this.any_hmac = function (k, d, e) {
this.any_hmac = function(k, d, e) {
return rstr2any(rstr_hmac(k, d), e);
};
/**
@ -1562,7 +1551,7 @@ layui.define(function (exports) {
* @return {String} Hexadecimal hash sample
* @public
*/
this.vm_test = function () {
this.vm_test = function() {
return hex('abc').toLowerCase() === '900150983cd24fb0d6963f7d28e17f72';
};
/**
@ -1571,7 +1560,7 @@ layui.define(function (exports) {
* @return {Object} this
* @public
*/
this.setUpperCase = function (a) {
this.setUpperCase = function(a) {
if (typeof a === 'boolean') {
hexcase = a;
}
@ -1583,7 +1572,7 @@ layui.define(function (exports) {
* @return {Object} this
* @public
*/
this.setPad = function (a) {
this.setPad = function(a) {
if (typeof a !== 'undefined') {
b64pad = a;
}
@ -1595,7 +1584,7 @@ layui.define(function (exports) {
* @return {Object} this
* @public
*/
this.setUTF8 = function (a) {
this.setUTF8 = function(a) {
if (typeof a === 'boolean') {
utf8 = a;
}
@ -1749,26 +1738,26 @@ layui.define(function (exports) {
var RMD160 = new pearHash.RMD160
var Base64 = new pearHash.Base64
pearHash.md5 = function (str) {
pearHash.md5 = function(str) {
return MD5.hex(str);
}
pearHash.sha1 = function (str) {
pearHash.sha1 = function(str) {
return SHA1.hex(str);
}
pearHash.sha256 = function (str) {
pearHash.sha256 = function(str) {
return SHA256.hex(str);
}
pearHash.sha512 = function (str) {
pearHash.sha512 = function(str) {
return SHA512.hex(str);
}
pearHash.crc32 = pearHash.CRC32;
pearHash.rmd160 = function (str) {
pearHash.rmd160 = function(str) {
return RMD160.hex(str);
}
pearHash.Base64Encode = function (str) {
pearHash.Base64Encode = function(str) {
return Base64.encode(str);
}
pearHash.Base64Decode = function (str) {
pearHash.Base64Decode = function(str) {
return Base64.decode(str);
}
exports('pearHash', pearHash);

View File

@ -1,38 +1,38 @@
layui.define(['jquery', 'element'], function (exports) {
layui.define(['jquery', 'element'], function(exports) {
"use strict";
var MOD_NAME = 'pearTab',
$ = layui.jquery,
element = layui.element;
var pearTab = function (opt) {
var pearTab = function(opt) {
this.option = opt;
};
pearTab.prototype.render = function (opt) {
pearTab.prototype.render = function(opt) {
//默认配置值
var option = {
elem:opt.elem,
data:opt.data,
tool:opt.tool,
roll:opt.roll,
index:opt.index,
width:opt.width,
height:opt.height,
tabMax:opt.tabMax
elem: opt.elem,
data: opt.data,
tool: opt.tool,
roll: opt.roll,
index: opt.index,
width: opt.width,
height: opt.height,
tabMax: opt.tabMax
}
var tab = createTab(option);
$("#"+option.elem).html(tab);
$("#" + option.elem).html(tab);
$(".layui-tab[lay-filter='"+option.elem+"'] .layui-tab-prev").click(function(){
rollPage("left",option);
$(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-prev").click(function() {
rollPage("left", option);
})
$(".layui-tab[lay-filter='"+option.elem+"'] .layui-tab-next").click(function(){
rollPage("right",option);
$(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-next").click(function() {
rollPage("right", option);
})
element.init();
@ -41,20 +41,22 @@ layui.define(['jquery', 'element'], function (exports) {
toolEvent(option);
$("#"+option.elem).width(opt.width);
$("#"+option.elem).height(opt.height);
$("#"+option.elem).css({position:"relative"});
$("#" + option.elem).width(opt.width);
$("#" + option.elem).height(opt.height);
$("#" + option.elem).css({
position: "relative"
});
return new pearTab(option);
}
pearTab.prototype.click = function(callback){
pearTab.prototype.click = function(callback) {
var elem = this.option.elem;
element.on('tab('+this.option.elem+')', function(data){
element.on('tab(' + this.option.elem + ')', function(data) {
var id = $("#"+elem+" .layui-tab-title .layui-this").attr("lay-id");
var id = $("#" + elem + " .layui-tab-title .layui-this").attr("lay-id");
callback(id);
@ -62,8 +64,8 @@ layui.define(['jquery', 'element'], function (exports) {
}
pearTab.prototype.positionTab = function(){
var $tabTitle = $('.layui-tab[lay-filter='+this.option.elem+'] .layui-tab-title');
pearTab.prototype.positionTab = function() {
var $tabTitle = $('.layui-tab[lay-filter=' + this.option.elem + '] .layui-tab-title');
var autoLeft = 0;
$tabTitle.children("li").each(function() {
if ($(this).hasClass('layui-this')) {
@ -74,84 +76,92 @@ layui.define(['jquery', 'element'], function (exports) {
});
$tabTitle.animate({
scrollLeft: autoLeft-$tabTitle.width()/3
scrollLeft: autoLeft - $tabTitle.width() / 3
}, 200);
}
pearTab.prototype.addTab = function (opt) {
pearTab.prototype.addTab = function(opt) {
var title = '';
if(opt.close){
if (opt.close) {
title += '<span class="pear-tab-active"></span><span class="able-close">'+opt.title+'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
title += '<span class="pear-tab-active"></span><span class="able-close">' + opt.title +
'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
}else{
} else {
title += '<span class="pear-tab-active"></span><span class="disable-close">'+opt.title+'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
title += '<span class="pear-tab-active"></span><span class="disable-close">' + opt.title +
'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
}
element.tabAdd(this.option.elem, {
title: title,
content: '<iframe id="'+opt.id+'" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' + opt.url +'" style="width:100%;height:100%;"></iframe>',
content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' +
opt.url + '" style="width:100%;height:100%;"></iframe>',
id: opt.id
});
element.tabChange(this.option.elem,opt.id);
element.tabChange(this.option.elem, opt.id);
}
var index =0;
var index = 0;
pearTab.prototype.addTabOnlyByElem = function(elem,opt,time){
pearTab.prototype.addTabOnlyByElem = function(elem, opt, time) {
var title = '';
if(opt.close){
title += '<span class="pear-tab-active"></span><span class="able-close">'+opt.title+'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
}else{
title += '<span class="pear-tab-active"></span><span class="disable-close">'+opt.title+'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
if (opt.close) {
title += '<span class="pear-tab-active"></span><span class="able-close">' + opt.title +
'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
} else {
title += '<span class="pear-tab-active"></span><span class="disable-close">' + opt.title +
'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
}
if ($(".layui-tab[lay-filter='"+elem+"'] .layui-tab-title li[lay-id]").length <= 0) {
if ($(".layui-tab[lay-filter='" + elem + "'] .layui-tab-title li[lay-id]").length <= 0) {
if(time!=false && time!=0){
if (time != false && time != 0) {
var load = '<div id="pear-tab-loading'+index+'" class="pear-tab-loading">'+
'<div class="ball-loader">'+
'<span></span><span></span><span></span><span></span>'+
'</div>'+
var load = '<div id="pear-tab-loading' + index + '" class="pear-tab-loading">' +
'<div class="ball-loader">' +
'<span></span><span></span><span></span><span></span>' +
'</div>' +
'</div>'
$("#"+elem).find(".pear-tab").append(load);
$("#" + elem).find(".pear-tab").append(load);
var pearLoad = $("#"+elem).find("#pear-tab-loading"+index);
var pearLoad = $("#" + elem).find("#pear-tab-loading" + index);
pearLoad.css({display:"block"});
pearLoad.css({
display: "block"
});
setTimeout(function(){
setTimeout(function() {
pearLoad.fadeOut(500,function(){
pearLoad.fadeOut(500, function() {
pearLoad.remove();
});
},time);
}, time);
index++;
}
element.tabAdd(elem, {
title: title,
content: '<iframe id="'+opt.id+'" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' + opt.url +'" style="width:100%;height:100%;"></iframe>',
content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' +
opt.url + '" style="width:100%;height:100%;"></iframe>',
id: opt.id
});
}else{
} else {
var isData = false;
$.each($(".layui-tab[lay-filter='"+elem+"'] .layui-tab-title li[lay-id]"), function() {
$.each($(".layui-tab[lay-filter='" + elem + "'] .layui-tab-title li[lay-id]"), function() {
if ($(this).attr("lay-id") == opt.id) {
@ -161,82 +171,89 @@ layui.define(['jquery', 'element'], function (exports) {
if (isData == false) {
if(time!=false && time!=0){
if (time != false && time != 0) {
var load = '<div id="pear-tab-loading'+index+'" class="pear-tab-loading">'+
'<div class="ball-loader">'+
'<span></span><span></span><span></span><span></span>'+
'</div>'+
var load = '<div id="pear-tab-loading' + index + '" class="pear-tab-loading">' +
'<div class="ball-loader">' +
'<span></span><span></span><span></span><span></span>' +
'</div>' +
'</div>'
$("#"+elem).find(".pear-tab").append(load);
$("#" + elem).find(".pear-tab").append(load);
var pearLoad = $("#"+elem).find("#pear-tab-loading"+index);
var pearLoad = $("#" + elem).find("#pear-tab-loading" + index);
pearLoad.css({display:"block"});
pearLoad.css({
display: "block"
});
setTimeout(function(){
setTimeout(function() {
pearLoad.fadeOut(500,function(){
pearLoad.fadeOut(500, function() {
pearLoad.remove();
});
},time);
}, time);
index++;
}
element.tabAdd(elem, {
title: title,
content: '<iframe id="'+opt.id+'" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' + opt.url +'" style="width:100%;height:100%;"></iframe>',
content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' +
opt.url + '" style="width:100%;height:100%;"></iframe>',
id: opt.id
});
}
}
element.tabChange(elem,opt.id);
element.tabChange(elem, opt.id);
}
/** 添 加 唯 一 选 项 卡 */
pearTab.prototype.addTabOnly = function(opt,time){
pearTab.prototype.addTabOnly = function(opt, time) {
var title = '';
if(opt.close){
if (opt.close) {
title += '<span class="pear-tab-active"></span><span class="able-close">'+opt.title+'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
title += '<span class="pear-tab-active"></span><span class="able-close">' + opt.title +
'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
}else{
} else {
title += '<span class="pear-tab-active"></span><span class="disable-close">'+opt.title+'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
title += '<span class="pear-tab-active"></span><span class="disable-close">' + opt.title +
'</span><i class="layui-icon layui-unselect layui-tab-close">ဆ</i>'
}
if ($(".layui-tab[lay-filter='"+this.option.elem+"'] .layui-tab-title li[lay-id]").length <= 0) {
if ($(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-title li[lay-id]").length <= 0) {
if(time!=false && time!=0){
if (time != false && time != 0) {
var load = '<div id="pear-tab-loading'+index+'" class="pear-tab-loading">'+
'<div class="ball-loader">'+
'<span></span><span></span><span></span><span></span>'+
'</div>'+
var load = '<div id="pear-tab-loading' + index + '" class="pear-tab-loading">' +
'<div class="ball-loader">' +
'<span></span><span></span><span></span><span></span>' +
'</div>' +
'</div>'
$("#"+this.option.elem).find(".pear-tab").append(load);
$("#" + this.option.elem).find(".pear-tab").append(load);
var pearLoad = $("#"+this.option.elem).find("#pear-tab-loading"+index);
var pearLoad = $("#" + this.option.elem).find("#pear-tab-loading" + index);
pearLoad.css({display:"block"});
pearLoad.css({
display: "block"
});
setTimeout(function(){
setTimeout(function() {
pearLoad.fadeOut(500,function(){
pearLoad.fadeOut(500, function() {
pearLoad.remove();
});
},time);
}, time);
index++;
}
@ -244,7 +261,8 @@ layui.define(['jquery', 'element'], function (exports) {
element.tabAdd(this.option.elem, {
title: title,
content: '<iframe id="'+opt.id+'" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' + opt.url +'" style="width:100%;height:100%;"></iframe>',
content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' +
opt.url + '" style="width:100%;height:100%;"></iframe>',
id: opt.id
});
@ -255,13 +273,13 @@ layui.define(['jquery', 'element'], function (exports) {
var isData = false;
//查询当前选项卡数量
if ($(".layui-tab[lay-filter='"+this.option.elem+"'] .layui-tab-title li[lay-id]").length >= this.option.tabMax) {
layer.msg("最多打开"+this.option.tabMax+"个标签页");
if ($(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-title li[lay-id]").length >= this.option.tabMax) {
layer.msg("最多打开" + this.option.tabMax + "个标签页");
return false;
}
$.each($(".layui-tab[lay-filter='"+this.option.elem+"'] .layui-tab-title li[lay-id]"), function() {
$.each($(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-title li[lay-id]"), function() {
if ($(this).attr("lay-id") == opt.id) {
@ -270,102 +288,108 @@ layui.define(['jquery', 'element'], function (exports) {
})
if (isData == false) {
if(time!=false && time!=0){
if (time != false && time != 0) {
var load = '<div id="pear-tab-loading'+index+'" class="pear-tab-loading">'+
'<div class="ball-loader">'+
'<span></span><span></span><span></span><span></span>'+
'</div>'+
var load = '<div id="pear-tab-loading' + index + '" class="pear-tab-loading">' +
'<div class="ball-loader">' +
'<span></span><span></span><span></span><span></span>' +
'</div>' +
'</div>'
$("#"+this.option.elem).find(".pear-tab").append(load);
$("#" + this.option.elem).find(".pear-tab").append(load);
var pearLoad = $("#"+this.option.elem).find("#pear-tab-loading"+index);
var pearLoad = $("#" + this.option.elem).find("#pear-tab-loading" + index);
pearLoad.css({display:"block"});
pearLoad.css({
display: "block"
});
setTimeout(function(){
setTimeout(function() {
pearLoad.fadeOut(500,function(){
pearLoad.fadeOut(500, function() {
pearLoad.remove();
});
},time);
}, time);
index++;
}
element.tabAdd(this.option.elem, {
title: title,
content: '<iframe id="'+opt.id+'" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' + opt.url +'" style="width:100%;height:100%;"></iframe>',
content: '<iframe id="' + opt.id + '" data-frameid="' + opt.id + '" scrolling="auto" frameborder="0" src="' +
opt.url + '" style="width:100%;height:100%;"></iframe>',
id: opt.id
});
}
}
element.tabChange(this.option.elem,opt.id);
element.tabChange(this.option.elem, opt.id);
}
// 刷 新 指 定 的 选 项 卡
pearTab.prototype.refresh = function(time){
pearTab.prototype.refresh = function(time) {
// 刷 新 指 定 的 选 项 卡
if(time!=false && time!=0){
if (time != false && time != 0) {
var load = '<div id="pear-tab-loading'+index+'" class="pear-tab-loading">'+
'<div class="ball-loader">'+
'<span></span><span></span><span></span><span></span>'+
'</div>'+
var load = '<div id="pear-tab-loading' + index + '" class="pear-tab-loading">' +
'<div class="ball-loader">' +
'<span></span><span></span><span></span><span></span>' +
'</div>' +
'</div>'
$("#"+this.option.elem).find(".pear-tab").append(load);
$("#" + this.option.elem).find(".pear-tab").append(load);
var pearLoad = $("#"+this.option.elem).find("#pear-tab-loading"+index);
var pearLoad = $("#" + this.option.elem).find("#pear-tab-loading" + index);
pearLoad.css({display:"block"});
pearLoad.css({
display: "block"
});
setTimeout(function(){
setTimeout(function() {
pearLoad.fadeOut(500,function(){
pearLoad.fadeOut(500, function() {
pearLoad.remove();
});
},time);
}, time);
index++;
}
$(".layui-tab[lay-filter='"+this.option.elem+"'] .layui-tab-content .layui-show").find("iframe")[0].contentWindow.location.reload(true);
$(".layui-tab[lay-filter='" + this.option.elem + "'] .layui-tab-content .layui-show").find("iframe")[0].contentWindow
.location.reload(true);
}
// 重写 Tab Delete 删除 源码存在 Bug 所以重写
function tabDelete(elem,id){
function tabDelete(elem, id) {
//根据 elem id 来删除指定的 layui title li
var tabTitle = $(".layui-tab[lay-filter='"+elem+"']").find(".layui-tab-title");
var tabTitle = $(".layui-tab[lay-filter='" + elem + "']").find(".layui-tab-title");
// 删除指定 id 的 title
var removeTab = tabTitle.find("li[lay-id='"+id+"']");
var removeTab = tabTitle.find("li[lay-id='" + id + "']");
// 查 找 下 方 是 否 存 在 li
var nextNode = removeTab.next("li");
if(nextNode.length){
if (nextNode.length) {
nextNode.addClass("layui-this");
var currId = nextNode.attr("lay-id");
$("#"+elem+" [id='"+currId+"']").parent().addClass("layui-show");
$("#" + elem + " [id='" + currId + "']").parent().addClass("layui-show");
}else{
} else {
var prevNode = removeTab.prev("li");
@ -373,7 +397,7 @@ layui.define(['jquery', 'element'], function (exports) {
var currId = prevNode.attr("lay-id");
$("#"+elem+" [id='"+currId+"']").parent().addClass("layui-show");
$("#" + elem + " [id='" + currId + "']").parent().addClass("layui-show");
}
removeTab.remove();
@ -383,62 +407,63 @@ layui.define(['jquery', 'element'], function (exports) {
var tabContent = $(".layui-tab[lay-filter='"+elem+"']").find("iframe[id='"+id+"']").parent();
var tabContent = $(".layui-tab[lay-filter='" + elem + "']").find("iframe[id='" + id + "']").parent();
tabContent.remove();
}
function createTab(option){
function createTab(option) {
var type ="";
var type = "";
if(option.roll==true){
if (option.roll == true) {
type = "layui-tab-roll";
}
if(option.tool!=false){
if (option.tool != false) {
type = "layui-tab-tool";
}
if(option.roll==true && option.tool!=false){
if (option.roll == true && option.tool != false) {
type = "layui-tab-rollTool";
}
var tab = '<div class="pear-tab '+type+' layui-tab" lay-filter="'+option.elem+'" lay-allowClose="true">';
var tab = '<div class="pear-tab ' + type + ' layui-tab" lay-filter="' + option.elem + '" lay-allowClose="true">';
var title = '<ul class="layui-tab-title">';
var content = '<div class="layui-tab-content">';
var control = '<div class="layui-tab-control"><li class="layui-tab-prev layui-icon layui-icon-left"></li><li class="layui-tab-next layui-icon layui-icon-right"></li><li class="layui-tab-tool layui-icon layui-icon-down"><ul class="layui-nav" lay-filter=""><li class="layui-nav-item"><a href="javascript:;"></a><dl class="layui-nav-child">';
var control =
'<div class="layui-tab-control"><li class="layui-tab-prev layui-icon layui-icon-left"></li><li class="layui-tab-next layui-icon layui-icon-right"></li><li class="layui-tab-tool layui-icon layui-icon-down"><ul class="layui-nav" lay-filter=""><li class="layui-nav-item"><a href="javascript:;"></a><dl class="layui-nav-child">';
// 处 理 选 项 卡 头 部
var index = 0;
$.each(option.data, function(i,item) {
$.each(option.data, function(i, item) {
var TitleItem ='';
var TitleItem = '';
if(option.index == index){
if (option.index == index) {
TitleItem += '<li lay-id="'+item.id+'" class="layui-this"><span class="pear-tab-active"></span>';
TitleItem += '<li lay-id="' + item.id + '" class="layui-this"><span class="pear-tab-active"></span>';
}else{
} else {
TitleItem += '<li lay-id="'+item.id+'" ><span class="pear-tab-active"></span>';
TitleItem += '<li lay-id="' + item.id + '" ><span class="pear-tab-active"></span>';
}
if(item.close){
if (item.close) {
// 当 前 选 项 卡 可 以 关 闭
TitleItem += '<span class="able-close">'+item.title+'</span>';
}else{
TitleItem += '<span class="able-close">' + item.title + '</span>';
} else {
// 当 前 选 项 卡 不 允 许 关 闭
TitleItem += '<span class="disable-close">'+item.title+'</span>';
TitleItem += '<span class="disable-close">' + item.title + '</span>';
}
TitleItem += '<i class="layui-icon layui-unselect layui-tab-close">ဆ</i></li>';
@ -446,15 +471,19 @@ layui.define(['jquery', 'element'], function (exports) {
title += TitleItem;
if(option.index == index){
if (option.index == index) {
// 处 理 显 示 内 容
content += '<div class="layui-show layui-tab-item"><iframe id="'+item.id+'" data-frameid="' + item.id + '" src="'+item.url+'" frameborder="no" border="0" marginwidth="0" marginheight="0" style="width: 100%;height: 100%;"></iframe></div>'
content += '<div class="layui-show layui-tab-item"><iframe id="' + item.id + '" data-frameid="' + item.id +
'" src="' + item.url +
'" frameborder="no" border="0" marginwidth="0" marginheight="0" style="width: 100%;height: 100%;"></iframe></div>'
}else{
} else {
// 处 理 显 示 内 容
content += '<div class="layui-tab-item"><iframe id="'+item.id+'" data-frameid="' + item.id + '" src="'+item.url+'" frameborder="no" border="0" marginwidth="0" marginheight="0" style="width: 100%;height: 100%;"></iframe></div>'
content += '<div class="layui-tab-item"><iframe id="' + item.id + '" data-frameid="' + item.id + '" src="' +
item.url +
'" frameborder="no" border="0" marginwidth="0" marginheight="0" style="width: 100%;height: 100%;"></iframe></div>'
}
@ -481,8 +510,8 @@ layui.define(['jquery', 'element'], function (exports) {
return tab;
}
function rollPage(d,option) {
var $tabTitle = $('#'+option.elem+' .layui-tab-title');
function rollPage(d, option) {
var $tabTitle = $('#' + option.elem + ' .layui-tab-title');
var left = $tabTitle.scrollLeft();
@ -500,50 +529,50 @@ layui.define(['jquery', 'element'], function (exports) {
}
}
function closeEvent(option){
$(".layui-tab[lay-filter='"+option.elem+"']").on("click",".layui-tab-close",function(){
function closeEvent(option) {
$(".layui-tab[lay-filter='" + option.elem + "']").on("click", ".layui-tab-close", function() {
var layid = $(this).parent().attr("lay-id")
element.tabDelete(option.elem, layid);
})
}
function toolEvent(option){
function toolEvent(option) {
$("body .layui-tab[lay-filter='"+option.elem+"']").on("click","#closeThis",function(){
var currentTab = $(".layui-tab[lay-filter='"+option.elem+"'] .layui-tab-title .layui-this");
$("body .layui-tab[lay-filter='" + option.elem + "']").on("click", "#closeThis", function() {
var currentTab = $(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-title .layui-this");
if(currentTab.find("span").is(".able-close")){
if (currentTab.find("span").is(".able-close")) {
var currentId = currentTab.attr("lay-id");
tabDelete(option.elem,currentId);
tabDelete(option.elem, currentId);
}
})
$("body .layui-tab[lay-filter='"+option.elem+"']").on("click","#closeOther",function(){
var currentId = $(".layui-tab[lay-filter='"+option.elem+"'] .layui-tab-title .layui-this").attr("lay-id");
var tabtitle = $(".layui-tab[lay-filter='"+option.elem+"'] .layui-tab-title li");
$("body .layui-tab[lay-filter='" + option.elem + "']").on("click", "#closeOther", function() {
var currentId = $(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-title .layui-this").attr("lay-id");
var tabtitle = $(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-title li");
$.each(tabtitle, function(i) {
if ($(this).attr("lay-id") != currentId) {
if($(this).find("span").is(".able-close")){
tabDelete(option.elem,$(this).attr("lay-id"));
if ($(this).find("span").is(".able-close")) {
tabDelete(option.elem, $(this).attr("lay-id"));
}
}
})
})
$("body .layui-tab[lay-filter='"+option.elem+"']").on("click","#closeAll",function(){
$("body .layui-tab[lay-filter='" + option.elem + "']").on("click", "#closeAll", function() {
var currentId = $(".layui-tab[lay-filter='"+option.elem+"'] .layui-tab-title .layui-this").attr("lay-id");
var tabtitle = $(".layui-tab[lay-filter='"+option.elem+"'] .layui-tab-title li");
var currentId = $(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-title .layui-this").attr("lay-id");
var tabtitle = $(".layui-tab[lay-filter='" + option.elem + "'] .layui-tab-title li");
$.each(tabtitle, function(i) {
if($(this).find("span").is(".able-close")){
tabDelete(option.elem,$(this).attr("lay-id"));
if ($(this).find("span").is(".able-close")) {
tabDelete(option.elem, $(this).attr("lay-id"));
}
@ -551,5 +580,5 @@ layui.define(['jquery', 'element'], function (exports) {
})
}
exports(MOD_NAME,new pearTab());
exports(MOD_NAME, new pearTab());
})

View File

@ -52,6 +52,24 @@
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-card" pear-has-permission="permission-add">
<div class="layui-card-header">
有权限卡片 (显示)
</div>
<div class="layui-card-body">
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-card" pear-has-permission="permission-add">
<div class="layui-card-header">
有权限卡片(显示)
</div>
<div class="layui-card-body">
</div>
</div>
</div>
<div class="layui-col-md6">
<div class="layui-card" pear-has-permission="permission-query">
<div class="layui-card-header">