Sha256: 6ce2369d95fa90f5108f79fd5d1b113b0909a806e31d2b1063f580e4465e1962

Contents?: true

Size: 656 Bytes

Versions: 1

Compression:

Stored size: 656 Bytes

Contents

angular.module("SWAT").factory "GlobalControl", ($cookies)->
  class GlobalControl

    constructor: ->
      @COOKIE_KEY = 'MainMenuStatus'
      @COOKIE_OPTS = { path: '/swat' }
      @OPENED = 'opened'
      @CLOSED = 'closed'
      @initStatus()
      @setReloader(->{})

    initStatus: ->
      status = $cookies.get(@COOKIE_KEY, @COOKIE_OPTS);
      @setStatus(status || @CLOSED)

    toggle: ->
      @setStatus(if @status == @CLOSED then @OPENED else @CLOSED)

    setStatus: (value)->
      $cookies.put(@COOKIE_KEY, value, @COOKIE_OPTS);
      @status = value

    setReloader: (func)->
      @reloader = func

    reload: ->
      @reloader()

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sw2at-ui-0.0.15 app/assets/javascripts/swat/app/factories/global_control.coffee