文件操作 - focus.js
返回文件管理
返回主菜单
删除本文件
文件: /home/www/public/wp-content/plugins/ionos-journey/js/journey/parts/focus.js
编辑文件内容
export default class Focus { constructor( parent ) { this.parent = parent; this.target = document.body; this.id = 'ionos-journey-focus'; this.jumps = 1; this.add(); this.registerClickEvent(); this.onClick = []; } getHtmlElement() { return document.body.querySelector( '#' + this.id ); } add() { const targetRect = this.target.getBoundingClientRect(); const el = document.createElement( 'DIV' ); el.id = this.id; el.style.top = targetRect.top + 'px'; el.style.left = targetRect.left + 'px'; el.style.width = targetRect.width - 8 + 'px'; el.style.height = targetRect.height - 8 + 'px'; el.style.borderColor = 'transparent'; this.parent.prepend( el ); } changeCursor( cursor ) { this.getHtmlElement().style.cursor = cursor; } addAnimation() { this.getHtmlElement().className = 'pulse-with-background'; this.changeCursor( 'pointer' ); } rmvAnimation() { this.getHtmlElement().className = ''; this.changeCursor( 'default' ); } registerClickEvent() { this.getHtmlElement().addEventListener( 'click', ( e ) => { if ( e.target === this.getHtmlElement() && e.target.closest( '#ionos-journey-guide' ) === null ) { this.onClick.forEach( ( fn ) => { fn(); } ); } } ); } removeChildren() { const focus = this.getHtmlElement(); while ( focus.firstChild ) { focus.removeChild( focus.lastChild ); } } resize( width, height ) { this.getHtmlElement().style.width = width + 'px'; this.getHtmlElement().style.height = height + 'px'; } hide() { this.getHtmlElement().style.visibility = 'hidden'; } show() { this.getHtmlElement().style.visibility = 'visible'; } setColor( color ) { this.getHtmlElement().style.borderColor = color; } moveToTop() { const cachedTransition = this.getHtmlElement().style.transition; this.getHtmlElement().style.transition = '0s all'; this.getHtmlElement().style.top = '0px'; setTimeout( () => { this.getHtmlElement().style.transition = cachedTransition; }, 500 ); } moveToBottom() { const cachedTransition = this.getHtmlElement().style.transition; this.getHtmlElement().style.transition = '0s all'; this.getHtmlElement().style.top = ( window.innerHeight || document.documentElement.clientHeight ) + 10 + 'px'; setTimeout( () => { this.getHtmlElement().style.transition = cachedTransition; }, 500 ); } move( x, y, width, height, callback ) { requestAnimationFrame( () => { this.getHtmlElement().style.left = x + 'px'; this.getHtmlElement().style.top = y + 'px'; this.getHtmlElement().style.width = width - 8 + 'px'; this.getHtmlElement().style.height = height - 8 + 'px'; } ); setTimeout( () => { callback(); }, 1000 ); } }
修改文件时间
将文件时间修改为当前时间的前一年
删除文件