Created
October 13, 2018 11:09
-
-
Save back2dos/d33cc374b55514aa4a408f4bf7f4035b to your computer and use it in GitHub Desktop.
TodoMVCoconut
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"/> | |
<title>TodoMVCoconut + Preact</title> | |
<meta name="description" content="TodoMVC implementation based on MVCoconut" /> | |
<link rel="stylesheet" type="text/css" href="styles.css"> | |
<link rel="icon" href="https://avatars1.githubusercontent.com/u/25455337?v=3&s=200" type="image/png" /> | |
</head> | |
<body> | |
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/preact.min.js"></script> | |
<script>window.React = preact; window.ReactDOM = preact;</script> | |
<script src="todomvc-react.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"/> | |
<title>TodoMVCoconut + React</title> | |
<meta name="description" content="TodoMVC implementation based on MVCoconut" /> | |
<link rel="stylesheet" type="text/css" href="styles.css"> | |
<link rel="icon" href="https://avatars1.githubusercontent.com/u/25455337?v=3&s=200" type="image/png" /> | |
</head> | |
<body> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.4.2/umd/react.production.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.4.2/umd/react-dom.production.min.js"></script> | |
<script src="todomvc-react.js"></script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ol { | |
border-top: 2px solid #e4e4e4; | |
} | |
.todo-item { | |
display: flex; | |
align-items: center; | |
position: relative; | |
list-style: none; | |
border-bottom: 1px solid #e4e4e4; | |
} | |
.todo-item .description, | |
.todo-item input[name="description"] { | |
flex-grow: 1; | |
padding: 15px; | |
} | |
.todo-item input[name="description"] { | |
font: inherit; | |
border: none; | |
} | |
.todo-item[data-editing] input[name="completed"] { | |
visibility: hidden; | |
} | |
.todo-item[data-completed] .description { | |
text-decoration: line-through; | |
color: #ccc; | |
} | |
.todo-item input[name="completed"] { | |
margin-left: 10px; | |
height: 40px; | |
-webkit-appearance: none; | |
-moz-appearance: none; | |
appearance: none; | |
} | |
.todo-item input[name="completed"]:focus { | |
outline: 0; | |
} | |
.todo-item input[name="completed"]:checked:after { | |
content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 -18 100 135"><circle cx="50" cy="50" r="50" fill="none" stroke="#bddad5" stroke-width="3"/><path fill="#5dc2af" d="M72 25L42 71 27 56l-4 4 20 20 34-52z"/></svg>'); | |
} | |
.todo-item input[name="completed"]:after { | |
content: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="40" height="40" viewBox="0 -18 100 135"><circle cx="50" cy="50" r="50" fill="none" stroke="#ededed" stroke-width="3"/></svg>'); | |
} | |
.todo-item:hover button.delete { | |
opacity: .5; | |
} | |
.todo-item:hover button.delete:hover { | |
opacity: 1; | |
} | |
.todo-item button.delete { | |
flex-basis: 60px; | |
align-self: stretch; | |
opacity: 0; | |
border: none; | |
background: none; | |
font-size: 0; | |
} | |
.todo-item button.delete:after { | |
content: "×"; | |
font-size: 30px; | |
color: #af5b5b; | |
} | |
html { | |
font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; | |
background: #f5f5f5; | |
} | |
* { | |
margin: 0; | |
padding: 0; | |
box-sizing: border-box; | |
} | |
button, | |
input[type="checkbox"] { | |
cursor: pointer; | |
} | |
button, | |
input { | |
font: inherit; | |
} | |
.todo-list { | |
font-size: 24px; | |
margin: 200px auto 50px; | |
width: 550px; | |
position: relative; | |
background: white; | |
box-shadow: 0 2px 4px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.1); | |
} | |
.todo-list h1 { | |
position: absolute; | |
top: -150px; | |
color: rgba(175, 91, 94, 0.25); | |
font-size: 100px; | |
font-weight: 100; | |
text-align: center; | |
width: 100%; | |
} | |
.todo-list button:focus { | |
outline: 0; | |
} | |
.todo-list:not([data-empty]):after { | |
content: ' '; | |
position: absolute; | |
right: 0; | |
bottom: 0; | |
left: 0; | |
height: 50px; | |
overflow: hidden; | |
pointer-events: none; | |
box-shadow: 0 1px 1px rgba(0, 0, 0, 0.2), 0 8px 0 -3px #f6f6f6, 0 9px 1px -3px rgba(0, 0, 0, 0.2), 0 16px 0 -6px #f6f6f6, 0 17px 2px -6px rgba(0, 0, 0, 0.2); | |
} | |
.todo-list footer { | |
font-size: 14px; | |
color: #777; | |
padding: 0 15px; | |
display: flex; | |
align-items: center; | |
height: 45px; | |
justify-content: space-between; | |
position: relative; | |
} | |
.todo-list footer button { | |
color: inherit; | |
font: inherit; | |
background: none; | |
border: none; | |
padding: 3px 7px; | |
} | |
.todo-list footer menu { | |
position: absolute; | |
top: 0; | |
left: 0; | |
right: 0; | |
bottom: 0; | |
display: flex; | |
pointer-events: none; | |
justify-content: center; | |
align-items: center; | |
} | |
.todo-list footer menu button { | |
pointer-events: all; | |
margin: 0 3px; | |
border: 1px solid transparent; | |
border-radius: 2px; | |
} | |
.todo-list footer menu button:hover { | |
border-color: rgba(175, 91, 91, 0.2); | |
} | |
.todo-list footer menu button[data-active] { | |
border-color: rgba(175, 91, 91, 0.5); | |
} | |
.todo-list footer > button:hover { | |
text-decoration: underline; | |
} | |
.todo-list header { | |
position: relative; | |
} | |
.todo-list header input[type="text"] { | |
width: 100%; | |
padding: 19px; | |
padding-left: 60px; | |
border: none; | |
font: inherit; | |
} | |
.todo-list header input[type="text"]:focus { | |
outline: 0; | |
} | |
.todo-list header input[type="text"]::-webkit-input-placeholder { | |
font-style: italic; | |
font-weight: 300; | |
color: #e6e6e6; | |
} | |
.todo-list header input[type="text"]::-moz-placeholder { | |
font-style: italic; | |
font-weight: 300; | |
color: #e6e6e6; | |
} | |
.todo-list header input[type="text"]::input-placeholder { | |
font-style: italic; | |
font-weight: 300; | |
color: #e6e6e6; | |
} | |
.todo-list header button { | |
position: absolute; | |
background: none; | |
border: 0; | |
font-size: 0; | |
top: 0; | |
left: 0; | |
bottom: 0; | |
width: 62px; | |
} | |
.todo-list header button.mark-all:before { | |
opacity: .5; | |
} | |
.todo-list header button:before { | |
color: #737373; | |
margin: 0 auto; | |
font-size: 22px; | |
content: '❯'; | |
transform: rotate(90deg); | |
display: block; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by Haxe 4.0.0-preview.5+7eb789f54 | |
(function () { "use strict"; | |
var $estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_; | |
function $extend(from, fields) { | |
var proto = Object.create(from); | |
for (var name in fields) proto[name] = fields[name]; | |
if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString; | |
return proto; | |
}var HxOverrides = function() { }; | |
HxOverrides.__name__ = true; | |
HxOverrides.cca = function(s,index) { | |
var x = s.charCodeAt(index); | |
if(x != x) { | |
return undefined; | |
} | |
return x; | |
}; | |
HxOverrides.substr = function(s,pos,len) { | |
if(len == null) { | |
len = s.length; | |
} else if(len < 0) { | |
if(pos == 0) { | |
len = s.length + len; | |
} else { | |
return ""; | |
} | |
} | |
return s.substr(pos,len); | |
}; | |
HxOverrides.remove = function(a,obj) { | |
var i = a.indexOf(obj); | |
if(i == -1) { | |
return false; | |
} | |
a.splice(i,1); | |
return true; | |
}; | |
HxOverrides.iter = function(a) { | |
return { cur : 0, arr : a, hasNext : function() { | |
return this.cur < this.arr.length; | |
}, next : function() { | |
return this.arr[this.cur++]; | |
}}; | |
}; | |
Math.__name__ = true; | |
var Reflect = function() { }; | |
Reflect.__name__ = true; | |
Reflect.fields = function(o) { | |
var a = []; | |
if(o != null) { | |
var hasOwnProperty = Object.prototype.hasOwnProperty; | |
for( var f in o ) { | |
if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) { | |
a.push(f); | |
} | |
} | |
} | |
return a; | |
}; | |
var Std = function() { }; | |
Std.__name__ = true; | |
Std.string = function(s) { | |
return js_Boot.__string_rec(s,""); | |
}; | |
Std.parseInt = function(x) { | |
var v = parseInt(x, x && x[0]=="0" && (x[1]=="x" || x[1]=="X") ? 16 : 10); | |
if(isNaN(v)) { | |
return null; | |
} | |
return v; | |
}; | |
var StringTools = function() { }; | |
StringTools.__name__ = true; | |
StringTools.isSpace = function(s,pos) { | |
var c = HxOverrides.cca(s,pos); | |
if(!(c > 8 && c < 14)) { | |
return c == 32; | |
} else { | |
return true; | |
} | |
}; | |
StringTools.ltrim = function(s) { | |
var l = s.length; | |
var r = 0; | |
while(r < l && StringTools.isSpace(s,r)) ++r; | |
if(r > 0) { | |
return HxOverrides.substr(s,r,l - r); | |
} else { | |
return s; | |
} | |
}; | |
StringTools.rtrim = function(s) { | |
var l = s.length; | |
var r = 0; | |
while(r < l && StringTools.isSpace(s,l - r - 1)) ++r; | |
if(r > 0) { | |
return HxOverrides.substr(s,0,l - r); | |
} else { | |
return s; | |
} | |
}; | |
StringTools.trim = function(s) { | |
return StringTools.ltrim(StringTools.rtrim(s)); | |
}; | |
var TodoMvc = function() { }; | |
TodoMvc.__name__ = true; | |
TodoMvc.main = function() { | |
var list = new todomvc_data_TodoList(); | |
var _g = 0; | |
var _g1 = Std.parseInt(HxOverrides.substr(window.location.hash,1,null)); | |
while(_g < _g1) { | |
var i = _g++; | |
list.add("item " + i); | |
} | |
var __r = []; | |
var this1 = { f : function() { | |
return list; | |
}}; | |
var __ret = { todos : tink_state__$Observable_Observable_$Impl_$.auto(this1)}; | |
__r.push(todomvc_ui_TodoListView.fromHxx(__ret)); | |
ReactDOM.render(__r[0],window.document.body.appendChild(window.document.createElement("div"))); | |
}; | |
var coconut_data_Model = function() { }; | |
coconut_data_Model.__name__ = true; | |
var coconut_react__$Html_CustomAttr_$Impl_$ = {}; | |
coconut_react__$Html_CustomAttr_$Impl_$.__name__ = true; | |
coconut_react__$Html_CustomAttr_$Impl_$.ofBool = function(b) { | |
if(b != true) { | |
return undefined; | |
} else { | |
return ""; | |
} | |
}; | |
var coconut_react_Html = function() { }; | |
coconut_react_Html.__name__ = true; | |
coconut_react_Html.h = function(tag,attr,children) { | |
if(children == null) { | |
return React.createElement(react__$ReactNode_ReactNode_$Impl_$.fromString(tag),attr); | |
} else { | |
var tmp = [tag,attr].concat(children); | |
return React.createElement.apply(null,tmp); | |
} | |
}; | |
var coconut_react__$Key_Key_$Impl_$ = {}; | |
coconut_react__$Key_Key_$Impl_$.__name__ = true; | |
coconut_react__$Key_Key_$Impl_$.ofObj = function(o) { | |
var id = o.__id__ || (o.__id__ = ++haxe_ds_ObjectMap.count); | |
return id; | |
}; | |
var coconut_react_Renderable = function(rendered,mounted,updated,unmounting) { | |
React.Component.call(this); | |
this.state = this.__snap(); | |
this.__rendered = rendered; | |
this.__viewMounted = mounted; | |
this.__viewUpdated = updated; | |
this.__viewUnmounting = unmounting; | |
}; | |
coconut_react_Renderable.__name__ = true; | |
coconut_react_Renderable.fromHxx = function(props) { | |
return React.createElement(react__$ReactNode_ReactNode_$Impl_$.fromComp(coconut_react_Renderable),props); | |
}; | |
coconut_react_Renderable.__super__ = React.Component; | |
coconut_react_Renderable.prototype = $extend(React.Component.prototype,{ | |
__snap: function() { | |
var _gthis = this; | |
return { vtree : new tink_core__$Lazy_LazyFunc(function() { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__rendered); | |
})}; | |
} | |
,componentDidMount: function() { | |
var _gthis = this; | |
this.__link = tink_state__$Observable_Observable_$Impl_$.bind(this.__rendered,null,function(_) { | |
var tmp = _gthis.__snap(); | |
_gthis.setState(tmp); | |
}); | |
if(this.__viewMounted != null) { | |
this.__viewMounted(); | |
} | |
} | |
,componentDidUpdate: function(_,_1) { | |
if(this.__viewUpdated != null) { | |
this.__viewUpdated(); | |
} | |
} | |
,componentWillUnmount: function() { | |
var this1 = this.__link; | |
if(this1 != null) { | |
this1.dissolve(); | |
} | |
if(this.__viewUnmounting != null) { | |
this.__viewUnmounting(); | |
} | |
} | |
,reactify: function() { | |
if(this.__rewrapped == null) { | |
this.__rewrapped = React.createElement(react__$ReactNode_ReactNode_$Impl_$.fromComp(coconut_react__$Renderable_Rewrapped),{ target : this}); | |
} | |
return this.__rewrapped; | |
} | |
,render: function() { | |
return this.state.vtree.get(); | |
} | |
}); | |
var coconut_react__$Renderable_Rewrapped = function(props,context) { | |
React.Component.call(this,props,context); | |
}; | |
coconut_react__$Renderable_Rewrapped.__name__ = true; | |
coconut_react__$Renderable_Rewrapped.fromHxx = function(props) { | |
return React.createElement(react__$ReactNode_ReactNode_$Impl_$.fromComp(coconut_react__$Renderable_Rewrapped),props); | |
}; | |
coconut_react__$Renderable_Rewrapped.__super__ = React.Component; | |
coconut_react__$Renderable_Rewrapped.prototype = $extend(React.Component.prototype,{ | |
componentDidMount: function() { | |
this.props.target.componentDidMount(); | |
} | |
,componentDidUpdate: function(_,_1) { | |
this.props.target.componentDidUpdate(null,null); | |
} | |
,componentWillUnmount: function() { | |
this.props.target.componentWillUnmount(); | |
} | |
,render: function() { | |
var _gthis = this; | |
var this1 = this.link; | |
if(this1 != null) { | |
this1.dissolve(); | |
} | |
var ret = tink_state__$Observable_Observable_$Impl_$.measure(this.props.target.__rendered); | |
this.link = ret.b.handle(tink_core__$Callback_Callback_$Impl_$.fromNiladic(function() { | |
_gthis.forceUpdate(); | |
})); | |
return ret.a; | |
} | |
}); | |
var coconut_ui_View = function(render,shouldUpdate,track,beforeRerender,mounted,updated) { | |
this.__au = []; | |
this.__bc = []; | |
this.__bu = []; | |
this.__revisionCounter = new tink_state__$State_SimpleState(0,null,null); | |
this.viewId = coconut_ui_View.idCounter++; | |
var _gthis = this; | |
var firstTime = true; | |
var last = null; | |
var hasBeforeRerender = beforeRerender != null; | |
var hasUpdated = updated != null; | |
var lastRev = tink_state__$State_State_$Impl_$.get_value(this.__revisionCounter); | |
var renderView = function() { | |
var curRev = tink_state__$State_State_$Impl_$.get_value(_gthis.__revisionCounter); | |
if(track != null) { | |
track(); | |
} | |
if(firstTime) { | |
firstTime = false; | |
} else { | |
if(curRev == lastRev && shouldUpdate != null && !shouldUpdate()) { | |
return last; | |
} | |
var hasCallbacks = _gthis.__bc.length > 0; | |
if(hasBeforeRerender || hasCallbacks) { | |
tink_state__$Observable_Observable_$Impl_$.untracked(function() { | |
if(hasBeforeRerender) { | |
beforeRerender(); | |
} | |
if(hasCallbacks) { | |
var _g = 0; | |
var _g1 = _gthis.__bc.splice(0,_gthis.__bc.length); | |
while(_g < _g1.length) { | |
var c = _g1[_g]; | |
++_g; | |
tink_core__$Callback_Callback_$Impl_$.invoke(c,false); | |
} | |
} | |
}); | |
} | |
} | |
lastRev = curRev; | |
last = render(); | |
return last; | |
}; | |
var this1 = { f : renderView}; | |
coconut_react_Renderable.call(this,tink_state__$Observable_Observable_$Impl_$.auto(this1),mounted,function() { | |
var hasCallbacks1 = _gthis.__au.length > 0; | |
if(hasUpdated || hasCallbacks1) { | |
tink_state__$Observable_Observable_$Impl_$.untracked(function() { | |
if(hasUpdated) { | |
updated(); | |
} | |
if(hasCallbacks1) { | |
var _g2 = 0; | |
var _g11 = _gthis.__au.splice(0,_gthis.__au.length); | |
while(_g2 < _g11.length) { | |
var c1 = _g11[_g2]; | |
++_g2; | |
tink_core__$Callback_Callback_$Impl_$.invoke(c1,tink_core_Noise.Noise); | |
} | |
} | |
}); | |
} | |
},$bind(this,this.__beforeUnmount)); | |
}; | |
coconut_ui_View.__name__ = true; | |
coconut_ui_View.__super__ = coconut_react_Renderable; | |
coconut_ui_View.prototype = $extend(coconut_react_Renderable.prototype,{ | |
__beforeUnmount: function() { | |
var _g = 0; | |
var _g1 = this.__bu.splice(0,this.__bu.length); | |
while(_g < _g1.length) { | |
var c = _g1[_g]; | |
++_g; | |
if(c != null) { | |
c.dissolve(); | |
} | |
} | |
var _g2 = 0; | |
var _g3 = this.__bc.splice(0,this.__bu.length); | |
while(_g2 < _g3.length) { | |
var c1 = _g3[_g2]; | |
++_g2; | |
tink_core__$Callback_Callback_$Impl_$.invoke(c1,true); | |
} | |
} | |
,forceUpdate: function(callback) { | |
this.__revisionCounter.set(tink_state__$State_State_$Impl_$.get_value(this.__revisionCounter) + 1); | |
if(callback != null) { | |
this.__au.push(tink_core__$Callback_Callback_$Impl_$.fromNiladic(callback)); | |
} | |
} | |
}); | |
var coconut_ui_tools__$Ref_Ref_$Impl_$ = {}; | |
coconut_ui_tools__$Ref_Ref_$Impl_$.__name__ = true; | |
coconut_ui_tools__$Ref_Ref_$Impl_$.toFunction = function(this1) { | |
return function(value) { | |
return this1.current = value; | |
}; | |
}; | |
var tink_state_ObservableObject = function() { }; | |
tink_state_ObservableObject.__name__ = true; | |
var coconut_ui_tools_Slot = function(owner,compare) { | |
this.owner = owner; | |
var tmp; | |
if(compare == null) { | |
tmp = function(a,b) { | |
return a == b; | |
}; | |
} else { | |
var v = compare; | |
tmp = v; | |
} | |
this.compare = tmp; | |
}; | |
coconut_ui_tools_Slot.__name__ = true; | |
coconut_ui_tools_Slot.__interfaces__ = [tink_state_ObservableObject]; | |
coconut_ui_tools_Slot.prototype = { | |
poll: function() { | |
var _gthis = this; | |
if(this.last == null) { | |
if(this.data == null) { | |
var this1 = new tink_core_MPair(null,new tink_core_FutureTrigger()); | |
this.last = this1; | |
} else { | |
var m = tink_state__$Observable_Observable_$Impl_$.measure(this.data); | |
var this2 = new tink_core_MPair(m.a,new tink_core_FutureTrigger()); | |
this.last = this2; | |
this.link = m.b.handle(($_=this.last.b,$bind($_,$_.trigger))); | |
} | |
this.last.b.handle(tink_core__$Callback_Callback_$Impl_$.fromNiladic(function() { | |
_gthis.last = null; | |
})); | |
} | |
var this3 = new tink_core_MPair(this.last.a,this.last.b); | |
var this4 = this3; | |
return this4; | |
} | |
,observe: function() { | |
return this; | |
} | |
,setData: function(data) { | |
this.data = data; | |
if(this.last != null) { | |
var this1 = this.link; | |
if(this1 != null) { | |
this1.dissolve(); | |
} | |
if(data != null) { | |
var _e = data; | |
var m = tink_state__$Observable_Observable_$Impl_$.untracked(function() { | |
return tink_state__$Observable_Observable_$Impl_$.measure(_e); | |
}); | |
if(this.compare(m.a,this.last.a)) { | |
this.link = m.b.handle(($_=this.last.b,$bind($_,$_.trigger))); | |
} else { | |
this.last.b.trigger(tink_core_Noise.Noise); | |
} | |
} | |
} | |
} | |
}; | |
var haxe_IMap = function() { }; | |
haxe_IMap.__name__ = true; | |
var haxe_Timer = function(time_ms) { | |
var me = this; | |
this.id = setInterval(function() { | |
me.run(); | |
},time_ms); | |
}; | |
haxe_Timer.__name__ = true; | |
haxe_Timer.delay = function(f,time_ms) { | |
var t = new haxe_Timer(time_ms); | |
t.run = function() { | |
t.stop(); | |
f(); | |
}; | |
return t; | |
}; | |
haxe_Timer.prototype = { | |
stop: function() { | |
if(this.id == null) { | |
return; | |
} | |
clearInterval(this.id); | |
this.id = null; | |
} | |
,run: function() { | |
} | |
}; | |
var haxe_ds_List = function() { | |
this.length = 0; | |
}; | |
haxe_ds_List.__name__ = true; | |
haxe_ds_List.prototype = { | |
push: function(item) { | |
var x = new haxe_ds__$List_ListNode(item,this.h); | |
this.h = x; | |
if(this.q == null) { | |
this.q = x; | |
} | |
this.length++; | |
} | |
,first: function() { | |
if(this.h == null) { | |
return null; | |
} else { | |
return this.h.item; | |
} | |
} | |
,pop: function() { | |
if(this.h == null) { | |
return null; | |
} | |
var x = this.h.item; | |
this.h = this.h.next; | |
if(this.h == null) { | |
this.q = null; | |
} | |
this.length--; | |
return x; | |
} | |
}; | |
var haxe_ds__$List_ListNode = function(item,next) { | |
this.item = item; | |
this.next = next; | |
}; | |
haxe_ds__$List_ListNode.__name__ = true; | |
var haxe_ds_ObjectMap = function() { | |
this.h = { __keys__ : { }}; | |
}; | |
haxe_ds_ObjectMap.__name__ = true; | |
haxe_ds_ObjectMap.__interfaces__ = [haxe_IMap]; | |
haxe_ds_ObjectMap.prototype = { | |
set: function(key,value) { | |
var id = key.__id__ || (key.__id__ = ++haxe_ds_ObjectMap.count); | |
this.h[id] = value; | |
this.h.__keys__[id] = key; | |
} | |
}; | |
var js__$Boot_HaxeError = function(val) { | |
Error.call(this); | |
this.val = val; | |
if(Error.captureStackTrace) { | |
Error.captureStackTrace(this,js__$Boot_HaxeError); | |
} | |
}; | |
js__$Boot_HaxeError.__name__ = true; | |
js__$Boot_HaxeError.__super__ = Error; | |
js__$Boot_HaxeError.prototype = $extend(Error.prototype,{ | |
}); | |
var js_Boot = function() { }; | |
js_Boot.__name__ = true; | |
js_Boot.__string_rec = function(o,s) { | |
if(o == null) { | |
return "null"; | |
} | |
if(s.length >= 5) { | |
return "<...>"; | |
} | |
var t = typeof(o); | |
if(t == "function" && (o.__name__ || o.__ename__)) { | |
t = "object"; | |
} | |
switch(t) { | |
case "function": | |
return "<function>"; | |
case "object": | |
if(o.__enum__) { | |
var e = $hxEnums[o.__enum__]; | |
var n = e.__constructs__[o._hx_index]; | |
var con = e[n]; | |
if(con.__params__) { | |
s += "\t"; | |
var tmp = n + "("; | |
var _g = []; | |
var _g1 = 0; | |
var _g2 = con.__params__; | |
while(_g1 < _g2.length) { | |
var p = _g2[_g1]; | |
++_g1; | |
_g.push(js_Boot.__string_rec(o[p],s)); | |
} | |
return tmp + _g.join(",") + ")"; | |
} else { | |
return n; | |
} | |
} | |
if((o instanceof Array)) { | |
var l = o.length; | |
var i; | |
var str = "["; | |
s += "\t"; | |
var _g3 = 0; | |
var _g11 = l; | |
while(_g3 < _g11) { | |
var i1 = _g3++; | |
str += (i1 > 0 ? "," : "") + js_Boot.__string_rec(o[i1],s); | |
} | |
str += "]"; | |
return str; | |
} | |
var tostr; | |
try { | |
tostr = o.toString; | |
} catch( e1 ) { | |
var e2 = (e1 instanceof js__$Boot_HaxeError) ? e1.val : e1; | |
return "???"; | |
} | |
if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") { | |
var s2 = o.toString(); | |
if(s2 != "[object Object]") { | |
return s2; | |
} | |
} | |
var k = null; | |
var str1 = "{\n"; | |
s += "\t"; | |
var hasp = o.hasOwnProperty != null; | |
for( var k in o ) { | |
if(hasp && !o.hasOwnProperty(k)) { | |
continue; | |
} | |
if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") { | |
continue; | |
} | |
if(str1.length != 2) { | |
str1 += ", \n"; | |
} | |
str1 += s + k + " : " + js_Boot.__string_rec(o[k],s); | |
} | |
s = s.substring(1); | |
str1 += "\n" + s + "}"; | |
return str1; | |
case "string": | |
return o; | |
default: | |
return String(o); | |
} | |
}; | |
var react__$ReactNode_ReactNode_$Impl_$ = {}; | |
react__$ReactNode_ReactNode_$Impl_$.__name__ = true; | |
react__$ReactNode_ReactNode_$Impl_$.fromString = function(s) { | |
return s; | |
}; | |
react__$ReactNode_ReactNode_$Impl_$.fromComp = function(cls) { | |
if(cls.__jsxStatic != null) { | |
return cls.__jsxStatic; | |
} | |
return cls; | |
}; | |
var tink_core__$Callback_Callback_$Impl_$ = {}; | |
tink_core__$Callback_Callback_$Impl_$.__name__ = true; | |
tink_core__$Callback_Callback_$Impl_$.invoke = function(this1,data) { | |
if(tink_core__$Callback_Callback_$Impl_$.depth < 1000) { | |
tink_core__$Callback_Callback_$Impl_$.depth++; | |
this1(data); | |
tink_core__$Callback_Callback_$Impl_$.depth--; | |
} else { | |
var _e = this1; | |
var f = function(data1) { | |
tink_core__$Callback_Callback_$Impl_$.invoke(_e,data1); | |
}; | |
var data2 = data; | |
tink_core__$Callback_Callback_$Impl_$.defer(function() { | |
f(data2); | |
}); | |
} | |
}; | |
tink_core__$Callback_Callback_$Impl_$.fromNiladic = function(f) { | |
return function(_) { | |
f(); | |
}; | |
}; | |
tink_core__$Callback_Callback_$Impl_$.defer = function(f) { | |
haxe_Timer.delay(f,0); | |
}; | |
var tink_core__$Callback_LinkObject = function() { }; | |
tink_core__$Callback_LinkObject.__name__ = true; | |
var tink_core__$Callback_SimpleLink = function(f) { | |
this.f = f; | |
}; | |
tink_core__$Callback_SimpleLink.__name__ = true; | |
tink_core__$Callback_SimpleLink.__interfaces__ = [tink_core__$Callback_LinkObject]; | |
tink_core__$Callback_SimpleLink.prototype = { | |
dissolve: function() { | |
if(this.f != null) { | |
this.f(); | |
this.f = null; | |
} | |
} | |
}; | |
var tink_core__$Callback_ListCell = function(cb,list) { | |
if(cb == null) { | |
throw new js__$Boot_HaxeError("callback expected but null received"); | |
} | |
this.cb = cb; | |
this.list = list; | |
}; | |
tink_core__$Callback_ListCell.__name__ = true; | |
tink_core__$Callback_ListCell.__interfaces__ = [tink_core__$Callback_LinkObject]; | |
tink_core__$Callback_ListCell.prototype = { | |
clear: function() { | |
this.list = null; | |
this.cb = null; | |
} | |
,dissolve: function() { | |
var _g = this.list; | |
if(_g != null) { | |
var v = _g; | |
this.clear(); | |
HxOverrides.remove(v,this); | |
} | |
} | |
}; | |
var tink_core__$Callback_CallbackList_$Impl_$ = {}; | |
tink_core__$Callback_CallbackList_$Impl_$.__name__ = true; | |
tink_core__$Callback_CallbackList_$Impl_$.add = function(this1,cb) { | |
var node = new tink_core__$Callback_ListCell(cb,this1); | |
this1.push(node); | |
return node; | |
}; | |
tink_core__$Callback_CallbackList_$Impl_$.invoke = function(this1,data) { | |
var _g = 0; | |
var _g1 = this1.slice(); | |
while(_g < _g1.length) { | |
var cell = _g1[_g]; | |
++_g; | |
if(cell.cb != null) { | |
tink_core__$Callback_Callback_$Impl_$.invoke(cell.cb,data); | |
} | |
} | |
}; | |
tink_core__$Callback_CallbackList_$Impl_$.clear = function(this1) { | |
var _g = 0; | |
var _g1 = this1.splice(0,this1.length); | |
while(_g < _g1.length) { | |
var cell = _g1[_g]; | |
++_g; | |
cell.clear(); | |
} | |
}; | |
var tink_core_TypedError = function() { }; | |
tink_core_TypedError.__name__ = true; | |
tink_core_TypedError.tryFinally = function(f,cleanup) { | |
try { return f(); } finally { cleanup(); } | |
return null; | |
}; | |
var tink_core__$Future_FutureObject = function() { }; | |
tink_core__$Future_FutureObject.__name__ = true; | |
var tink_core__$Lazy_LazyObject = function() { }; | |
tink_core__$Lazy_LazyObject.__name__ = true; | |
var tink_core__$Lazy_LazyConst = function(value) { | |
this.value = value; | |
}; | |
tink_core__$Lazy_LazyConst.__name__ = true; | |
tink_core__$Lazy_LazyConst.__interfaces__ = [tink_core__$Lazy_LazyObject]; | |
tink_core__$Lazy_LazyConst.prototype = { | |
get: function() { | |
return this.value; | |
} | |
,map: function(f) { | |
var _gthis = this; | |
return new tink_core__$Lazy_LazyFunc(function() { | |
return f(_gthis.value); | |
}); | |
} | |
}; | |
var tink_core__$Future_SyncFuture = function(value) { | |
this.value = value; | |
}; | |
tink_core__$Future_SyncFuture.__name__ = true; | |
tink_core__$Future_SyncFuture.__interfaces__ = [tink_core__$Future_FutureObject]; | |
tink_core__$Future_SyncFuture.prototype = { | |
flatMap: function(f) { | |
var l = this.value.map(f); | |
return new tink_core__$Future_SimpleFuture(function(cb) { | |
return l.get().handle(cb); | |
}); | |
} | |
,handle: function(cb) { | |
tink_core__$Callback_Callback_$Impl_$.invoke(cb,this.value.get()); | |
return null; | |
} | |
,gather: function() { | |
return this; | |
} | |
}; | |
var tink_core_Noise = $hxEnums["tink.core.Noise"] = { __ename__ : true, __constructs__ : ["Noise"] | |
,Noise: {_hx_index:0,__enum__:"tink.core.Noise",toString:$estr} | |
}; | |
var tink_core__$Future_Future_$Impl_$ = {}; | |
tink_core__$Future_Future_$Impl_$.__name__ = true; | |
tink_core__$Future_Future_$Impl_$.flatten = function(f) { | |
return new tink_core__$Future_NestedFuture(f); | |
}; | |
var tink_core__$Future_SimpleFuture = function(f) { | |
this.f = f; | |
}; | |
tink_core__$Future_SimpleFuture.__name__ = true; | |
tink_core__$Future_SimpleFuture.__interfaces__ = [tink_core__$Future_FutureObject]; | |
tink_core__$Future_SimpleFuture.prototype = { | |
handle: function(callback) { | |
return this.f(callback); | |
} | |
,flatMap: function(f) { | |
var f1 = f; | |
var _gthis = this; | |
return tink_core__$Future_Future_$Impl_$.flatten(new tink_core__$Future_SimpleFuture(function(cb) { | |
return _gthis.f(function(v) { | |
var tmp = f1(v); | |
tink_core__$Callback_Callback_$Impl_$.invoke(cb,tmp); | |
}); | |
})); | |
} | |
,gather: function() { | |
if(this.gathered != null) { | |
return this.gathered; | |
} else { | |
return this.gathered = tink_core_FutureTrigger.gatherFuture(this); | |
} | |
} | |
}; | |
var tink_core__$Future_NestedFuture = function(outer) { | |
this.outer = outer; | |
}; | |
tink_core__$Future_NestedFuture.__name__ = true; | |
tink_core__$Future_NestedFuture.__interfaces__ = [tink_core__$Future_FutureObject]; | |
tink_core__$Future_NestedFuture.prototype = { | |
flatMap: function(f) { | |
var ret = this.outer.flatMap(function(inner) { | |
var ret1 = inner.flatMap(f); | |
return ret1.gather(); | |
}); | |
return ret.gather(); | |
} | |
,gather: function() { | |
if(this.gathered != null) { | |
return this.gathered; | |
} else { | |
return this.gathered = tink_core_FutureTrigger.gatherFuture(this); | |
} | |
} | |
,handle: function(cb) { | |
var ret = null; | |
ret = this.outer.handle(function(inner) { | |
ret = inner.handle(function(result) { | |
tink_core__$Callback_Callback_$Impl_$.invoke(cb,result); | |
}); | |
}); | |
return ret; | |
} | |
}; | |
var tink_core_FutureTrigger = function() { | |
var this1 = []; | |
this.list = this1; | |
}; | |
tink_core_FutureTrigger.__name__ = true; | |
tink_core_FutureTrigger.__interfaces__ = [tink_core__$Future_FutureObject]; | |
tink_core_FutureTrigger.gatherFuture = function(f) { | |
var op = null; | |
var this1 = new tink_core__$Future_SimpleFuture(function(cb) { | |
if(op == null) { | |
op = new tink_core_FutureTrigger(); | |
f.handle($bind(op,op.trigger)); | |
f = null; | |
} | |
return op.handle(cb); | |
}); | |
return this1; | |
}; | |
tink_core_FutureTrigger.prototype = { | |
handle: function(callback) { | |
var _g = this.list; | |
if(_g == null) { | |
tink_core__$Callback_Callback_$Impl_$.invoke(callback,this.result); | |
return null; | |
} else { | |
var v = _g; | |
return tink_core__$Callback_CallbackList_$Impl_$.add(v,callback); | |
} | |
} | |
,flatMap: function(f) { | |
var _g = this.list; | |
if(_g == null) { | |
return f(this.result); | |
} else { | |
var v = _g; | |
var ret = new tink_core_FutureTrigger(); | |
tink_core__$Callback_CallbackList_$Impl_$.add(this.list,function(v1) { | |
f(v1).handle($bind(ret,ret.trigger)); | |
}); | |
return ret; | |
} | |
} | |
,gather: function() { | |
return this; | |
} | |
,trigger: function(result) { | |
if(this.list == null) { | |
return false; | |
} else { | |
var list = this.list; | |
this.list = null; | |
this.result = result; | |
tink_core__$Callback_CallbackList_$Impl_$.invoke(list,result); | |
tink_core__$Callback_CallbackList_$Impl_$.clear(list); | |
return true; | |
} | |
} | |
}; | |
var tink_core__$Lazy_LazyFunc = function(f) { | |
this.f = f; | |
}; | |
tink_core__$Lazy_LazyFunc.__name__ = true; | |
tink_core__$Lazy_LazyFunc.__interfaces__ = [tink_core__$Lazy_LazyObject]; | |
tink_core__$Lazy_LazyFunc.prototype = { | |
get: function() { | |
if(this.f != null) { | |
this.result = this.f(); | |
this.f = null; | |
} | |
return this.result; | |
} | |
,map: function(f) { | |
var _gthis = this; | |
return new tink_core__$Lazy_LazyFunc(function() { | |
var tmp = _gthis.get(); | |
return f(tmp); | |
}); | |
} | |
}; | |
var tink_core_NamedWith = function(name,value) { | |
this.name = name; | |
this.value = value; | |
}; | |
tink_core_NamedWith.__name__ = true; | |
var tink_core_Outcome = $hxEnums["tink.core.Outcome"] = { __ename__ : true, __constructs__ : ["Success","Failure"] | |
,Success: ($_=function(data) { return {_hx_index:0,data:data,__enum__:"tink.core.Outcome",toString:$estr}; },$_.__params__ = ["data"],$_) | |
,Failure: ($_=function(failure) { return {_hx_index:1,failure:failure,__enum__:"tink.core.Outcome",toString:$estr}; },$_.__params__ = ["failure"],$_) | |
}; | |
var tink_core_MPair = function(a,b) { | |
this.a = a; | |
this.b = b; | |
}; | |
tink_core_MPair.__name__ = true; | |
var tink_core__$Promise_Promise_$Impl_$ = {}; | |
tink_core__$Promise_Promise_$Impl_$.__name__ = true; | |
tink_core__$Promise_Promise_$Impl_$.next = function(this1,f,gather) { | |
if(gather == null) { | |
gather = true; | |
} | |
var ret = this1.flatMap(function(o) { | |
switch(o._hx_index) { | |
case 0: | |
var d = o.data; | |
return f(d); | |
case 1: | |
var f1 = o.failure; | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Failure(f1))); | |
} | |
}); | |
if(gather) { | |
return ret.gather(); | |
} else { | |
return ret; | |
} | |
}; | |
var tink_core__$Signal_Signal_$Impl_$ = {}; | |
tink_core__$Signal_Signal_$Impl_$.__name__ = true; | |
tink_core__$Signal_Signal_$Impl_$.trigger = function() { | |
return new tink_core_SignalTrigger(); | |
}; | |
var tink_core_SignalObject = function() { }; | |
tink_core_SignalObject.__name__ = true; | |
var tink_core_SignalTrigger = function() { | |
this.handlers = []; | |
}; | |
tink_core_SignalTrigger.__name__ = true; | |
tink_core_SignalTrigger.__interfaces__ = [tink_core_SignalObject]; | |
var tink_domspec__$ClassName_ClassName_$Impl_$ = {}; | |
tink_domspec__$ClassName_ClassName_$Impl_$.__name__ = true; | |
tink_domspec__$ClassName_ClassName_$Impl_$.ofString = function(s) { | |
var this1 = StringTools.trim(s); | |
return this1; | |
}; | |
var tink_pure__$List_List_$Impl_$ = {}; | |
tink_pure__$List_List_$Impl_$.__name__ = true; | |
tink_pure__$List_List_$Impl_$.prepend = function(this1,value) { | |
if(this1 == null) { | |
return new tink_pure__$List_Node(1,value); | |
} else { | |
return new tink_pure__$List_Node(this1.length + 1,value,[this1]); | |
} | |
}; | |
tink_pure__$List_List_$Impl_$.filter = function(this1,f) { | |
if(this1 == null) { | |
return null; | |
} else { | |
return this1.filter(f); | |
} | |
}; | |
tink_pure__$List_List_$Impl_$.fromArray = function(i) { | |
var ret = null; | |
var len = 0; | |
var pos = i.length; | |
while(pos-- > 0) ret = new tink_pure__$List_Node(++len,i[pos],ret == null ? tink_pure__$List_Node.EMPTY : [ret]); | |
return ret; | |
}; | |
var tink_pure__$List_Node = function(length,value,tails) { | |
this.value = value; | |
this.length = length; | |
this.tails = tails == null ? tink_pure__$List_Node.EMPTY : tails; | |
}; | |
tink_pure__$List_Node.__name__ = true; | |
tink_pure__$List_Node.prototype = { | |
filter: function(f) { | |
var iter = new tink_pure_NodeIterator(this); | |
var ret = []; | |
while(iter.list.length > 0) { | |
var value = iter.next(); | |
var res = f(value); | |
if(res > 0) { | |
ret.push(value); | |
} | |
if((res & 3) == 3) { | |
break; | |
} | |
} | |
return tink_pure__$List_List_$Impl_$.fromArray(ret); | |
} | |
}; | |
var tink_pure_NodeIterator = function(node) { | |
this.list = []; | |
if(node != null) { | |
this.list.push(node); | |
} | |
}; | |
tink_pure_NodeIterator.__name__ = true; | |
tink_pure_NodeIterator.prototype = { | |
hasNext: function() { | |
return this.list.length > 0; | |
} | |
,next: function() { | |
var _g = this.list.pop(); | |
if(_g == null) { | |
return null; | |
} else { | |
var next = _g; | |
var _g1 = -next.tails.length; | |
var _g11 = 0; | |
while(_g1 < _g11) { | |
var i = _g1++; | |
this.list.push(next.tails[-i - 1]); | |
} | |
return next.value; | |
} | |
} | |
}; | |
var tink_state__$Observable_Observable_$Impl_$ = {}; | |
tink_state__$Observable_Observable_$Impl_$.__name__ = true; | |
tink_state__$Observable_Observable_$Impl_$.get_value = function(this1) { | |
return tink_state__$Observable_Observable_$Impl_$.measure(this1).a; | |
}; | |
tink_state__$Observable_Observable_$Impl_$.map = function(this1,f) { | |
return tink_state__$Observable_Observable_$Impl_$.create(function() { | |
var m = tink_state__$Observable_Observable_$Impl_$.measure(this1); | |
var this2 = new tink_core_MPair(f(m.a),m.b); | |
var this3 = this2; | |
return this3; | |
}); | |
}; | |
tink_state__$Observable_Observable_$Impl_$.measure = function(this1) { | |
var before = tink_state__$Observable_Observable_$Impl_$.stack.first(); | |
tink_state__$Observable_Observable_$Impl_$.stack.push(this1); | |
var p = this1.poll(); | |
var _g = (before instanceof tink_state__$Observable_AutoObservable) ? before : null; | |
if(_g != null) { | |
var v = _g; | |
v.subscribe(p.b); | |
} | |
tink_state__$Observable_Observable_$Impl_$.stack.pop(); | |
return p; | |
}; | |
tink_state__$Observable_Observable_$Impl_$.bind = function(this1,options,cb) { | |
var cb1; | |
if(options == null) { | |
cb1 = cb; | |
} else if(options.comparator == null) { | |
cb1 = cb; | |
} else { | |
var equal = options.comparator; | |
var isFirst = true; | |
var last = null; | |
cb1 = function(data) { | |
if(isFirst) { | |
isFirst = false; | |
tink_core__$Callback_Callback_$Impl_$.invoke(cb,data); | |
} else if(!equal(last,data)) { | |
tink_core__$Callback_Callback_$Impl_$.invoke(cb,data); | |
} | |
last = data; | |
}; | |
} | |
if(options == null) { | |
var scheduled = false; | |
var active = true; | |
var updated = null; | |
var link = null; | |
var update = function() { | |
if(active) { | |
var next = tink_state__$Observable_Observable_$Impl_$.measure(this1); | |
tink_core__$Callback_Callback_$Impl_$.invoke(cb1,next.a); | |
scheduled = false; | |
link = next.b.handle(updated); | |
} | |
}; | |
var doSchedule = function() { | |
if(scheduled) { | |
return; | |
} | |
scheduled = true; | |
tink_state__$Observable_Observable_$Impl_$.schedule(update); | |
}; | |
updated = tink_core__$Callback_Callback_$Impl_$.fromNiladic(doSchedule); | |
doSchedule(); | |
var this2 = new tink_core__$Callback_SimpleLink(function() { | |
if(active) { | |
active = false; | |
if(link != null) { | |
link.dissolve(); | |
} | |
} | |
}); | |
return this2; | |
} else if(options.direct == null) { | |
var scheduled1 = false; | |
var active1 = true; | |
var updated1 = null; | |
var link1 = null; | |
var update1 = function() { | |
if(active1) { | |
var next1 = tink_state__$Observable_Observable_$Impl_$.measure(this1); | |
tink_core__$Callback_Callback_$Impl_$.invoke(cb1,next1.a); | |
scheduled1 = false; | |
link1 = next1.b.handle(updated1); | |
} | |
}; | |
var doSchedule1 = function() { | |
if(scheduled1) { | |
return; | |
} | |
scheduled1 = true; | |
tink_state__$Observable_Observable_$Impl_$.schedule(update1); | |
}; | |
updated1 = tink_core__$Callback_Callback_$Impl_$.fromNiladic(doSchedule1); | |
doSchedule1(); | |
var this3 = new tink_core__$Callback_SimpleLink(function() { | |
if(active1) { | |
active1 = false; | |
if(link1 != null) { | |
link1.dissolve(); | |
} | |
} | |
}); | |
return this3; | |
} else if(options.direct == false) { | |
var scheduled2 = false; | |
var active2 = true; | |
var updated2 = null; | |
var link2 = null; | |
var update2 = function() { | |
if(active2) { | |
var next2 = tink_state__$Observable_Observable_$Impl_$.measure(this1); | |
tink_core__$Callback_Callback_$Impl_$.invoke(cb1,next2.a); | |
scheduled2 = false; | |
link2 = next2.b.handle(updated2); | |
} | |
}; | |
var doSchedule2 = function() { | |
if(scheduled2) { | |
return; | |
} | |
scheduled2 = true; | |
tink_state__$Observable_Observable_$Impl_$.schedule(update2); | |
}; | |
updated2 = tink_core__$Callback_Callback_$Impl_$.fromNiladic(doSchedule2); | |
doSchedule2(); | |
var this4 = new tink_core__$Callback_SimpleLink(function() { | |
if(active2) { | |
active2 = false; | |
if(link2 != null) { | |
link2.dissolve(); | |
} | |
} | |
}); | |
return this4; | |
} else { | |
var link3 = null; | |
var update3 = null; | |
update3 = function(_) { | |
var next3 = tink_state__$Observable_Observable_$Impl_$.measure(this1); | |
tink_core__$Callback_Callback_$Impl_$.invoke(cb1,next3.a); | |
link3 = next3.b.handle(update3); | |
}; | |
update3(tink_core_Noise.Noise); | |
var this5 = new tink_core__$Callback_SimpleLink(function() { | |
if(link3 != null) { | |
link3.dissolve(); | |
} | |
}); | |
return this5; | |
} | |
}; | |
tink_state__$Observable_Observable_$Impl_$.schedule = function(f) { | |
var _g = tink_state__$Observable_Observable_$Impl_$.scheduled; | |
if(_g == null) { | |
f(); | |
} else { | |
var v = _g; | |
v.push(f); | |
tink_state__$Observable_Observable_$Impl_$.scheduleUpdate(); | |
} | |
}; | |
tink_state__$Observable_Observable_$Impl_$.scheduleUpdate = function() { | |
if(!tink_state__$Observable_Observable_$Impl_$.isScheduled) { | |
tink_state__$Observable_Observable_$Impl_$.isScheduled = true; | |
if(tink_state__$Observable_Observable_$Impl_$.hasRAF) { | |
window.requestAnimationFrame(function(_) { | |
tink_state__$Observable_Observable_$Impl_$.scheduledRun(); | |
}); | |
} else { | |
tink_core__$Callback_Callback_$Impl_$.defer(tink_state__$Observable_Observable_$Impl_$.scheduledRun); | |
} | |
} | |
}; | |
tink_state__$Observable_Observable_$Impl_$.scheduledRun = function() { | |
tink_state__$Observable_Observable_$Impl_$.isScheduled = false; | |
tink_state__$Observable_Observable_$Impl_$.updatePending(); | |
}; | |
tink_state__$Observable_Observable_$Impl_$.updatePending = function(maxSeconds) { | |
if(maxSeconds == null) { | |
maxSeconds = .01; | |
} | |
var end = new Date().getTime() / 1000 + maxSeconds; | |
while(true) { | |
var old = tink_state__$Observable_Observable_$Impl_$.scheduled; | |
tink_state__$Observable_Observable_$Impl_$.scheduled = []; | |
var _g = 0; | |
while(_g < old.length) { | |
var o = old[_g]; | |
++_g; | |
o(); | |
} | |
if(!(tink_state__$Observable_Observable_$Impl_$.scheduled.length > 0 && new Date().getTime() / 1000 < end)) { | |
break; | |
} | |
} | |
if(tink_state__$Observable_Observable_$Impl_$.scheduled.length > 0) { | |
tink_state__$Observable_Observable_$Impl_$.scheduleUpdate(); | |
return true; | |
} else { | |
return false; | |
} | |
}; | |
tink_state__$Observable_Observable_$Impl_$.create = function(f) { | |
return new tink_state__$Observable_SimpleObservable(f); | |
}; | |
tink_state__$Observable_Observable_$Impl_$.auto = function(f) { | |
return new tink_state__$Observable_AutoObservable(f); | |
}; | |
tink_state__$Observable_Observable_$Impl_$["const"] = function(value) { | |
return new tink_state_ConstObservable(value); | |
}; | |
tink_state__$Observable_Observable_$Impl_$.untracked = function(f) { | |
tink_state__$Observable_Observable_$Impl_$.stack.push(null); | |
return tink_core_TypedError.tryFinally(f,($_=tink_state__$Observable_Observable_$Impl_$.stack,$bind($_,$_.pop))); | |
}; | |
var tink_state__$Observable_SimpleObservable = function(f) { | |
this._poll = f; | |
}; | |
tink_state__$Observable_SimpleObservable.__name__ = true; | |
tink_state__$Observable_SimpleObservable.__interfaces__ = [tink_state_ObservableObject]; | |
tink_state__$Observable_SimpleObservable.prototype = { | |
resetCache: function(_) { | |
this.cache = null; | |
} | |
,poll: function() { | |
var count = 0; | |
var last = null; | |
while(this.cache == null) { | |
var cache = this.cache = this._poll(); | |
if(last == cache) { | |
throw new js__$Boot_HaxeError("Polling loops on the same value"); | |
} | |
last = cache; | |
cache.b.handle($bind(this,this.resetCache)); | |
if(count++ >= 100) { | |
throw new js__$Boot_HaxeError("Polling not concluded after 100 iterations"); | |
} | |
} | |
return this.cache; | |
} | |
}; | |
var tink_state__$Observable_Transform_$Impl_$ = {}; | |
tink_state__$Observable_Transform_$Impl_$.__name__ = true; | |
tink_state__$Observable_Transform_$Impl_$.plain = function(f) { | |
var this1 = f; | |
return this1; | |
}; | |
var tink_state_ConstObservable = function(value) { | |
var this1 = new tink_core_MPair(value,tink_state_ConstObservable.NEVER); | |
var this2 = this1; | |
this.m = this2; | |
}; | |
tink_state_ConstObservable.__name__ = true; | |
tink_state_ConstObservable.__interfaces__ = [tink_state_ObservableObject]; | |
tink_state_ConstObservable.prototype = { | |
poll: function() { | |
return this.m; | |
} | |
}; | |
var tink_state__$Observable_AutoObservable = function(comp) { | |
this.subscriptions = new haxe_ds_ObjectMap(); | |
var _gthis = this; | |
tink_state__$Observable_SimpleObservable.call(this,function() { | |
_gthis.subscriptions = new haxe_ds_ObjectMap(); | |
_gthis.trigger = new tink_core_FutureTrigger(); | |
var this1 = new tink_core_MPair(comp.f(),_gthis.trigger); | |
var this2 = this1; | |
return this2; | |
}); | |
}; | |
tink_state__$Observable_AutoObservable.__name__ = true; | |
tink_state__$Observable_AutoObservable.__super__ = tink_state__$Observable_SimpleObservable; | |
tink_state__$Observable_AutoObservable.prototype = $extend(tink_state__$Observable_SimpleObservable.prototype,{ | |
subscribe: function(change) { | |
if(this.subscriptions.h.__keys__[change.__id__] == null) { | |
var this1 = this.subscriptions; | |
var v = change.handle(($_=this.trigger,$bind($_,$_.trigger))); | |
this1.set(change,v); | |
} | |
} | |
}); | |
var tink_state__$State_State_$Impl_$ = {}; | |
tink_state__$State_State_$Impl_$.__name__ = true; | |
tink_state__$State_State_$Impl_$.get_value = function(this1) { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(this1); | |
}; | |
var tink_state__$State_StateObject = function() { }; | |
tink_state__$State_StateObject.__name__ = true; | |
tink_state__$State_StateObject.__interfaces__ = [tink_state_ObservableObject]; | |
var tink_state__$State_SimpleState = function(value,isEqual,guard) { | |
this.value = value; | |
this.isEqual = isEqual; | |
this.guard = guard; | |
this.arm(); | |
}; | |
tink_state__$State_SimpleState.__name__ = true; | |
tink_state__$State_SimpleState.__interfaces__ = [tink_state__$State_StateObject]; | |
tink_state__$State_SimpleState.prototype = { | |
poll: function() { | |
return this.next; | |
} | |
,arm: function() { | |
this.trigger = new tink_core_FutureTrigger(); | |
var this1 = new tink_core_MPair(this.value,this.trigger); | |
var this2 = this1; | |
this.next = this2; | |
} | |
,set: function(value) { | |
if(this.guard != null) { | |
value = this.guard(value,this.value); | |
} | |
var b = this.value; | |
if(this.isEqual == null ? value != b : !this.isEqual(value,b)) { | |
this.value = value; | |
var last = this.trigger; | |
this.arm(); | |
last.trigger(tink_core_Noise.Noise); | |
} | |
} | |
}; | |
var todomvc_data_TodoFilter = function() { | |
this.options = tink_pure__$List_List_$Impl_$.fromArray([new tink_core_NamedWith("All",function(_) { | |
return true; | |
}),new tink_core_NamedWith("Active",todomvc_data_TodoItem.isActive),new tink_core_NamedWith("Completed",todomvc_data_TodoItem.isCompleted)]); | |
var this1 = new tink_state__$State_SimpleState(new tink_pure_NodeIterator(this.options).next().value,null,null); | |
this.__coco_currentFilter = this1; | |
var this2 = new tink_state__$State_SimpleState(0,null,null); | |
this.__coco_transitionCount = this2; | |
this.errorTrigger = tink_core__$Signal_Signal_$Impl_$.trigger(); | |
this.transitionErrors = this.errorTrigger; | |
this.observables = { options : tink_state__$Observable_Observable_$Impl_$["const"](this.options), currentFilter : this.__coco_currentFilter, isInTransition : tink_state__$Observable_Observable_$Impl_$.map(this.__coco_transitionCount,tink_state__$Observable_Transform_$Impl_$.plain(function(count) { | |
return count > 0; | |
}))}; | |
}; | |
todomvc_data_TodoFilter.__name__ = true; | |
todomvc_data_TodoFilter.__interfaces__ = [coconut_data_Model]; | |
todomvc_data_TodoFilter.prototype = { | |
matches: function(item) { | |
return (tink_state__$State_State_$Impl_$.get_value(this.__coco_currentFilter))(item); | |
} | |
,toggle: function(filter) { | |
var _gthis = this; | |
return tink_core__$Promise_Promise_$Impl_$.next(this.__cocoupdate((function() { | |
var _g = new tink_pure_NodeIterator(_gthis.options); | |
while(_g.list.length > 0) { | |
var o = _g.next(); | |
if(o.value == filter) { | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success({ currentFilter : filter}))); | |
} | |
} | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success({ }))); | |
})()),function(_) { | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success(tink_core_Noise.Noise))); | |
}); | |
} | |
,isActive: function(filter) { | |
return filter == tink_state__$State_State_$Impl_$.get_value(this.__coco_currentFilter); | |
} | |
,__cocoupdate: function(ret) { | |
var _gthis = this; | |
var sync = true; | |
var done = false; | |
ret.handle(function(o) { | |
done = true; | |
if(!sync) { | |
var tmp = tink_state__$State_State_$Impl_$.get_value(_gthis.__coco_transitionCount) - 1; | |
_gthis.__coco_transitionCount.set(tmp); | |
} | |
switch(o._hx_index) { | |
case 0: | |
var delta = o.data; | |
var this1 = { }; | |
var sparse = this1; | |
var delta1 = delta; | |
var _g = 0; | |
var _g1 = Reflect.fields(delta1); | |
while(_g < _g1.length) { | |
var k = _g1[_g]; | |
++_g; | |
var this2 = new Array(1); | |
var this3 = this2; | |
var ret1 = this3; | |
ret1[0] = delta1[k]; | |
sparse[k] = ret1; | |
} | |
var delta2 = sparse; | |
if(delta2.currentFilter != null) { | |
_gthis.__coco_currentFilter.set(delta2.currentFilter[0]); | |
} | |
break; | |
case 1: | |
var e = o.failure; | |
tink_core__$Callback_CallbackList_$Impl_$.invoke(_gthis.errorTrigger.handlers,e); | |
break; | |
} | |
}); | |
if(!done) { | |
sync = false; | |
} | |
if(!sync) { | |
this.__coco_transitionCount.set(tink_state__$State_State_$Impl_$.get_value(this.__coco_transitionCount) + 1); | |
} | |
return ret; | |
} | |
}; | |
var todomvc_data_TodoItem = function(init) { | |
this.id = Std.string(todomvc_data_TodoItem.idCounter++); | |
var value; | |
var _g = init.completed; | |
if(_g == null) { | |
value = false; | |
} else { | |
var v = _g; | |
value = v; | |
} | |
var this1 = new tink_state__$State_SimpleState(value,null,null); | |
this.__coco_completed = this1; | |
var this2 = new tink_state__$State_SimpleState(init.description,null,null); | |
this.__coco_description = this2; | |
var _g1 = init.created; | |
var tmp; | |
if(_g1 == null) { | |
tmp = new Date(); | |
} else { | |
var v1 = _g1; | |
tmp = v1; | |
} | |
this.created = tmp; | |
var this3 = new tink_state__$State_SimpleState(0,null,null); | |
this.__coco_transitionCount = this3; | |
this.errorTrigger = tink_core__$Signal_Signal_$Impl_$.trigger(); | |
this.transitionErrors = this.errorTrigger; | |
this.observables = { id : tink_state__$Observable_Observable_$Impl_$["const"](this.id), completed : this.__coco_completed, description : this.__coco_description, created : tink_state__$Observable_Observable_$Impl_$["const"](this.created), isInTransition : tink_state__$Observable_Observable_$Impl_$.map(this.__coco_transitionCount,tink_state__$Observable_Transform_$Impl_$.plain(function(count) { | |
return count > 0; | |
}))}; | |
}; | |
todomvc_data_TodoItem.__name__ = true; | |
todomvc_data_TodoItem.__interfaces__ = [coconut_data_Model]; | |
todomvc_data_TodoItem.create = function(description) { | |
return new todomvc_data_TodoItem({ description : description}); | |
}; | |
todomvc_data_TodoItem.isActive = function(item) { | |
return !tink_state__$State_State_$Impl_$.get_value(item.__coco_completed); | |
}; | |
todomvc_data_TodoItem.isCompleted = function(item) { | |
return tink_state__$State_State_$Impl_$.get_value(item.__coco_completed); | |
}; | |
todomvc_data_TodoItem.prototype = { | |
set_completed: function(param) { | |
this.__coco_completed.set(param); | |
return param; | |
} | |
,set_description: function(param) { | |
this.__coco_description.set(param); | |
return param; | |
} | |
}; | |
var todomvc_data_TodoList = function(init) { | |
var _gthis = this; | |
if(init == null) { | |
init = { }; | |
} | |
var value; | |
var _g = init.items; | |
if(_g == null) { | |
value = null; | |
} else { | |
var v = _g; | |
value = v; | |
} | |
var this1 = new tink_state__$State_SimpleState(value,null,null); | |
this.__coco_items = this1; | |
var this2 = { f : function() { | |
var predicate = todomvc_data_TodoItem.isActive; | |
var ret = 0; | |
var _g1 = new tink_pure_NodeIterator(tink_state__$State_State_$Impl_$.get_value(_gthis.__coco_items)); | |
while(_g1.list.length > 0) { | |
var x = _g1.next(); | |
if(predicate(x)) { | |
++ret; | |
} | |
} | |
return ret; | |
}}; | |
this.__coco_unfinished = tink_state__$Observable_Observable_$Impl_$.auto(this2); | |
var this3 = { f : function() { | |
var this4 = tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__coco_unfinished); | |
var this5 = tink_state__$State_State_$Impl_$.get_value(_gthis.__coco_items); | |
return this4 < (this5 == null ? 0 : this5.length); | |
}}; | |
this.__coco_hasAnyCompleted = tink_state__$Observable_Observable_$Impl_$.auto(this3); | |
var this6 = new tink_state__$State_SimpleState(0,null,null); | |
this.__coco_transitionCount = this6; | |
this.errorTrigger = tink_core__$Signal_Signal_$Impl_$.trigger(); | |
this.transitionErrors = this.errorTrigger; | |
this.observables = { items : this.__coco_items, unfinished : this.__coco_unfinished, hasAnyCompleted : this.__coco_hasAnyCompleted, isInTransition : tink_state__$Observable_Observable_$Impl_$.map(this.__coco_transitionCount,tink_state__$Observable_Transform_$Impl_$.plain(function(count) { | |
return count > 0; | |
}))}; | |
}; | |
todomvc_data_TodoList.__name__ = true; | |
todomvc_data_TodoList.__interfaces__ = [coconut_data_Model]; | |
todomvc_data_TodoList.prototype = { | |
add: function(description) { | |
return tink_core__$Promise_Promise_$Impl_$.next(this.__cocoupdate(new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success({ items : tink_pure__$List_List_$Impl_$.prepend(tink_state__$State_State_$Impl_$.get_value(this.__coco_items),todomvc_data_TodoItem.create(description))})))),function(_) { | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success(tink_core_Noise.Noise))); | |
}); | |
} | |
,'delete': function(item) { | |
return tink_core__$Promise_Promise_$Impl_$.next(this.__cocoupdate(new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success({ items : tink_pure__$List_List_$Impl_$.filter(tink_state__$State_State_$Impl_$.get_value(this.__coco_items),function(i) { | |
if(i != item) { | |
return 1; | |
} else { | |
return 0; | |
} | |
})})))),function(_) { | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success(tink_core_Noise.Noise))); | |
}); | |
} | |
,clearCompleted: function() { | |
return tink_core__$Promise_Promise_$Impl_$.next(this.__cocoupdate(new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success({ items : tink_pure__$List_List_$Impl_$.filter(tink_state__$State_State_$Impl_$.get_value(this.__coco_items),function(i) { | |
if(!tink_state__$State_State_$Impl_$.get_value(i.__coco_completed)) { | |
return 1; | |
} else { | |
return 0; | |
} | |
})})))),function(_) { | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success(tink_core_Noise.Noise))); | |
}); | |
} | |
,__cocoupdate: function(ret) { | |
var _gthis = this; | |
var sync = true; | |
var done = false; | |
ret.handle(function(o) { | |
done = true; | |
if(!sync) { | |
var tmp = tink_state__$State_State_$Impl_$.get_value(_gthis.__coco_transitionCount) - 1; | |
_gthis.__coco_transitionCount.set(tmp); | |
} | |
switch(o._hx_index) { | |
case 0: | |
var delta = o.data; | |
var this1 = { }; | |
var sparse = this1; | |
var delta1 = delta; | |
var _g = 0; | |
var _g1 = Reflect.fields(delta1); | |
while(_g < _g1.length) { | |
var k = _g1[_g]; | |
++_g; | |
var this2 = new Array(1); | |
var this3 = this2; | |
var ret1 = this3; | |
ret1[0] = delta1[k]; | |
sparse[k] = ret1; | |
} | |
var delta2 = sparse; | |
if(delta2.items != null) { | |
_gthis.__coco_items.set(delta2.items[0]); | |
} | |
break; | |
case 1: | |
var e = o.failure; | |
tink_core__$Callback_CallbackList_$Impl_$.invoke(_gthis.errorTrigger.handlers,e); | |
break; | |
} | |
}); | |
if(!done) { | |
sync = false; | |
} | |
if(!sync) { | |
this.__coco_transitionCount.set(tink_state__$State_State_$Impl_$.get_value(this.__coco_transitionCount) + 1); | |
} | |
return ret; | |
} | |
}; | |
var todomvc_ui_TodoItemView = function(data) { | |
this.__tink_defaults31 = { }; | |
this.__slots = { item : new coconut_ui_tools_Slot(this,null), ondeleted : new coconut_ui_tools_Slot(this,null)}; | |
var this1 = new tink_state__$State_SimpleState(false,null,null); | |
this.__coco_isEditing = this1; | |
this.__initAttributes(data); | |
var snapshot = null; | |
coconut_ui_View.call(this,$bind(this,this.coconutRender),null,null,null,null,null); | |
}; | |
todomvc_ui_TodoItemView.__name__ = true; | |
todomvc_ui_TodoItemView.fromHxx = function(attributes) { | |
return React.createElement(react__$ReactNode_ReactNode_$Impl_$.fromComp(todomvc_ui_TodoItemView),attributes); | |
}; | |
todomvc_ui_TodoItemView.__super__ = coconut_ui_View; | |
todomvc_ui_TodoItemView.prototype = $extend(coconut_ui_View.prototype,{ | |
coconutRender: function() { | |
var _gthis = this; | |
var edit = function(entered) { | |
var _g = StringTools.rtrim(entered); | |
if(_g == "") { | |
(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.ondeleted.observe()))(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.item.observe())); | |
} else { | |
var v = _g; | |
tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.item.observe()).set_description(v); | |
} | |
}; | |
var __r = []; | |
var __ret = { className : tink_domspec__$ClassName_ClassName_$Impl_$.ofString("todo-item"), "data-completed" : coconut_react__$Html_CustomAttr_$Impl_$.ofBool(tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.item.observe()).__coco_completed)), "data-editing" : undefined}; | |
var __r1 = []; | |
var __ret1 = { name : "completed", type : "checkbox", checked : tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.item.observe()).__coco_completed), onChange : function(event) { | |
tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.item.observe()).set_completed(event.currentTarget.checked); | |
}}; | |
__r1.push(coconut_react_Html.h("input",__ret1)); | |
if(tink_state__$State_State_$Impl_$.get_value(this.__coco_isEditing)) { | |
var __ret2 = { ref : function(i) { | |
if(i != null) { | |
i.focus(); | |
} | |
return; | |
}, name : "description", type : "text", value : tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.item.observe()).__coco_description), onChange : function(event1) { | |
edit(event1.currentTarget.value); | |
}, onBlur : function(event2) { | |
_gthis.__coco_isEditing.set(false); | |
}}; | |
__r1.push(coconut_react_Html.h("input",__ret2)); | |
} else { | |
var __ret3 = { className : tink_domspec__$ClassName_ClassName_$Impl_$.ofString("description"), onDoubleClick : function(event3) { | |
_gthis.__coco_isEditing.set(true); | |
}}; | |
var __r2 = []; | |
__r2.push(tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.item.observe()).__coco_description)); | |
__r1.push(coconut_react_Html.h("span",__ret3,__r2)); | |
var __ret4 = { className : tink_domspec__$ClassName_ClassName_$Impl_$.ofString("delete"), onClick : function(event4) { | |
(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.ondeleted.observe()))(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.item.observe())); | |
}}; | |
var __r3 = []; | |
__r3.push("Delete"); | |
__r1.push(coconut_react_Html.h("button",__ret4,__r3)); | |
} | |
__r.push(coconut_react_Html.h("li",__ret,__r1)); | |
return __r[0]; | |
} | |
,get_item: function() { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.item.observe()); | |
} | |
,get_ondeleted: function() { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.ondeleted.observe()); | |
} | |
,get_isEditing: function() { | |
return tink_state__$State_State_$Impl_$.get_value(this.__coco_isEditing); | |
} | |
,set_isEditing: function(param) { | |
this.__coco_isEditing.set(param); | |
return param; | |
} | |
,__initAttributes: function(attributes) { | |
this.__slots.item.setData(attributes.item); | |
this.__slots.ondeleted.setData(attributes.ondeleted); | |
} | |
}); | |
var todomvc_ui_TodoListView = function(data) { | |
var this1 = { f : function() { | |
return new todomvc_data_TodoList(); | |
}}; | |
var tmp = tink_state__$Observable_Observable_$Impl_$.auto(this1); | |
var this2 = { f : function() { | |
return new todomvc_data_TodoFilter(); | |
}}; | |
this.__tink_defaults2 = { todos : tmp, filter : tink_state__$Observable_Observable_$Impl_$.auto(this2)}; | |
this.__slots = { todos : new coconut_ui_tools_Slot(this,null), filter : new coconut_ui_tools_Slot(this,null)}; | |
this.__initAttributes(data); | |
var snapshot = null; | |
coconut_ui_View.call(this,$bind(this,this.coconutRender),null,null,null,null,null); | |
}; | |
todomvc_ui_TodoListView.__name__ = true; | |
todomvc_ui_TodoListView.fromHxx = function(attributes) { | |
return React.createElement(react__$ReactNode_ReactNode_$Impl_$.fromComp(todomvc_ui_TodoListView),attributes); | |
}; | |
todomvc_ui_TodoListView.__super__ = coconut_ui_View; | |
todomvc_ui_TodoListView.prototype = $extend(coconut_ui_View.prototype,{ | |
coconutRender: function() { | |
var _gthis = this; | |
var __r = []; | |
var __ret = tink_domspec__$ClassName_ClassName_$Impl_$.ofString("todo-list"); | |
var this1 = tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.todos.observe()).__coco_items); | |
var __ret1 = { className : __ret, "data-empty" : coconut_react__$Html_CustomAttr_$Impl_$.ofBool((this1 == null ? 0 : this1.length) == 0)}; | |
var attributes = __ret1; | |
var __r1 = []; | |
var __r2 = []; | |
__r2.push("todos"); | |
var __ret2 = { }; | |
__r1.push(coconut_react_Html.h("h1",__ret2,__r2)); | |
var __o0 = this; | |
var this2 = { f : function() { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(__o0.__slots.todos.observe()); | |
}}; | |
var __ret3 = { todos : tink_state__$Observable_Observable_$Impl_$.auto(this2)}; | |
__r1.push(todomvc_ui_Header.fromHxx(__ret3)); | |
var this3 = tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()).__coco_items); | |
if((this3 == null ? 0 : this3.length) > 0) { | |
var __r3 = []; | |
var _g = new tink_pure_NodeIterator(tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()).__coco_items)); | |
while(_g.list.length > 0) { | |
var item = [_g.next()]; | |
if(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.filter.observe()).matches(item[0])) { | |
var this4 = { f : (function(item1) { | |
return function() { | |
return item1[0]; | |
}; | |
})(item)}; | |
var __ret4 = tink_state__$Observable_Observable_$Impl_$.auto(this4); | |
var this5 = { f : (function(item2) { | |
return function() { | |
return (function(item3) { | |
return function(event) { | |
tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.todos.observe())["delete"](item3[0]); | |
}; | |
})(item2); | |
}; | |
})(item)}; | |
var __ret5 = { key : item[0].id, item : __ret4, ondeleted : tink_state__$Observable_Observable_$Impl_$.auto(this5)}; | |
__r3.push(todomvc_ui_TodoItemView.fromHxx(__ret5)); | |
} | |
} | |
var __ret6 = { }; | |
__r1.push(coconut_react_Html.h("ol",__ret6,__r3)); | |
var __o01 = this; | |
var this6 = { f : function() { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(__o01.__slots.todos.observe()); | |
}}; | |
var __ret7 = tink_state__$Observable_Observable_$Impl_$.auto(this6); | |
var this7 = { f : function() { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(__o01.__slots.filter.observe()); | |
}}; | |
var __ret8 = { todos : __ret7, filter : tink_state__$Observable_Observable_$Impl_$.auto(this7)}; | |
__r1.push(todomvc_ui_Footer.fromHxx(__ret8)); | |
} | |
__r.push(coconut_react_Html.h("div",attributes,__r1)); | |
return __r[0]; | |
} | |
,get_todos: function() { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()); | |
} | |
,get_filter: function() { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.filter.observe()); | |
} | |
,__initAttributes: function(attributes) { | |
var this1 = attributes.todos; | |
this.__slots.todos.setData(this1 == null ? this.__tink_defaults2.todos : this1); | |
var this2 = attributes.filter; | |
this.__slots.filter.setData(this2 == null ? this.__tink_defaults2.filter : this2); | |
} | |
}); | |
var todomvc_ui_Header = function(data) { | |
var _gthis = this; | |
var this1 = { current : null}; | |
this.input = this1; | |
this.__tink_defaults1 = { }; | |
this.__slots = { todos : new coconut_ui_tools_Slot(this,null)}; | |
this.__initAttributes(data); | |
var snapshot = null; | |
var viewDidMount = function() { | |
_gthis.input.current.focus(); | |
}; | |
coconut_ui_View.call(this,$bind(this,this.coconutRender),null,null,null,viewDidMount,null); | |
}; | |
todomvc_ui_Header.__name__ = true; | |
todomvc_ui_Header.fromHxx = function(attributes) { | |
return React.createElement(react__$ReactNode_ReactNode_$Impl_$.fromComp(todomvc_ui_Header),attributes); | |
}; | |
todomvc_ui_Header.__super__ = coconut_ui_View; | |
todomvc_ui_Header.prototype = $extend(coconut_ui_View.prototype,{ | |
coconutRender: function() { | |
var _gthis = this; | |
var __r = []; | |
var __r1 = []; | |
var __ret = { ref : coconut_ui_tools__$Ref_Ref_$Impl_$.toFunction(_gthis.input), type : "text", placeholder : "What needs to be done?", onKeyPress : function(e) { | |
if(e.which == 13 && e.currentTarget.value != "") { | |
tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.todos.observe()).add(e.currentTarget.value); | |
e.currentTarget.value = ""; | |
} | |
return; | |
}}; | |
__r1.push(coconut_react_Html.h("input",__ret)); | |
var this1 = tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()).__coco_items); | |
if((this1 == null ? 0 : this1.length) > 0) { | |
if(tink_state__$Observable_Observable_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()).__coco_unfinished) > 0) { | |
var __ret1 = { className : tink_domspec__$ClassName_ClassName_$Impl_$.ofString("mark-all"), onClick : function(event) { | |
var _g = new tink_pure_NodeIterator(tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.todos.observe()).__coco_items)); | |
while(_g.list.length > 0) { | |
var i = _g.next(); | |
i.set_completed(true); | |
} | |
}}; | |
var __r2 = []; | |
__r2.push("Mark all as completed"); | |
__r1.push(coconut_react_Html.h("button",__ret1,__r2)); | |
} else { | |
var __ret2 = { className : tink_domspec__$ClassName_ClassName_$Impl_$.ofString("unmark-all"), onClick : function(event1) { | |
var _g1 = new tink_pure_NodeIterator(tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.todos.observe()).__coco_items)); | |
while(_g1.list.length > 0) { | |
var i1 = _g1.next(); | |
i1.set_completed(false); | |
} | |
}}; | |
var __r3 = []; | |
__r3.push("Unmark all as completed"); | |
__r1.push(coconut_react_Html.h("button",__ret2,__r3)); | |
} | |
} | |
var __ret3 = { }; | |
__r.push(coconut_react_Html.h("header",__ret3,__r1)); | |
return __r[0]; | |
} | |
,viewDidMount: function() { | |
this.input.current.focus(); | |
} | |
,get_todos: function() { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()); | |
} | |
,__initAttributes: function(attributes) { | |
this.__slots.todos.setData(attributes.todos); | |
} | |
}); | |
var todomvc_ui_Footer = function(data) { | |
this.__tink_defaults0 = { }; | |
this.__slots = { todos : new coconut_ui_tools_Slot(this,null), filter : new coconut_ui_tools_Slot(this,null)}; | |
this.__initAttributes(data); | |
var snapshot = null; | |
coconut_ui_View.call(this,$bind(this,this.coconutRender),null,null,null,null,null); | |
}; | |
todomvc_ui_Footer.__name__ = true; | |
todomvc_ui_Footer.fromHxx = function(attributes) { | |
return React.createElement(react__$ReactNode_ReactNode_$Impl_$.fromComp(todomvc_ui_Footer),attributes); | |
}; | |
todomvc_ui_Footer.__super__ = coconut_ui_View; | |
todomvc_ui_Footer.prototype = $extend(coconut_ui_View.prototype,{ | |
coconutRender: function() { | |
var _gthis = this; | |
var __r = []; | |
var __r1 = []; | |
var __r2 = []; | |
var _g = tink_state__$Observable_Observable_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()).__coco_unfinished); | |
if(_g == 1) { | |
__r2.push("1 item"); | |
} else { | |
var v = _g; | |
__r2.push(v); | |
__r2.push(" items"); | |
} | |
__r2.push(" left"); | |
var __ret = { }; | |
__r1.push(coconut_react_Html.h("span",__ret,__r2)); | |
var __r3 = []; | |
var _g1 = new tink_pure_NodeIterator(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.filter.observe()).options); | |
while(_g1.list.length > 0) { | |
var f = [_g1.next()]; | |
var __ret1 = { onClick : (function(f1) { | |
return function(event) { | |
tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.filter.observe()).toggle(f1[0].value); | |
}; | |
})(f), "data-active" : coconut_react__$Html_CustomAttr_$Impl_$.ofBool(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.filter.observe()).isActive(f[0].value))}; | |
var __r4 = []; | |
__r4.push(f[0].name); | |
__r3.push(coconut_react_Html.h("button",__ret1,__r4)); | |
} | |
var __ret2 = { }; | |
__r1.push(coconut_react_Html.h("menu",__ret2,__r3)); | |
if(tink_state__$Observable_Observable_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()).__coco_hasAnyCompleted)) { | |
var __ret3 = { onClick : tink_core__$Callback_Callback_$Impl_$.fromNiladic(($_=tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.todos.observe()),$bind($_,$_.clearCompleted)))}; | |
var __r5 = []; | |
__r5.push("Clear Completed"); | |
__r1.push(coconut_react_Html.h("button",__ret3,__r5)); | |
} | |
var __ret4 = { }; | |
__r.push(coconut_react_Html.h("footer",__ret4,__r1)); | |
return __r[0]; | |
} | |
,get_todos: function() { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()); | |
} | |
,get_filter: function() { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.filter.observe()); | |
} | |
,__initAttributes: function(attributes) { | |
this.__slots.todos.setData(attributes.todos); | |
this.__slots.filter.setData(attributes.filter); | |
} | |
}); | |
var $fid = 0; | |
function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $fid++; var f; if( o.hx__closures__ == null ) o.hx__closures__ = {}; else f = o.hx__closures__[m.__id__]; if( f == null ) { f = m.bind(o); o.hx__closures__[m.__id__] = f; } return f; } | |
String.__name__ = true; | |
Array.__name__ = true; | |
Date.__name__ = "Date"; | |
var $$tre = (typeof Symbol === "function" && Symbol.for && Symbol.for("react.element")) || 0xeac7; | |
Object.defineProperty(coconut_react_Renderable.prototype,"props",{ get : function() { | |
return this.__props; | |
}, set : function(attr) { | |
if(attr != null) { | |
this.__props = attr; | |
this.__initAttributes(attr); | |
} | |
}}); | |
haxe_ds_ObjectMap.count = 0; | |
Object.defineProperty(js__$Boot_HaxeError.prototype,"message",{ get : function() { | |
return String(this.val); | |
}}); | |
coconut_ui_View.idCounter = 0; | |
tink_core__$Callback_Callback_$Impl_$.depth = 0; | |
tink_pure__$List_Node.EMPTY = []; | |
tink_state__$Observable_Observable_$Impl_$.stack = new haxe_ds_List(); | |
tink_state__$Observable_Observable_$Impl_$.scheduled = []; | |
tink_state__$Observable_Observable_$Impl_$.hasRAF = typeof window != 'undefined' && 'requestAnimationFrame' in window; | |
tink_state__$Observable_Observable_$Impl_$.isScheduled = false; | |
tink_state_ConstObservable.NEVER = (function($this) { | |
var $r; | |
var this1 = new tink_core__$Future_SimpleFuture(function(_) { | |
return null; | |
}); | |
$r = this1; | |
return $r; | |
}(this)); | |
todomvc_data_TodoItem.idCounter = 0; | |
TodoMvc.main(); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Generated by Haxe 4.0.0-preview.5+7eb789f54 | |
(function () { "use strict"; | |
var $estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_; | |
function $extend(from, fields) { | |
var proto = Object.create(from); | |
for (var name in fields) proto[name] = fields[name]; | |
if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString; | |
return proto; | |
}var HxOverrides = function() { }; | |
HxOverrides.__name__ = true; | |
HxOverrides.cca = function(s,index) { | |
var x = s.charCodeAt(index); | |
if(x != x) { | |
return undefined; | |
} | |
return x; | |
}; | |
HxOverrides.substr = function(s,pos,len) { | |
if(len == null) { | |
len = s.length; | |
} else if(len < 0) { | |
if(pos == 0) { | |
len = s.length + len; | |
} else { | |
return ""; | |
} | |
} | |
return s.substr(pos,len); | |
}; | |
HxOverrides.remove = function(a,obj) { | |
var i = a.indexOf(obj); | |
if(i == -1) { | |
return false; | |
} | |
a.splice(i,1); | |
return true; | |
}; | |
Math.__name__ = true; | |
var Reflect = function() { }; | |
Reflect.__name__ = true; | |
Reflect.fields = function(o) { | |
var a = []; | |
if(o != null) { | |
var hasOwnProperty = Object.prototype.hasOwnProperty; | |
for( var f in o ) { | |
if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) { | |
a.push(f); | |
} | |
} | |
} | |
return a; | |
}; | |
var Std = function() { }; | |
Std.__name__ = true; | |
Std.string = function(s) { | |
return js_Boot.__string_rec(s,""); | |
}; | |
Std.parseInt = function(x) { | |
var v = parseInt(x, x && x[0]=="0" && (x[1]=="x" || x[1]=="X") ? 16 : 10); | |
if(isNaN(v)) { | |
return null; | |
} | |
return v; | |
}; | |
var StringTools = function() { }; | |
StringTools.__name__ = true; | |
StringTools.isSpace = function(s,pos) { | |
var c = HxOverrides.cca(s,pos); | |
if(!(c > 8 && c < 14)) { | |
return c == 32; | |
} else { | |
return true; | |
} | |
}; | |
StringTools.ltrim = function(s) { | |
var l = s.length; | |
var r = 0; | |
while(r < l && StringTools.isSpace(s,r)) ++r; | |
if(r > 0) { | |
return HxOverrides.substr(s,r,l - r); | |
} else { | |
return s; | |
} | |
}; | |
StringTools.rtrim = function(s) { | |
var l = s.length; | |
var r = 0; | |
while(r < l && StringTools.isSpace(s,l - r - 1)) ++r; | |
if(r > 0) { | |
return HxOverrides.substr(s,0,l - r); | |
} else { | |
return s; | |
} | |
}; | |
StringTools.trim = function(s) { | |
return StringTools.ltrim(StringTools.rtrim(s)); | |
}; | |
var TodoMvc = function() { }; | |
TodoMvc.__name__ = true; | |
TodoMvc.main = function() { | |
var list = new todomvc_data_TodoList(); | |
var _g = 0; | |
var _g1 = Std.parseInt(HxOverrides.substr(window.location.hash,1,null)); | |
while(_g < _g1) { | |
var i = _g++; | |
list.add("item " + i); | |
} | |
var __r = []; | |
var this1 = { f : function() { | |
return list; | |
}}; | |
var __ret = { todos : tink_state__$Observable_Observable_$Impl_$.auto(this1)}; | |
__r.push(todomvc_ui_TodoListView.fromHxx(__ret)); | |
coconut_vdom__$Child_Child_$Impl_$.renderInto(__r[0],window.document.body.appendChild(window.document.createElement("div"))); | |
}; | |
var coconut_data_Model = function() { }; | |
coconut_data_Model.__name__ = true; | |
var coconut_diffing_Differ = function() { }; | |
coconut_diffing_Differ.__name__ = true; | |
coconut_diffing_Differ.prototype = { | |
_renderAll: function(nodes,later,$with) { | |
var byType = new haxe_ds_StringMap(); | |
var childList = []; | |
if(nodes != null) { | |
var _g = 0; | |
while(_g < nodes.length) { | |
var n = [nodes[_g]]; | |
++_g; | |
var key = n[0].type; | |
var _g1 = __map_reserved[key] != null ? byType.getReserved(key) : byType.h[key]; | |
var registry; | |
if(_g1 == null) { | |
var k = n[0].type; | |
var v = new coconut_diffing_TypeRegistry(); | |
if(__map_reserved[k] != null) { | |
byType.setReserved(k,v); | |
} else { | |
byType.h[k] = v; | |
} | |
registry = v; | |
} else { | |
var v1 = _g1; | |
registry = v1; | |
} | |
var registry1 = [registry]; | |
var add = (function(registry2,n1) { | |
return function(r,kind) { | |
if(n1[0].ref != null) { | |
var add1 = (function(n2) { | |
return function() { | |
n2[0].ref(r); | |
}; | |
})(n1); | |
later(add1); | |
} | |
var n3 = new coconut_diffing_NodeOf(n1[0].key,n1[0].type,n1[0].ref,kind); | |
var _g11 = n3.key; | |
if(_g11 == null) { | |
registry2[0].put(n3); | |
} else { | |
var k1 = _g11; | |
registry2[0].set(k1,n3); | |
} | |
childList.push(n3); | |
}; | |
})(registry1,n); | |
var _g12 = n[0].kind; | |
switch(_g12._hx_index) { | |
case 0: | |
var v2 = _g12.n; | |
var r1 = $with.native(n[0].type,n[0].key,v2); | |
add(r1,coconut_diffing_RNodeKind.RNative(v2,r1)); | |
break; | |
case 1: | |
var t = _g12.t; | |
var a = _g12.a; | |
var w = $with.widget(n[0].type,n[0].key,a,t); | |
add(w,coconut_diffing_RNodeKind.RWidget(w)); | |
break; | |
} | |
} | |
} | |
return new coconut_diffing_Rendered(byType,childList); | |
} | |
,renderAll: function(nodes,parent,later) { | |
var _gthis = this; | |
return this._renderAll(nodes,later,{ native : function(type,_,v) { | |
return _gthis.createNative(type,v,parent,later); | |
}, widget : function(_1,_2,a,t) { | |
return _gthis.createWidget(t,a,parent,later); | |
}}); | |
} | |
,createWidget: function(t,a,parent,later) { | |
var ret = t.create(a); | |
ret._coco_initialize(this,parent,later); | |
return ret; | |
} | |
,updateAll: function(before,nodes,parent,later) { | |
var _gthis = this; | |
var _this = before.byType; | |
var registry = new haxe_ds__$StringMap_StringMapIterator(_this,_this.arrayKeys()); | |
while(registry.hasNext()) { | |
var registry1 = registry.next(); | |
if(registry1.keyed != null) { | |
var _this1 = registry1.keyed; | |
var v = new haxe_ds__$StringMap_StringMapIterator(_this1,_this1.arrayKeys()); | |
while(v.hasNext()) { | |
var v1 = v.next(); | |
if(v1.ref != null) { | |
var f = v1.ref; | |
f(null); | |
} | |
} | |
} | |
if(registry1.unkeyed != null) { | |
var _g = 0; | |
var _g1 = registry1.unkeyed; | |
while(_g < _g1.length) { | |
var v2 = _g1[_g]; | |
++_g; | |
if(v2.ref != null) { | |
var f1 = v2.ref; | |
f1(null); | |
} | |
} | |
} | |
} | |
var previous = function(t,key) { | |
var _this2 = before.byType; | |
var _g2 = __map_reserved[t] != null ? _this2.getReserved(t) : _this2.h[t]; | |
if(_g2 == null) { | |
return null; | |
} else { | |
var v3 = _g2; | |
if(key == null) { | |
return v3.pull(); | |
} else { | |
return v3.get(key); | |
} | |
} | |
}; | |
var after = this._renderAll(nodes,later,{ native : function(type,key1,nu) { | |
var _g3 = previous(type,key1); | |
if(_g3 == null) { | |
return _gthis.createNative(type,nu,parent,later); | |
} else if(_g3.kind._hx_index == 0) { | |
var r = _g3.kind.r; | |
var old = _g3.kind.n; | |
_gthis.updateNative(r,nu,old,parent,later); | |
return r; | |
} else { | |
throw new js__$Boot_HaxeError("assert"); | |
} | |
}, widget : function(type1,key2,attr,widgetType) { | |
var _g4 = previous(type1,key2); | |
if(_g4 == null) { | |
return _gthis.createWidget(widgetType,attr,parent,later); | |
} else if(_g4.kind._hx_index == 1) { | |
var w = _g4.kind.w; | |
widgetType.update(attr,w); | |
return w; | |
} else { | |
throw new js__$Boot_HaxeError("assert"); | |
} | |
}}); | |
var _this3 = before.byType; | |
var registry2 = new haxe_ds__$StringMap_StringMapIterator(_this3,_this3.arrayKeys()); | |
while(registry2.hasNext()) { | |
var registry3 = registry2.next(); | |
var f2 = $bind(this,this.destroyRender); | |
if(registry3.keyed != null) { | |
var _this4 = registry3.keyed; | |
var v4 = new haxe_ds__$StringMap_StringMapIterator(_this4,_this4.arrayKeys()); | |
while(v4.hasNext()) { | |
var v5 = v4.next(); | |
f2(v5); | |
} | |
} | |
if(registry3.unkeyed != null) { | |
var _g5 = 0; | |
var _g11 = registry3.unkeyed; | |
while(_g5 < _g11.length) { | |
var v6 = _g11[_g5]; | |
++_g5; | |
f2(v6); | |
} | |
} | |
} | |
return after; | |
} | |
,destroyRender: function(r) { | |
var _g = r.kind; | |
switch(_g._hx_index) { | |
case 0: | |
var r1 = _g.r; | |
this.unsetLastRender(r1); | |
this.destroyNative(r1); | |
break; | |
case 1: | |
var w = _g.w; | |
w._coco_teardown(); | |
break; | |
} | |
} | |
,destroyNative: function(n) { | |
throw new js__$Boot_HaxeError("abstract"); | |
} | |
,_render: function(nodes,target,parent,later) { | |
var ret; | |
var _g = this.getLastRender(target); | |
if(_g == null) { | |
ret = this.renderAll(nodes,parent,later); | |
} else { | |
var v = _g; | |
ret = this.updateAll(v,nodes,parent,later); | |
} | |
this.setLastRender(target,ret); | |
this.setChildren(target,this.flatten(ret.childList,later)); | |
return ret; | |
} | |
,setChildren: function(target,children) { | |
throw new js__$Boot_HaxeError("abstract"); | |
} | |
,flatten: function(children,later) { | |
var ret = []; | |
var rec = null; | |
rec = function(children1) { | |
var _g = 0; | |
while(_g < children1.length) { | |
var c = children1[_g]; | |
++_g; | |
var _g1 = c.kind; | |
switch(_g1._hx_index) { | |
case 0: | |
var r = _g1.r; | |
ret.push(r); | |
break; | |
case 1: | |
var w = _g1.w; | |
rec(w._coco_getRender(later).childList); | |
break; | |
} | |
} | |
}; | |
rec(children); | |
return ret; | |
} | |
,render: function(virtual,target) { | |
var f = $bind(this,this._render); | |
var nodes = virtual; | |
var target1 = target; | |
this.run(function(later) { | |
return f(nodes,target1,null,later); | |
}); | |
} | |
,run: function(f) { | |
var after = []; | |
var ret = f(function(later) { | |
if(later != null) { | |
after.push(later); | |
} | |
}); | |
var _g = 0; | |
while(_g < after.length) { | |
var f1 = after[_g]; | |
++_g; | |
f1(); | |
} | |
return ret; | |
} | |
,unsetLastRender: function(target) { | |
throw new js__$Boot_HaxeError("abstract"); | |
} | |
,setLastRender: function(target,r) { | |
throw new js__$Boot_HaxeError("abstract"); | |
} | |
,getLastRender: function(target) { | |
throw new js__$Boot_HaxeError("abstract"); | |
} | |
,updateNative: function(real,nu,old,parent,later) { | |
throw new js__$Boot_HaxeError("abstract"); | |
} | |
,createNative: function(type,n,parent,later) { | |
throw new js__$Boot_HaxeError("abstract"); | |
} | |
,setField: function(target,name,newVal,oldVal) { | |
target[name] = newVal; | |
} | |
}; | |
var coconut_diffing_NodeOf = function(key,type,ref,kind) { | |
this.key = key; | |
this.type = type; | |
this.ref = ref; | |
this.kind = kind; | |
}; | |
coconut_diffing_NodeOf.__name__ = true; | |
var coconut_diffing_Parent = function() { }; | |
coconut_diffing_Parent.__name__ = true; | |
var coconut_diffing_RNodeKind = $hxEnums["coconut.diffing.RNodeKind"] = { __ename__ : true, __constructs__ : ["RNative","RWidget"] | |
,RNative: ($_=function(n,r) { return {_hx_index:0,n:n,r:r,__enum__:"coconut.diffing.RNodeKind",toString:$estr}; },$_.__params__ = ["n","r"],$_) | |
,RWidget: ($_=function(w) { return {_hx_index:1,w:w,__enum__:"coconut.diffing.RNodeKind",toString:$estr}; },$_.__params__ = ["w"],$_) | |
}; | |
var coconut_diffing_Rendered = function(byType,childList) { | |
this.byType = byType; | |
this.childList = childList; | |
}; | |
coconut_diffing_Rendered.__name__ = true; | |
var coconut_diffing_TypeRegistry = function() { | |
}; | |
coconut_diffing_TypeRegistry.__name__ = true; | |
coconut_diffing_TypeRegistry.prototype = { | |
get: function(key) { | |
if(this.keyed == null) { | |
return null; | |
} else { | |
var _this = this.keyed; | |
var ret = __map_reserved[key] != null ? _this.getReserved(key) : _this.h[key]; | |
if(ret != null) { | |
this.keyed.remove(key); | |
} | |
return ret; | |
} | |
} | |
,set: function(key,value) { | |
if(this.keyed == null) { | |
var this1 = new haxe_ds_StringMap(); | |
this.keyed = this1; | |
} | |
var _this = this.keyed; | |
if(__map_reserved[key] != null ? _this.existsReserved(key) : _this.h.hasOwnProperty(key)) { | |
throw new js__$Boot_HaxeError("duplicate key " + key); | |
} | |
var _this1 = this.keyed; | |
if(__map_reserved[key] != null) { | |
_this1.setReserved(key,value); | |
} else { | |
_this1.h[key] = value; | |
} | |
} | |
,put: function(v) { | |
if(this.unkeyed == null) { | |
this.unkeyed = []; | |
} | |
this.unkeyed.push(v); | |
} | |
,pull: function() { | |
if(this.unkeyed == null) { | |
return null; | |
} else { | |
return this.unkeyed.shift(); | |
} | |
} | |
}; | |
var coconut_diffing_VNodeKind = $hxEnums["coconut.diffing.VNodeKind"] = { __ename__ : true, __constructs__ : ["VNative","VWidget"] | |
,VNative: ($_=function(n) { return {_hx_index:0,n:n,__enum__:"coconut.diffing.VNodeKind",toString:$estr}; },$_.__params__ = ["n"],$_) | |
,VWidget: ($_=function(a,t) { return {_hx_index:1,a:a,t:t,__enum__:"coconut.diffing.VNodeKind",toString:$estr}; },$_.__params__ = ["a","t"],$_) | |
}; | |
var coconut_diffing_Widget = function(rendered,mounted,updated,unmounting) { | |
this._coco_invalid = false; | |
this._coco_vStructure = tink_state__$Observable_Observable_$Impl_$.map(rendered,tink_state__$Observable_Transform_$Impl_$.plain(function(r) { | |
return [r]; | |
})); | |
this._coco_viewMounted = mounted; | |
this._coco_viewUpdated = updated; | |
this._coco_viewUnmounting = unmounting; | |
}; | |
coconut_diffing_Widget.__name__ = true; | |
coconut_diffing_Widget.__interfaces__ = [coconut_diffing_Parent]; | |
coconut_diffing_Widget.defer = function(f) { | |
tink_core__$Callback_Callback_$Impl_$.defer(f); | |
}; | |
coconut_diffing_Widget.prototype = { | |
_coco_getRender: function(later) { | |
if(this._coco_invalid) { | |
this._coco_invalid = false; | |
var nuSnapshot = this._coco_vStructure.poll().a; | |
if(nuSnapshot != this._coco_lastSnapshot) { | |
this._coco_lastSnapshot = nuSnapshot; | |
this._coco_lastRender = this._coco_differ.updateAll(this._coco_lastRender,nuSnapshot,this,later); | |
this._coco_arm(); | |
later(this._coco_viewUpdated); | |
} | |
} | |
return this._coco_lastRender; | |
} | |
,_coco_invalidate: function() { | |
if(!this._coco_invalid) { | |
this._coco_invalid = true; | |
if(this._coco_parent != null) { | |
this._coco_parent._coco_invalidate(); | |
} | |
coconut_diffing_Widget.defer($bind(this,this._coco_update)); | |
} | |
} | |
,_coco_update: function() { | |
var _gthis = this; | |
if(this._coco_invalid) { | |
this._coco_differ.run(function(later) { | |
_gthis._coco_getRender(later); | |
}); | |
} | |
} | |
,_coco_arm: function() { | |
var this1 = this._coco_link; | |
if(this1 != null) { | |
this1.dissolve(); | |
} | |
this._coco_link = this._coco_vStructure.poll().b.handle(tink_core__$Callback_Callback_$Impl_$.fromNiladic($bind(this,this._coco_invalidate))); | |
} | |
,_coco_teardown: function() { | |
this._coco_viewUnmounting(); | |
var _g = 0; | |
var _g1 = this._coco_lastRender.childList; | |
while(_g < _g1.length) { | |
var c = _g1[_g]; | |
++_g; | |
this._coco_differ.destroyRender(c); | |
} | |
} | |
,_coco_initialize: function(differ,parent,later) { | |
this._coco_parent = parent; | |
this._coco_differ = differ; | |
this._coco_lastRender = differ.renderAll(this._coco_lastSnapshot = this._coco_vStructure.poll().a,parent,later); | |
this._coco_arm(); | |
later(this._coco_viewMounted); | |
} | |
}; | |
var coconut_ui_View = function(render,shouldUpdate,track,beforeRerender,mounted,updated) { | |
this.__au = []; | |
this.__bc = []; | |
this.__bu = []; | |
this.__revisionCounter = new tink_state__$State_SimpleState(0,null,null); | |
this.viewId = coconut_ui_View.idCounter++; | |
var _gthis = this; | |
var firstTime = true; | |
var last = null; | |
var hasBeforeRerender = beforeRerender != null; | |
var hasUpdated = updated != null; | |
var lastRev = tink_state__$State_State_$Impl_$.get_value(this.__revisionCounter); | |
var renderView = function() { | |
var curRev = tink_state__$State_State_$Impl_$.get_value(_gthis.__revisionCounter); | |
if(track != null) { | |
track(); | |
} | |
if(firstTime) { | |
firstTime = false; | |
} else { | |
if(curRev == lastRev && shouldUpdate != null && !shouldUpdate()) { | |
return last; | |
} | |
var hasCallbacks = _gthis.__bc.length > 0; | |
if(hasBeforeRerender || hasCallbacks) { | |
tink_state__$Observable_Observable_$Impl_$.untracked(function() { | |
if(hasBeforeRerender) { | |
beforeRerender(); | |
} | |
if(hasCallbacks) { | |
var _g = 0; | |
var _g1 = _gthis.__bc.splice(0,_gthis.__bc.length); | |
while(_g < _g1.length) { | |
var c = _g1[_g]; | |
++_g; | |
tink_core__$Callback_Callback_$Impl_$.invoke(c,false); | |
} | |
} | |
}); | |
} | |
} | |
lastRev = curRev; | |
last = render(); | |
return last; | |
}; | |
var this1 = { f : renderView}; | |
coconut_diffing_Widget.call(this,tink_state__$Observable_Observable_$Impl_$.auto(this1),mounted,function() { | |
var hasCallbacks1 = _gthis.__au.length > 0; | |
if(hasUpdated || hasCallbacks1) { | |
tink_state__$Observable_Observable_$Impl_$.untracked(function() { | |
if(hasUpdated) { | |
updated(); | |
} | |
if(hasCallbacks1) { | |
var _g2 = 0; | |
var _g11 = _gthis.__au.splice(0,_gthis.__au.length); | |
while(_g2 < _g11.length) { | |
var c1 = _g11[_g2]; | |
++_g2; | |
tink_core__$Callback_Callback_$Impl_$.invoke(c1,tink_core_Noise.Noise); | |
} | |
} | |
}); | |
} | |
},$bind(this,this.__beforeUnmount)); | |
}; | |
coconut_ui_View.__name__ = true; | |
coconut_ui_View.__super__ = coconut_diffing_Widget; | |
coconut_ui_View.prototype = $extend(coconut_diffing_Widget.prototype,{ | |
__beforeUnmount: function() { | |
var _g = 0; | |
var _g1 = this.__bu.splice(0,this.__bu.length); | |
while(_g < _g1.length) { | |
var c = _g1[_g]; | |
++_g; | |
if(c != null) { | |
c.dissolve(); | |
} | |
} | |
var _g2 = 0; | |
var _g3 = this.__bc.splice(0,this.__bu.length); | |
while(_g2 < _g3.length) { | |
var c1 = _g3[_g2]; | |
++_g2; | |
tink_core__$Callback_Callback_$Impl_$.invoke(c1,true); | |
} | |
} | |
}); | |
var coconut_ui_tools__$Ref_Ref_$Impl_$ = {}; | |
coconut_ui_tools__$Ref_Ref_$Impl_$.__name__ = true; | |
coconut_ui_tools__$Ref_Ref_$Impl_$.toFunction = function(this1) { | |
return function(value) { | |
return this1.current = value; | |
}; | |
}; | |
var tink_state_ObservableObject = function() { }; | |
tink_state_ObservableObject.__name__ = true; | |
var coconut_ui_tools_Slot = function(owner,compare) { | |
this.owner = owner; | |
var tmp; | |
if(compare == null) { | |
tmp = function(a,b) { | |
return a == b; | |
}; | |
} else { | |
var v = compare; | |
tmp = v; | |
} | |
this.compare = tmp; | |
}; | |
coconut_ui_tools_Slot.__name__ = true; | |
coconut_ui_tools_Slot.__interfaces__ = [tink_state_ObservableObject]; | |
coconut_ui_tools_Slot.prototype = { | |
poll: function() { | |
var _gthis = this; | |
if(this.last == null) { | |
if(this.data == null) { | |
var this1 = new tink_core_MPair(null,new tink_core_FutureTrigger()); | |
this.last = this1; | |
} else { | |
var m = tink_state__$Observable_Observable_$Impl_$.measure(this.data); | |
var this2 = new tink_core_MPair(m.a,new tink_core_FutureTrigger()); | |
this.last = this2; | |
this.link = m.b.handle(($_=this.last.b,$bind($_,$_.trigger))); | |
} | |
this.last.b.handle(tink_core__$Callback_Callback_$Impl_$.fromNiladic(function() { | |
_gthis.last = null; | |
})); | |
} | |
var this3 = new tink_core_MPair(this.last.a,this.last.b); | |
var this4 = this3; | |
return this4; | |
} | |
,observe: function() { | |
return this; | |
} | |
,setData: function(data) { | |
this.data = data; | |
if(this.last != null) { | |
var this1 = this.link; | |
if(this1 != null) { | |
this1.dissolve(); | |
} | |
if(data != null) { | |
var _e = data; | |
var m = tink_state__$Observable_Observable_$Impl_$.untracked(function() { | |
return tink_state__$Observable_Observable_$Impl_$.measure(_e); | |
}); | |
if(this.compare(m.a,this.last.a)) { | |
this.link = m.b.handle(($_=this.last.b,$bind($_,$_.trigger))); | |
} else { | |
this.last.b.trigger(tink_core_Noise.Noise); | |
} | |
} | |
} | |
} | |
}; | |
var coconut_vdom__$Child_DomDiffer = function() { | |
}; | |
coconut_vdom__$Child_DomDiffer.__name__ = true; | |
coconut_vdom__$Child_DomDiffer.__super__ = coconut_diffing_Differ; | |
coconut_vdom__$Child_DomDiffer.prototype = $extend(coconut_diffing_Differ.prototype,{ | |
unsetLastRender: function(target) { | |
target._coco_ = null; | |
} | |
,getLastRender: function(target) { | |
return target._coco_; | |
} | |
,setLastRender: function(target,r) { | |
target._coco_ = r; | |
} | |
,setChildren: function(target,children) { | |
var e = target; | |
if(children == null) { | |
e.innerHTML = ""; | |
} else { | |
var pos = 0; | |
var _g = 0; | |
while(_g < children.length) { | |
var nu = children[_g]; | |
++_g; | |
var old = e.childNodes[pos++]; | |
if(old != nu) { | |
e.insertBefore(nu,old); | |
} | |
} | |
var _g1 = pos; | |
var _g2 = e.childNodes.length; | |
while(_g1 < _g2) { | |
var i = _g1++; | |
e.removeChild(e.childNodes[pos]); | |
} | |
} | |
} | |
,updateNative: function(real,nu,old,parent,later) { | |
if(real.nodeType == 3) { | |
var text = nu.attributes.text; | |
if(text != old.attributes.text) { | |
real.nodeValue = text; | |
} | |
} else { | |
var elt = real; | |
var newProps = nu.attributes; | |
var oldProps = old.attributes; | |
var updateProp = $bind(this,this.setProp); | |
if(newProps != oldProps) { | |
var this1 = { }; | |
var keys = this1; | |
if(newProps == null) { | |
newProps = coconut_diffing_Differ.EMPTY; | |
} | |
if(oldProps == null) { | |
oldProps = coconut_diffing_Differ.EMPTY; | |
} | |
var _g = 0; | |
var _g1 = Reflect.fields(newProps); | |
while(_g < _g1.length) { | |
var key = _g1[_g]; | |
++_g; | |
keys[key] = true; | |
} | |
var _g2 = 0; | |
var _g3 = Reflect.fields(oldProps); | |
while(_g2 < _g3.length) { | |
var key1 = _g3[_g2]; | |
++_g2; | |
keys[key1] = true; | |
} | |
var _g4 = 0; | |
var _g5 = Reflect.fields(keys); | |
while(_g4 < _g5.length) { | |
var key2 = _g5[_g4]; | |
++_g4; | |
var _g41 = oldProps[key2]; | |
var _g51 = newProps[key2]; | |
if(_g51 == null) { | |
var b = _g41; | |
var a = _g51; | |
if(a != b) { | |
var old1 = _g41; | |
var nu1 = _g51; | |
updateProp(elt,key2,nu1,old1); | |
} | |
} else { | |
var b1 = _g41; | |
var a1 = _g51; | |
if(a1 != b1) { | |
var old2 = _g41; | |
var nu2 = _g51; | |
updateProp(elt,key2,nu2,old2); | |
} | |
} | |
} | |
} | |
this._render(nu.children,elt,parent,later); | |
} | |
} | |
,createNative: function(tag,vdom,parent,later) { | |
if(tag == "") { | |
return window.document.createTextNode(vdom.attributes.text); | |
} else { | |
var other = tag; | |
var elt = window.document.createElement(tag); | |
var newProps = vdom.attributes; | |
var oldProps = null; | |
var updateProp = $bind(this,this.setProp); | |
if(newProps != oldProps) { | |
var this1 = { }; | |
var keys = this1; | |
if(newProps == null) { | |
newProps = coconut_diffing_Differ.EMPTY; | |
} | |
if(oldProps == null) { | |
oldProps = coconut_diffing_Differ.EMPTY; | |
} | |
var _g = 0; | |
var _g1 = Reflect.fields(newProps); | |
while(_g < _g1.length) { | |
var key = _g1[_g]; | |
++_g; | |
keys[key] = true; | |
} | |
var _g2 = 0; | |
var _g3 = Reflect.fields(oldProps); | |
while(_g2 < _g3.length) { | |
var key1 = _g3[_g2]; | |
++_g2; | |
keys[key1] = true; | |
} | |
var _g4 = 0; | |
var _g5 = Reflect.fields(keys); | |
while(_g4 < _g5.length) { | |
var key2 = _g5[_g4]; | |
++_g4; | |
var _g41 = oldProps[key2]; | |
var _g51 = newProps[key2]; | |
if(_g51 == null) { | |
var b = _g41; | |
var a = _g51; | |
if(a != b) { | |
var old = _g41; | |
var nu = _g51; | |
updateProp(elt,key2,nu,old); | |
} | |
} else { | |
var b1 = _g41; | |
var a1 = _g51; | |
if(a1 != b1) { | |
var old1 = _g41; | |
var nu1 = _g51; | |
updateProp(elt,key2,nu1,old1); | |
} | |
} | |
} | |
} | |
this._render(vdom.children,elt,parent,later); | |
return elt; | |
} | |
} | |
,destroyNative: function(n) { | |
var _g = this.getLastRender(n); | |
if(_g != null) { | |
var r = _g; | |
var _g1 = 0; | |
var _g11 = r.childList; | |
while(_g1 < _g11.length) { | |
var c = _g11[_g1]; | |
++_g1; | |
this.destroyRender(c); | |
} | |
} | |
var _g12 = n.parentNode; | |
if(_g12 != null) { | |
var p = _g12; | |
p.removeChild(n); | |
} | |
} | |
,setProp: function(element,name,newVal,oldVal) { | |
switch(name) { | |
case "attributes": | |
var newProps = newVal; | |
var oldProps = oldVal; | |
var updateProp = $bind(this,this.updateAttribute); | |
if(newProps != oldProps) { | |
var this1 = { }; | |
var keys = this1; | |
if(newProps == null) { | |
newProps = coconut_diffing_Differ.EMPTY; | |
} | |
if(oldProps == null) { | |
oldProps = coconut_diffing_Differ.EMPTY; | |
} | |
var _g = 0; | |
var _g1 = Reflect.fields(newProps); | |
while(_g < _g1.length) { | |
var key = _g1[_g]; | |
++_g; | |
keys[key] = true; | |
} | |
var _g2 = 0; | |
var _g3 = Reflect.fields(oldProps); | |
while(_g2 < _g3.length) { | |
var key1 = _g3[_g2]; | |
++_g2; | |
keys[key1] = true; | |
} | |
var _g4 = 0; | |
var _g5 = Reflect.fields(keys); | |
while(_g4 < _g5.length) { | |
var key2 = _g5[_g4]; | |
++_g4; | |
var _g41 = oldProps[key2]; | |
var _g51 = newProps[key2]; | |
if(_g51 == null) { | |
var b = _g41; | |
var a = _g51; | |
if(a != b) { | |
var old = _g41; | |
var nu = _g51; | |
updateProp(element,key2,nu,old); | |
} | |
} else { | |
var b1 = _g41; | |
var a1 = _g51; | |
if(a1 != b1) { | |
var old1 = _g41; | |
var nu1 = _g51; | |
updateProp(element,key2,nu1,old1); | |
} | |
} | |
} | |
} | |
break; | |
case "key":case "ref": | |
break; | |
case "style": | |
var element1 = element.style; | |
var newProps1 = newVal; | |
var oldProps1 = oldVal; | |
var updateProp1 = $bind(this,this.setField); | |
if(newProps1 != oldProps1) { | |
var this2 = { }; | |
var keys1 = this2; | |
if(newProps1 == null) { | |
newProps1 = coconut_diffing_Differ.EMPTY; | |
} | |
if(oldProps1 == null) { | |
oldProps1 = coconut_diffing_Differ.EMPTY; | |
} | |
var _g6 = 0; | |
var _g11 = Reflect.fields(newProps1); | |
while(_g6 < _g11.length) { | |
var key3 = _g11[_g6]; | |
++_g6; | |
keys1[key3] = true; | |
} | |
var _g21 = 0; | |
var _g31 = Reflect.fields(oldProps1); | |
while(_g21 < _g31.length) { | |
var key4 = _g31[_g21]; | |
++_g21; | |
keys1[key4] = true; | |
} | |
var _g42 = 0; | |
var _g52 = Reflect.fields(keys1); | |
while(_g42 < _g52.length) { | |
var key5 = _g52[_g42]; | |
++_g42; | |
var _g43 = oldProps1[key5]; | |
var _g53 = newProps1[key5]; | |
if(_g53 == null) { | |
var b2 = _g43; | |
var a2 = _g53; | |
if(a2 != b2) { | |
var old2 = _g43; | |
var nu2 = _g53; | |
updateProp1(element1,key5,nu2,old2); | |
} | |
} else { | |
var b3 = _g43; | |
var a3 = _g53; | |
if(a3 != b3) { | |
var old3 = _g43; | |
var nu3 = _g53; | |
updateProp1(element1,key5,nu3,old3); | |
} | |
} | |
} | |
} | |
break; | |
default: | |
if(newVal == null) { | |
delete element[name]; | |
} else { | |
element[name] = newVal; | |
} | |
} | |
} | |
,updateAttribute: function(element,name,newVal,oldVal) { | |
if(newVal == null) { | |
element.removeAttribute(name); | |
} else { | |
element.setAttribute(name,newVal); | |
} | |
} | |
}); | |
var coconut_vdom__$Child_Child_$Impl_$ = {}; | |
coconut_vdom__$Child_Child_$Impl_$.__name__ = true; | |
coconut_vdom__$Child_Child_$Impl_$.element = function(tag,attr,children) { | |
var this1 = new coconut_diffing_NodeOf(attr.key,tag,attr.ref,coconut_diffing_VNodeKind.VNative({ attributes : attr, children : children})); | |
return this1; | |
}; | |
coconut_vdom__$Child_Child_$Impl_$.ofText = function(s) { | |
return coconut_vdom__$Child_Child_$Impl_$.element("",{ text : s}); | |
}; | |
coconut_vdom__$Child_Child_$Impl_$.ofInt = function(i) { | |
return coconut_vdom__$Child_Child_$Impl_$.ofText(i == null ? "null" : "" + i); | |
}; | |
coconut_vdom__$Child_Child_$Impl_$.widget = function(name,key,ref,attr,type) { | |
var this1 = new coconut_diffing_NodeOf(key,name,ref,coconut_diffing_VNodeKind.VWidget(attr,type)); | |
return this1; | |
}; | |
coconut_vdom__$Child_Child_$Impl_$.renderInto = function(this1,target) { | |
coconut_vdom__$Child_Child_$Impl_$.differ.render([this1],target); | |
}; | |
var haxe_IMap = function() { }; | |
haxe_IMap.__name__ = true; | |
var haxe_Timer = function(time_ms) { | |
var me = this; | |
this.id = setInterval(function() { | |
me.run(); | |
},time_ms); | |
}; | |
haxe_Timer.__name__ = true; | |
haxe_Timer.delay = function(f,time_ms) { | |
var t = new haxe_Timer(time_ms); | |
t.run = function() { | |
t.stop(); | |
f(); | |
}; | |
return t; | |
}; | |
haxe_Timer.prototype = { | |
stop: function() { | |
if(this.id == null) { | |
return; | |
} | |
clearInterval(this.id); | |
this.id = null; | |
} | |
,run: function() { | |
} | |
}; | |
var haxe_ds_List = function() { | |
this.length = 0; | |
}; | |
haxe_ds_List.__name__ = true; | |
haxe_ds_List.prototype = { | |
push: function(item) { | |
var x = new haxe_ds__$List_ListNode(item,this.h); | |
this.h = x; | |
if(this.q == null) { | |
this.q = x; | |
} | |
this.length++; | |
} | |
,first: function() { | |
if(this.h == null) { | |
return null; | |
} else { | |
return this.h.item; | |
} | |
} | |
,pop: function() { | |
if(this.h == null) { | |
return null; | |
} | |
var x = this.h.item; | |
this.h = this.h.next; | |
if(this.h == null) { | |
this.q = null; | |
} | |
this.length--; | |
return x; | |
} | |
}; | |
var haxe_ds__$List_ListNode = function(item,next) { | |
this.item = item; | |
this.next = next; | |
}; | |
haxe_ds__$List_ListNode.__name__ = true; | |
var haxe_ds_ObjectMap = function() { | |
this.h = { __keys__ : { }}; | |
}; | |
haxe_ds_ObjectMap.__name__ = true; | |
haxe_ds_ObjectMap.__interfaces__ = [haxe_IMap]; | |
haxe_ds_ObjectMap.prototype = { | |
set: function(key,value) { | |
var id = key.__id__ || (key.__id__ = ++haxe_ds_ObjectMap.count); | |
this.h[id] = value; | |
this.h.__keys__[id] = key; | |
} | |
}; | |
var haxe_ds__$StringMap_StringMapIterator = function(map,keys) { | |
this.map = map; | |
this.keys = keys; | |
this.index = 0; | |
this.count = keys.length; | |
}; | |
haxe_ds__$StringMap_StringMapIterator.__name__ = true; | |
haxe_ds__$StringMap_StringMapIterator.prototype = { | |
hasNext: function() { | |
return this.index < this.count; | |
} | |
,next: function() { | |
var _this = this.map; | |
var key = this.keys[this.index++]; | |
if(__map_reserved[key] != null) { | |
return _this.getReserved(key); | |
} else { | |
return _this.h[key]; | |
} | |
} | |
}; | |
var haxe_ds_StringMap = function() { | |
this.h = { }; | |
}; | |
haxe_ds_StringMap.__name__ = true; | |
haxe_ds_StringMap.__interfaces__ = [haxe_IMap]; | |
haxe_ds_StringMap.prototype = { | |
setReserved: function(key,value) { | |
if(this.rh == null) { | |
this.rh = { }; | |
} | |
this.rh["$" + key] = value; | |
} | |
,getReserved: function(key) { | |
if(this.rh == null) { | |
return null; | |
} else { | |
return this.rh["$" + key]; | |
} | |
} | |
,existsReserved: function(key) { | |
if(this.rh == null) { | |
return false; | |
} | |
return this.rh.hasOwnProperty("$" + key); | |
} | |
,remove: function(key) { | |
if(__map_reserved[key] != null) { | |
key = "$" + key; | |
if(this.rh == null || !this.rh.hasOwnProperty(key)) { | |
return false; | |
} | |
delete(this.rh[key]); | |
return true; | |
} else { | |
if(!this.h.hasOwnProperty(key)) { | |
return false; | |
} | |
delete(this.h[key]); | |
return true; | |
} | |
} | |
,arrayKeys: function() { | |
var out = []; | |
for( var key in this.h ) { | |
if(this.h.hasOwnProperty(key)) { | |
out.push(key); | |
} | |
} | |
if(this.rh != null) { | |
for( var key in this.rh ) { | |
if(key.charCodeAt(0) == 36) { | |
out.push(key.substr(1)); | |
} | |
} | |
} | |
return out; | |
} | |
}; | |
var js__$Boot_HaxeError = function(val) { | |
Error.call(this); | |
this.val = val; | |
if(Error.captureStackTrace) { | |
Error.captureStackTrace(this,js__$Boot_HaxeError); | |
} | |
}; | |
js__$Boot_HaxeError.__name__ = true; | |
js__$Boot_HaxeError.__super__ = Error; | |
js__$Boot_HaxeError.prototype = $extend(Error.prototype,{ | |
}); | |
var js_Boot = function() { }; | |
js_Boot.__name__ = true; | |
js_Boot.__string_rec = function(o,s) { | |
if(o == null) { | |
return "null"; | |
} | |
if(s.length >= 5) { | |
return "<...>"; | |
} | |
var t = typeof(o); | |
if(t == "function" && (o.__name__ || o.__ename__)) { | |
t = "object"; | |
} | |
switch(t) { | |
case "function": | |
return "<function>"; | |
case "object": | |
if(o.__enum__) { | |
var e = $hxEnums[o.__enum__]; | |
var n = e.__constructs__[o._hx_index]; | |
var con = e[n]; | |
if(con.__params__) { | |
s += "\t"; | |
var tmp = n + "("; | |
var _g = []; | |
var _g1 = 0; | |
var _g2 = con.__params__; | |
while(_g1 < _g2.length) { | |
var p = _g2[_g1]; | |
++_g1; | |
_g.push(js_Boot.__string_rec(o[p],s)); | |
} | |
return tmp + _g.join(",") + ")"; | |
} else { | |
return n; | |
} | |
} | |
if((o instanceof Array)) { | |
var l = o.length; | |
var i; | |
var str = "["; | |
s += "\t"; | |
var _g3 = 0; | |
var _g11 = l; | |
while(_g3 < _g11) { | |
var i1 = _g3++; | |
str += (i1 > 0 ? "," : "") + js_Boot.__string_rec(o[i1],s); | |
} | |
str += "]"; | |
return str; | |
} | |
var tostr; | |
try { | |
tostr = o.toString; | |
} catch( e1 ) { | |
var e2 = (e1 instanceof js__$Boot_HaxeError) ? e1.val : e1; | |
return "???"; | |
} | |
if(tostr != null && tostr != Object.toString && typeof(tostr) == "function") { | |
var s2 = o.toString(); | |
if(s2 != "[object Object]") { | |
return s2; | |
} | |
} | |
var k = null; | |
var str1 = "{\n"; | |
s += "\t"; | |
var hasp = o.hasOwnProperty != null; | |
for( var k in o ) { | |
if(hasp && !o.hasOwnProperty(k)) { | |
continue; | |
} | |
if(k == "prototype" || k == "__class__" || k == "__super__" || k == "__interfaces__" || k == "__properties__") { | |
continue; | |
} | |
if(str1.length != 2) { | |
str1 += ", \n"; | |
} | |
str1 += s + k + " : " + js_Boot.__string_rec(o[k],s); | |
} | |
s = s.substring(1); | |
str1 += "\n" + s + "}"; | |
return str1; | |
case "string": | |
return o; | |
default: | |
return String(o); | |
} | |
}; | |
var tink_core__$Callback_Callback_$Impl_$ = {}; | |
tink_core__$Callback_Callback_$Impl_$.__name__ = true; | |
tink_core__$Callback_Callback_$Impl_$.invoke = function(this1,data) { | |
if(tink_core__$Callback_Callback_$Impl_$.depth < 1000) { | |
tink_core__$Callback_Callback_$Impl_$.depth++; | |
this1(data); | |
tink_core__$Callback_Callback_$Impl_$.depth--; | |
} else { | |
var _e = this1; | |
var f = function(data1) { | |
tink_core__$Callback_Callback_$Impl_$.invoke(_e,data1); | |
}; | |
var data2 = data; | |
tink_core__$Callback_Callback_$Impl_$.defer(function() { | |
f(data2); | |
}); | |
} | |
}; | |
tink_core__$Callback_Callback_$Impl_$.fromNiladic = function(f) { | |
return function(_) { | |
f(); | |
}; | |
}; | |
tink_core__$Callback_Callback_$Impl_$.defer = function(f) { | |
haxe_Timer.delay(f,0); | |
}; | |
var tink_core__$Callback_LinkObject = function() { }; | |
tink_core__$Callback_LinkObject.__name__ = true; | |
var tink_core__$Callback_ListCell = function(cb,list) { | |
if(cb == null) { | |
throw new js__$Boot_HaxeError("callback expected but null received"); | |
} | |
this.cb = cb; | |
this.list = list; | |
}; | |
tink_core__$Callback_ListCell.__name__ = true; | |
tink_core__$Callback_ListCell.__interfaces__ = [tink_core__$Callback_LinkObject]; | |
tink_core__$Callback_ListCell.prototype = { | |
clear: function() { | |
this.list = null; | |
this.cb = null; | |
} | |
,dissolve: function() { | |
var _g = this.list; | |
if(_g != null) { | |
var v = _g; | |
this.clear(); | |
HxOverrides.remove(v,this); | |
} | |
} | |
}; | |
var tink_core__$Callback_CallbackList_$Impl_$ = {}; | |
tink_core__$Callback_CallbackList_$Impl_$.__name__ = true; | |
tink_core__$Callback_CallbackList_$Impl_$.add = function(this1,cb) { | |
var node = new tink_core__$Callback_ListCell(cb,this1); | |
this1.push(node); | |
return node; | |
}; | |
tink_core__$Callback_CallbackList_$Impl_$.invoke = function(this1,data) { | |
var _g = 0; | |
var _g1 = this1.slice(); | |
while(_g < _g1.length) { | |
var cell = _g1[_g]; | |
++_g; | |
if(cell.cb != null) { | |
tink_core__$Callback_Callback_$Impl_$.invoke(cell.cb,data); | |
} | |
} | |
}; | |
tink_core__$Callback_CallbackList_$Impl_$.clear = function(this1) { | |
var _g = 0; | |
var _g1 = this1.splice(0,this1.length); | |
while(_g < _g1.length) { | |
var cell = _g1[_g]; | |
++_g; | |
cell.clear(); | |
} | |
}; | |
var tink_core_TypedError = function() { }; | |
tink_core_TypedError.__name__ = true; | |
tink_core_TypedError.tryFinally = function(f,cleanup) { | |
try { return f(); } finally { cleanup(); } | |
return null; | |
}; | |
var tink_core__$Future_FutureObject = function() { }; | |
tink_core__$Future_FutureObject.__name__ = true; | |
var tink_core__$Lazy_LazyObject = function() { }; | |
tink_core__$Lazy_LazyObject.__name__ = true; | |
var tink_core__$Lazy_LazyConst = function(value) { | |
this.value = value; | |
}; | |
tink_core__$Lazy_LazyConst.__name__ = true; | |
tink_core__$Lazy_LazyConst.__interfaces__ = [tink_core__$Lazy_LazyObject]; | |
tink_core__$Lazy_LazyConst.prototype = { | |
get: function() { | |
return this.value; | |
} | |
,map: function(f) { | |
var _gthis = this; | |
return new tink_core__$Lazy_LazyFunc(function() { | |
return f(_gthis.value); | |
}); | |
} | |
}; | |
var tink_core__$Future_SyncFuture = function(value) { | |
this.value = value; | |
}; | |
tink_core__$Future_SyncFuture.__name__ = true; | |
tink_core__$Future_SyncFuture.__interfaces__ = [tink_core__$Future_FutureObject]; | |
tink_core__$Future_SyncFuture.prototype = { | |
flatMap: function(f) { | |
var l = this.value.map(f); | |
return new tink_core__$Future_SimpleFuture(function(cb) { | |
return l.get().handle(cb); | |
}); | |
} | |
,handle: function(cb) { | |
tink_core__$Callback_Callback_$Impl_$.invoke(cb,this.value.get()); | |
return null; | |
} | |
,gather: function() { | |
return this; | |
} | |
}; | |
var tink_core_Noise = $hxEnums["tink.core.Noise"] = { __ename__ : true, __constructs__ : ["Noise"] | |
,Noise: {_hx_index:0,__enum__:"tink.core.Noise",toString:$estr} | |
}; | |
var tink_core__$Future_Future_$Impl_$ = {}; | |
tink_core__$Future_Future_$Impl_$.__name__ = true; | |
tink_core__$Future_Future_$Impl_$.flatten = function(f) { | |
return new tink_core__$Future_NestedFuture(f); | |
}; | |
var tink_core__$Future_SimpleFuture = function(f) { | |
this.f = f; | |
}; | |
tink_core__$Future_SimpleFuture.__name__ = true; | |
tink_core__$Future_SimpleFuture.__interfaces__ = [tink_core__$Future_FutureObject]; | |
tink_core__$Future_SimpleFuture.prototype = { | |
handle: function(callback) { | |
return this.f(callback); | |
} | |
,flatMap: function(f) { | |
var f1 = f; | |
var _gthis = this; | |
return tink_core__$Future_Future_$Impl_$.flatten(new tink_core__$Future_SimpleFuture(function(cb) { | |
return _gthis.f(function(v) { | |
var tmp = f1(v); | |
tink_core__$Callback_Callback_$Impl_$.invoke(cb,tmp); | |
}); | |
})); | |
} | |
,gather: function() { | |
if(this.gathered != null) { | |
return this.gathered; | |
} else { | |
return this.gathered = tink_core_FutureTrigger.gatherFuture(this); | |
} | |
} | |
}; | |
var tink_core__$Future_NestedFuture = function(outer) { | |
this.outer = outer; | |
}; | |
tink_core__$Future_NestedFuture.__name__ = true; | |
tink_core__$Future_NestedFuture.__interfaces__ = [tink_core__$Future_FutureObject]; | |
tink_core__$Future_NestedFuture.prototype = { | |
flatMap: function(f) { | |
var ret = this.outer.flatMap(function(inner) { | |
var ret1 = inner.flatMap(f); | |
return ret1.gather(); | |
}); | |
return ret.gather(); | |
} | |
,gather: function() { | |
if(this.gathered != null) { | |
return this.gathered; | |
} else { | |
return this.gathered = tink_core_FutureTrigger.gatherFuture(this); | |
} | |
} | |
,handle: function(cb) { | |
var ret = null; | |
ret = this.outer.handle(function(inner) { | |
ret = inner.handle(function(result) { | |
tink_core__$Callback_Callback_$Impl_$.invoke(cb,result); | |
}); | |
}); | |
return ret; | |
} | |
}; | |
var tink_core_FutureTrigger = function() { | |
var this1 = []; | |
this.list = this1; | |
}; | |
tink_core_FutureTrigger.__name__ = true; | |
tink_core_FutureTrigger.__interfaces__ = [tink_core__$Future_FutureObject]; | |
tink_core_FutureTrigger.gatherFuture = function(f) { | |
var op = null; | |
var this1 = new tink_core__$Future_SimpleFuture(function(cb) { | |
if(op == null) { | |
op = new tink_core_FutureTrigger(); | |
f.handle($bind(op,op.trigger)); | |
f = null; | |
} | |
return op.handle(cb); | |
}); | |
return this1; | |
}; | |
tink_core_FutureTrigger.prototype = { | |
handle: function(callback) { | |
var _g = this.list; | |
if(_g == null) { | |
tink_core__$Callback_Callback_$Impl_$.invoke(callback,this.result); | |
return null; | |
} else { | |
var v = _g; | |
return tink_core__$Callback_CallbackList_$Impl_$.add(v,callback); | |
} | |
} | |
,flatMap: function(f) { | |
var _g = this.list; | |
if(_g == null) { | |
return f(this.result); | |
} else { | |
var v = _g; | |
var ret = new tink_core_FutureTrigger(); | |
tink_core__$Callback_CallbackList_$Impl_$.add(this.list,function(v1) { | |
f(v1).handle($bind(ret,ret.trigger)); | |
}); | |
return ret; | |
} | |
} | |
,gather: function() { | |
return this; | |
} | |
,trigger: function(result) { | |
if(this.list == null) { | |
return false; | |
} else { | |
var list = this.list; | |
this.list = null; | |
this.result = result; | |
tink_core__$Callback_CallbackList_$Impl_$.invoke(list,result); | |
tink_core__$Callback_CallbackList_$Impl_$.clear(list); | |
return true; | |
} | |
} | |
}; | |
var tink_core__$Lazy_LazyFunc = function(f) { | |
this.f = f; | |
}; | |
tink_core__$Lazy_LazyFunc.__name__ = true; | |
tink_core__$Lazy_LazyFunc.__interfaces__ = [tink_core__$Lazy_LazyObject]; | |
tink_core__$Lazy_LazyFunc.prototype = { | |
get: function() { | |
if(this.f != null) { | |
this.result = this.f(); | |
this.f = null; | |
} | |
return this.result; | |
} | |
,map: function(f) { | |
var _gthis = this; | |
return new tink_core__$Lazy_LazyFunc(function() { | |
var tmp = _gthis.get(); | |
return f(tmp); | |
}); | |
} | |
}; | |
var tink_core_NamedWith = function(name,value) { | |
this.name = name; | |
this.value = value; | |
}; | |
tink_core_NamedWith.__name__ = true; | |
var tink_core_Outcome = $hxEnums["tink.core.Outcome"] = { __ename__ : true, __constructs__ : ["Success","Failure"] | |
,Success: ($_=function(data) { return {_hx_index:0,data:data,__enum__:"tink.core.Outcome",toString:$estr}; },$_.__params__ = ["data"],$_) | |
,Failure: ($_=function(failure) { return {_hx_index:1,failure:failure,__enum__:"tink.core.Outcome",toString:$estr}; },$_.__params__ = ["failure"],$_) | |
}; | |
var tink_core_MPair = function(a,b) { | |
this.a = a; | |
this.b = b; | |
}; | |
tink_core_MPair.__name__ = true; | |
var tink_core__$Promise_Promise_$Impl_$ = {}; | |
tink_core__$Promise_Promise_$Impl_$.__name__ = true; | |
tink_core__$Promise_Promise_$Impl_$.next = function(this1,f,gather) { | |
if(gather == null) { | |
gather = true; | |
} | |
var ret = this1.flatMap(function(o) { | |
switch(o._hx_index) { | |
case 0: | |
var d = o.data; | |
return f(d); | |
case 1: | |
var f1 = o.failure; | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Failure(f1))); | |
} | |
}); | |
if(gather) { | |
return ret.gather(); | |
} else { | |
return ret; | |
} | |
}; | |
var tink_core__$Signal_Signal_$Impl_$ = {}; | |
tink_core__$Signal_Signal_$Impl_$.__name__ = true; | |
tink_core__$Signal_Signal_$Impl_$.trigger = function() { | |
return new tink_core_SignalTrigger(); | |
}; | |
var tink_core_SignalObject = function() { }; | |
tink_core_SignalObject.__name__ = true; | |
var tink_core_SignalTrigger = function() { | |
this.handlers = []; | |
}; | |
tink_core_SignalTrigger.__name__ = true; | |
tink_core_SignalTrigger.__interfaces__ = [tink_core_SignalObject]; | |
var tink_domspec__$ClassName_ClassName_$Impl_$ = {}; | |
tink_domspec__$ClassName_ClassName_$Impl_$.__name__ = true; | |
tink_domspec__$ClassName_ClassName_$Impl_$.ofString = function(s) { | |
var this1 = StringTools.trim(s); | |
return this1; | |
}; | |
var tink_pure__$List_List_$Impl_$ = {}; | |
tink_pure__$List_List_$Impl_$.__name__ = true; | |
tink_pure__$List_List_$Impl_$.prepend = function(this1,value) { | |
if(this1 == null) { | |
return new tink_pure__$List_Node(1,value); | |
} else { | |
return new tink_pure__$List_Node(this1.length + 1,value,[this1]); | |
} | |
}; | |
tink_pure__$List_List_$Impl_$.filter = function(this1,f) { | |
if(this1 == null) { | |
return null; | |
} else { | |
return this1.filter(f); | |
} | |
}; | |
tink_pure__$List_List_$Impl_$.fromArray = function(i) { | |
var ret = null; | |
var len = 0; | |
var pos = i.length; | |
while(pos-- > 0) ret = new tink_pure__$List_Node(++len,i[pos],ret == null ? tink_pure__$List_Node.EMPTY : [ret]); | |
return ret; | |
}; | |
var tink_pure__$List_Node = function(length,value,tails) { | |
this.value = value; | |
this.length = length; | |
this.tails = tails == null ? tink_pure__$List_Node.EMPTY : tails; | |
}; | |
tink_pure__$List_Node.__name__ = true; | |
tink_pure__$List_Node.prototype = { | |
filter: function(f) { | |
var iter = new tink_pure_NodeIterator(this); | |
var ret = []; | |
while(iter.list.length > 0) { | |
var value = iter.next(); | |
var res = f(value); | |
if(res > 0) { | |
ret.push(value); | |
} | |
if((res & 3) == 3) { | |
break; | |
} | |
} | |
return tink_pure__$List_List_$Impl_$.fromArray(ret); | |
} | |
}; | |
var tink_pure_NodeIterator = function(node) { | |
this.list = []; | |
if(node != null) { | |
this.list.push(node); | |
} | |
}; | |
tink_pure_NodeIterator.__name__ = true; | |
tink_pure_NodeIterator.prototype = { | |
hasNext: function() { | |
return this.list.length > 0; | |
} | |
,next: function() { | |
var _g = this.list.pop(); | |
if(_g == null) { | |
return null; | |
} else { | |
var next = _g; | |
var _g1 = -next.tails.length; | |
var _g11 = 0; | |
while(_g1 < _g11) { | |
var i = _g1++; | |
this.list.push(next.tails[-i - 1]); | |
} | |
return next.value; | |
} | |
} | |
}; | |
var tink_state__$Observable_Observable_$Impl_$ = {}; | |
tink_state__$Observable_Observable_$Impl_$.__name__ = true; | |
tink_state__$Observable_Observable_$Impl_$.get_value = function(this1) { | |
return tink_state__$Observable_Observable_$Impl_$.measure(this1).a; | |
}; | |
tink_state__$Observable_Observable_$Impl_$.map = function(this1,f) { | |
return tink_state__$Observable_Observable_$Impl_$.create(function() { | |
var m = tink_state__$Observable_Observable_$Impl_$.measure(this1); | |
var this2 = new tink_core_MPair(f(m.a),m.b); | |
var this3 = this2; | |
return this3; | |
}); | |
}; | |
tink_state__$Observable_Observable_$Impl_$.measure = function(this1) { | |
var before = tink_state__$Observable_Observable_$Impl_$.stack.first(); | |
tink_state__$Observable_Observable_$Impl_$.stack.push(this1); | |
var p = this1.poll(); | |
var _g = (before instanceof tink_state__$Observable_AutoObservable) ? before : null; | |
if(_g != null) { | |
var v = _g; | |
v.subscribe(p.b); | |
} | |
tink_state__$Observable_Observable_$Impl_$.stack.pop(); | |
return p; | |
}; | |
tink_state__$Observable_Observable_$Impl_$.create = function(f) { | |
return new tink_state__$Observable_SimpleObservable(f); | |
}; | |
tink_state__$Observable_Observable_$Impl_$.auto = function(f) { | |
return new tink_state__$Observable_AutoObservable(f); | |
}; | |
tink_state__$Observable_Observable_$Impl_$["const"] = function(value) { | |
return new tink_state_ConstObservable(value); | |
}; | |
tink_state__$Observable_Observable_$Impl_$.untracked = function(f) { | |
tink_state__$Observable_Observable_$Impl_$.stack.push(null); | |
return tink_core_TypedError.tryFinally(f,($_=tink_state__$Observable_Observable_$Impl_$.stack,$bind($_,$_.pop))); | |
}; | |
var tink_state__$Observable_SimpleObservable = function(f) { | |
this._poll = f; | |
}; | |
tink_state__$Observable_SimpleObservable.__name__ = true; | |
tink_state__$Observable_SimpleObservable.__interfaces__ = [tink_state_ObservableObject]; | |
tink_state__$Observable_SimpleObservable.prototype = { | |
resetCache: function(_) { | |
this.cache = null; | |
} | |
,poll: function() { | |
var count = 0; | |
var last = null; | |
while(this.cache == null) { | |
var cache = this.cache = this._poll(); | |
if(last == cache) { | |
throw new js__$Boot_HaxeError("Polling loops on the same value"); | |
} | |
last = cache; | |
cache.b.handle($bind(this,this.resetCache)); | |
if(count++ >= 100) { | |
throw new js__$Boot_HaxeError("Polling not concluded after 100 iterations"); | |
} | |
} | |
return this.cache; | |
} | |
}; | |
var tink_state__$Observable_Transform_$Impl_$ = {}; | |
tink_state__$Observable_Transform_$Impl_$.__name__ = true; | |
tink_state__$Observable_Transform_$Impl_$.plain = function(f) { | |
var this1 = f; | |
return this1; | |
}; | |
var tink_state_ConstObservable = function(value) { | |
var this1 = new tink_core_MPair(value,tink_state_ConstObservable.NEVER); | |
var this2 = this1; | |
this.m = this2; | |
}; | |
tink_state_ConstObservable.__name__ = true; | |
tink_state_ConstObservable.__interfaces__ = [tink_state_ObservableObject]; | |
tink_state_ConstObservable.prototype = { | |
poll: function() { | |
return this.m; | |
} | |
}; | |
var tink_state__$Observable_AutoObservable = function(comp) { | |
this.subscriptions = new haxe_ds_ObjectMap(); | |
var _gthis = this; | |
tink_state__$Observable_SimpleObservable.call(this,function() { | |
_gthis.subscriptions = new haxe_ds_ObjectMap(); | |
_gthis.trigger = new tink_core_FutureTrigger(); | |
var this1 = new tink_core_MPair(comp.f(),_gthis.trigger); | |
var this2 = this1; | |
return this2; | |
}); | |
}; | |
tink_state__$Observable_AutoObservable.__name__ = true; | |
tink_state__$Observable_AutoObservable.__super__ = tink_state__$Observable_SimpleObservable; | |
tink_state__$Observable_AutoObservable.prototype = $extend(tink_state__$Observable_SimpleObservable.prototype,{ | |
subscribe: function(change) { | |
if(this.subscriptions.h.__keys__[change.__id__] == null) { | |
var this1 = this.subscriptions; | |
var v = change.handle(($_=this.trigger,$bind($_,$_.trigger))); | |
this1.set(change,v); | |
} | |
} | |
}); | |
var tink_state__$State_State_$Impl_$ = {}; | |
tink_state__$State_State_$Impl_$.__name__ = true; | |
tink_state__$State_State_$Impl_$.get_value = function(this1) { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(this1); | |
}; | |
var tink_state__$State_StateObject = function() { }; | |
tink_state__$State_StateObject.__name__ = true; | |
tink_state__$State_StateObject.__interfaces__ = [tink_state_ObservableObject]; | |
var tink_state__$State_SimpleState = function(value,isEqual,guard) { | |
this.value = value; | |
this.isEqual = isEqual; | |
this.guard = guard; | |
this.arm(); | |
}; | |
tink_state__$State_SimpleState.__name__ = true; | |
tink_state__$State_SimpleState.__interfaces__ = [tink_state__$State_StateObject]; | |
tink_state__$State_SimpleState.prototype = { | |
poll: function() { | |
return this.next; | |
} | |
,arm: function() { | |
this.trigger = new tink_core_FutureTrigger(); | |
var this1 = new tink_core_MPair(this.value,this.trigger); | |
var this2 = this1; | |
this.next = this2; | |
} | |
,set: function(value) { | |
if(this.guard != null) { | |
value = this.guard(value,this.value); | |
} | |
var b = this.value; | |
if(this.isEqual == null ? value != b : !this.isEqual(value,b)) { | |
this.value = value; | |
var last = this.trigger; | |
this.arm(); | |
last.trigger(tink_core_Noise.Noise); | |
} | |
} | |
}; | |
var todomvc_data_TodoFilter = function() { | |
this.options = tink_pure__$List_List_$Impl_$.fromArray([new tink_core_NamedWith("All",function(_) { | |
return true; | |
}),new tink_core_NamedWith("Active",todomvc_data_TodoItem.isActive),new tink_core_NamedWith("Completed",todomvc_data_TodoItem.isCompleted)]); | |
var this1 = new tink_state__$State_SimpleState(new tink_pure_NodeIterator(this.options).next().value,null,null); | |
this.__coco_currentFilter = this1; | |
var this2 = new tink_state__$State_SimpleState(0,null,null); | |
this.__coco_transitionCount = this2; | |
this.errorTrigger = tink_core__$Signal_Signal_$Impl_$.trigger(); | |
this.transitionErrors = this.errorTrigger; | |
this.observables = { options : tink_state__$Observable_Observable_$Impl_$["const"](this.options), currentFilter : this.__coco_currentFilter, isInTransition : tink_state__$Observable_Observable_$Impl_$.map(this.__coco_transitionCount,tink_state__$Observable_Transform_$Impl_$.plain(function(count) { | |
return count > 0; | |
}))}; | |
}; | |
todomvc_data_TodoFilter.__name__ = true; | |
todomvc_data_TodoFilter.__interfaces__ = [coconut_data_Model]; | |
todomvc_data_TodoFilter.prototype = { | |
matches: function(item) { | |
return (tink_state__$State_State_$Impl_$.get_value(this.__coco_currentFilter))(item); | |
} | |
,toggle: function(filter) { | |
var _gthis = this; | |
return tink_core__$Promise_Promise_$Impl_$.next(this.__cocoupdate((function() { | |
var _g = new tink_pure_NodeIterator(_gthis.options); | |
while(_g.list.length > 0) { | |
var o = _g.next(); | |
if(o.value == filter) { | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success({ currentFilter : filter}))); | |
} | |
} | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success({ }))); | |
})()),function(_) { | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success(tink_core_Noise.Noise))); | |
}); | |
} | |
,isActive: function(filter) { | |
return filter == tink_state__$State_State_$Impl_$.get_value(this.__coco_currentFilter); | |
} | |
,__cocoupdate: function(ret) { | |
var _gthis = this; | |
var sync = true; | |
var done = false; | |
ret.handle(function(o) { | |
done = true; | |
if(!sync) { | |
var tmp = tink_state__$State_State_$Impl_$.get_value(_gthis.__coco_transitionCount) - 1; | |
_gthis.__coco_transitionCount.set(tmp); | |
} | |
switch(o._hx_index) { | |
case 0: | |
var delta = o.data; | |
var this1 = { }; | |
var sparse = this1; | |
var delta1 = delta; | |
var _g = 0; | |
var _g1 = Reflect.fields(delta1); | |
while(_g < _g1.length) { | |
var k = _g1[_g]; | |
++_g; | |
var this2 = new Array(1); | |
var this3 = this2; | |
var ret1 = this3; | |
ret1[0] = delta1[k]; | |
sparse[k] = ret1; | |
} | |
var delta2 = sparse; | |
if(delta2.currentFilter != null) { | |
_gthis.__coco_currentFilter.set(delta2.currentFilter[0]); | |
} | |
break; | |
case 1: | |
var e = o.failure; | |
tink_core__$Callback_CallbackList_$Impl_$.invoke(_gthis.errorTrigger.handlers,e); | |
break; | |
} | |
}); | |
if(!done) { | |
sync = false; | |
} | |
if(!sync) { | |
this.__coco_transitionCount.set(tink_state__$State_State_$Impl_$.get_value(this.__coco_transitionCount) + 1); | |
} | |
return ret; | |
} | |
}; | |
var todomvc_data_TodoItem = function(init) { | |
this.id = Std.string(todomvc_data_TodoItem.idCounter++); | |
var value; | |
var _g = init.completed; | |
if(_g == null) { | |
value = false; | |
} else { | |
var v = _g; | |
value = v; | |
} | |
var this1 = new tink_state__$State_SimpleState(value,null,null); | |
this.__coco_completed = this1; | |
var this2 = new tink_state__$State_SimpleState(init.description,null,null); | |
this.__coco_description = this2; | |
var _g1 = init.created; | |
var tmp; | |
if(_g1 == null) { | |
tmp = new Date(); | |
} else { | |
var v1 = _g1; | |
tmp = v1; | |
} | |
this.created = tmp; | |
var this3 = new tink_state__$State_SimpleState(0,null,null); | |
this.__coco_transitionCount = this3; | |
this.errorTrigger = tink_core__$Signal_Signal_$Impl_$.trigger(); | |
this.transitionErrors = this.errorTrigger; | |
this.observables = { id : tink_state__$Observable_Observable_$Impl_$["const"](this.id), completed : this.__coco_completed, description : this.__coco_description, created : tink_state__$Observable_Observable_$Impl_$["const"](this.created), isInTransition : tink_state__$Observable_Observable_$Impl_$.map(this.__coco_transitionCount,tink_state__$Observable_Transform_$Impl_$.plain(function(count) { | |
return count > 0; | |
}))}; | |
}; | |
todomvc_data_TodoItem.__name__ = true; | |
todomvc_data_TodoItem.__interfaces__ = [coconut_data_Model]; | |
todomvc_data_TodoItem.create = function(description) { | |
return new todomvc_data_TodoItem({ description : description}); | |
}; | |
todomvc_data_TodoItem.isActive = function(item) { | |
return !tink_state__$State_State_$Impl_$.get_value(item.__coco_completed); | |
}; | |
todomvc_data_TodoItem.isCompleted = function(item) { | |
return tink_state__$State_State_$Impl_$.get_value(item.__coco_completed); | |
}; | |
todomvc_data_TodoItem.prototype = { | |
set_completed: function(param) { | |
this.__coco_completed.set(param); | |
return param; | |
} | |
,set_description: function(param) { | |
this.__coco_description.set(param); | |
return param; | |
} | |
}; | |
var todomvc_data_TodoList = function(init) { | |
var _gthis = this; | |
if(init == null) { | |
init = { }; | |
} | |
var value; | |
var _g = init.items; | |
if(_g == null) { | |
value = null; | |
} else { | |
var v = _g; | |
value = v; | |
} | |
var this1 = new tink_state__$State_SimpleState(value,null,null); | |
this.__coco_items = this1; | |
var this2 = { f : function() { | |
var predicate = todomvc_data_TodoItem.isActive; | |
var ret = 0; | |
var _g1 = new tink_pure_NodeIterator(tink_state__$State_State_$Impl_$.get_value(_gthis.__coco_items)); | |
while(_g1.list.length > 0) { | |
var x = _g1.next(); | |
if(predicate(x)) { | |
++ret; | |
} | |
} | |
return ret; | |
}}; | |
this.__coco_unfinished = tink_state__$Observable_Observable_$Impl_$.auto(this2); | |
var this3 = { f : function() { | |
var this4 = tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__coco_unfinished); | |
var this5 = tink_state__$State_State_$Impl_$.get_value(_gthis.__coco_items); | |
return this4 < (this5 == null ? 0 : this5.length); | |
}}; | |
this.__coco_hasAnyCompleted = tink_state__$Observable_Observable_$Impl_$.auto(this3); | |
var this6 = new tink_state__$State_SimpleState(0,null,null); | |
this.__coco_transitionCount = this6; | |
this.errorTrigger = tink_core__$Signal_Signal_$Impl_$.trigger(); | |
this.transitionErrors = this.errorTrigger; | |
this.observables = { items : this.__coco_items, unfinished : this.__coco_unfinished, hasAnyCompleted : this.__coco_hasAnyCompleted, isInTransition : tink_state__$Observable_Observable_$Impl_$.map(this.__coco_transitionCount,tink_state__$Observable_Transform_$Impl_$.plain(function(count) { | |
return count > 0; | |
}))}; | |
}; | |
todomvc_data_TodoList.__name__ = true; | |
todomvc_data_TodoList.__interfaces__ = [coconut_data_Model]; | |
todomvc_data_TodoList.prototype = { | |
add: function(description) { | |
return tink_core__$Promise_Promise_$Impl_$.next(this.__cocoupdate(new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success({ items : tink_pure__$List_List_$Impl_$.prepend(tink_state__$State_State_$Impl_$.get_value(this.__coco_items),todomvc_data_TodoItem.create(description))})))),function(_) { | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success(tink_core_Noise.Noise))); | |
}); | |
} | |
,'delete': function(item) { | |
return tink_core__$Promise_Promise_$Impl_$.next(this.__cocoupdate(new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success({ items : tink_pure__$List_List_$Impl_$.filter(tink_state__$State_State_$Impl_$.get_value(this.__coco_items),function(i) { | |
if(i != item) { | |
return 1; | |
} else { | |
return 0; | |
} | |
})})))),function(_) { | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success(tink_core_Noise.Noise))); | |
}); | |
} | |
,clearCompleted: function() { | |
return tink_core__$Promise_Promise_$Impl_$.next(this.__cocoupdate(new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success({ items : tink_pure__$List_List_$Impl_$.filter(tink_state__$State_State_$Impl_$.get_value(this.__coco_items),function(i) { | |
if(!tink_state__$State_State_$Impl_$.get_value(i.__coco_completed)) { | |
return 1; | |
} else { | |
return 0; | |
} | |
})})))),function(_) { | |
return new tink_core__$Future_SyncFuture(new tink_core__$Lazy_LazyConst(tink_core_Outcome.Success(tink_core_Noise.Noise))); | |
}); | |
} | |
,__cocoupdate: function(ret) { | |
var _gthis = this; | |
var sync = true; | |
var done = false; | |
ret.handle(function(o) { | |
done = true; | |
if(!sync) { | |
var tmp = tink_state__$State_State_$Impl_$.get_value(_gthis.__coco_transitionCount) - 1; | |
_gthis.__coco_transitionCount.set(tmp); | |
} | |
switch(o._hx_index) { | |
case 0: | |
var delta = o.data; | |
var this1 = { }; | |
var sparse = this1; | |
var delta1 = delta; | |
var _g = 0; | |
var _g1 = Reflect.fields(delta1); | |
while(_g < _g1.length) { | |
var k = _g1[_g]; | |
++_g; | |
var this2 = new Array(1); | |
var this3 = this2; | |
var ret1 = this3; | |
ret1[0] = delta1[k]; | |
sparse[k] = ret1; | |
} | |
var delta2 = sparse; | |
if(delta2.items != null) { | |
_gthis.__coco_items.set(delta2.items[0]); | |
} | |
break; | |
case 1: | |
var e = o.failure; | |
tink_core__$Callback_CallbackList_$Impl_$.invoke(_gthis.errorTrigger.handlers,e); | |
break; | |
} | |
}); | |
if(!done) { | |
sync = false; | |
} | |
if(!sync) { | |
this.__coco_transitionCount.set(tink_state__$State_State_$Impl_$.get_value(this.__coco_transitionCount) + 1); | |
} | |
return ret; | |
} | |
}; | |
var todomvc_ui_TodoItemView = function(data) { | |
this.__tink_defaults31 = { }; | |
this.__slots = { item : new coconut_ui_tools_Slot(this,null), ondeleted : new coconut_ui_tools_Slot(this,null)}; | |
var this1 = new tink_state__$State_SimpleState(false,null,null); | |
this.__coco_isEditing = this1; | |
this.__initAttributes(data); | |
var snapshot = null; | |
coconut_ui_View.call(this,$bind(this,this.render),null,null,null,null,null); | |
}; | |
todomvc_ui_TodoItemView.__name__ = true; | |
todomvc_ui_TodoItemView.fromHxx = function(attributes) { | |
return coconut_vdom__$Child_Child_$Impl_$.widget("todomvc.ui.TodoItemView",attributes.key,$bind(attributes,attributes.ref),attributes,{ create : function(data) { | |
return new todomvc_ui_TodoItemView(data); | |
}, update : function(attr,v) { | |
v.__initAttributes(attr); | |
}}); | |
}; | |
todomvc_ui_TodoItemView.__super__ = coconut_ui_View; | |
todomvc_ui_TodoItemView.prototype = $extend(coconut_ui_View.prototype,{ | |
render: function() { | |
var _gthis = this; | |
var edit = function(entered) { | |
var _g = StringTools.rtrim(entered); | |
if(_g == "") { | |
(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.ondeleted.observe()))(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.item.observe())); | |
} else { | |
var v = _g; | |
tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.item.observe()).set_description(v); | |
} | |
}; | |
var __r = []; | |
var __ret = { className : tink_domspec__$ClassName_ClassName_$Impl_$.ofString("todo-item"), attributes : { "data-completed" : tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.item.observe()).__coco_completed) ? "" : null, "data-editing" : undefined}}; | |
var __r1 = []; | |
var __ret1 = { name : "completed", type : "checkbox", checked : tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.item.observe()).__coco_completed), onchange : function(event) { | |
tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.item.observe()).set_completed(event.currentTarget.checked); | |
}}; | |
__r1.push(coconut_vdom__$Child_Child_$Impl_$.element("input",__ret1,null)); | |
if(tink_state__$State_State_$Impl_$.get_value(this.__coco_isEditing)) { | |
var __ret2 = { ref : function(i) { | |
if(i != null) { | |
i.focus(); | |
} | |
return; | |
}, name : "description", type : "text", value : tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.item.observe()).__coco_description), onchange : function(event1) { | |
edit(event1.currentTarget.value); | |
}, onblur : function(event2) { | |
_gthis.__coco_isEditing.set(false); | |
}}; | |
__r1.push(coconut_vdom__$Child_Child_$Impl_$.element("input",__ret2,null)); | |
} else { | |
var __ret3 = { className : tink_domspec__$ClassName_ClassName_$Impl_$.ofString("description"), ondblclick : function(event3) { | |
_gthis.__coco_isEditing.set(true); | |
}}; | |
var __r2 = []; | |
__r2.push(coconut_vdom__$Child_Child_$Impl_$.ofText(tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.item.observe()).__coco_description))); | |
__r1.push(coconut_vdom__$Child_Child_$Impl_$.element("span",__ret3,__r2)); | |
var __ret4 = { className : tink_domspec__$ClassName_ClassName_$Impl_$.ofString("delete"), onclick : function(event4) { | |
(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.ondeleted.observe()))(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.item.observe())); | |
}}; | |
var __r3 = []; | |
__r3.push(coconut_vdom__$Child_Child_$Impl_$.ofText("Delete")); | |
__r1.push(coconut_vdom__$Child_Child_$Impl_$.element("button",__ret4,__r3)); | |
} | |
__r.push(coconut_vdom__$Child_Child_$Impl_$.element("li",__ret,__r1)); | |
return __r[0]; | |
} | |
,__initAttributes: function(attributes) { | |
this.__slots.item.setData(attributes.item); | |
this.__slots.ondeleted.setData(attributes.ondeleted); | |
} | |
}); | |
var todomvc_ui_TodoListView = function(data) { | |
var this1 = { f : function() { | |
return new todomvc_data_TodoList(); | |
}}; | |
var tmp = tink_state__$Observable_Observable_$Impl_$.auto(this1); | |
var this11 = { f : function() { | |
return new todomvc_data_TodoFilter(); | |
}}; | |
this.__tink_defaults371 = { todos : tmp, filter : tink_state__$Observable_Observable_$Impl_$.auto(this11)}; | |
this.__slots = { todos : new coconut_ui_tools_Slot(this,null), filter : new coconut_ui_tools_Slot(this,null)}; | |
this.__initAttributes(data); | |
var snapshot = null; | |
coconut_ui_View.call(this,$bind(this,this.render),null,null,null,null,null); | |
}; | |
todomvc_ui_TodoListView.__name__ = true; | |
todomvc_ui_TodoListView.fromHxx = function(attributes) { | |
return coconut_vdom__$Child_Child_$Impl_$.widget("todomvc.ui.TodoListView",attributes.key,$bind(attributes,attributes.ref),attributes,{ create : function(data) { | |
return new todomvc_ui_TodoListView(data); | |
}, update : function(attr,v) { | |
v.__initAttributes(attr); | |
}}); | |
}; | |
todomvc_ui_TodoListView.__super__ = coconut_ui_View; | |
todomvc_ui_TodoListView.prototype = $extend(coconut_ui_View.prototype,{ | |
render: function() { | |
var _gthis = this; | |
var __r = []; | |
var __ret = tink_domspec__$ClassName_ClassName_$Impl_$.ofString("todo-list"); | |
var this1 = tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.todos.observe()).__coco_items); | |
var __ret1 = { className : __ret, attributes : { "data-empty" : (this1 == null ? 0 : this1.length) == 0 ? "" : null}}; | |
var attr = __ret1; | |
var __r1 = []; | |
var __r2 = []; | |
__r2.push(coconut_vdom__$Child_Child_$Impl_$.ofText("todos")); | |
var __ret2 = { }; | |
__r1.push(coconut_vdom__$Child_Child_$Impl_$.element("h1",__ret2,__r2)); | |
var __o0 = this; | |
var this11 = { f : function() { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(__o0.__slots.todos.observe()); | |
}}; | |
var __ret3 = { todos : tink_state__$Observable_Observable_$Impl_$.auto(this11)}; | |
__r1.push(todomvc_ui_Header.fromHxx(__ret3)); | |
var this12 = tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()).__coco_items); | |
if((this12 == null ? 0 : this12.length) > 0) { | |
var __r3 = []; | |
var _g = new tink_pure_NodeIterator(tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()).__coco_items)); | |
while(_g.list.length > 0) { | |
var item = [_g.next()]; | |
if(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.filter.observe()).matches(item[0])) { | |
var this13 = { f : (function(item1) { | |
return function() { | |
return item1[0]; | |
}; | |
})(item)}; | |
var __ret4 = tink_state__$Observable_Observable_$Impl_$.auto(this13); | |
var this14 = { f : (function(item2) { | |
return function() { | |
return (function(item3) { | |
return function(event) { | |
tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.todos.observe())["delete"](item3[0]); | |
}; | |
})(item2); | |
}; | |
})(item)}; | |
var __ret5 = { key : item[0].id, item : __ret4, ondeleted : tink_state__$Observable_Observable_$Impl_$.auto(this14)}; | |
__r3.push(todomvc_ui_TodoItemView.fromHxx(__ret5)); | |
} | |
} | |
var __ret6 = { }; | |
__r1.push(coconut_vdom__$Child_Child_$Impl_$.element("ol",__ret6,__r3)); | |
var __o01 = this; | |
var this15 = { f : function() { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(__o01.__slots.todos.observe()); | |
}}; | |
var __ret7 = tink_state__$Observable_Observable_$Impl_$.auto(this15); | |
var this16 = { f : function() { | |
return tink_state__$Observable_Observable_$Impl_$.get_value(__o01.__slots.filter.observe()); | |
}}; | |
var __ret8 = { todos : __ret7, filter : tink_state__$Observable_Observable_$Impl_$.auto(this16)}; | |
__r1.push(todomvc_ui_Footer.fromHxx(__ret8)); | |
} | |
__r.push(coconut_vdom__$Child_Child_$Impl_$.element("div",attr,__r1)); | |
return __r[0]; | |
} | |
,__initAttributes: function(attributes) { | |
var this1 = attributes.todos; | |
this.__slots.todos.setData(this1 == null ? this.__tink_defaults371.todos : this1); | |
var this11 = attributes.filter; | |
this.__slots.filter.setData(this11 == null ? this.__tink_defaults371.filter : this11); | |
} | |
}); | |
var todomvc_ui_Header = function(data) { | |
var _gthis = this; | |
var this1 = { current : null}; | |
this.input = this1; | |
this.__tink_defaults370 = { }; | |
this.__slots = { todos : new coconut_ui_tools_Slot(this,null)}; | |
this.__initAttributes(data); | |
var snapshot = null; | |
var viewDidMount = function() { | |
_gthis.input.current.focus(); | |
}; | |
coconut_ui_View.call(this,$bind(this,this.render),null,null,null,viewDidMount,null); | |
}; | |
todomvc_ui_Header.__name__ = true; | |
todomvc_ui_Header.fromHxx = function(attributes) { | |
return coconut_vdom__$Child_Child_$Impl_$.widget("todomvc.ui.Header",attributes.key,$bind(attributes,attributes.ref),attributes,{ create : function(data) { | |
return new todomvc_ui_Header(data); | |
}, update : function(attr,v) { | |
v.__initAttributes(attr); | |
}}); | |
}; | |
todomvc_ui_Header.__super__ = coconut_ui_View; | |
todomvc_ui_Header.prototype = $extend(coconut_ui_View.prototype,{ | |
render: function() { | |
var _gthis = this; | |
var __r = []; | |
var __r1 = []; | |
var __ret = { ref : coconut_ui_tools__$Ref_Ref_$Impl_$.toFunction(_gthis.input), type : "text", placeholder : "What needs to be done?", onkeypress : function(e) { | |
if(e.which == 13 && e.currentTarget.value != "") { | |
tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.todos.observe()).add(e.currentTarget.value); | |
e.currentTarget.value = ""; | |
} | |
return; | |
}}; | |
__r1.push(coconut_vdom__$Child_Child_$Impl_$.element("input",__ret,null)); | |
var this1 = tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()).__coco_items); | |
if((this1 == null ? 0 : this1.length) > 0) { | |
if(tink_state__$Observable_Observable_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()).__coco_unfinished) > 0) { | |
var __ret1 = { className : tink_domspec__$ClassName_ClassName_$Impl_$.ofString("mark-all"), onclick : function(event) { | |
var _g = new tink_pure_NodeIterator(tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.todos.observe()).__coco_items)); | |
while(_g.list.length > 0) { | |
var i = _g.next(); | |
i.set_completed(true); | |
} | |
}}; | |
var __r2 = []; | |
__r2.push(coconut_vdom__$Child_Child_$Impl_$.ofText("Mark all as completed")); | |
__r1.push(coconut_vdom__$Child_Child_$Impl_$.element("button",__ret1,__r2)); | |
} else { | |
var __ret2 = { className : tink_domspec__$ClassName_ClassName_$Impl_$.ofString("unmark-all"), onclick : function(event1) { | |
var _g1 = new tink_pure_NodeIterator(tink_state__$State_State_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.todos.observe()).__coco_items)); | |
while(_g1.list.length > 0) { | |
var i1 = _g1.next(); | |
i1.set_completed(false); | |
} | |
}}; | |
var __r3 = []; | |
__r3.push(coconut_vdom__$Child_Child_$Impl_$.ofText("Unmark all as completed")); | |
__r1.push(coconut_vdom__$Child_Child_$Impl_$.element("button",__ret2,__r3)); | |
} | |
} | |
var __ret3 = { }; | |
__r.push(coconut_vdom__$Child_Child_$Impl_$.element("header",__ret3,__r1)); | |
return __r[0]; | |
} | |
,__initAttributes: function(attributes) { | |
this.__slots.todos.setData(attributes.todos); | |
} | |
}); | |
var todomvc_ui_Footer = function(data) { | |
this.__tink_defaults369 = { }; | |
this.__slots = { todos : new coconut_ui_tools_Slot(this,null), filter : new coconut_ui_tools_Slot(this,null)}; | |
this.__initAttributes(data); | |
var snapshot = null; | |
coconut_ui_View.call(this,$bind(this,this.render),null,null,null,null,null); | |
}; | |
todomvc_ui_Footer.__name__ = true; | |
todomvc_ui_Footer.fromHxx = function(attributes) { | |
return coconut_vdom__$Child_Child_$Impl_$.widget("todomvc.ui.Footer",attributes.key,$bind(attributes,attributes.ref),attributes,{ create : function(data) { | |
return new todomvc_ui_Footer(data); | |
}, update : function(attr,v) { | |
v.__initAttributes(attr); | |
}}); | |
}; | |
todomvc_ui_Footer.__super__ = coconut_ui_View; | |
todomvc_ui_Footer.prototype = $extend(coconut_ui_View.prototype,{ | |
render: function() { | |
var _gthis = this; | |
var __r = []; | |
var __r1 = []; | |
var __r2 = []; | |
var _g = tink_state__$Observable_Observable_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()).__coco_unfinished); | |
if(_g == 1) { | |
__r2.push(coconut_vdom__$Child_Child_$Impl_$.ofText("1 item")); | |
} else { | |
var v = _g; | |
__r2.push(coconut_vdom__$Child_Child_$Impl_$.ofInt(v)); | |
__r2.push(coconut_vdom__$Child_Child_$Impl_$.ofText(" items")); | |
} | |
__r2.push(coconut_vdom__$Child_Child_$Impl_$.ofText(" left")); | |
var __ret = { }; | |
__r1.push(coconut_vdom__$Child_Child_$Impl_$.element("span",__ret,__r2)); | |
var __r3 = []; | |
var _g1 = new tink_pure_NodeIterator(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.filter.observe()).options); | |
while(_g1.list.length > 0) { | |
var f = [_g1.next()]; | |
var __ret1 = { onclick : (function(f1) { | |
return function(event) { | |
tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.filter.observe()).toggle(f1[0].value); | |
}; | |
})(f), attributes : { "data-active" : tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.filter.observe()).isActive(f[0].value) ? "" : null}}; | |
var __r4 = []; | |
__r4.push(coconut_vdom__$Child_Child_$Impl_$.ofText(f[0].name)); | |
__r3.push(coconut_vdom__$Child_Child_$Impl_$.element("button",__ret1,__r4)); | |
} | |
var __ret2 = { }; | |
__r1.push(coconut_vdom__$Child_Child_$Impl_$.element("menu",__ret2,__r3)); | |
if(tink_state__$Observable_Observable_$Impl_$.get_value(tink_state__$Observable_Observable_$Impl_$.get_value(this.__slots.todos.observe()).__coco_hasAnyCompleted)) { | |
var __ret3 = { onclick : tink_core__$Callback_Callback_$Impl_$.fromNiladic(($_=tink_state__$Observable_Observable_$Impl_$.get_value(_gthis.__slots.todos.observe()),$bind($_,$_.clearCompleted)))}; | |
var __r5 = []; | |
__r5.push(coconut_vdom__$Child_Child_$Impl_$.ofText("Clear Completed")); | |
__r1.push(coconut_vdom__$Child_Child_$Impl_$.element("button",__ret3,__r5)); | |
} | |
var __ret4 = { }; | |
__r.push(coconut_vdom__$Child_Child_$Impl_$.element("footer",__ret4,__r1)); | |
return __r[0]; | |
} | |
,__initAttributes: function(attributes) { | |
this.__slots.todos.setData(attributes.todos); | |
this.__slots.filter.setData(attributes.filter); | |
} | |
}); | |
var $fid = 0; | |
function $bind(o,m) { if( m == null ) return null; if( m.__id__ == null ) m.__id__ = $fid++; var f; if( o.hx__closures__ == null ) o.hx__closures__ = {}; else f = o.hx__closures__[m.__id__]; if( f == null ) { f = m.bind(o); o.hx__closures__[m.__id__] = f; } return f; } | |
String.__name__ = true; | |
Array.__name__ = true; | |
Date.__name__ = "Date"; | |
haxe_ds_ObjectMap.count = 0; | |
var __map_reserved = {}; | |
Object.defineProperty(js__$Boot_HaxeError.prototype,"message",{ get : function() { | |
return String(this.val); | |
}}); | |
coconut_diffing_Differ.EMPTY = { }; | |
coconut_ui_View.idCounter = 0; | |
coconut_vdom__$Child_Child_$Impl_$.differ = new coconut_vdom__$Child_DomDiffer(); | |
tink_core__$Callback_Callback_$Impl_$.depth = 0; | |
tink_pure__$List_Node.EMPTY = []; | |
tink_state__$Observable_Observable_$Impl_$.stack = new haxe_ds_List(); | |
tink_state_ConstObservable.NEVER = (function($this) { | |
var $r; | |
var this1 = new tink_core__$Future_SimpleFuture(function(_) { | |
return null; | |
}); | |
$r = this1; | |
return $r; | |
}(this)); | |
todomvc_data_TodoItem.idCounter = 0; | |
TodoMvc.main(); | |
})(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"/> | |
<title>TodoMVCoconut</title> | |
<meta name="description" content="TodoMVC implementation based on MVCoconut" /> | |
<link rel="stylesheet" type="text/css" href="styles.css"> | |
<link rel="icon" href="https://avatars1.githubusercontent.com/u/25455337?v=3&s=200" type="image/png" /> | |
</head> | |
<body> | |
<script src="todomvc-vdom.js"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment