macUI/js/index.min.js

1 line
26 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.

window.Win10={_version:"v1.1.2.5",_debug:!0,_bgs:{main:"",mobile:""},_wallpaperBlur:!0,_countTask:0,_newMsgCount:0,_animated_classes:[],_animated_liveness:0,_switchMenuTooHurry:!1,_lang:"unknown",_iframeOnClick:{resolution:200,iframes:[],interval:null,Iframe:function(){this.element=arguments[0],this.cb=arguments[1],this.hasTracked=!1},track:function(element,cb){if(this.iframes.push(new this.Iframe(element,cb)),!this.interval){let _this=this;this.interval=setInterval((function(){_this.checkClick()}),this.resolution)}},checkClick:function(){if(document.activeElement){let activeElement=document.activeElement;for(let i in this.iframes){let eid=void 0;!(eid=this.iframes[i].element.id)||document.getElementById(eid)?activeElement===this.iframes[i].element?!1===this.iframes[i].hasTracked&&(this.iframes[i].cb.apply(window,[]),this.iframes[i].hasTracked=!0):this.iframes[i].hasTracked=!1:delete this.iframes[i]}}}},_iframe_click_lock_children:{},_renderBar:function(){if(this._countTask<=0)return;let btns;$("#win10_btn_group_middle>.btn").css("width","calc("+1/this._countTask*100+"% - 1px )")},_handleReady:[],_hideShortcut:function(){let that=$("#win10 #win10-shortcuts .shortcut");that.removeClass("animated flipInX"),that.addClass("animated flipOutX")},_showShortcut:function(){let that=$("#win10 #win10-shortcuts .shortcut");that.removeClass("animated flipOutX"),that.addClass("animated flipInX")},_checkBgUrls:function(){let loaders=$("#win10>.img-loader"),flag=!1;if(Win10.isSmallScreen()){if(Win10._bgs.mobile&&(loaders.each((function(){let loader=$(this);loader.attr("src")===Win10._bgs.mobile&&loader.hasClass("loaded")&&(Win10._setBackgroundImg(Win10._bgs.mobile),flag=!0)})),!flag)){let img=$('<img class="img-loader" src="'+Win10._bgs.mobile+'" />');$("#win10").append(img),Win10._onImgComplete(img[0],(function(){img.addClass("loaded"),Win10._setBackgroundImg(Win10._bgs.mobile)}))}}else if(Win10._bgs.main&&(loaders.each((function(){let loader=$(this);loader.attr("src")===Win10._bgs.main&&loader.hasClass("loaded")&&(Win10._setBackgroundImg(Win10._bgs.main),flag=!0)})),!flag)){let img=$('<img class="img-loader" src="'+Win10._bgs.main+'" />');$("#win10").append(img),Win10._onImgComplete(img[0],(function(){img.addClass("loaded"),Win10._setBackgroundImg(Win10._bgs.main)}))}Win10._wallpaperBlur&&$(".background").addClass("blur")},loadScript:function(url,callback){let el=document.createElement("script");el.type="text/javascript",void 0!==callback&&(el.readyState?el.onreadystatechange=function(){"loaded"!=el.readyState&&"complete"!=el.readyState||(el.onreadystatechange=null,callback())}:el.onload=function(){callback()}),el.src=url,document.head.appendChild(el)},_startAnimate:function(){setInterval((function(){let classes_lenth=Win10._animated_classes.length,animated_liveness=Win10._animated_liveness;0!==animated_liveness&&0!==classes_lenth&&$("#win10-menu").hasClass("opened")&&$("#win10-menu>.blocks>.menu_group>.block").each((function(){if(!$(this).hasClass("onAnimate")&&Math.random()<=animated_liveness){let that=$(this),class_animate=Win10._animated_classes[Math.floor(Math.random()*classes_lenth)];that.addClass("onAnimate"),setTimeout((function(){that.addClass(class_animate),setTimeout((function(){that.removeClass("onAnimate"),that.removeClass(class_animate)}),3e3)}),2*Math.random()*1e3)}}))}),1e3)},_onImgComplete:function(img,callback){if(!img)return;let timer=setInterval((function(){img.complete&&(callback(img),clearInterval(timer))}),50)},_setBackgroundImg:function(img){$("#win10 .background").css("background-image","url("+img+")")},_settop:function(layero){isNaN(layero)||(layero=this.getLayeroByIndex(layero));let max_zindex=0;$(".win10-open-iframe").each((function(){z=parseInt($(this).css("z-index")),$(this).css("z-index",z-1),z>max_zindex&&(max_zindex=z)})),layero.css("z-index",max_zindex+1)},_checkTop:function(){let max_index=0,max_z=0,btn=null;$("#win10_btn_group_middle .btn.show").each((function(){let index=$(this).attr("index"),layero,z=Win10.getLayeroByIndex(index).css("z-index");z>max_z&&(max_index=index,max_z=z,btn=$(this))})),this._settop(max_index),$("#win10_btn_group_middle .btn").removeClass("active"),btn&&btn.addClass("active")},_renderContextMenu:function(x,y,menu,trigger){if(this._removeContextMenu(),!0===menu)return;let dom=$("<div class='win10-context-menu'><ul></ul></div>");$("#win10").append(dom);let ul=dom.find("ul");for(let i=0;i<menu.length;i++){let item=menu[i];if("|"!==item)if("string"!=typeof item)if("object"!=typeof item);else{let sub=$("<li>"+item[0]+"</li>");ul.append(sub),sub.click(trigger,item[1])}else ul.append($("<li>"+item+"</li>"));else ul.append($("<hr/>"))}x+150>document.body.clientWidth&&(x-=150),y+dom.height()>document.body.clientHeight&&(y-=dom.height()),dom.css({top:y,left:x})},_removeContextMenu:function(){$(".win10-context-menu").remove()},_closeWin:function(index){$("#win10_"+index).remove(),layer.close(index),Win10._checkTop(),Win10._countTask--,Win10._renderBar()},_fixWindowsHeightAndWidth:function(){let opens=$(".win10-open-iframe"),clientHeight=document.body.clientHeight;opens.each((function(){let layero_opened=$(this),height=layero_opened.css("height");height=parseInt(height.replace("px","")),height+30>=clientHeight&&(layero_opened.css("height",clientHeight-30),layero_opened.find(".layui-layer-content").css("height",clientHeight-62),layero_opened.find(".layui-layer-content iframe").css("height",clientHeight-62))}))},_bind_open_windows:function(){$("#win10").on("click",".win10-open-window",(function(){if($this=$(this),""!==$this.data("url")){let title=$this.data("title")||"",areaAndOffset,icon,bg=$this.data("icon-bg")?$this.data("icon-bg"):"";$this.data("icon-image")&&(icon='<img class="icon '+bg+'" src="'+$this.data("icon-image")+'"/>'),$this.data("icon-font")&&(icon='<i class="fa fa-fw fa-'+$this.data("icon-font")+" icon "+bg+'"></i>'),title||1!==$this.children(".icon").length||1!==$this.children(".title").length||(title=$this.children(".title").html(),icon||(icon=$this.children(".icon").prop("outerHTML"))),$this.data("area-offset")&&(areaAndOffset=$this.data("area-offset"),-1!==areaAndOffset.indexOf(",")&&(areaAndOffset=eval(areaAndOffset))),Win10.openUrl($this.data("url"),icon,title,areaAndOffset)}}))},_init:function(){this._lang=(navigator.language||navigator.browserLanguage).toLowerCase(),$("#win10_btn_win").click((function(){Win10.commandCenterClose(),Win10.menuToggle()})),$("#win10_btn_command").click((function(){Win10.renderCommand(),Win10.menuClose(),Win10.commandCenterToggle()})),$("#win10 .desktop").click((function(){Win10.menuClose(),Win10.commandCenterClose()})),$("#win10").on("click",".notice .btn_close_msg",(function(){let msg=$(this).parents(".notice");$(msg).addClass("animated slideOutRight"),setTimeout((function(){msg.remove()}),500)})),$("#win10_command_center").on("click",".command-header div",(function(){$(this).hasClass("active")||($(this).hasClass("tab-today")?($(this).parent().siblings(".msgs").hide().siblings(".today").show(),$(this).addClass("active").siblings("div").removeClass("active")):($(this).parent().siblings(".today").hide().siblings(".msgs").show(),$(this).addClass("active").siblings("div").removeClass("active")))})),$("#win10_btn_command_center_clean_all").click((function(){let msgs=$("#win10_command_center .msg");msgs.addClass("animated slideOutRight"),setTimeout((function(){msgs.remove()}),1500),setTimeout((function(){Win10.commandCenterClose()}),1e3)})),$("#win10_btn_show_desktop").click((function(){$("#win10 .desktop").click(),Win10.hideWins()})),$("#win10-menu-switcher").click((function(){if(Win10._switchMenuTooHurry)return;Win10._switchMenuTooHurry=!0;let class_name="win10-menu-hidden",list=$("#win10-menu>.list"),blocks=$("#win10-menu>.blocks"),toggleSlide=function(obj){obj.hasClass(class_name)?(obj.addClass("animated slideInLeft"),obj.removeClass("animated slideOutLeft"),obj.removeClass(class_name)):(setTimeout((function(){obj.addClass(class_name)}),450),obj.addClass("animated slideOutLeft"),obj.removeClass("animated slideInLeft"))};toggleSlide(list),toggleSlide(blocks),setTimeout((function(){Win10._switchMenuTooHurry=!1}),520)})),$("#win10_btn_group_middle").click((function(){$("#win10 .desktop").click()})),$(document).on("click",".win10-btn-refresh",(function(){let index=$(this).attr("index"),iframe=Win10.getLayeroByIndex(index).find("iframe");iframe.attr("src",iframe.attr("src"))})),$(document).on("mousedown",".win10-open-iframe",(function(){let layero=$(this);Win10._settop(layero),Win10._checkTop()})),$("#win10_btn_group_middle").on("click",".btn_close",(function(){let index=$(this).parent().attr("index");Win10._closeWin(index)})),$("#win10-menu .list").on("click",".item",(function(){let e=$(this);for(e.hasClass("has-sub-down")&&($("#win10-menu .list .item.has-sub-up").toggleClass("has-sub-down").toggleClass("has-sub-up"),$("#win10-menu .list .sub-item").slideUp()),e.next().hasClass("sub-item")&&e.toggleClass("has-sub-down").toggleClass("has-sub-up");e.next().hasClass("sub-item");)e.next().slideToggle(),e=e.next()})),setInterval((function(){let myDate=Win10.getLunarObj();$("#win10_btn_time").html(myDate.weekDay+myDate.hour+":"+myDate.minute)}),1e3),document.body.onbeforeunload=function(event){let rel=Win10.lang("系统可能不会保存您所做的更改","The system may not save the changes you have made.");window.event?window.event.returnValue=rel:event.returnValue=rel},Win10.buildList(),Win10._startAnimate(),Win10.renderShortcuts(),$("#win10-shortcuts").removeClass("shortcuts-hidden"),Win10._showShortcut(),Win10.renderDocks(),$(window).resize((function(){Win10.renderShortcuts(),Win10._checkBgUrls(),Win10.isSmallScreen()||Win10._fixWindowsHeightAndWidth(),Win10.renderDocks()})),setTimeout((function(){console.log(Win10.lang("本页由Win10-UI强力驱动\n更多信息http://win10ui.yuri2.cn \nWin10-UI,轻松打造别具一格的后台界面 ","The page is strongly driven by Win10-UI.\nFor more info: http://win10ui.yuri2.cn.\n Win10-UI, easy to create a unique background interface."))}),2e3),$(document).click((function(event){event.button||Win10._removeContextMenu()})),$(document).on("contextmenu",".win10-context-menu",(function(e){e.preventDefault(),e.stopPropagation()})),Win10.setContextMenu("#win10",!0),Win10.setContextMenu("#win10>.desktop",[['<i class="fa fa-fw fa-star"></i> 收藏本页',function(){let url=window.location,title=document.title,ua=navigator.userAgent.toLowerCase();if(ua.indexOf("360se")>-1)layer.alert(Win10.lang("您的浏览器不支持,请按 Ctrl+D 手动收藏!","Your browser does not support, please press Ctrl+D to manual collection!"));else if(ua.indexOf("msie 8")>-1)window.external.AddToFavoritesBar(url,title);else if(document.all)try{window.external.addFavorite(url,title)}catch(e){layer.alert(Win10.lang("您的浏览器不支持,请按 Ctrl+D 手动收藏!","Your browser does not support, please press Ctrl+D to manual collection!"))}else window.sidebar?window.sidebar.addPanel(title,url,""):layer.alert(Win10.lang("您的浏览器不支持,请按 Ctrl+D 手动收藏!","Your browser does not support, please press Ctrl+D to manual collection!"))}],['<i class="fa fa-fw fa-window-maximize"></i> '+Win10.lang("进入全屏","Enable Full Screen"),function(){Win10.enableFullScreen()}],['<i class="fa fa-fw fa-window-restore"></i> '+Win10.lang("退出全屏","Disable Full Screen"),function(){Win10.disableFullScreen()}],"|",['<i class="fa fa-fw fa-info-circle"></i> '+Win10.lang("关于","About Us"),function(){Win10.aboutUs()}]]),Win10.setContextMenu("#win10_btn_group_middle",[['<i class="fa fa-fw fa-window-maximize"></i> '+Win10.lang("全部显示","Show All Windows"),function(){Win10.showWins()}],['<i class="fa fa-fw fa-window-minimize"></i> '+Win10.lang("全部隐藏","Hide All Windows"),function(){Win10.hideWins()}],['<i class="fa fa-fw fa-window-close"></i> '+Win10.lang("全部关闭","Close All Windows"),function(){Win10.closeAll()}]]),setInterval((function(){let btn=$("#win10-msg-nof.on-new-msg");btn.length>0&&btn.toggleClass("fa-commenting-o")}),600),$("body").keyup((function(e){if(e.ctrlKey)switch(e.keyCode){case 37:$("#win10_btn_win").click();break;case 38:Win10.showWins();break;case 39:$("#win10_btn_command").click();break;case 40:Win10.hideWins()}})),$("#win10-desktop-scene").length<1&&($("#win10-shortcuts").css({position:"absolute",left:0,top:30,"z-index":100}),$("#win10 .desktop").append("<div id='win10-desktop-scene' style='width: 100%;height: 100%;position: absolute;left: 0;top: 0; z-index: 0;background-color: transparent;'></div>")),Win10._bind_open_windows()},setBgUrl:function(bgs){this._bgs=bgs,this._checkBgUrls()},setBg:function(bgs){this._bgs=bgs,this._checkBgUrls()},menuClose:function(){$("#win10-menu").removeClass("opened"),$("#win10-menu").addClass("hidden"),this._showShortcut(),$(".win10-open-iframe").removeClass("hide")},getLunarObj:function(){let lunarInfo=new Array(19416,19168,42352,21717,53856,55632,91476,22176,39632,21970,19168,42422,42192,53840,119381,46400,54944,44450,38320,84343,18800,42160,46261,27216,27968,109396,11104,38256,21234,18800,25958,54432,59984,28309,23248,11104,100067,37600,116951,51536,54432,120998,46416,22176,107956,9680,37584,53938,43344,46423,27808,46416,86869,19872,42448,83315,21200,43432,59728,27296,44710,43856,19296,43748,42352,21088,62051,55632,23383,22176,38608,19925,19152,42192,54484,53840,54616,46400,46496,103846,38320,18864,43380,42160,45690,27216,27968,44870,43872,38256,19189,18800,25776,29859,59984,27480,21952,43872,38613,37600,51552,55636,54432,55888,30034,22176,43959,9680,37584,51893,43344,46240,47780,44368,21977,19360,42416,86390,21168,43312,31060,27296,44368,23378,19296,42726,42208,53856,60005,54576,23200,30371,38608,19415,19152,42192,118966,53840,54560,56645,46496,22224,21938,18864,42359,42160,43600,111189,27936,44448),Animals=new Array("鼠","牛","虎","兔","龙","蛇","马","羊","猴","鸡","狗","猪"),Gan=new Array("甲","乙","丙","丁","戊","己","庚","辛","壬","癸"),Zhi=new Array("子","丑","寅","卯","辰","巳","午","未","申","酉","戌","亥");function lYearDays(y){let i,sum=348;for(i=32768;i>8;i>>=1)sum+=lunarInfo[y-1900]&i?1:0;return sum+leapDays(y)}function leapDays(y){return leapMonth(y)?65536&lunarInfo[y-1900]?30:29:0}function leapMonth(y){return 15&lunarInfo[y-1900]}function monthDays(y,m){return lunarInfo[y-1900]&65536>>m?30:29}function lunar(objDate){let i,leap=0,temp=0,baseDate,offset=(objDate-new Date(1900,0,31))/864e5;for(this.dayCyl=offset+40,this.monCyl=14,i=1900;i<2050&&offset>0;i++)temp=lYearDays(i),offset-=temp,this.monCyl+=12;for(offset<0&&(offset+=temp,i--,this.monCyl-=12),this.year=i,this.yearCyl=i-1864,leap=leapMonth(i),this.isLeap=!1,i=1;i<13&&offset>0;i++)leap>0&&i==leap+1&&!1===this.isLeap?(--i,this.isLeap=!0,temp=leapDays(this.year)):temp=monthDays(this.year,i),!0===this.isLeap&&i==leap+1&&(this.isLeap=!1),offset-=temp,!1===this.isLeap&&this.monCyl++;0==offset&&leap>0&&i==leap+1&&(this.isLeap?this.isLeap=!1:(this.isLeap=!0,--i,--this.monCyl)),offset<0&&(offset+=temp,--i,--this.monCyl),this.month=i,this.day=offset+1}function get_lunarmonth(month){let fm;return["一月","二月","三月","四月","五月","六月","七月","八月","九月","十月","十一月","腊月"][month-1]}function get_lunarday(day){let fd=["十","一","二","三","四","五","六","七","八","九","十"];return day<=10?"初"+fd[day]:day<20?"十"+fd[day-10]:20==day?"二十":day<30?"廿"+fd[day-20]:"三"+fd[day-30]}function get_ganzhi(year){let num=year-1900+36;return Gan[num%10]+Zhi[num%12]}function get_animal(year){return Animals[(year-4)%12]}function get_weekday(date){let values;return["周日","周一","周二","周三","周四","周五","周六"][date.getDay()]}function get_week(date){let values;return["星期日","星期一","星期二","星期三","星期四","星期五","星期六"][date.getDay()]}function get_min(date){let mins=date.getMinutes();return mins<10&&(mins="0"+mins),mins}function get_hour(date){let hour=date.getHours();return hours=hour<6?"凌晨"+hour:hour<9?"早上"+hour:hour<12?"上午"+hour:hour<14?"中午"+(hour-12):hour<17?"下午"+(hour-12):hour<19?"傍晚"+(hour-12):hour<22?"晚上"+(hour-12):"深夜"+(hour-12),hours}let viewdate={},date=new Date;viewdate.second=date.getSeconds(),viewdate.minute=get_min(date),viewdate.hour=get_hour(date),viewdate.day=date.getDate(),viewdate.week=get_week(date),viewdate.weekDay=get_weekday(date),viewdate.month=date.getMonth()+1,viewdate.fullYear=date.getFullYear(),viewdate.year=date.getYear();let lunar_obj=new lunar(date);viewdate.lunarmonth=get_lunarmonth(lunar_obj.month);let lunar_day=Math.floor(lunar_obj.day);return viewdate.lunarday=get_lunarday(lunar_day),viewdate.lunar=lunar_obj.year+"-"+lunar_obj.month+"-"+lunar_day,viewdate.ganzhi=get_ganzhi(lunar_obj.year),viewdate.animal=get_animal(lunar_obj.year),viewdate},renderCommand:function(todayHtml=null){let active;if(!$("#win10_command_center .command-body.today").hasClass("active")){if(!todayHtml){let lunarDate=Win10.getLunarObj();todayHtml='<div class="command-body-calendar">\n\t<div class="command-body-calendar-date normal-date">'+lunarDate.month+"月"+lunarDate.day+"日 \n"+lunarDate.week+'</div>\n\t<div class="command-body-calendar-date lunar-date">'+lunarDate.ganzhi+"年"+lunarDate.lunarmonth+lunarDate.lunarday+'</div>\n</div>\n<div class="notice">\t<div class="notice-header">\t\t<span class="notice-header-icon"><img src="./img/icon/weather.png" class="notice-header-icon-img" /></span>\n\t\t<span class="notice-header-title">天气</span>\n\t</div>\n\t<div class="notice-body">\n\t<iframe scrolling="no" src="https://tianqiapi.com/api.php?style=tw&skin=durian" frameborder="0" width="100%" height="500" allowtransparency="true"></iframe>\n\t</div>\n</div>\n'}$("#win10_command_center .command-body.today").html(todayHtml).addClass("active")}},menuOpen:function(){$("#win10-menu").addClass("opened"),$("#win10-menu").removeClass("hidden"),$(".win10-open-iframe").addClass("hide")},menuToggle:function(){$("#win10-menu").hasClass("opened")?this.menuClose():this.menuOpen()},commandCenterClose:function(){$("#win10_command_center").addClass("hidden_right"),this._showShortcut(),$(".win10-open-iframe").removeClass("hide")},commandCenterOpen:function(){$("#win10_command_center").removeClass("hidden_right"),$(".win10-open-iframe").addClass("hide"),$("#win10-msg-nof").removeClass("on-new-msg fa-commenting-o")},renderShortcuts:function(){if(this.isSmallScreen()){let w=parseInt(($("#win10 #win10-shortcuts")[0].offsetWidth-10)/82),x=0,y=0;$("#win10 #win10-shortcuts .shortcut").each((function(){$(this).css({left:82*x+10,right:0,top:100*y+10}),x++,x>=w&&(x=0,y++)}))}else{let h=parseInt(($("#win10 #win10-shortcuts")[0].offsetHeight-90)/100),w=0,x=0,y=0;$("#win10 #win10-shortcuts .shortcut").each((function(){$(this).css({right:82*x+10,left:"auto",top:100*y+10}),y++,y>=h&&(y=0,x++)}))}},renderDocks:function(){let cell_width=60,width=document.body.clientWidth,docks=$("#footer .dock li"),max_num=parseInt(width/60)-1;for(let i=0;i<docks.length;i++)i>max_num?docks.eq(i).css("display","none"):docks.eq(i).css("display","list-item");this.isSmallScreen()?$("#footer .dock li a img").hover((function(){$(this).parent("a").prev().css("display","none")})):$("#footer .dock li a img").hover((function(){$(this).parent("a").prev().css("display","flex")}),(function(){$(this).parent("a").prev().css("display","none")}))},commandCenterToggle:function(){$("#win10_command_center").hasClass("hidden_right")?this.commandCenterOpen():this.commandCenterClose()},newMsg:function(title,content,handle_click,app_name="提示消息",app_icon='<img src="./img/icon/weather.png" class="notice-header-icon-img" />',is_del=!0){let msg='<div class="notice"><div class="notice-header"><span class="notice-header-icon">'+app_icon+'</span><span class="notice-header-title">'+app_name+"</span>";is_del&&(msg+='<span class="btn_close_msg fa fa-times-circle"></span>'),msg+='</div><div class="notice-body"><div class="msg"><div class="title">'+title+'</div><div class="content">'+content+"</div></div></div></div>";let e=$(msg);$("#win10_command_center .msgs").prepend(e),e.find(".content:first,.title:first").click((function(){handle_click&&handle_click(e)})),layer.tips(Win10.lang("新消息:","New message:")+title,"#win10_btn_command",{tips:[1,"rgba(0, 0, 0, 0.7)"],time:3e3}),$("#win10_command_center").hasClass("hidden_right")&&$("#win10-msg-nof").addClass("on-new-msg")},getLayeroByIndex:function(index){return $("#layui-layer"+index)},isSmallScreen:function(size){let width;return size||(size=768),document.body.clientWidth<size},enableFullScreen:function(){let docElm=document.documentElement;docElm.requestFullscreen?docElm.requestFullscreen():docElm.mozRequestFullScreen?docElm.mozRequestFullScreen():docElm.webkitRequestFullScreen?docElm.webkitRequestFullScreen():docElm.msRequestFullscreen&&document.body.msRequestFullscreen()},disableFullScreen:function(){document.exitFullscreen?document.exitFullscreen():document.mozCancelFullScreen?document.mozCancelFullScreen():document.webkitCancelFullScreen?document.webkitCancelFullScreen():document.msExitFullscreen&&document.msExitFullscreen()},buildList:function(){$("#win10-menu .list .sub-item").slideUp(),$("#win10-menu .list .item").each((function(){$(this).next().hasClass("sub-item")&&($(this).addClass("has-sub-down"),$(this).removeClass("has-sub-up"))}))},openUrl:function(url,icon,title,areaAndOffset){if(this._countTask>12)return layer.msg("您打开的太多了,歇会儿吧~"),!1;let preg,area,offset;if(this._countTask++,url||(url="404"),url=url.replace(/(^\s*)|(\s*$)/g,""),/^(https?:\/\/|\.\.?\/|\/\/?)/.test(url)||(url="http://"+url),url||(url="//yuri2.cn"),title||(title=url),this.isSmallScreen()||"max"===areaAndOffset)area=["100%",document.body.clientHeight-24+"px"],offset=["24px","0"];else if("object"==typeof areaAndOffset)area=areaAndOffset[0],offset=areaAndOffset[1];else{let topset,leftset;area=["80%","80%"],topset=parseInt($(window).height()),topset=(topset-.8*topset)/2-31,leftset=parseInt($(window).width()),leftset=(leftset-.8*leftset)/2-120,offset=[Math.round(this._countTask%10*20+topset)+"px",Math.round(this._countTask%10*20+100+leftset)+"px"]}let index=layer.open({type:2,shadeClose:!0,shade:!1,maxmin:!0,title:icon+title,content:url,area:area,offset:offset,isOutAnim:!1,skin:"win10-open-iframe",cancel:function(index,layero){$("#win10_"+index).remove(),Win10._checkTop(),Win10._countTask--,Win10._renderBar()},min:function(layero){return layero.hide(),$("#win10_"+index).removeClass("show"),Win10._checkTop(),!1},full:function(layero){layero.find(".layui-layer-min").css("display","inline-block"),layero_opened.css("top",24)}});$("#win10_btn_group_middle .btn.active").removeClass("active");let btn=$('<div id="win10_'+index+'" index="'+index+'" class="btn show active"><div class="btn_title">'+icon+"</div></div>"),layero_opened=Win10.getLayeroByIndex(index);return layero_opened.css("z-index",Win10._countTask+813),Win10._settop(layero_opened),layero_opened.find(".layui-layer-setwin").prepend('<a class="win10-btn-refresh" index="'+index+'" href="#"></a>'),layero_opened.find(".layui-layer-setwin>a").each((function(){$(this).prependTo(layero_opened.find(".layui-layer-setwin"))})),layero_opened.find(".layui-layer-setwin .layui-layer-max").click((function(){setTimeout((function(){let height=layero_opened.css("height");height=parseInt(height.replace("px","")),height>=document.body.clientHeight&&(layero_opened.css("height",height-25),layero_opened.find(".layui-layer-content").css("height",height-55),layero_opened.find(".layui-layer-content iframe").css("height",height-55))}),300)})),$("#win10_btn_group_middle").append(btn),Win10._renderBar(),btn.click((function(){let index=$(this).attr("index"),layero=Win10.getLayeroByIndex(index),settop=function(){let max_zindex=0;$(".win10-open-iframe").each((function(){z=parseInt($(this).css("z-index")),$(this).css("z-index",z-1),z>max_zindex&&(max_zindex=z)})),layero.css("z-index",max_zindex+1)};$(this).hasClass("show")?$(this).hasClass("active")?($(this).removeClass("active"),$(this).removeClass("show"),Win10._checkTop(),layero.hide()):($("#win10_btn_group_middle .btn.active").removeClass("active"),$(this).addClass("active"),Win10._settop(layero)):($(this).addClass("show"),$("#win10_btn_group_middle .btn.active").removeClass("active"),$(this).addClass("active"),Win10._settop(layero),layero.show())})),Win10._iframeOnClick.track(layero_opened.find("iframe:first")[0],(function(){0===Object.getOwnPropertyNames(Win10._iframe_click_lock_children).length?(Win10._settop(layero_opened),Win10._checkTop()):console.log("click locked")})),this.menuClose(),this.commandCenterClose(),index},closeAll:function(){$(".win10-open-iframe").remove(),$("#win10_btn_group_middle").html(""),Win10._countTask=0,Win10._renderBar()},setAnimated:function(animated_classes,animated_liveness){this._animated_classes=animated_classes,this._animated_liveness=animated_liveness},exit:function(){layer.confirm(Win10.lang("确认要关闭本页吗?","Are you sure you want to close this page?"),{icon:3,title:Win10.lang("提示","Prompt")},(function(index){document.body.onbeforeunload=function(){},window.location.href="about:blank",window.close(),layer.close(index),layer.alert(Win10.lang("哎呀,好像失败了呢。","Ops...There seems to be a little problem."),{skin:"layui-layer-lan",closeBtn:0})}))},lang:function(cn,en){return"zh-cn"===this._lang||"zh-tw"===this._lang?cn:en},aboutUs:function(){layer.open({type:1,closeBtn:1,anim:2,skin:"win10-open-iframe",title:"MAC-UI "+this._version,shadeClose:!0,area:["320px","200px"],content:'<div style="padding: 10px;font-size: 12px"><p>支持组件:layer、jquery、animated.css、font-awesome</p><p>木子的忧伤、尤里2号©版权所有</p><p>作者邮箱:1099438829@qq.com</p></div>'})},setContextMenu:function(jq_dom,menu){"string"==typeof jq_dom&&(jq_dom=$(jq_dom)),jq_dom.unbind("contextmenu"),jq_dom.on("contextmenu",(function(e){menu&&(Win10._renderContextMenu(e.clientX,e.clientY,menu,this),e.cancelable&&(e.defaultPrevented||e.preventDefault()),e.stopPropagation())}))},hideWins:function(){$("#win10_btn_group_middle>.btn.show").each((function(){let index=$(this).attr("index"),layero=Win10.getLayeroByIndex(index);$(this).removeClass("show"),$(this).removeClass("active"),layero.hide()}))},showWins:function(){$("#win10_btn_group_middle>.btn").each((function(){let index=$(this).attr("index"),layero=Win10.getLayeroByIndex(index);$(this).addClass("show"),layero.show()})),Win10._checkTop()},getDesktopScene:function(){return $("#win10-desktop-scene")},onReady:function(handle){Win10._handleReady.push(handle)}},$((function(){Win10._init();for(let i in Win10._handleReady){let handle;(0,Win10._handleReady[i])()}}));