Skip to content

Commit

Permalink
reactifying the workflowy demo
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredly committed Apr 16, 2014
1 parent ae401f7 commit f3cbdf2
Showing 1 changed file with 71 additions and 26 deletions.
97 changes: 71 additions & 26 deletions demo/workflowy/setup.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,77 @@


var bread = document.getElementById('breadcrumb')
var base = document.getElementById('example')
, data = make_listed(flare_data, undefined, true)
, ctrl = new WFController(data.id, data.tree, {onBullet: onBullet})
base.appendChild(ctrl.node)


function onBullet(lineage) {
bread.innerHTML = ''
lineage.slice(0, -1).forEach(function (item, i) {
var d = document.createElement('div')
d.classList.add('listless__bread')
bread.appendChild(d)
d.innerHTML = marked(item.name)
/*
if (i === lineage.length - 1) {
d.classList.add('listless__bread--last')
} else {
*/
d.addEventListener('mousedown', function (e) {
if (e.button !== 0) return
ctrl.actions.clickBullet(item.id)
var d = React.DOM

var MainApp = React.createClass({
getInitialState: function () {
return {
lineage: [],
}
},
changeBread: function (id) {
this.refs.wf.wf.actions.clickBullet(id)
},
updateBread: function (lineage) {
this.setState({lineage: lineage})
},
render: function () {
return d.div({
className: 'workflowme'
}, History({items: this.state.lineage, onClick: this.changeBread}),
Workflowy({
ref: 'wf',
id: this.props.id,
tree: this.props.tree,
onBreadCrumb: this.updateBread
})
/*
)
}
})

var Workflowy = React.createClass({
componentDidMount: function () {
this.wf = new WFController(this.props.id, this.props.tree, {onBullet: this.props.onBreadCrumb})
this.getDOMNode().appendChild(this.wf.node)
},
render: function () {
return d.div()
}
})

var History = React.createClass({
getDefaultProps: function () {
return {
items: [],
onClick: function () {}
}
*/
})
}
},
mouseDown: function (id, e) {
if (e.button !== 0) return
this.props.onClick(id)
},
render: function () {
var that = this
return d.ul(
{className: 'breadcrumb'},
this.props.items.map(function (item, i) {
return d.li({
key: item.id,
className: 'listless__bread',
onMouseDown: that.mouseDown.bind(null, item.id),
dangerouslySetInnerHTML: {
__html: marked(item.name)
}
})
})
)
}
})

var base = document.getElementById('example')
, data = make_listed(flare_data, undefined, true)

React.renderComponent(MainApp({
id: data.id,
tree: data.tree
}), base)

0 comments on commit f3cbdf2

Please sign in to comment.