Unified · Split
| @@ -77,11 +77,7 @@ · 76 unmodified lines | |||
| 77 | return | 77 | return |
| 78 | 78 | ||
| 79 | start: -> | 79 | start: -> |
| 80 | for doc in @docs.all() | 80 | @initDoc(doc) for doc in @docs.all() |
| 81 | @entries.add doc.toEntry() | ||
| 82 | @entries.add type.toEntry() for type in doc.types.all() | ||
| 83 | @entries.add doc.entries.all() | ||
| 84 | |||
| 85 | @db = new app.DB() | 81 | @db = new app.DB() |
| 86 | @trigger 'ready' | 82 | @trigger 'ready' |
| 87 | @router.start() | 83 | @router.start() |
| @@ -90,6 +86,25 @@ · 2 unmodified lines | |||
| 90 | @removeEvent 'ready bootError' | 86 | @removeEvent 'ready bootError' |
| 91 | return | 87 | return |
| 92 | 88 | ||
| 89 | initDoc: (doc) -> | ||
| 90 | @entries.add doc.toEntry() | ||
| 91 | @entries.add type.toEntry() for type in doc.types.all() | ||
| 92 | @entries.add doc.entries.all() | ||
| 93 | return | ||
| 94 | |||
| 95 | enableDoc: (doc, _onSuccess, onError) -> | ||
| 96 | onSuccess = => | ||
| 97 | @disabledDocs.remove(doc) | ||
| 98 | @docs.add(doc) | ||
| 99 | @docs.sort() | ||
| 100 | @initDoc(doc) | ||
| 101 | @settings.setDocs(doc.slug for doc in @docs.all()) | ||
| 102 | _onSuccess() | ||
| 103 | return | ||
| 104 | |||
| 105 | doc.load onSuccess, onError, writeCache: true | ||
| 106 | return | ||
| 107 | |||
| 93 | welcomeBack: -> | 108 | welcomeBack: -> |
| 94 | visitCount = @settings.get('count') | 109 | visitCount = @settings.get('count') |
| 95 | @settings.set 'count', ++visitCount | 110 | @settings.set 'count', ++visitCount |
| @@ -21,6 +21,10 @@ class app.Collection · 20 unmodified lines | |||
| 21 | @models.push new (@model())(object) | 21 | @models.push new (@model())(object) |
| 22 | return | 22 | return |
| 23 | 23 | ||
| 24 | remove: (model) -> | ||
| 25 | @models.splice @models.indexOf(model), 1 | ||
| 26 | return | ||
| 27 | |||
| 24 | size: -> | 28 | size: -> |
| 25 | @models.length | 29 | @models.length |
| 26 | 30 | ||
| @@ -4,7 +4,10 @@ templates.sidebarDoc = (doc, options = {}) -> · 3 unmodified lines | |||
| 4 | link = """<a href="#{doc.fullPath()}" class="_list-item _icon-#{doc.slug} """ | 4 | link = """<a href="#{doc.fullPath()}" class="_list-item _icon-#{doc.slug} """ |
| 5 | link += if options.disabled then '_list-disabled' else '_list-dir' | 5 | link += if options.disabled then '_list-disabled' else '_list-dir' |
| 6 | link += """" data-slug="#{doc.slug}">""" | 6 | link += """" data-slug="#{doc.slug}">""" |
| 7 | link += """<span class="_list-arrow"></span>""" unless options.disabled | 7 | if options.disabled |
| 8 | link += """<span class="_list-enable" data-enable="#{doc.slug}">Enable</span>""" | ||
| 9 | else | ||
| 10 | link += """<span class="_list-arrow"></span>""" | ||
| 8 | link += """<span class="_list-count">#{doc.version}</span>""" if doc.version | 11 | link += """<span class="_list-count">#{doc.version}</span>""" if doc.version |
| 9 | link + "#{doc.name}</a>" | 12 | link + "#{doc.name}</a>" |
| 10 | 13 | ||
| @@ -123,17 +123,24 @@ class app.views.DocList extends app.View · 122 unmodified lines | |||
| 123 | $.scrollTo @find("a[href='#{model.fullPath()}']"), null, 'top', margin: 0 | 123 | $.scrollTo @find("a[href='#{model.fullPath()}']"), null, 'top', margin: 0 |
| 124 | return | 124 | return |
| 125 | 125 | ||
| 126 | onClick: (event) => | 126 | toggleDisabled: -> |
| 127 | return unless @disabledTitle and $.hasChild @disabledTitle, event.target | ||
| 128 | $.stopEvent(event) | ||
| 129 | |||
| 130 | if @disabledTitle.classList.contains('open-title') | 127 | if @disabledTitle.classList.contains('open-title') |
| 131 | @removeDisabledList() | 128 | @removeDisabledList() |
| 132 | app.settings.set 'hideDisabled', true | 129 | app.settings.set 'hideDisabled', true |
| 133 | else | 130 | else |
| 134 | @appendDisabledList() | 131 | @appendDisabledList() |
| 135 | app.settings.set 'hideDisabled', false | 132 | app.settings.set 'hideDisabled', false |
| 133 | return | ||
| 136 | 134 | ||
| 135 | onClick: (event) => | ||
| 136 | if @disabledTitle and $.hasChild(@disabledTitle, event.target) | ||
| 137 | $.stopEvent(event) | ||
| 138 | @toggleDisabled() | ||
| 139 | else if slug = event.target.getAttribute('data-enable') | ||
| 140 | $.stopEvent(event) | ||
| 141 | doc = app.disabledDocs.findBy('slug', slug) | ||
| 142 | app.enableDoc(doc, @render, @render) | ||
| 143 | return | ||
| 137 | 144 | ||
| 138 | afterRoute: (route, context) => | 145 | afterRoute: (route, context) => |
| 139 | if context.init | 146 | if context.init |
| @@ -109,11 +109,9 @@ · 108 unmodified lines | |||
| 109 | } | 109 | } |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | ._list-count { | 112 | ._list-count, ._list-enable { |
| 113 | float: right; | 113 | float: right; |
| 114 | font-size: .75rem; | 114 | font-size: .75rem; |
| 115 | color: $textColorLighter; | ||
| 116 | pointer-events: none; | ||
| 117 | 115 | ||
| 118 | .focus > &, | 116 | .focus > &, |
| 119 | .active > & { | 117 | .active > & { |
| @@ -121,6 +119,22 @@ · 1 unmodified line | |||
| 121 | } | 119 | } |
| 122 | } | 120 | } |
| 123 | 121 | ||
| 122 | ._list-count { | ||
| 123 | color: $textColorLighter; | ||
| 124 | pointer-events: none; | ||
| 125 | |||
| 126 | ._list-disabled:hover > & { display: none; } | ||
| 127 | } | ||
| 128 | |||
| 129 | ._list-enable { | ||
| 130 | display: none; | ||
| 131 | color: $linkColor; | ||
| 132 | cursor: pointer; | ||
| 133 | |||
| 134 | &:hover { text-decoration: underline; } | ||
| 135 | ._list-disabled:hover > & { display: block; } | ||
| 136 | } | ||
| 137 | |||
| 124 | // | 138 | // |
| 125 | // List hierarchy | 139 | // List hierarchy |
| 126 | // | 140 | // |