泡泡通知

This page is a translated version of the page Bubble notifications and the translation is 67% complete.

泡泡通知是作为MediaWiki的一部分开发的JavaScript系统,用于在网页上显示通知。

一个泡泡通知的例子

功能

  • 多项通知: 它可以同时显示多项通知。 每一个通知都可以各自关闭。
  • 自动关闭: 每一个通知显示一段时间之后就可以自行隐藏不见。 它是默认启用的,但是在需要时使用这个系统的独立特性可以选择关闭特定的通知。
  • 标签: 一个通知可以被给予一个名称(或标签) 当一个新的通知以相同名称创建时,旧的那个将会被新的通知取代。 This enables an improved user experience where one would otherwise cause old, incomplete, or duplicate notifications to be visible (example use cases)

API

泡泡通知的加入点是mw.notify()方法。 一些例子:

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.

格式為:mw.notify(message, options),可用參數有:

  • autoHideA boolean indicating whether the notification should automatically be hidden after shown or if it should persist.
  • autoHideSecondsNumber of seconds for timeout of auto-hide notifications.
  • tagAn optional string. When a notification is tagged only one message with that tag will be displayed. Trying to display a new notification with the same tag as one already being displayed will cause the other notification to be closed and this new notification to open up inside the same place as the previous notification.
  • titleAn optional title for the notification. Will be displayed above the content, usually in bold.
  • typeAn optional string for the type of the message used for styling: Examples: 'info', 'warn', 'error', 'success'.
  • visibleTimeoutA 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.


参见

代碼維護