Skip to content

Commit

Permalink
support nested, closed #11
Browse files Browse the repository at this point in the history
  • Loading branch information
clkao committed Mar 27, 2013
1 parent 93fdd8f commit de071ef
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
18 changes: 17 additions & 1 deletion app/app/controllers.ls
Expand Up @@ -17,6 +17,7 @@ angular.module 'app.controllers' <[ui.state]>
update: -> console?log \notyetupdated
iframes: HackFolder.iframes
docs: HackFolder.docs
tree: HackFolder.tree
activate: HackFolder.activate
HackFolder: HackFolder
reload: (hackId) -> HackFolder.getIndex hackId, true ->
Expand Down Expand Up @@ -52,11 +53,13 @@ angular.module 'app.controllers' <[ui.state]>
.factory HackFolder: <[$http]> ++ ($http) ->
iframes = {}
docs = []
tree = []
var hackId
do
iframes: iframes
collapsed: false
docs: docs
tree: tree
activate: (id, edit=false) ->
[{type}:doc] = [d for d in docs when d.id is id]
mode = if edit => \edit else \view
Expand Down Expand Up @@ -93,7 +96,8 @@ angular.module 'app.controllers' <[ui.state]>
entries = for line in csv.split /\n/ when line
[url, title, ...rest] = line.split /,/
title -= /"/g
entry = { url, title } <<< match url
[_, prefix, url] = url.match /^"?(\s*)(\S+)"?$/
entry = { url, title, indent: prefix.length } <<< match url
| // ^https?:\/\/www\.ethercalc\.(?:com|org)/(.*) //
type: \ethercalc
id: that.1
Expand All @@ -119,5 +123,17 @@ angular.module 'app.controllers' <[ui.state]>
| otherwise => console?log \unrecognized url
entry.icon ?= "img/#{ entry.type }.png"
entry
last-parent = 0
docs.splice 0, -1, ...(entries.filter -> it?)
nested = for entry, i in docs when i > 0
if entry.indent
entries[last-parent]
..children ?= []
..children.push entry
..collapsed = true
null
else
last-parent = i
entry
tree.splice 0, -1, ...(nested.filter -> it?)
cb docs
18 changes: 13 additions & 5 deletions app/partials/app/hack.static.jade
Expand Up @@ -5,11 +5,19 @@
&nbsp;
a.indexlink.expanded-content(ng-href="http://ethercalc.org/{{hackId}}",target="_blank",ngx-final) {{hackId}}
small: a.reload(ng-click="reload(hackId)",ngx-noclick) &#x21BA;
ul(ui-sortable='sortableOptions', ng-model='docs')
li(ng-repeat='doc in docs', ng-title="{{doc.title || doc.id}}",ngx-noclick,ng-class='{active: doc.id == docId}')
a.link(ng-href='/#/{{hackId}}/{{doc.id}}',ngx-final)
img(ng-src="{{doc.icon}}",title="{{doc.title || doc.id}}")
span.expanded-content {{doc.title || doc.id}}
ul(ui-sortable='sortableOptions', ng-model='tree')
li(ng-repeat='doc in tree', ng-title="{{doc.title || doc.id}}",ngx-noclick,ng-class='{active: doc.id == docId}')
.entry
a.link(ng-href='/#/{{hackId}}/{{doc.id}}',ngx-final)
img(ng-src="{{doc.icon}}",title="{{doc.title || doc.id}}")
span.expanded-content {{doc.title || doc.id}}
span.collapser(ui-if='doc.children',ng-class='{collapsed: doc.collapsed}',ng-click='doc.collapsed=!doc.collapsed') {{ {"true": "&#x25B8;", "false": "&#x25BE;"}[!!doc.collapsed] }}
ul(ui-if='doc.children && !doc.collapsed',ui-sortable='sortableOptions', ng-model='doc.children')
li(ng-repeat='doc in doc.children', ng-title="{{doc.title || doc.id}}",ngx-noclick,ng-class='{active: doc.id == docId}')
.entry
a.link(ng-href='/#/{{hackId}}/{{doc.id}}',ngx-final)
img(ng-src="{{doc.icon}}",title="{{doc.title || doc.id}}")
span.expanded-content {{doc.title || doc.id}}
.pad-container(ng-style='{height: height-49}')
article.pad(ng-repeat='(key, iframe) in iframes',ng-show='docId == key')
span.docmode(ng-show="hasViewMode(iframe.doc.type) && iframe.mode != 'edit'",ng-click="activate(iframe.doc.id, true)") edit
Expand Down
12 changes: 10 additions & 2 deletions app/styles/hack.sass
Expand Up @@ -81,7 +81,7 @@ a
li
margin-top: 1px
padding: 2px 5px 2px 11px
height: 1.2em
min-height: 1.2em
font-size: 16px
&:hover
background: rgba(255,255,255,0.7)
Expand All @@ -93,6 +93,7 @@ a
margin-left: 10px
margin-right: 20px
li
position: relative
list-style: none
cursor: pointer
margin: 0
Expand All @@ -101,8 +102,15 @@ a
padding: 5px 0 15px -3px
margin-top: 5px
font-weight: 700
&.active
&.active > .entry
background: orange
margin-left: -30px
margin-right: -20px
padding-left: 30px
span.collapser
position: absolute
right: 5px
top: 0px


.pad-container
Expand Down

0 comments on commit de071ef

Please sign in to comment.