// 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 args30457 = [];
var len__24559__auto___30476 = arguments.length;
var i__24560__auto___30477 = (0);
while(true){
if((i__24560__auto___30477 < len__24559__auto___30476)){
args30457.push((arguments[i__24560__auto___30477]));

var G__30478 = (i__24560__auto___30477 + (1));
i__24560__auto___30477 = G__30478;
continue;
} else {
}
break;
}

var G__30463 = args30457.length;
switch (G__30463) {
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(args30457.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__30464 = cljs.core.seq.call(null,kvs);
var chunk__30466 = null;
var count__30467 = (0);
var i__30468 = (0);
while(true){
if((i__30468 < count__30467)){
var vec__30470 = cljs.core._nth.call(null,chunk__30466,i__30468);
var k = cljs.core.nth.call(null,vec__30470,(0),null);
var v = cljs.core.nth.call(null,vec__30470,(1),null);
var k_30480__$1 = cljs.core.name.call(null,k);
if(cljs.core.not.call(null,v)){
e.removeAttr(k_30480__$1);
} else {
e.attr(k_30480__$1,((cljs.core._EQ_.call(null,true,v))?k_30480__$1:v));
}

var G__30481 = seq__30464;
var G__30482 = chunk__30466;
var G__30483 = count__30467;
var G__30484 = (i__30468 + (1));
seq__30464 = G__30481;
chunk__30466 = G__30482;
count__30467 = G__30483;
i__30468 = G__30484;
continue;
} else {
var temp__5278__auto__ = cljs.core.seq.call(null,seq__30464);
if(temp__5278__auto__){
var seq__30464__$1 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__30464__$1)){
var c__24249__auto__ = cljs.core.chunk_first.call(null,seq__30464__$1);
var G__30485 = cljs.core.chunk_rest.call(null,seq__30464__$1);
var G__30486 = c__24249__auto__;
var G__30487 = cljs.core.count.call(null,c__24249__auto__);
var G__30488 = (0);
seq__30464 = G__30485;
chunk__30466 = G__30486;
count__30467 = G__30487;
i__30468 = G__30488;
continue;
} else {
var vec__30473 = cljs.core.first.call(null,seq__30464__$1);
var k = cljs.core.nth.call(null,vec__30473,(0),null);
var v = cljs.core.nth.call(null,vec__30473,(1),null);
var k_30489__$1 = cljs.core.name.call(null,k);
if(cljs.core.not.call(null,v)){
e.removeAttr(k_30489__$1);
} else {
e.attr(k_30489__$1,((cljs.core._EQ_.call(null,true,v))?k_30489__$1:v));
}

var G__30490 = cljs.core.next.call(null,seq__30464__$1);
var G__30491 = null;
var G__30492 = (0);
var G__30493 = (0);
seq__30464 = G__30490;
chunk__30466 = G__30491;
count__30467 = G__30492;
i__30468 = G__30493;
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 (seq30458){
var G__30459 = cljs.core.first.call(null,seq30458);
var seq30458__$1 = cljs.core.next.call(null,seq30458);
var G__30460 = cljs.core.first.call(null,seq30458__$1);
var seq30458__$2 = cljs.core.next.call(null,seq30458__$1);
var G__30461 = cljs.core.first.call(null,seq30458__$2);
var seq30458__$3 = cljs.core.next.call(null,seq30458__$2);
return hoplon.jquery.set_attributes_BANG_.cljs$core$IFn$_invoke$arity$variadic(G__30459,G__30460,G__30461,seq30458__$3);
});

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

hoplon.jquery.set_styles_BANG_ = (function hoplon$jquery$set_styles_BANG_(var_args){
var args30494 = [];
var len__24559__auto___30511 = arguments.length;
var i__24560__auto___30512 = (0);
while(true){
if((i__24560__auto___30512 < len__24559__auto___30511)){
args30494.push((arguments[i__24560__auto___30512]));

var G__30513 = (i__24560__auto___30512 + (1));
i__24560__auto___30512 = G__30513;
continue;
} else {
}
break;
}

var G__30500 = args30494.length;
switch (G__30500) {
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(args30494.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__30501 = cljs.core.seq.call(null,kvs);
var chunk__30502 = null;
var count__30503 = (0);
var i__30504 = (0);
while(true){
if((i__30504 < count__30503)){
var vec__30505 = cljs.core._nth.call(null,chunk__30502,i__30504);
var k = cljs.core.nth.call(null,vec__30505,(0),null);
var v = cljs.core.nth.call(null,vec__30505,(1),null);
e.css(cljs.core.name.call(null,k),[cljs.core.str.cljs$core$IFn$_invoke$arity$1(v)].join(''));

var G__30515 = seq__30501;
var G__30516 = chunk__30502;
var G__30517 = count__30503;
var G__30518 = (i__30504 + (1));
seq__30501 = G__30515;
chunk__30502 = G__30516;
count__30503 = G__30517;
i__30504 = G__30518;
continue;
} else {
var temp__5278__auto__ = cljs.core.seq.call(null,seq__30501);
if(temp__5278__auto__){
var seq__30501__$1 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__30501__$1)){
var c__24249__auto__ = cljs.core.chunk_first.call(null,seq__30501__$1);
var G__30519 = cljs.core.chunk_rest.call(null,seq__30501__$1);
var G__30520 = c__24249__auto__;
var G__30521 = cljs.core.count.call(null,c__24249__auto__);
var G__30522 = (0);
seq__30501 = G__30519;
chunk__30502 = G__30520;
count__30503 = G__30521;
i__30504 = G__30522;
continue;
} else {
var vec__30508 = cljs.core.first.call(null,seq__30501__$1);
var k = cljs.core.nth.call(null,vec__30508,(0),null);
var v = cljs.core.nth.call(null,vec__30508,(1),null);
e.css(cljs.core.name.call(null,k),[cljs.core.str.cljs$core$IFn$_invoke$arity$1(v)].join(''));

var G__30523 = cljs.core.next.call(null,seq__30501__$1);
var G__30524 = null;
var G__30525 = (0);
var G__30526 = (0);
seq__30501 = G__30523;
chunk__30502 = G__30524;
count__30503 = G__30525;
i__30504 = G__30526;
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 (seq30495){
var G__30496 = cljs.core.first.call(null,seq30495);
var seq30495__$1 = cljs.core.next.call(null,seq30495);
var G__30497 = cljs.core.first.call(null,seq30495__$1);
var seq30495__$2 = cljs.core.next.call(null,seq30495__$1);
var G__30498 = cljs.core.first.call(null,seq30495__$2);
var seq30495__$3 = cljs.core.next.call(null,seq30495__$2);
return hoplon.jquery.set_styles_BANG_.cljs$core$IFn$_invoke$arity$variadic(G__30496,G__30497,G__30498,seq30495__$3);
});

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

hoplon.jquery.text_val_BANG_ = (function hoplon$jquery$text_val_BANG_(var_args){
var args30527 = [];
var len__24559__auto___30530 = arguments.length;
var i__24560__auto___30531 = (0);
while(true){
if((i__24560__auto___30531 < len__24559__auto___30530)){
args30527.push((arguments[i__24560__auto___30531]));

var G__30532 = (i__24560__auto___30531 + (1));
i__24560__auto___30531 = G__30532;
continue;
} else {
}
break;
}

var G__30529 = args30527.length;
switch (G__30529) {
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(args30527.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 args30534 = [];
var len__24559__auto___30537 = arguments.length;
var i__24560__auto___30538 = (0);
while(true){
if((i__24560__auto___30538 < len__24559__auto___30537)){
args30534.push((arguments[i__24560__auto___30538]));

var G__30539 = (i__24560__auto___30538 + (1));
i__24560__auto___30538 = G__30539;
continue;
} else {
}
break;
}

var G__30536 = args30534.length;
switch (G__30536) {
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(args30534.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__30541__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__30541 = function (elem,_,var_args){
var args = null;
if (arguments.length > 2) {
var G__30542__i = 0, G__30542__a = new Array(arguments.length -  2);
while (G__30542__i < G__30542__a.length) {G__30542__a[G__30542__i] = arguments[G__30542__i + 2]; ++G__30542__i;}
  args = new cljs.core.IndexedSeq(G__30542__a,0,null);
} 
return G__30541__delegate.call(this,elem,_,args);};
G__30541.cljs$lang$maxFixedArity = 2;
G__30541.cljs$lang$applyTo = (function (arglist__30543){
var elem = cljs.core.first(arglist__30543);
arglist__30543 = cljs.core.next(arglist__30543);
var _ = cljs.core.first(arglist__30543);
var args = cljs.core.rest(arglist__30543);
return G__30541__delegate(elem,_,args);
});
G__30541.cljs$core$IFn$_invoke$arity$variadic = G__30541__delegate;
return G__30541;
})()
);
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__30544 = cljs.core.seq.call(null,clmap);
var chunk__30545 = null;
var count__30546 = (0);
var i__30547 = (0);
while(true){
if((i__30547 < count__30546)){
var vec__30548 = cljs.core._nth.call(null,chunk__30545,i__30547);
var c = cljs.core.nth.call(null,vec__30548,(0),null);
var p_QMARK_ = cljs.core.nth.call(null,vec__30548,(1),null);
elem__$1.toggleClass(cljs.core.name.call(null,c),cljs.core.boolean$.call(null,p_QMARK_));

var G__30554 = seq__30544;
var G__30555 = chunk__30545;
var G__30556 = count__30546;
var G__30557 = (i__30547 + (1));
seq__30544 = G__30554;
chunk__30545 = G__30555;
count__30546 = G__30556;
i__30547 = G__30557;
continue;
} else {
var temp__5278__auto__ = cljs.core.seq.call(null,seq__30544);
if(temp__5278__auto__){
var seq__30544__$1 = temp__5278__auto__;
if(cljs.core.chunked_seq_QMARK_.call(null,seq__30544__$1)){
var c__24249__auto__ = cljs.core.chunk_first.call(null,seq__30544__$1);
var G__30558 = cljs.core.chunk_rest.call(null,seq__30544__$1);
var G__30559 = c__24249__auto__;
var G__30560 = cljs.core.count.call(null,c__24249__auto__);
var G__30561 = (0);
seq__30544 = G__30558;
chunk__30545 = G__30559;
count__30546 = G__30560;
i__30547 = G__30561;
continue;
} else {
var vec__30551 = cljs.core.first.call(null,seq__30544__$1);
var c = cljs.core.nth.call(null,vec__30551,(0),null);
var p_QMARK_ = cljs.core.nth.call(null,vec__30551,(1),null);
elem__$1.toggleClass(cljs.core.name.call(null,c),cljs.core.boolean$.call(null,p_QMARK_));

var G__30562 = cljs.core.next.call(null,seq__30544__$1);
var G__30563 = null;
var G__30564 = (0);
var G__30565 = (0);
seq__30544 = G__30562;
chunk__30545 = G__30563;
count__30546 = G__30564;
i__30547 = G__30565;
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);
}));
}));
