// 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__29774__auto__){
var vec__38244 = hoplon.core.parse_args.call(null,args__29774__auto__);
var attrs = cljs.core.nth.call(null,vec__38244,(0),null);
var map__38247 = attrs;
var map__38247__$1 = ((((!((map__38247 == null)))?((((map__38247.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__38247.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__38247):map__38247);
var css = cljs.core.get.call(null,map__38247__$1,new cljs.core.Keyword(null,"css","css",1135045163));
var latched_QMARK_ = cljs.core.get.call(null,map__38247__$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__38247,map__38247__$1,css,latched_QMARK_,attrs__$1,vec__38244,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__23338__auto__ = latched_QMARK___$1;
if(cljs.core.truth_(or__23338__auto__)){
return or__23338__auto__;
} else {
return down__$1;
}
})()),css);
});})(down,map__38247,map__38247__$1,css,latched_QMARK_,attrs__$1,vec__38244,attrs))
).call(null,latched_QMARK_,down),new cljs.core.Keyword(null,"mousedown","mousedown",1391242074),((function (down,map__38247,map__38247__$1,css,latched_QMARK_,attrs__$1,vec__38244,attrs){
return (function (e){
var up_38249 = ((function (down,map__38247,map__38247__$1,css,latched_QMARK_,attrs__$1,vec__38244,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__38247,map__38247__$1,css,latched_QMARK_,attrs__$1,vec__38244,attrs))
;
document.addEventListener("mouseup",up_38249);

return cljs.core.reset_BANG_.call(null,down,true);
});})(down,map__38247,map__38247__$1,css,latched_QMARK_,attrs__$1,vec__38244,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__29774__auto__ = null;
if (arguments.length > 0) {
var G__38250__i = 0, G__38250__a = new Array(arguments.length -  0);
while (G__38250__i < G__38250__a.length) {G__38250__a[G__38250__i] = arguments[G__38250__i + 0]; ++G__38250__i;}
  args__29774__auto__ = new cljs.core.IndexedSeq(G__38250__a,0,null);
} 
return weathergen$ui$buttons$image_button__delegate.call(this,args__29774__auto__);};
weathergen$ui$buttons$image_button.cljs$lang$maxFixedArity = 0;
weathergen$ui$buttons$image_button.cljs$lang$applyTo = (function (arglist__38251){
var args__29774__auto__ = cljs.core.seq(arglist__38251);
return weathergen$ui$buttons$image_button__delegate(args__29774__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));
weathergen.ui.common.register_class_BANG_.call(null,new cljs.core.Keyword("weathergen.ui.buttons","disabled-button","weathergen.ui.buttons/disabled-button",1352747181),new cljs.core.PersistentVector(null, 1, 5, cljs.core.PersistentVector.EMPTY_NODE, [new cljs.core.PersistentArrayMap(null, 3, [new cljs.core.Keyword(null,"pointer-events","pointer-events",-1053858853),"none",new cljs.core.Keyword(null,"color","color",1011675173),"grey",new cljs.core.Keyword(null,"cursor","cursor",1011937484),"default"], 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. Can take
 *   a `disabled?` attribute, which, if a cell evalating to true,
 *   disables the button.
 * @param {...*} var_args
 */
weathergen.ui.buttons.a_button = (function() { 
var weathergen$ui$buttons$a_button__delegate = function (args__29774__auto__){
var vec__38257 = hoplon.core.parse_args.call(null,args__29774__auto__);
var attrs = cljs.core.nth.call(null,vec__38257,(0),null);
var content = cljs.core.nth.call(null,vec__38257,(1),null);
var map__38260 = attrs;
var map__38260__$1 = ((((!((map__38260 == null)))?((((map__38260.cljs$lang$protocol_mask$partition0$ & (64))) || ((cljs.core.PROTOCOL_SENTINEL === map__38260.cljs$core$ISeq$)))?true:false):false))?cljs.core.apply.call(null,cljs.core.hash_map,map__38260):map__38260);
var disabled_QMARK_ = cljs.core.get.call(null,map__38260__$1,new cljs.core.Keyword(null,"disabled?","disabled?",-1523234181));
var latched_QMARK_ = cljs.core.get.call(null,map__38260__$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),new cljs.core.Keyword(null,"disabled?","disabled?",-1523234181));
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__38260,map__38260__$1,disabled_QMARK_,latched_QMARK_,attrs__$1,vec__38257,attrs,content){
return (function (latched_QMARK___$1,down__$1,disabled_QMARK___$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__23338__auto__ = latched_QMARK___$1;
if(cljs.core.truth_(or__23338__auto__)){
return or__23338__auto__;
} else {
return down__$1;
}
})(),weathergen.ui.common.class_for.call(null,new cljs.core.Keyword("weathergen.ui.buttons","disabled-button","weathergen.ui.buttons/disabled-button",1352747181)),disabled_QMARK___$1]);
});})(down,map__38260,map__38260__$1,disabled_QMARK_,latched_QMARK_,attrs__$1,vec__38257,attrs,content))
).call(null,latched_QMARK_,down,disabled_QMARK_)], null)),content);
};
var weathergen$ui$buttons$a_button = function (var_args){
var args__29774__auto__ = null;
if (arguments.length > 0) {
var G__38262__i = 0, G__38262__a = new Array(arguments.length -  0);
while (G__38262__i < G__38262__a.length) {G__38262__a[G__38262__i] = arguments[G__38262__i + 0]; ++G__38262__i;}
  args__29774__auto__ = new cljs.core.IndexedSeq(G__38262__a,0,null);
} 
return weathergen$ui$buttons$a_button__delegate.call(this,args__29774__auto__);};
weathergen$ui$buttons$a_button.cljs$lang$maxFixedArity = 0;
weathergen$ui$buttons$a_button.cljs$lang$applyTo = (function (arglist__38263){
var args__29774__auto__ = cljs.core.seq(arglist__38263);
return weathergen$ui$buttons$a_button__delegate(args__29774__auto__);
});
weathergen$ui$buttons$a_button.cljs$core$IFn$_invoke$arity$variadic = weathergen$ui$buttons$a_button__delegate;
return weathergen$ui$buttons$a_button;
})()
;
