This commit is contained in:
昱墨 2022-09-26 20:04:45 +08:00
parent b4ee90c8b0
commit 64f691c665
3 changed files with 1731 additions and 1624 deletions

File diff suppressed because it is too large Load Diff

View File

@ -11,7 +11,7 @@
<link rel='Shortcut Icon' type='image/x-icon' href='./img/favicon.ico'> <link rel='Shortcut Icon' type='image/x-icon' href='./img/favicon.ico'>
<link rel="stylesheet" href="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/animate.css/4.1.1/animate.min.css"> <link rel="stylesheet" href="https://lf9-cdn-tos.bytecdntp.com/cdn/expire-1-M/animate.css/4.1.1/animate.min.css">
<link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="./css/index.min.css"> <link rel="stylesheet" href="./css/index.css">
<link rel="stylesheet" href="./plugins/shortcut-drawer/shortcut-drawer.min.css"> <link rel="stylesheet" href="./plugins/shortcut-drawer/shortcut-drawer.min.css">
</head> </head>
@ -154,7 +154,7 @@
src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/2.2.4/jquery.min.js"></script> src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/jquery/2.2.4/jquery.min.js"></script>
<script type="text/javascript" src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/layer/3.5.1/layer.min.js"></script> <script type="text/javascript" src="https://lf3-cdn-tos.bytecdntp.com/cdn/expire-1-M/layer/3.5.1/layer.min.js"></script>
<script type="text/javascript" src="./js/interface.min.js"></script> <script type="text/javascript" src="./js/interface.min.js"></script>
<script type="text/javascript" src="./js/index.min.js"></script> <script type="text/javascript" src="./js/index.js"></script>
<script type="text/javascript" src="./plugins/shortcut-drawer/shortcut-drawer.min.js"></script> <script type="text/javascript" src="./plugins/shortcut-drawer/shortcut-drawer.min.js"></script>
<script> <script>
Macui.onReady(function () { Macui.onReady(function () {

View File

@ -19,21 +19,21 @@ window.Macui = {
resolution: 200, resolution: 200,
iframes: [], iframes: [],
interval: null, interval: null,
Iframe: function() { Iframe: function () {
this.element = arguments[0]; this.element = arguments[0];
this.cb = arguments[1]; this.cb = arguments[1];
this.hasTracked = false; this.hasTracked = false;
}, },
track: function(element, cb) { track: function (element, cb) {
this.iframes.push(new this.Iframe(element, cb)); this.iframes.push(new this.Iframe(element, cb));
if (!this.interval) { if (!this.interval) {
let _this = this; let _this = this;
this.interval = setInterval(function() { this.interval = setInterval(function () {
_this.checkClick(); _this.checkClick();
}, this.resolution); }, this.resolution);
} }
}, },
checkClick: function() { checkClick: function () {
if (document.activeElement) { if (document.activeElement) {
let activeElement = document.activeElement; let activeElement = document.activeElement;
for (let i in this.iframes) { for (let i in this.iframes) {
@ -55,7 +55,7 @@ window.Macui = {
} }
}, },
_iframe_click_lock_children: {}, _iframe_click_lock_children: {},
_renderBar: function() { _renderBar: function () {
//调整任务栏项目的宽度 //调整任务栏项目的宽度
if (this._countTask <= 0) { if (this._countTask <= 0) {
return; return;
@ -64,22 +64,22 @@ window.Macui = {
btns.css('width', ('calc(' + (1 / this._countTask * 100) + '% - 1px )')) btns.css('width', ('calc(' + (1 / this._countTask * 100) + '% - 1px )'))
}, },
_handleReady: [], _handleReady: [],
_hideShortcut: function() { _hideShortcut: function () {
let that = $("#mac #mac-shortcuts .shortcut"); let that = $("#mac #mac-shortcuts .shortcut");
that.removeClass('animated flipInX'); that.removeClass('animated flipInX');
that.addClass('animated flipOutX'); that.addClass('animated flipOutX');
}, },
_showShortcut: function() { _showShortcut: function () {
let that = $("#mac #mac-shortcuts .shortcut"); let that = $("#mac #mac-shortcuts .shortcut");
that.removeClass('animated flipOutX'); that.removeClass('animated flipOutX');
that.addClass('animated flipInX'); that.addClass('animated flipInX');
}, },
_checkBgUrls: function() { _checkBgUrls: function () {
let loaders = $('#mac>.img-loader'); let loaders = $('#mac>.img-loader');
let flag = false; let flag = false;
if (Macui.isSmallScreen()) { if (Macui.isSmallScreen()) {
if (Macui._bgs.mobile) { if (Macui._bgs.mobile) {
loaders.each(function() { loaders.each(function () {
let loader = $(this); let loader = $(this);
if (loader.attr('src') === Macui._bgs.mobile && loader.hasClass('loaded')) { if (loader.attr('src') === Macui._bgs.mobile && loader.hasClass('loaded')) {
Macui._setBackgroundImg(Macui._bgs.mobile); Macui._setBackgroundImg(Macui._bgs.mobile);
@ -90,7 +90,7 @@ window.Macui = {
//没找到加载完毕的图片 //没找到加载完毕的图片
let img = $('<img class="img-loader" src="' + Macui._bgs.mobile + '" />'); let img = $('<img class="img-loader" src="' + Macui._bgs.mobile + '" />');
$('#mac').append(img); $('#mac').append(img);
Macui._onImgComplete(img[0], function() { Macui._onImgComplete(img[0], function () {
img.addClass('loaded'); img.addClass('loaded');
Macui._setBackgroundImg(Macui._bgs.mobile); Macui._setBackgroundImg(Macui._bgs.mobile);
}) })
@ -98,7 +98,7 @@ window.Macui = {
} }
} else { } else {
if (Macui._bgs.main) { if (Macui._bgs.main) {
loaders.each(function() { loaders.each(function () {
let loader = $(this); let loader = $(this);
if (loader.attr('src') === Macui._bgs.main && loader.hasClass('loaded')) { if (loader.attr('src') === Macui._bgs.main && loader.hasClass('loaded')) {
Macui._setBackgroundImg(Macui._bgs.main); Macui._setBackgroundImg(Macui._bgs.main);
@ -109,7 +109,7 @@ window.Macui = {
//没找到加载完毕的图片 //没找到加载完毕的图片
let img = $('<img class="img-loader" src="' + Macui._bgs.main + '" />'); let img = $('<img class="img-loader" src="' + Macui._bgs.main + '" />');
$('#mac').append(img); $('#mac').append(img);
Macui._onImgComplete(img[0], function() { Macui._onImgComplete(img[0], function () {
img.addClass('loaded'); img.addClass('loaded');
Macui._setBackgroundImg(Macui._bgs.main); Macui._setBackgroundImg(Macui._bgs.main);
}) })
@ -123,20 +123,20 @@ window.Macui = {
} }
}, },
//动态加载JS文件 //动态加载JS文件
loadScript: function(url, callback) { loadScript: function (url, callback) {
let el = document.createElement("script"); let el = document.createElement("script");
el.type = "text/javascript"; el.type = "text/javascript";
if (typeof(callback) != "undefined") { if (typeof (callback) != "undefined") {
if (el.readyState) { if (el.readyState) {
el.onreadystatechange = function() { el.onreadystatechange = function () {
if (el.readyState === "loaded" || el.readyState === "complete") { if (el.readyState === "loaded" || el.readyState === "complete") {
el.onreadystatechange = null; el.onreadystatechange = null;
callback(); callback();
} }
}; };
} else { } else {
el.onload = function() { el.onload = function () {
callback(); callback();
}; };
} }
@ -145,23 +145,23 @@ window.Macui = {
el.src = url; el.src = url;
document.head.appendChild(el); document.head.appendChild(el);
}, },
_startAnimate: function() { _startAnimate: function () {
setInterval(function() { setInterval(function () {
let classes_length = Macui._animated_classes.length; let classes_length = Macui._animated_classes.length;
let animated_live_ness = Macui._animated_liveness; let animated_live_ness = Macui._animated_liveness;
if (animated_live_ness === 0 || classes_length === 0 || !$("#mac-menu").hasClass( if (animated_live_ness === 0 || classes_length === 0 || !$("#mac-menu").hasClass(
'opened')) { 'opened')) {
return; return;
} }
$('#mac-menu>.blocks>.menu_group>.block').each(function() { $('#mac-menu>.blocks>.menu_group>.block').each(function () {
if (!$(this).hasClass('onAnimate') && Math.random() <= animated_live_ness) { if (!$(this).hasClass('onAnimate') && Math.random() <= animated_live_ness) {
let that = $(this); let that = $(this);
let class_animate = Macui._animated_classes[Math.floor((Math.random() * let class_animate = Macui._animated_classes[Math.floor((Math.random() *
classes_length))]; classes_length))];
that.addClass('onAnimate'); that.addClass('onAnimate');
setTimeout(function() { setTimeout(function () {
that.addClass(class_animate); that.addClass(class_animate);
setTimeout(function() { setTimeout(function () {
that.removeClass('onAnimate'); that.removeClass('onAnimate');
that.removeClass(class_animate); that.removeClass(class_animate);
}, 3000); }, 3000);
@ -170,27 +170,27 @@ window.Macui = {
}) })
}, 1000); }, 1000);
}, },
_onImgComplete: function(img, callback) { _onImgComplete: function (img, callback) {
if (!img) { if (!img) {
return; return;
} }
let timer = setInterval(function() { let timer = setInterval(function () {
if (img.complete) { if (img.complete) {
callback(img); callback(img);
clearInterval(timer); clearInterval(timer);
} }
}, 50) }, 50)
}, },
_setBackgroundImg: function(img) { _setBackgroundImg: function (img) {
$('#mac .background').css('background-image', 'url(' + img + ')') $('#mac .background').css('background-image', 'url(' + img + ')')
}, },
_settop: function(layero) { _settop: function (layero) {
if (!isNaN(layero)) { if (!isNaN(layero)) {
layero = this.getLayeroByIndex(layero); layero = this.getLayeroByIndex(layero);
} }
//置顶窗口 //置顶窗口
let max_zindex = 0; let max_zindex = 0;
$(".mac-open-iframe").each(function() { $(".mac-open-iframe").each(function () {
z = parseInt($(this).css('z-index')); z = parseInt($(this).css('z-index'));
$(this).css('z-index', z - 1); $(this).css('z-index', z - 1);
if (z > max_zindex) { if (z > max_zindex) {
@ -199,11 +199,11 @@ window.Macui = {
}); });
layero.css('z-index', max_zindex + 1); layero.css('z-index', max_zindex + 1);
}, },
_checkTop: function() { _checkTop: function () {
let max_index = 0, let max_index = 0,
max_z = 0, max_z = 0,
btn = null; btn = null;
$("#mac_btn_group_middle .btn.show").each(function() { $("#mac_btn_group_middle .btn.show").each(function () {
let index = $(this).attr('index'); let index = $(this).attr('index');
let layero = Macui.getLayeroByIndex(index); let layero = Macui.getLayeroByIndex(index);
let z = layero.css('z-index'); let z = layero.css('z-index');
@ -220,7 +220,7 @@ window.Macui = {
} }
}, },
//渲染右键 //渲染右键
_renderContextMenu: function(x, y, menu, trigger) { _renderContextMenu: function (x, y, menu, trigger) {
this._removeContextMenu(); this._removeContextMenu();
if (menu === true) { if (menu === true) {
return; return;
@ -234,11 +234,11 @@ window.Macui = {
ul.append($('<hr/>')); ul.append($('<hr/>'));
continue; continue;
} }
if (typeof(item) === 'string') { if (typeof (item) === 'string') {
ul.append($('<li>' + item + '</li>')); ul.append($('<li>' + item + '</li>'));
continue; continue;
} }
if (typeof(item) === 'object') { if (typeof (item) === 'object') {
let sub = $('<li>' + item[0] + '</li>'); let sub = $('<li>' + item[0] + '</li>');
ul.append(sub); ul.append(sub);
sub.click(trigger, item[1]); sub.click(trigger, item[1]);
@ -256,21 +256,21 @@ window.Macui = {
left: x, left: x,
}); });
}, },
_removeContextMenu: function() { _removeContextMenu: function () {
$('.mac-context-menu').remove(); $('.mac-context-menu').remove();
}, },
_closeWin: function(index) { _closeWin: function (index) {
$("#mac_" + index).remove(); $("#mac_" + index).remove();
layer.close(index); layer.close(index);
Macui._checkTop(); Macui._checkTop();
Macui._countTask--; //回退countTask数 Macui._countTask--; //回退countTask数
Macui._renderBar(); Macui._renderBar();
}, },
_fixWindowsHeightAndWidth: function() { _fixWindowsHeightAndWidth: function () {
//此处代码修正全屏切换引起的子窗体尺寸超出屏幕 //此处代码修正全屏切换引起的子窗体尺寸超出屏幕
let opens = $('.mac-open-iframe'); let opens = $('.mac-open-iframe');
let clientHeight = document.body.clientHeight; let clientHeight = document.body.clientHeight;
opens.each(function() { opens.each(function () {
let layero_opened = $(this); let layero_opened = $(this);
let height = layero_opened.css('height'); let height = layero_opened.css('height');
height = parseInt(height.replace('px', '')); height = parseInt(height.replace('px', ''));
@ -289,9 +289,9 @@ window.Macui = {
* @version:2.0.1 * @version:2.0.1
* 说明: 所有#win10下的元素加入类win10-open-window即可自动绑定openUrl函数无须用onclick手动绑定 * 说明: 所有#win10下的元素加入类win10-open-window即可自动绑定openUrl函数无须用onclick手动绑定
*/ */
_bind_open_windows: function() { _bind_open_windows: function () {
// 注册事件委派 打开url窗口 // 注册事件委派 打开url窗口
$('#mac').on('click', '.mac-open-window', function() { $('#mac').on('click', '.mac-open-window', function () {
//>> 获取当前点击的对象 //>> 获取当前点击的对象
$this = $(this); $this = $(this);
//>> 判断url地址是否为空 如果为空 不予处理 //>> 判断url地址是否为空 如果为空 不予处理
@ -331,32 +331,32 @@ window.Macui = {
} }
}) })
}, },
_init: function() { _init: function () {
//获取语言 //获取语言
this._lang = (navigator.language || navigator.browserLanguage).toLowerCase(); this._lang = (navigator.language || navigator.browserLanguage).toLowerCase();
$("#mac_btn_win").click(function() { $("#mac_btn_win").click(function () {
Macui.commandCenterClose(); Macui.commandCenterClose();
Macui.menuToggle(); Macui.menuToggle();
}); });
$("#mac_btn_command").click(function() { $("#mac_btn_command").click(function () {
Macui.renderCommand(); Macui.renderCommand();
Macui.menuClose(); Macui.menuClose();
Macui.commandCenterToggle(); Macui.commandCenterToggle();
}); });
$("#mac .desktop").click(function() { $("#mac .desktop").click(function () {
Macui.menuClose(); Macui.menuClose();
Macui.commandCenterClose(); Macui.commandCenterClose();
}); });
$('#mac').on('click', ".notice .btn_close_msg", function() { $('#mac').on('click', ".notice .btn_close_msg", function () {
let msg = $(this).parents('.notice'); let msg = $(this).parents('.notice');
$(msg).addClass('animated slideOutRight'); $(msg).addClass('animated slideOutRight');
setTimeout(function() { setTimeout(function () {
msg.remove() msg.remove()
}, 500) }, 500)
}); });
$("#mac .launchpad").click(function() { $("#mac .launchpad").click(function () {
if ($("#launchpad").hasClass("hidden")) { if ($("#launchpad").hasClass("hidden")) {
Macui.renderLaunchpad(); Macui.renderLaunchpad();
Macui.menuClose(); Macui.menuClose();
@ -366,7 +366,7 @@ window.Macui = {
} }
}); });
//消息界面切换 //消息界面切换
$('#mac_command_center').on('click', ".command-header div", function() { $('#mac_command_center').on('click', ".command-header div", function () {
if (!$(this).hasClass('active')) { if (!$(this).hasClass('active')) {
if ($(this).hasClass('tab-today')) { if ($(this).hasClass('tab-today')) {
$(this).parent().siblings('.msgs').hide().siblings('.today').show(); $(this).parent().siblings('.msgs').hide().siblings('.today').show();
@ -377,21 +377,21 @@ window.Macui = {
} }
} }
}); });
$('#mac_btn_command_center_clean_all').click(function() { $('#mac_btn_command_center_clean_all').click(function () {
let msgs = $('#mac_command_center .msg'); let msgs = $('#mac_command_center .msg');
msgs.addClass('animated slideOutRight'); msgs.addClass('animated slideOutRight');
setTimeout(function() { setTimeout(function () {
msgs.remove() msgs.remove()
}, 1500); }, 1500);
setTimeout(function() { setTimeout(function () {
Macui.commandCenterClose(); Macui.commandCenterClose();
}, 1000); }, 1000);
}); });
$("#mac_btn_show_desktop").click(function() { $("#mac_btn_show_desktop").click(function () {
$("#mac .desktop").click(); $("#mac .desktop").click();
Macui.hideWins(); Macui.hideWins();
}); });
$("#mac-menu-switcher").click(function() { $("#mac-menu-switcher").click(function () {
if (Macui._switchMenuTooHurry) { if (Macui._switchMenuTooHurry) {
return; return;
} }
@ -399,13 +399,13 @@ window.Macui = {
let class_name = 'mac-menu-hidden'; let class_name = 'mac-menu-hidden';
let list = $("#mac-menu>.list"); let list = $("#mac-menu>.list");
let blocks = $("#mac-menu>.blocks"); let blocks = $("#mac-menu>.blocks");
let toggleSlide = function(obj) { let toggleSlide = function (obj) {
if (obj.hasClass(class_name)) { if (obj.hasClass(class_name)) {
obj.addClass('animated slideInLeft'); obj.addClass('animated slideInLeft');
obj.removeClass('animated slideOutLeft'); obj.removeClass('animated slideOutLeft');
obj.removeClass(class_name); obj.removeClass(class_name);
} else { } else {
setTimeout(function() { setTimeout(function () {
obj.addClass(class_name); obj.addClass(class_name);
}, 450); }, 450);
obj.addClass('animated slideOutLeft'); obj.addClass('animated slideOutLeft');
@ -414,28 +414,28 @@ window.Macui = {
}; };
toggleSlide(list); toggleSlide(list);
toggleSlide(blocks); toggleSlide(blocks);
setTimeout(function() { setTimeout(function () {
Macui._switchMenuTooHurry = false; Macui._switchMenuTooHurry = false;
}, 520) }, 520)
}); });
$("#mac_btn_group_middle").click(function() { $("#mac_btn_group_middle").click(function () {
$("#mac .desktop").click(); $("#mac .desktop").click();
}); });
$(document).on('click', '.mac-btn-refresh', function() { $(document).on('click', '.mac-btn-refresh', function () {
let index = $(this).attr('index'); let index = $(this).attr('index');
let iframe = Macui.getLayeroByIndex(index).find('iframe'); let iframe = Macui.getLayeroByIndex(index).find('iframe');
iframe.attr('src', iframe.attr('src')); iframe.attr('src', iframe.attr('src'));
}); });
$(document).on('mousedown', '.mac-open-iframe', function() { $(document).on('mousedown', '.mac-open-iframe', function () {
let layero = $(this); let layero = $(this);
Macui._settop(layero); Macui._settop(layero);
Macui._checkTop(); Macui._checkTop();
}); });
$('#mac_btn_group_middle').on('click', '.btn_close', function() { $('#mac_btn_group_middle').on('click', '.btn_close', function () {
let index = $(this).parent().attr('index'); let index = $(this).parent().attr('index');
Macui._closeWin(index); Macui._closeWin(index);
}); });
$('#mac-menu .list').on('click', '.item', function() { $('#mac-menu .list').on('click', '.item', function () {
let e = $(this); let e = $(this);
if (e.hasClass('has-sub-down')) { if (e.hasClass('has-sub-down')) {
$('#mac-menu .list .item.has-sub-up').toggleClass('has-sub-down').toggleClass( $('#mac-menu .list .item.has-sub-up').toggleClass('has-sub-down').toggleClass(
@ -450,13 +450,13 @@ window.Macui = {
e = e.next(); e = e.next();
} }
}); });
setInterval(function() { setInterval(function () {
//重新写mac时间 //重新写mac时间
let myDate = Macui.getLunarObj(); let myDate = Macui.getLunarObj();
$("#mac_btn_time").html(myDate.weekDay + myDate.hour + ':' + myDate.minute); $("#mac_btn_time").html(myDate.weekDay + myDate.hour + ':' + myDate.minute);
}, 1000); }, 1000);
//离开前警告 //离开前警告
document.body.onbeforeunload = function(event) { document.body.onbeforeunload = function (event) {
let rel = Macui.lang('系统可能不会保存您所做的更改', 'The system may not save the changes you have made.'); let rel = Macui.lang('系统可能不会保存您所做的更改', 'The system may not save the changes you have made.');
if (!window.event) { if (!window.event) {
event.returnValue = rel; event.returnValue = rel;
@ -471,33 +471,33 @@ window.Macui = {
Macui._showShortcut(); //显示图标 Macui._showShortcut(); //显示图标
Macui.renderDocks(); //渲染DOCK Macui.renderDocks(); //渲染DOCK
//窗口改大小,重新渲染 //窗口改大小,重新渲染
$(window).resize(function() { $(window).resize(function () {
Macui.renderShortcuts(); Macui.renderShortcuts();
Macui._checkBgUrls(); Macui._checkBgUrls();
if (!Macui.isSmallScreen()) Macui._fixWindowsHeightAndWidth(); //2017年11月14日修改加入了if条件 if (!Macui.isSmallScreen()) Macui._fixWindowsHeightAndWidth(); //2017年11月14日修改加入了if条件
Macui.renderDocks(); Macui.renderDocks();
}); });
//打广告 //打广告
setTimeout(function() { setTimeout(function () {
console.log(Macui.lang( console.log(Macui.lang(
'本页由Mac-UI强力驱动\n更多信息https://mac.apecloud.cn \nMac-UI,轻松打造别具一格的后台界面 ', '本页由Mac-UI强力驱动\n更多信息https://mac.apecloud.cn \nMac-UI,轻松打造别具一格的后台界面 ',
'The page is strongly driven by Mac-UI.\nFor more info: https://mac.apecloud.cn.\n Mac-UI, easy to create a unique background interface.' 'The page is strongly driven by Mac-UI.\nFor more info: https://mac.apecloud.cn.\n Mac-UI, easy to create a unique background interface.'
)) ))
}, 2000); }, 2000);
//点击清空右键菜单 //点击清空右键菜单
$(document).click(function(event) { $(document).click(function (event) {
if (!event.button) if (!event.button)
Macui._removeContextMenu(); Macui._removeContextMenu();
}); });
//禁用右键的右键 //禁用右键的右键
$(document).on('contextmenu', '.mac-context-menu', function(e) { $(document).on('contextmenu', '.mac-context-menu', function (e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
}); });
//设置默认右键菜单 //设置默认右键菜单
Macui.setContextMenu('#mac', true); Macui.setContextMenu('#mac', true);
Macui.setContextMenu('#mac>.desktop', [ Macui.setContextMenu('#mac>.desktop', [
['<i class="fa fa-fw fa-star"></i> 收藏本页', function() { ['<i class="fa fa-fw fa-star"></i> 收藏本页', function () {
let url = window.location; let url = window.location;
let title = document.title; let title = document.title;
let ua = navigator.userAgent.toLowerCase(); let ua = navigator.userAgent.toLowerCase();
@ -524,40 +524,40 @@ window.Macui = {
} }
}], }],
['<i class="fa fa-fw fa-window-maximize"></i> ' + Macui.lang('进入全屏', 'Enable Full Screen'), ['<i class="fa fa-fw fa-window-maximize"></i> ' + Macui.lang('进入全屏', 'Enable Full Screen'),
function() { function () {
Macui.enableFullScreen() Macui.enableFullScreen()
} }
], ],
['<i class="fa fa-fw fa-window-restore"></i> ' + Macui.lang('退出全屏', 'Disable Full Screen'), ['<i class="fa fa-fw fa-window-restore"></i> ' + Macui.lang('退出全屏', 'Disable Full Screen'),
function() { function () {
Macui.disableFullScreen() Macui.disableFullScreen()
} }
], ],
'|', '|',
['<i class="fa fa-fw fa-info-circle"></i> ' + Macui.lang('关于', 'About Us'), function() { ['<i class="fa fa-fw fa-info-circle"></i> ' + Macui.lang('关于', 'About Us'), function () {
Macui.aboutUs() Macui.aboutUs()
}], }],
]); ]);
Macui.setContextMenu('#mac_btn_group_middle', [ Macui.setContextMenu('#mac_btn_group_middle', [
['<i class="fa fa-fw fa-window-maximize"></i> ' + Macui.lang('全部显示', 'Show All Windows'), ['<i class="fa fa-fw fa-window-maximize"></i> ' + Macui.lang('全部显示', 'Show All Windows'),
function() { function () {
Macui.showWins() Macui.showWins()
} }
], ],
['<i class="fa fa-fw fa-window-minimize"></i> ' + Macui.lang('全部隐藏', 'Hide All Windows'), ['<i class="fa fa-fw fa-window-minimize"></i> ' + Macui.lang('全部隐藏', 'Hide All Windows'),
function() { function () {
Macui.hideWins() Macui.hideWins()
} }
], ],
['<i class="fa fa-fw fa-window-close"></i> ' + Macui.lang('全部关闭', 'Close All Windows'), ['<i class="fa fa-fw fa-window-close"></i> ' + Macui.lang('全部关闭', 'Close All Windows'),
function() { function () {
Macui.closeAll() Macui.closeAll()
} }
], ],
]); ]);
//处理消息图标闪烁 //处理消息图标闪烁
setInterval(function() { setInterval(function () {
let btn = $("#mac-msg-nof.on-new-msg"); let btn = $("#mac-msg-nof.on-new-msg");
if (btn.length > 0) { if (btn.length > 0) {
btn.toggleClass('fa-commenting-o'); btn.toggleClass('fa-commenting-o');
@ -565,7 +565,7 @@ window.Macui = {
}, 600); }, 600);
//绑定快捷键 //绑定快捷键
$("body").keyup(function(e) { $("body").keyup(function (e) {
if (e.ctrlKey) { if (e.ctrlKey) {
switch (e.keyCode) { switch (e.keyCode) {
case 37: //left case 37: //left
@ -584,15 +584,15 @@ window.Macui = {
} }
}); });
//launchpad 搜索功能 //launchpad 搜索功能
$("#launchpad .input-search").on("input propertychange", function() { $("#launchpad .input-search").on("input propertychange", function () {
//在输入框中打印输入的值 //在输入框中打印输入的值
var searchName = $(this).val(); var searchName = $(this).val();
if (searchName == "") { if (searchName == "") {
$("#app-shortcuts .shortcut").show(); $("#app-shortcuts .shortcut").show();
} else { } else {
$("#app-shortcuts .shortcut").each(function() { $("#app-shortcuts .shortcut").each(function () {
var appName = $(this).children(".title").text().toLowerCase(); var appName = $(this).children(".title").text().toLowerCase();
if (appName.indexOf(searchName.toLowerCase()) != -1){ if (appName.indexOf(searchName.toLowerCase()) != -1) {
$(this).show(); $(this).show();
} else { } else {
$(this).hide(); $(this).hide();
@ -622,20 +622,20 @@ window.Macui = {
//属性绑定 //属性绑定
Macui._bind_open_windows(); Macui._bind_open_windows();
}, },
setBgUrl: function(bgs) { setBgUrl: function (bgs) {
this._bgs = bgs; this._bgs = bgs;
this._checkBgUrls(); this._checkBgUrls();
}, },
setBg: function(bgs) { setBg: function (bgs) {
this._bgs = bgs; this._bgs = bgs;
this._checkBgUrls(); this._checkBgUrls();
}, },
menuClose: function() { menuClose: function () {
$("#mac-menu").removeClass('opened').addClass('hidden'); $("#mac-menu").removeClass('opened').addClass('hidden');
this._showShortcut(); this._showShortcut();
$(".mac-open-iframe").removeClass('hide'); $(".mac-open-iframe").removeClass('hide');
}, },
getLunarObj: function() { getLunarObj: function () {
//农历年信息 //农历年信息
let lunarInfo = [0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0, let lunarInfo = [0x04bd8, 0x04ae0, 0x0a570, 0x054d5, 0x0d260, 0x0d950, 0x16554, 0x056a0,
0x09ad0, 0x055d2, 0x09ad0, 0x055d2,
@ -875,17 +875,17 @@ window.Macui = {
return viewdate; return viewdate;
}, },
//launchpad渲染 //launchpad渲染
renderLaunchpad: function() { renderLaunchpad: function () {
$("#launchpad").removeClass("hidden").addClass("show").show(); $("#launchpad").removeClass("hidden").addClass("show").show();
$("#mac-shortcuts").addClass('shortcuts-hidden'); //隐藏图标 $("#mac-shortcuts").addClass('shortcuts-hidden'); //隐藏图标
this.renderDocks(); //渲染DOCK this.renderDocks(); //渲染DOCK
}, },
//close Launchpad //close Launchpad
closeLaunchpad: function() { closeLaunchpad: function () {
$("#launchpad").removeClass("show").addClass("hidden").hide(); $("#launchpad").removeClass("show").addClass("hidden").hide();
}, },
//消息中心渲染 //消息中心渲染
renderCommand: function(todayHtml = null) { renderCommand: function (todayHtml = null) {
let active = $("#mac_command_center .command-body.today").hasClass('active'); let active = $("#mac_command_center .command-body.today").hasClass('active');
if (!active) { if (!active) {
if (!todayHtml) { if (!todayHtml) {
@ -909,30 +909,30 @@ window.Macui = {
$("#mac_command_center .command-body.today").html(todayHtml).addClass('active'); $("#mac_command_center .command-body.today").html(todayHtml).addClass('active');
} }
}, },
menuOpen: function() { menuOpen: function () {
$("#mac-menu").addClass('opened').removeClass('hidden'); $("#mac-menu").addClass('opened').removeClass('hidden');
//this._hideShortcut(); //不关闭 //this._hideShortcut(); //不关闭
$(".mac-open-iframe").addClass('hide'); $(".mac-open-iframe").addClass('hide');
}, },
menuToggle: function() { menuToggle: function () {
if (!$("#mac-menu").hasClass('opened')) { if (!$("#mac-menu").hasClass('opened')) {
this.menuOpen(); this.menuOpen();
} else { } else {
this.menuClose(); this.menuClose();
} }
}, },
commandCenterClose: function() { commandCenterClose: function () {
$("#mac_command_center").addClass('hidden_right'); $("#mac_command_center").addClass('hidden_right');
this._showShortcut(); this._showShortcut();
$(".mac-open-iframe").removeClass('hide'); $(".mac-open-iframe").removeClass('hide');
}, },
commandCenterOpen: function() { commandCenterOpen: function () {
$("#mac_command_center").removeClass('hidden_right'); $("#mac_command_center").removeClass('hidden_right');
//this._hideShortcut(); //this._hideShortcut();
$(".mac-open-iframe").addClass('hide'); $(".mac-open-iframe").addClass('hide');
$("#mac-msg-nof").removeClass('on-new-msg fa-commenting-o'); $("#mac-msg-nof").removeClass('on-new-msg fa-commenting-o');
}, },
renderShortcuts: function() { renderShortcuts: function () {
if (!this.isSmallScreen()) { if (!this.isSmallScreen()) {
//大屏执行pc的布局也就是竖排靠右对齐小屏幕执行移动端也就是横向排列 //大屏执行pc的布局也就是竖排靠右对齐小屏幕执行移动端也就是横向排列
let h = parseInt(($("#mac #mac-shortcuts")[0].offsetHeight - 90) / 100); let h = parseInt(($("#mac #mac-shortcuts")[0].offsetHeight - 90) / 100);
@ -940,7 +940,7 @@ window.Macui = {
//计算一列最大几个图标,公式是(桌面图标界面的大小 - 顶部状态栏和底部dock栏的尺寸/单个图标高度所占的尺寸 //计算一列最大几个图标,公式是(桌面图标界面的大小 - 顶部状态栏和底部dock栏的尺寸/单个图标高度所占的尺寸
let x = 0, let x = 0,
y = 0; y = 0;
$("#mac #mac-shortcuts .shortcut").each(function() { $("#mac #mac-shortcuts .shortcut").each(function () {
$(this).css({ $(this).css({
right: x * 82 + 10, right: x * 82 + 10,
left: 'auto', left: 'auto',
@ -957,7 +957,7 @@ window.Macui = {
let w = parseInt(($("#mac #mac-shortcuts")[0].offsetWidth - 10) / 82); let w = parseInt(($("#mac #mac-shortcuts")[0].offsetWidth - 10) / 82);
let x = 0, let x = 0,
y = 0; y = 0;
$("#mac #mac-shortcuts .shortcut").each(function() { $("#mac #mac-shortcuts .shortcut").each(function () {
$(this).css({ $(this).css({
left: x * 82 + 10, left: x * 82 + 10,
right: 0, right: 0,
@ -972,11 +972,11 @@ window.Macui = {
} }
}, },
//渲染DOCK //渲染DOCK
renderDocks: function() { renderDocks: function () {
let cell_width = 50; let cell_width = 50;
let width = document.body.clientWidth; let width = document.body.clientWidth;
let docks = $(".dock .dock-container a"); let docks = $(".dock .dock-container a");
let max_num = parseInt((width - 40) / (cell_width + 25)) - 1; let max_num = width / cell_width - 1;
for (let i = 0; i <= docks.length; i++) { for (let i = 0; i <= docks.length; i++) {
if (i >= max_num) { if (i >= max_num) {
docks.eq(i).hide(); docks.eq(i).hide();
@ -997,18 +997,14 @@ window.Macui = {
halign: 'center' halign: 'center'
}) })
} else { } else {
$('.dock-container').css({ for (let i = 0; i <= max_num; i++) {
'width': width docks.on('mouseover', function (e) {
});
for (let i = 0; i < max_num; i++) {
docks.on('mouseover', function(e) {
e.preventDefault(); e.preventDefault();
}); });
docks.on('mouseout', function(e) { docks.on('mouseout', function (e) {
e.preventDefault(); e.preventDefault();
}); });
docks.on('click', function(e) { docks.on('click', function (e) {
e.preventDefault(); e.preventDefault();
}); });
docks.unbind("mouseover").unbind('mouseout').unbind('click').css({ docks.unbind("mouseover").unbind('mouseout').unbind('click').css({
@ -1020,14 +1016,14 @@ window.Macui = {
} }
} }
}, },
commandCenterToggle: function() { commandCenterToggle: function () {
if ($("#mac_command_center").hasClass('hidden_right')) { if ($("#mac_command_center").hasClass('hidden_right')) {
this.commandCenterOpen(); this.commandCenterOpen();
} else { } else {
this.commandCenterClose(); this.commandCenterClose();
} }
}, },
newMsg: function(title, content, handle_click, app_name = '提示消息', app_icon = newMsg: function (title, content, handle_click, app_name = '提示消息', app_icon =
'<img src="./img/icon/weather.png" class="notice-header-icon-img" />', is_del = true) { '<img src="./img/icon/weather.png" class="notice-header-icon-img" />', is_del = true) {
let msg = '<div class="notice">' + let msg = '<div class="notice">' +
'<div class="notice-header">' + '<div class="notice-header">' +
@ -1044,7 +1040,7 @@ window.Macui = {
'</div></div></div>'; '</div></div></div>';
let e = $(msg); let e = $(msg);
$("#mac_command_center .msgs").prepend(e); $("#mac_command_center .msgs").prepend(e);
e.find('.content:first,.title:first').click(function() { e.find('.content:first,.title:first').click(function () {
if (handle_click) { if (handle_click) {
handle_click(e); handle_click(e);
} }
@ -1057,17 +1053,17 @@ window.Macui = {
$("#mac-msg-nof").addClass('on-new-msg'); $("#mac-msg-nof").addClass('on-new-msg');
} }
}, },
getLayeroByIndex: function(index) { getLayeroByIndex: function (index) {
return $('#' + 'layui-layer' + index) return $('#' + 'layui-layer' + index)
}, },
isSmallScreen: function(size) { isSmallScreen: function (size) {
if (!size) { if (!size) {
size = 768 size = 768
} }
let width = document.body.clientWidth; let width = document.body.clientWidth;
return width < size; return width < size;
}, },
enableFullScreen: function() { enableFullScreen: function () {
let docElm = document.documentElement; let docElm = document.documentElement;
//W3C //W3C
if (docElm.requestFullscreen) { if (docElm.requestFullscreen) {
@ -1086,7 +1082,7 @@ window.Macui = {
document.body.msRequestFullscreen(); document.body.msRequestFullscreen();
} }
}, },
disableFullScreen: function() { disableFullScreen: function () {
if (document.exitFullscreen) { if (document.exitFullscreen) {
document.exitFullscreen(); document.exitFullscreen();
} else if (document.mozCancelFullScreen) { } else if (document.mozCancelFullScreen) {
@ -1097,16 +1093,16 @@ window.Macui = {
document.msExitFullscreen(); document.msExitFullscreen();
} }
}, },
buildList: function() { buildList: function () {
$("#mac-menu .list .sub-item").slideUp(); $("#mac-menu .list .sub-item").slideUp();
$("#mac-menu .list .item").each(function() { $("#mac-menu .list .item").each(function () {
if ($(this).next().hasClass('sub-item')) { if ($(this).next().hasClass('sub-item')) {
$(this).addClass('has-sub-down'); $(this).addClass('has-sub-down');
$(this).removeClass('has-sub-up'); $(this).removeClass('has-sub-up');
} }
}) })
}, },
openUrl: function(url, icon, title, areaAndOffset) { openUrl: function (url, icon, title, areaAndOffset) {
if (this._countTask > 12) { if (this._countTask > 12) {
layer.msg("您打开的太多了,歇会儿吧~"); layer.msg("您打开的太多了,歇会儿吧~");
return false; return false;
@ -1155,19 +1151,19 @@ window.Macui = {
offset: offset, offset: offset,
isOutAnim: false, isOutAnim: false,
skin: 'mac-open-iframe', skin: 'mac-open-iframe',
cancel: function(index, layero) { cancel: function (index, layero) {
$("#mac_" + index).remove(); $("#mac_" + index).remove();
Macui._checkTop(); Macui._checkTop();
Macui._countTask--; //回退countTask数 Macui._countTask--; //回退countTask数
Macui._renderBar(); Macui._renderBar();
}, },
min: function(layero) { min: function (layero) {
layero.hide(); layero.hide();
$("#mac_" + index).removeClass('show'); $("#mac_" + index).removeClass('show');
Macui._checkTop(); Macui._checkTop();
return false; return false;
}, },
full: function(layero) { full: function (layero) {
layero.find('.layui-layer-min').css('display', 'inline-block'); layero.find('.layui-layer-min').css('display', 'inline-block');
layero_opened.css('top', 24); layero_opened.css('top', 24);
}, },
@ -1182,11 +1178,11 @@ window.Macui = {
layero_opened.find('.layui-layer-setwin').prepend('<a class="mac-btn-refresh" index="' + index + layero_opened.find('.layui-layer-setwin').prepend('<a class="mac-btn-refresh" index="' + index +
'" href="#"></a>'); '" href="#"></a>');
//菜单排列倒序 //菜单排列倒序
layero_opened.find(".layui-layer-setwin>a").each(function() { layero_opened.find(".layui-layer-setwin>a").each(function () {
$(this).prependTo(layero_opened.find(".layui-layer-setwin")); $(this).prependTo(layero_opened.find(".layui-layer-setwin"));
}) })
layero_opened.find('.layui-layer-setwin .layui-layer-max').click(function() { layero_opened.find('.layui-layer-setwin .layui-layer-max').click(function () {
setTimeout(function() { setTimeout(function () {
let height = layero_opened.css('height'); let height = layero_opened.css('height');
height = parseInt(height.replace('px', '')); height = parseInt(height.replace('px', ''));
if (height >= document.body.clientHeight) { if (height >= document.body.clientHeight) {
@ -1201,13 +1197,13 @@ window.Macui = {
}); });
$("#mac_btn_group_middle").append(btn); $("#mac_btn_group_middle").append(btn);
Macui._renderBar(); Macui._renderBar();
btn.click(function() { btn.click(function () {
let index = $(this).attr('index'); let index = $(this).attr('index');
let layero = Macui.getLayeroByIndex(index); let layero = Macui.getLayeroByIndex(index);
let settop = function() { let settop = function () {
//置顶窗口 //置顶窗口
let max_zindex = 0; let max_zindex = 0;
$(".mac-open-iframe").each(function() { $(".mac-open-iframe").each(function () {
z = parseInt($(this).css('z-index')); z = parseInt($(this).css('z-index'));
$(this).css('z-index', z - 1); $(this).css('z-index', z - 1);
if (z > max_zindex) { if (z > max_zindex) {
@ -1237,7 +1233,7 @@ window.Macui = {
}); });
Macui._iframeOnClick.track(layero_opened.find('iframe:first')[0], function() { Macui._iframeOnClick.track(layero_opened.find('iframe:first')[0], function () {
if (Object.getOwnPropertyNames(Macui._iframe_click_lock_children).length === 0) { if (Object.getOwnPropertyNames(Macui._iframe_click_lock_children).length === 0) {
Macui._settop(layero_opened); Macui._settop(layero_opened);
Macui._checkTop(); Macui._checkTop();
@ -1251,22 +1247,23 @@ window.Macui = {
this.closeLaunchpad(); this.closeLaunchpad();
return index; return index;
}, },
closeAll: function() { closeAll: function () {
$(".mac-open-iframe").remove(); $(".mac-open-iframe").remove();
$("#mac_btn_group_middle").html(""); $("#mac_btn_group_middle").html("");
Macui._countTask = 0; Macui._countTask = 0;
Macui._renderBar(); Macui._renderBar();
}, },
setAnimated: function(animated_classes, animated_liveness) { setAnimated: function (animated_classes, animated_liveness) {
this._animated_classes = animated_classes; this._animated_classes = animated_classes;
this._animated_liveness = animated_liveness; this._animated_liveness = animated_liveness;
}, },
exit: function() { exit: function () {
layer.confirm(Macui.lang('确认要关闭本页吗?', 'Are you sure you want to close this page?'), { layer.confirm(Macui.lang('确认要关闭本页吗?', 'Are you sure you want to close this page?'), {
icon: 3, icon: 3,
title: Macui.lang('提示', 'Prompt') title: Macui.lang('提示', 'Prompt')
}, function(index) { }, function (index) {
document.body.onbeforeunload = function() {}; document.body.onbeforeunload = function () {
};
window.location.href = "about:blank"; window.location.href = "about:blank";
window.close(); window.close();
layer.close(index); layer.close(index);
@ -1277,10 +1274,10 @@ window.Macui = {
}); });
}, },
lang: function(cn, en) { lang: function (cn, en) {
return this._lang === 'zh-cn' || this._lang === 'zh-tw' ? cn : en; return this._lang === 'zh-cn' || this._lang === 'zh-tw' ? cn : en;
}, },
aboutUs: function() { aboutUs: function () {
//关于我们 //关于我们
layer.open({ layer.open({
type: 1, type: 1,
@ -1297,12 +1294,12 @@ window.Macui = {
'</div>' '</div>'
}); });
}, },
setContextMenu: function(jq_dom, menu) { setContextMenu: function (jq_dom, menu) {
if (typeof(jq_dom) === 'string') { if (typeof (jq_dom) === 'string') {
jq_dom = $(jq_dom); jq_dom = $(jq_dom);
} }
jq_dom.unbind('contextmenu'); jq_dom.unbind('contextmenu');
jq_dom.on('contextmenu', function(e) { jq_dom.on('contextmenu', function (e) {
if (menu) { if (menu) {
Macui._renderContextMenu(e.clientX, e.clientY, menu, this); Macui._renderContextMenu(e.clientX, e.clientY, menu, this);
if (e.cancelable) { if (e.cancelable) {
@ -1315,8 +1312,8 @@ window.Macui = {
} }
}); });
}, },
hideWins: function() { hideWins: function () {
$('#mac_btn_group_middle>.btn.show').each(function() { $('#mac_btn_group_middle>.btn.show').each(function () {
let index = $(this).attr('index'); let index = $(this).attr('index');
let layero = Macui.getLayeroByIndex(index); let layero = Macui.getLayeroByIndex(index);
$(this).removeClass('show'); $(this).removeClass('show');
@ -1324,8 +1321,8 @@ window.Macui = {
layero.hide(); layero.hide();
}) })
}, },
showWins: function() { showWins: function () {
$('#mac_btn_group_middle>.btn').each(function() { $('#mac_btn_group_middle>.btn').each(function () {
let index = $(this).attr('index'); let index = $(this).attr('index');
let layero = Macui.getLayeroByIndex(index); let layero = Macui.getLayeroByIndex(index);
$(this).addClass('show'); $(this).addClass('show');
@ -1333,16 +1330,16 @@ window.Macui = {
}); });
Macui._checkTop(); Macui._checkTop();
}, },
getDesktopScene: function() { getDesktopScene: function () {
return $("#mac-desktop-scene"); return $("#mac-desktop-scene");
}, },
onReady: function(handle) { onReady: function (handle) {
Macui._handleReady.push(handle); Macui._handleReady.push(handle);
} }
}; };
$(function() { $(function () {
Macui._init(); Macui._init();
for (let i in Macui._handleReady) { for (let i in Macui._handleReady) {
let handle = Macui._handleReady[i]; let handle = Macui._handleReady[i];