mirror of
https://gitee.com/java110/MicroCommunityWeb.git
synced 2026-02-24 05:46:03 +08:00
优化代码
This commit is contained in:
parent
14538d290d
commit
9400b0f01c
@ -18,7 +18,7 @@
|
||||
<link href="/css/plugins/summernote/summernote-bs4.min.css" rel="stylesheet">
|
||||
<link href="/css/plugins/jsTree/style.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/css/vc-ui.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/bootstrap-submenu@3.0.1/dist/css/bootstrap-submenu.css">
|
||||
<link rel="stylesheet" href="/css/plugins/bootstrap-submenu/bootstrap-submenu.css">
|
||||
|
||||
<script src="/js/bootstrap/jquery-3.3.1.min.js"></script>
|
||||
<script src="/js/vue/vue.min.js"></script>
|
||||
@ -27,8 +27,8 @@
|
||||
<script src="/js/bootstrap/bootstrap.min.js"></script>
|
||||
<script src="/js/bootstrap/bootstrap-datetimepicker.js"></script>
|
||||
<script src="/js/bootstrap/bootstrap-datetimepicker.zh-CN.js"></script>
|
||||
<!-- <script src="/js/bootstrap/bootstrap-submenu.js"></script> -->
|
||||
<script src="https://unpkg.com/bootstrap-submenu@3.0.1/dist/js/bootstrap-submenu.js" defer></script>
|
||||
<script src="/js/bootstrap/bootstrap-submenu.js"></script>
|
||||
|
||||
<script src="/js/plugins/select2/select2.full.min.js"></script>
|
||||
<script src="/js/plugins/echart/echarts.min.js"></script>
|
||||
<script src="/js/plugins/echart/china.js"></script>
|
||||
|
||||
29
public/css/plugins/bootstrap-submenu/bootstrap-submenu.css
vendored
Normal file
29
public/css/plugins/bootstrap-submenu/bootstrap-submenu.css
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
.dropdown-submenu.dropright .dropdown-menu {
|
||||
margin-left: 1px;
|
||||
}
|
||||
|
||||
.dropdown-submenu.dropleft .dropdown-menu {
|
||||
margin-right: 1px;
|
||||
}
|
||||
|
||||
[x-placement^="bottom-"] .dropdown-submenu .dropdown-menu,
|
||||
.navbar .dropdown-submenu .dropdown-menu {
|
||||
bottom: auto;
|
||||
margin-top: calc(-0.5rem - 1px);
|
||||
}
|
||||
|
||||
[x-placement^="top-"] .dropdown-submenu .dropdown-menu {
|
||||
top: auto;
|
||||
bottom: 0;
|
||||
margin-bottom: calc(-0.5rem - 1px);
|
||||
}
|
||||
|
||||
.dropdown-submenu.dropright > .dropdown-toggle {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.dropdown-submenu.dropright > .dropdown-toggle::after {
|
||||
margin-right: -12px;
|
||||
}
|
||||
234
public/js/bootstrap/bootstrap-submenu.js
vendored
234
public/js/bootstrap/bootstrap-submenu.js
vendored
@ -1,121 +1,123 @@
|
||||
(function (factory) {
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node/CommonJS
|
||||
module.exports = factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(jQuery);
|
||||
if (typeof define === 'function' && define.amd) {
|
||||
// AMD. Register as an anonymous module
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node/CommonJS
|
||||
module.exports = factory(require('jquery'));
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(jQuery);
|
||||
}
|
||||
})(function ($) {
|
||||
var DropdownSubmenu =
|
||||
/*#__PURE__*/
|
||||
function () {
|
||||
function DropdownSubmenu(element) {
|
||||
this.element = element.parentElement;
|
||||
this.menuElement = this.element.querySelector('.dropdown-menu');
|
||||
this.init();
|
||||
}
|
||||
})(function ($) {
|
||||
var DropdownSubmenu = /*#__PURE__*/function () {
|
||||
function DropdownSubmenu(element) {
|
||||
this.element = element.parentElement;
|
||||
this.menuElement = this.element.querySelector('.dropdown-menu');
|
||||
this.init();
|
||||
}
|
||||
|
||||
var _proto = DropdownSubmenu.prototype;
|
||||
|
||||
_proto.init = function init() {
|
||||
var _this = this;
|
||||
|
||||
$(this.element).off('keydown.bs.dropdown.data-api');
|
||||
this.menuElement.addEventListener('keydown', this.itemKeydown.bind(this));
|
||||
var dropdownItemNodeList = this.menuElement.querySelectorAll('.dropdown-item');
|
||||
Array.from(dropdownItemNodeList).forEach(function (element) {
|
||||
element.addEventListener('keydown', _this.handleKeydownDropdownItem.bind(_this));
|
||||
});
|
||||
$(this.menuElement).on('keydown', '.dropdown-submenu > .dropdown-item', this.handleKeydownSubmenuDropdownItem.bind(this));
|
||||
$(this.menuElement).on('click', '.dropdown-submenu > .dropdown-item', this.handleClickSubmenuDropdownItem.bind(this));
|
||||
$(this.element).on('hidden.bs.dropdown', function () {
|
||||
_this.close(_this.menuElement);
|
||||
});
|
||||
};
|
||||
|
||||
_proto.handleKeydownDropdownItem = function handleKeydownDropdownItem(event) {
|
||||
// 27: Esc
|
||||
if (event.keyCode !== 27) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.target.closest('.dropdown-menu').previousElementSibling.focus();
|
||||
event.target.closest('.dropdown-menu').classList.remove('show');
|
||||
};
|
||||
|
||||
_proto.handleKeydownSubmenuDropdownItem = function handleKeydownSubmenuDropdownItem(event) {
|
||||
// 32: Spacebar
|
||||
if (event.keyCode !== 32) {
|
||||
return;
|
||||
} // NOTE: Off vertical scrolling
|
||||
|
||||
|
||||
event.preventDefault();
|
||||
this.toggle(event.target);
|
||||
};
|
||||
|
||||
_proto.handleClickSubmenuDropdownItem = function handleClickSubmenuDropdownItem(event) {
|
||||
event.stopPropagation();
|
||||
this.toggle(event.target);
|
||||
};
|
||||
|
||||
_proto.itemKeydown = function itemKeydown(event) {
|
||||
// 38: Arrow up, 40: Arrow down
|
||||
if (![38, 40].includes(event.keyCode)) {
|
||||
return;
|
||||
} // NOTE: Off vertical scrolling
|
||||
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
var itemNodeList = this.element.querySelectorAll('.show > .dropdown-item:not(:disabled):not(.disabled), .show > .dropdown > .dropdown-item');
|
||||
var index = Array.from(itemNodeList).indexOf(event.target);
|
||||
|
||||
if (event.keyCode === 38 && index !== 0) {
|
||||
index--;
|
||||
} else if (event.keyCode === 40 && index !== itemNodeList.length - 1) {
|
||||
index++;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
itemNodeList[index].focus();
|
||||
};
|
||||
|
||||
_proto.toggle = function toggle(element) {
|
||||
var dropdownElement = element.closest('.dropdown');
|
||||
var parentMenuElement = dropdownElement.closest('.dropdown-menu');
|
||||
var menuElement = dropdownElement.querySelector('.dropdown-menu');
|
||||
var isOpen = menuElement.classList.contains('show');
|
||||
this.close(parentMenuElement);
|
||||
menuElement.classList.toggle('show', !isOpen);
|
||||
};
|
||||
|
||||
_proto.close = function close(menuElement) {
|
||||
var menuNodeList = menuElement.querySelectorAll('.dropdown-menu.show');
|
||||
Array.from(menuNodeList).forEach(function (element) {
|
||||
element.classList.remove('show');
|
||||
});
|
||||
};
|
||||
|
||||
return DropdownSubmenu;
|
||||
}(); // For AMD/Node/CommonJS used elements (optional)
|
||||
// http://learn.jquery.com/jquery-ui/environments/amd/
|
||||
|
||||
|
||||
$.fn.submenupicker = function (elements) {
|
||||
var $elements = this instanceof $ ? this : $(elements);
|
||||
return $elements.each(function () {
|
||||
var data = $.data(this, 'bs.submenu');
|
||||
|
||||
if (!data) {
|
||||
data = new DropdownSubmenu(this);
|
||||
$.data(this, 'bs.submenu', data);
|
||||
}
|
||||
|
||||
var _proto = DropdownSubmenu.prototype;
|
||||
|
||||
_proto.init = function init() {
|
||||
var _this = this;
|
||||
|
||||
$(this.element).off('keydown.bs.dropdown.data-api');
|
||||
this.menuElement.addEventListener('keydown', this.itemKeydown.bind(this));
|
||||
var dropdownItemNodeList = this.menuElement.querySelectorAll('.dropdown-item');
|
||||
Array.from(dropdownItemNodeList).forEach(function (element) {
|
||||
element.addEventListener('keydown', _this.handleKeydownDropdownItem.bind(_this));
|
||||
});
|
||||
$(this.menuElement).on('keydown', '.dropdown-submenu > .dropdown-item', this.handleKeydownSubmenuDropdownItem.bind(this));
|
||||
$(this.menuElement).on('click', '.dropdown-submenu > .dropdown-item', this.handleClickSubmenuDropdownItem.bind(this));
|
||||
$(this.element).on('hidden.bs.dropdown', function () {
|
||||
_this.close(_this.menuElement);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
_proto.handleKeydownDropdownItem = function handleKeydownDropdownItem(event) {
|
||||
// 27: Esc
|
||||
if (event.keyCode !== 27) {
|
||||
return;
|
||||
}
|
||||
|
||||
event.target.closest('.dropdown-menu').previousElementSibling.focus();
|
||||
event.target.closest('.dropdown-menu').classList.remove('show');
|
||||
};
|
||||
|
||||
_proto.handleKeydownSubmenuDropdownItem = function handleKeydownSubmenuDropdownItem(event) {
|
||||
// 32: Spacebar
|
||||
if (event.keyCode !== 32) {
|
||||
return;
|
||||
} // NOTE: Off vertical scrolling
|
||||
|
||||
|
||||
event.preventDefault();
|
||||
this.toggle(event.target);
|
||||
};
|
||||
|
||||
_proto.handleClickSubmenuDropdownItem = function handleClickSubmenuDropdownItem(event) {
|
||||
event.stopPropagation();
|
||||
this.toggle(event.target);
|
||||
};
|
||||
|
||||
_proto.itemKeydown = function itemKeydown(event) {
|
||||
// 38: Arrow up, 40: Arrow down
|
||||
if (![38, 40].includes(event.keyCode)) {
|
||||
return;
|
||||
} // NOTE: Off vertical scrolling
|
||||
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
var itemNodeList = this.element.querySelectorAll('.show > .dropdown-item:not(:disabled):not(.disabled), .show > .dropdown > .dropdown-item');
|
||||
var index = Array.from(itemNodeList).indexOf(event.target);
|
||||
|
||||
if (event.keyCode === 38 && index !== 0) {
|
||||
index--;
|
||||
} else if (event.keyCode === 40 && index !== itemNodeList.length - 1) {
|
||||
index++;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
itemNodeList[index].focus();
|
||||
};
|
||||
|
||||
_proto.toggle = function toggle(element) {
|
||||
var dropdownElement = element.closest('.dropdown');
|
||||
var parentMenuElement = dropdownElement.closest('.dropdown-menu');
|
||||
var menuElement = dropdownElement.querySelector('.dropdown-menu');
|
||||
var isOpen = menuElement.classList.contains('show');
|
||||
this.close(parentMenuElement);
|
||||
menuElement.classList.toggle('show', !isOpen);
|
||||
};
|
||||
|
||||
_proto.close = function close(menuElement) {
|
||||
var menuNodeList = menuElement.querySelectorAll('.dropdown-menu.show');
|
||||
Array.from(menuNodeList).forEach(function (element) {
|
||||
element.classList.remove('show');
|
||||
});
|
||||
};
|
||||
|
||||
return DropdownSubmenu;
|
||||
});
|
||||
}(); // For AMD/Node/CommonJS used elements (optional)
|
||||
// http://learn.jquery.com/jquery-ui/environments/amd/
|
||||
|
||||
|
||||
$.fn.submenupicker = function (elements) {
|
||||
var $elements = this instanceof $ ? this : $(elements);
|
||||
return $elements.each(function () {
|
||||
var data = $.data(this, 'bs.submenu');
|
||||
|
||||
if (!data) {
|
||||
data = new DropdownSubmenu(this);
|
||||
$.data(this, 'bs.submenu', data);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return DropdownSubmenu;
|
||||
});
|
||||
@ -17,7 +17,7 @@
|
||||
<!-- SUMMERNOTE 富文本组件-->
|
||||
<link href="/css/plugins/summernote/summernote-bs4.min.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="/css/vc-ui.css" />
|
||||
<link rel="stylesheet" href="https://unpkg.com/bootstrap-submenu@3.0.1/dist/css/bootstrap-submenu.css">
|
||||
<link rel="stylesheet" href="/css/plugins/bootstrap-submenu/bootstrap-submenu.css">
|
||||
|
||||
<script src="/js/bootstrap/jquery-3.3.1.min.js"></script>
|
||||
<script src="/js/vue/vue.min.js"></script>
|
||||
@ -26,8 +26,7 @@
|
||||
<script src="/js/bootstrap/bootstrap.min.js"></script>
|
||||
<script src="/js/bootstrap/bootstrap-datetimepicker.js"></script>
|
||||
<script src="/js/bootstrap/bootstrap-datetimepicker.zh-CN.js"></script>
|
||||
<!-- <script src="/js/bootstrap/bootstrap-submenu.js"></script> -->
|
||||
<script src="https://unpkg.com/bootstrap-submenu@3.0.1/dist/js/bootstrap-submenu.js" defer></script>
|
||||
<script src="/js/bootstrap/bootstrap-submenu.js"></script>
|
||||
<script src="/js/plugins/select2/select2.full.min.js"></script>
|
||||
<script src="/js/plugins/echart/echarts.min.js"></script>
|
||||
<script src="/js/plugins/echart/china.js"></script>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user