// Compiled by ClojureScript 1.9.562 {}
goog.provide('hoplon.jquery');
goog.require('cljs.core');
goog.require('hoplon.core');
hoplon.jquery.set_attributes_BANG_ = (function hoplon$jquery$set_attributes_BANG_(var_args){
var args30355 = [];
var len__24559__auto___30374 = arguments.length;
var i__24560__auto___30375 = (0);
while(true){
if((i__24560__auto___30375 < len__24559__auto___30374)){
args30355.push((arguments[i__24560__auto___30375]));

var G__30376 = (i__24560__auto___30375 + (1));
i__24560__auto___30375 = G__30376;
continue;
} else {
}
break;
}

var G__30361 = args30355.length;
switch (G__30361) {
case 2:
return hoplon.jquery.set_attributes_BANG_.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

break;
default:
var argseq__24582__auto__ = (new cljs.core.IndexedSeq(args30355.slice((3)),(0),null));
return hoplon.jquery.set_attributes_BANG_.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),argseq__24582__auto__);

}
});

hoplon.jquery.set_attributes_BANG_.cljs$core$IFn$_invoke$arity$2 = (function (this$,kvs){
var e = jQuery(this$);
var seq__30362 = cljs.core.seq.call(null,kvs);
var chunk__30364 = null;
var count__30365 = (0);
var i__30366 = (0);
while(true){
if((i__30366 < count__30365)){
var vec__30368 = cljs.core._nth.call(null,chunk__30364,i__30366);
var k = cljs.core.nth.call(null,vec__30368,(0),null);
var v = cljs.core.nth.call(null,vec__30368,(1),null);
var k_30378__$1 = cljs.core.name.call(null,k);
if(cljs.core.not.call(null,v)){
e.removeAttr(k_30378__$1);
} else {
e.attr(k_30378__$1,((cljs.core._EQ_.call(null,true,v))?k_30378__$1:v));
}

var G__30379 = seq__30362;
var G__30380 = chunk__30364;
var G__30381 = count__30365;
var G__30382 = (i__30366 + (1));
seq__30362 = G__30379;
chunk__30364 = G__30380;
count__30365 = G__30381;
i__30366 = G__30382;
continue;
} else {
var temp__5278__auto__ = cljs.core.seq.call(null,seq__30362);
if(temp__5278__auto__){
var seq__30362__$1 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__30362__$1)){
var c__24249__auto__ = cljs.core.chunk_first.call(null,seq__30362__$1);
var G__30383 = cljs.core.chunk_rest.call(null,seq__30362__$1);
var G__30384 = c__24249__auto__;
var G__30385 = cljs.core.count.call(null,c__24249__auto__);
var G__30386 = (0);
seq__30362 = G__30383;
chunk__30364 = G__30384;
count__30365 = G__30385;
i__30366 = G__30386;
continue;
} else {
var vec__30371 = cljs.core.first.call(null,seq__30362__$1);
var k = cljs.core.nth.call(null,vec__30371,(0),null);
var v = cljs.core.nth.call(null,vec__30371,(1),null);
var k_30387__$1 = cljs.core.name.call(null,k);
if(cljs.core.not.call(null,v)){
e.removeAttr(k_30387__$1);
} else {
e.attr(k_30387__$1,((cljs.core._EQ_.call(null,true,v))?k_30387__$1:v));
}

var G__30388 = cljs.core.next.call(null,seq__30362__$1);
var G__30389 = null;
var G__30390 = (0);
var G__30391 = (0);
seq__30362 = G__30388;
chunk__30364 = G__30389;
count__30365 = G__30390;
i__30366 = G__30391;
continue;
}
} else {
return null;
}
}
break;
}
});

hoplon.jquery.set_attributes_BANG_.cljs$core$IFn$_invoke$arity$variadic = (function (this$,k,v,kvs){
return hoplon.jquery.set_attributes_BANG_.call(null,this$,cljs.core.apply.call(null,cljs.core.hash_map,k,v,kvs));
});

hoplon.jquery.set_attributes_BANG_.cljs$lang$applyTo = (function (seq30356){
var G__30357 = cljs.core.first.call(null,seq30356);
var seq30356__$1 = cljs.core.next.call(null,seq30356);
var G__30358 = cljs.core.first.call(null,seq30356__$1);
var seq30356__$2 = cljs.core.next.call(null,seq30356__$1);
var G__30359 = cljs.core.first.call(null,seq30356__$2);
var seq30356__$3 = cljs.core.next.call(null,seq30356__$2);
return hoplon.jquery.set_attributes_BANG_.cljs$core$IFn$_invoke$arity$variadic(G__30357,G__30358,G__30359,seq30356__$3);
});

hoplon.jquery.set_attributes_BANG_.cljs$lang$maxFixedArity = (3);

hoplon.jquery.set_styles_BANG_ = (function hoplon$jquery$set_styles_BANG_(var_args){
var args30392 = [];
var len__24559__auto___30409 = arguments.length;
var i__24560__auto___30410 = (0);
while(true){
if((i__24560__auto___30410 < len__24559__auto___30409)){
args30392.push((arguments[i__24560__auto___30410]));

var G__30411 = (i__24560__auto___30410 + (1));
i__24560__auto___30410 = G__30411;
continue;
} else {
}
break;
}

var G__30398 = args30392.length;
switch (G__30398) {
case 2:
return hoplon.jquery.set_styles_BANG_.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

break;
default:
var argseq__24582__auto__ = (new cljs.core.IndexedSeq(args30392.slice((3)),(0),null));
return hoplon.jquery.set_styles_BANG_.cljs$core$IFn$_invoke$arity$variadic((arguments[(0)]),(arguments[(1)]),(arguments[(2)]),argseq__24582__auto__);

}
});

hoplon.jquery.set_styles_BANG_.cljs$core$IFn$_invoke$arity$2 = (function (this$,kvs){
var e = jQuery(this$);
var seq__30399 = cljs.core.seq.call(null,kvs);
var chunk__30400 = null;
var count__30401 = (0);
var i__30402 = (0);
while(true){
if((i__30402 < count__30401)){
var vec__30403 = cljs.core._nth.call(null,chunk__30400,i__30402);
var k = cljs.core.nth.call(null,vec__30403,(0),null);
var v = cljs.core.nth.call(null,vec__30403,(1),null);
e.css(cljs.core.name.call(null,k),[cljs.core.str.cljs$core$IFn$_invoke$arity$1(v)].join(''));

var G__30413 = seq__30399;
var G__30414 = chunk__30400;
var G__30415 = count__30401;
var G__30416 = (i__30402 + (1));
seq__30399 = G__30413;
chunk__30400 = G__30414;
count__30401 = G__30415;
i__30402 = G__30416;
continue;
} else {
var temp__5278__auto__ = cljs.core.seq.call(null,seq__30399);
if(temp__5278__auto__){
var seq__30399__$1 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__30399__$1)){
var c__24249__auto__ = cljs.core.chunk_first.call(null,seq__30399__$1);
var G__30417 = cljs.core.chunk_rest.call(null,seq__30399__$1);
var G__30418 = c__24249__auto__;
var G__30419 = cljs.core.count.call(null,c__24249__auto__);
var G__30420 = (0);
seq__30399 = G__30417;
chunk__30400 = G__30418;
count__30401 = G__30419;
i__30402 = G__30420;
continue;
} else {
var vec__30406 = cljs.core.first.call(null,seq__30399__$1);
var k = cljs.core.nth.call(null,vec__30406,(0),null);
var v = cljs.core.nth.call(null,vec__30406,(1),null);
e.css(cljs.core.name.call(null,k),[cljs.core.str.cljs$core$IFn$_invoke$arity$1(v)].join(''));

var G__30421 = cljs.core.next.call(null,seq__30399__$1);
var G__30422 = null;
var G__30423 = (0);
var G__30424 = (0);
seq__30399 = G__30421;
chunk__30400 = G__30422;
count__30401 = G__30423;
i__30402 = G__30424;
continue;
}
} else {
return null;
}
}
break;
}
});

hoplon.jquery.set_styles_BANG_.cljs$core$IFn$_invoke$arity$variadic = (function (this$,k,v,kvs){
return hoplon.jquery.set_styles_BANG_.call(null,this$,cljs.core.apply.call(null,cljs.core.hash_map,k,v,kvs));
});

