asked on
define(['/assets/js/views/app2/custom_checkbox_and_radio.js','jquery'],function(){
return function(){
$('.at_filters label').click(function(){
$(this).siblings('.checkbox').click();
});
$('input[name="filt"]').on('change',function(){
if(this.value=='all'){
if($(this).is(':checked')) $('input[name="filt"]').attr('checked', true);
else $('input[name="filt"]').attr('checked', false);
} else {
$('input[name="filt"][value="all"]').attr('checked', false);
}
var show = [];
var left = true;
$('input[name="filt"]:checked').each(function(){
show.push($(this).val());
});
var year = '';
var month = '';
$('.at_timeline_list li').each(function(){
if($(this).hasClass('yearheader')){
if(year && year.data('delete')) year.slideUp();
else if(year) year.slideDown();
year = $(this);
year.data('delete', true);
} else if($(this).hasClass('monthheader')){
if(month && month.data('delete')) month.slideUp();
else if(month) month.slideDown();
month = $(this);
month.data('delete', true);
} else if($(this).hasClass('event')){
if(show.indexOf($(this).data('type'))!=-1){
$(this).removeClass('left').removeClass('right');
$(this).addClass(left?'left':'right');
left=!left;
if($(this).css('display')!='list-item') $(this).slideDown();
year.data('delete',false);
month.data('delete',false);
} else {
if($(this).css('display')=='list-item') $(this).slideUp();
}
}
});
if(year && year.data('delete')) year.slideUp();
else if(year) year.slideDown();
if(month && month.data('delete')) month.slideUp();
else if(month) month.slideDown();
});
//Account Search
$('input.at_search').keypress(function(e){
if(e.which == 13){
$(this).siblings('.magnificon').click();
}
});
$('.at_searchwrap .magnificon').click(function(){
if(!$('.at_search').val()) return;
pf.ajax({
url:'/app/accounttimeline',
data:{searchfor:$('.at_search').val()},
type:'post',
dataType:'json',
success:function(res){
if(res.success && res.body){
if(res.loadAccount){
pf.apps.loadApp({
appurl:'/app/accounttimeline',
postdata:{accountkey:res.loadAccount},
refresh:new Date()
});
} else pf.dialog(res.body, 'Search Results');
} else {
pf.dialog('There has been an issue processing your request. I apologize for the inconvenience, please try again.', 'Error');
}
}
});
});
setupLabel();
};
});
<div class="at_searchwrap clearfix"><input class="at_search" placeholder="Search by first name, last name, or accountid."/><span class="magnificon"></span></div>
<ul class="at_filters">
<li>
<span class="checkbox">
<input type="checkbox" name="filt" value="all" checked/>
</span><label>All</label>
</li>
<li>
<span class="checkbox">
<input type="checkbox" name="filt" value="transaction" checked/>
</span><label>Transactions</label>
</li>
<li>
<span class="checkbox">
<input type="checkbox" name="filt" value="statement" checked/>
</span><label>Statements</label>
</li>
<li>
<span class="checkbox">
<input type="checkbox" name="filt" value="note" checked/>
</span><label>Notes</label>
</li>
<li>
<span class="checkbox">
<input type="checkbox" name="filt" value="comment" checked/>
</span><label>Task Comments</label>
</li>
<li>
<span class="checkbox">
<input type="checkbox" name="filt" value="personal_payments" checked/>
</span><label>Personal Payments</label>
</li>
</ul>