// Compiled by ClojureScript 0.0-2138
goog.provide('lt.objs.popup');
goog.require('cljs.core');
goog.require('lt.util.dom');
goog.require('lt.objs.context');
goog.require('lt.objs.context');
goog.require('lt.util.dom');
goog.require('lt.objs.canvas');
goog.require('lt.objs.command');
goog.require('lt.objs.keyboard');
goog.require('lt.objs.canvas');
goog.require('lt.object');
goog.require('lt.object');
goog.require('lt.objs.command');
goog.require('lt.objs.keyboard');
lt.objs.popup._STAR_no_close_STAR_ = null;
lt.objs.popup.__BEH__on_click_destroy = (function __BEH__on_click_destroy(this$){return lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"close!","close!",3951350939));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.popup","on-click-destroy","lt.objs.popup/on-click-destroy",4693561385),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.popup.__BEH__on_click_destroy,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"click","click",1108654330),null], null), null));
lt.objs.popup.__BEH__close_BANG_ = (function __BEH__close_BANG_(this$){lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"close","close",1108660586));
lt.object.destroy_BANG_.call(null,this$);
var temp__4090__auto__ = cljs.core.seq.call(null,lt.object.by_tag.call(null,new cljs.core.Keyword(null,"popup","popup",1120756766)));if(temp__4090__auto__)
{var others = temp__4090__auto__;return lt.objs.context.in_BANG_.call(null,new cljs.core.Keyword(null,"popup","popup",1120756766),cljs.core.last.call(null,others));
} else
{return lt.objs.context.out_BANG_.call(null,new cljs.core.Keyword(null,"popup","popup",1120756766));
}
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.popup","close!","lt.objs.popup/close!",4613970955),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.popup.__BEH__close_BANG_,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"close!","close!",3951350939),null], null), null));
lt.objs.popup.__BEH__refocus_on_close = (function __BEH__refocus_on_close(this$){return lt.objs.command.exec_BANG_.call(null,new cljs.core.Keyword(null,"tabs.focus-active","tabs.focus-active",2001074557));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.popup","refocus-on-close","lt.objs.popup/refocus-on-close",2521298612),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.popup.__BEH__refocus_on_close,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"close","close",1108660586),null], null), null));
lt.objs.popup.__BEH__change_active_button = (function __BEH__change_active_button(this$,dir){var buttons = lt.util.dom.$$.call(null,".button",lt.object.__GT_content.call(null,this$));var button = cljs.core.mod.call(null,(new cljs.core.Keyword(null,"button","button",3931183780).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,this$)) + dir),cljs.core.count.call(null,buttons));lt.util.dom.remove_class.call(null,(buttons[new cljs.core.Keyword(null,"button","button",3931183780).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,this$))]),new cljs.core.Keyword(null,"active","active",3885920888));
lt.util.dom.add_class.call(null,(buttons[button]),new cljs.core.Keyword(null,"active","active",3885920888));
return lt.object.merge_BANG_.call(null,this$,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"button","button",3931183780),button], null));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.popup","change-active-button","lt.objs.popup/change-active-button",2736197342),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.popup.__BEH__change_active_button,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"move-active","move-active",3635471348),null], null), null));
lt.objs.popup.__BEH__exec_active = (function __BEH__exec_active(this$){var buttons = lt.util.dom.$$.call(null,".button",lt.object.__GT_content.call(null,this$));return lt.util.dom.trigger.call(null,(buttons[new cljs.core.Keyword(null,"button","button",3931183780).cljs$core$IFn$_invoke$arity$1(cljs.core.deref.call(null,this$))]),new cljs.core.Keyword(null,"click","click",1108654330));
});
lt.object.behavior_STAR_.call(null,new cljs.core.Keyword("lt.objs.popup","exec-active","lt.objs.popup/exec-active",1054217124),new cljs.core.Keyword(null,"reaction","reaction",4441361819),lt.objs.popup.__BEH__exec_active,new cljs.core.Keyword(null,"triggers","triggers",2516997421),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"exec-active","exec-active",533892916),null], null), null));
lt.objs.popup.remain_open = (function remain_open(){return lt.objs.popup._STAR_no_close_STAR_ = true;
});
lt.objs.popup.__GT_button = (function __GT_button(this$,p__11466){var map__11475 = p__11466;var map__11475__$1 = ((cljs.core.seq_QMARK_.call(null,map__11475))?cljs.core.apply.call(null,cljs.core.hash_map,map__11475):map__11475);var post_action = cljs.core.get.call(null,map__11475__$1,new cljs.core.Keyword(null,"post-action","post-action",4039331701));var action = cljs.core.get.call(null,map__11475__$1,new cljs.core.Keyword(null,"action","action",3885920680));var label = cljs.core.get.call(null,map__11475__$1,new cljs.core.Keyword(null,"label","label",1116631654));var e__3325__auto__ = crate.core.html.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"li.button","li.button",2481585205),label], null));var seq__11476_11483 = cljs.core.seq.call(null,cljs.core.partition.call(null,2,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"click","click",1108654330),(function (){var _STAR_no_close_STAR_11480 = lt.objs.popup._STAR_no_close_STAR_;try{lt.objs.popup._STAR_no_close_STAR_ = null;
if(cljs.core.fn_QMARK_.call(null,action))
{action.call(null);
} else
{}
if(cljs.core.truth_(lt.objs.popup._STAR_no_close_STAR_))
{} else
{lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"close!","close!",3951350939));
}
if(cljs.core.fn_QMARK_.call(null,post_action))
{return post_action.call(null);
} else
{return null;
}
}finally {lt.objs.popup._STAR_no_close_STAR_ = _STAR_no_close_STAR_11480;
}})], null)));var chunk__11477_11484 = null;var count__11478_11485 = 0;var i__11479_11486 = 0;while(true){
if((i__11479_11486 < count__11478_11485))
{var vec__11481_11487 = cljs.core._nth.call(null,chunk__11477_11484,i__11479_11486);var ev__3326__auto___11488 = cljs.core.nth.call(null,vec__11481_11487,0,null);var func__3327__auto___11489 = cljs.core.nth.call(null,vec__11481_11487,1,null);lt.util.dom.on.call(null,e__3325__auto__,ev__3326__auto___11488,func__3327__auto___11489);
{
var G__11490 = seq__11476_11483;
var G__11491 = chunk__11477_11484;
var G__11492 = count__11478_11485;
var G__11493 = (i__11479_11486 + 1);
seq__11476_11483 = G__11490;
chunk__11477_11484 = G__11491;
count__11478_11485 = G__11492;
i__11479_11486 = G__11493;
continue;
}
} else
{var temp__4092__auto___11494 = cljs.core.seq.call(null,seq__11476_11483);if(temp__4092__auto___11494)
{var seq__11476_11495__$1 = temp__4092__auto___11494;if(cljs.core.chunked_seq_QMARK_.call(null,seq__11476_11495__$1))
{var c__4262__auto___11496 = cljs.core.chunk_first.call(null,seq__11476_11495__$1);{
var G__11497 = cljs.core.chunk_rest.call(null,seq__11476_11495__$1);
var G__11498 = c__4262__auto___11496;
var G__11499 = cljs.core.count.call(null,c__4262__auto___11496);
var G__11500 = 0;
seq__11476_11483 = G__11497;
chunk__11477_11484 = G__11498;
count__11478_11485 = G__11499;
i__11479_11486 = G__11500;
continue;
}
} else
{var vec__11482_11501 = cljs.core.first.call(null,seq__11476_11495__$1);var ev__3326__auto___11502 = cljs.core.nth.call(null,vec__11482_11501,0,null);var func__3327__auto___11503 = cljs.core.nth.call(null,vec__11482_11501,1,null);lt.util.dom.on.call(null,e__3325__auto__,ev__3326__auto___11502,func__3327__auto___11503);
{
var G__11504 = cljs.core.next.call(null,seq__11476_11495__$1);
var G__11505 = null;
var G__11506 = 0;
var G__11507 = 0;
seq__11476_11483 = G__11504;
chunk__11477_11484 = G__11505;
count__11478_11485 = G__11506;
i__11479_11486 = G__11507;
continue;
}
}
} else
{}
}
break;
}
return e__3325__auto__;
});
lt.objs.popup.popup_content = (function popup_content(this$,opts){var e__3325__auto__ = crate.core.html.call(null,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"div","div",1014003715),new cljs.core.PersistentVector(null, 4, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"div","div",1014003715),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"h2","h2",1013907516),new cljs.core.Keyword(null,"header","header",4087600639).cljs$core$IFn$_invoke$arity$1(opts)], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"p","p",1013904354),new cljs.core.Keyword(null,"body","body",1016933652).cljs$core$IFn$_invoke$arity$1(opts)], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"ul.buttons","ul.buttons",666323612),(function (){var iter__4231__auto__ = (function iter__11518(s__11519){return (new cljs.core.LazySeq(null,(function (){var s__11519__$1 = s__11519;while(true){
var temp__4092__auto__ = cljs.core.seq.call(null,s__11519__$1);if(temp__4092__auto__)
{var s__11519__$2 = temp__4092__auto__;if(cljs.core.chunked_seq_QMARK_.call(null,s__11519__$2))
{var c__4229__auto__ = cljs.core.chunk_first.call(null,s__11519__$2);var size__4230__auto__ = cljs.core.count.call(null,c__4229__auto__);var b__11521 = cljs.core.chunk_buffer.call(null,size__4230__auto__);if((function (){var i__11520 = 0;while(true){
if((i__11520 < size__4230__auto__))
{var b = cljs.core._nth.call(null,c__4229__auto__,i__11520);cljs.core.chunk_append.call(null,b__11521,lt.objs.popup.__GT_button.call(null,this$,b));
{
var G__11528 = (i__11520 + 1);
i__11520 = G__11528;
continue;
}
} else
{return true;
}
break;
}
})())
{return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__11521),iter__11518.call(null,cljs.core.chunk_rest.call(null,s__11519__$2)));
} else
{return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__11521),null);
}
} else
{var b = cljs.core.first.call(null,s__11519__$2);return cljs.core.cons.call(null,lt.objs.popup.__GT_button.call(null,this$,b),iter__11518.call(null,cljs.core.rest.call(null,s__11519__$2)));
}
} else
{return null;
}
break;
}
}),null,null));
});return iter__4231__auto__.call(null,cljs.core.reverse.call(null,new cljs.core.Keyword(null,"buttons","buttons",1255256819).cljs$core$IFn$_invoke$arity$1(opts)));
})()], null)], null)], null));var seq__11522_11529 = cljs.core.seq.call(null,cljs.core.partition.call(null,2,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"click","click",1108654330),(function (e){lt.util.dom.prevent.call(null,e);
return lt.util.dom.stop_propagation.call(null,e);
})], null)));var chunk__11523_11530 = null;var count__11524_11531 = 0;var i__11525_11532 = 0;while(true){
if((i__11525_11532 < count__11524_11531))
{var vec__11526_11533 = cljs.core._nth.call(null,chunk__11523_11530,i__11525_11532);var ev__3326__auto___11534 = cljs.core.nth.call(null,vec__11526_11533,0,null);var func__3327__auto___11535 = cljs.core.nth.call(null,vec__11526_11533,1,null);lt.util.dom.on.call(null,e__3325__auto__,ev__3326__auto___11534,func__3327__auto___11535);
{
var G__11536 = seq__11522_11529;
var G__11537 = chunk__11523_11530;
var G__11538 = count__11524_11531;
var G__11539 = (i__11525_11532 + 1);
seq__11522_11529 = G__11536;
chunk__11523_11530 = G__11537;
count__11524_11531 = G__11538;
i__11525_11532 = G__11539;
continue;
}
} else
{var temp__4092__auto___11540 = cljs.core.seq.call(null,seq__11522_11529);if(temp__4092__auto___11540)
{var seq__11522_11541__$1 = temp__4092__auto___11540;if(cljs.core.chunked_seq_QMARK_.call(null,seq__11522_11541__$1))
{var c__4262__auto___11542 = cljs.core.chunk_first.call(null,seq__11522_11541__$1);{
var G__11543 = cljs.core.chunk_rest.call(null,seq__11522_11541__$1);
var G__11544 = c__4262__auto___11542;
var G__11545 = cljs.core.count.call(null,c__4262__auto___11542);
var G__11546 = 0;
seq__11522_11529 = G__11543;
chunk__11523_11530 = G__11544;
count__11524_11531 = G__11545;
i__11525_11532 = G__11546;
continue;
}
} else
{var vec__11527_11547 = cljs.core.first.call(null,seq__11522_11541__$1);var ev__3326__auto___11548 = cljs.core.nth.call(null,vec__11527_11547,0,null);var func__3327__auto___11549 = cljs.core.nth.call(null,vec__11527_11547,1,null);lt.util.dom.on.call(null,e__3325__auto__,ev__3326__auto___11548,func__3327__auto___11549);
{
var G__11550 = cljs.core.next.call(null,seq__11522_11541__$1);
var G__11551 = null;
var G__11552 = 0;
var G__11553 = 0;
seq__11522_11529 = G__11550;
chunk__11523_11530 = G__11551;
count__11524_11531 = G__11552;
i__11525_11532 = G__11553;
continue;
}
}
} else
{}
}
break;
}
return e__3325__auto__;
});
lt.objs.popup.popup = (function popup(this$,opts){var e__3325__auto__ = crate.core.html.call(null,new cljs.core.PersistentVector(null, 3, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"div.popup","div.popup",2038588545),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"tabindex","tabindex",4410954191),-1], null),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"div","div",1014003715),lt.objs.popup.popup_content.call(null,this$,opts)], null)], null));var seq__11560_11566 = cljs.core.seq.call(null,cljs.core.partition.call(null,2,new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"click","click",1108654330),(function (){return lt.object.raise.call(null,this$,new cljs.core.Keyword(null,"click","click",1108654330));
})], null)));var chunk__11561_11567 = null;var count__11562_11568 = 0;var i__11563_11569 = 0;while(true){
if((i__11563_11569 < count__11562_11568))
{var vec__11564_11570 = cljs.core._nth.call(null,chunk__11561_11567,i__11563_11569);var ev__3326__auto___11571 = cljs.core.nth.call(null,vec__11564_11570,0,null);var func__3327__auto___11572 = cljs.core.nth.call(null,vec__11564_11570,1,null);lt.util.dom.on.call(null,e__3325__auto__,ev__3326__auto___11571,func__3327__auto___11572);
{
var G__11573 = seq__11560_11566;
var G__11574 = chunk__11561_11567;
var G__11575 = count__11562_11568;
var G__11576 = (i__11563_11569 + 1);
seq__11560_11566 = G__11573;
chunk__11561_11567 = G__11574;
count__11562_11568 = G__11575;
i__11563_11569 = G__11576;
continue;
}
} else
{var temp__4092__auto___11577 = cljs.core.seq.call(null,seq__11560_11566);if(temp__4092__auto___11577)
{var seq__11560_11578__$1 = temp__4092__auto___11577;if(cljs.core.chunked_seq_QMARK_.call(null,seq__11560_11578__$1))
{var c__4262__auto___11579 = cljs.core.chunk_first.call(null,seq__11560_11578__$1);{
var G__11580 = cljs.core.chunk_rest.call(null,seq__11560_11578__$1);
var G__11581 = c__4262__auto___11579;
var G__11582 = cljs.core.count.call(null,c__4262__auto___11579);
var G__11583 = 0;
seq__11560_11566 = G__11580;
chunk__11561_11567 = G__11581;
count__11562_11568 = G__11582;
i__11563_11569 = G__11583;
continue;
}
} else
{var vec__11565_11584 = cljs.core.first.call(null,seq__11560_11578__$1);var ev__3326__auto___11585 = cljs.core.nth.call(null,vec__11565_11584,0,null);var func__3327__auto___11586 = cljs.core.nth.call(null,vec__11565_11584,1,null);lt.util.dom.on.call(null,e__3325__auto__,ev__3326__auto___11585,func__3327__auto___11586);
{
var G__11587 = cljs.core.next.call(null,seq__11560_11578__$1);
var G__11588 = null;
var G__11589 = 0;
var G__11590 = 0;
seq__11560_11566 = G__11587;
chunk__11561_11567 = G__11588;
count__11562_11568 = G__11589;
i__11563_11569 = G__11590;
continue;
}
}
} else
{}
}
break;
}
return e__3325__auto__;
});
lt.object.object_STAR_.call(null,new cljs.core.Keyword("lt.objs.popup","popup","lt.objs.popup/popup",767372430),new cljs.core.Keyword(null,"tags","tags",1017456523),new cljs.core.PersistentHashSet(null, new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"popup","popup",1120756766),null], null), null),new cljs.core.Keyword(null,"button","button",3931183780),0,new cljs.core.Keyword(null,"init","init",1017141378),(function (this$,content){return lt.objs.popup.popup.call(null,this$,content);
}));
lt.objs.command.command.call(null,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"command","command",1964298941),new cljs.core.Keyword(null,"popup.exec-active","popup.exec-active",2113737970),new cljs.core.Keyword(null,"desc","desc",1016984067),"Popup: execute active option",new cljs.core.Keyword(null,"hidden","hidden",4091384092),true,new cljs.core.Keyword(null,"exec","exec",1017031683),(function (){var temp__4092__auto__ = lt.objs.context.__GT_obj.call(null,new cljs.core.Keyword(null,"popup","popup",1120756766));if(cljs.core.truth_(temp__4092__auto__))
{var p = temp__4092__auto__;return lt.object.raise.call(null,p,new cljs.core.Keyword(null,"exec-active","exec-active",533892916));
} else
{return null;
}
})], null));
lt.objs.command.command.call(null,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"command","command",1964298941),new cljs.core.Keyword(null,"popup.move-active","popup.move-active",920349106),new cljs.core.Keyword(null,"desc","desc",1016984067),"Popup: move selection",new cljs.core.Keyword(null,"hidden","hidden",4091384092),true,new cljs.core.Keyword(null,"exec","exec",1017031683),(function (dir){var temp__4092__auto__ = lt.objs.context.__GT_obj.call(null,new cljs.core.Keyword(null,"popup","popup",1120756766));if(cljs.core.truth_(temp__4092__auto__))
{var p = temp__4092__auto__;return lt.object.raise.call(null,p,new cljs.core.Keyword(null,"move-active","move-active",3635471348),dir);
} else
{return null;
}
})], null));
lt.objs.command.command.call(null,new cljs.core.PersistentArrayMap(null, 4, [new cljs.core.Keyword(null,"command","command",1964298941),new cljs.core.Keyword(null,"popup.escape","popup.escape",1937231733),new cljs.core.Keyword(null,"desc","desc",1016984067),"Popup: escape",new cljs.core.Keyword(null,"hidden","hidden",4091384092),true,new cljs.core.Keyword(null,"exec","exec",1017031683),(function (){var temp__4092__auto__ = lt.objs.context.__GT_obj.call(null,new cljs.core.Keyword(null,"popup","popup",1120756766));if(cljs.core.truth_(temp__4092__auto__))
{var p = temp__4092__auto__;return lt.object.raise.call(null,p,new cljs.core.Keyword(null,"click","click",1108654330));
} else
{return null;
}
})], null));
lt.objs.popup.popup_BANG_ = (function popup_BANG_(options){var p = lt.object.create.call(null,new cljs.core.Keyword("lt.objs.popup","popup","lt.objs.popup/popup",767372430),options);lt.object.raise.call(null,p,new cljs.core.Keyword(null,"move-active","move-active",3635471348),0);
lt.util.dom.append.call(null,lt.util.dom.$.call(null,new cljs.core.Keyword(null,"body","body",1016933652)),lt.object.__GT_content.call(null,p));
lt.object.__GT_content.call(null,p).focus();
lt.objs.context.in_BANG_.call(null,new cljs.core.Keyword(null,"popup","popup",1120756766),p);
return p;
});
lt.objs.popup.cancel_button = new cljs.core.PersistentArrayMap(null, 2, [new cljs.core.Keyword(null,"label","label",1116631654),"cancel",new cljs.core.Keyword(null,"action","action",3885920680),new cljs.core.Keyword(null,"cancel","cancel",3941147116)], null);
