// Compiled by ClojureScript 1.9.562 {}
goog.provide('weathergen.ui.buttons');
goog.require('cljs.core');
goog.require('weathergen.ui.common');
goog.require('taoensso.timbre');
goog.require('javelin.core');
goog.require('hoplon.jquery');
goog.require('hoplon.core');
weathergen.ui.buttons.image_button_style = (function weathergen$ui$buttons$image_button_style(pressed_QMARK_){
return new cljs.core.PersistentArrayMap(null, 7, [new cljs.core.Keyword(null,"border-style","border-style",-485574304),(cljs.core.truth_(pressed_QMARK_)?"inset":"outset"),new cljs.core.Keyword(null,"border-color","border-color",-2059162761),"#ddd",new cljs.core.Keyword(null,"border-radius","border-radius",419594011),"6px",new cljs.core.Keyword(null,"padding","padding",1660304693),"2px",new cljs.core.Keyword(null,"background","background",-863952629),(cljs.core.truth_(pressed_QMARK_)?"lightgrey":"white"),new cljs.core.Keyword(null,"border-width","border-width",-1512605390),"2px",new cljs.core.Keyword(null,"vertical-align","vertical-align",651007333),"middle"], null);
});
/**
 * A button displaying an image rather than text. Can take a
 *   `latched?` attribute, which, if a cell evaluating to true, locks the
 *   button in the pressed state.
 * @param {...*} var_args
 */
weathergen.ui.buttons.image_button = (function() { 
var weathergen$ui$buttons$image_button__delegate = function (args__29571__auto__){
var vec__36712 = hoplon.core.parse_args.call(null,args__29571__auto__);
var attrs = cljs.core.nth.call(null,vec__36712,(0),null);
var map__36715 = attrs;
var map__36715__$1 = ((((!((map__36715 == null)))?((((map__36715.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36715.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36715):map__36715);
var css = cljs.core.get.call(null,map__36715__$1,new cljs.core.Keyword(null,"css","css",1135045163));
var latched_QMARK_ = cljs.core.get.call(null,map__36715__$1,new cljs.core.Keyword(null,"latched?","latched?",2124907793));
var attrs__$1 = cljs.core.dissoc.call(null,attrs,new cljs.core.Keyword(null,"css","css",1135045163),new cljs.core.Keyword(null,"latched?","latched?",2124907793));
var down = javelin.core.cell.call(null,false);
return hoplon.core.img.call(null,new cljs.core.Keyword(null,"css","css",1135045163),javelin.core.formula.call(null,((function (down,map__36715,map__36715__$1,css,latched_QMARK_,attrs__$1,vec__36712,attrs){
return (function (latched_QMARK___$1,down__$1){
return cljs.core.merge.call(null,weathergen.ui.buttons.image_button_style.call(null,(function (){var or__23148__auto__ = latched_QMARK___$1;
if(cljs.core.truth_(or__23148__auto__)){
return or__23148__auto__;
} else {
return down__$1;
}
})()),css);
});})(down,map__36715,map__36715__$1,css,latched_QMARK_,attrs__$1,vec__36712,attrs))
).call(null,latched_QMARK_,down),new cljs.core.Keyword(null,"mousedown","mousedown",1391242074),((function (down,map__36715,map__36715__$1,css,latched_QMARK_,attrs__$1,vec__36712,attrs){
return (function (e){
var up_36717 = ((function (down,map__36715,map__36715__$1,css,latched_QMARK_,attrs__$1,vec__36712,attrs){
return (function weathergen$ui$buttons$image_button_$_up_fn(e__$1){
document.removeEventListener("mouseup",weathergen$ui$buttons$image_button_$_up_fn);

return cljs.core.reset_BANG_.call(null,down,false);
});})(down,map__36715,map__36715__$1,css,latched_QMARK_,attrs__$1,vec__36712,attrs))
;
document.addEventListener("mouseup",up_36717);

return cljs.core.reset_BANG_.call(null,down,true);
});})(down,map__36715,map__36715__$1,css,latched_QMARK_,attrs__$1,vec__36712,attrs))
,new cljs.core.Keyword(null,"dragstart","dragstart",955864218),cljs.core.constantly.call(null,false),attrs__$1);
};
var weathergen$ui$buttons$image_button = function (var_args){
var args__29571__auto__ = null;
if (arguments.length > 0) {
var G__36718__i = 0, G__36718__a = new Array(arguments.length -  0);
while (G__36718__i < G__36718__a.length) {G__36718__a[G__36718__i] = arguments[G__36718__i + 0]; ++G__36718__i;}
  args__29571__auto__ = new cljs.core.IndexedSeq(G__36718__a,0,null);
} 
return weathergen$ui$buttons$image_button__delegate.call(this,args__29571__auto__);};
weathergen$ui$buttons$image_button.cljs$lang$maxFixedArity = 0;
weathergen$ui$buttons$image_button.cljs$lang$applyTo = (function (arglist__36719){
var args__29571__auto__ = cljs.core.seq(arglist__36719);
return weathergen$ui$buttons$image_button__delegate(args__29571__auto__);
});
weathergen$ui$buttons$image_button.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$buttons$image_button__delegate;
return weathergen$ui$buttons$image_button;
})()
;
weathergen.ui.common.register_class_BANG_.call(null,new cljs.core.Keyword("weathergen.ui.buttons","div-button","weathergen.ui.buttons/div-button",-1385258890),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [cljs.core.PersistentHashMap.fromArrays([new cljs.core.Keyword(null,"border-style","border-style",-485574304),new cljs.core.Keyword(null,"color","color",1011675173),new cljs.core.Keyword(null,"font-size","font-size",-1847940346),new cljs.core.Keyword(null,"background","background",-863952629),new cljs.core.Keyword(null,"cursor","cursor",1011937484),new cljs.core.Keyword(null,"border-width","border-width",-1512605390),new cljs.core.Keyword(null,"padding","padding",1660304693),new cljs.core.Keyword(null,"border-color","border-color",-2059162761),new cljs.core.Keyword(null,"text-decoration","text-decoration",1836813207),new cljs.core.Keyword(null,"display","display",242065432),new cljs.core.Keyword(null,"border-radius","border-radius",419594011),new cljs.core.Keyword(null,"font-family","font-family",-667419874),new cljs.core.Keyword(null,"margin","margin",-995903681)],["solid","black","72%","linear-gradient(white, white 75%, #ededed 100%)","pointer","0.5px","3px","#d0d0d0","none","inline-block","4px","Lucida Grande, Lucida Sans Unicode, Tahoma, sans-serif","2px"]),new cljs.core.PersistentVector(null, 2, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.Keyword(null,"&:active","&:active",-1687810105),new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"background","background",-863952629),"linear-gradient(#c0c0c0, #f0f0f0)"], null)], null)], null));
weathergen.ui.common.register_class_BANG_.call(null,new cljs.core.Keyword("weathergen.ui.buttons","latched-div-button","weathergen.ui.buttons/latched-div-button",103418273),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"background","background",-863952629),"linear-gradient(#c0c0c0, #f0f0f0)"], null)], null));
/**
 * Renders a plain button, but using an anchor tag to better enable
 *   styling. Can take a `latched?` attribute, which, if a cell
 *   evaluating to true, locks the button in the pressed state.
 * @param {...*} var_args
 */
