lib/multi-wrap-guide.js
// Private: Updates package menu and context menus dynamically.
Updates package menu and context menus dynamically.
Updates package menu and context menus dynamically .
updateMenus () {
    this.updateContextMenu()
    const grab = function (obj, attr, val) {
      for (const item of obj) {
        if (item[attr] === val) {
          return item
        }
      }
    }
    const packages = grab(atom.menu.template, 'label', 'Packages')
    if (packages == null) return
    const ourMenu = grab(packages.submenu, 'label', 'Multi Wrap Guide')
    if (ourMenu == null) return
    const locker = grab(ourMenu.submenu, 'command', 'multi-wrap-guide:toggle-lock')
    if (locker != null) {
      locker.label = this.locked ? this.labelUnlockGuides() : this.labelLockGuides()
    }
    const toggler = grab(ourMenu.submenu, 'command', 'multi-wrap-guide:toggle')
    if (toggler != null) {
      toggler.label = this.enabled ? this.labelDisableGuides() : this.labelEnableGuides()
    }
    atom.menu.update()
  }
updateMenus ( ) { this . updateContextMenu ( ) const grab = function ( obj , attr , val ) { for ( const item of obj ) { if ( item [ attr ] === val ) { return item } } } const packages = grab ( atom . menu . template , 'label' , 'Packages' ) if ( packages == null ) return const ourMenu = grab ( packages . submenu , 'label' , 'Multi Wrap Guide' ) if ( ourMenu == null ) return const locker = grab ( ourMenu . submenu , 'command' , 'multi-wrap-guide:toggle-lock' ) if ( locker != null ) { locker . label = this . locked ? this . labelUnlockGuides ( ) : this . labelLockGuides ( ) } const toggler = grab ( ourMenu . submenu , 'command' , 'multi-wrap-guide:toggle' ) if ( toggler != null ) { toggler . label = this . enabled ? this . labelDisableGuides ( ) : this . labelEnableGuides ( ) } atom . menu . update ( ) }
Private: Updates package menu and context menus dynamically.
Private : Updates package menu and context menus dynamically .