You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
devdocs/assets/javascripts/app/settings.coffee

72 lines
1.3 KiB

11 years ago
class app.Settings
10 years ago
DOCS_KEY = 'docs'
DARK_KEY = 'dark'
LAYOUT_KEY = 'layout'
SIZE_KEY = 'size'
TIPS_KEY = 'tips'
10 years ago
@defaults:
10 years ago
count: 0
hideDisabled: false
hideIntro: false
news: 0
manualUpdate: false
schema: 1
10 years ago
constructor: ->
@store = new CookieStore
10 years ago
set: (key, value) ->
@store.set(key, value)
return
10 years ago
get: (key) ->
@store.get(key) ? @constructor.defaults[key]
10 years ago
11 years ago
hasDocs: ->
try !!@store.get(DOCS_KEY)
11 years ago
getDocs: ->
@store.get(DOCS_KEY)?.split('/') or app.config.default_docs
11 years ago
setDocs: (docs) ->
@store.set DOCS_KEY, docs.join('/')
return
getTips: ->
@store.get(TIPS_KEY)?.split('/') or []
setTips: (tips) ->
@store.set TIPS_KEY, tips.join('/')
return
setLayout: (name, enable) ->
layout = (@store.get(LAYOUT_KEY) || '').split(' ')
$.arrayDelete(layout, '')
if enable
layout.push(name) if layout.indexOf(name) is -1
else
$.arrayDelete(layout, name)
if layout.length > 0
@store.set LAYOUT_KEY, layout.join(' ')
else
@store.del LAYOUT_KEY
return
hasLayout: (name) ->
layout = (@store.get(LAYOUT_KEY) || '').split(' ')
layout.indexOf(name) isnt -1
setSize: (value) ->
@store.set SIZE_KEY, value
return
dump: ->
@store.dump()
11 years ago
reset: ->
@store.reset()
11 years ago
return