@categories = {}
- reset: ->
- FieldList::reset ...
- console.log "#this.reset!"
-
- n = 0
- cats = @categories
- @forEach (field) ->
- cat = field.get('tags', [])[0]
- unless cats[cat]?
- cats[cat] = n++
- field.set 'category', "category_#{cats[cat]}", {+silent}
-
- setTimeout do
- ~> _ _.pluck(@models, 'view') .invoke 'render'
- 10
- this
+ # reset: ->
+ # FieldList::reset ...
+ # console.log "#this.reset!"
+ #
+ # n = 0
+ # cats = @categories
+ # @forEach (field) ->
+ # cat = field.get('tags', [])[0]
+ # unless cats[cat]?
+ # cats[cat] = n++
+ # field.set 'category', "category_#{cats[cat]}", {+silent}
+ #
+ # setTimeout do
+ # ~> _ _.pluck(@models, 'view') .invoke 'render'
+ # 10
+ # this
# }}}
onClick: (evt) ->
target = $ evt.target
- console.log "#this.onClick()", target
+ # console.log "#this.onClick()", target
@toggleCollapsed() if @$el.hasClass('collapsed') and not target.hasClass('close')
toggleCollapsed: ->
starting = @$el.hasClass 'collapsed' #@isCollapsed
@$el.toggleClass 'collapsed'
@isCollapsed = @$el.hasClass 'collapsed'
- console.log "#this.toggleCollapsed!", starting, '->', @isCollapsed
+ # console.log "#this.toggleCollapsed!", starting, '->', @isCollapsed
@trigger 'change:collapse', this
this
getParser: (type) ->
- type or= @get 'type'
- t = _ type.toLowerCase()
-
- parser = op.toStr
- if t.startsWith 'integer'
- parser = op.toInt
- if t.startsWith 'float'
- parser = op.toFloat
- if t.startsWith 'boolean'
- parser = op.toBool
- if t.startsWith 'object' or t.startsWith 'array'
- parser = op.toObject
- if t.startsWith 'function'
- parser = (fn) -> eval "(#fn)"
-
- # TODO: handle 'or' by returning an array of parsers
- parser
+ # XXX: handle 'or' by returning an array of parsers?
+ type = _ (type or @get 'type').toLowerCase()
+ for t of <[ Integer Float Boolean Object Array Function ]>
+ if type.startsWith t.toLowerCase()
+ console.log "parse#t ->", @["parse#t"] unless @["parse#t"]
+ return @["parse#t"]
+ @parseString
+
+ parseString: (v) ->
+ if v? then op.toStr v else null
+
+ parseInteger: (v) ->
+ r = op.toInt v
+ unless isNaN r then r else null
+
+ parseFloat: (v) ->
+ r = op.toFloat v
+ unless isNaN r then r else null
+
+ parseBoolean: (v) ->
+ op.toBool v
+
+ parseArray: (v) ->
+ if v then op.toObject v else null
+
+ parseObject: (v) ->
+ if v then op.toObject v else null
+
+ parseFunction: (fn) ->
+ if fn and _.startswith String(fn), 'function'
+ try eval "(#fn)" catch err
+ else
+ null
+
-
getValue: (def) ->
@getParser() @get 'value', def
@model.on 'change', @render, this
@model.on 'destroy', @remove, this
-
toTemplateLocals: ->
- { $, _, op, @model, view:this } import @model.toJSON()
+ json = {value:v} = @model.toJSON()
+ json.value = JSON.stringify v if _.isArray(v) or _.isObject(v)
+ { $, _, op, @model, view:this } import json
$template: (locals={}) ->
$ @template @toTemplateLocals() import locals
val = @$el.find('.value').val()
current = @model.get 'value'
return if val is current
- # console.log "#this.onUIChange( #current -> #val )"
+ console.log "#this.onUIChange( #current -> #val )"
@model.setValue val, {+silent}
render: ->
.default(class=type_cls, title="Default: #{def} (#{type})") #{def}
.desc
- != (jade.filters || {}).markdown(desc)
+ != jade.filters.markdown(desc)
//- .tags(data-toggle="collapse", data-target="##{option_id} .tags ul"): ul.collapse
.tags
for tag in tags
- span.tag(class=_.domize('tag', tag)+' '+_.domize('category', model.getTagIndex(tag))) #{tag}
+ - var tag_cls = _.domize('tag',tag) + ' ' + _.domize('category',model.getTagIndex(tag))
+ span.tag(class=tag_cls) #{tag}
|
.examples(data-toggle="collapse", data-target="##{option_id} .examples ul"): ul.collapse
for example in examples
toInt : (v) -> parseInt v
toFloat : (v) -> parseFloat v
toStr : (v) -> String v
- toObject : (v) -> JSON.parse v
+ toObject : (v) -> if typeof v is 'string' then JSON.parse v else v
# comparison
cmp : (x,y) -> if x < y then -1 else (if x > y then 1 else 0)
+/** Color Helpers **/
+
+invert($v)
+ hsla( 180deg * hue($v), 100% - saturation($v), 100% - lightness($v), alpha($v) )
+
+contrast_direction($v)
+ // ((lightness($v) * (100% - saturation($v))) < 50%) ? 1 : -1
+ (lightness($v) < 50%) ? 1 : -1
+
+
/** Project Colors **/
$dark = #333
$hilites = ($hilite_dkblue $hilite_sky $hilite_ltblue $hilite_steelblue $hilite_cyan $hilite_hurricane $hilite_tourquoise $hilite_green $hilite_lime $hilite_yellow $hilite_squash $hilite_orange $hilite_watermelon $hilite_red $hilite_pink $hilite_magenta $hilite_purple $hilite_periwinkle $hilite_lavender)
+$hilite_favs = ($hilite_dkblue $hilite_ltblue $hilite_cyan $hilite_lime $hilite_yellow $hilite_squash $hilite_red $hilite_magenta $hilite_purple)
+// colors: ["#FF0097", "#EF8158", "#83BB32", "#182B53", "#4596FF", "#553DC9", "#AD3238", "#00FFBC", "#F1D950"]
/* background colors */
$border_color = #ccc
-/** Color Helpers **/
-
-invert($v)
- hsla( 180deg * hue($v), 100% - saturation($v), 100% - lightness($v), alpha($v) )
-
-
-
-@import 'nib'
@import 'colors'
+@import 'nib'
section.graph
.graph-label
// border 1px solid #999
.shortname
- z-index -1
+ // z-index -1
// absolute bottom 0.5em right 0.5em
font-weight bold
color white
.name
+ display none
font-weight bold
- line-height 1.5
- font-size 100%
+ // line-height 1.5
+ // font-size 100%
.value
width auto
font-family menlo, monospace
.tags, .examples
cursor pointer
.tags
+ font-size 85%
&::before
content "Tags: "
font-weight bold
- font-size 85%
.tag
margin 0.2em
line-height 1.5
padding 0.2em
- font-size 85%
+ white-space nowrap
color white
background-color rgba(255,255,255, 0.15)
border-radius 5px
- border 1px solid white
- white-space nowrap
+ // border 1px solid white
.examples
display none
&::before
/* Category Colors {{{ */
for i in 0...length($hilites)
- $bg_color = $hilites[i]
- $fg_color = light($bg_color) ? $dark : $light
+ $bg_color = $hilites[i]
+ $tag_color = $bg_color + contrast_direction($bg_color) * 50%
+ $fg_color = (lightness($bg_color) > 55%) ? $dark : $light
&.category_{i}
color $fg_color
background-color $bg_color
+ // .shortname, .name, .close
+ // color $tag_color
label, h1, h2, h3, .shortname, .name, .close
color $fg_color
- .tag{i}
+ .tag.category_{i}
+ // border 1px solid $tag_color
+ // color $tag_color
+ // background-color $bg_color
color $fg_color
background-color $bg_color
- border 1px solid $fg_color
@import 'nib'
@import 'colors'
-@import 'text'
+
header, footer, #content
-@import 'colors'
-
-
$font_size = 16px
$fonts_body = helvetica, arial, sans-serif
$fonts_headers = "gotham rounded", "helvetica neue", helvetica, arial, sans-serif