focustracker.js 606 B

123456789101112131415161718
  1. /**
  2. * @license Copyright (c) 2003-2020, CKSource - Frederico Knabben. All rights reserved.
  3. * For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
  4. */
  5. /* global document */
  6. import FocusTracker from '../../../src/focustracker';
  7. const focusTracker = new FocusTracker();
  8. const counters = document.querySelectorAll( '.status b' );
  9. [].forEach.call( document.querySelectorAll( '.track' ), el => focusTracker.add( el ) );
  10. focusTracker.on( 'change:isFocused', ( evt, name, value ) => {
  11. const el = counters[ value ? 0 : 1 ];
  12. el.textContent = parseInt( el.textContent ) + 1;
  13. } );