Commit Graph

729 Commits

Author SHA1 Message Date
toasted-nutbread
736d3c892e
Dictionary data utility class (#698)
* Create utility class for helping format dictionary data

* Change format
2020-07-30 20:45:52 -04:00
toasted-nutbread
6e0b25c5d6
Standardize hotkey action naming convention (#696) 2020-07-26 20:25:15 -04:00
toasted-nutbread
313476aa92
Query parser fix (#695)
* Standardize setContent calls

* Rename _queryText to _fullQuery

* Move query parser into Display and update float.html

* Generalize params

* Add "full" parameter to maintain the original full query
2020-07-26 19:29:12 -04:00
toasted-nutbread
0512258c8e
Display scroll refactor (#694)
* Cache navigation header

* Create _focusEntry

* Update scroll restoration

* Require explicit entry focus index
2020-07-26 18:49:38 -04:00
toasted-nutbread
208217198e
Display history refactor (#691)
* Create DisplayHistory

* Change arguments for _setContentTermsOrKanji

* Set up history-driven content updates

* Use new history only

* Load definitions if missing

* Refactor definitions getting

* Add support for wildcards

* Move definitions setup

* Add events

* Allow state change even if there is no history state

* Update search page to use history

* Fix history overwriting

* Fix search page not seeing state chang events during prepare

* Update state if necessary

* Don't reassign query text if the same

* Remove DisplayContext

* Initialize with real history state

* Track URL

* Update DisplayHistory to support pseudo-history

* Configure history settings on search page

* Fix state

* Use full URL

* Change data format of setContent

* Rename details to content

* Update event arguments

* Fix animation

* Remove old state changes

* Clear content properly

* Remove set/clear content overrides

* Fix setting up event listeners for content clear

* Make clearContent private

* Make focus opt-in

* Validate source

* Add unloaded type

* Generalize content params

* Update how extension unload content is assigned

* Restore query blurring
2020-07-26 16:51:54 -04:00
toasted-nutbread
4a43b41f79
Set content refactor (#686)
* Simplify invoke

* Pass isTerms instead of type

* Update DisplaySearch.setContent to pass argument array

* Simplify argument object structure for setContent

* Move focus and disableHistory level

* Always include focus and disableHistory options

* Change disableHistory to history

* Pass source text to setContent

* Use consistent argument/object field order

* Remove unused previous field

* Combine logic for forward/back navigation
2020-07-25 09:58:06 -04:00
toasted-nutbread
e493cbc998
Simplify Popup.showContent API to use only two details arguments (#684) 2020-07-24 17:34:53 -04:00
toasted-nutbread
71b97c2019
Display refactoring (#674)
* Move setupNestedPopups to Display

* Move auto-play timer and delay into Display

* Move some message handler definitions into Display

* Move default optionsContext definition
2020-07-18 23:47:02 -04:00
toasted-nutbread
d7f78c23b5
Script ready state change (#672)
* Update how backend/frontend ready states are awaited and signaled

* Log errors on the search page

* Update action name
2020-07-18 17:11:38 -04:00
toasted-nutbread
c6c0126394
Content script ready checks (#670)
* Move ready checkout of Display

* Add function to wait until if a tab's content script is ready
2020-07-18 14:18:10 -04:00
toasted-nutbread
dac33e6961
Extension unload indication fix (#662)
* Remove unused function

* Rename field

* Change extensionUnloaded trigger function

* Update how extension unloaded content is shown

* Ignore certain errors caused by extension unload

* Add _showExtensionUnloaded function

* Wrap internals of updateOptions

* Suppress errors caued by extension unload

* Make the frontend trigger the popup's extensionUnloaded event
2020-07-18 14:15:36 -04:00
toasted-nutbread
ec42a7e4d6
Message handler refactor (#660)
* Refactor searchQueryUpdate action

* Use standard message handler style

* Use name "promiseOrResult" for consistency

* Use standard message handler convention for Yomichan message handlers

* Use common message handler invoker
2020-07-11 15:20:00 -04:00
toasted-nutbread
8389cd8ba2
Popup crossFrame communication (#658)
* Add support for dynamic message handlers

* Pass messages using crossFrame.invoke instead of contentWindow.postMessage

* Set up async handlers

* Simplify configure call and response
2020-07-10 22:13:59 -04:00
toasted-nutbread
964f011409
Various updates to FrameOffsetForwarder (#657)
* Remove bindings

* Fast exit if same window

* Simplify selector

* Rename functions, reuse _getFrameOffsetParent

* Update message style

* Send reply message to a specific frame
2020-07-10 22:13:11 -04:00
toasted-nutbread
59c224d99d
Add support for async vs non-async (#656) 2020-07-10 22:12:14 -04:00
toasted-nutbread
f76a6ff1e3
Refactor hotkey definitions to be more generic (#655) 2020-07-08 20:02:20 -04:00
toasted-nutbread
6f49f426b5
Generalized frame connections (#654)
* Create FrameClient and FrameEndpoint

* Use new Frame* classes for Popup=>frame connection

* Update api.sendMessageToFrame and api.broadcastTab to include the sender's frameId

* Update FrameClient to store the frame's frameId
2020-07-08 19:58:06 -04:00
toasted-nutbread
295ffa6e54
Refactor DisplayFloat=>Frontend message passing (#652)
* Change getOrCreatePopup arguments to be an object

* Add ownerFrameId to popup and DisplayFloat

* Refactor DisplayFloat host action invocation

* Use CrossFrameAPI instead of window.postMessage

* Update popup closing functionality on the search page
2020-07-08 19:50:13 -04:00
toasted-nutbread
8f48a23a45
Display class refactoring (#650)
* Organize by public/private

* Don't access super class's private members

* Make _autoPlayAudioTimer private

* Refactor constructors

* Make functions private

* Organize by public/private

* Organize window message handlers

* Make fields private

* Refactor DisplaySearch constructor

* Make functions private

* Organize by public/private
2020-07-03 15:58:29 -04:00
toasted-nutbread
a07a8dfff6
Extension unload detection (#647)
* Update how extension unload is detected

* Remove event handlers and use yomichan.isExtensionUnloaded instead

* Update terminology
2020-07-03 12:20:22 -04:00
toasted-nutbread
e36bc8771f
Display refactor (#643)
* Remove statics

* Move orphan detection and error handling to Display

* Add clearContent function

* Add/use public get/set functions for optionsContext

* Add public getOptions

* Move interactive assignment

* Mark fields as private

* Mark functions as private

* Change stray getter into a function
2020-07-03 12:02:21 -04:00
toasted-nutbread
562cfd7470
Make PopupProxy._frameOffsetExpireTimeout non-static (#640) 2020-07-03 11:58:52 -04:00
toasted-nutbread
0279d00274
Don't use/assign popup private fields without using "this" (#635) 2020-07-03 11:54:51 -04:00
toasted-nutbread
f2345b7d1c
Use deferPromise (#630)
* Use deferPromise

* Move definition

* Implement promiseTimeout using deferPromise
2020-06-28 14:39:43 -04:00
toasted-nutbread
5bf805755a
Yomichan object separation (#627)
* Move "yomichan" object setup to a separate file

* Update script imports

* Align message handlers

* Rename Yomichan.prepare to Yomichan.ready

* Add new prepare function

* Improve isExtensionUrl
2020-06-28 11:26:43 -04:00
toasted-nutbread
6ee50b3c95
Make PopupFactory.prepare non-async (#625) 2020-06-25 18:32:29 -04:00
toasted-nutbread
3e68af8666
Shadow DOM container for popup iframes (#623)
* Add support for injecting stylesheets into a custom parent node

* Add api.getStylesheetContent

* Add support for injecting a CSS file's content

* Add usePopupShadowDom option

* Use a per-parentNode cache

* Add support for using a shadow DOM wrapper around popup iframes

* Ignore the popup container instead of the frame
2020-06-24 21:46:13 -04:00
toasted-nutbread
96932119f8
Remove window. from visualViewport, use local variable instead (#621) 2020-06-22 19:27:40 -04:00
toasted-nutbread
65c41975a6
Secure popup frame url changes (#622)
* Throw error if options is not ready

* Remove id

* Change unsecurePopupFrameUrl to useSecurePopupFrameUrl
2020-06-22 19:26:59 -04:00
toasted-nutbread
f2991fb9ee
Frontend initialization refactor (#610)
* Create member functions for ignoreElements and ignorePoint

* Create addFullscreenChangeEventListener utility

* Move popup creation management into Frontend

* Move getUrl implementation

* Remove old setup

* Remove try/catch block

* Error wrap

* Add prepare call to TextScanner

* Update depth when popup changes

* Refactor how Frontend gets PopupFactory and frameId

* Update popup preview to work

* Update popup preview frame to use the frontend's popup

* Update how nested popups are set up

* Error wrap

* Update how popups are set up on the search page

* Error wrap

* Error unwrap

* Add missing prepare

* Remove use of frontendInitializationData

* Catch and log errors
2020-06-21 16:14:05 -04:00
toasted-nutbread
e23504613f
Use DOMTextScanner (#536)
* Use DOMTextScanner instead of TextSourceRange.seek*

* Move getNodesInRange to dom.js

* Move anyNodeMatchesSelector to dom.js

* Remove unused functions

* Update tests

* Add layoutAwareScan option

* Use layoutAwareScan for source and sentence scanning

* Remove unused IGNORE_TEXT_PATTERN
2020-06-21 16:07:51 -04:00
toasted-nutbread
3db7b3a925
Add option to use the unsecure frame URL (#618) 2020-06-21 15:52:43 -04:00
toasted-nutbread
b4a617cac3
Ignore getZoom errors (#604) 2020-06-14 15:14:47 -04:00
toasted-nutbread
b612bd8b8d
PopupProxy refactor (#609)
* Remove setDisabled member; replace with an event

* Pass frameOffsetForwarder directly to PopupProxy

* Replace .start with .prepare

* Make onMessage private

* Make message safer and handle unexpected inputs
2020-06-14 14:06:52 -04:00
toasted-nutbread
9767b76553
Use cross frame API (#553)
* Use new CrossFrameAPI for popup proxy communication

* Remove use of old cross-frame communication classes

* Remove use of old cross-frame communication files

* Make the crossFrame object a member of the api object
2020-06-07 21:40:11 -04:00
toasted-nutbread
3c4c82dcfc
Ensure single popup factory (#554)
* Add createPopupFactory

* Ensure only a single PopupFactory is generated
2020-05-24 14:00:32 -04:00
toasted-nutbread
4d2e5b93f4
Style adjustments (#537)
* Remove newlines for term-definition-item-template

* Update how action button icons are styled

* Fix spacing

* Group text colors together

* Correct image styles

* Fix missing </span>
2020-05-24 13:37:23 -04:00
toasted-nutbread
c61a87b152
API refactor (#532)
* Convert api.js into a class instance

* Use new api.* functions

* Fix missing binds

* Group functions with progress callbacks together

* Change style

* Fix API override not working
2020-05-24 13:30:40 -04:00
toasted-nutbread
dd673f0b26
Dynamic loader load style (#521)
* Remove unnecessary load of /fg/css/client.css

* Replace dynamicLoader.loadStyles with dynamicLoader.loadStyle

* Replace Popup._injectStylesheet with dynamicLoader.loadStyle

* Remove unused global
2020-05-19 20:33:06 -04:00
toasted-nutbread
dd6c3015c4
Use both shadowRoot and openOrClosedShadowRoot (#534) 2020-05-10 14:10:02 -04:00
toasted-nutbread
c38cd70e91
Load frame content using contentDocument.location.href instead of src attribute (#529) 2020-05-10 14:08:18 -04:00
toasted-nutbread
9742d5662b
Use CSS variables for themes (#528)
* Update formatting

* Merge default tag color with category-less tags

* Use CSS variables for colors

* Add dark theme colors

* Move color variables into display.css

* Remove old stylesheets

* Update headings

* Bump minimum Firefox version to support CSS var()

* Revert popular kanji text color
2020-05-10 14:07:25 -04:00
toasted-nutbread
5752b23a8e
Text source refactor (#527)
* Update TextSourceElement API to have parity with TextSourceRange

* Make fields private

* Update equality check

* Fix "this.element" being used instead of just "element"
2020-05-10 14:06:25 -04:00
toasted-nutbread
6eafdac362
Fix setStartOffset not appending (#526) 2020-05-09 21:09:23 -04:00
toasted-nutbread
69c783f861
Frontend/popup proxy message refactoring (#520)
* Use direct message handler functions

* Remove unused targetPopupId

* Make target a member of FrontendApiSender

* Rename frameId to parentFrameId for clarity

* Remove _parentFrameId

* Rename _parentId to _parentPopupId for clarity
2020-05-09 12:27:56 -04:00
toasted-nutbread
48cf646973
Popup refactor (#518)
* Add default

* Convert function to non-static

* Remove static for private functions

* Replace .call

* Move functions with side effects into a synchronous prepare function

* Rename variables with "container" to "frame" in _initializeFrame

* Rename variables with "container" to "frame"

* Rename getContainer to getFrame

* Rename getContainerRect to getFrameRect

* Organize and simplify

* Fix incorrect change of "popup" => "this"

* Move initial _updateVisibility into prepare()
2020-05-08 19:10:06 -04:00
toasted-nutbread
3949db26d7
Text scanner refactor (#517)
* Fix return type

* Pass search function as a constructor argument

* Pass constructor as a details object

For consistency with other complex constructors and improved semantics.

* Convert _ignorePoints to a single optional function

* Organize functions

* Rename ignorePoints to ignorePoint
2020-05-08 19:05:50 -04:00
toasted-nutbread
b936c3e4b1
Popup proxy host refactor (#516)
* Rename PopupProxyHost to PopupFactory

* Update FrontendApiReceiver to support non-async handlers

* Make some functions non-async

* Make setCustomCss non-async

* Make setContentScale non-async

* Remove static

* Rename variables

* Pass frameId into PopupFactory's constructor

* Change FrontendApiReceiver source from popup-proxy-host to popup-factor

* Rename _invokeHostApi to _invoke

* Rename PopupProxy.getHostUrl to getUrl
2020-05-08 19:04:53 -04:00
toasted-nutbread
edb86d9ec3
Organize frontend functions (#513) 2020-05-07 19:38:09 -04:00
toasted-nutbread
38d6f58fac
Frontend refactor (#508)
* Use this.popup instead of this.frontend.popup

* Rename Frontend.popup to _popup

* Make Frontend functions private

* Clean up Frontend constructor
2020-05-06 19:35:36 -04:00