OOUI/ウィンドウ

This page is a translated version of the page OOUI/Windows and the translation is 46% complete.

Windowは子フレームに要素を格納するコンテナです。 格ウィンドウがその開閉に使われるWindowManagerによって管理され、表示をコントロールします。 ウィンドウのサイズは、記号的な名前(「small」、「medium」、「large」、「full」)を使用してウィンドウマネージャがこれを解釈することで特定されます。 If the requested size is not recognized, the window manager will choose a sensible fallback.

OOUIウィンドウにはダイアログプロセスダイアログメッセージダイアログが含まれます。 単純な使用例として、いくつか便利な関数があります。 OOUI/ウィンドウ/単純なメッセージをご覧ください。

ウィンドウは表示デバイスのサイズに対応し動的に表示を調節します。 そのためダイアログの大きさは正確な指定ではなく近似値と考えるべきでしょう。

ウィンドウの周期

それぞれのマネージされたウィンドウは排他的です。 ウィンドウが開かれている状態で新しいウィンドウを開くことはできません。 ウィンドウ自体は永続的で、閉じる時にデータが破棄される訳ではなく、関連付けられたデータを再び入れて再利用ができます。

ウィンドウの周期はWindowInstanceに代表されます。 This object has four properties, containing promises that represent the primary stages of the cycle: 'opening', 'opened', 'closing', and 'closed'.

  • The opening promise is resolved after the window has started opening (this may be delayed if another window is still closing), with the 'data' value passed to the openWindow() call.
  • The opened promise is resolved after the window is opened, with the 'data' value passed to the openWindow() call.
  • The closing promise is resolved after the window has started closing, with the 'data' value passed to the closeWindow() call.
  • The closed promise is resolved after the window is closed, with the 'data' value passed to the closeWindow() call.

See Process dialogs, for examples that show this promise chain in practice.

For backwards compatibility, WindowInstance objects returned by openWindow() and closeWindow() are extended with Promise-like properties. This will be removed in the future.

Before the window is opened for the first time (and only before the first time), the initialize() method is called. The initialize() method is used to populate the window with persistent content, providing a sort of caching mechanism. A window that contains a list of 250 languages can be populated with that list during initialization, for example, and if the window is opened again, the list will not have to be reloaded.

 

工程

Opening

The opening stage begins when the window manager’s openWindow() or the window’s open() method is used to open a window. WindowInstance's 'opening' promise is resolved. For backwards compatibility, the window manager emits an 'opening' event with a promise that will be resolved with an 'opened' promise when the window is setup, ready, and opened.

The window manager then calls the getSetupDelay() method, which gets the number of milliseconds to wait before calling the window’s getSetupProcess() method and executing the result. The getSetupProcess() method assembles a process for setting up the window with data passed to the opening function. Each time a window is reused, it can be set up with new data. When setup is complete, a 'setup' progress notification is emitted from the opening promise.

The window manager then calls the getReadyDelay() method, which gets the number of milliseconds to wait between finishing setup and calling the window’s getReadyProcess() method and executing the result. A 'ready' progress notification is then emitted from the backwards-compatibility opening promise.

Opened

When the window is set up and ready, WindowInstance's 'opened' promise is resolved, and the backwards-compatibility 'opening' promise is resolved with a backwards-compatibility 'opened' promise. The window is now opened.  At this point it is okay to set the focus inside the window.

Closing

The closing stage begins when the window manager’s closeWindow() or the window’s close() method is used to close a window. WindowInstance's 'closing' promise is resolved. For backwards compatibility, the window manager emits a 'closing' event and the backwards-compatibility 'opened' promise is resolved with a backwards-compatibility 'closing' promise.

The window manager calls the getHoldDelay() method, which gets the number of milliseconds to wait before calling the window’s getHoldProcess() method and executing the result. There is rarely a need to override this method, though one might if a window requires a long time to teardown and you wish to disable the window controls in the meantime. When the hold process is complete, a 'hold' progress notification is emitted from the backwards-compatibility closing promise.

The window manager then calls the getTeardownDelay() method, which gets the number of milliseconds to wait between finishing the hold process and calling the window’s getTeardownProcess() method and executing the result. A 'teardown' progress notification is emitted from the backwards-compatibility closing promise.

Closed

閉窓プロセスが完了すると、WindowInstanceのclosedプロミスが解決され、後方互換性の閉窓プロミスも解決されます。 close()メソッドに渡されたデータはWindowsInstanceのclosedプロミスと後方互換の閉窓プロミスを解決する際の引数に渡されます。 その後ウィンドウは閉じられます。

注記

各プロセス(setup、ready、hold、teardown)は連続で実行され、非同期処理を完了できます。 常にウィンドウのプロセスは非同期で処理されるものとします。 See Processes and errors for more details about processes.

Closing a window without data will safely close it without making any changes, essentially canceling the process.

The WindowManager can also be configured to prevent interaction outside the window (by setting the modal option to 'true'). For a full list of supported methods and configuration options, please see the code-level documentation.

WindowInstanceの使用例

instance = windowManager.openWindow( ... );
instance.opening.then( function () {
    // このコードはウィンドウが開き始めてから実行されます。
} );
instance.opened.then( function () {
    // このコードはウィンドウが開き終わってから実行されます。
} );
instance.closing.then( function () {
    // このコードはウィンドウが閉じ始めてから実行されます。
} );
instance.closed.then( function ( data ) {
    // このコードはウィンドウが閉じ終わってから実行されます。
} );

もしウィンドウを開いて閉じられるまで待ちたいだけなら、こちらを使用してください:

windowManager.openWindow( ... ).closed.then( function ( data ) {
    // このコードはウィンドウが閉じ終わってから実行されます。
} );