weathergen.ui.buttons.a_button = (function() { 
var weathergen$ui$buttons$a_button__delegate = function (args__29571__auto__){
var vec__36725 = hoplon.core.parse_args.call(null,args__29571__auto__);
var attrs = cljs.core.nth.call(null,vec__36725,(0),null);
var content = cljs.core.nth.call(null,vec__36725,(1),null);
var map__36728 = attrs;
var map__36728__$1 = ((((!((map__36728 == null)))?((((map__36728.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__36728.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__36728):map__36728);
var latched_QMARK_ = cljs.core.get.call(null,map__36728__$1,new cljs.core.Keyword(null,"latched?","latched?",2124907793));
var attrs__$1 = cljs.core.dissoc.call(null,attrs,new cljs.core.Keyword(null,"latched?","latched?",2124907793));
var down = javelin.core.cell.call(null,false);
return hoplon.core.a.call(null,cljs.core.merge.call(null,attrs__$1,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"class","class",-2030961996),javelin.core.formula.call(null,((function (down,map__36728,map__36728__$1,latched_QMARK_,attrs__$1,vec__36725,attrs,content){
return (function (latched_QMARK___$1,down__$1){
return cljs.core.PersistentArrayMap.createAsIfByAssoc([weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.buttons","div-button","weathergen.ui.buttons/div-button",-1385258890)),true,weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.buttons","latched-div-button","weathergen.ui.buttons/latched-div-button",103418273)),(function (){var or__23148__auto__ = latched_QMARK___$1;
if(cljs.core.truth_(or__23148__auto__)){
return or__23148__auto__;
} else {
return down__$1;
}
})()]);
});})(down,map__36728,map__36728__$1,latched_QMARK_,attrs__$1,vec__36725,attrs,content))
).call(null,latched_QMARK_,down)], null)),content);
};
var weathergen$ui$buttons$a_button = function (var_args){
var args__29571__auto__ = null;
if (arguments.length > 0) {
var G__36730__i = 0, G__36730__a = new Array(arguments.length -  0);
while (G__36730__i < G__36730__a.length) {G__36730__a[G__36730__i] = arguments[G__36730__i + 0]; ++G__36730__i;}
  args__29571__auto__ = new cljs.core.IndexedSeq(G__36730__a,0,null);
} 
return weathergen$ui$buttons$a_button__delegate.call(this,args__29571__auto__);};
weathergen$ui$buttons$a_button.cljs$lang$maxFixedArity = 0;
weathergen$ui$buttons$a_button.cljs$lang$applyTo = (function (arglist__36731){
var args__29571__auto__ = cljs.core.seq(arglist__36731);
return weathergen$ui$buttons$a_button__delegate(args__29571__auto__);
});
weathergen$ui$buttons$a_button.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$buttons$a_button__delegate;
return weathergen$ui$buttons$a_button;
})()
;
