wpfw_ewei_shopv2/static/js/web/tip.js
2023-02-14 19:57:32 +08:00

1 line
4.0 KiB
JavaScript

define(["jquery"],function(u){var i={lang:{success:"操作成功",error:"操作失败",exception:"网络异常",processing:"处理中..."}};u("#tip-msgbox").remove(),u("body",top.window.document).append('<div id="tip-msgbox" class="msgbox"></div>'),window.msgbox=u("#tip-msgbox",top.window.document),i.confirm=function(n,t,o){n=(n=n.replace(/&lt;/g,"<")).replace(/&gt;/g,">"),myrequire(["jquery.confirm"],function(){u.confirm({title:"提示",content:n,confirmButtonClass:"btn-primary",cancelButtonClass:"btn-default",confirmButton:"确 定",cancelButton:"取 消",animation:"top",confirm:function(){t&&"function"==typeof t&&t()},cancel:function(){o&&"function"==typeof o&&o()}})})},i.prompt=function(n,t,o){var e=null,i=null,c=!1,r=o?"password":"text";"function"==typeof t?e=t:"object"==typeof t&&(i=t.maxlength||null,e=t.callback&&"function"==typeof t.callback?t.callback:null,c=t.required||!1);var s="prompt_"+ +new Date,l=i?" maxlength='"+i+"' ":"";myrequire(["jquery.confirm"],function(){u.alert({title:"提示",content:"<p>"+n+"</p><p><input id='"+s+"' type='"+r+"' class='form-control' name='confirm' placeholder='"+n+"' "+l+" /></p>",confirmButtonClass:"btn-primary",confirmButton:"确 定",closeIcon:!0,animation:"top",keyboardEnabled:!0,onOpen:function(){setTimeout(function(){u("#"+s).focus()},100)},confirm:function(){var n=u("#"+s).val();if(""==u.trim(n)&&c)return u("#"+s).focus(),!1;e&&"function"==typeof e&&e(n)}})})},i.promptlive=function(n,t,o){var e=null,i=null,c=!1,r=o?"password":"text";"function"==typeof t?e=t:"object"==typeof t&&(i=t.maxlength||null,e=t.callback&&"function"==typeof t.callback?t.callback:null,c=t.required||!1);var s="prompt_"+ +new Date,l=i?" maxlength='"+i+"' ":"";myrequire(["jquery.confirm"],function(){u.alert({title:"提示",content:"<p>"+n+"</p><p><input id='"+s+"' type='"+r+"' class='form-control' name='confirm' placeholder='' "+l+" /></p>",confirmButtonClass:"btn-primary",confirmButton:"确 定",closeIcon:!0,animation:"top",keyboardEnabled:!0,onOpen:function(){setTimeout(function(){u("#"+s).focus()},100)},confirm:function(){var n=u("#"+s).val();return""==u.trim(n)&&c?(u("#"+s).focus(),!1):e&&"function"==typeof e?(e(n),!1):void 0}})})},i.alert=function(n,t){n=(n=n.replace(/&lt;/g,"<")).replace(/&gt;/g,">"),myrequire(["jquery.confirm"],function(){u.alert({title:"提示",content:n,confirmButtonClass:"btn-primary",confirmButton:"确 定",animation:"top",confirm:function(){t&&"function"==typeof t&&t()}})})};function t(n,t){this.$element=u(n),this.options=u.extend({},u.fn.notify.defaults,t);var o='<span class="msg '+(this.options.type?"msg-"+this.options.type:"msg-success")+'">'+this.options.message+"</span>";return this.$element.html(o),this}t.prototype.show=function(){if(this.$element.addClass("in"),this.$element.append(this.$note),this.options.autoClose||!0){var n=this;setTimeout(function(){n.close()},this.options.delay||2e3)}},t.prototype.close=function(){var n=this;n.$element.removeClass("in").transitionEnd(function(){n.$element.empty(),n.options.onClosed&&n.options.onClosed(n)}),n.options.onClose&&n.options.onClose(n)},u.fn.notify=function(n){return new t(this,n)},u.fn.notify.defaults={type:"success",delay:3e3,message:""},i.msgbox={show:function(n){n.url&&(n.url=n.url.replace(/&amp;/gi,"&"),n.onClose=function(){redirect(n.url)}),n.message&&17<n.message.length?i.alert(n.message,function(){n.url&&redirect(n.url)}):(notify=window.msgbox.notify(n),notify.show())},suc:function(n,t,o,e){i.msgbox.show({delay:2e3,type:"success",message:n,url:t,onClose:o,onClosed:e})},err:function(n,t,o,e){i.msgbox.show({delay:2e3,type:"error",message:n,url:t,onClose:o,onClosed:e})}},i.impower=function(n,t,o){n=(n=n.replace(/&lt;/g,"<")).replace(/&gt;/g,">"),myrequire(["jquery.confirm"],function(){u.confirm({title:" ",content:n,confirmButtonClass:"btn-default",cancelButtonClass:"btn-primary",confirmButton:"重新上传",cancelButton:"审核完成",animation:"top",closeIcon:!0,confirm:function(){t&&"function"==typeof t&&t()},cancel:function(){o&&"function"==typeof o&&o()}})})},window.tip=i});