mirror of
https://github.com/zhw2590582/ArtPlayer.git
synced 2026-10-24 14:41:20 -08:00
压缩字符
This commit is contained in:
1 parent
baaaa4c56c
commit
ee90291897
13 files changed
+216
-280
No files matched your search
@@ -10,15 +10,15 @@ export default class Contextmenu extends Component {
|
||||
constructor(art) {
|
||||
super(art);
|
||||
|
||||
this.$parent = art.template.$contextmenu;
|
||||
const {
|
||||
option,
|
||||
template: { $player, $contextmenu },
|
||||
events: { proxy },
|
||||
} = art;
|
||||
|
||||
this.$parent = $contextmenu;
|
||||
|
||||
art.on('ready', () => {
|
||||
const {
|
||||
option,
|
||||
template: { $player, $contextmenu },
|
||||
events: { proxy },
|
||||
} = art;
|
||||
|
||||
this.add(
|
||||
playbackRate({
|
||||
disable: !option.playbackRate,
|
||||
|
||||
@@ -17,9 +17,9 @@ export default class Control extends Component {
|
||||
constructor(art) {
|
||||
super(art);
|
||||
|
||||
art.on('ready', () => {
|
||||
const { option } = art;
|
||||
const { option } = art;
|
||||
|
||||
art.on('ready', () => {
|
||||
this.add(
|
||||
progress({
|
||||
name: 'progress',
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
export default class Hotkey {
|
||||
constructor(art) {
|
||||
this.art = art;
|
||||
this.keys = {};
|
||||
if (this.art.option.hotkey) {
|
||||
this.art.on('ready', () => {
|
||||
if (art.option.hotkey) {
|
||||
art.on('ready', () => {
|
||||
this.add(27, () => {
|
||||
if (art.player.fullscreenWeb) {
|
||||
art.player.fullscreenWeb = false;
|
||||
@@ -30,7 +29,21 @@ export default class Hotkey {
|
||||
art.player.volume -= 0.1;
|
||||
});
|
||||
|
||||
this.init();
|
||||
const { proxy } = art.events;
|
||||
proxy(window, 'keydown', event => {
|
||||
if (art.isFocus) {
|
||||
const tag = document.activeElement.tagName.toUpperCase();
|
||||
const editable = document.activeElement.getAttribute('contenteditable');
|
||||
if (tag !== 'INPUT' && tag !== 'TEXTAREA' && editable !== '' && editable !== 'true') {
|
||||
const events = this.keys[event.keyCode];
|
||||
if (events) {
|
||||
event.preventDefault();
|
||||
events.forEach(fn => fn());
|
||||
art.emit('hotkey', event);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -42,22 +55,4 @@ export default class Hotkey {
|
||||
this.keys[key] = [event];
|
||||
}
|
||||
}
|
||||
|
||||
init() {
|
||||
const { proxy } = this.art.events;
|
||||
proxy(window, 'keydown', event => {
|
||||
if (this.art.isFocus) {
|
||||
const tag = document.activeElement.tagName.toUpperCase();
|
||||
const editable = document.activeElement.getAttribute('contenteditable');
|
||||
if (tag !== 'INPUT' && tag !== 'TEXTAREA' && editable !== '' && editable !== 'true') {
|
||||
const events = this.keys[event.keyCode];
|
||||
if (events) {
|
||||
event.preventDefault();
|
||||
events.forEach(fn => fn());
|
||||
this.art.emit('hotkey', event);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import Component from './utils/component';
|
||||
export default class Loading extends Component {
|
||||
constructor(art) {
|
||||
super(art);
|
||||
const { $loading } = art.template;
|
||||
append($loading, art.icons.loading);
|
||||
append(art.template.$loading, art.icons.loading);
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import Component from './utils/component';
|
||||
export default class Mask extends Component {
|
||||
constructor(art) {
|
||||
super(art);
|
||||
const { $state } = art.template;
|
||||
append($state, art.icons.state);
|
||||
append(art.template.$state, art.icons.state);
|
||||
}
|
||||
}
|
||||
@@ -20,7 +20,8 @@ export default class Notice {
|
||||
}
|
||||
|
||||
hide() {
|
||||
const { $player } = this.art.template;
|
||||
const { $player, $noticeInner } = this.art.template;
|
||||
$noticeInner.innerHTML = '';
|
||||
removeClass($player, 'art-notice-show');
|
||||
this.art.emit('notice:toggle', true);
|
||||
}
|
||||
|
||||
@@ -7,15 +7,15 @@ export default class Setting extends Component {
|
||||
constructor(art) {
|
||||
super(art);
|
||||
|
||||
this.$parent = art.template.$settingBody;
|
||||
|
||||
const {
|
||||
option,
|
||||
template: { $setting },
|
||||
template: { $setting, $settingBody },
|
||||
events: { proxy },
|
||||
} = art;
|
||||
|
||||
if (art.option.setting) {
|
||||
this.$parent = $settingBody;
|
||||
|
||||
if (option.setting) {
|
||||
art.on('ready', () => {
|
||||
proxy($setting, 'click', e => {
|
||||
if (e.target === $setting) {
|
||||
@@ -44,10 +44,10 @@ export default class Setting extends Component {
|
||||
}),
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
art.on('blur', () => {
|
||||
this.show = false;
|
||||
});
|
||||
art.on('blur', () => {
|
||||
this.show = false;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,3 @@
|
||||
import { defineProperty } from './property';
|
||||
|
||||
export function query(selector, parent = document) {
|
||||
return parent.querySelector(selector);
|
||||
}
|
||||
@@ -63,28 +61,3 @@ export function tooltip(target, msg, pos = 'up') {
|
||||
target.setAttribute('aria-label', msg);
|
||||
target.setAttribute('data-balloon-pos', pos);
|
||||
}
|
||||
|
||||
export function addShowProperty(target, ref, name) {
|
||||
const className = `art-${name}-show`;
|
||||
|
||||
defineProperty(target, 'show', {
|
||||
get() {
|
||||
return hasClass(ref, className);
|
||||
},
|
||||
set(value) {
|
||||
if (value) {
|
||||
addClass(ref, className);
|
||||
} else {
|
||||
removeClass(ref, className);
|
||||
}
|
||||
|
||||
target.art.emit(`${name}:toggle`, value);
|
||||
},
|
||||
});
|
||||
|
||||
defineProperty(target, 'toggle', {
|
||||
value: () => {
|
||||
target.show = !target.show;
|
||||
},
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user