// 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__10957){var map__10966 = p__10957;var map__10966__$1 = ((cljs.core.seq_QMARK_.call(null,map__10966))?cljs.core.apply.call(null,cljs.core.hash_map,map__10966):map__10966);var post_action = cljs.core.get.call(null,map__10966__$1,new cljs.core.Keyword(null,"post-action","post-action",4039331701));var action = cljs.core.get.call(null,map__10966__$1,new cljs.core.Keyword(null,"action","action",3885920680));var label = cljs.core.get.call(null,map__10966__$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__10967_10974 = 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_10971 = 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_10971;
}})], null)));var chunk__10968_10975 = null;var count__10969_10976 = 0;var i__10970_10977 = 0;while(true){
if((i__10970_10977 < count__10969_10976))
{var vec__10972_10978 = cljs.core._nth.call(null,chunk__10968_10975,i__10970_10977);var ev__3326__auto___10979 = cljs.core.nth.call(null,vec__10972_10978,0,null);var func__3327__auto___10980 = cljs.core.nth.call(null,vec__10972_10978,1,null);lt.util.dom.on.call(null,e__3325__auto__,ev__3326__auto___10979,func__3327__auto___10980);
{
var G__10981 = seq__10967_10974;
var G__10982 = chunk__10968_10975;
var G__10983 = count__10969_10976;
var G__10984 = (i__10970_10977 + 1);
seq__10967_10974 = G__10981;
chunk__10968_10975 = G__10982;
count__10969_10976 = G__10983;
i__10970_10977 = G__10984;
continue;
}
} else
{var temp__4092__auto___10985 = cljs.core.seq.call(null,seq__10967_10974);if(temp__4092__auto___10985)
{var seq__10967_10986__$1 = temp__4092__auto___10985;if(cljs.core.chunked_seq_QMARK_.call(null,seq__10967_10986__$1))
{var c__4262__auto___10987 = cljs.core.chunk_first.call(null,seq__10967_10986__$1);{
var G__10988 = cljs.core.chunk_rest.call(null,seq__10967_10986__$1);
var G__10989 = c__4262__auto___10987;
var G__10990 = cljs.core.count.call(null,c__4262__auto___10987);
var G__10991 = 0;
seq__10967_10974 = G__10988;
chunk__10968_10975 = G__10989;
count__10969_10976 = G__10990;
i__10970_10977 = G__10991;
continue;
}
} else
{var vec__10973_10992 = cljs.core.first.call(null,seq__10967_10986__$1);var ev__3326__auto___10993 = cljs.core.nth.call(null,vec__10973_10992,0,null);var func__3327__auto___10994 = cljs.core.nth.call(null,vec__10973_10992,1,null);lt.util.dom.on.call(null,e__3325__auto__,ev__3326__auto___10993,func__3327__auto___10994);
{
var G__10995 = cljs.core.next.call(null,seq__10967_10986__$1);
var G__10996 = null;
var G__10997 = 0;
var G__10998 = 0;
seq__10967_10974 = G__10995;
chunk__10968_10975 = G__10996;
count__10969_10976 = G__10997;
i__10970_10977 = G__10998;
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__11009(s__11010){return (new cljs.core.LazySeq(null,(function (){var s__11010__$1 = s__11010;while(true){
var temp__4092__auto__ = cljs.core.seq.call(null,s__11010__$1);if(temp__4092__auto__)
{var s__11010__$2 = temp__4092__auto__;if(cljs.core.chunked_seq_QMARK_.call(null,s__11010__$2))
{var c__4229__auto__ = cljs.core.chunk_first.call(null,s__11010__$2);var size__4230__auto__ = cljs.core.count.call(null,c__4229__auto__);var b__11012 = cljs.core.chunk_buffer.call(null,size__4230__auto__);if((function (){var i__11011 = 0;while(true){
if((i__11011 < size__4230__auto__))
{var b = cljs.core._nth.call(null,c__4229__auto__,i__11011);cljs.core.chunk_append.call(null,b__11012,lt.objs.popup.__GT_button.call(null,this$,b));
{
var G__11019 = (i__11011 + 1);
i__11011 = G__11019;
continue;
}
} else
{return true;
}
break;
}
})())
{return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__11012),iter__11009.call(null,cljs.core.chunk_rest.call(null,s__11010__$2)));
} else
{return cljs.core.chunk_cons.call(null,cljs.core.chunk.call(null,b__11012),null);
}
} else
{var b = cljs.core.first.call(null,s__11010__$2);return cljs.core.cons.call(null,lt.objs.popup.__GT_button.call(null,this$,b),iter__11009.call(null,cljs.core.rest.call(null,s__11010__$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__11013_11020 = 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__11014_11021 = null;var count__11015_11022 = 0;var i__11016_11023 = 0;while(true){
if((i__11016_11023 < count__11015_11022))
{var vec__11017_11024 = cljs.core._nth.call(null,chunk__11014_11021,i__11016_11023);var ev__3326__auto___11025 = cljs.core.nth.call(null,vec__11017_11024,0,null);var func__3327__auto___11026 = cljs.core.nth.call(null,vec__11017_11024,1,null);lt.util.dom.on.call(null,e__3325__auto__,ev__3326__auto___11025,func__3327__auto___11026);
{
var G__11027 = seq__11013_11020;
var G__11028 = chunk__11014_11021;
var G__11029 = count__11015_11022;
var G__11030 = (i__11016_11023 + 1);
seq__11013_11020 = G__11027;
chunk__11014_11021 = G__11028;
count__11015_11022 = G__11029;
i__11016_11023 = G__11030;
continue;
}
} else
{var temp__4092__auto___11031 = cljs.core.seq.call(null,seq__11013_11020);if(temp__4092__auto___11031)
{var seq__11013_11032__$1 = temp__4092__auto___11031;if(cljs.core.chunked_seq_QMARK_.call(null,seq__11013_11032__$1))
{var c__4262__auto___11033 = cljs.core.chunk_first.call(null,seq__11013_11032__$1);{
var G__11034 = cljs.core.chunk_rest.call(null,seq__11013_11032__$1);
var G__11035 = c__4262__auto___11033;
var G__11036 = cljs.core.count.call(null,c__4262__auto___11033);
var G__11037 = 0;
seq__11013_11020 = G__11034;
chunk__11014_11021 = G__11035;
count__11015_11022 = G__11036;
i__11016_11023 = G__11037;
continue;
}
} else
{var vec__11018_11038 = cljs.core.first.call(null,seq__11013_11032__$1);var ev__3326__auto___11039 = cljs.core.nth.call(null,vec__11018_11038,0,null);var func__3327__auto___11040 = cljs.core.nth.call(null,vec__11018_11038,1,null);lt.util.dom.on.call(null,e__3325__auto__,ev__3326__auto___11039,func__3327__auto___11040);
{
var G__11041 = cljs.core.next.call(null,seq__11013_11032__$1);
var G__11042 = null;
var G__11043 = 0;
var G__11044 = 0;
seq__11013_11020 = G__11041;
chunk__11014_11021 = G__11042;
count__11015_11022 = G__11043;
i__11016_11023 = G__11044;
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__11051_11057 = 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__11052_11058 = null;var count__11053_11059 = 0;var i__11054_11060 = 0;while(true){
if((i__11054_11060 < count__11053_11059))
{var vec__11055_11061 = cljs.core._nth.call(null,chunk__11052_11058,i__11054_11060);var ev__3326__auto___11062 = cljs.core.nth.call(null,vec__11055_11061,0,null);var func__3327__auto___11063 = cljs.core.nth.call(null,vec__11055_11061,1,null);lt.util.dom.on.call(null,e__3325__auto__,ev__3326__auto___11062,func__3327__auto___11063);
{
var G__11064 = seq__11051_11057;
var G__11065 = chunk__11052_11058;
var G__11066 = count__11053_11059;
var G__11067 = (i__11054_11060 + 1);
seq__11051_11057 = G__11064;
chunk__11052_11058 = G__11065;
count__11053_11059 = G__11066;
i__11054_11060 = G__11067;
continue;
}
} else
{var temp__4092__auto___11068 = cljs.core.seq.call(null,seq__11051_11057);if(temp__4092__auto___11068)
{var seq__11051_11069__$1 = temp__4092__auto___11068;if(cljs.core.chunked_seq_QMARK_.call(null,seq__11051_11069__$1))
{var c__4262__auto___11070 = cljs.core.chunk_first.call(null,seq__11051_11069__$1);{
var G__11071 = cljs.core.chunk_rest.call(null,seq__11051_11069__$1);
var G__11072 = c__4262__auto___11070;
var G__11073 = cljs.core.count.call(null,c__4262__auto___11070);
var G__11074 = 0;
seq__11051_11057 = G__11071;
chunk__11052_11058 = G__11072;
count__11053_11059 = G__11073;
i__11054_11060 = G__11074;
continue;
}
} else
{var vec__11056_11075 = cljs.core.first.call(null,seq__11051_11069__$1);var ev__3326__auto___11076 = cljs.core.nth.call(null,vec__11056_11075,0,null);var func__3327__auto___11077 = cljs.core.nth.call(null,vec__11056_11075,1,null);lt.util.dom.on.call(null,e__3325__auto__,ev__3326__auto___11076,func__3327__auto___11077);
{
var G__11078 = cljs.core.next.call(null,seq__11051_11069__$1);
var G__11079 = null;
var G__11080 = 0;
var G__11081 = 0;
seq__11051_11057 = G__11078;
chunk__11052_11058 = G__11079;
count__11053_11059 = G__11080;
i__11054_11060 = G__11081;
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);
