gdoo/public/assets/dist/index.min.js

1331 lines
42 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
/* Modernizr 2.8.3 (Custom Build) | MIT & BSD
* Build: http://modernizr.com/download/#-fontface-backgroundsize-borderimage-borderradius-boxshadow-flexbox-flexboxlegacy-hsla-multiplebgs-opacity-rgba-textshadow-cssanimations-csscolumns-generatedcontent-cssgradients-cssreflections-csstransforms-csstransforms3d-csstransitions-applicationcache-canvas-canvastext-draganddrop-hashchange-history-audio-video-indexeddb-input-inputtypes-localstorage-postmessage-sessionstorage-websockets-websqldatabase-webworkers-geolocation-inlinesvg-smil-svg-svgclippaths-touch-webgl-shiv-cssclasses-teststyles-testprop-testallprops-hasevent-prefixes-domprefixes-load
*/
;
window.Modernizr = function (a, b, c) {
function C(a) {
j.cssText = a;
}
function D(a, b) {
return C(n.join(a + ";") + (b || ""));
}
function E(a, b) {
return _typeof(a) === b;
}
function F(a, b) {
return !!~("" + a).indexOf(b);
}
function G(a, b) {
for (var d in a) {
var e = a[d];
if (!F(e, "-") && j[e] !== c) return b == "pfx" ? e : !0;
}
return !1;
}
function H(a, b, d) {
for (var e in a) {
var f = b[a[e]];
if (f !== c) return d === !1 ? a[e] : E(f, "function") ? f.bind(d || b) : f;
}
return !1;
}
function I(a, b, c) {
var d = a.charAt(0).toUpperCase() + a.slice(1),
e = (a + " " + p.join(d + " ") + d).split(" ");
return E(b, "string") || E(b, "undefined") ? G(e, b) : (e = (a + " " + q.join(d + " ") + d).split(" "), H(e, b, c));
}
function J() {
e.input = function (c) {
for (var d = 0, e = c.length; d < e; d++) {
u[c[d]] = c[d] in k;
}
return u.list && (u.list = !!b.createElement("datalist") && !!a.HTMLDataListElement), u;
}("autocomplete autofocus list placeholder max min multiple pattern required step".split(" ")), e.inputtypes = function (a) {
for (var d = 0, e, f, h, i = a.length; d < i; d++) {
k.setAttribute("type", f = a[d]), e = k.type !== "text", e && (k.value = l, k.style.cssText = "position:absolute;visibility:hidden;", /^range$/.test(f) && k.style.WebkitAppearance !== c ? (g.appendChild(k), h = b.defaultView, e = h.getComputedStyle && h.getComputedStyle(k, null).WebkitAppearance !== "textfield" && k.offsetHeight !== 0, g.removeChild(k)) : /^(search|tel)$/.test(f) || (/^(url|email)$/.test(f) ? e = k.checkValidity && k.checkValidity() === !1 : e = k.value != l)), t[a[d]] = !!e;
}
return t;
}("search tel url email datetime date month week time datetime-local number range color".split(" "));
}
var d = "2.8.3",
e = {},
f = !0,
g = b.documentElement,
h = "modernizr",
i = b.createElement(h),
j = i.style,
k = b.createElement("input"),
l = ":)",
m = {}.toString,
n = " -webkit- -moz- -o- -ms- ".split(" "),
o = "Webkit Moz O ms",
p = o.split(" "),
q = o.toLowerCase().split(" "),
r = {
svg: "http://www.w3.org/2000/svg"
},
s = {},
t = {},
u = {},
v = [],
w = v.slice,
x,
y = function y(a, c, d, e) {
var f,
i,
j,
k,
l = b.createElement("div"),
m = b.body,
n = m || b.createElement("body");
if (parseInt(d, 10)) while (d--) {
j = b.createElement("div"), j.id = e ? e[d] : h + (d + 1), l.appendChild(j);
}
return f = ["&#173;", '<style id="s', h, '">', a, "</style>"].join(""), l.id = h, (m ? l : n).innerHTML += f, n.appendChild(l), m || (n.style.background = "", n.style.overflow = "hidden", k = g.style.overflow, g.style.overflow = "hidden", g.appendChild(n)), i = c(l, a), m ? l.parentNode.removeChild(l) : (n.parentNode.removeChild(n), g.style.overflow = k), !!i;
},
z = function () {
function d(d, e) {
e = e || b.createElement(a[d] || "div"), d = "on" + d;
var f = (d in e);
return f || (e.setAttribute || (e = b.createElement("div")), e.setAttribute && e.removeAttribute && (e.setAttribute(d, ""), f = E(e[d], "function"), E(e[d], "undefined") || (e[d] = c), e.removeAttribute(d))), e = null, f;
}
var a = {
select: "input",
change: "input",
submit: "form",
reset: "form",
error: "img",
load: "img",
abort: "img"
};
return d;
}(),
A = {}.hasOwnProperty,
B;
!E(A, "undefined") && !E(A.call, "undefined") ? B = function B(a, b) {
return A.call(a, b);
} : B = function B(a, b) {
return b in a && E(a.constructor.prototype[b], "undefined");
}, Function.prototype.bind || (Function.prototype.bind = function (b) {
var c = this;
if (typeof c != "function") throw new TypeError();
var d = w.call(arguments, 1),
e = function e() {
if (this instanceof e) {
var a = function a() {};
a.prototype = c.prototype;
var f = new a(),
g = c.apply(f, d.concat(w.call(arguments)));
return Object(g) === g ? g : f;
}
return c.apply(b, d.concat(w.call(arguments)));
};
return e;
}), s.flexbox = function () {
return I("flexWrap");
}, s.flexboxlegacy = function () {
return I("boxDirection");
}, s.canvas = function () {
var a = b.createElement("canvas");
return !!a.getContext && !!a.getContext("2d");
}, s.canvastext = function () {
return !!e.canvas && !!E(b.createElement("canvas").getContext("2d").fillText, "function");
}, s.webgl = function () {
return !!a.WebGLRenderingContext;
}, s.touch = function () {
var c;
return "ontouchstart" in a || a.DocumentTouch && b instanceof DocumentTouch ? c = !0 : y(["@media (", n.join("touch-enabled),("), h, ")", "{#modernizr{top:9px;position:absolute}}"].join(""), function (a) {
c = a.offsetTop === 9;
}), c;
}, s.geolocation = function () {
return "geolocation" in navigator;
}, s.postmessage = function () {
return !!a.postMessage;
}, s.websqldatabase = function () {
return !!a.openDatabase;
}, s.indexedDB = function () {
return !!I("indexedDB", a);
}, s.hashchange = function () {
return z("hashchange", a) && (b.documentMode === c || b.documentMode > 7);
}, s.history = function () {
return !!a.history && !!history.pushState;
}, s.draganddrop = function () {
var a = b.createElement("div");
return "draggable" in a || "ondragstart" in a && "ondrop" in a;
}, s.websockets = function () {
return "WebSocket" in a || "MozWebSocket" in a;
}, s.rgba = function () {
return C("background-color:rgba(150,255,150,.5)"), F(j.backgroundColor, "rgba");
}, s.hsla = function () {
return C("background-color:hsla(120,40%,100%,.5)"), F(j.backgroundColor, "rgba") || F(j.backgroundColor, "hsla");
}, s.multiplebgs = function () {
return C("background:url(https://),url(https://),red url(https://)"), /(url\s*\(.*?){3}/.test(j.background);
}, s.backgroundsize = function () {
return I("backgroundSize");
}, s.borderimage = function () {
return I("borderImage");
}, s.borderradius = function () {
return I("borderRadius");
}, s.boxshadow = function () {
return I("boxShadow");
}, s.textshadow = function () {
return b.createElement("div").style.textShadow === "";
}, s.opacity = function () {
return D("opacity:.55"), /^0.55$/.test(j.opacity);
}, s.cssanimations = function () {
return I("animationName");
}, s.csscolumns = function () {
return I("columnCount");
}, s.cssgradients = function () {
var a = "background-image:",
b = "gradient(linear,left top,right bottom,from(#9f9),to(white));",
c = "linear-gradient(left top,#9f9, white);";
return C((a + "-webkit- ".split(" ").join(b + a) + n.join(c + a)).slice(0, -a.length)), F(j.backgroundImage, "gradient");
}, s.cssreflections = function () {
return I("boxReflect");
}, s.csstransforms = function () {
return !!I("transform");
}, s.csstransforms3d = function () {
var a = !!I("perspective");
return a && "webkitPerspective" in g.style && y("@media (transform-3d),(-webkit-transform-3d){#modernizr{left:9px;position:absolute;height:3px;}}", function (b, c) {
a = b.offsetLeft === 9 && b.offsetHeight === 3;
}), a;
}, s.csstransitions = function () {
return I("transition");
}, s.fontface = function () {
var a;
return y('@font-face {font-family:"font";src:url("https://")}', function (c, d) {
var e = b.getElementById("smodernizr"),
f = e.sheet || e.styleSheet,
g = f ? f.cssRules && f.cssRules[0] ? f.cssRules[0].cssText : f.cssText || "" : "";
a = /src/i.test(g) && g.indexOf(d.split(" ")[0]) === 0;
}), a;
}, s.generatedcontent = function () {
var a;
return y(["#", h, "{font:0/0 a}#", h, ':after{content:"', l, '";visibility:hidden;font:3px/1 a}'].join(""), function (b) {
a = b.offsetHeight >= 3;
}), a;
}, s.video = function () {
var a = b.createElement("video"),
c = !1;
try {
if (c = !!a.canPlayType) c = new Boolean(c), c.ogg = a.canPlayType('video/ogg; codecs="theora"').replace(/^no$/, ""), c.h264 = a.canPlayType('video/mp4; codecs="avc1.42E01E"').replace(/^no$/, ""), c.webm = a.canPlayType('video/webm; codecs="vp8, vorbis"').replace(/^no$/, "");
} catch (d) {}
return c;
}, s.audio = function () {
var a = b.createElement("audio"),
c = !1;
try {
if (c = !!a.canPlayType) c = new Boolean(c), c.ogg = a.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, ""), c.mp3 = a.canPlayType("audio/mpeg;").replace(/^no$/, ""), c.wav = a.canPlayType('audio/wav; codecs="1"').replace(/^no$/, ""), c.m4a = (a.canPlayType("audio/x-m4a;") || a.canPlayType("audio/aac;")).replace(/^no$/, "");
} catch (d) {}
return c;
}, s.localstorage = function () {
try {
return localStorage.setItem(h, h), localStorage.removeItem(h), !0;
} catch (a) {
return !1;
}
}, s.sessionstorage = function () {
try {
return sessionStorage.setItem(h, h), sessionStorage.removeItem(h), !0;
} catch (a) {
return !1;
}
}, s.webworkers = function () {
return !!a.Worker;
}, s.applicationcache = function () {
return !!a.applicationCache;
}, s.svg = function () {
return !!b.createElementNS && !!b.createElementNS(r.svg, "svg").createSVGRect;
}, s.inlinesvg = function () {
var a = b.createElement("div");
return a.innerHTML = "<svg/>", (a.firstChild && a.firstChild.namespaceURI) == r.svg;
}, s.smil = function () {
return !!b.createElementNS && /SVGAnimate/.test(m.call(b.createElementNS(r.svg, "animate")));
}, s.svgclippaths = function () {
return !!b.createElementNS && /SVGClipPath/.test(m.call(b.createElementNS(r.svg, "clipPath")));
};
for (var K in s) {
B(s, K) && (x = K.toLowerCase(), e[x] = s[K](), v.push((e[x] ? "" : "no-") + x));
}
return e.input || J(), e.addTest = function (a, b) {
if (_typeof(a) == "object") for (var d in a) {
B(a, d) && e.addTest(d, a[d]);
} else {
a = a.toLowerCase();
if (e[a] !== c) return e;
b = typeof b == "function" ? b() : b, typeof f != "undefined" && f && (g.className += " " + (b ? "" : "no-") + a), e[a] = b;
}
return e;
}, C(""), i = k = null, function (a, b) {
function l(a, b) {
var c = a.createElement("p"),
d = a.getElementsByTagName("head")[0] || a.documentElement;
return c.innerHTML = "x<style>" + b + "</style>", d.insertBefore(c.lastChild, d.firstChild);
}
function m() {
var a = s.elements;
return typeof a == "string" ? a.split(" ") : a;
}
function n(a) {
var b = j[a[h]];
return b || (b = {}, i++, a[h] = i, j[i] = b), b;
}
function o(a, c, d) {
c || (c = b);
if (k) return c.createElement(a);
d || (d = n(c));
var g;
return d.cache[a] ? g = d.cache[a].cloneNode() : f.test(a) ? g = (d.cache[a] = d.createElem(a)).cloneNode() : g = d.createElem(a), g.canHaveChildren && !e.test(a) && !g.tagUrn ? d.frag.appendChild(g) : g;
}
function p(a, c) {
a || (a = b);
if (k) return a.createDocumentFragment();
c = c || n(a);
var d = c.frag.cloneNode(),
e = 0,
f = m(),
g = f.length;
for (; e < g; e++) {
d.createElement(f[e]);
}
return d;
}
function q(a, b) {
b.cache || (b.cache = {}, b.createElem = a.createElement, b.createFrag = a.createDocumentFragment, b.frag = b.createFrag()), a.createElement = function (c) {
return s.shivMethods ? o(c, a, b) : b.createElem(c);
}, a.createDocumentFragment = Function("h,f", "return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&(" + m().join().replace(/[\w\-]+/g, function (a) {
return b.createElem(a), b.frag.createElement(a), 'c("' + a + '")';
}) + ");return n}")(s, b.frag);
}
function r(a) {
a || (a = b);
var c = n(a);
return s.shivCSS && !g && !c.hasCSS && (c.hasCSS = !!l(a, "article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")), k || q(a, c), a;
}
var c = "3.7.0",
d = a.html5 || {},
e = /^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,
f = /^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,
g,
h = "_html5shiv",
i = 0,
j = {},
k;
(function () {
try {
var a = b.createElement("a");
a.innerHTML = "<xyz></xyz>", g = "hidden" in a, k = a.childNodes.length == 1 || function () {
b.createElement("a");
var a = b.createDocumentFragment();
return typeof a.cloneNode == "undefined" || typeof a.createDocumentFragment == "undefined" || typeof a.createElement == "undefined";
}();
} catch (c) {
g = !0, k = !0;
}
})();
var s = {
elements: d.elements || "abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output progress section summary template time video",
version: c,
shivCSS: d.shivCSS !== !1,
supportsUnknownElements: k,
shivMethods: d.shivMethods !== !1,
type: "default",
shivDocument: r,
createElement: o,
createDocumentFragment: p
};
a.html5 = s, r(b);
}(this, b), e._version = d, e._prefixes = n, e._domPrefixes = q, e._cssomPrefixes = p, e.hasEvent = z, e.testProp = function (a) {
return G([a]);
}, e.testAllProps = I, e.testStyles = y, g.className = g.className.replace(/(^|\s)no-js(\s|$)/, "$1$2") + (f ? " js " + v.join(" ") : ""), e;
}(this, this.document), function (a, b, c) {
function d(a) {
return "[object Function]" == o.call(a);
}
function e(a) {
return "string" == typeof a;
}
function f() {}
function g(a) {
return !a || "loaded" == a || "complete" == a || "uninitialized" == a;
}
function h() {
var a = p.shift();
q = 1, a ? a.t ? m(function () {
("c" == a.t ? _B.injectCss : _B.injectJs)(a.s, 0, a.a, a.x, a.e, 1);
}, 0) : (a(), h()) : q = 0;
}
function i(a, c, d, e, f, i, j) {
function k(b) {
if (!o && g(l.readyState) && (u.r = o = 1, !q && h(), l.onload = l.onreadystatechange = null, b)) {
"img" != a && m(function () {
t.removeChild(l);
}, 50);
for (var d in y[c]) {
y[c].hasOwnProperty(d) && y[c][d].onload();
}
}
}
var j = j || _B.errorTimeout,
l = b.createElement(a),
o = 0,
r = 0,
u = {
t: d,
s: c,
e: f,
a: i,
x: j
};
1 === y[c] && (r = 1, y[c] = []), "object" == a ? l.data = c : (l.src = c, l.type = a), l.width = l.height = "0", l.onerror = l.onload = l.onreadystatechange = function () {
k.call(this, r);
}, p.splice(e, 0, u), "img" != a && (r || 2 === y[c] ? (t.insertBefore(l, s ? null : n), m(k, j)) : y[c].push(l));
}
function j(a, b, c, d, f) {
return q = 0, b = b || "j", e(a) ? i("c" == b ? v : u, a, b, this.i++, c, d, f) : (p.splice(this.i++, 0, a), 1 == p.length && h()), this;
}
function k() {
var a = _B;
return a.loader = {
load: j,
i: 0
}, a;
}
var l = b.documentElement,
m = a.setTimeout,
n = b.getElementsByTagName("script")[0],
o = {}.toString,
p = [],
q = 0,
r = ("MozAppearance" in l.style),
s = r && !!b.createRange().compareNode,
t = s ? l : n.parentNode,
l = a.opera && "[object Opera]" == o.call(a.opera),
l = !!b.attachEvent && !l,
u = r ? "object" : l ? "script" : "img",
v = l ? "script" : u,
w = Array.isArray || function (a) {
return "[object Array]" == o.call(a);
},
x = [],
y = {},
z = {
timeout: function timeout(a, b) {
return b.length && (a.timeout = b[0]), a;
}
},
_A,
_B;
_B = function B(a) {
function b(a) {
var a = a.split("!"),
b = x.length,
c = a.pop(),
d = a.length,
c = {
url: c,
origUrl: c,
prefixes: a
},
e,
f,
g;
for (f = 0; f < d; f++) {
g = a[f].split("="), (e = z[g.shift()]) && (c = e(c, g));
}
for (f = 0; f < b; f++) {
c = x[f](c);
}
return c;
}
function g(a, e, f, g, h) {
var i = b(a),
j = i.autoCallback;
i.url.split(".").pop().split("?").shift(), i.bypass || (e && (e = d(e) ? e : e[a] || e[g] || e[a.split("/").pop().split("?")[0]]), i.instead ? i.instead(a, e, f, g, h) : (y[i.url] ? i.noexec = !0 : y[i.url] = 1, f.load(i.url, i.forceCSS || !i.forceJS && "css" == i.url.split(".").pop().split("?").shift() ? "c" : c, i.noexec, i.attrs, i.timeout), (d(e) || d(j)) && f.load(function () {
k(), e && e(i.origUrl, h, g), j && j(i.origUrl, h, g), y[i.url] = 2;
})));
}
function h(a, b) {
function c(a, c) {
if (a) {
if (e(a)) c || (j = function j() {
var a = [].slice.call(arguments);
k.apply(this, a), l();
}), g(a, j, b, 0, h);else if (Object(a) === a) for (n in m = function () {
var b = 0,
c;
for (c in a) {
a.hasOwnProperty(c) && b++;
}
return b;
}(), a) {
a.hasOwnProperty(n) && (!c && ! --m && (d(j) ? j = function j() {
var a = [].slice.call(arguments);
k.apply(this, a), l();
} : j[n] = function (a) {
return function () {
var b = [].slice.call(arguments);
a && a.apply(this, b), l();
};
}(k[n])), g(a[n], j, b, n, h));
}
} else !c && l();
}
var h = !!a.test,
i = a.load || a.both,
j = a.callback || f,
k = j,
l = a.complete || f,
m,
n;
c(h ? a.yep : a.nope, !!i), i && c(i);
}
var i,
j,
l = this.yepnope.loader;
if (e(a)) g(a, 0, l, 0);else if (w(a)) for (i = 0; i < a.length; i++) {
j = a[i], e(j) ? g(j, 0, l, 0) : w(j) ? _B(j) : Object(j) === j && h(j, l);
} else Object(a) === a && h(a, l);
}, _B.addPrefix = function (a, b) {
z[a] = b;
}, _B.addFilter = function (a) {
x.push(a);
}, _B.errorTimeout = 1e4, null == b.readyState && b.addEventListener && (b.readyState = "loading", b.addEventListener("DOMContentLoaded", _A = function A() {
b.removeEventListener("DOMContentLoaded", _A, 0), b.readyState = "complete";
}, 0)), a.yepnope = k(), a.yepnope.executeStack = h, a.yepnope.injectJs = function (a, c, d, e, i, j) {
var k = b.createElement("script"),
l,
o,
e = e || _B.errorTimeout;
k.src = a;
for (o in d) {
k.setAttribute(o, d[o]);
}
c = j ? h : c || f, k.onreadystatechange = k.onload = function () {
!l && g(k.readyState) && (l = 1, c(), k.onload = k.onreadystatechange = null);
}, m(function () {
l || (l = 1, c(1));
}, e), i ? k.onload() : n.parentNode.insertBefore(k, n);
}, a.yepnope.injectCss = function (a, c, d, e, g, i) {
var e = b.createElement("link"),
j,
c = i ? h : c || f;
e.href = a, e.rel = "stylesheet", e.type = "text/css";
for (j in d) {
e.setAttribute(j, d[j]);
}
g || (n.parentNode.insertBefore(e, n), m(c, 0));
};
}(this, document), Modernizr.load = function () {
yepnope.apply(window, [].slice.call(arguments, 0));
};
/**
* Website: http://git.oschina.net/hbbcs/bootStrap-addTabs
*
* Version : 2.1
*
* Created by joe on 2016-2-4.Update 2017-10-24
*/
(function ($) {
var settings = {
/**
* 直接指定所有页面TABS内容
* @type {String}
*/
content: '',
/**
* 是否可以关闭
* @type {Boolean}
*/
close: true,
/**
* 监视的区域
* @type {String}
*/
monitor: 'body',
/**
* 默认使用iframe还是ajax,true 是iframe,false是ajax
* @type {Boolean}
*/
iframe: true,
/**
* 固定TAB中IFRAME高度,根据需要自己修改
* @type {Number}
*/
height: $(window).height() - 118,
/**
* 目标
* @type {String}
*/
target: '#tabs-list',
/**
* 显示加载条
* @type {Boolean}
*/
loadbar: true,
/**
* 是否使用右键菜单
* @type {Boolean}
*/
contextmenu: false,
/**
* 将打开的tab页记录到本地中刷新页面时自动打开默认不使用
* @type {Boolean}
*/
store: false,
/**
* 保存的项目名称,为了区分项目
* @type {String}
*/
storeName: '',
/**
* 内容样式表
* @type {String}
*/
contentStyle: 'content',
/**
* ajax 的参数
* @type {Object}
*/
ajax: {
'async': true,
'dataType': 'html',
'type': 'get'
},
/**
*
* @type {Object}
*/
local: {
'refreshLabel': '刷新此标签',
'closeThisLabel': '关闭此标签',
'closeOtherLabel': '关闭其他标签',
'closeLeftLabel': '关闭左侧标签',
'closeRightLabel': '关闭右侧标签',
'loadbar': '正在加载内容,请稍候...'
},
/**
* 关闭tab回调函数
* @return {[type]} [description]
*/
callback: function callback() {}
};
var target;
_store = function _store() {
if (_typeof(arguments[0]) == 'object') {
arguments[0].each(function (name, val) {
localStorage.setItem(name, val);
});
} else if (arguments[1]) {
localStorage.setItem(arguments[0], arguments[1]);
} else {
return localStorage.getItem(arguments[0]);
}
};
_click = function _click(obj) {
var a_obj, a_target;
a_obj = _typeof(obj.data('addtab')) == 'object' ? obj.data('addtab') : obj.data();
if (!a_obj.id && !a_obj.addtab) {
a_obj.id = Math.random().toString(36).substring(3, 35);
obj.data('id', a_obj.id);
}
$.addtabs.add({
'target': a_obj.target ? a_obj.target : target,
'id': a_obj.id ? a_obj.id : a_obj.addtab,
'title': a_obj.title ? a_obj.title : obj.html(),
'content': settings.content ? settings.content : a_obj.content,
'url': a_obj.url ? a_obj.url : obj.attr('href'),
'ajax': a_obj.ajax ? a_obj.ajax : false
});
};
_createMenu = function _createMenu(right, icon, text) {
return $('<a>', {
'href': 'javascript:void(0);',
'class': "list-group-item",
'data-right': right
}).append($('<i>', {
'class': 'fa ' + icon
})).append(text);
};
_pop = function _pop(id, e, mouse) {
$('body').find('#popMenu').remove();
var refresh = e.attr('id') ? _createMenu('refresh', 'fa-refresh', settings.local.refreshLabel) : '';
var remove = e.attr('id') ? _createMenu('remove', 'fa-remove', settings.local.closeThisLabel) : '';
var left = e.prev('li').attr('id') ? _createMenu('remove-left', 'fa-chevron-left', settings.local.closeLeftLabel) : '';
var right = e.next('li').attr('id') ? _createMenu('remove-right', 'fa-chevron-right', settings.local.closeRightLabel) : '';
var popHtml = $('<ul>', {
'aria-controls': id,
'class': 'rightMenu list-group',
id: 'popMenu',
'aria-url': e.attr('aria-url'),
'aria-ajax': e.attr('aria-ajax')
}).append(refresh).append(remove).append(_createMenu('remove-circle', 'fa-remove-circle', settings.local.closeOtherLabel)).append(left).append(right);
popHtml.css({
'top': mouse.pageY,
'left': mouse.pageX
});
popHtml.appendTo($('body')).show(); // 刷新页面
$('ul.rightMenu a[data-right=refresh]').on('click', function () {
var id = $(this).parent('ul').attr("aria-controls").substring(4);
var url = $(this).parent('ul').attr('aria-url');
var ajax = $(this).parent('ul').attr('aria-ajax');
$.addtabs.add({
'id': id,
'url': url,
'refresh': true,
'ajax': ajax
});
}); // 关闭自身
$('ul.rightMenu a[data-right=remove]').on('click', function () {
var id = $(this).parent("ul").attr("aria-controls");
if (id.substring(0, 4) != 'tab_') return;
$.addtabs.close({
"id": id
});
$.addtabs.drop();
}); // 关闭其他
$('ul.rightMenu a[data-right=remove-circle]').on('click', function () {
var tab_id = $(this).parent('ul').attr("aria-controls");
target.find('li').each(function () {
var id = $(this).attr('id');
if (id && id != 'tab_' + tab_id) {
$.addtabs.close({
"id": $(this).children('a').attr('aria-controls')
});
}
});
$.addtabs.drop();
}); // 关闭左侧
$('ul.rightMenu a[data-right=remove-left]').on('click', function () {
var tab_id = $(this).parent('ul').attr("aria-controls");
$('#tab_' + tab_id).prevUntil().each(function () {
var id = $(this).attr('id');
if (id && id != 'tab_' + tab_id) {
$.addtabs.close({
"id": $(this).children('a').attr('aria-controls')
});
}
});
$.addtabs.drop();
}); // 关闭右侧
$('ul.rightMenu a[data-right=remove-right]').on('click', function () {
var tab_id = $(this).parent('ul').attr("aria-controls");
$('#tab_' + tab_id).nextUntil().each(function () {
var id = $(this).attr('id');
if (id && id != 'tab_' + tab_id) {
$.addtabs.close({
"id": $(this).children('a').attr('aria-controls')
});
}
});
$.addtabs.drop();
});
popHtml.mouseleave(function () {
$(this).hide();
});
$('body').click(function () {
popHtml.hide();
});
};
_listen = function _listen() {
$(settings.monitor).on('click', '[data-addtab]', function () {
_click($(this));
$.addtabs.drop();
});
$('body').on('click', '.tab-close', function () {
var id = $(this).prev("a").attr("aria-controls");
$.addtabs.close({
'id': id
});
$.addtabs.drop();
});
$('body').on('mouseover', 'li[role = "presentation"]', function () {
$(this).find('.tab-close').show();
});
$('body').on('mouseleave', 'li[role = "presentation"]', function () {
$(this).find('.tab-close').hide();
});
if (settings.contextmenu) {
//obj上禁用右键菜单
$('body').on('contextmenu', 'li[role=presentation]', function (e) {
var id = $(this).children('a').attr('aria-controls');
_pop(id, $(this), e);
return false;
});
}
var el;
$('body').on('dragstart.h5s', '.tabs-list li', function (e) {
el = $(this); // 清除拖动操作携带的数据,否者在部分浏览器上会打开新页面
if (e.originalEvent && e.originalEvent.dataTransfer && 'function' == typeof e.originalEvent.dataTransfer.clearData) {
e.originalEvent.dataTransfer.clearData();
}
}).on('dragover.h5s dragenter.h5s drop.h5s', '.tabs-list li', function (e) {
if (el == $(this)) return;
$('.dragBack').removeClass('dragBack');
$(this).addClass('dragBack'); // 支持前后调整标签顺序
if (el.index() < $(this).index()) {
el.insertAfter($(this));
} else {
$(this).insertAfter(el);
}
}).on('dragend.h5s', '.tabs-list li', function () {
$('.dragBack').removeClass('dragBack');
});
$('body').on('shown.bs.tab', 'a[data-toggle="tab"]', function () {
var id = $(this).parent('li').attr('id');
id = id ? id.substring(8) : '';
if (settings.store) {
var tabs = $.parseJSON(_store('addtabs' + settings.storeName));
$.each(tabs, function (k, t) {
t.id == id ? t.active = 'true' : delete t.active;
});
tabs = JSON.stringify(tabs);
_store('addtabs' + settings.storeName, tabs);
}
}); // 浏览器大小改变时自动收放tab
$(window).on('resize', function () {
$.addtabs.drop();
});
};
$.addtabs = function (options) {
$.addtabs.set(options);
_listen();
if (settings.store) {
var tabs = _store('addtabs' + settings.storeName) ? $.parseJSON(_store('addtabs' + settings.storeName)) : {};
var active;
$.each(tabs, function (k, t) {
if (t.active) active = k;
$.addtabs.add(t);
});
if (active) {
target.children('.active').removeClass('active');
$('#tab_' + active).addClass('active');
$('#tabs-content').children('.active').removeClass('active');
$('#' + active).addClass('active');
}
}
};
$.addtabs.set = function () {
if (arguments[0]) {
if (_typeof(arguments[0]) == 'object') {
settings = $.extend(settings, arguments[0] || {});
} else {
settings[arguments[0]] = arguments[1];
}
}
if (_typeof(settings.target) == 'object') {
target = settings.target;
} else {
target = $('body').find(settings.target).length > 0 ? $(settings.target).first() : $('body').find('.tabs-list').first();
}
};
$.addtabs.add = function (opts) {
var a_target, content;
opts.id = opts.id ? opts.id : Math.random().toString(36).substring(3, 35);
if (_typeof(opts.target) == 'object') {
a_target = opts.target;
} else if (typeof opts.target == 'string') {
a_target = $('body').find(opts.target).first();
} else {
a_target = target;
}
var id = 'tab_' + opts.id;
var tab_li = a_target; // 写入cookie
if (settings.store) {
var tabs = _store('addtabs' + settings.storeName) ? $.parseJSON(_store('addtabs' + settings.storeName)) : {};
tabs[id] = opts;
tabs[id].target = _typeof(tabs[id].target) == 'object' ? settings.target : tabs[id].target;
$.each(tabs, function (k, t) {
delete t.active;
});
tabs[id].active = 'true';
tabs = JSON.stringify(tabs);
_store('addtabs' + settings.storeName, tabs);
}
var tab_content = $('#tabs-content');
var lastTabId = tab_content.children('div[role="tabpanel"].active');
localStorage.setItem('addtabs_active_id', lastTabId.attr('id'));
tab_li.children('li[role="presentation"].active').removeClass('active');
tab_content.children('div[role="tabpanel"].active').removeClass('active'); // 如果TAB不存在创建一个新的TAB
if (tab_li.find('#tab_' + id).length < 1) {
var cover = $('<div>', {
'id': 'tabCover',
'class': 'tab-cover'
}); // 创建新TAB的title
var title = $('<li>', {
'role': 'presentation',
'id': 'tab_' + id,
'aria-url': opts.url,
'aria-ajax': opts.ajax ? true : false
}).append($('<a>', {
'href': '#' + id,
'aria-controls': id,
'role': 'tab',
'data-toggle': 'tab'
}).html(opts.title)); // 是否允许关闭
if (settings.close) {
title.append($('<i>', {
'class': 'tab-close fa fa-remove',
'style': 'display:none'
}));
} // 创建新TAB的内容
var content = $('<div>', {
'class': 'tab-pane',
//'class': 'tab-pane ' + settings.contentStyle,
'id': id,
// 'height': settings.height - 5,
'role': 'tabpanel'
}); // 加入TABS
tab_li.append(title);
tab_content.append(content.append(cover));
$.addtabs.drop();
} else if (!opts.refresh) {
$('#tab_' + id).addClass('active');
$('#' + id).addClass('active');
return;
} else {
content = $('#' + id);
content.html('');
} // 加载条
if (settings.loadbar) {
content.html($('<div>', {
'class': ''
}).append($('<div>', {
'class': 'progress-bar progress-bar-striped progress-bar-success active',
'role': 'progressbar',
'aria-valuenow': '100',
'aria-valuemin': '0',
'aria-valuemax': '100',
'style': 'width:100%;position:absolute;height:20px;z-index:9999;'
}).append('<span class="sr-only">100% Complete</span>').append('<span>' + settings.local.loadbar + '</span>')));
} // 是否指定TAB内容
if (opts.content) {
content.html(opts.content);
} else if (settings.iframe == true && (opts.ajax == 'false' || !opts.ajax)) {
//没有内容使用IFRAME打开链接
var iframe = $('<iframe>', {
'class': 'tabIframe',
//'height': settings.height,
'id': 'iframe_' + opts.id,
'name': 'iframe_' + opts.id,
'width': "100%",
'height': "100%",
'frameborder': "no",
'border': "0",
'src': opts.url
});
content.html(iframe);
layer.load(2);
iframe.load(function () {
layer.closeAll('loading');
});
} else {
var ajaxOption = $.extend(settings.ajax, opts.ajax || {});
ajaxOption.url = opts.url;
ajaxOption.error = function (XMLHttpRequest, textStatus) {
content.html(XMLHttpRequest.responseText);
};
ajaxOption.success = function (result) {
content.html(result);
};
$.ajax(ajaxOption);
} // 激活TAB
tab_li.find('#tab_' + id).addClass('active');
tab_content.find('#' + id).addClass('active');
tab_content.find('#' + id).find('#tabCover').remove();
};
$.addtabs.close = function (opts) {
var lastTabId = localStorage.getItem('addtabs_active_id'); // 如果关闭的是当前激活的TAB激活他的前一个TAB
if ($("#tab_" + opts.id).hasClass('active')) {
if ($('#tab_' + opts.id).parents('li.tabdrop').length > 0 && !$('#tab_' + opts.id).parents('li.tabdrop').hasClass('hide')) {
var lastTab = $("#tab_" + lastTabId);
if (lastTab.size() > 0) {
$("#tab_" + lastTabId).tab('show');
} else {
$('#tab_' + opts.id).parents('.tabs-list').find('li').last().tab('show');
}
} else {
var lastTab = $("#tab_" + lastTabId);
if (lastTab.size() > 0) {
$("#tab_" + lastTabId).tab('show');
} else {
$("#tab_" + opts.id).prev('li').tab('show');
}
}
var lastTab = $("#tab_" + lastTabId);
if (lastTab.size() > 0) {
$("#" + lastTabId).addClass('active');
} else {
$("#" + opts.id).prev().addClass('active');
}
} // 关闭TAB
$("#tab_" + opts.id).remove();
$("#" + opts.id).remove();
if (settings.store) {
var tabs = $.parseJSON(_store('addtabs' + settings.storeName));
delete tabs[opts.id];
tabs = JSON.stringify(tabs);
_store('addtabs' + settings.storeName, tabs);
}
$.addtabs.drop();
settings.callback();
};
$.addtabs.closeAll = function (target) {
if (typeof target == 'string') {
target = $('body').find(target);
}
$.each(target.find('li[id]'), function () {
var id = $(this).children('a').attr('aria-controls');
$("#tab_" + id).remove();
$("#" + id).remove();
});
target.find('li[role = "presentation"]').first().addClass('active');
var firstID = target.find('li[role = "presentation"]').first().children('a').attr('aria-controls');
$('#' + firstID).addClass('active');
$.addtabs.drop();
};
$.addtabs.drop = function () {
// 创建下拉标签
var dropdown = $('<li>', {
'class': 'dropdown pull-right hide tabdrop'
}).append($('<a>', {
'class': 'dropdown-toggle',
'data-toggle': 'dropdown',
'href': '#'
}).append($('<i>', {
'class': "fa fa-align-justify"
})).append($(' <b>', {
'class': 'caret'
}))).append($('<ul>', {
'class': "dropdown-menu"
}));
$('body').find('.tabs-list').each(function () {
var element = $(this); // 检测是否已增加
if (element.find('.tabdrop').length < 1) {
dropdown.prependTo(element);
} else {
dropdown = element.find('.tabdrop');
} // 检测是否有下拉样式
if (element.parent().is('.tabs-below')) {
dropdown.addClass('dropup');
}
var collection = 0;
var ww = $(window).width();
var left = $('#navbar-left').width();
var right = $('.nav-user').width();
var www = ww - left - right; // 检查超过一行的标签页
element.append(dropdown.find('li')).find('>li').not('.tabdrop').each(function () {
www = www - $(this).width(); // this.offsetTop > 0 ||
/*
if (element.width() - $(this).position().left - $(this).width() < 83) {
dropdown.find('ul').prepend($(this));
collection++;
}
*/
if (www < $(this).width()) {
dropdown.find('ul').prepend($(this));
collection++;
}
}); // 如果有超出的,显示下拉标签
if (collection > 0) {
dropdown.removeClass('hide');
if (dropdown.find('.active').length == 1) {
dropdown.addClass('active');
} else {
dropdown.removeClass('active');
}
} else {
dropdown.addClass('hide');
}
});
};
})(jQuery);
$(function () {
$.addtabs();
});
function checkMQ() {
// 检查移动或桌面设备
return window.getComputedStyle(document.querySelector('.main-content'), '::before').getPropertyValue('content').replace(/'/g, "").replace(/"/g, "");
}
function addTab(url, id, name) {
var size = $('#tabs-list').find('#tab_tab_' + id).length;
if (size > 0) {
$.addtabs.add({
id: id,
iframeId: id,
target: "#tabs-list",
url: app.url(url),
title: name,
loadbar: true,
refresh: true
});
} else {
$.addtabs.add({
id: id,
target: "#tabs-list",
url: app.url(url),
loadbar: true,
title: name
});
}
/*
// 不刷新页面改变地址
if(history.replaceState) {
var i = url.replace(settings.public_url + '/', '');
history.replaceState(null, '', settings.public_url + '?i=' + i);
}
*/
if ($('.side-nav').hasClass('nav-is-visible')) {
var sidebar = $('.side-nav'),
scroll = $('.nav-scroll'),
sidebarTrigger = $('.nav-trigger');
$([sidebar, sidebarTrigger, scroll]).toggleClass('nav-is-visible');
} // 删除hover样式
$('.side-nav').find('.hover').removeClass('hover');
$('.side-nav').find('.selected').removeClass('selected');
}
$(function () {
var $body = $('body');
$('[data-toggle="addtab"]').on('click', function (event) {
event.preventDefault(); // 无ID不触发事件
var data = $(this).data();
if (data.id == undefined) {
return;
}
addTab(data.url, data.id, data.name);
}); // 缓存dom元素
var mainContent = $('.main-content'),
header = $('.main-header'),
sidebar = $('.side-nav'),
scroll = $('.nav-scroll'),
sidebarTrigger = $('.nav-trigger'); // 仅移动 - 当用户单击菜单时打开侧边栏
sidebarTrigger.on('click', function (event) {
event.preventDefault();
$([sidebar, sidebarTrigger, scroll]).toggleClass('nav-is-visible');
}); // 初始化折叠菜单
var folded = localStorage.getItem("side-folded");
if (folded === 'on') {
$body.addClass('side-folded');
$('.folded').addClass('active');
} // 折叠左边菜单
$(document).on('click', "[data-toggle=side-folded]", function (event) {
event.preventDefault();
$(this).toggleClass('active');
$body.toggleClass('side-folded'); // 保存折叠菜单到本地
localStorage.setItem("side-folded", $body.hasClass('side-folded') === true ? 'on' : 'off');
}); // 单击项并显示子菜单
$('.has-children > a').on('click', function (event) {
var mq = checkMQ(),
selectedItem = $(this);
if (mq == 'mobile' || mq == 'tablet') {
event.preventDefault();
if (selectedItem.parent('li').hasClass('selected')) {
selectedItem.parent('li').removeClass('selected');
} else {
selectedItem.parent().parent().find('>.has-children.selected').removeClass('selected');
selectedItem.parent('li').addClass('selected');
}
}
});
$('.has-children').on('mouseover mouseout', function (event) {
var mq = checkMQ();
if (mq == 'desktop') {
// 鼠标悬浮
if (event.type == 'mouseover') {
var wh = $(window).height();
$(this).addClass('hover');
var list = $(this).find('ul:visible').not('.fix');
list.each(function (i) {
var uh = $(this).height();
var p = $(this).offset();
var c = wh - p.top - uh - 25;
/* 二级菜单和三级菜单高出window */
if (c < 0) {
$(this).css({
top: c
});
$(this).addClass('fix');
}
}); // 鼠标离开
} else if (event.type == 'mouseout') {
$(this).removeClass('hover');
}
}
});
});