123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 |
- /**
- * power
- * @author luoyifan
- * 2018-11-22 17:32:00
- */
- 'use strict';
- (function ($) {
- $.yvan = $.yvan || {};
- var loadingLayerHandler;
- function alert(title, msg, icon, fn) {
- var opts = {
- title: '提示',
- msg: msg,
- icon: icon,
- onMove: function (left, top) {
- //防止越界
- var $w = $(this);
- if (left < 0) {
- $w.window("move", { left: 0 });
- }
- if (top < 0) {
- $w.window("move", { top: 0 });
- }
- }
- };
- if (fn) {
- $.extend(opts, {
- closable: false,
- fn: fn
- });
- }
- var $window = $.messager.alert(opts);
- //实时拖动
- $window.window('window').draggable({
- onStartDrag: function () { },
- onDrag: function (e) {
- $window.window('move', {
- left: e.data.left,
- top: e.data.top
- });
- },
- onStopDrag: function (e) {
- $window.window('move', {
- left: e.data.left,
- top: e.data.top
- });
- }
- });
- };
- $.extend($.yvan, {
- //右下角弹出提示窗口
- notify: function (option) {
- option = $.extend({}, $.yvan.notify.default, option);
- toastr.options = {
- closeButton: option.showClose,
- debug: false,
- newestOnTop: false,
- progressBar: true,
- positionClass: "toast-bottom-right",
- preventDuplicates: false,
- onclick: option.onClick,
- showDuration: "50",
- hideDuration: "50",
- extendedTimeOut: "1000",
- showEasing: "swing",
- hideEasing: "linear",
- showMethod: "fadeIn",
- hideMethod: "fadeOut"
- };
- if ($.type(option.autoClose) === 'number') {
- toastr.options.timeOut = option.autoClose;
- } else if (option.autoClose === false) {
- toastr.options.timeOut = -1;
- } else {
- toastr.options.timeOut = 2000;
- }
- toastr[option.type](option.body, option.title);
- },
- progress: function (msg) {
- var $dom = $(
- '<div class="loading-wrap" style="top:0;left:0;bottom:0;right:0;opacity: .6;">' +
- '<div class="spinner">' +
- ' <div class="spinner-container container1">\n' +
- ' <div class="circle1"></div>\n' +
- ' <div class="circle2"></div>\n' +
- ' <div class="circle3"></div>\n' +
- ' <div class="circle4"></div>\n' +
- ' </div>\n' +
- ' <div class="spinner-container container2">\n' +
- ' <div class="circle1"></div>\n' +
- ' <div class="circle2"></div>\n' +
- ' <div class="circle3"></div>\n' +
- ' <div class="circle4"></div>\n' +
- ' </div>\n' +
- ' <div class="spinner-container container3">\n' +
- ' <div class="circle1"></div>\n' +
- ' <div class="circle2"></div>\n' +
- ' <div class="circle3"></div>\n' +
- ' <div class="circle4"></div>\n' +
- ' </div>' +
- '</div>' +
- '</div>'
- );
- $('body').append($dom);
- },
- closep: function () {
- $('body').find('.loading-wrap').remove();
- },
- msg: function (m, callback) {
- $('body').down('msg').remove();
- var $w = $(
- //'<div xtype="msg" class="layui-layer layui-layer-dialog layui-layer-border layui-layer-msg layui-layer-hui yvan-anim yvan-anim-00" style="z-index: 10000;">' +
- '<div xtype="msg" class="yvan-msg yvan-anim yvan-anim-00">' +
- ' <div class="yvan-msg-content">' + m + '</div>' +
- '</div>');
- $('body').append($w);
- var iframeWidth = $w.parent().width();
- var iframeHeight = $w.parent().height();
- var windowWidth = $w.width();
- var windowHeight = $w.height();
- var setWidth = (iframeWidth - windowWidth) / 2;
- var setHeight = (iframeHeight - windowHeight) / 2;
- if (iframeHeight < windowHeight || setHeight < 0) {
- setHeight = 0;
- }
- if (iframeWidth < windowWidth || setWidth < 0) {
- setWidth = 0;
- }
- $w.css({ left: setWidth, top: setHeight });
- setTimeout(function () { $w.remove(); if ($.type(callback) === 'function') {callback()} }, 3000);
- },
- error: function (msg, afterDialog) {
- alert('错误', msg, 'error', afterDialog);
- },
- info: function (msg, afterDialog) {
- alert('提示', msg, 'info', afterDialog);
- },
- alert: function (msg, afterDialog) {
- alert('提示', msg, '', afterDialog);
- },
- confirm: function (title, fn) {
- $.messager.confirm('询问', title, function (r) {
- if ($.type(fn) === 'function') {
- if (r) {
- fn();
- }
- } else {
- if (r) {
- if (fn.hasOwnProperty('yes')) {
- fn.yes();
- }
- } else {
- if (fn.hasOwnProperty('no')) {
- fn.no();
- }
- }
- }
- });
- }
- });
- $.yvan.notify.default = {
- type: 'success',
- showClose: true,
- onClick: function () {
- },
- body: '请设置 body 内容',
- title: '请设置 tital 内容',
- autoClose: false
- };
- })(jQuery);
|