text: ﻿(function (b) { b.fn.extend({ ProgressBarWars: function (opciones) { defaults = { _window: self, porcentaje: "100", tiempo: 1, color: "", estilo: "yoda", tamanio: "30", alto: "6px" }; var opciones = b.extend({}, defaults, opciones); var ProgressBarWars = opciones._window.$(this); var theidProgressBarWars = ProgressBarWars.attr("id"); ProgressBarWars.append('<span class="barControl" style="width:' + (opciones.tamanio > 100 ? 100 : opciones.tamanio) + '%;"><div class="barContro_space"><span class="' + opciones.estilo + ' bar' + theidProgressBarWars + '" style="height: ' + opciones.alto + ';" ></span></div></span>'); var _theidProgressBarWars = ProgressBarWars.find('.bar' + theidProgressBarWars); _theidProgressBarWars.css(opciones._window.$.extend({ 'width': '0%' }, getStyle(opciones.color))); opciones.tiempo > 0 ? _theidProgressBarWars.animate({ width: opciones.porcentaje + "%" }, opciones.tiempo) : _theidProgressBarWars.css('width', opciones.porcentaje + "%"); this.mover = function (ntamanio) { ntamanio = ntamanio > 100 ? 100 : ntamanio; opciones.tiempo > 0 ? _theidProgressBarWars.animate({ width: ntamanio + "%" }, opciones.tiempo) : _theidProgressBarWars.css('width', ntamanio + "%") }; this.changestyle = function (style) { ProgressBarWars.find('.bar' + theidProgressBarWars).removeClass('vader').removeClass('yoda').removeClass('obi').removeClass('windu').removeClass('c_warning').removeClass('c_fast').addClass(style) }; this.changecolor = function (color) { ProgressBarWars.find('.bar' + theidProgressBarWars).css(getStyle(color)) }; this.changeheight = function (alto) { ProgressBarWars.find('.bar' + theidProgressBarWars).css('height', alto) }; this.changespeed = function (tiempo) { opciones.tiempo = tiempo }; function getStyle(color) { return color != '' ? { 'border-radius': '2px !important', 'display': 'block', 'width': '0%', 'box-shadow': '0px 0px 10px 1px ' + color + ', 0 0 1px ' + color + ', 0 0 1px ' + color + ', 0 0 1px ' + color + ', 0 0 1px ' + color + ', 0 0 1px ' + color + ', 0 0 1px ' + color, 'background-color': '#fff', } : {} }; return this }, colourBrightness: function () { function r(r) { for (var t = ""; "html" != r[0].tagName.toLowerCase() && (t = r.css("background-color"), "rgba(0, 0, 0, 0)" == t || "transparent" == t);)r = r.parent(); return t } var t, a, s, o, e, n = r(this); return n.match(/^rgb/) ? (n = n.match(/rgba?\(([^)]+)\)/)[1], n = n.split(/ *, */).map(Number), t = n[0], a = n[1], s = n[2], o = !n[3] && n[3] != 0 ? 1 : n[3]) : "#" == n[0] && 7 == n.length ? (t = parseInt(n.slice(1, 3), 16), a = parseInt(n.slice(3, 5), 16), s = parseInt(n.slice(5, 7), 16)) : "#" == n[0] && 4 == n.length && (t = parseInt(n[1] + n[1], 16), a = parseInt(n[2] + n[2], 16), s = parseInt(n[3] + n[3], 16)), e = (299 * t + 587 * a + 114 * s) / 1e3, 125 > e && o > 0.2 ? this.removeClass("light").addClass("dark") : this.removeClass("dark").addClass("light"), this }, }); b.extend({ rgbHex: function (a) { return function () { function a(a) { return !isNaN(parseFloat(a)) && isFinite(a) } function b(a) { return a.replace(/^\s+|\s+$/g, "") } function c(c) { return c = b(c), a(c) && c >= 0 && 255 >= c } function d(a) { return /^[0-9a-f]{3}$|^[0-9a-f]{6}$/i.test(b(a)) } function e(a) { return a = parseInt(a, 10).toString(16), 1 === a.length ? "0" + a : a } function f(a) { return parseInt(a, 16).toString() } function g(b) { return b = b.split(","), (3 === b.length || 4 === b.length) && c(b[0]) && c(b[1]) && c(b[2]) ? 4 !== b.length || a(b[3]) ? "#" + e(b[0]).toUpperCase() + e(b[1]).toUpperCase() + e(b[2]).toUpperCase() : null : null } function h(a) { return d(a) ? (3 === a.length && (a = a.charAt(0) + a.charAt(0) + a.charAt(1) + a.charAt(1) + a.charAt(2) + a.charAt(2)), "rgb(" + f(a.substr(0, 2)) + "," + f(a.substr(2, 2)) + "," + f(a.substr(4, 2)) + ")") : void 0 } function i(a) { return a.replace(/\s/g, "") } return function (a) { if (!a) return null; var c = null, d = /^rgba?\((.*)\);?$/, e = /^#/; return a = b(a.toString()), "transparent" === a || "rgba(0,0,0,0)" === i(a) ? "transparent" : d.test(a) ? g(a.match(d)[1]) : e.test(a) ? h(a.split("#").reverse()[0]) : (c = a.split(","), 1 === c.length ? h(a) : 3 === c.length || 4 === c.length ? g(a) : void 0) } }()(a) }, }); b.fn.fakeLoader = function (m) { var f = b.extend({ _window: self, pos: "fixed", top: "0px", left: "0px", width: "100%", height: "100%", zIndex: "99999", bgColor: 'rgb(0,0,0,0)', spinner: "", imagePath: "", defaultinfo: '', closebtn: false, fadeSpeed: 100, }, m); var shade_local = f._window.$('<div class=""></div>'); var mi = f._window.$('<div  class="maininfo"><span id="' + f._window.$(this).attr('ID') + '_mainInfo" ></span></div>'); var close = f._window.$('<a href="javascript:;" class="closebtn" title="手动关闭">关闭</a>'); var progressBox = f._window.$('<div class="fl spinner001"></div>'); var progress = []; var InfoBox = f._window.$('<div style="display:none;font-size:13px;color:#AD0505;max-height:200px;width:100%;border:1px solid #bdbdbd;overflow-y:scroll;overflow-y:visible:"></div>'); var r = f._window.$(''); var l = f._window.$('<div class="fl spinner1"><div class="double-bounce1"></div><div class="double-bounce2"></div>'); var k = f._window.$('<div class="fl spinner2"><div class="spinner-container container1"><div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div></div><div class="spinner-container container2"><div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div></div><div class="spinner-container container3"><div class="circle1"></div><div class="circle2"></div><div class="circle3"></div><div class="circle4"></div></div></div>'); var j = f._window.$('<div class="fl spinner3"><div class="dot1"></div><div class="dot2"></div></div>'); var i = f._window.$('<div class="fl spinner4"></div>'); var h = f._window.$('<div class="fl spinner5"><div class="cube1"></div><div class="cube2"></div></div>'); var g = f._window.$('<div class="fl spinner6"><div class="rect1"></div><div class="rect2"></div><div class="rect3"></div><div class="rect4"></div><div class="rect5"></div></div>'); var e = f._window.$('<div class="fl spinner7"><div class="circ1"></div><div class="circ2"></div><div class="circ3"></div><div class="circ4"></div></div>'); var d = m.el || f._window.$(this); var c = { position: f.pos, width: f.width, height: f.height, top: f.top, left: f.left, backgroundColor: f.bgColor, zIndex: f.zIndex, 'display': 'flex', 'flex-direction': 'column', 'justify-content': 'center', 'align-items': 'center', }; d.css(c); d.each(function () { var n = f.spinner; switch (n) { case "spinner0": d.append(r); break; case "spinner1": d.append(l); break; case "spinner2": d.append(k); break; case "spinner3": d.append(j); break; case "spinner4": d.append(i); break; case "spinner5": d.append(h); break; case "spinner6": d.append(g); break; case "spinner7": d.append(e); break; default: d.html('') }; if (f.imagePath != "") { d.html('<div class="fl"><img src="' + f.imagePath + '"></div>'); a() } }); d.append(shade_local); d.append(mi); d.append(progressBox); d.append(InfoBox); d.on('mainInfo', function (event, message, type, btnText) { mi.find('span').html(message || '').attr('title', message || ''); (message || '') == '' ? (mi.css('display', 'none'), d.find('.fl').not('.spinner001').css('position', 'absolute'), shade_local.removeClass('f-shade-local')) : (shade_local.addClass('f-shade-local'), mi.css('display', 'block'), d.find('.fl').not('.spinner001').css('position', 'relative')); if (type && type === 1) { mi.append(close.html(btnText || '关闭')); close.on('click', function () { d.css('opacity') === '0' ? d.remove() : d.fadeOut(f.fadeSpeed, function () { d.remove() }); d.trigger('close') }) } else { close.off('click'); close.remove() } }); d.on('progressBar', function (event, index, type, params) { if (typeof index == 'undefined') return; var item = progress[index]; if (type && type === 1) { if (item && item.progress) { item.main.remove(); progress[index] = null; d.find('.fl').not('.spinner001').css('position', 'absolute') } } else { if (item && item.main && item.progress && item.info && params) { if (typeof params.speed != 'undefined') { item.progress.changespeed(parseInt(params.speed)) } if (typeof params.alto != 'undefined') { item.progress.changeheight(params.alto) } if (typeof params.style != 'undefined') { item.progress.changestyle(params.style) } else if (typeof params.color != 'undefined') { item.progress.changecolor(params.color) } if (typeof params.val != 'undefined' && !isNaN(parseInt(params.val)) && params.val != -1) { item.progress.mover(parseInt(params.val)) } if (typeof params.info != 'undefined') { item.info.html(params.info) } } else { d.find('.fl').not('.spinner001').css('position', 'relative'); var p = b.extend({ style: 'yoda', color: '', info: null, val: 0, speed: 100, alto: "6px", }, params); item = { main: null, progress: null, info: null, }; item.main = f._window.$('<div><span class="pinfo"></span></br><div class="progressbar" id="progress_' + index + '"></div></div>'); item.progress = item.main.find('.progressbar'); item.progress.ProgressBarWars({ porcentaje: p.val, estilo: p.style, tiempo: p.speed, alto: p.alto, color: p.color }); item.info = item.main.find('.pinfo'); item.main.appendTo(progressBox); progress[index] = item; if (p.info) { item.info.html(p.info) } } } }); d.trigger('mainInfo', [f.defaultinfo, f.closebtn ? 1 : 0]); f._window.$(window).load(function () { f._window.$(window).resize(function () { }) }); function a() { var c = f._window.$(window).width(); var e = f._window.$(window).height(); var d = f._window.$(".fl").outerWidth(); var f = f._window.$(".fl").outerHeight(); f._window.$(".fl").css({ position: "absolute", left: (c / 2) - (d / 2), top: (e / 2) - (f / 2), }) } return this }; var s = function showMask(params, fadeSpeed) { switch (typeof params) { case 'string': b('#' + params).length ? (b('#' + params).css('opacity') === '0' ? b('#' + params).remove() : b('#' + params).fadeOut(fadeSpeed || 100, function () { b(this).remove() })) : !1; break; case 'boolean': if (params) { return showMaskPlus({ el: 'fakeloader', position: "fixed", rgb: "#000", opacity: "0.85", spinner: "spinner2", fadeSpeed: fadeSpeed || 100, }) } else { b('#fakeloader').length ? b('#fakeloader').css('opacity') === '0' ? b('#fakeloader').remove() : b('#fakeloader').fadeOut(fadeSpeed || 100, function () { b(this).remove() }) : !1 } break; case 'object': return showMaskPlus(params); break; default: console.log('%cshowMask : invalid parameter', 'color:#f5a022cc;text-shadow:1px 1px 1px rgba(0,0,0,.2);font-size:15px'); return showMaskPlus({}) } }; var sp = function showMaskPlus(params) { var option = {}, me = {}, _window = self, $_fakeloader, init = () => { option = b.extend(true, { body: 'body', el: 'x' + Date.parse(new Date()) + _window.$('[name=fakeloader]').length.toString(), fadeSpeed: 500, rgb: 'rgb(0,0,0)', opacity: 0, spinner: '', image: '', defaultinfo: '', closebtn: 0, DynamicColor: false, ColorSpeed: 50, Duration: 0, }, params); option.body = getbody(); me._window = _window; me.dynamicColorQueue = []; if (option.body.length > 1) { $_fakeloader = []; b.each(option.body, function (i, item) { $_fakeloader[i] = _window.$('<div id="x' + Date.parse(new Date()) + _window.$('[name=fakeloader]').length.toString() + i + '" name="fakeloader" class="fakeloader"></div>'); build(_window.$(item), $_fakeloader[i]) }) } else { $_fakeloader = _window.$('#' + option.el); $_fakeloader.length > 0 ? $_fakeloader.attr('name', 'fakeloader').html('') : $_fakeloader = _window.$('<div id="' + option.el + '" name="fakeloader" class="fakeloader"></div>'); build(option.body, $_fakeloader) } }; init(); $_fakeloader.length > 0 ? ($.isArray($_fakeloader) ? $_fakeloader.forEach(item => { item.colourBrightness() }) : $_fakeloader.colourBrightness()) : !1; function getbody() { var result = typeof option.body == 'undefined' ? (_window.$('.modal').length > 0 && _window.$('.modal').css('display') != 'none' ? _window.$('.modal') : _window.$('body')) : (_window.$(option.body).length == 0 ? null : _window.$(option.body)); if (result == null) { result = top.$(option.body); if (result.length > 0) { _window = top; return result } for (var i = 0; i < top.length; i++) { if (typeof top[i].$ == 'undefined') continue; result = top[i].$(option.body); if (result.length > 0) { _window = top[i]; return result } } return _window.$('body') } else return result } function build(body, target) { body.data('position', body.css('position')); option.position != 'fixed' ? (body.css('position') ? 1 : body.css({ position: 'absolute' })) : 1; body.append(target.css('display', 'block').fakeLoader({ _window: _window, el: target, pos: option.position, bgColor: checkColor(option.rgb, option.opacity), spinner: option.spinner, imagePath: option.image, defaultinfo: option.defaultinfo, closebtn: option.closebtn, fadeSpeed: option.fadeSpeed }).fadeIn(option.fadeSpeed, function () { option.DynamicColor ? dynamicColor({ type: 'start', index: -1, target: target }) : 1; option.Duration ? setTimeout(function () { option.DynamicColor ? window.clearInterval(target.colorTick) : !1; target.css('opacity') === '0' ? (target.remove(), body.css({ position: body.data('position') })) : target.fadeOut(option.fadeSpeed, function () { target.remove(); body.css({ position: body.data('position') }) }) }, option.Duration - option.fadeSpeed * 2) : 1; typeof done == 'function' ? done() : 1 })) } function dynamicColor(params) { var target = params.type == 'sync' ? $_fakeloader : (params.index != -1 ? $_fakeloader[params.index] : params.target || $_fakeloader); if (typeof target == 'undefined') { return } else if (Array.isArray(target)) { target.forEach(item => { switch (params.type) { case 'start': startDynamicColor_done(item, params.speed); break; case 'stop': stopDynamicColor_done(item); break; case 'sync': item.rgb = b.extend(true, {}, params.rgb || target[params.index || 0].rgb); break; case 'speed': speedDynamicColor_done(item, params.speed); break } }) } else { switch (params.type) { case 'start': startDynamicColor_done(target, params.speed); break; case 'stop': stopDynamicColor_done(target); break; case 'sync': break; case 'speed': speedDynamicColor_done(target, params.speed); break } } } function startDynamicColor_done(target, speed) { target.speed = speed || (target.speed || option.ColorSpeed); target.colorTick && target.colorTick != -1 ? 1 : target.colorTick = setInterval(changeColor, target.speed, target) } function stopDynamicColor_done(target) { target.colorTick && target.colorTick != -1 ? window.clearInterval(target.colorTick) : 1; changeColor(target); target.colorTick = -1 } function speedDynamicColor_done(target, speed) { target.colorTick && target.colorTick != -1 ? (stopDynamicColor_done(target), startDynamicColor_done(target, speed)) : target.speed = speed } function changeColor(target) { if (target.length) { if (!target.rgb || (!target.rgb.r && target.rgb.r != 0) || (!target.rgb.g && target.rgb.g != 0) || (!target.rgb.b && target.rgb.b != 0)) { var rgbArray = option.rgb.substring(4, option.rgb.length - 1).split(','); target.rgb = { r: rgbArray[0], g: rgbArray[1], b: rgbArray[2] } } target.rgb.r == 255 ? (target.rgb.g == 255 ? target.rgb.r-- : (target.rgb.b == 0 ? target.rgb.g++ : target.rgb.b--)) : (target.rgb.g == 255 ? (target.rgb.b == 255 ? target.rgb.g-- : (target.rgb.r == 0 ? target.rgb.b++ : target.rgb.r--)) : (target.rgb.g == 0 ? target.rgb.r++ : target.rgb.g--)); target.css('background-color', checkColor('rgb(' + target.rgb.r + ',' + target.rgb.g + ',' + target.rgb.b + ')', option.opacity)) } else { window.clearInterval(target.colorTick) } } function checkColor(that, opacity) { if (/^(rgb|RGB)/.test(that)) { that = that.replace('rgb', 'rgba'); return that.substring(0, that.length - 1) + ',' + opacity + ')' } else { that = $.rgbHex(that).replace('rgb', 'rgba'); return that.substring(0, that.length - 1) + ',' + opacity + ')' } } function refresh(_option, index) { option = b.extend(true, option, _option); $_fakeloader.length > 0 ? (Array.isArray($_fakeloader) ? (index == -1 ? $_fakeloader.forEach(item => { item.stop().css(option) }) : $_fakeloader[index].stop().css(option)) : $_fakeloader.stop().css(option)) : init(); $_fakeloader.length > 0 ? ($.isArray($_fakeloader) ? $_fakeloader.forEach(item => { item.colourBrightness() }) : $_fakeloader.colourBrightness()) : !1 } function mainMethod(params) { var target = $_fakeloader.length > 0 ? (params.index != -1 ? $_fakeloader[params.index] : $_fakeloader) : 1; if (typeof target == 'undefined') { return } else if (Array.isArray(target)) { target.forEach(item => { switch (params.method) { case 'visible': changeVisible_done(params.type, params.fadeSpeed, item); break; case 'maininfo': mainInfo_done(item, params.message, params.closebtn, params.btnText); break; case 'progressbar': progressBar_done(item, params._index, params.type, params.params); break } }) } else { switch (params.method) { case 'visible': changeVisible_done(params.type, params.fadeSpeed, target); break; case 'maininfo': mainInfo_done(target, params.message, params.closebtn, params.btnText); break; case 'progressbar': progressBar_done(target, params._index, params.type, params.params); break } } } function changeVisible_done(type, fadeSpeed, target) { target.length ? (type != 2 ? (target.css('opacity') === '0' ? (type == 0 ? (changePostion(target), target.remove(), that = null) : (target.css('display') == 'none' ? 1 : (target.css('display', 'none'), changePostion(target)))) : (target.css('display') == 'none' ? (type == 0 ? (target.remove(), that = null) : 1) : target.fadeOut(fadeSpeed, function () { changePostion(target), type == 0 ? (target.remove(), that = null) : 1 }))) : (target.css('display') == 'flex' ? 1 : (changePostion(target), target.css('opacity') === '0' ? target.css('display', 'flex') : target.fadeIn(fadeSpeed, function () { })))) : !1 } function changePostion(target) { var _position = target.parent().css('position'); target.parent().css({ position: target.parent().data('position') || target.parent().css('position') }); target.parent().data('position', _position) } function mainInfo_done(target, message, closebtn, btnText) { target.trigger('mainInfo', [message, closebtn, btnText]) } function progressBar_done(target, index, type, params) { target.trigger('progressBar', [index, type, params]) } me.target = $_fakeloader; me.startDC = function (index, speed) { dynamicColor({ type: 'start', index: typeof index == 'undefined' ? -1 : index, speed: speed }); return me }; me.stopDC = function (index) { dynamicColor({ type: 'stop', index: typeof index == 'undefined' ? -1 : index }); return me }; me.syncDC = function (params) { var _params = { type: 'sync' }; typeof params == 'string' ? (/^(rgb|RGB)/.test(params) ? (params = params.substring(4, option.rgb.length - 1).split(','), _params.rgb = { r: params[0], g: params[1], b: params[2] }) : _params.index = 0) : (typeof params == 'object' ? _params.rgb = params : _params.index = params || 0); dynamicColor(_params); return me }; me.speedDC = function (speed, index) { dynamicColor({ type: 'speed', index: typeof index == 'undefined' ? -1 : index, speed: speed || option.ColorSpeed }); return me }; me.refresh = function (_option, index) { refresh(_option, typeof index == 'undefined' ? -1 : index); return me }; me.close = function (fadeSpeed, index) { mainMethod({ method: 'visible', type: 0, index: index || -1, fadeSpeed: fadeSpeed || option.fadeSpeed }); return me }; me.hide = function (fadeSpeed, index) { mainMethod({ method: 'visible', type: 1, index: index || -1, fadeSpeed: fadeSpeed || option.fadeSpeed }); return me }; me.show = function (fadeSpeed, index) { mainMethod({ method: 'visible', type: 2, index: index || -1, fadeSpeed: fadeSpeed || option.fadeSpeed }); return me }; me.updateMainInfo = function (message, closebtn, btnText, index) { mainMethod({ method: 'maininfo', index: index || -1, message: message, closebtn: closebtn ? 1 : 0, btnText: btnText }); return me }; me.updateProgressBar = function (index, params, _index) { mainMethod({ method: 'progressbar', type: 0, index: _index || -1, _index: index, params: params }); return me }; me.removeProgressBar = function (index, _index) { mainMethod({ method: 'progressbar', type: 1, index: _index || -1, _index: index }); return me }; return me }; window.showMask = s; window.showMaskPlus = sp }(jQuery));