Options
All
  • Public
  • Public/Protected
  • All
Menu

Module src/common/helpers

Index

Type aliases

ModdedChildrenWithItemName

ModdedChildrenWithItemName: ModdedChildren & { itemName?: string }

This type represents an element of a list returned by ItemList.toArray(), coupled with some static properties used on various components.

Functions

avatar

fireApplicationError

  • fireApplicationError(userTitle: string, consoleTitle: string, error: any): void

fireDebugWarning

  • fireDebugWarning(...args: [message?: any, ...optionalParams: any[]]): void
  • Calls console.warn with the provided arguments, but only if the forum is in debug mode.

    This function is intended to provide warnings to extension developers about issues with their extensions that may not be easily noticed when testing, such as accessibility issues.

    These warnings should be hidden on production forums to ensure webmasters are not inundated with do-gooders telling them they have an issue when it isn't something they can fix.

    Parameters

    • Rest ...args: [message?: any, ...optionalParams: any[]]

    Returns void

fireDeprecationWarning

  • fireDeprecationWarning(message: string, githubId: string, removedFrom?: string, repo?: string): void
  • Fire a Flarum deprecation warning which is shown in the JS console.

    These warnings are only shown when the forum is in debug mode, and the function exists to reduce bundle size caused by multiple warnings across our JavaScript.

    see

    fireDebugWarning

    Parameters

    • message: string

      The message to display. (Short, but sweet, please!)

    • githubId: string

      The PR or Issue ID with more info in relation to this change.

    • removedFrom: string = '2.0'
    • repo: string = 'flarum/core'

    Returns void

fullTime

  • fullTime(time: Date): Mithril.Vnode

highlight

  • highlight(string: string, phrase?: string | RegExp, length?: number): Mithril.Vnode<any, any> | string
  • The highlight helper searches for a word phrase in a string, and wraps matches with the tag.

    Parameters

    • string: string

      The string to highlight.

    • Optional phrase: string | RegExp

      The word or words to highlight.

    • Optional length: number

    Returns Mithril.Vnode<any, any> | string

humanTime

  • humanTime(time: Date): Mithril.Vnode
  • The humanTime helper displays a time in a human-friendly time-ago format (e.g. '12 days ago'), wrapped in a

    Parameters

    Returns Mithril.Vnode

icon

  • icon(fontClass: string, attrs?: Attributes): Mithril.Vnode
  • The icon helper displays an icon.

    Parameters

    • fontClass: string

      The full icon class, prefix and the icon’s name.

    • attrs: Attributes = {}

      Any other attributes to apply.

    Returns Mithril.Vnode

listItems

  • The listItems helper wraps an array of components in the provided tag, stripping out any unnecessary Separator components.

    By default, this tag is an <li> tag, but this is customisable through the second function parameter, customTag.

    Type parameters

    Parameters

    Returns Mithril.Vnode[]

punctuateSeries

  • punctuateSeries(items: Children[]): Children
  • The punctuateSeries helper formats a list of strings (e.g. names) to read fluently in the application's locale.

    punctuateSeries(['Toby', 'Franz', 'Dominion']) // Toby, Franz, and Dominion
    

    Parameters

    • items: Children[]

    Returns Children

    ')}

userOnline

  • userOnline(user: User): Mithril.Vnode<{}, {}> | null

username

  • username(user: undefined | null | false | User): Mithril.Vnode
  • The username helper displays a user's username in a tag. If the user doesn't exist, the username will be displayed as [deleted].

    Parameters

    • user: undefined | null | false | User

    Returns Mithril.Vnode

Generated using TypeDoc version 0.22.10