hoplon.jquery.set_styles_BANG_.cljs$lang$applyTo = (function (seq30393){
var G__30394 = cljs.core.first.call(null,seq30393);
var seq30393__$1 = cljs.core.next.call(null,seq30393);
var G__30395 = cljs.core.first.call(null,seq30393__$1);
var seq30393__$2 = cljs.core.next.call(null,seq30393__$1);
var G__30396 = cljs.core.first.call(null,seq30393__$2);
var seq30393__$3 = cljs.core.next.call(null,seq30393__$2);
return hoplon.jquery.set_styles_BANG_.cljs$core$IFn$_invoke$arity$variadic(G__30394,G__30395,G__30396,seq30393__$3);
});

hoplon.jquery.set_styles_BANG_.cljs$lang$maxFixedArity = (3);

hoplon.jquery.text_val_BANG_ = (function hoplon$jquery$text_val_BANG_(var_args){
var args30425 = [];
var len__24559__auto___30428 = arguments.length;
var i__24560__auto___30429 = (0);
while(true){
if((i__24560__auto___30429 < len__24559__auto___30428)){
args30425.push((arguments[i__24560__auto___30429]));

var G__30430 = (i__24560__auto___30429 + (1));
i__24560__auto___30429 = G__30430;
continue;
} else {
}
break;
}

var G__30427 = args30425.length;
switch (G__30427) {
case 1:
return hoplon.jquery.text_val_BANG_.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));

break;
case 2:
return hoplon.jquery.text_val_BANG_.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

break;
default:
throw (new Error([cljs.core.str.cljs$core$IFn$_invoke$arity$1("Invalid arity: "),cljs.core.str.cljs$core$IFn$_invoke$arity$1(args30425.length)].join('')));

}
});

hoplon.jquery.text_val_BANG_.cljs$core$IFn$_invoke$arity$1 = (function (e){
return e.val();
});

hoplon.jquery.text_val_BANG_.cljs$core$IFn$_invoke$arity$2 = (function (e,v){
var v__$1 = [cljs.core.str.cljs$core$IFn$_invoke$arity$1(v)].join('');
if(cljs.core.not_EQ_.call(null,v__$1,hoplon.jquery.text_val_BANG_.call(null,e))){
return e.val(v__$1);
} else {
return null;
}
});

hoplon.jquery.text_val_BANG_.cljs$lang$maxFixedArity = 2;

hoplon.jquery.check_val_BANG_ = (function hoplon$jquery$check_val_BANG_(var_args){
var args30432 = [];
var len__24559__auto___30435 = arguments.length;
var i__24560__auto___30436 = (0);
while(true){
if((i__24560__auto___30436 < len__24559__auto___30435)){
args30432.push((arguments[i__24560__auto___30436]));

var G__30437 = (i__24560__auto___30436 + (1));
i__24560__auto___30436 = G__30437;
continue;
} else {
}
break;
}

var G__30434 = args30432.length;
switch (G__30434) {
case 1:
return hoplon.jquery.check_val_BANG_.cljs$core$IFn$_invoke$arity$1((arguments[(0)]));

break;
case 2:
return hoplon.jquery.check_val_BANG_.cljs$core$IFn$_invoke$arity$2((arguments[(0)]),(arguments[(1)]));

break;
default:
throw (new Error([cljs.core.str.cljs$core$IFn$_invoke$arity$1("Invalid arity: "),cljs.core.str.cljs$core$IFn$_invoke$arity$1(args30432.length)].join('')));

}
});

hoplon.jquery.check_val_BANG_.cljs$core$IFn$_invoke$arity$1 = (function (e){
return e.is(":checked");
});

hoplon.jquery.check_val_BANG_.cljs$core$IFn$_invoke$arity$2 = (function (e,v){
return e.prop("checked",cljs.core.boolean$.call(null,v));
});

hoplon.jquery.check_val_BANG_.cljs$lang$maxFixedArity = 2;

cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword("hoplon.core","default","hoplon.core/default",-778824365),(function (elem,key,val){
return hoplon.core.do_BANG_.call(null,elem,new cljs.core.Keyword(null,"attr","attr",-604132353),cljs.core.PersistentArrayMap.createAsIfByAssoc([key,val]));
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword("css","*","css/*",-1295355419),(function (elem,key,val){
return hoplon.jquery.set_styles_BANG_.call(null,elem,key,val);
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword("html","*","html/*",-1283138243),(function (elem,key,val){
return hoplon.jquery.set_attributes_BANG_.call(null,elem,key,val);
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword("svg","*","svg/*",-1295405562),(function (elem,key,val){
return hoplon.jquery.set_attributes_BANG_.call(null,elem,key,val);
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword("attr","*","attr/*",-1283077225),(function (elem,_,kvs){
return hoplon.jquery.set_attributes_BANG_.call(null,elem,kvs);
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword("prop","*","prop/*",-1283942139),(function (elem,key,val){
var e = jQuery(elem);
return e.prop(cljs.core.name.call(null,key),val);
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword("data","*","data/*",-1283013312),(function (elem,key,val){
var e = jQuery(elem);
return e.data(cljs.core.name.call(null,key),val);
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword(null,"attr","attr",-604132353),(function (elem,_,kvs){
return hoplon.jquery.set_attributes_BANG_.call(null,elem,kvs);
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword(null,"css","css",1135045163),(function (elem,_,kvs){
return hoplon.jquery.set_styles_BANG_.call(null,elem,kvs);
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword(null,"value","value",305978217),(function() { 
var G__30439__delegate = function (elem,_,args){
var e = jQuery(elem);
return cljs.core.apply.call(null,((cljs.core._EQ_.call(null,"checkbox",e.attr("type")))?hoplon.jquery.check_val_BANG_:hoplon.jquery.text_val_BANG_),e,args);
};
var G__30439 = function (elem,_,var_args){
var args = null;
if (arguments.length > 2) {
var G__30440__i = 0, G__30440__a = new Array(arguments.length -  2);
while (G__30440__i < G__30440__a.length) {G__30440__a[G__30440__i] = arguments[G__30440__i + 2]; ++G__30440__i;}
  args = new cljs.core.IndexedSeq(G__30440__a,0,null);
} 
return G__30439__delegate.call(this,elem,_,args);};
G__30439.cljs$lang$maxFixedArity = 2;
G__30439.cljs$lang$applyTo = (function (arglist__30441){
var elem = cljs.core.first(arglist__30441);
arglist__30441 = cljs.core.next(arglist__30441);
var _ = cljs.core.first(arglist__30441);
var args = cljs.core.rest(arglist__30441);
return G__30439__delegate(elem,_,args);
});
G__30439.cljs$core$IFn$_invoke$arity$variadic = G__30439__delegate;
return G__30439;
})()
);
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword(null,"class","class",-2030961996),(function (elem,_,kvs){
var elem__$1 = jQuery(elem);
var clmap = hoplon.core.normalize_class.call(null,kvs);
var seq__30442 = cljs.core.seq.call(null,clmap);
var chunk__30443 = null;
var count__30444 = (0);
var i__30445 = (0);
while(true){
if((i__30445 < count__30444)){
var vec__30446 = cljs.core._nth.call(null,chunk__30443,i__30445);
var c = cljs.core.nth.call(null,vec__30446,(0),null);
var p_QMARK_ = cljs.core.nth.call(null,vec__30446,(1),null);
elem__$1.toggleClass(cljs.core.name.call(null,c),cljs.core.boolean$.call(null,p_QMARK_));

var G__30452 = seq__30442;
var G__30453 = chunk__30443;
var G__30454 = count__30444;
var G__30455 = (i__30445 + (1));
seq__30442 = G__30452;
chunk__30443 = G__30453;
count__30444 = G__30454;
i__30445 = G__30455;
continue;
} else {
var temp__5278__auto__ = cljs.core.seq.call(null,seq__30442);
if(temp__5278__auto__){
var seq__30442__$1 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__30442__$1)){
var c__24249__auto__ = cljs.core.chunk_first.call(null,seq__30442__$1);
var G__30456 = cljs.core.chunk_rest.call(null,seq__30442__$1);
var G__30457 = c__24249__auto__;
var G__30458 = cljs.core.count.call(null,c__24249__auto__);
var G__30459 = (0);
seq__30442 = G__30456;
chunk__30443 = G__30457;
count__30444 = G__30458;
i__30445 = G__30459;
continue;
} else {
var vec__30449 = cljs.core.first.call(null,seq__30442__$1);
var c = cljs.core.nth.call(null,vec__30449,(0),null);
var p_QMARK_ = cljs.core.nth.call(null,vec__30449,(1),null);
elem__$1.toggleClass(cljs.core.name.call(null,c),cljs.core.boolean$.call(null,p_QMARK_));

var G__30460 = cljs.core.next.call(null,seq__30442__$1);
var G__30461 = null;
var G__30462 = (0);
var G__30463 = (0);
seq__30442 = G__30460;
chunk__30443 = G__30461;
count__30444 = G__30462;
i__30445 = G__30463;
continue;
}
} else {
return null;
}
}
break;
}
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword(null,"toggle","toggle",1291842030),(function (elem,_,v){
return jQuery(elem).toggle(cljs.core.boolean$.call(null,v));
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword(null,"slide-toggle","slide-toggle",968641513),(function (elem,_,v){
if(cljs.core.truth_(v)){
return jQuery(elem).hide().slideDown("fast");
} else {
return jQuery(elem).slideUp("fast");
}
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword(null,"fade-toggle","fade-toggle",-1468421852),(function (elem,_,v){
if(cljs.core.truth_(v)){
return jQuery(elem).hide().fadeIn("fast");
} else {
return jQuery(elem).fadeOut("fast");
}
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword(null,"focus","focus",234677911),(function (elem,_,v){
return setTimeout((function (){
if(cljs.core.truth_(v)){
return jQuery(elem).focus();
} else {
return jQuery(elem).focusout();
}
}),(0));
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword(null,"select","select",1147833503),(function (elem,_,___$1){
return jQuery(elem).select();
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword(null,"focus-select","focus-select",1107982934),(function (elem,_,v){
if(cljs.core.truth_(v)){
hoplon.core.do_BANG_.call(null,elem,new cljs.core.Keyword(null,"focus","focus",234677911),v);

return hoplon.core.do_BANG_.call(null,elem,new cljs.core.Keyword(null,"select","select",1147833503),v);
} else {
return null;
}
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword(null,"text","text",-1790561697),(function (elem,_,v){
return jQuery(elem).text([cljs.core.str.cljs$core$IFn$_invoke$arity$1(v)].join(''));
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword(null,"html","html",-998796897),(function (elem,_,v){
return jQuery(elem).html(v);
}));
cljs.core._add_method.call(null,hoplon.core.do_BANG_,new cljs.core.Keyword(null,"scroll-to","scroll-to",-34957602),(function (elem,_,v){
if(cljs.core.truth_(v)){
var body = jQuery("body,html");
var elem__$1 = jQuery(elem);
return body.animate(cljs.core.clj__GT_js.call(null,new cljs.core.PersistentArrayMap(null, 1, [new cljs.core.Keyword(null,"scrollTop","scrollTop",-1143661921),elem__$1.offset().top], null)));
} else {
return null;
}
}));
jQuery.Event.prototype.cljs$core$IDeref$ = cljs.core.PROTOCOL_SENTINEL;

jQuery.Event.prototype.cljs$core$IDeref$_deref$arity$1 = (function (this$){
var this$__$1 = this;
return jQuery(this$__$1.target).val();
});
cljs.core._add_method.call(null,hoplon.core.on_BANG_,new cljs.core.Keyword("hoplon.core","default","hoplon.core/default",-778824365),(function (elem,event,callback){
return hoplon.core.when_dom.call(null,elem,(function (){
return jQuery(elem).on(cljs.core.name.call(null,event),callback);
}));
}));
cljs.core._add_method.call(null,hoplon.core.on_BANG_,new cljs.core.Keyword("html","*","html/*",-1283138243),(function (elem,event,callback){
return hoplon.core.when_dom.call(null,elem,(function (){
return jQuery(elem).on(cljs.core.name.call(null,event),callback);
}));
}));
