Всплывающие уведомления
Всплывающие уведомления — это JavaScript-система, разработанная как часть MediaWiki для показа уведомлений на веб-странице.
Возможности
- Несколько уведомлений: Можно одновременно отображать несколько уведомлений. Каждое из них закрывается независимо друг от друга.
- Автоматическое закрытие: Уведомление может быть настроено на автоматическое закрытие по истечении короткого промежутка времени. This is enabled by default, but individual features using this system may choose to disable it for specific notifications where needed.
- Присвоение тегов: При желании уведомлению можно присвоить имя (или «тег»). Когда новое уведомление создаётся с тем же именем, что и у старого, которое ещё активно, старое уведомление заменяется новым. This enables an improved user experience where one would otherwise cause old, incomplete, or duplicate notifications to be visible (example use cases)
API
The entry point for the bubble notifications is the mw.notify()
method.
Некоторые примеры:
mw.notify( 'This is a notification.' ); // Send a plaintext notification
mw.notify( mw.message( 'some-message' ) ); // Use an i18n message to send a notification
mw.notify( $( '<span>This is an <u>HTML</u> notification.</span>' ) ); // Send an HTML notification with a jQuery instance (a DOM node also works)
mw.notify( 'Test', { title: 'Title!' } ); // Give the notification a title
mw.notify( 'Test', { autoHide: false } ); // Don't automatically hide the notification
mw.notify( 'Test', { tag: 'foobar' } ); // Send a notification tagged with a tag
mw.notify( 'Test 2', { tag: 'foobar' } ); // This one will replace the previous 'foobar' notification.
The format is: mw.notify(message, options)
, available options are:
autoHide
– A boolean indicating whether the notification should automatically be hidden after shown or if it should persist.autoHideSeconds
– Количество секунд времени ожидания для автоматического скрытия уведомлений.tag
– Необязательная строка. Когда уведомление имеет тег, только одно уведомление с этим тегом может быть отображено. Попытка отобразить новое уведомление с тем же тегом, что и у уже отображаемого, приведёт к тому, что другое (старое) уведомление будет закрыто, а новое уведомление появится в том же месте, где было предыдущее.title
– Необязательный заголовок уведомления. Will be displayed above the content, usually in bold.type
– An optional string for the type of the message used for styling: Examples: 'info', 'warn', 'error', 'success'.visibleTimeout
– A boolean indicating if the autoHide timeout should be based on time the page was visible to user or if it should use wall clock time.
См. также
Code stewardship
- Maintained by Unknown or Unassigned[Maintainers page].
- Issue tracker: Phabricator MediaWiki-Interface (Report an issue)